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.PolygonApproximation.Polygon.CellCompact |
| 2 | import Mathlib.Analysis.Convex.Measure |
| 3 | |
| 4 | /-! |
| 5 | # Null polygon-cell cuts |
| 6 | |
| 7 | The closed angular cells cover the annulus rectangle. Each is a convex |
| 8 | rectangle, so its frontier has zero planar volume; consequently almost every |
| 9 | domain point lies in the interior of one cell. |
| 10 | |
| 11 | Morgan--Tian context: Section 19.4, Definition 19.18 and Claims 19.19-19.22, printed pp. |
| 12 | 450-453. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | open Set Filter MeasureTheory Bundle |
| 19 | open scoped Manifold ContDiff Topology Bundle ENNReal NNReal |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | namespace PoincareMT |
| 24 | |
| 25 | /-- Every closed angular polygon cell is convex. Source: Auxiliary step for MT Definition |
| 26 | 19.18 and Claims 19.19/19.22, pp. 450-453; project construction in |
| 27 | `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 28 | theorem m64PolygonCellSet_convex {N : ℕ} (j : Fin N) : |
| 29 | Convex ℝ (m64PolygonCellSet j) := by |
| 30 | intro x hx y hy a b ha hb hab |
| 31 | change m63CellLeft N j ≤ (a • x + b • y) 0 ∧ |
| 32 | (a • x + b • y) 0 ≤ m63CellLeft N j + m63CellLength N ∧ |
| 33 | 0 ≤ (a • x + b • y) 1 ∧ (a • x + b • y) 1 ≤ 1 |
| 34 | change m63CellLeft N j ≤ x 0 ∧ x 0 ≤ m63CellLeft N j + m63CellLength N ∧ |
| 35 | 0 ≤ x 1 ∧ x 1 ≤ 1 at hx |
| 36 | change m63CellLeft N j ≤ y 0 ∧ y 0 ≤ m63CellLeft N j + m63CellLength N ∧ |
| 37 | 0 ≤ y 1 ∧ y 1 ≤ 1 at hy |
| 38 | simp only [PiLp.add_apply, PiLp.smul_apply, smul_eq_mul] |
| 39 | refine ⟨?_, ?_, ?_, ?_⟩ |
| 40 | · calc |
| 41 | m63CellLeft N j = a * m63CellLeft N j + b * m63CellLeft N j := by |
| 42 | rw [← add_mul, hab, one_mul] |
| 43 | _ ≤ a * x 0 + b * y 0 := add_le_add |
| 44 | (mul_le_mul_of_nonneg_left hx.1 ha) |
| 45 | (mul_le_mul_of_nonneg_left hy.1 hb) |
| 46 | · calc |
| 47 | a * x 0 + b * y 0 ≤ |
| 48 | a * (m63CellLeft N j + m63CellLength N) + |
| 49 | b * (m63CellLeft N j + m63CellLength N) := |
| 50 | add_le_add (mul_le_mul_of_nonneg_left hx.2.1 ha) |
| 51 | (mul_le_mul_of_nonneg_left hy.2.1 hb) |
| 52 | _ = m63CellLeft N j + m63CellLength N := by rw [← add_mul, hab, one_mul] |
| 53 | · exact add_nonneg (mul_nonneg ha hx.2.2.1) (mul_nonneg hb hy.2.2.1) |
| 54 | · calc |
| 55 | a * x 1 + b * y 1 ≤ a * 1 + b * 1 := |
| 56 | add_le_add (mul_le_mul_of_nonneg_left hx.2.2.2 ha) |
| 57 | (mul_le_mul_of_nonneg_left hy.2.2.2 hb) |
| 58 | _ = 1 := by rw [← add_mul, hab, one_mul] |
| 59 | |
| 60 | /-- The closed cells cover the complete rectangle, including the last angular endpoint. |
| 61 | Source: Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. 450-453; project |
| 62 | construction in `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 63 | theorem m64_polygon_cells_cover {N : ℕ} (hN : 0 < N) : |
| 64 | ∀ p ∈ m64AnnulusDomain, ∃ j : Fin N, p ∈ m64PolygonCellSet j := by |
| 65 | intro p hp |
| 66 | have hell : 0 < m63CellLength N := m63CellLength_pos hN |
| 67 | have hNell : (N : ℝ) * m63CellLength N = curvePeriod := |
| 68 | m63_count_mul_cellLength hN |
| 69 | have hleft : 0 ≤ p 0 := hp.1 |
| 70 | rcases lt_or_eq_of_le hp.2.1 with hlt | hperiod |
| 71 | · have hdiv : 0 ≤ p 0 / m63CellLength N := div_nonneg hleft hell.le |
| 72 | have hj : Nat.floor (p 0 / m63CellLength N) < N := |
| 73 | (Nat.floor_lt hdiv).mpr ((div_lt_iff₀ hell).mpr (by simpa [hNell] using hlt)) |
| 74 | let j : Fin N := ⟨Nat.floor (p 0 / m63CellLength N), hj⟩ |
| 75 | refine ⟨j, ?_⟩ |
| 76 | change m63CellLeft N j ≤ p 0 ∧ |
| 77 | p 0 ≤ m63CellLeft N j + m63CellLength N ∧ 0 ≤ p 1 ∧ p 1 ≤ 1 |
| 78 | have hfloor : (Nat.floor (p 0 / m63CellLength N) : ℝ) ≤ |
| 79 | p 0 / m63CellLength N := Nat.floor_le hdiv |
| 80 | have hnext := Nat.lt_floor_add_one (p 0 / m63CellLength N) |
| 81 | refine ⟨?_, ?_, hp.2.2.1, hp.2.2.2⟩ |
| 82 | · exact (le_div_iff₀ hell).mp hfloor |
| 83 | · dsimp [m63CellLeft] |
| 84 | have hnext' : p 0 / m63CellLength N < |
| 85 | (Nat.floor (p 0 / m63CellLength N) : ℝ) + 1 := hnext |
| 86 | apply (div_lt_iff₀ hell).mp at hnext' |
| 87 | linarith |
| 88 | · let j : Fin N := ⟨N - 1, by omega⟩ |
| 89 | refine ⟨j, ?_⟩ |
| 90 | change m63CellLeft N j ≤ p 0 ∧ |
| 91 | p 0 ≤ m63CellLeft N j + m63CellLength N ∧ 0 ≤ p 1 ∧ p 1 ≤ 1 |
| 92 | have hn : ((N - 1 : ℕ) : ℝ) + 1 = N := by |
| 93 | exact_mod_cast (by omega : N - 1 + 1 = N) |
| 94 | refine ⟨?_, ?_, hp.2.2.1, hp.2.2.2⟩ |
| 95 | · have hle : m63CellLeft N j ≤ curvePeriod := by |
| 96 | dsimp [j, m63CellLeft] |
| 97 | rw [← hNell] |
| 98 | exact mul_le_mul_of_nonneg_right |
| 99 | (by exact_mod_cast (Nat.sub_le N 1)) hell.le |
| 100 | exact hle.trans_eq hperiod.symm |
| 101 | · dsimp [j, m63CellLeft] |
| 102 | calc |
| 103 | p 0 = curvePeriod := hperiod |
| 104 | _ = ((N - 1 : ℕ) : ℝ) * m63CellLength N + m63CellLength N := by |
| 105 | rw [← hNell, ← hn] |
| 106 | ring |
| 107 | _ ≤ ((N - 1 : ℕ) : ℝ) * m63CellLength N + m63CellLength N := le_rfl |
| 108 | |
| 109 | /-- Almost every rectangle point lies inside one polygon cell because the finite frontiers |
| 110 | are null. Source: Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. |
| 111 | 450-453; project construction in |
| 112 | `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 113 | theorem m64_polygon_cells_interior_ae {N : ℕ} (hN : 0 < N) : |
| 114 | ∀ᵐ p ∂volume.restrict m64AnnulusDomain, |
| 115 | ∃ j : Fin N, p ∈ interior (m64PolygonCellSet j) := by |
| 116 | have hfront : ∀ j : Fin N, |
| 117 | volume (frontier (m64PolygonCellSet j)) = 0 := by |
| 118 | intro j |
| 119 | exact Convex.addHaar_frontier volume (m64PolygonCellSet_convex j) |
| 120 | have hfront_union : volume (⋃ j : Fin N, frontier (m64PolygonCellSet j)) = 0 := |
| 121 | measure_iUnion_null hfront |
| 122 | let U : Set LoopPlane := ⋃ j : Fin N, interior (m64PolygonCellSet j) |
| 123 | have hbad : volume (m64AnnulusDomain \ U) = 0 := by |
| 124 | apply measure_mono_null _ hfront_union |
| 125 | intro p hp |
| 126 | obtain ⟨j, hj⟩ := m64_polygon_cells_cover hN p hp.1 |
| 127 | have hnot : p ∉ interior (m64PolygonCellSet j) := by |
| 128 | intro hi |
| 129 | exact hp.2 (show p ∈ U from mem_iUnion.mpr ⟨j, hi⟩) |
| 130 | apply mem_iUnion.mpr |
| 131 | refine ⟨j, ?_⟩ |
| 132 | change p ∈ closure (m64PolygonCellSet j) \ interior (m64PolygonCellSet j) |
| 133 | exact ⟨subset_closure hj, hnot⟩ |
| 134 | apply (ae_restrict_iff' m64AnnulusDomain_measurableSet).2 |
| 135 | apply ae_iff.mpr |
| 136 | have hcomp : {p : LoopPlane | |
| 137 | ¬ (p ∈ m64AnnulusDomain → ∃ j : Fin N, |
| 138 | p ∈ interior (m64PolygonCellSet j))} = |
| 139 | m64AnnulusDomain \ U := by |
| 140 | ext p |
| 141 | simp [U] |
| 142 | rw [hcomp] |
| 143 | exact hbad |
| 144 | |
| 145 | end PoincareMT |