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.Geometry.Manifold.Algebra.Structures |
| 2 | import Mathlib.LinearAlgebra.Matrix.NonsingularInverse |
| 3 | |
| 4 | /-! # Smooth matrix inversion in manifold coordinates -/ |
| 5 | |
| 6 | set_option autoImplicit false |
| 7 | |
| 8 | open scoped Manifold ContDiff |
| 9 | |
| 10 | namespace Poincare.Manifold |
| 11 | |
| 12 | variable {E H M : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 13 | [TopologicalSpace H] {I : ModelWithCorners ℝ E H} |
| 14 | [TopologicalSpace M] [ChartedSpace H M] |
| 15 | {ι : Type*} [Fintype ι] [DecidableEq ι] |
| 16 | |
| 17 | lemma contMDiffAt_matrix_det (G : M → Matrix ι ι ℝ) (x : M) |
| 18 | (hG : ∀ i j, ContMDiffAt I 𝓘(ℝ, ℝ) ∞ (fun y => G y i j) x) : |
| 19 | ContMDiffAt I 𝓘(ℝ, ℝ) ∞ (fun y => (G y).det) x := by |
| 20 | simp only [Matrix.det_apply'] |
| 21 | exact ContMDiffAt.sum fun σ _ => contMDiffAt_const.mul |
| 22 | (ContMDiffAt.prod fun i _ => hG (σ i) i) |
| 23 | |
| 24 | lemma contMDiffAt_matrix_inv_entry (G : M → Matrix ι ι ℝ) (x : M) |
| 25 | (hG : ∀ i j, ContMDiffAt I 𝓘(ℝ, ℝ) ∞ (fun y => G y i j) x) |
| 26 | (hx : (G x).det ≠ 0) (i j : ι) : |
| 27 | ContMDiffAt I 𝓘(ℝ, ℝ) ∞ (fun y => (G y)⁻¹ i j) x := by |
| 28 | simp only [Matrix.inv_def, Ring.inverse_eq_inv, Matrix.smul_apply, smul_eq_mul, |
| 29 | Matrix.adjugate_apply] |
| 30 | apply ((contMDiffAt_matrix_det G x hG).inv₀ hx).mul |
| 31 | apply contMDiffAt_matrix_det |
| 32 | intro a b |
| 33 | by_cases ha : a = j |
| 34 | · subst a |
| 35 | simpa using (contMDiffAt_const (I := I) (x := x) (n := ∞) |
| 36 | (c := (Pi.single i (1 : ℝ) : ι → ℝ) b)) |
| 37 | · simpa [Matrix.updateRow_apply, ha] using hG a b |
| 38 | |
| 39 | end Poincare.Manifold |