Measuring what exactness loses
Homological algebra began in topology. To detect the "holes" of a space, Poincaré counted closed loops and surfaces (cycles) that do not bound anything, treating those that bound (boundaries) as trivial. Algebraically this is a sequence of groups and maps with — "the boundary of a boundary is empty" — and the invariant is the quotient , the homology.
The same structure appears throughout algebra, for a different reason. The functors , and are not exact: they turn some short exact sequences into sequences that are exact only at one end (see modules). Homological algebra measures the failure precisely. Each such functor comes with a sequence of derived functors — for , for — that repair the lost exactness in a long exact sequence. These groups answer concrete questions:
- classifies the ways of building a module with submodule and quotient ;
- is the -torsion of — hence the name;
- the homology of with coefficients in differs from that with coefficients in , by an amount computed by .
This lesson assumes modules, exact sequences and functors. The snake lemma is proved in abelian categories; here we use it. Everything works in any abelian category with enough projectives (or injectives); for concreteness we work with modules over a ring .
Cycles, boundaries and resolutions
Take the boundary of a triangle: vertices and oriented edges . Let (edges) and (vertices), with . The chain goes once around the triangle and has : it is a cycle. With no 2-cell to fill the triangle, it is not a boundary, and detects the hole. Fill the triangle with a 2-cell , , and becomes .
The same quotient measures failure of exactness. A sequence with composite is exact exactly when its homology vanishes. To measure how far a functor is from exact, homological algebra replaces a module by a projective resolution — an exact sequence of projective (for instance free) modules: generators, relations among the generators, relations among the relations, and so on. The resolution is a complex with homology only in degree . Apply to the and take homology: if were exact, the result would again be just in degree ; the higher homology groups measure exactly what fails to preserve. The comparison theorem below says the answer does not depend on which resolution we chose.
Definitions
Definition— chain complex, homology
A chain complex is a sequence of modules and homomorphisms with for all . Its cycles are , its boundaries , and its homology is . A cochain complex has differentials raising the degree, , and cohomology . A complex is exact (acyclic) if all its homology vanishes.
Definition— chain map, quasi-isomorphism, chain homotopy
A chain map is a family with ; it sends cycles to cycles and boundaries to boundaries, so it induces . It is a quasi-isomorphism if every is an isomorphism. Two chain maps are chain homotopic, , if there are maps with
A homotopy equivalence is a chain map with a chain map such that and .
Definition— short exact sequence of complexes
A sequence of chain maps is short exact if is exact for every .
Definition— projective and injective resolutions
A projective resolution of is a complex of projective modules ( for ) with a map such that is exact. Every module has one: take free on generators of , then free on generators of , and so on. An injective resolution is the dual notion, with the injective; every module has one. The projective dimension of is the shortest length of a projective resolution (possibly ); the global dimension of is the supremum of the projective dimensions of all modules.
Definition— derived functors; Tor and Ext
Let be an additive functor from -modules to abelian groups. If is covariant and right exact, its left derived functors are for a projective resolution . If is contravariant and left exact, its right derived functors are . In particular
Equivalently, for an injective resolution , and may be computed by resolving either variable ("balance"; Weibel, §2.7). For non-commutative , is a right and a left module in .
Definition— extension; equivalence
An extension of by is a short exact sequence . Two extensions are equivalent if there is a homomorphism making both squares commute (it is then an isomorphism by the five lemma). The split extension is .
Examples
Example— A complex with torsion homology
The real projective plane is a square with boundary word : one 2-cell , two edges , and two vertices ( runs from to , from to ). Its cellular chain complex is
Then and , so ; ; and . With coefficients, and has rank , so for . (Formalised in part below; computed for four surfaces in the second experiment.)
Example— Resolutions
- Over : . Every abelian group has a free resolution of length (subgroups of free abelian groups are free), so has global dimension .
- Over : .
- Over , the Koszul resolution of :
- Over , the module has the infinite periodic resolution , and no finite one: has infinite global dimension.
Example— Tor and Ext over ℤ
Resolve by . Tensoring with gives , and gives as well, so
and all higher groups vanish. For each of these is cyclic of order ; for : and . In general is the -torsion subgroup of — the origin of the name "Tor".
Example— Tor and Ext over k[x] and ℤ/4
Over , with , the resolution above gives , which is multiplication by on . So if , and otherwise: the two points must coincide to interact. Over , the periodic resolution gives for every : derived functors over a ring of infinite global dimension need not stop.
The main theorems
Theorem— Theorem 1 (long exact homology sequence)
A short exact sequence of chain complexes induces an exact sequence
in which the connecting homomorphism is where and .
Proof
Apply the snake lemma to the map of short exact sequences . Its kernel part says that is exact; applied to , its cokernel part says that is exact. Since , the differential induces maps , and similarly for and , giving a commutative diagram with exact rows
The kernel of is and its cokernel is , and likewise for and . The snake lemma now gives the exact sequence , and these six-term pieces overlap to form the long exact sequence. Unwinding the snake's construction: lift a cycle to ; then , so for a unique , which is a cycle because and is injective; and .
∎
Theorem— Theorem 2 (homotopy invariance)
If , then for all . Hence a homotopy equivalence is a quasi-isomorphism, and additive functors, which preserve chain homotopies, send homotopy equivalences to homotopy equivalences.
Proof
For a cycle , is a boundary, so . If is additive, applying it to gives .
∎
Theorem— Theorem 3 (comparison theorem)
Let be a complex of projective modules over (that is, for and is a complex), and a resolution (exact, not necessarily projective). Then every homomorphism lifts to a chain map compatible with the augmentations, and any two such lifts are chain homotopic.
Proof
Existence. lifts through the surjection because is projective; call the lift . Suppose have been built with (and ). The map lands in (with ): indeed , or when . By exactness of , that kernel is the image of , so projectivity of gives with .
Uniqueness up to homotopy. Let be two lifts and , a lift of . We build with , starting from . Since , lands in ; lift to with . Inductively, lands in , because
and so, by exactness and projectivity of , it equals for some .
∎
Theorem— Corollary 4 (derived functors are well defined)
Any two projective resolutions of are homotopy equivalent, by a homotopy equivalence lifting that is unique up to homotopy. Consequently , and do not depend on the resolution, up to canonical isomorphism, and are functorial in . Moreover:
- for right exact , so ; and ;
- for if is projective; so ;
- a short exact sequence gives long exact sequences
Proof
If resolve , Theorem 3 gives lifts and of ; and both lift , so by uniqueness, and likewise . By Theorem 2, and have canonically isomorphic homology. (1): is exact and is right exact, so ; dually for . (2): resolves itself (, otherwise). (3): The horseshoe lemma builds projective resolutions , , forming a short exact sequence of complexes that is split in each degree (since is projective). Additive functors preserve split exact sequences, so is short exact, and Theorem 1 gives the long exact sequence (Weibel, Lemma 2.2.8 and Theorem 2.4.6).
∎
Theorem— Theorem 5 (Ext¹ classifies extensions)
There is a bijection between equivalence classes of extensions and , under which the split extension corresponds to . In particular every extension of by splits if and only if .
Proof
Choose a short exact sequence with projective. Its long exact sequence, with , gives
From extensions to classes. Given , lift through to (projectivity). Then , so for a unique . Another lift is with , changing to ; so the class is well defined, and equivalent extensions give the same class.
From classes to extensions. Given , let be the pushout , with , , and , . A diagram chase shows is exact, and replacing by gives an equivalent extension, via the map , .
They are inverse. For , the lift satisfies , so . Conversely, for an extension with lift and class , the map , , is well defined and compatible with both ends, hence an equivalence. Finally, iff for some , iff the lift vanishes on and so factors through as a section of , iff splits.
∎
Under this bijection, has two elements: the split extension and . The group structure on corresponds to the Baer sum of extensions (Baer, 1934). Higher classify -fold exact sequences up to a suitable equivalence (Yoneda).
Theorem— Theorem 6 (three landmarks; stated)
- Universal coefficient theorem. For a chain complex of free abelian groups and an abelian group there are natural short exact sequences, split but not naturally,
- Hilbert's syzygy theorem (1890). Every finitely generated module over has a free resolution of length at most ; the global dimension of is exactly .
- Auslander–Buchsbaum–Serre (1956). A Noetherian local ring is regular if and only if it has finite global dimension.
Proofs: Hatcher, Algebraic Topology, Theorem 3A.3, or Weibel, Theorem 3.6.2 (universal coefficients); Weibel, §4.3–4.4, and Eisenbud, Chapter 19 (syzygies and regular rings). The third theorem is a striking use of homological algebra in commutative algebra: it shows at once that localisations of regular local rings are regular, which had resisted direct attack.
Explore: chain complexes of glued squares
Each surface below is a square with its sides glued in pairs. Its cellular chain complex has one 2-cell , one 1-cell for each letter, and one 0-cell for each class of glued corners, and the boundary of is read off the word: is the sum of the letters, with sign for an inverse. So:
- torus : , so and ;
- Klein bottle : , so and ;
- projective plane : , so and ;
- sphere : and three vertices, so , .
Walk the flatlander across the seams. Exactly on the non-orientable surfaces it comes back mirror-reversed — and exactly there , so the 2-cell is not a cycle over and acquires the torsion . Over the coefficient vanishes, and every one of these closed surfaces has , as the universal coefficient theorem predicts: for the Klein bottle and this class comes from .
Gluing words and boundary maps
Where the flag flips, the boundary of the 2-cell is not zero.
Keys: ↑ forward, ↓ back, ← and → turn, Space walks or stops. You can also drag it.
- Orientable
- No
- Euler characteristic
- χ = 1
Gluing turns the 4 corners into V = 2, the 4 sides into E = 2 and the square into F = 1: V − E + F = 2 − 2 + 1 = 1
Same way round as at the start.
Sides crossed so far: 0
Both pairs of opposite sides are glued with a twist. This is the real projective plane: non-orientable, with χ = 1. Like the Klein bottle, it cannot sit in 3D space without passing through itself.
The second experiment builds these chain complexes from the words and computes all their homology groups.
Homological algebra in Lean and Mathlib
We begin with the chain complex of as integer matrices, verify , and prove that contains an element of order exactly : the cycle is not a boundary, but twice it is.
/-- The cellular boundary `d₂ : ℤ → ℤ²` of the real projective plane, glued from a square with
boundary word `a b a b`: the 2-cell runs along `a` twice and `b` twice, so `d₂(F) = 2a + 2b`. -/
def rp2_d2 : Matrix (Fin 2) (Fin 1) ℤ := !![2; 2]/-- The cellular boundary `d₁ : ℤ² → ℤ²` (edges `a, b` to vertices `v, w`): `a` runs from `v` to
`w` and `b` from `w` back to `v`, so `d₁(a) = w - v` and `d₁(b) = v - w`. Columns are edges. -/
def rp2_d1 : Matrix (Fin 2) (Fin 2) ℤ := !![-1, 1; 1, -1]/-- **`d ∘ d = 0`**: the boundary of the boundary vanishes, `d₁(2a + 2b) = 2(w - v) + 2(v - w)`.
A direct matrix computation. -/
theorem rp2_dd : rp2_d1 * rp2_d2 = 0 := by
ext i j
fin_cases i <;> fin_cases j <;> simp [rp2_d1, rp2_d2, Matrix.mul_apply, Fin.sum_univ_two]/-- **`H₁(ℝP²)` has a non-trivial element of order `2`.** The chain `a + b` is a cycle
(`d₁(a + b) = 0`), it is not a boundary (boundaries `d₂(n) = (2n, 2n)` have even coordinates), but
twice it is the boundary `d₂(1)`. So its class in `H₁ = ker d₁ / im d₂` is non-zero with order
`2`; the experiment computes `H₁(ℝP²; ℤ) ≅ ℤ/2` completely. -/
theorem rp2_torsion_cycle :
rp2_d1.mulVec ![1, 1] = 0 ∧ (∀ n : Fin 1 → ℤ, rp2_d2.mulVec n ≠ ![1, 1]) ∧
rp2_d2.mulVec ![1] = 2 • ![1, 1] := by
refine ⟨?_, ?_, ?_⟩
· ext i
fin_cases i <;> simp [rp2_d1, Matrix.mulVec, dotProduct, Fin.sum_univ_two]
· intro n h
have h0 := congrFun h 0
simp [rp2_d2, Matrix.mulVec, dotProduct] at h0
omega
· ext i
fin_cases i <;> simp [rp2_d2, Matrix.mulVec, dotProduct]Next, the computation behind two misconceptions: there are no non-zero homomorphisms , so the extension does not split (its class in is non-zero), and the quasi-isomorphism from to has no inverse chain map.
/-- **`Hom(ℤ/2, ℤ) = 0`.** If `f : ℤ/2 → ℤ` is additive then `2 f(1) = f(1 + 1) = f(0) = 0`, so
`f(1) = 0`, and `f` vanishes on both elements of `ℤ/2`. -/
theorem hom_zmod_two_int (f : ZMod 2 →+ ℤ) : f = 0 := by
have h1 : f 1 = 0 := by
have h : f 1 + f 1 = 0 := by
rw [← map_add]
have : (1 : ZMod 2) + 1 = 0 := rfl
rw [this, map_zero]
omega
ext x
have hx : x = 0 ∨ x = 1 := by
revert x
decide
rcases hx with rfl | rfl
· simp
· simp [h1]/-- **The extension `0 → ℤ --2·--> ℤ → ℤ/2 → 0` does not split**: reduction mod `2` has no
additive section, because the only homomorphism `ℤ/2 → ℤ` is zero. Equivalently, the chain map
from the complex `[ℤ --2·--> ℤ]` to `ℤ/2` (in degree `0`) is a quasi-isomorphism with no chain map
going back that induces the inverse on homology: in degree `0` such a map would be a section
`ℤ/2 → ℤ`. -/
theorem not_split : ¬ ∃ s : ZMod 2 →+ ℤ, ∀ x : ZMod 2, ((s x : ℤ) : ZMod 2) = x := by
rintro ⟨s, hs⟩
have h := hs 1
rw [hom_zmod_two_int s] at h
exact absurd h (by decide)The resolution computation of and , as a kernel and a cokernel of multiplication by on , decided by evaluation:
/-- **`Tor₁(ℤ/4, ℤ/6)` has `2` elements.** Resolve `ℤ/4` by `0 → ℤ --4·--> ℤ → ℤ/4 → 0`, tensor
with `ℤ/6` to get `ℤ/6 --4·--> ℤ/6`; `Tor₁` is the kernel of this map. A finite computation:
the kernel is `{0, 3}`, with `gcd(4, 6) = 2` elements. -/
theorem tor_four_six : (Finset.univ.filter (fun x : ZMod 6 => 4 * x = 0)).card = 2 := by
decide/-- **`Ext¹(ℤ/4, ℤ/6)` has `2` elements.** Applying `Hom(−, ℤ/6)` to the same resolution gives
`ℤ/6 --4·--> ℤ/6` again, and `Ext¹` is its cokernel: the image `{0, 2, 4}` has index `2`. -/
theorem ext_four_six : (Finset.univ.image (fun x : ZMod 6 => 4 * x)).card * 2 = 6 := by
decideMathlib develops homological algebra in an arbitrary abelian category. Its long exact sequence is built from the snake lemma, exactly as in Theorem 1; homotopy invariance, the comparison theorem and as a derived functor are all there:
/-- **The long exact sequence, at the connecting map.** For a short exact sequence of chain
complexes `0 → X₁ → X₂ → X₃ → 0` and indices with `c.Rel i j`, the sequence
`Hᵢ(X₂) → Hᵢ(X₃) --δ--> Hⱼ(X₁)` is exact. Mathlib: `ShortComplex.ShortExact.homology_exact₃`;
`δ` is built from the snake lemma, as in the lesson. -/
theorem long_exact_connecting {ι : Type*} {c : ComplexShape ι}
{S : ShortComplex (HomologicalComplex C c)} (hS : S.ShortExact) (i j : ι) (hij : c.Rel i j) :
(ShortComplex.mk _ _ (hS.comp_δ i j hij)).Exact :=
hS.homology_exact₃ i j hij/-- **The long exact sequence, after the connecting map**: `Hᵢ(X₃) --δ--> Hⱼ(X₁) → Hⱼ(X₂)` is
exact. Mathlib: `ShortComplex.ShortExact.homology_exact₁`. -/
theorem long_exact_after_connecting {ι : Type*} {c : ComplexShape ι}
{S : ShortComplex (HomologicalComplex C c)} (hS : S.ShortExact) (i j : ι) (hij : c.Rel i j) :
(ShortComplex.mk _ _ (hS.δ_comp i j hij)).Exact :=
hS.homology_exact₁ i j hij/-- **Chain-homotopic maps induce the same map on homology.** Mathlib: `Homotopy.homologyMap_eq`. -/
theorem homotopy_invariance {ι : Type*} {c : ComplexShape ι} {K L : HomologicalComplex C c}
{f g : K ⟶ L} (h : Homotopy f g) (i : ι) :
HomologicalComplex.homologyMap f i = HomologicalComplex.homologyMap g i :=
h.homologyMap_eq i/-- **The comparison theorem**: any two projective resolutions of the same object are chain
homotopy equivalent (via lifts of the identity, unique up to homotopy). Mathlib:
`ProjectiveResolution.homotopyEquiv`, built from `ProjectiveResolution.lift` and
`ProjectiveResolution.liftHomotopy`. -/
theorem comparison {X : C} (P Q : ProjectiveResolution X) :
Nonempty (HomotopyEquiv P.complex Q.complex) :=
⟨ProjectiveResolution.homotopyEquiv P Q⟩/-- **`Ext` does not depend on the resolution**: `Extⁿ(X, Y)` is the `n`-th cohomology of
`Hom(P•, Y)` for *any* projective resolution `P• → X`. Mathlib defines `Ext R C n` as a derived
functor and proves this as `ProjectiveResolution.isoExt`. -/
theorem ext_via_resolution (R : Type*) [Ring R] [Linear R C] [EnoughProjectives C] {X : C}
(P : ProjectiveResolution X) (n : ℕ) (Y : C) :
Nonempty (((Ext R C n).obj (Opposite.op X)).obj Y ≅
(P.complex.linearYonedaObj R Y).homology n) :=
⟨P.isoExt n Y⟩/-- **Projectives have no higher Ext**: `Extⁿ⁺¹(P, Y) = 0` for projective `P` (resolve `P` by
itself). Mathlib: `isZero_Ext_succ_of_projective`. -/
theorem ext_projective (R : Type*) [Ring R] [Linear R C] [EnoughProjectives C] (X Y : C)
[Projective X] (n : ℕ) : IsZero (((Ext R C (n + 1)).obj (Opposite.op X)).obj Y) :=
isZero_Ext_succ_of_projective X Y nWhat is and is not formalised. Proved here: for and an element of order in ; and the non-splitting of ; the sizes of and as a kernel and cokernel. From Mathlib: the long exact sequence, homotopy invariance, the comparison theorem, the independence of from the resolution, and the vanishing of on projectives. Not formalised here: the full computation as a quotient module, Theorem 5 (Mathlib relates in the derived category to short exact sequences, but we do not use it), the universal coefficient theorem, and the general formula , which the first experiment checks for .
Tor, Ext and homology, computed
The first experiment computes , , and of and from the resolution for all , then recomputes from a different, non-minimal resolution — a concrete instance of Corollary 4.
"""Tor and Ext of cyclic groups from projective resolutions, two ways.
Z/m has the free resolution 0 -> Z --m--> Z -> Z/m -> 0. Tensoring with Z/n
gives the complex Z/n --m--> Z/n, whose homology is Tor_1 (kernel) and
Tor_0 = Z/m (x) Z/n (cokernel); applying Hom(-, Z/n) gives the same map, whose
kernel is Hom(Z/m, Z/n) and cokernel Ext^1(Z/m, Z/n). We count kernels and
cokernels by brute force and compare with gcd(m, n). Then we redo Tor_1 with
a different, non-minimal resolution 0 -> Z^2 --A--> Z^2 -> Z/m -> 0 and check
that the answer does not change, as the comparison theorem predicts.
Exact finite arithmetic, exhaustive in the stated range.
"""
from itertools import product
from math import gcd
def kernel_size(m, n):
"""Number of x in Z/n with m x = 0."""
return sum(1 for x in range(n) if m * x % n == 0)
def cokernel_size(m, n):
"""|Z/n / m(Z/n)|."""
return n // len({m * x % n for x in range(n)})
def tor1_from_matrix(a, n):
"""Kernel size of the integer matrix a (2x2) acting on (Z/n)^2."""
count = 0
for x, y in product(range(n), repeat=2):
u = (a[0][0] * x + a[0][1] * y) % n
v = (a[1][0] * x + a[1][1] * y) % n
count += u == 0 and v == 0
return count
def second_resolution(m):
"""A 2x2 integer matrix with cokernel Z/m: relations (m, 0) and (3, 1)."""
return [[m, 3], [0, 1]]
def main():
limit = 20
pairs = [(m, n) for m in range(1, limit + 1) for n in range(1, limit + 1)]
ker_ok = sum(kernel_size(m, n) == gcd(m, n) for m, n in pairs)
cok_ok = sum(cokernel_size(m, n) == gcd(m, n) for m, n in pairs)
alt_ok = sum(tor1_from_matrix(second_resolution(m), n) == gcd(m, n)
for m, n in pairs)
print(f"All {len(pairs)} pairs 1 <= m, n <= {limit}; Z/n (x) - and "
"Hom(-, Z/n) give Z/n --m--> Z/n:")
print(f" kernel = Tor_1 = Hom(Z/m, Z/n) has gcd(m, n) elements: {ker_ok}")
print(f" cokernel = Tor_0 = Ext^1(Z/m, Z/n) has gcd(m, n) elements: "
f"{cok_ok}")
print(f" Tor_1 from the resolution Z^2 --A--> Z^2, A = [[m, 3], [0, 1]]: "
f"{alt_ok}")
print("Examples (|kernel|, |cokernel|):")
for m, n in [(4, 6), (2, 2), (3, 5), (12, 18)]:
print(f" m = {m}, n = {n}: {kernel_size(m, n)}, {cokernel_size(m, n)}")
print("Ext^1(Z/n, Z) = Z / nZ, so Ext^1(Z/2, Z) has 2 elements: the split")
print(" extension Z + Z/2 and the non-split 0 -> Z --2--> Z -> Z/2 -> 0.")
print()
print("Epistemic status: exact and exhaustive for m, n <= 20, using one "
"particular\nsecond resolution. It illustrates the comparison "
"theorem and the formula\nTor_1(Z/m, Z/n) = Z/gcd(m, n); both are "
"proved in the lesson for all m, n.")
if __name__ == "__main__":
main()The second builds the cellular chain complexes of the four glued squares from the visualisation, computes their homology over (with torsion, by Smith normal form), over , and , and checks the universal coefficient theorem and the Euler characteristic in every case.
"""Cellular homology of four surfaces, and the universal coefficient theorem.
Glue the sides of a square in pairs by a word such as "a b a' b'" (a' is a
inverse, read counter-clockwise from the bottom-left corner). This gives a
cell complex with one 2-cell, the distinct edge letters as 1-cells and the
classes of identified corners as 0-cells, with cellular chain complex
Z --d2--> Z^E --d1--> Z^V. We build d2 and d1 from the word, check d1 d2 = 0,
and compute homology over Z (Smith normal form: Betti numbers and torsion),
over F_2, F_3 and over Q (ranks). Then we check the universal coefficient
theorem dim H_n(X; F_p) = b_n + t_n(p) + t_(n-1)(p), where t_n(p) counts the
torsion factors of H_n(X; Z) divisible by p, and the Euler characteristic.
"""
from fractions import Fraction
WORDS = {
"torus": "a b a' b'",
"Klein bottle": "a b a' b",
"sphere": "a a' b b'",
"projective plane": "a b a b",
}
def cell_complex(word):
"""(d2, d1) as integer matrices (lists of rows) for a square gluing word."""
sides = [(s[0], -1 if s.endswith("'") else 1) for s in word.split()]
letters = sorted({s for s, _ in sides})
parent = list(range(4)) # corners 0..3, union-find
def find(c):
while parent[c] != c:
c = parent[c]
return c
ends = {} # letter -> (tail, head) corners
for k, (s, e) in enumerate(sides):
tail, head = (k, (k + 1) % 4) if e == 1 else ((k + 1) % 4, k)
if s in ends:
for old, new in zip(ends[s], (tail, head)):
parent[find(old)] = find(new)
else:
ends[s] = (tail, head)
vertices = sorted({find(c) for c in range(4)})
d2 = [[sum(e for s, e in sides if s == letter)] for letter in letters]
d1 = [[0] * len(letters) for _ in vertices]
for j, letter in enumerate(letters):
tail, head = ends[letter]
d1[vertices.index(find(head))][j] += 1
d1[vertices.index(find(tail))][j] -= 1
return d2, d1
def matmul(a, b):
"""Product of integer matrices given as lists of rows."""
return [[sum(x * y for x, y in zip(row, col)) for col in zip(*b)]
for row in a]
def rank(mat, p=None):
"""Rank over F_p (p prime) or over Q (p = None)."""
rows = [[Fraction(v) if p is None else v % p for v in r] for r in mat]
r, cols = 0, len(rows[0]) if rows else 0
for c in range(cols):
piv = next((i for i in range(r, len(rows)) if rows[i][c] != 0), None)
if piv is None:
continue
rows[r], rows[piv] = rows[piv], rows[r]
inv = 1 / rows[r][c] if p is None else pow(rows[r][c], p - 2, p)
rows[r] = [v * inv if p is None else v * inv % p for v in rows[r]]
for i in range(len(rows)):
if i != r and rows[i][c] != 0:
k = rows[i][c]
rows[i] = [(a - k * b) if p is None else (a - k * b) % p
for a, b in zip(rows[i], rows[r])]
r += 1
return r
def smith_diagonal(matrix):
"""Smith normal form diagonal (d1 | d2 | ...) of an integer matrix."""
a = [list(row) for row in matrix]
m, n = len(a), len(a[0]) if a else 0
diag = []
for t in range(min(m, n)):
cells = [(abs(a[i][j]), i, j) for i in range(t, m)
for j in range(t, n) if a[i][j]]
if not cells:
break
while True:
_, i, j = min(cells)
a[t], a[i] = a[i], a[t]
for row in a:
row[t], row[j] = row[j], row[t]
done = True
for i in range(t + 1, m):
q = a[i][t] // a[t][t]
a[i] = [x - q * y for x, y in zip(a[i], a[t])]
done &= a[i][t] == 0
for j in range(t + 1, n):
q = a[t][j] // a[t][t]
for row in a:
row[j] -= q * row[t]
done &= a[t][j] == 0
bad = [i for i in range(t + 1, m) for j in range(t + 1, n)
if a[i][j] % a[t][t]]
if done and bad:
a[t] = [x + y for x, y in zip(a[t], a[bad[0]])]
done = False
if done:
break
cells = [(abs(a[i][j]), i, j) for i in range(t, m)
for j in range(t, n) if a[i][j]]
diag.append(abs(a[t][t]))
return diag
def torsion(mat):
"""Invariant factors > 1 of an integer matrix: the torsion of its cokernel."""
return [d for d in smith_diagonal(mat) if d > 1]
def homology(word, p=None):
"""Betti numbers (b0, b1, b2) over Q or F_p, plus integral torsion."""
d2, d1 = cell_complex(word)
v, e = len(d1), len(d2)
r1, r2 = rank(d1, p), rank(d2, p)
betti = (v - r1, e - r1 - r2, 1 - r2)
return betti, {0: torsion(d1), 1: torsion(d2), 2: []}
def main():
print("Surface V E F d1d2=0 H_0, H_1, H_2 over Z chi")
uct_ok = True
for name, word in WORDS.items():
d2, d1 = cell_complex(word)
zero = all(x == 0 for row in matmul(d1, d2) for x in row)
b, tors = homology(word)
groups = []
for n in range(3):
parts = ["Z"] * b[n] + [f"Z/{t}" for t in tors[n]]
groups.append(" + ".join(parts) or "0")
chi = len(d1) - len(d2) + 1
print(f"{name:18} {len(d1)} {len(d2)} 1 {str(zero):6} "
f"{', '.join(groups):26} {chi}")
for p in (2, 3):
bp, _ = homology(word, p)
t = [sum(1 for f in tors[n] if f % p == 0) for n in range(3)]
predicted = tuple(b[n] + t[n] + (t[n - 1] if n else 0)
for n in range(3))
uct_ok = uct_ok and bp == predicted
uct_ok = uct_ok and chi == bp[0] - bp[1] + bp[2] == b[0] - b[1] + b[2]
print("Betti numbers over F_2 for the Klein bottle and RP^2:",
homology(WORDS["Klein bottle"], 2)[0],
homology(WORDS["projective plane"], 2)[0])
print("Universal coefficients over F_2, F_3 and chi = V - E + F agree:",
uct_ok)
print()
print("Epistemic status: exact integer and modular arithmetic for four "
"small cell\ncomplexes; it confirms the theorems in these cases "
"only. The universal\ncoefficient theorem is stated in the lesson "
"and proved in the references.")
if __name__ == "__main__":
main()Exercises
1. Homological algebra
Warm-upHumanConsider the chain complex with and . How many elements does have?
2. Homological algebra
Warm-upHumanWhich statements about chain maps are true in general? (Choose all that apply.)
3. Homological algebra
CoreHumanHow many elements does have?
4. Homological algebra
CoreHumanHow many equivalence classes of extensions of abelian groups are there?
5. Homological algebra
CoreHumanIn the existence part of the comparison theorem, why does land in (for )?
6. Homological algebra
StretchHumanApply and its derived functors to . The long exact sequence reads . What is ?
7. Homological algebra
CoreFormalWhich Lean statement says that the extension does not split (as proved in not_split)?
8. Homological algebra
StretchComputationalA chain complex of free abelian groups is given by integer matrices d2 (shape ) and d1 (shape ), as lists of rows. Write betti_mod_p(d2, d1, p) returning [b0, b1, b2], the dimensions of for a prime , using over (with ).
Common misconceptions
Misconception
"A quasi-isomorphism has an inverse chain map." It need not. The chain map from (degrees and ) to in degree , given by reduction mod , is a quasi-isomorphism: both complexes have homology in degree only. A chain map back would be a homomorphism in degree , and the only one is (formalised above), which does not induce an isomorphism. Inverting quasi-isomorphisms formally is exactly what the derived category does. Homotopy equivalences, by contrast, do have inverses up to homotopy, and between bounded-below complexes of projectives every quasi-isomorphism is a homotopy equivalence.
Misconception
"A complex is determined by its homology." Not up to isomorphism: above and have the same homology but different terms. Not even up to quasi-isomorphism in general: over , the complex and (zero differential) have the same homology, but every chain map kills (a map sends to ), and every chain map in the other direction kills (its degree- component lands in ). Since consists of projectives, any zigzag of quasi-isomorphisms could be replaced by a single chain map out of , so the two complexes are not quasi-isomorphic (Weibel, §10.4). Over , or any ring of global dimension at most , every complex is quasi-isomorphic to the direct sum of its shifted homology groups.
Misconception
" counts the possible middle modules ." It classifies extensions up to equivalence, which remembers the maps. has elements, but there are only two isomorphism types of middle group: (the split class ) and , which carries the non-zero classes, differing in how is embedded and how the quotient is identified with .
Misconception
"Tor and Ext depend on the resolution chosen." The groups computed from different resolutions are canonically isomorphic (Corollary 4), and the first experiment checks one instance. What depends on choices is the chain level: the resolution itself, and the representing cocycles.
Viewpoints
Topology— Homology theories and universal coefficients
Singular homology is the homology of the singular chain complex , and the long exact sequence of Theorem 1, applied to or to a Mayer–Vietoris sequence, is the main computational tool of algebraic topology. The universal coefficient theorem says that integral homology determines homology with any coefficients, with as the correction: although . The Künneth theorem has a term too: , a class not visible in any product of homology classes. On a smooth manifold, the de Rham theorem identifies the cohomology of the cochain complex of differential forms, , with singular cohomology with real coefficients.
Geometry— Sheaf cohomology and deformations
On a space or variety , the global sections functor on sheaves is left exact but not exact, and its right derived functors — computed with injective resolutions, which exist in the abelian category of sheaves — are sheaf cohomology . They measure the obstruction to passing from local to global solutions: on every nowhere-zero holomorphic function has a logarithm locally, and the obstruction to a global one lies in (the winding number). In algebraic geometry, groups of sheaves govern deformation theory: for a sheaf on a projective variety, is the tangent space to the space of first-order deformations of , and obstructions to extending them lie in (see sheaves).
Algebra— Group cohomology
For a group and a -module (a module over the group ring ), group cohomology is , with the trivial module. In low degrees it is classical: , the invariants; is crossed homomorphisms modulo principal ones; and classifies group extensions inducing the given action, as Ext¹ classifies module extensions. For a cyclic group there is a periodic free resolution of by , with maps alternating between and , so for and . For finite and , is annihilated by , so it vanishes when acts invertibly on — the cohomological form of Maschke's theorem (see representation theory).
Number theory— Galois cohomology and Kummer theory
For a field with absolute Galois group , the cohomology of the Galois module carries arithmetic. Hilbert's Theorem 90 says . Applying the long exact cohomology sequence to the Kummer sequence (exact when is invertible in ) gives
which classifies cyclic extensions of degree dividing when — Kummer theory, whose classical form predates cohomology. The next term, , is the -torsion of the Brauer group, the central object of local and global class field theory (see algebraic number theory).
Category theory— Derived functors and derived categories
Derived functors are a categorical construction: in an abelian category with enough projectives, is defined by the same recipe, and Grothendieck's Tôhoku paper (1957) set up the theory in that generality, including the existence of enough injectives in categories of sheaves (see abelian categories). The modern view packages all into one total derived functor between derived categories, in which quasi-isomorphisms have become isomorphisms; , and long exact sequences become distinguished triangles (see derived categories and triangulated categories). The comparison theorem is then the statement that the homotopy category of bounded-below complexes of projectives is equivalent to .
History and global context
- Henri Poincaré introduced Betti numbers and torsion coefficients of spaces in Analysis Situs (1895) and its supplements. Around 1925 Emmy Noether pointed out that they are invariants of homology groups, an idea taken up by Heinz Hopf, Pavel Alexandrov and Leopold Vietoris; Walther Mayer gave an early purely algebraic treatment of chain complexes (1929).
- David Hilbert's syzygy theorem (1890) was the first theorem about free resolutions. Reinhold Baer studied extensions of abelian groups and their sum (1934). Witold Hurewicz introduced exact sequences in topology (1941), and Samuel Eilenberg and Saunders Mac Lane defined and group cohomology in the 1940s, from questions in topology.
- Henri Cartan and Samuel Eilenberg's Homological Algebra (1956) created the subject in its modern form — projective and injective resolutions, derived functors, and for modules. Nobuo Yoneda described by -fold extensions (1954). Alexander Grothendieck's Tôhoku paper (1957) extended the theory to abelian categories and sheaves.
- Maurice Auslander, David Buchsbaum and Jean-Pierre Serre (1956) characterised regular local rings homologically, and Jean-Louis Verdier's thesis (1960s) introduced derived and triangulated categories, following Grothendieck's ideas.
Further reading
- Charles A. Weibel, An Introduction to Homological Algebra (1994) — the standard graduate text: Chapters 1–3 cover this lesson.
- Henri Cartan and Samuel Eilenberg, Homological Algebra (1956) — the founding text.
- Joseph J. Rotman, An Introduction to Homological Algebra (2nd ed., 2009) — detailed, with many examples.
- Peter J. Hilton and Urs Stammbach, A Course in Homological Algebra (2nd ed., 1997) — concise, with group cohomology.
- Allen Hatcher, Algebraic Topology (2002) — Chapters 2–3 for homology, universal coefficients and Künneth from the topologist's side.
- Sergei I. Gelfand and Yuri I. Manin, Methods of Homological Algebra (2nd ed., 2003) — derived categories and the modern viewpoint.