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 | /- Adapted from Mapher `PoincareMT/Proofs/M03/Existence/MatrixMetricTraceNative.lean` at |
| 2 | f927d9e1f0810042766d3b5f64d3f4da02ee93cc. See |
| 3 | `references/ricci-flow/mapher/local-theory/port.json`. -/ |
| 4 | |
| 5 | import Mathlib.Analysis.InnerProductSpace.GramMatrix |
| 6 | import Mathlib.LinearAlgebra.Matrix.Basis |
| 7 | |
| 8 | /-! |
| 9 | # The metric trace in an arbitrary basis |
| 10 | |
| 11 | The product of the orthonormal-to-basis transition matrix and its transpose |
| 12 | is the inverse Gram matrix. Expanding both slots of a bilinear map gives |
| 13 | the inverse-Gram contraction formula for its orthonormal trace. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | set_option maxHeartbeats 1600000 |
| 18 | |
| 19 | open scoped BigOperators Matrix |
| 20 | |
| 21 | noncomputable section |
| 22 | |
| 23 | namespace PoincareMT.DeTurckNative |
| 24 | |
| 25 | variable {V F ι κ : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] |
| 26 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 27 | [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] |
| 28 | |
| 29 | theorem sum_orthonormal_coordinates_eq_inverse_gram |
| 30 | (e : OrthonormalBasis κ ℝ V) (b : Module.Basis ι ℝ V) (i j : ι) : |
| 31 | (∑ r, b.repr (e r) i * b.repr (e r) j) = (Matrix.gram ℝ b)⁻¹ i j := by |
| 32 | let C : Matrix κ ι ℝ := e.toBasis.toMatrix b |
| 33 | let D : Matrix ι κ ℝ := b.toMatrix e.toBasis |
| 34 | have hCD : C * D = 1 := e.toBasis.toMatrix_mul_toMatrix_flip b |
| 35 | have hDC : D * C = 1 := b.toMatrix_mul_toMatrix_flip e.toBasis |
| 36 | have hC : (Matrix.of fun r a => e.repr (b a) r) = C := by |
| 37 | ext r a |
| 38 | simp only [Matrix.of_apply, C, Module.Basis.toMatrix_apply, |
| 39 | OrthonormalBasis.coe_toBasis_repr_apply] |
| 40 | have hG : Matrix.gram ℝ b = Cᵀ * C := by |
| 41 | simpa only [hC, Matrix.conjTranspose_eq_transpose_of_trivial] using |
| 42 | (Matrix.gram_eq_conjTranspose_mul e b) |
| 43 | have hleft : (D * Dᵀ) * Matrix.gram ℝ b = 1 := by |
| 44 | calc |
| 45 | (D * Dᵀ) * Matrix.gram ℝ b = (D * Dᵀ) * (Cᵀ * C) := by rw [hG] |
| 46 | _ = D * (Dᵀ * Cᵀ) * C := by simp only [Matrix.mul_assoc] |
| 47 | _ = D * (C * D)ᵀ * C := by rw [Matrix.transpose_mul] |
| 48 | _ = 1 := by rw [hCD, Matrix.transpose_one, Matrix.mul_one, hDC] |
| 49 | have hinv : (Matrix.gram ℝ b)⁻¹ = D * Dᵀ := Matrix.inv_eq_left_inv hleft |
| 50 | have hentry := congrArg (fun A : Matrix ι ι ℝ => A i j) hinv |
| 51 | simpa only [Matrix.mul_apply, Matrix.transpose_apply, D, Module.Basis.toMatrix_apply, |
| 52 | OrthonormalBasis.coe_toBasis] using hentry.symm |
| 53 | |
| 54 | theorem orthonormal_trace_eq_inverse_gram |
| 55 | (e : OrthonormalBasis κ ℝ V) (b : Module.Basis ι ℝ V) |
| 56 | (A : V →L[ℝ] V →L[ℝ] F) : |
| 57 | (∑ r, A (e r) (e r)) = |
| 58 | ∑ i, ∑ j, (Matrix.gram ℝ b)⁻¹ i j • A (b i) (b j) := by |
| 59 | have hexpand (v w : V) : |
| 60 | A v w = ∑ i, ∑ j, (b.repr v i * b.repr w j) • A (b i) (b j) := by |
| 61 | calc |
| 62 | A v w = A (∑ i, b.repr v i • b i) (∑ j, b.repr w j • b j) := by |
| 63 | rw [b.sum_repr, b.sum_repr] |
| 64 | _ = _ := by |
| 65 | simp only [map_sum, ContinuousLinearMap.sum_apply, map_smul, |
| 66 | ContinuousLinearMap.smul_apply, Finset.smul_sum, smul_smul] |
| 67 | rw [Finset.sum_comm] |
| 68 | simp only [mul_comm] |
| 69 | calc |
| 70 | (∑ r, A (e r) (e r)) = |
| 71 | ∑ r, ∑ i, ∑ j, (b.repr (e r) i * b.repr (e r) j) • A (b i) (b j) := by |
| 72 | exact Finset.sum_congr rfl fun r _ => hexpand (e r) (e r) |
| 73 | _ = ∑ i, ∑ j, (∑ r, b.repr (e r) i * b.repr (e r) j) • A (b i) (b j) := by |
| 74 | rw [Finset.sum_comm] |
| 75 | apply Finset.sum_congr rfl |
| 76 | intro i _ |
| 77 | rw [Finset.sum_comm] |
| 78 | apply Finset.sum_congr rfl |
| 79 | intro j _ |
| 80 | exact Finset.sum_smul.symm |
| 81 | _ = _ := by |
| 82 | simp only [sum_orthonormal_coordinates_eq_inverse_gram e b] |
| 83 | |
| 84 | end PoincareMT.DeTurckNative |
| 85 | |
| 86 | end |