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.Determinant |
| 3 | import Mathlib.Analysis.Real.Sqrt |
| 4 | |
| 5 | /-! |
| 6 | # Gram determinant under a source equivalence |
| 7 | |
| 8 | The square root of a nonnegative Gram determinant changes by the |
| 9 | absolute source determinant. This algebraic identity requires no |
| 10 | positivity assumption on the bilinear form and includes dimension |
| 11 | zero. Morgan-Tian Lemma 6.71, p. 141. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | namespace PoincareMT.M14 |
| 17 | |
| 18 | /-- A source equivalence scales the nonnegative Gram square root by |
| 19 | its absolute determinant, Lemma 6.71, p. 141. -/ |
| 20 | theorem sqrt_max_det_bilin_source_equiv |
| 21 | {V : Type*} [AddCommGroup V] [Module ℝ V] {n : ℕ} |
| 22 | (b : Module.Basis (Fin n) ℝ V) (B : LinearMap.BilinForm ℝ V) (C : V ≃ₗ[ℝ] V) : |
| 23 | Real.sqrt (max 0 (Matrix.det (fun i j => B (C (b i)) (C (b j))))) = |
| 24 | |LinearMap.det C.toLinearMap| * |
| 25 | Real.sqrt (max 0 (Matrix.det (fun i j => B (b i) (b j)))) := by |
| 26 | have hm := LinearMap.BilinForm.toMatrix_comp b b B C.toLinearMap C.toLinearMap |
| 27 | have hd := congrArg Matrix.det hm |
| 28 | simp only [Matrix.det_mul, Matrix.det_transpose, LinearMap.det_toMatrix] at hd |
| 29 | have hg : Matrix.det (fun i j => B (C (b i)) (C (b j))) = |
| 30 | LinearMap.det C.toLinearMap ^ 2 * Matrix.det (fun i j => B (b i) (b j)) := by |
| 31 | have hleft : (fun i j => B (C (b i)) (C (b j))) = |
| 32 | LinearMap.BilinForm.toMatrix b (B.comp C.toLinearMap C.toLinearMap) := by |
| 33 | ext i j |
| 34 | simp only [LinearMap.BilinForm.toMatrix_apply, LinearMap.BilinForm.comp_apply] |
| 35 | rfl |
| 36 | have hright : (fun i j => B (b i) (b j)) = LinearMap.BilinForm.toMatrix b B := by |
| 37 | ext i j |
| 38 | simp only [LinearMap.BilinForm.toMatrix_apply] |
| 39 | rw [hleft, hright, hd] |
| 40 | ring |
| 41 | rw [hg] |
| 42 | have hmax : max 0 (LinearMap.det C.toLinearMap ^ 2 * |
| 43 | Matrix.det (fun i j => B (b i) (b j))) = |
| 44 | LinearMap.det C.toLinearMap ^ 2 * max 0 (Matrix.det (fun i j => B (b i) (b j))) := by |
| 45 | rw [mul_max_of_nonneg _ _ (sq_nonneg _), mul_zero] |
| 46 | rw [hmax, Real.sqrt_mul (sq_nonneg _), Real.sqrt_sq_eq_abs] |
| 47 | |
| 48 | end PoincareMT.M14 |