Poincaré conjecture: the Lean proof, cleaned up together
The 2026 Lean proof of the Poincaré conjecture after Morgan and Tian, 3 million lines, cleaned up together: smaller, faster to build, more readable, the theorems unchanged

| 1 | import PoincareLib.AlgebraicTopology.HomotopyGroup.LoopSpace.Compatibility.ThreeManifoldTopology |
| 2 | import PoincareLib.AlgebraicTopology.HomotopyGroup.LoopSpace.Compatibility.ThreeManifoldTopology |
| 3 | |
| 4 | /-! |
| 5 | # Cubical homotopies with moving basepoint |
| 6 | |
| 7 | Hatcher, Algebraic Topology, Section 4.1, pp. 341-342, changes the basepoint |
| 8 | by carrying one path on the entire cube boundary. M02's homotopy extension |
| 9 | and boundary adjustment give this construction on every finite cube and in |
| 10 | an arbitrary target space. No separation hypothesis is required. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open scoped Topology unitInterval |
| 16 | |
| 17 | noncomputable section |
| 18 | |
| 19 | namespace GenLoop |
| 20 | |
| 21 | variable {N X Y : Type*} [Finite N] [TopologicalSpace X] [TopologicalSpace Y] |
| 22 | {x y z : X} |
| 23 | |
| 24 | /-- A homotopy of cubical loops whose boundary follows one specified path. |
| 25 | Source: Hatcher, Section 4.1, pp. 341-342. -/ |
| 26 | structure HomotopyAlong (p : Path x y) (a : GenLoop N X x) (b : GenLoop N X y) |
| 27 | extends a.val.Homotopy b.val where |
| 28 | boundary_path : ∀ (t : I) (v : Cube.boundary N), toHomotopy (t, v) = p t |
| 29 | |
| 30 | namespace HomotopyAlong |
| 31 | |
| 32 | variable {p : Path x y} {q : Path y z} |
| 33 | {a : GenLoop N X x} {b : GenLoop N X y} {c : GenLoop N X z} |
| 34 | |
| 35 | /-- The stationary homotopy has constant boundary trace. |
| 36 | Source: Hatcher, Section 4.1, property (3), p. 341. -/ |
| 37 | def refl (a : GenLoop N X x) : HomotopyAlong (Path.refl x) a a where |
| 38 | toHomotopy := ContinuousMap.Homotopy.refl a.val |
| 39 | boundary_path _ v := GenLoop.boundary a v v.property |
| 40 | |
| 41 | /-- Reversing time reverses the boundary path. |
| 42 | Source: Hatcher, Section 4.1, pp. 341-342. -/ |
| 43 | def symm (H : HomotopyAlong p a b) : HomotopyAlong p.symm b a where |
| 44 | toHomotopy := H.toHomotopy.symm |
| 45 | boundary_path _ v := H.boundary_path _ v |
| 46 | |
| 47 | /-- Concatenation carries the concatenated boundary path. |
| 48 | Source: Hatcher, Section 4.1, property (2), p. 341. -/ |
| 49 | def trans (H : HomotopyAlong p a b) (G : HomotopyAlong q b c) : |
| 50 | HomotopyAlong (p.trans q) a c where |
| 51 | toHomotopy := H.toHomotopy.trans G.toHomotopy |
| 52 | boundary_path t v := by |
| 53 | rw [ContinuousMap.Homotopy.trans_apply, Path.trans_apply] |
| 54 | split_ifs |
| 55 | · exact H.boundary_path _ v |
| 56 | · exact G.boundary_path _ v |
| 57 | |
| 58 | /-- An ordinary relative homotopy has the stationary boundary path. |
| 59 | Source: Hatcher, Section 4.1, homotopy invariance, p. 341. -/ |
| 60 | def ofRel {a b : GenLoop N X x} (H : a.val.HomotopyRel b.val (Cube.boundary N)) : |
| 61 | HomotopyAlong (Path.refl x) a b where |
| 62 | toHomotopy := H.toHomotopy |
| 63 | boundary_path t v := (H.eq_fst t v.property).trans (GenLoop.boundary a v v.property) |
| 64 | |
| 65 | /-- A homotopy with stationary boundary is relative to that boundary. |
| 66 | Source: Hatcher, Section 4.1, property (3), p. 341. -/ |
| 67 | def toRel {a b : GenLoop N X x} (H : HomotopyAlong (Path.refl x) a b) : |
| 68 | a.val.HomotopyRel b.val (Cube.boundary N) where |
| 69 | toHomotopy := H.toHomotopy |
| 70 | prop' t v hv := (H.boundary_path t ⟨v, hv⟩).trans (GenLoop.boundary a v hv).symm |
| 71 | |
| 72 | /-- Homotopic boundary paths can be substituted while fixing both endpoint maps. |
| 73 | Source: Hatcher, Section 4.1, homotopy invariance, p. 341. -/ |
| 74 | theorem change_path (H : HomotopyAlong p a b) {q : Path x y} |
| 75 | (P : p.Homotopic q) : Nonempty (HomotopyAlong q a b) := by |
| 76 | obtain ⟨P⟩ := P |
| 77 | let K : C(I × (I × Cube.boundary N), X) := |
| 78 | ⟨fun v => P (v.1, v.2.1), |
| 79 | P.continuous.comp (continuous_fst.prodMk (continuous_fst.comp continuous_snd))⟩ |
| 80 | obtain ⟨H', hH'⟩ := |
| 81 | PoincareMT.Proofs.M02.exists_cube_homotopy_of_boundary_homotopy |
| 82 | a.val b.val H.toHomotopy K |
| 83 | (fun t v => (P.apply_zero t).trans (H.boundary_path t v).symm) |
| 84 | (fun s v => (P.source s).trans (GenLoop.boundary a v v.property).symm) |
| 85 | (fun s v => (P.target s).trans (GenLoop.boundary b v v.property).symm) |
| 86 | exact ⟨{ |
| 87 | toHomotopy := H' |
| 88 | boundary_path := fun t v => (hH' t v).trans (P.apply_one t) }⟩ |
| 89 | |
| 90 | /-- Equal initial maps and equal boundary traces give equal endpoint classes. |
| 91 | Source: Hatcher, Section 4.1, homotopy invariance, p. 341. -/ |
| 92 | theorem endpoint_homotopic {c : GenLoop N X y} |
| 93 | (H : HomotopyAlong p a b) (G : HomotopyAlong p a c) : Homotopic b c := |
| 94 | PoincareMT.Proofs.M02.cube_homotopicRel_of_homotopies_with_same_boundary |
| 95 | a.val b.val c.val H.toHomotopy G.toHomotopy |
| 96 | (fun t v => (H.boundary_path t v).trans (G.boundary_path t v).symm) |
| 97 | |
| 98 | /-- Postcomposition carries the entire homotopy and its boundary path. |
| 99 | Source: Hatcher, Section 4.1, functoriality, p. 342. -/ |
| 100 | def map (H : HomotopyAlong p a b) (f : C(X, Y)) : |
| 101 | HomotopyAlong (p.map f.continuous) |
| 102 | (PoincareMT.Proofs.M02.mapGenLoop f rfl a) |
| 103 | (PoincareMT.Proofs.M02.mapGenLoop f rfl b) where |
| 104 | toHomotopy := (ContinuousMap.Homotopy.refl f).comp H.toHomotopy |
| 105 | boundary_path t v := congrArg f (H.boundary_path t v) |
| 106 | |
| 107 | /-- The path itself is a homotopy between constant cubes. |
| 108 | Source: Hatcher, Section 4.1, preservation of the identity, p. 341. -/ |
| 109 | def const (p : Path x y) : |
| 110 | HomotopyAlong p (GenLoop.const : GenLoop N X x) GenLoop.const where |
| 111 | toFun v := p v.1 |
| 112 | continuous_toFun := p.continuous.comp continuous_fst |
| 113 | map_zero_left _ := p.source |
| 114 | map_one_left _ := p.target |
| 115 | boundary_path _ _ := rfl |
| 116 | |
| 117 | end HomotopyAlong |
| 118 | |
| 119 | /-- Extend a boundary path from any cubical loop, including the empty-index cube. |
| 120 | Source: Hatcher, Section 4.1, basepoint change, pp. 341-342. -/ |
| 121 | theorem exists_homotopyAlong (p : Path x y) (a : GenLoop N X x) : |
| 122 | ∃ b : GenLoop N X y, Nonempty (HomotopyAlong p a b) := by |
| 123 | let h : C(I × Cube.boundary N, X) := |
| 124 | ⟨fun v => p v.1, p.continuous.comp continuous_fst⟩ |
| 125 | obtain ⟨F, hF0, hFB⟩ := PoincareMT.Proofs.M02.exists_cube_homotopy_extension |
| 126 | a.val h (fun v => p.source.trans (GenLoop.boundary a v v.property).symm) |
| 127 | let b : GenLoop N X y := |
| 128 | ⟨⟨fun v => F (1, v), F.continuous.comp (continuous_const.prodMk continuous_id)⟩, |
| 129 | fun v hv => (hFB 1 ⟨v, hv⟩).trans p.target⟩ |
| 130 | exact ⟨b, ⟨{ toContinuousMap := F |
| 131 | map_zero_left := hF0 |
| 132 | map_one_left := fun _ => rfl |
| 133 | boundary_path := hFB }⟩⟩ |
| 134 | |
| 135 | /-- A chosen cubical basepoint transport, obtained by extending the boundary path. |
| 136 | Source: Hatcher, Section 4.1, pp. 341-342. -/ |
| 137 | def boundaryTransport (p : Path x y) (a : GenLoop N X x) : GenLoop N X y := |
| 138 | Classical.choose (exists_homotopyAlong p a) |
| 139 | |
| 140 | /-- The transport is realized by an actual moving-boundary homotopy. |
| 141 | Source: Hatcher, Section 4.1, pp. 341-342. -/ |
| 142 | def boundaryTransportHomotopy (p : Path x y) (a : GenLoop N X x) : |
| 143 | HomotopyAlong p a (boundaryTransport p a) := |
| 144 | Classical.choice (Classical.choose_spec (exists_homotopyAlong p a)) |
| 145 | |
| 146 | /-- Any homotopy with the prescribed trace computes the transported class. |
| 147 | Source: Hatcher, Section 4.1, homotopy invariance, p. 341. -/ |
| 148 | theorem boundaryTransport_homotopic_of_homotopyAlong |
| 149 | {p : Path x y} {a : GenLoop N X x} {b : GenLoop N X y} |
| 150 | (H : HomotopyAlong p a b) : Homotopic (boundaryTransport p a) b := |
| 151 | (boundaryTransportHomotopy p a).endpoint_homotopic H |
| 152 | |
| 153 | /-- Transport along a constant path acts identically on classes. |
| 154 | Source: Hatcher, Section 4.1, property (3), p. 341. -/ |
| 155 | theorem boundaryTransport_refl (a : GenLoop N X x) : |
| 156 | Homotopic (boundaryTransport (Path.refl x) a) a := |
| 157 | boundaryTransport_homotopic_of_homotopyAlong (HomotopyAlong.refl a) |
| 158 | |
| 159 | /-- Transport along consecutive paths composes in path order. |
| 160 | Source: Hatcher, Section 4.1, property (2), p. 341. -/ |
| 161 | theorem boundaryTransport_trans (p : Path x y) (q : Path y z) (a : GenLoop N X x) : |
| 162 | Homotopic (boundaryTransport (p.trans q) a) |
| 163 | (boundaryTransport q (boundaryTransport p a)) := |
| 164 | boundaryTransport_homotopic_of_homotopyAlong |
| 165 | ((boundaryTransportHomotopy p a).trans |
| 166 | (boundaryTransportHomotopy q (boundaryTransport p a))) |
| 167 | |
| 168 | /-- Reverse-path transport undoes transport, up to relative homotopy. |
| 169 | Source: Hatcher, Section 4.1, p. 342. -/ |
| 170 | theorem boundaryTransport_symm (p : Path x y) (a : GenLoop N X x) : |
| 171 | Homotopic (boundaryTransport p.symm (boundaryTransport p a)) a := |
| 172 | boundaryTransport_homotopic_of_homotopyAlong (boundaryTransportHomotopy p a).symm |
| 173 | |
| 174 | /-- Transport respects the relation defining the homotopy quotient. |
| 175 | Source: Hatcher, Section 4.1, homotopy invariance, p. 341. -/ |
| 176 | theorem boundaryTransport_homotopic (p : Path x y) {a b : GenLoop N X x} |
| 177 | (h : Homotopic a b) : Homotopic (boundaryTransport p a) (boundaryTransport p b) := by |
| 178 | obtain ⟨H⟩ := h |
| 179 | obtain ⟨G⟩ := ((HomotopyAlong.ofRel H).trans (boundaryTransportHomotopy p b)).change_path |
| 180 | (Path.Homotopic.refl_trans p) |
| 181 | exact boundaryTransport_homotopic_of_homotopyAlong G |
| 182 | |
| 183 | /-- Homotopic paths induce the same basepoint transport on classes. |
| 184 | Source: Hatcher, Section 4.1, p. 341. -/ |
| 185 | theorem boundaryTransport_path_homotopic {p q : Path x y} (h : p.Homotopic q) |
| 186 | (a : GenLoop N X x) : Homotopic (boundaryTransport p a) (boundaryTransport q a) := by |
| 187 | obtain ⟨H⟩ := (boundaryTransportHomotopy p a).change_path h |
| 188 | exact (boundaryTransport_homotopic_of_homotopyAlong H).symm |
| 189 | |
| 190 | /-- Transport carries the constant cube to the constant class. |
| 191 | Source: Hatcher, Section 4.1, preservation of identity, p. 341. -/ |
| 192 | theorem boundaryTransport_const (p : Path x y) : |
| 193 | Homotopic (boundaryTransport p (GenLoop.const : GenLoop N X x)) GenLoop.const := |
| 194 | boundaryTransport_homotopic_of_homotopyAlong (HomotopyAlong.const p) |
| 195 | |
| 196 | /-- Transport commutes with continuous postcomposition on cubical classes. |
| 197 | Source: Hatcher, Section 4.1, functoriality, p. 342. -/ |
| 198 | theorem boundaryTransport_map (p : Path x y) (a : GenLoop N X x) (f : C(X, Y)) : |
| 199 | Homotopic |
| 200 | (boundaryTransport (p.map f.continuous) (PoincareMT.Proofs.M02.mapGenLoop f rfl a)) |
| 201 | (PoincareMT.Proofs.M02.mapGenLoop f rfl (boundaryTransport p a)) := |
| 202 | boundaryTransport_homotopic_of_homotopyAlong ((boundaryTransportHomotopy p a).map f) |
| 203 | |
| 204 | end GenLoop |