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.LinearAlgebra.Matrix.BilinearForm |
| 2 | import Mathlib.LinearAlgebra.Matrix.Determinant.Basic |
| 3 | import Mathlib.Analysis.Real.Sqrt |
| 4 | |
| 5 | /-! |
| 6 | # Gram determinants in an orthonormal target basis |
| 7 | |
| 8 | The algebraic Jacobian identity used in Morgan-Tian Lemma 6.71, p. 141. |
| 9 | It applies to arbitrary real modules with finite bases, including singular |
| 10 | maps and the zero-dimensional case. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | namespace LinearMap.BilinForm |
| 16 | |
| 17 | /-- The square root of the nonnegative Gram determinant is the absolute |
| 18 | coordinate determinant when the target basis is orthonormal. This is the |
| 19 | algebraic Jacobian identity in Morgan-Tian Lemma 6.71, p. 141. -/ |
| 20 | theorem sqrt_max_det_comp_eq_abs_det_toMatrix |
| 21 | {ι : Type*} [Fintype ι] [DecidableEq ι] |
| 22 | {V W : Type*} [AddCommMonoid V] [Module ℝ V] |
| 23 | [AddCommMonoid W] [Module ℝ W] |
| 24 | (b : Module.Basis ι ℝ V) (c : Module.Basis ι ℝ W) |
| 25 | (g : LinearMap.BilinForm ℝ W) |
| 26 | (hc : ∀ i j, g (c i) (c j) = if i = j then 1 else 0) |
| 27 | (A : V →ₗ[ℝ] W) : |
| 28 | Real.sqrt (max 0 (Matrix.det (fun i j => g (A (b i)) (A (b j))))) = |
| 29 | |Matrix.det (LinearMap.toMatrix b c A)| := by |
| 30 | have hg : toMatrix c g = 1 := by |
| 31 | ext i j |
| 32 | simpa only [toMatrix_apply, Matrix.one_apply] using hc i j |
| 33 | have hm : (fun i j => g (A (b i)) (A (b j))) = |
| 34 | (LinearMap.toMatrix b c A).transpose * LinearMap.toMatrix b c A := by |
| 35 | have h := toMatrix_comp c b g A A |
| 36 | rw [hg, Matrix.mul_one] at h |
| 37 | have heq : (fun i j => g (A (b i)) (A (b j))) = toMatrix b (g.comp A A) := by |
| 38 | ext i j |
| 39 | simp only [toMatrix_apply, comp_apply] |
| 40 | exact heq.trans h |
| 41 | have hd : Matrix.det (fun i j => g (A (b i)) (A (b j))) = |
| 42 | Matrix.det (LinearMap.toMatrix b c A) ^ 2 := by |
| 43 | rw [hm, Matrix.det_mul, Matrix.det_transpose, pow_two] |
| 44 | rw [hd, max_eq_right (sq_nonneg _), Real.sqrt_sq_eq_abs] |
| 45 | |
| 46 | end LinearMap.BilinForm |