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.Analysis.Calculus.ContDiff.Operations |
| 2 | import Mathlib.LinearAlgebra.Matrix.NonsingularInverse |
| 3 | |
| 4 | /-! |
| 5 | # Smooth matrix inversion on a nonsingular parameter set |
| 6 | |
| 7 | The finite determinant and adjugate formulas preserve within-smoothness. |
| 8 | This gives the parameter regularity of the actual cylinder connection |
| 9 | in Morgan-Tian Proposition 12.7, pp. 298-299; see the closed-time |
| 10 | intrinsic-jet derivation. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set |
| 16 | open scoped ContDiff BigOperators |
| 17 | |
| 18 | variable {𝕜 E ι : Type*} [NontriviallyNormedField 𝕜] |
| 19 | [NormedAddCommGroup E] [NormedSpace 𝕜 E] [Fintype ι] [DecidableEq ι] |
| 20 | {n : ℕ∞ω} {S : Set E} {A : E → Matrix ι ι 𝕜} |
| 21 | |
| 22 | /-- Entrywise within-smoothness passes to the finite determinant |
| 23 | (Proposition 12.7, pp. 298-299, parameter regularity). -/ |
| 24 | theorem ContDiffOn.matrix_det (hA : ∀ a b, ContDiffOn 𝕜 n (fun x => A x a b) S) : |
| 25 | ContDiffOn 𝕜 n (fun x => (A x).det) S := by |
| 26 | classical |
| 27 | have heq : (fun x => (A x).det) = fun x => |
| 28 | ∑ σ : Equiv.Perm ι, (Equiv.Perm.sign σ : 𝕜) * ∏ i, A x (σ i) i := by |
| 29 | funext x |
| 30 | simp [Matrix.det_apply, Units.smul_def] |
| 31 | rw [heq] |
| 32 | exact ContDiffOn.sum fun σ _ => contDiffOn_const.mul |
| 33 | (contDiffOn_prod fun i _ => hA (σ i) i) |
| 34 | |
| 35 | /-- The actual matrix inverse is entrywise smooth wherever the |
| 36 | determinant does not vanish (Proposition 12.7, pp. 298-299). -/ |
| 37 | theorem ContDiffOn.matrix_inv (hA : ∀ a b, ContDiffOn 𝕜 n (fun x => A x a b) S) |
| 38 | (hdet : ∀ x ∈ S, (A x).det ≠ 0) (a b : ι) : |
| 39 | ContDiffOn 𝕜 n (fun x => (A x)⁻¹ a b) S := by |
| 40 | classical |
| 41 | simp only [Matrix.inv_def, Matrix.smul_apply, smul_eq_mul, Ring.inverse_eq_inv', |
| 42 | Matrix.adjugate_apply] |
| 43 | apply ((ContDiffOn.matrix_det hA).inv hdet).mul |
| 44 | apply ContDiffOn.matrix_det |
| 45 | intro i j |
| 46 | by_cases hi : i = b |
| 47 | · subst i |
| 48 | simpa only [Matrix.updateRow_self] using |
| 49 | (contDiffOn_const (c := (Pi.single a (1 : 𝕜) : ι → 𝕜) j) : |
| 50 | ContDiffOn 𝕜 n (fun _ : E => (Pi.single a (1 : 𝕜) : ι → 𝕜) j) S) |
| 51 | · simpa only [Matrix.updateRow_ne hi] using hA i j |