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.Instances.Matrix |
| 2 | import Mathlib.Analysis.SpecialFunctions.Sqrt |
| 3 | import Mathlib.Topology.MetricSpace.Pseudo.Pi |
| 4 | |
| 5 | /-! |
| 6 | Adapted from Mapher `PoincareMT/Proofs/M49/Mathlib/GramDensity.lean` at |
| 7 | revision `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. |
| 8 | |
| 9 | # Uniform volume-density tolerances |
| 10 | |
| 11 | Morgan-Tian Definition 2.16, p. 30, controls the normalized metric |
| 12 | coefficients. The continuous square-root determinant gives a uniform |
| 13 | density comparison, used in Lemma 17.12, p. 410. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | |
| 18 | open Set |
| 19 | |
| 20 | namespace Matrix |
| 21 | |
| 22 | open scoped Classical in |
| 23 | /-- Uniform entrywise closeness to the identity controls Gram density, |
| 24 | as used in MT Definition 2.16, p. 30, and Lemma 17.12, p. 410. -/ |
| 25 | theorem exists_pos_entrywise_sqrt_det_bounds (ι : Type*) [Fintype ι] : |
| 26 | ∃ eta : ℝ, 0 < eta ∧ ∀ A : Matrix ι ι ℝ, |
| 27 | (∀ i j, |A i j - if i = j then 1 else 0| ≤ eta) → |
| 28 | (1 / 2 : ℝ) ≤ Real.sqrt A.det ∧ Real.sqrt A.det ≤ 2 := by |
| 29 | classical |
| 30 | have hc : Continuous (fun A : ι → ι → ℝ => Real.sqrt (Matrix.det A)) := |
| 31 | Real.continuous_sqrt.comp continuous_id.matrix_det |
| 32 | obtain ⟨d, hd, hbound⟩ := (Metric.continuousAt_iff (α := ι → ι → ℝ)).mp |
| 33 | (hc.continuousAt (x := (1 : Matrix ι ι ℝ))) |
| 34 | (1 / 2) (by norm_num) |
| 35 | refine ⟨d / 2, half_pos hd, ?_⟩ |
| 36 | intro A hA |
| 37 | have hdist : dist (show ι → ι → ℝ from A) (1 : Matrix ι ι ℝ) ≤ d / 2 := by |
| 38 | apply (dist_pi_le_iff (half_pos hd).le).mpr |
| 39 | intro i |
| 40 | apply (dist_pi_le_iff (half_pos hd).le).mpr |
| 41 | intro j |
| 42 | simpa only [Real.dist_eq, Matrix.one_apply] using hA i j |
| 43 | have hb := hbound (show dist (show ι → ι → ℝ from A) (1 : Matrix ι ι ℝ) < d by |
| 44 | linarith) |
| 45 | simp only [Matrix.det_one, Real.sqrt_one, Real.dist_eq] at hb |
| 46 | have hb' := abs_lt.mp hb |
| 47 | constructor <;> linarith |
| 48 | |
| 49 | /-- Entrywise closeness to any fixed positive density preserves half |
| 50 | that density (MT Definition 2.16, p. 30; Lemma 17.12, p. 410). -/ |
| 51 | theorem exists_pos_entrywise_sqrt_det_lower {ι : Type*} [Fintype ι] [DecidableEq ι] |
| 52 | (A : Matrix ι ι ℝ) (hA : 0 < Real.sqrt A.det) : |
| 53 | ∃ eta : ℝ, 0 < eta ∧ ∀ B : Matrix ι ι ℝ, |
| 54 | (∀ i j, |B i j - A i j| ≤ eta) → |
| 55 | Real.sqrt A.det / 2 ≤ Real.sqrt B.det := by |
| 56 | have hc : Continuous (fun B : ι → ι → ℝ => Real.sqrt (Matrix.det B)) := |
| 57 | Real.continuous_sqrt.comp continuous_id.matrix_det |
| 58 | obtain ⟨d, hd, hbound⟩ := (Metric.continuousAt_iff (α := ι → ι → ℝ)).mp |
| 59 | (hc.continuousAt (x := A)) (Real.sqrt A.det / 2) (half_pos hA) |
| 60 | refine ⟨d / 2, half_pos hd, ?_⟩ |
| 61 | intro B hB |
| 62 | have hdist : dist (show ι → ι → ℝ from B) A ≤ d / 2 := by |
| 63 | apply (dist_pi_le_iff (half_pos hd).le).mpr |
| 64 | intro i |
| 65 | apply (dist_pi_le_iff (half_pos hd).le).mpr |
| 66 | intro j |
| 67 | simpa only [Real.dist_eq] using hB i j |
| 68 | have hb := hbound (show dist (show ι → ι → ℝ from B) A < d by linarith) |
| 69 | rw [Real.dist_eq, abs_lt] at hb |
| 70 | linarith [hb.1] |
| 71 | |
| 72 | end Matrix |