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 Mathlib.Topology.Homotopy.HomotopyGroup |
| 2 | |
| 3 | /-! |
| 4 | # Paths in spaces of cubical loops |
| 5 | |
| 6 | The compact-open topology identifies paths of based cubes with homotopies |
| 7 | relative to their boundary. This makes the loop-space adjunction compatible |
| 8 | with the actual representatives. Source: Hatcher, Section 4.1, pp. 340-342. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open scoped Topology unitInterval |
| 14 | |
| 15 | namespace GenLoop |
| 16 | |
| 17 | variable {N X : Type*} [TopologicalSpace X] {x : X} |
| 18 | |
| 19 | /-- A homotopy relative to the cube boundary is a path of based cubes. |
| 20 | Source: Hatcher, Section 4.1, pp. 340-342. -/ |
| 21 | def pathOfHomotopy {f g : GenLoop N X x} |
| 22 | (H : f.val.HomotopyRel g.val (Cube.boundary N)) : Path f g where |
| 23 | toFun t := ⟨H.toContinuousMap.curry t, fun v hv => |
| 24 | (H.eq_fst t hv).trans (GenLoop.boundary f v hv)⟩ |
| 25 | continuous_toFun := H.toContinuousMap.curry.continuous.subtype_mk _ |
| 26 | source' := by ext v; exact H.apply_zero v |
| 27 | target' := by ext v; exact H.apply_one v |
| 28 | |
| 29 | /-- A path of based cubes gives a homotopy relative to their boundary. |
| 30 | Source: Hatcher, Section 4.1, pp. 340-342. -/ |
| 31 | def homotopyOfPath {f g : GenLoop N X x} (p : Path f g) : |
| 32 | f.val.HomotopyRel g.val (Cube.boundary N) where |
| 33 | toFun q := p q.1 q.2 |
| 34 | continuous_toFun := by fun_prop |
| 35 | map_zero_left := by intro v; rw [p.source]; rfl |
| 36 | map_one_left := by intro v; rw [p.target]; rfl |
| 37 | prop' := fun t v hv => |
| 38 | (GenLoop.boundary (p t) v hv).trans (GenLoop.boundary f v hv).symm |
| 39 | |
| 40 | /-- Based cube homotopy is precisely path connectedness in the cube space. |
| 41 | Source: Hatcher, Section 4.1, pp. 340-342. -/ |
| 42 | theorem homotopic_iff_nonempty_path {f g : GenLoop N X x} : |
| 43 | Homotopic f g ↔ Nonempty (Path f g) := |
| 44 | ⟨Nonempty.map pathOfHomotopy, Nonempty.map homotopyOfPath⟩ |
| 45 | |
| 46 | /-- Vanishing of the cubical homotopy set makes its representative space |
| 47 | path connected. Source: Hatcher, Section 4.1, pp. 340-342. -/ |
| 48 | theorem pathConnectedSpace_of_subsingleton |
| 49 | (h : Subsingleton (HomotopyGroup N X x)) : PathConnectedSpace (GenLoop N X x) where |
| 50 | nonempty := inferInstance |
| 51 | joined f g := homotopic_iff_nonempty_path.mp (Quotient.exact (h.elim ⟦f⟧ ⟦g⟧)) |
| 52 | |
| 53 | end GenLoop |
| 54 | |
| 55 | namespace HomotopyGroup |
| 56 | |
| 57 | /-- A homeomorphism of spaces of based cubes descends to their homotopy sets. |
| 58 | Source: Hatcher, Section 4.1, pp. 340-342. -/ |
| 59 | def equivOfGenLoopHomeomorph {N P X Y : Type*} |
| 60 | [TopologicalSpace X] [TopologicalSpace Y] {x : X} {y : Y} |
| 61 | (e : GenLoop N X x ≃ₜ GenLoop P Y y) : |
| 62 | HomotopyGroup N X x ≃ HomotopyGroup P Y y := |
| 63 | Quotient.congr e.toEquiv fun f g => by |
| 64 | change GenLoop.Homotopic f g ↔ GenLoop.Homotopic (e f) (e g) |
| 65 | rw [GenLoop.homotopic_iff_nonempty_path, GenLoop.homotopic_iff_nonempty_path] |
| 66 | constructor |
| 67 | · exact Nonempty.map (fun p => p.map e.continuous) |
| 68 | · exact Nonempty.map (fun p => |
| 69 | (p.map e.symm.continuous).cast (e.symm_apply_apply f).symm |
| 70 | (e.symm_apply_apply g).symm) |
| 71 | |
| 72 | end HomotopyGroup |