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.Comparison.PathClassMap |
| 2 | import PoincareLib.AlgebraicTopology.HomotopyGroup.LoopSpace.Comparison.SimplyConnectedCharts |
| 3 | import Mathlib.Topology.Homotopy.Lifting |
| 4 | |
| 5 | /-! |
| 6 | # Explicit paths in the path-class cover |
| 7 | |
| 8 | The path-class cover of the interval is the interval itself. Functoriality |
| 9 | therefore lifts every path to a path ending at its represented class. |
| 10 | Appending an initial class gives the same endpoint formula for arbitrary |
| 11 | starting points. Source: Hatcher, Section 1.3, printed pp. 63-65; used in |
| 12 | MT Claim 18.16, p. 430. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set TopologicalSpace |
| 18 | open scoped unitInterval |
| 19 | |
| 20 | universe u |
| 21 | |
| 22 | namespace PathClassCover |
| 23 | |
| 24 | variable {X : Type u} [TopologicalSpace X] {x y x₀ : X} |
| 25 | |
| 26 | private instance : ContractibleSpace I := |
| 27 | (convex_Icc (0 : ℝ) 1).contractibleSpace ⟨0, le_rfl, zero_le_one⟩ |
| 28 | |
| 29 | /-- Equality of endpoints and of dependent path classes gives equality in |
| 30 | the cover. Source: Hatcher, Section 1.3, printed p. 64. -/ |
| 31 | @[ext] theorem ext {a b : PathClassCover x₀} (h : a.endpoint = b.endpoint) |
| 32 | (hc : HEq a.pathClass b.pathClass) : a = b := by |
| 33 | cases a |
| 34 | cases b |
| 35 | cases h |
| 36 | cases eq_of_heq hc |
| 37 | rfl |
| 38 | |
| 39 | /-- Equal choices of the original basepoint give identical path-class covers. |
| 40 | Source: Hatcher, Section 1.3, printed p. 64. -/ |
| 41 | def basepointCongr (h : x = y) : PathClassCover x ≃ₜ PathClassCover y := by |
| 42 | subst y |
| 43 | exact Homeomorph.refl _ |
| 44 | |
| 45 | /-- Changing the original basepoint by equality does not change endpoints. |
| 46 | Source: Hatcher, Section 1.3, printed p. 64. -/ |
| 47 | @[simp] theorem basepointCongr_endpoint (h : x = y) (a : PathClassCover x) : |
| 48 | (basepointCongr h a).endpoint = a.endpoint := by |
| 49 | subst y |
| 50 | rfl |
| 51 | |
| 52 | /-- Equality transport preserves the constant class point. |
| 53 | Source: Hatcher, Section 1.3, printed p. 64. -/ |
| 54 | @[simp] theorem basepointCongr_basepoint (h : x = y) : |
| 55 | basepointCongr h (basepoint x) = basepoint y := by |
| 56 | subst y |
| 57 | rfl |
| 58 | |
| 59 | /-- On represented paths equality transport is the usual source cast. |
| 60 | Source: Hatcher, Section 1.3, printed p. 64. -/ |
| 61 | theorem basepointCongr_mk_path (h : x = y) {z : X} (p : Path x z) : |
| 62 | basepointCongr h ⟨z, .mk p⟩ = ⟨z, .mk (p.cast h.symm rfl)⟩ := by |
| 63 | subst y |
| 64 | rfl |
| 65 | |
| 66 | private theorem interval_zero : |
| 67 | (endpointHomeomorph (0 : I)).symm 0 = basepoint 0 := by |
| 68 | apply (endpointHomeomorph (0 : I)).injective |
| 69 | simp [basepoint] |
| 70 | |
| 71 | private theorem interval_one : |
| 72 | (endpointHomeomorph (0 : I)).symm 1 = ⟨1, .mk Path.id⟩ := by |
| 73 | apply (endpointHomeomorph (0 : I)).injective |
| 74 | simp |
| 75 | |
| 76 | /-- The canonical lift from the constant class ends at the class of the |
| 77 | original path. Source: Hatcher, Section 1.3, printed p. 64. -/ |
| 78 | noncomputable def pathFromBase (p : Path x y) : |
| 79 | Path (basepoint x) (⟨y, .mk p⟩ : PathClassCover x) where |
| 80 | toFun t := basepointCongr p.source |
| 81 | (map p.toContinuousMap ((endpointHomeomorph (0 : I)).symm t)) |
| 82 | continuous_toFun := (basepointCongr p.source).continuous.comp |
| 83 | ((continuous_map p.toContinuousMap).comp (endpointHomeomorph (0 : I)).symm.continuous) |
| 84 | source' := by |
| 85 | rw [interval_zero, map_basepoint] |
| 86 | exact basepointCongr_basepoint p.source |
| 87 | target' := by |
| 88 | rw [interval_one] |
| 89 | change basepointCongr p.source |
| 90 | ⟨p 1, .mk (Path.id.map p.continuous)⟩ = ⟨y, .mk p⟩ |
| 91 | rw [basepointCongr_mk_path] |
| 92 | exact ext p.target (Path.Homotopic.hpath_hext (fun _ => rfl)) |
| 93 | |
| 94 | /-- The canonical lift projects pointwise to the original path. |
| 95 | Source: Hatcher, Section 1.3, printed p. 64. -/ |
| 96 | @[simp] theorem endpoint_pathFromBase (p : Path x y) (t : I) : |
| 97 | (pathFromBase p t).endpoint = p t := by |
| 98 | change (basepointCongr p.source |
| 99 | (map p.toContinuousMap ((endpointHomeomorph (0 : I)).symm t))).endpoint = p t |
| 100 | rw [basepointCongr_endpoint] |
| 101 | change p ((endpointHomeomorph (0 : I)).symm t).endpoint = p t |
| 102 | rw [← endpointHomeomorph_apply, Homeomorph.apply_symm_apply] |
| 103 | |
| 104 | /-- Prefixing a path class changes the original basepoint of the cover. |
| 105 | Source: Hatcher, Section 1.3, printed pp. 63-65. -/ |
| 106 | noncomputable def append (a : PathClassCover x₀) (b : PathClassCover a.endpoint) : |
| 107 | PathClassCover x₀ := |
| 108 | ⟨b.endpoint, a.pathClass.trans b.pathClass⟩ |
| 109 | |
| 110 | /-- Prefixing the constant class returns the prefix point. |
| 111 | Source: Hatcher, Section 1.3, printed pp. 63-65. -/ |
| 112 | @[simp] theorem append_basepoint (a : PathClassCover x₀) : append a (basepoint a.endpoint) = a := by |
| 113 | cases a |
| 114 | simp [append, basepoint] |
| 115 | |
| 116 | /-- Prefixing classes preserves local sheet membership. |
| 117 | Source: Hatcher, Section 1.3, printed pp. 63-65. -/ |
| 118 | theorem append_mem_sheet (a : PathClassCover x₀) {U : Set X} |
| 119 | {b c : PathClassCover a.endpoint} (hc : c ∈ sheet U b) : |
| 120 | append a c ∈ sheet U (append a b) := by |
| 121 | obtain ⟨p, hp, he⟩ := hc |
| 122 | refine ⟨p, hp, ?_⟩ |
| 123 | change a.pathClass.trans c.pathClass = (a.pathClass.trans b.pathClass).trans (.mk p) |
| 124 | simp [he] |
| 125 | |
| 126 | /-- Prefixing a class is continuous for the sheet topology. |
| 127 | Source: Hatcher, Section 1.3, printed pp. 63-65. -/ |
| 128 | theorem continuous_append [LocallySimplyConnectedSpace X] (a : PathClassCover x₀) : |
| 129 | Continuous (append a) := by |
| 130 | apply continuous_generateFrom_iff.mpr |
| 131 | rintro _ ⟨U, b, hU, hscU, hb, rfl⟩ |
| 132 | apply (isTopologicalBasis a.endpoint).isOpen_iff.mpr |
| 133 | intro c hc |
| 134 | have hcU : c.endpoint ∈ U := by |
| 135 | exact endpoint_mem_of_mem_sheet (a := b) (b := append a c) hc |
| 136 | refine ⟨sheet U c, ⟨U, c, hU, hscU, hcU, rfl⟩, mem_sheet_self c hcU, ?_⟩ |
| 137 | intro d hd |
| 138 | change append a d ∈ sheet U b |
| 139 | rw [← sheet_eq_of_mem (show append a c ∈ sheet U b from hc)] |
| 140 | exact append_mem_sheet a hd |
| 141 | |
| 142 | /-- The path-class cover is path connected: each class is reached by its |
| 143 | representative. Source: Hatcher, Section 1.3, printed p. 64. -/ |
| 144 | instance pathConnectedSpace (x₀ : X) : PathConnectedSpace (PathClassCover x₀) where |
| 145 | nonempty := ⟨basepoint x₀⟩ |
| 146 | joined a b := by |
| 147 | obtain ⟨p, hp⟩ := Path.Homotopic.Quotient.mk_surjective a.pathClass |
| 148 | obtain ⟨q, hq⟩ := Path.Homotopic.Quotient.mk_surjective b.pathClass |
| 149 | have ha : (⟨a.endpoint, .mk p⟩ : PathClassCover x₀) = a := ext rfl (heq_of_eq hp) |
| 150 | have hb : (⟨b.endpoint, .mk q⟩ : PathClassCover x₀) = b := ext rfl (heq_of_eq hq) |
| 151 | exact ⟨((pathFromBase p).symm.trans (pathFromBase q)).cast ha.symm hb.symm⟩ |
| 152 | |
| 153 | end PathClassCover |