Holes, dimension and fixed points
Three questions that sound unrelated:
- Is the plane homeomorphic to space ? Both are infinite, connected, contractible, and have the same cardinality — and Peano's curve maps an interval onto a square. Why should dimension be a topological invariant at all?
- Stir a cup of coffee: does some particle end where it began? Equivalently, must every continuous map of a closed ball have a fixed point?
- A sphere and a torus are both closed surfaces. What precisely is the "hole" in the torus, and how do we prove the sphere has none?
The fundamental group answers the third question and the two-dimensional cases of the others, but it only sees loops, and higher homotopy groups are notoriously hard to compute. Homology is the tool that works in every dimension. It assigns to each space a sequence of abelian groups — roughly, counts the -dimensional holes — and to each continuous map a homomorphism, in a way that is unchanged by homotopy and computable by exact sequences and cell decompositions. With it, all three questions have short answers: detects ; the sphere is not a retract of the ball because its homology does not vanish; the torus has and the sphere has .
This lesson assumes homotopy and the fundamental group, quotient groups and point-set topology.
Cycles that bound and cycles that don't
Draw a closed curve on a surface. Sometimes it is the boundary of a piece of the surface; sometimes, like a loop around the hole of an annulus, it is not. Homology makes this precise with formal sums. A chain is a formal integer combination of oriented pieces (points, curve segments, triangles, …); its boundary is the formal sum of the oriented pieces of its edge. A cycle is a chain with zero boundary; a boundary is a chain that is the boundary of something one dimension higher. The key algebraic fact is that a boundary has no boundary — the edge of a triangle is a closed loop — so every boundary is a cycle, and
measures the cycles that do not bound: the holes.
Two features make the idea powerful. First, homology is functorial: a map pushes chains forward and induces homomorphisms with and . Second, it is homotopy invariant and local-to-global computable: deforming does not change , and the homology of is controlled by that of , and . Functoriality turns topological impossibility into algebraic impossibility: if a retraction existed, then on would factor through .
Definitions
Definition— chain complex; homology
A chain complex is a sequence of abelian groups and homomorphisms with . Elements of are cycles, elements of are boundaries, and the -th homology group is . A chain map is a family with ; it sends cycles to cycles and boundaries to boundaries, so it induces .
Definition— singular chains
The standard -simplex is , with face maps inserting a in position . A singular -simplex in a space is a continuous map . The group of singular -chains is the free abelian group on all singular -simplices, and
The homology of is the singular homology . A continuous map induces the chain map and hence . With coefficients in an abelian group one uses and writes .
Definition— reduced and relative homology
Reduced homology is the homology of the augmented complex , with . For non-empty , and for ; a point has . For the relative homology is the homology of .
Definition— chain homotopy
Chain maps are chain homotopic if there are homomorphisms with for all .
Definition— exact sequence
A sequence of homomorphisms is exact at if . A short exact sequence of chain complexes is a pair of chain maps that is exact in every degree.
Definition— CW complex
A CW complex is built inductively: is a discrete set of points (-cells), and is obtained from by attaching -cells, i.e. forming modulo for continuous attaching maps . Then with the weak topology (a set is open if and only if it meets each in an open set). is the -skeleton.
Definition— degree
A map () induces multiplication by an integer on , its degree . Homotopic maps have equal degree; a reflection has degree ; the antipodal map of has degree .
First examples
Example— A point, and path components
For a point, for every (one singular simplex in each dimension), and is for odd and an isomorphism for even, . So and for .
For any space, is free abelian on the path components. Indeed, if is path connected, is onto and its kernel consists of boundaries: a path from to is a singular -simplex with , so every chain with equals . The general case splits over path components.
Example— H₁ is the abelianised fundamental group
A loop is a singular -simplex with , so it is a cycle. The Hurewicz theorem in degree one says that for path-connected the map , , is surjective with kernel the commutator subgroup: (Hatcher, Theorem 2A.1). So , , and for the figure eight , whose fundamental group is free on two generators, : homology forgets the order in which loops are traversed.
Example— The answers we will prove
| space | non-zero homology groups | |
|---|---|---|
| sphere , | ||
| torus | , , | |
| orientable surface of genus | , , | |
| projective plane | , | |
| Klein bottle | , | |
| for |
Torsion such as the in is a genuinely new phenomenon: twice the generating loop bounds (the loop that goes twice around the cross-cap), though the loop itself does not.
The basic machine
Theorem— Lemma 1 (the boundary of a boundary is zero)
For singular chains, .
Proof
First, the simplicial identity for : both sides send to the point of obtained by inserting zeros in positions and . Now for a singular -simplex ,
Split the double sum into the terms with and those with . For rewrite and put ; this is a bijection from onto , and the sign is reversed. So the two halves cancel term by term, and ; by linearity on all chains.
∎
Theorem— Lemma 2 (chain homotopic maps agree on homology)
If are chain homotopic, then for all .
Proof
Let be a cycle. Then is a boundary, so in .
∎
Theorem— Theorem 3 (homotopy invariance)
If are homotopic maps, then for every . Consequently a homotopy equivalence induces isomorphisms on all homology groups, and a contractible space has .
Proof
Proof sketch (complete details in Hatcher, Theorem 2.10). Let be a homotopy from to . In let and ; the prism is the union of the affine -simplices . The prism operator ,
satisfies . Geometrically: the boundary of the prism is the top () minus the bottom () minus the prism over the boundary of ; algebraically it is a cancellation of the same kind as in Lemma 1, where the interior faces cancel in pairs. So and are chain homotopic and Lemma 2 applies. If and then and , and a contractible space is homotopy equivalent to a point.
∎
Theorem— Theorem 4 (long exact sequence)
A short exact sequence of chain complexes gives a long exact sequence
Proof
Construction of . Let be a cycle. Choose with . Then , so for a unique ; and with injective, so is a cycle. Put . Well defined: another lift changes to ; replacing by and lifting to changes by plus an element of , which changes by a boundary. Exactness at : if with then , so ; conversely if , say , then is a cycle with , so . Exactness at and is proved by similar diagram chases (Hatcher, Theorem 2.16).
∎
The short exact sequence gives the long exact sequence of the pair . The local-to-global version is the following.
Theorem— Theorem 5 (Mayer–Vietoris)
If where the interiors of and cover , there is a long exact sequence
and the same holds for reduced homology when .
Proof
Proof sketch. There is a short exact sequence , where consists of chains that are sums of simplices lying in or in ; Theorem 4 gives a long exact sequence for it. The substantial input is that the inclusion induces isomorphisms on homology, proved by repeated barycentric subdivision and the Lebesgue number lemma (Hatcher, Proposition 2.21). We use it without proof.
∎
Theorem— Theorem 6 (homology of spheres)
For : and for .
Proof
Induction on . is two points, so , , and higher groups vanish. For let and (north and south poles). Both are homeomorphic to by stereographic projection, so contractible, and . In the reduced Mayer–Vietoris sequence the terms vanish, so
is exact and for every . The induction hypothesis finishes the proof.
∎
Theorem— Corollary 7 (invariance of dimension)
If and are homeomorphic, then .
Proof
If one of is , the space is a point, and is a point only for . Let and let be a homeomorphism. It restricts to a homeomorphism . The map is a deformation retraction of onto , and likewise . By Theorem 3, , and by Theorem 6 the only non-zero group sits in degree on one side and on the other. So .
∎
Theorem— Corollary 8 (Brouwer fixed-point theorem)
Every continuous map () has a fixed point.
Proof
Suppose for all . Let be the point where the ray from through meets : with the larger root of the quadratic equation ; this root is non-negative because , it is when , and it depends continuously on by the quadratic formula. Then is continuous and for , i.e. . Applying gives on , which factors through (the disc is contractible). This is impossible, so has a fixed point.
∎
Cellular homology and the Euler characteristic
Singular chains are enormous; for a CW complex there is a much smaller chain complex with the same homology. Put , which is free abelian on the -cells, with differential the composite of maps from the long exact sequences of pairs.
Theorem— Theorem 9 (cellular homology)
. Moreover the cellular boundary formula holds: , where is the degree of the composite .
The proof uses the long exact sequences of the pairs and the computation for (Hatcher, Theorem 2.35 and the formula on p. 140). In practice: , and if a -cell is attached along a word in the -cells of a complex with one -cell, is the vector of exponent sums of the letters in that word.
Example— Spheres, complex projective spaces, surfaces
- : for all differentials vanish, recovering Theorem 6.
- : cells only in even dimensions, so all differentials vanish and for , zero otherwise.
- The torus: one -cell, -cells , one -cell attached along . Then and , so . The same argument for (word ) gives .
- The Klein bottle: word , so and , . The surface with cross-caps (word ) has and .
Example— Real projective space
, where is attached by the double cover . Composing with the collapse , the two sheets contribute the identity and the antipodal map, of degrees and . So : zero for odd, multiplication by for even. Hence
With coefficients in every differential becomes zero and for : homology depends on the coefficients.
Theorem— Theorem 10 (Euler–Poincaré)
For a finite CW complex with cells of dimension , define . Then . In particular does not depend on the cell structure and is a homotopy invariant.
Proof
Tensor the cellular chain complex with : since is flat, , whose dimension is . So we may work with a finite complex of finite-dimensional -vector spaces with cycles , boundaries and homology . Rank–nullity for gives , and . Hence
because the terms cancel in the telescoping sum.
∎
So for every cell decomposition of (Euler's polyhedron formula), , , or as is even or odd, and .
Cohomology and cup products
Dualising gives more structure. For a commutative ring , the singular cochains are with , and singular cohomology is their cohomology. It is contravariant: induces . By the universal coefficient theorem, , so the cohomology groups carry no new information. The new information is a product.
Definition— cup product
For and , define by evaluating on the front -face and the back -face:
It satisfies , so it descends to cohomology, making a ring with unit. This ring is graded commutative () and natural ().
The standard computations (Hatcher, §3.2): is the exterior algebra on two classes of degree , with generating ; with ; with . For a wedge sum, as rings: the restrictions to the two summands identify the cohomology, and products of a class from with a class from vanish.
Theorem— Theorem 11 (cup products see more than homology)
and have isomorphic homology and cohomology groups, but they are not homotopy equivalent.
Proof
Both have and all other groups zero (, and with the -cell attached by a constant map). In a generator has generating (by the ring computation above, which rests on Poincaré duality). In , let and let be the inclusion; is an isomorphism, and because . So every square of a degree- class vanishes. A homotopy equivalence would induce a ring isomorphism , which would preserve "the square of a generator of generates ". Contradiction.
∎
The same argument shows that is not homotopy equivalent to , although their homology groups agree. Geometrically, in because two projective lines meet in a point; in , because a meridian and a longitude meet once.
The Lefschetz fixed-point theorem
Brouwer's theorem is the first case of a general principle: a global algebraic count forces fixed points.
Theorem— Theorem 12 (Lefschetz, 1926; Hopf)
Let be a compact triangulable space (or a retract of a finite simplicial complex) and continuous. Its Lefschetz number is . If , then has a fixed point.
The proof (Hatcher, Theorem 2C.3) uses simplicial approximation: if had no fixed point, a fine subdivision would give a simplicial approximation moving every simplex off itself, so the traces on the chain level would be zero, and the Hopf trace formula — the trace version of Theorem 10 — shows that the alternating sum of traces on chains equals .
Examples. If is contractible then for every : Brouwer again. For of degree , , so every map of degree has a fixed point — and the antipodal map, of degree exactly , has none. For we get . So if a closed manifold carries a nowhere-vanishing vector field, its flow for small is homotopic to the identity and has no fixed points (by compactness, periodic orbits have periods bounded below), and therefore . For a map of with , naturality of the cup product forces , so : every self-map of has a fixed point.
Homological algebra in Lean
The algebraic heart of the lesson is proved from first principles with a small, self-contained notion of chain complex of abelian groups. (Mathlib's general notion is ChainComplex V ℕ for an arbitrary preadditive category V; ours keeps every element visible.)
/-- A chain complex of abelian groups, graded by `ℕ`: groups `C n` and boundary maps
`d n : C (n + 1) → C n` with `d ∘ d = 0`. (Mathlib's general notion is `ChainComplex V ℕ` for
any preadditive category `V`; this small version keeps every element visible.) -/
structure ChainCx where
/-- The group of `n`-chains. -/
C : ℕ → Type
/-- Each `C n` is an abelian group. -/
[grp : ∀ n, AddCommGroup (C n)]
/-- The boundary map from `(n + 1)`-chains to `n`-chains. -/
d : ∀ n, C (n + 1) →+ C n
/-- The boundary of a boundary is zero. -/
d_d : ∀ n (x : C (n + 2)), d n (d (n + 1) x) = 0/-- An `n`-chain is a **cycle** if its boundary vanishes. Every `0`-chain is a cycle. -/
def IsCycle (K : ChainCx) : ∀ n, K.C n → Prop
| 0, _ => True
| n + 1, z => K.d n z = 0/-- An `n`-chain is a **boundary** if it is `d` of some `(n + 1)`-chain. Homology is
"cycles modulo boundaries". -/
def IsBoundary (K : ChainCx) (n : ℕ) (z : K.C n) : Prop :=
∃ y : K.C (n + 1), K.d n y = z/-- Every boundary is a cycle: this is exactly `d ∘ d = 0`, and it is what makes
"cycles modulo boundaries" meaningful. -/
theorem boundary_isCycle (K : ChainCx) (n : ℕ) (z : K.C n) (hz : IsBoundary K n z) :
IsCycle K n z := by
obtain ⟨y, rfl⟩ := hz
cases n with
| zero => trivial
| succ n => exact K.d_d n yChain maps preserve boundaries, which is what makes well defined on homology, and Lemma 2 is proved with a calc block that mirrors the one-line human proof: .
/-- A **chain map** `f : K → L` is a family of homomorphisms commuting with the boundary maps.
Continuous maps of spaces induce chain maps on singular chains. -/
structure ChainMap (K L : ChainCx) where
/-- The component in degree `n`. -/
f : ∀ n, K.C n →+ L.C n
/-- `d ∘ f = f ∘ d`. -/
comm : ∀ n (x : K.C (n + 1)), L.d n (f (n + 1) x) = f n (K.d n x)/-- A chain map sends boundaries to boundaries (`f (d y) = d (f y)`), so it induces a
homomorphism on homology. -/
theorem chainMap_boundary {K L : ChainCx} (φ : ChainMap K L) (n : ℕ) (z : K.C n)
(hz : IsBoundary K n z) : IsBoundary L n (φ.f n z) := by
obtain ⟨y, rfl⟩ := hz
exact ⟨φ.f (n + 1) y, φ.comm n y⟩/-- A **chain homotopy** between chain maps `f, g : K → L` is a family `h n : K.C n → L.C (n+1)`
with `f - g = d h + h d` (in degree `0`, simply `f - g = d h`). The prism operator of the lesson
is a chain homotopy between the maps induced by homotopic continuous maps. -/
structure ChainHomotopy {K L : ChainCx} (φ ψ : ChainMap K L) where
/-- The homotopy operator, raising degree by one. -/
h : ∀ n, K.C n →+ L.C (n + 1)
/-- `f - g = d h` in degree `0`. -/
zero : ∀ x : K.C 0, φ.f 0 x - ψ.f 0 x = L.d 0 (h 0 x)
/-- `f - g = d h + h d` in degree `n + 1`. -/
succ : ∀ n (x : K.C (n + 1)),
φ.f (n + 1) x - ψ.f (n + 1) x = L.d (n + 1) (h (n + 1) x) + h n (K.d n x)/-- **Chain-homotopic maps induce the same map on homology.** If `z` is a cycle then
`f z - g z = d (h z) + h (d z) = d (h z)` is a boundary, so `f z` and `g z` have the same
homology class. This is the algebraic half of the homotopy invariance of homology. -/
theorem homotopic_maps_agree_on_homology {K L : ChainCx} {φ ψ : ChainMap K L}
(H : ChainHomotopy φ ψ) (n : ℕ) (z : K.C n) (hz : IsCycle K n z) :
IsBoundary L n (φ.f n z - ψ.f n z) := by
cases n with
| zero => exact ⟨H.h 0 z, (H.zero z).symm⟩
| succ n =>
refine ⟨H.h (n + 1) z, ?_⟩
have hdz : K.d n z = 0 := hz
calc L.d (n + 1) (H.h (n + 1) z)
= L.d (n + 1) (H.h (n + 1) z) + H.h n (K.d n z) := by rw [hdz, map_zero, add_zero]
_ = φ.f (n + 1) z - ψ.f (n + 1) z := (H.succ n z).symmTheorem 10 for a two-dimensional complex of vector spaces — for instance the cellular chains of a surface over or — is the rank–nullity argument of the proof, with the homology groups written explicitly as quotients. It is the formal content of "".
/-- **The Euler–Poincaré formula** for a complex `C₂ → C₁ → C₀` of finite-dimensional vector
spaces over a field `K` (for example the cellular chains of a surface with coefficients in `ℚ`
or `ℤ/2`): the alternating sum of the dimensions of the homology groups
`H₀ = C₀ / im d₁`, `H₁ = ker d₁ / im d₂`, `H₂ = ker d₂` equals the alternating sum of the
dimensions of the chain groups — `b₀ - b₁ + b₂ = V - E + F`. The proof is rank–nullity twice. -/
theorem euler_poincare {K : Type*} [Field K] {C₀ C₁ C₂ : Type*}
[AddCommGroup C₀] [Module K C₀] [FiniteDimensional K C₀]
[AddCommGroup C₁] [Module K C₁] [FiniteDimensional K C₁]
[AddCommGroup C₂] [Module K C₂] [FiniteDimensional K C₂]
(d₁ : C₁ →ₗ[K] C₀) (d₂ : C₂ →ₗ[K] C₁) (hd : d₁ ∘ₗ d₂ = 0) :
(finrank K (C₀ ⧸ LinearMap.range d₁) : ℤ)
- finrank K (LinearMap.ker d₁ ⧸ (LinearMap.range d₂).comap (LinearMap.ker d₁).subtype)
+ finrank K (LinearMap.ker d₂)
= finrank K C₀ - finrank K C₁ + finrank K C₂ := by
-- `im d₂ ⊆ ker d₁` because `d₁ ∘ d₂ = 0`.
have hle : LinearMap.range d₂ ≤ LinearMap.ker d₁ := by
rintro _ ⟨y, rfl⟩
simpa using LinearMap.congr_fun hd y
-- dimensions of the quotients
have h₀ := (LinearMap.range d₁).finrank_quotient_add_finrank
have h₁ := ((LinearMap.range d₂).comap (LinearMap.ker d₁).subtype).finrank_quotient_add_finrank
-- inside `ker d₁`, the boundaries are a copy of `im d₂`
have hB : finrank K ((LinearMap.range d₂).comap (LinearMap.ker d₁).subtype)
= finrank K (LinearMap.range d₂) :=
(Submodule.comapSubtypeEquivOfLe hle).finrank_eq
-- rank–nullity for `d₁` and `d₂`
have r₁ := LinearMap.finrank_range_add_finrank_ker d₁
have r₂ := LinearMap.finrank_range_add_finrank_ker d₂
omegaThe cellular chain complex of is . The next two declarations compute what happens to it with integer and with coefficients, and identify with using Mathlib:
/-- The cellular chain complex of `ℝP²` is `ℤ --(×2)--> ℤ --(×0)--> ℤ`. With integer
coefficients the top differential `×2` is injective, so `H₂(ℝP²; ℤ) = 0`; with coefficients in
`ℤ/2` it is the zero map, so `H₂(ℝP²; ℤ/2) ≅ ℤ/2`. Homology depends on the coefficients. -/
theorem rp2_cellular :
(∀ x : ℤ, 2 * x = 0 → x = 0) ∧ (∀ x : ZMod 2, 2 * x = 0) := by
refine ⟨fun x hx => by omega, ?_⟩
decide/-- `H₁(ℝP²; ℤ) = ker(×0) / im(×2) = ℤ / 2ℤ ≅ ℤ/2`: a homology group with torsion. This applies
Mathlib's `Int.quotientZMultiplesNatEquivZMod`. -/
theorem rp2_h1 : Nonempty ((ℤ ⧸ AddSubgroup.zmultiples (2 : ℤ)) ≃+ ZMod 2) :=
⟨Int.quotientZMultiplesNatEquivZMod 2⟩The functoriality step of Corollary 8 holds for any functor into a category with zero morphisms, and is proved in that generality:
/-- **The no-retraction principle.** Let `F` be any functor (for instance reduced homology
`H̃ₙ₋₁`). If `i : A → X` has a retraction `r` (`r ∘ i = id`) and `F X` is a zero object, then
`F A` is a zero object too: `id = F r ∘ F i` factors through `F X = 0`. Applied to
`A = Sⁿ⁻¹ ⊂ X = Dⁿ`, where `H̃ₙ₋₁(Dⁿ) = 0` but `H̃ₙ₋₁(Sⁿ⁻¹) ≅ ℤ`, it shows that the sphere is not
a retract of the disc — the heart of the Brouwer fixed-point theorem. -/
theorem no_retraction {C D : Type*} [Category C] [Category D] [HasZeroMorphisms D]
(F : C ⥤ D) {A X : C} (i : A ⟶ X) (r : X ⟶ A) (hri : i ≫ r = 𝟙 A)
(hX : IsZero (F.obj X)) : IsZero (F.obj A) := by
rw [IsZero.iff_id_eq_zero]
calc 𝟙 (F.obj A) = F.map (i ≫ r) := by rw [hri, F.map_id]
_ = F.map i ≫ F.map r := F.map_comp i r
_ = 0 ≫ F.map r := by rw [hX.eq_of_tgt (F.map i) 0]
_ = 0 := zero_compMathlib already contains the topological foundations. Lemma 1 holds for the alternating face map complex of any simplicial object — singular chains are the case of the singular simplicial set — and Theorem 3 is a recent addition to Mathlib (by Joël Riou and Fabian Odermatt), built on homotopy invariance for simplicial sets:
/-- **`∂ ∘ ∂ = 0`.** For every simplicial object `X` in a preadditive category (for example the
singular simplicial set of a space, made into simplicial abelian groups), the alternating sum
`∂ = Σᵢ (-1)ⁱ dᵢ` of the face maps squares to zero. This applies Mathlib's
`AlgebraicTopology.AlternatingFaceMapComplex.d_squared`, whose proof cancels the double sum in
pairs using the simplicial identities, exactly as in the lesson. -/
theorem d_squared {V : Type*} [Category V] [Preadditive V] (X : SimplicialObject V) (n : ℕ) :
_root_.AlgebraicTopology.AlternatingFaceMapComplex.objD X (n + 1) ≫
_root_.AlgebraicTopology.AlternatingFaceMapComplex.objD X n = 0 :=
_root_.AlgebraicTopology.AlternatingFaceMapComplex.d_squared X n/-- **Homotopy invariance of singular homology.** Homotopic continuous maps `f ≃ g : X → Y`
induce the same homomorphism `Hₙ(X; R) → Hₙ(Y; R)` for every `n` and every coefficient object
`R` (e.g. `ℤ` as an abelian group). This applies Mathlib's
`TopCat.Homotopy.congr_homologyMap_singularChainComplexFunctor` (Riou–Odermatt), which builds a
chain homotopy between the induced maps of singular chain complexes. -/
theorem homotopy_invariance {V : Type*} [Category V] [Preadditive V] [HasCoproducts V]
[CategoryWithHomology V] {X Y : TopCat} {f g : X ⟶ Y} (H : TopCat.Homotopy f g) (R : V)
(n : ℕ) :
HomologicalComplex.homologyMap
(((_root_.AlgebraicTopology.singularChainComplexFunctor V).obj R).map f) n =
HomologicalComplex.homologyMap
(((_root_.AlgebraicTopology.singularChainComplexFunctor V).obj R).map g) n :=
H.congr_homologyMap_singularChainComplexFunctor R nWhat is and is not formalised. Formalised independently: boundaries are cycles, chain maps induce maps on homology, Lemma 2, Theorem 10 in dimension two, the cellular computation for , and the functorial no-retraction argument. From Mathlib: Lemma 1 and Theorem 3 for singular homology. Not formalised: Mayer–Vietoris, excision and the computation (not yet in Mathlib for singular homology), so Corollaries 7 and 8 are not formalised end to end; cellular homology of CW complexes; cup products; and the Lefschetz theorem.
Computing homology by machine
Homology of a finite simplicial complex is linear algebra over : write down the boundary matrices and put them in Smith normal form. The ranks give the Betti numbers and the diagonal entries larger than give the torsion. The experiment does this for explicit triangulations of four surfaces, over and over , and checks Theorem 10 in each case.
"""Simplicial homology of four surfaces, computed exactly over the integers.
For a triangulated surface we build the boundary matrices d1 (edges to
vertices) and d2 (triangles to edges) with the usual signs, put them in Smith
normal form over Z, and read off H_n = Z^(b_n) + torsion. We also compute the
Betti numbers with coefficients in Z/2 and check the Euler-Poincare formula
V - E + F = b0 - b1 + b2. This is exact computation for these particular
triangulations; that the answers do not depend on the triangulation is a
theorem (homotopy invariance of homology), not something the computation shows.
"""
from itertools import combinations
def grid_surface(twist):
"""Triangulate a 3x3 grid of squares with opposite sides glued.
twist=False gives the torus; twist=True glues top to bottom with a flip,
giving the Klein bottle. Returns a list of triangles (sorted vertex tuples).
"""
def label(a, b):
if b % 3 == 0 and b != 0 and twist:
a = -a
return (a % 3) * 3 + (b % 3)
triangles = []
for i in range(3):
for j in range(3):
p, q = label(i, j), label(i + 1, j)
r, s = label(i + 1, j + 1), label(i, j + 1)
triangles += [tuple(sorted((p, q, r))), tuple(sorted((p, s, r)))]
return triangles
SURFACES = {
"sphere S^2": [tuple(t) for t in combinations(range(4), 3)],
"torus T^2": grid_surface(False),
"Klein bottle": grid_surface(True),
"proj. plane RP^2": [
(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 4, 5), (0, 1, 5),
(1, 2, 4), (2, 3, 5), (1, 3, 4), (2, 4, 5), (1, 3, 5),
],
}
def boundary_matrices(triangles):
"""Return (vertices, edges, d1, d2) with integer matrices as lists of rows."""
edges = sorted({e for t in triangles for e in combinations(t, 2)})
verts = sorted({v for t in triangles for v in t})
vi = {v: k for k, v in enumerate(verts)}
ei = {e: k for k, e in enumerate(edges)}
d1 = [[0] * len(edges) for _ in verts]
for k, (a, b) in enumerate(edges):
d1[vi[b]][k] += 1
d1[vi[a]][k] -= 1
d2 = [[0] * len(triangles) for _ in edges]
for k, (a, b, c) in enumerate(triangles):
for sign, face in ((1, (b, c)), (-1, (a, c)), (1, (a, b))):
d2[ei[face]][k] += sign
return verts, edges, d1, d2
def smith_diagonal(matrix):
"""Nonzero diagonal entries of the Smith normal form of an integer matrix."""
m = [row[:] for row in matrix]
diag = []
while m and m[0]:
entries = [(abs(x), i, j) for i, row in enumerate(m)
for j, x in enumerate(row) if x]
if not entries:
break
_, i, j = min(entries)
m[0], m[i] = m[i], m[0]
for row in m:
row[0], row[j] = row[j], row[0]
done = False
while not done:
done = True
p = m[0][0]
for i in range(1, len(m)):
q = m[i][0] // p
m[i] = [x - q * y for x, y in zip(m[i], m[0])]
for j in range(1, len(m[0])):
q = m[0][j] // p
for row in m:
row[j] -= q * row[0]
rest = [(abs(x), i, j) for i, row in enumerate(m)
for j, x in enumerate(row)
if x and (i == 0 or j == 0) and (i, j) != (0, 0)]
if rest:
_, i, j = min(rest)
if i:
m[0], m[i] = m[i], m[0]
else:
for row in m:
row[0], row[j] = row[j], row[0]
done = False
elif any(x % p for row in m[1:] for x in row[1:]):
i = next(i for i, row in enumerate(m)
if i and any(x % p for x in row[1:]))
m[0] = [x + y for x, y in zip(m[0], m[i])]
done = False
diag.append(abs(m[0][0]))
m = [row[1:] for row in m[1:]]
return diag
def rank_mod2(matrix):
"""Rank of an integer matrix reduced modulo 2 (Gaussian elimination)."""
rows = [sum(1 << j for j, x in enumerate(r) if x % 2) for r in matrix]
rank = 0
for bit in range(max((r.bit_length() for r in rows), default=0)):
pivot = next((r for r in rows if r >> bit & 1), None)
if pivot is None:
continue
rows = [r ^ pivot if r >> bit & 1 else r for r in rows if r != pivot]
rank += 1
return rank
def homology(triangles):
"""Return (betti over Z, torsion of H_1, betti over Z/2, (V, E, F))."""
verts, edges, d1, d2 = boundary_matrices(triangles)
s1, s2 = smith_diagonal(d1), smith_diagonal(d2)
nv, ne, nf = len(verts), len(edges), len(triangles)
betti = (nv - len(s1), ne - len(s1) - len(s2), nf - len(s2))
torsion = [d for d in s2 if d > 1]
r1, r2 = rank_mod2(d1), rank_mod2(d2)
betti2 = (nv - r1, ne - r1 - r2, nf - r2)
return betti, torsion, betti2, (nv, ne, nf)
def describe(betti, torsion):
"""Human-readable H_0, H_1, H_2 such as 'Z | Z+Z/2 | 0'."""
def group(rank, tors):
parts = (["Z^%d" % rank] if rank > 1 else ["Z"] * rank)
parts += ["Z/%d" % t for t in tors]
return "+".join(parts) or "0"
return " | ".join([group(betti[0], []), group(betti[1], torsion),
group(betti[2], [])])
def main():
print("Simplicial homology over Z (exact, via Smith normal form)")
print()
print(f"{'surface':<18}{'V,E,F':<12}{'H0 | H1 | H2':<20}"
f"{'b mod 2':<10}chi")
for name, tris in SURFACES.items():
betti, torsion, betti2, (v, e, f) = homology(tris)
chi = v - e + f
assert chi == betti[0] - betti[1] + betti[2]
assert chi == betti2[0] - betti2[1] + betti2[2]
print(f"{name:<18}{f'{v},{e},{f}':<12}{describe(betti, torsion):<20}"
f"{','.join(map(str, betti2)):<10}{chi}")
print()
print("In every row V - E + F equals the alternating sum of the Betti")
print("numbers, over Z and over Z/2 alike, although the Z/2 Betti numbers")
print("of RP^2 and the Klein bottle differ from the integral ones: torsion")
print("Z/2 in H_1 becomes an extra Z/2 in both H_1 and H_2 mod 2.")
print()
print("Epistemic status: exact integer linear algebra on four explicit")
print("triangulations. That homology is independent of the triangulation")
print("(indeed a homotopy invariant) is a theorem discussed in the lesson,")
print("not something this computation establishes.")
if __name__ == "__main__":
main()The Betti numbers of and the Klein bottle are larger than the integral ones — torsion in shows up twice mod , as the universal coefficient theorem predicts — yet the Euler characteristic is the same. The computation is exact, but only for these triangulations; that the answer does not depend on the triangulation is Theorem 3.
The second experiment tests the Lefschetz theorem on maps of the torus for integer matrices . Since is , and on , the Lefschetz number is , and the fixed points can be counted exactly.
"""The Lefschetz fixed-point theorem on the torus, checked by exact counting.
A 2x2 integer matrix A induces a map f(x) = A x (mod 1) of the torus
T^2 = R^2/Z^2. On homology it acts by 1 on H_0, by A on H_1 and by det A on
H_2, so its Lefschetz number is L(f) = 1 - tr A + det A = det(I - A). We count
the fixed points exactly with fractions: x is fixed when (A - I) x is an
integer vector, and all such x lie on the grid (1/d) Z^2 with d = |det(A - I)|.
Exact enumeration for a handful of matrices; the general theorem is proved by
other means.
"""
from fractions import Fraction
MATRICES = {
"rotation by 90 deg": ((0, -1), (1, 0)),
"x -> -x": ((-1, 0), (0, -1)),
"cat map": ((2, 1), (1, 1)),
"doubling": ((2, 0), (0, 2)),
"A = [[3,1],[1,0]]": ((3, 1), (1, 0)),
"shear [[1,1],[0,1]]": ((1, 1), (0, 1)),
}
def lefschetz_number(a):
"""L(f) = sum (-1)^k tr(f_* on H_k) = 1 - tr A + det A."""
(p, q), (r, s) = a
return 1 - (p + s) + (p * s - q * r)
def fixed_points(a):
"""Exact fixed points of x -> A x (mod 1) in [0,1)^2, or None if infinite."""
(p, q), (r, s) = a
m = ((p - 1, q), (r, s - 1))
d = abs(m[0][0] * m[1][1] - m[0][1] * m[1][0])
if d == 0:
return None
points = []
for i in range(d):
for j in range(d):
x, y = Fraction(i, d), Fraction(j, d)
u = m[0][0] * x + m[0][1] * y
v = m[1][0] * x + m[1][1] * y
if u.denominator == 1 and v.denominator == 1:
points.append((x, y))
return points
def show(point):
"""Format a point with fractional coordinates."""
return "(" + ", ".join(str(c) for c in point) + ")"
def main():
print("Maps x -> A x (mod 1) of the torus: Lefschetz number vs fixed points")
print()
print(f"{'map':<22}{'L = det(I-A)':<14}{'#fixed':<8}fixed points")
for name, a in MATRICES.items():
lef = lefschetz_number(a)
pts = fixed_points(a)
if pts is None:
print(f"{name:<22}{lef:<14}{'inf':<8}a whole circle (L = 0)")
continue
shown = " ".join(show(p) for p in pts[:3])
if len(pts) > 3:
shown += " ..."
print(f"{name:<22}{lef:<14}{len(pts):<8}{shown}")
print()
print("Whenever L is nonzero, the number of fixed points is |L|: every fixed")
print("point of a linear map has index sign det(I - A). A translation by a")
print("small vector is homotopic to the identity, has L = 0 and no fixed")
print("points at all: L = 0 gives no information.")
print()
print("Epistemic status: exact rational arithmetic, exhaustive over the")
print("grid (1/d)Z^2 that must contain every fixed point, for six matrices.")
print("It illustrates the Lefschetz fixed-point theorem; the theorem itself")
print("is proved with simplicial approximation and homology.")
if __name__ == "__main__":
main()Explore: cells, gluings and the Euler characteristic
In the Surfaces and genus tab, refine a cell structure with the three moves (split an edge, cut a face, add a vertex). The numbers , , change, but never does — the elementary shadow of Theorem 10, which explains why: is computed from homology, which does not see the cell structure at all.
Vertices, edges and faces
χ = V − E + F does not depend on how the surface is cut into cells.
Every closed surface with two sides (an inside and an outside) is, up to stretching, a sphere with some number g of handles. That number g is its genus.
genus g = 1
χ = 2 − 2g = 2 − 2·1 = 0
Each extra handle lowers χ by 2.
One way to cut it into flat faces is the solid “Picture frame (one hole)”: V = 16, E = 32, F = 16
Cut it up differently
Make the faces finer. Watch V, E and F change.
V − E + F = 16 − 32 + 16 = 0
Each move changes V, E and F, but not V − E + F.
χ is a topological invariant: it depends only on the surface, not on how you cut it into faces (as long as each face is a disc and faces meet edge to edge).
These examples and moves are evidence, not a proof. Proving that every way of cutting the same surface into faces gives the same χ takes more work — for example, showing that any two ways of cutting it have a common refinement, or using homology.
The formula χ = 2 − 2g is for closed surfaces with two sides. One-sided surfaces such as the Klein bottle (χ = 0) and the projective plane (χ = 1) need a different formula.
The next widget shows the gluing words used in the cellular computations. Walk the flatlander around the Klein bottle () and the projective plane () and watch it come back mirror-reversed. Count, for each word, the exponent sum of each letter: that is the cellular boundary , and a non-zero exponent sum is exactly where the torsion in comes from.
Surfaces from a square
The torus word has exponent sums 0, 0; the Klein bottle 0, 2; the projective plane 2, 2.
Keys: ↑ forward, ↓ back, ← and → turn, Space walks or stops. You can also drag it.
- Orientable
- No
- Euler characteristic
- χ = 0
Gluing turns the 4 corners into V = 1, the 4 sides into E = 2 and the square into F = 1: V − E + F = 1 − 2 + 1 = 0
Same way round as at the start.
Sides crossed so far: 0
Top and bottom are glued as on the torus, but the left and right sides are glued with opposite arrows. Walk through them and you come back mirrored. A surface on which a walk can mirror you is called non-orientable. The Klein bottle cannot sit in ordinary 3D space without passing through itself.
Exercises
1. Algebraic topology
Warm-upHumanWhat is the rank of , where is the closed orientable surface of genus ?
2. Algebraic topology
CoreHumanWhich list gives of (integer coefficients)?
3. Algebraic topology
CoreHumanWe try to compute with Mayer–Vietoris using the two closed hemispheres and . Which hypothesis of Theorem 5, as stated in the lesson, fails?
4. Algebraic topology
CoreHumanIn the proof that for , why do we remove a point before taking homology?
5. Algebraic topology
StretchHumanFor which pairs do the homology groups alone prove that the two spaces are not homotopy equivalent? (Select all that apply.)
6. Algebraic topology
CoreFormalWith H : ChainHomotopy φ ψ, which Lean statement correctly formalises chain-homotopic maps induce the same map on homology at the level of elements?
7. Algebraic topology
StretchHumanA map satisfies on . What is its Lefschetz number ?
8. Algebraic topology
CoreComputationalWrite euler_characteristic(triangles) that takes a list of triangles (3-tuples of vertex labels) forming a -dimensional simplicial complex and returns , where counts distinct vertices, distinct edges (unordered pairs of vertices of a triangle) and triangles.
Common misconceptions
Misconception
"Homology determines the homotopy type." It does not. and have the same homology but different cohomology rings (Theorem 11). More strikingly, Poincaré's homology sphere — the quotient of by the icosahedral group — has the homology of but a fundamental group of order . Even a map inducing isomorphisms on all homology groups need not be a homotopy equivalence; Whitehead's theorem requires extra hypotheses such as simple connectivity (see homotopy theory).
Misconception
"Homology groups are the same as homotopy groups." Only in the first non-trivial degree, by the Hurewicz theorem. Homology vanishes above the dimension of a CW complex, but homotopy groups do not: while , and the groups are known only in a limited range. Homology is computable precisely because it satisfies excision and Mayer–Vietoris, which homotopy groups do not.
Misconception
" is the fundamental group." is the abelianisation of . For the figure eight, is free on two generators and , but in the commutator is zero.
Misconception
"Torsion in homology means non-orientable." For closed surfaces, torsion in occurs exactly for the non-orientable ones. But the lens spaces are orientable -manifolds with . Orientability of a closed connected -manifold is detected instead by (orientable) versus (non-orientable).
Misconception
"The Euler characteristic depends on the triangulation, and homology on the cells chosen." Both are invariants of the homotopy type (Theorems 3 and 10). This is the point of the definition: a quantity computed from a combinatorial structure turns out not to depend on it.
Viewpoints
Topology— A homotopy-invariant functor, characterised by axioms
Homology is a functor from the homotopy category, with long exact sequences of pairs and excision. Eilenberg and Steenrod showed that these properties, together with the dimension axiom for , determine homology on finite CW complexes. Their consequences include the Jordan–Brouwer separation theorem (an embedded has complement with exactly two components) and Brouwer's invariance of domain (an injective continuous map is open), both via Alexander duality. Dropping the dimension axiom gives generalised homology theories such as K-theory and bordism — see stable homotopy theory.
Geometry— Duality and intersection
For a closed oriented -manifold , Poincaré duality turns the cup product into intersection: if submanifolds , meet transversally, the Poincaré dual of is the cup product of their duals. This is why generates (two lines meet in a point) and why the intersection form on of a -manifold is a central invariant. The Euler characteristic is also geometric: by Gauss–Bonnet, for a closed surface, a theme continued in vector bundles and characteristic classes.
Analysis— Holes detected by differential forms
On a smooth manifold, the de Rham theorem identifies with closed -forms modulo exact ones. On , the form is closed but not exact, since ; it represents the generator of . Hodge theory goes further: on a compact Riemannian manifold every class has a unique harmonic representative, so the Betti numbers are dimensions of spaces of solutions of an elliptic PDE. See differential forms and smooth manifolds.
Algebra— Homological algebra
The chain complex is the real object; homology is its first invariant. Lemmas 1 and 2 and Theorem 4 belong to homological algebra, which grew out of topology and now runs through algebra: derived functors and measure how tensor products and fail to be exact, and appear in the Künneth and universal coefficient theorems; group cohomology is the cohomology of a . Emmy Noether's insistence on groups rather than Betti numbers is what made this possible. The modern frame is the derived category, where chain complexes are considered up to quasi-isomorphism — see derived categories.
Computation— Homology of data
Because homology of a finite complex is Smith normal form, it is algorithmic, and persistent homology applies it to data: build complexes from a point cloud at every scale and record when holes are born and die, producing a barcode that is stable under perturbation of the data (Cohen-Steiner, Edelsbrunner and Harer, 2007). On a graph, the Euler–Poincaré formula reads , so the number of independent cycles is — the cyclomatic number used in circuit analysis and software engineering.
Physics— Kirchhoff's laws are homology
In an electrical network, currents form a -chain on the circuit graph. Kirchhoff's current law (1847) says that, without external sources, the current is a cycle: . The voltage law says that voltage drops form a coboundary: they are differences of a potential, . The space of steady currents therefore has dimension for a connected network, and Kirchhoff's own count of independent loops is an early computation of a Betti number. Hermann Weyl later (1923) made this connection with combinatorial topology explicit.
Category theory— Why category theory was invented
Eilenberg and Mac Lane introduced categories, functors and natural transformations in 1945 precisely to say what "natural" means for maps such as and the universal coefficient isomorphisms. Homology is a functor; the connecting homomorphism is a natural transformation; Theorem 3 says factors through the homotopy category. See categories.
History and global context
- Polyhedra and surfaces. Leonhard Euler stated for polyhedra in 1750 and published proofs in 1758; René Descartes' unpublished notes (c. 1630) contain an equivalent statement about angular defects. Bernhard Riemann (1851, 1857) introduced the connectivity of surfaces in his work on what are now Riemann surfaces, and Enrico Betti (1871) defined higher connectivity numbers.
- Analysis situs. Henri Poincaré's Analysis Situs (1895) and its five complements (1899–1904) created the subject: homology with integer coefficients, torsion, the fundamental group, the duality theorem that bears his name, and in 1904 the homology sphere showing that homology does not detect .
- Brouwer and Lefschetz. L. E. J. Brouwer proved the fixed-point theorem and the invariance of dimension and of domain in 1910–1912, introducing the degree of a map. Solomon Lefschetz proved his fixed-point theorem in 1926; Heinz Hopf extended it in 1928–29.
- Groups, not numbers. In the mid-1920s Emmy Noether in Göttingen urged topologists to treat homology as groups; Pavel Alexandroff and Heinz Hopf credited her influence in their 1935 Topologie. Leopold Vietoris and Walther Mayer developed the Mayer–Vietoris sequence (1929–30).
- Cohomology. James W. Alexander and Andrey Kolmogorov independently introduced cohomology and products at the 1935 Moscow topology conference; Eduard Čech and Hassler Whitney gave the cup product its modern form (1936–38). Lev Pontryagin's duality theorems were part of the same period.
- Foundations. Samuel Eilenberg defined singular homology in its modern form (1944); Eilenberg and Saunders Mac Lane introduced category theory (1945); Eilenberg and Norman Steenrod axiomatised homology (1945, book 1952); J. H. C. Whitehead introduced CW complexes (1949).
- Today. Algebraic topology is a working tool from algebraic geometry to robotics and data analysis; persistent homology, introduced by Herbert Edelsbrunner, David Letscher and Afra Zomorodian (2002) and developed by Gunnar Carlsson and others, is used in fields from materials science to neuroscience.
Further reading
- Allen Hatcher, Algebraic Topology (2002) — the standard first course; Chapter 2 (homology) and Chapter 3 (cohomology) cover this lesson, with the proofs sketched here in full.
- James R. Munkres, Elements of Algebraic Topology (1984) — careful simplicial and singular homology, with many computations.
- Glen E. Bredon, Topology and Geometry (1993) — homology and cohomology together with smooth manifolds and de Rham theory.
- Raoul Bott and Loring W. Tu, Differential Forms in Algebraic Topology (1982) — the analyst's and geometer's route via de Rham cohomology.
- Tammo tom Dieck, Algebraic Topology (2008), and J. P. May, A Concise Course in Algebraic Topology (1999) — more categorical treatments.
- Herbert Edelsbrunner and John Harer, Computational Topology: An Introduction (2010) — algorithms and persistent homology.
- Jean Dieudonné, A History of Algebraic and Differential Topology, 1900–1960 (1989).
Reading path: Hatcher Chapter 2 with this lesson; then Chapter 3 or Bott–Tu; then homotopy theory and characteristic classes.