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.Geometry.CurveShortening.Comparison.Compatibility.SourceNames |
| 2 | import PoincareLib.Geometry.CurveShortening.Ramp.Approximation.Sampled.PolygonLength |
| 3 | import PoincareLib.Geometry.CurveShortening.Comparison.PolygonApproximation.Polygon.CellBoundaryNull |
| 4 | |
| 5 | /-! |
| 6 | # Quantitative distance to a sampled polygon |
| 7 | |
| 8 | A loop with speed at most `S` stays within `2 * S * cellLength` of any |
| 9 | minimizing polygon through its sampled vertices. Each term in the triangle |
| 10 | inequality is bounded by the original cell arc. Periodicity extends the |
| 11 | estimate from the fundamental interval to every real angular parameter. |
| 12 | |
| 13 | Morgan--Tian context: Section 19.4, Definition 19.18 and Claims 19.19-19.22, printed pp. |
| 14 | 450-453. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | set_option backward.isDefEq.respectTransparency false |
| 19 | |
| 20 | open Set MeasureTheory Bundle |
| 21 | open scoped Manifold ContDiff Topology ENNReal intervalIntegral |
| 22 | |
| 23 | universe u |
| 24 | |
| 25 | namespace PoincareMT |
| 26 | |
| 27 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 28 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] |
| 29 | [IsManifold (𝓡 n) ∞ M] |
| 30 | |
| 31 | /-- Bound the endpoint distance of a C1 subarc by its speed bound times parameter length. |
| 32 | Source: Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. 450-453; project |
| 33 | construction in `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 34 | theorem m64_c1_subarc_edist_le_speed |
| 35 | (g : RiemannianMetric n M) {gamma : ℝ → M} |
| 36 | (hgamma : ContMDiff 𝓘(ℝ, ℝ) (𝓡 n) 1 gamma) |
| 37 | {S s t : ℝ} (hs : 0 ≤ s) (hst : s ≤ t) (ht : t ≤ curvePeriod) |
| 38 | (hbound : ∀ x ∈ Icc (0 : ℝ) curvePeriod, |
| 39 | g.tangentNorm (gamma x) (curveVelocity gamma x) ≤ S) : |
| 40 | g.edist (gamma s) (gamma t) ≤ ENNReal.ofReal (S * (t - s)) := by |
| 41 | have hd := g.edist_le_pathELength_of_mem_Icc hgamma.contMDiffOn |
| 42 | (show t ∈ Icc s t from ⟨hst, le_rfl⟩) |
| 43 | rw [M04.pathELength_eq_ofReal_integral_pathSpeed g hgamma hst] at hd |
| 44 | apply hd.trans (ENNReal.ofReal_le_ofReal ?_) |
| 45 | have hi := intervalIntegral.integral_mono_on (μ := volume) hst |
| 46 | ((M04.continuous_pathSpeed g hgamma).intervalIntegrable s t) |
| 47 | (continuous_const.intervalIntegrable s t) |
| 48 | (fun x hx => hbound x ⟨hs.trans hx.1, hx.2.trans ht⟩) |
| 49 | simpa only [M04.pathSpeed, curveVelocity, intervalIntegral.integral_const, |
| 50 | smul_eq_mul, mul_comm] using hi |
| 51 | |
| 52 | /-- The endpoint distance of an initial part of a minimizing side is at most its full |
| 53 | length. Source: Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. 450-453; |
| 54 | project construction in `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 55 | theorem m64_minimizing_side_prefix_edist_le |
| 56 | {g : RiemannianMetric n M} {D : LeviCivitaData g} |
| 57 | {ell s : ℝ} {p q : M} |
| 58 | (side : M63MinimizingGeodesicSide g D ell p q) |
| 59 | (hs : s ∈ Icc (0 : ℝ) ell) : |
| 60 | g.edist p (side.map s) ≤ g.edist p q := by |
| 61 | have hside : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 n) 1 side.map (Icc (0 : ℝ) ell) := |
| 62 | (side.smooth.of_le (m := 1) (by norm_num)).mono side.interval_subset |
| 63 | have hd := g.edist_le_pathELength_of_mem_Icc hside hs |
| 64 | simpa only [side.start, side.minimizing] using hd |
| 65 | |
| 66 | /-- On a closed cell the source loop and sampled polygon are within twice the source |
| 67 | arc-length bound. Source: Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. |
| 68 | 450-453; project construction in |
| 69 | `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 70 | theorem m64_sampled_polygon_cell_edist_le |
| 71 | {g : RiemannianMetric n M} {D : LeviCivitaData g} |
| 72 | {N : ℕ} (hN : 0 < N) (polygon : M63GeodesicPolygon g D N) |
| 73 | {gamma : ℝ → M} |
| 74 | (hgamma : ContMDiff 𝓘(ℝ, ℝ) (𝓡 n) 1 gamma) |
| 75 | (hperiodic : Function.Periodic gamma curvePeriod) |
| 76 | (hvertices : ∀ j : Fin N, polygon.vertices j = gamma (m63CellLeft N j)) |
| 77 | {S : ℝ} (hS : 0 ≤ S) |
| 78 | (hbound : ∀ x ∈ Icc (0 : ℝ) curvePeriod, |
| 79 | g.tangentNorm (gamma x) (curveVelocity gamma x) ≤ S) |
| 80 | (j : Fin N) {s : ℝ} (hs : s ∈ Icc (0 : ℝ) (m63CellLength N)) : |
| 81 | g.edist (gamma (m63CellLeft N j + s)) |
| 82 | (polygon.map (m63CellLeft N j + s)) ≤ |
| 83 | ENNReal.ofReal (2 * S * m63CellLength N) := by |
| 84 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 85 | ⟨g.toRiemannianMetric⟩ |
| 86 | have hell : 0 < m63CellLength N := m63CellLength_pos hN |
| 87 | have hleft : 0 ≤ m63CellLeft N j := |
| 88 | mul_nonneg (Nat.cast_nonneg _) hell.le |
| 89 | have hj : (j.val : ℝ) + 1 ≤ N := by |
| 90 | exact_mod_cast Nat.succ_le_of_lt j.isLt |
| 91 | have hright : m63CellLeft N j + m63CellLength N ≤ curvePeriod := by |
| 92 | calc |
| 93 | _ = ((j.val : ℝ) + 1) * m63CellLength N := by |
| 94 | dsimp only [m63CellLeft] |
| 95 | ring |
| 96 | _ ≤ (N : ℝ) * m63CellLength N := |
| 97 | mul_le_mul_of_nonneg_right hj hell.le |
| 98 | _ = curvePeriod := m63_count_mul_cellLength hN |
| 99 | have hadj : g.edist (polygon.vertices j) (polygon.vertices (finRotate N j)) ≤ |
| 100 | ENNReal.ofReal (S * m63CellLength N) := by |
| 101 | rw [hvertices j, hvertices (finRotate N j), |
| 102 | m63PeriodicLoop_cell_finish hperiodic hN j] |
| 103 | simpa only [add_sub_cancel_left] using |
| 104 | m64_c1_subarc_edist_le_speed g hgamma hleft |
| 105 | (le_add_of_nonneg_right hell.le) hright hbound |
| 106 | have hside : g.edist (polygon.vertices j) ((polygon.side j).map s) ≤ |
| 107 | ENNReal.ofReal (S * m63CellLength N) := |
| 108 | (m64_minimizing_side_prefix_edist_le (polygon.side j) hs).trans hadj |
| 109 | have horiginal : g.edist (polygon.vertices j) |
| 110 | (gamma (m63CellLeft N j + s)) ≤ |
| 111 | ENNReal.ofReal (S * m63CellLength N) := by |
| 112 | rw [hvertices j] |
| 113 | have h := m64_c1_subarc_edist_le_speed g hgamma hleft |
| 114 | (le_add_of_nonneg_right hs.1) |
| 115 | (by linarith [hs.2]) hbound |
| 116 | apply h.trans (ENNReal.ofReal_le_ofReal ?_) |
| 117 | rw [add_sub_cancel_left] |
| 118 | exact mul_le_mul_of_nonneg_left hs.2 hS |
| 119 | rw [polygon.cell_agreement j s hs] |
| 120 | have htri : g.edist (gamma (m63CellLeft N j + s)) ((polygon.side j).map s) ≤ |
| 121 | g.edist (gamma (m63CellLeft N j + s)) (polygon.vertices j) + |
| 122 | g.edist (polygon.vertices j) ((polygon.side j).map s) := |
| 123 | Manifold.riemannianEDist_triangle |
| 124 | have hrev : g.edist (gamma (m63CellLeft N j + s)) (polygon.vertices j) = |
| 125 | g.edist (polygon.vertices j) (gamma (m63CellLeft N j + s)) := |
| 126 | Manifold.riemannianEDist_comm |
| 127 | rw [hrev] at htri |
| 128 | apply (htri.trans (add_le_add horiginal hside)).trans_eq |
| 129 | rw [← ENNReal.ofReal_add (mul_nonneg hS hell.le) (mul_nonneg hS hell.le)] |
| 130 | congr 1 |
| 131 | ring |
| 132 | |
| 133 | /-- Periodicity extends the quantitative sampled-polygon distance bound to every real angle. |
| 134 | Source: Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. 450-453; project |
| 135 | construction in `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 136 | theorem m64_sampled_polygon_edist_le |
| 137 | {g : RiemannianMetric n M} {D : LeviCivitaData g} |
| 138 | {N : ℕ} (hN : 0 < N) (polygon : M63GeodesicPolygon g D N) |
| 139 | {gamma : ℝ → M} |
| 140 | (hgamma : ContMDiff 𝓘(ℝ, ℝ) (𝓡 n) 1 gamma) |
| 141 | (hperiodic : Function.Periodic gamma curvePeriod) |
| 142 | (hvertices : ∀ j : Fin N, polygon.vertices j = gamma (m63CellLeft N j)) |
| 143 | {S : ℝ} (hS : 0 ≤ S) |
| 144 | (hbound : ∀ x ∈ Icc (0 : ℝ) curvePeriod, |
| 145 | g.tangentNorm (gamma x) (curveVelocity gamma x) ≤ S) : |
| 146 | ∀ x : ℝ, g.edist (gamma x) (polygon.map x) ≤ |
| 147 | ENNReal.ofReal (2 * S * m63CellLength N) := by |
| 148 | have hon {x : ℝ} (hx : x ∈ Icc (0 : ℝ) curvePeriod) : |
| 149 | g.edist (gamma x) (polygon.map x) ≤ |
| 150 | ENNReal.ofReal (2 * S * m63CellLength N) := by |
| 151 | obtain ⟨j, hj⟩ := m64_polygon_cells_cover hN (annulusPoint x 0) |
| 152 | (show annulusPoint x 0 ∈ m64AnnulusDomain from |
| 153 | ⟨hx.1, hx.2, le_rfl, zero_le_one⟩) |
| 154 | change m63CellLeft N j ≤ x ∧ |
| 155 | x ≤ m63CellLeft N j + m63CellLength N ∧ |
| 156 | 0 ≤ (0 : ℝ) ∧ (0 : ℝ) ≤ 1 at hj |
| 157 | have hs : x - m63CellLeft N j ∈ Icc (0 : ℝ) (m63CellLength N) := by |
| 158 | constructor <;> linarith [hj.1, hj.2.1] |
| 159 | have hh := m64_sampled_polygon_cell_edist_le hN polygon hgamma hperiodic |
| 160 | hvertices hS hbound j hs |
| 161 | rw [show m63CellLeft N j + (x - m63CellLeft N j) = x by ring] at hh |
| 162 | exact hh |
| 163 | intro x |
| 164 | let k : ℤ := Int.floor (x / curvePeriod) |
| 165 | let y : ℝ := x - (k : ℝ) * curvePeriod |
| 166 | have hy : y ∈ Icc (0 : ℝ) curvePeriod := by |
| 167 | have h0 := (le_div_iff₀ Real.two_pi_pos).mp (Int.floor_le (x / curvePeriod)) |
| 168 | have h1 := (div_lt_iff₀ Real.two_pi_pos).mp |
| 169 | (Int.lt_floor_add_one (x / curvePeriod)) |
| 170 | dsimp only [y, k] |
| 171 | dsimp only [curvePeriod] at h0 h1 ⊢ |
| 172 | constructor <;> linarith only [h0, h1] |
| 173 | have hx : x = y + (k : ℝ) * curvePeriod := by dsimp only [y]; ring |
| 174 | rw [hx, hperiodic.int_mul k y, polygon.periodic.int_mul k y] |
| 175 | exact hon hy |
| 176 | |
| 177 | end PoincareMT |