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 PoincareLib.Geometry.Riemannian.Tensor.Product |
| 2 | import PoincareLib.Geometry.Riemannian.Tensor.Trace |
| 3 | import PoincareLib.Geometry.RicciFlow.Curvature.Reaction |
| 4 | import PoincareLib.Geometry.Riemannian.Tensor.ProductDerivative |
| 5 | import PoincareLib.Geometry.Riemannian.Tensor.TraceRegularity |
| 6 | import PoincareLib.Geometry.Riemannian.Tensor.Linearity |
| 7 | import PoincareLib.Geometry.Riemannian.Tensor.Algebra |
| 8 | |
| 9 | set_option autoImplicit false |
| 10 | set_option backward.isDefEq.respectTransparency false |
| 11 | |
| 12 | open scoped Manifold ContDiff Bundle Topology BigOperators |
| 13 | |
| 14 | universe u |
| 15 | |
| 16 | namespace PoincareMT.LeviCivitaData |
| 17 | |
| 18 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 19 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 20 | {g : RiemannianMetric n M} |
| 21 | |
| 22 | /-- The double metric trace of the permuted curvature-Ricci product is the |
| 23 | curvature-Ricci contraction occurring in `ricciReaction`. -/ |
| 24 | lemma tensorTrace_tensorTrace_curvatureRicci |
| 25 | (D : LeviCivitaData g) (x : M) |
| 26 | (a b : TangentSpace (𝓡 n) x) : |
| 27 | g.tensorTrace (g.tensorTrace (fun y z => |
| 28 | tensorProduct D.riemannEvaluation D.ricciEvaluation y |
| 29 | (z ∘ (Equiv.ofBijective ![4, 0, 5, 2, 1, 3] (by decide))))) x ![a, b] = |
| 30 | ∑ d, ∑ e, D.curvatureTensor x a (g.orthonormalBasis x d) b |
| 31 | (g.orthonormalBasis x e) * D.ricci x (g.orthonormalBasis x d) |
| 32 | (g.orthonormalBasis x e) := by |
| 33 | let σ : Equiv.Perm (Fin 6) := |
| 34 | Equiv.ofBijective ![4, 0, 5, 2, 1, 3] (by decide) |
| 35 | simp only [RiemannianMetric.tensorTrace] |
| 36 | rw [Finset.sum_comm] |
| 37 | apply Finset.sum_congr rfl |
| 38 | intro d hd |
| 39 | apply Finset.sum_congr rfl |
| 40 | intro e he |
| 41 | have hz : |
| 42 | (Fin.cons (g.orthonormalBasis x d) |
| 43 | (Fin.cons (g.orthonormalBasis x d) |
| 44 | (Fin.cons (g.orthonormalBasis x e) |
| 45 | (Fin.cons (g.orthonormalBasis x e) ![a, b]))) : |
| 46 | Fin 6 → TangentSpace (𝓡 n) x) ∘ σ = |
| 47 | ![a, g.orthonormalBasis x d, b, g.orthonormalBasis x e, |
| 48 | g.orthonormalBasis x d, g.orthonormalBasis x e] := by |
| 49 | ext i |
| 50 | fin_cases i <;> rfl |
| 51 | change tensorProduct D.riemannEvaluation D.ricciEvaluation x |
| 52 | ((Fin.cons (g.orthonormalBasis x d) |
| 53 | (Fin.cons (g.orthonormalBasis x d) |
| 54 | (Fin.cons (g.orthonormalBasis x e) |
| 55 | (Fin.cons (g.orthonormalBasis x e) ![a, b]))) : |
| 56 | Fin 6 → TangentSpace (𝓡 n) x) ∘ σ) = _ |
| 57 | rw [hz] |
| 58 | simp only [tensorProduct] |
| 59 | unfold riemannEvaluation ricciEvaluation |
| 60 | rfl |
| 61 | |
| 62 | lemma curvatureRicci_eq_double_trace (D : LeviCivitaData g) : |
| 63 | (fun y (z : Fin 2 → TangentSpace (𝓡 n) y) => |
| 64 | ∑ i, ∑ j, D.curvatureTensor y (z 0) (g.orthonormalBasis y i) (z 1) |
| 65 | (g.orthonormalBasis y j) * D.ricci y (g.orthonormalBasis y i) |
| 66 | (g.orthonormalBasis y j)) = |
| 67 | g.tensorTrace (g.tensorTrace (fun y z => |
| 68 | tensorProduct D.riemannEvaluation D.ricciEvaluation y |
| 69 | (z ∘ (Equiv.ofBijective ![4, 0, 5, 2, 1, 3] (by decide))))) := by |
| 70 | funext x z |
| 71 | have hz : ![z 0, z 1] = z := by ext i; fin_cases i <;> rfl |
| 72 | simpa only [hz] using (D.tensorTrace_tensorTrace_curvatureRicci x (z 0) (z 1)).symm |
| 73 | |
| 74 | /-- Differentiation of the curvature-Ricci contraction, with the metric |
| 75 | traces taken through the covariant derivative. -/ |
| 76 | lemma covariantTensorDerivative_curvatureRicci |
| 77 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) |
| 78 | (x : M) (a b c : TangentSpace (𝓡 n) x) : |
| 79 | D.covariantTensorDerivative (fun y z => |
| 80 | ∑ i, ∑ j, D.curvatureTensor y (z 0) (g.orthonormalBasis y i) (z 1) |
| 81 | (g.orthonormalBasis y j) * D.ricci y (g.orthonormalBasis y i) |
| 82 | (g.orthonormalBasis y j)) x ![a, b, c] = |
| 83 | ∑ i, ∑ j, (D.covariantTensorDerivative D.riemannEvaluation x |
| 84 | ![a, b, g.orthonormalBasis x i, c, g.orthonormalBasis x j] * |
| 85 | D.ricci x (g.orthonormalBasis x i) (g.orthonormalBasis x j) + |
| 86 | D.curvatureTensor x b (g.orthonormalBasis x i) c (g.orthonormalBasis x j) * |
| 87 | D.covariantTensorDerivative D.ricciEvaluation x |
| 88 | ![a, g.orthonormalBasis x i, g.orthonormalBasis x j]) := by |
| 89 | let σ : Equiv.Perm (Fin 6) := Equiv.ofBijective ![4, 0, 5, 2, 1, 3] (by decide) |
| 90 | let S := fun y z => tensorProduct D.riemannEvaluation D.ricciEvaluation y (z ∘ σ) |
| 91 | have hS : IsSmoothCovariantTensor S := |
| 92 | (isSmoothCovariantTensor_tensorProduct hD.1 hD.2.1).perm σ |
| 93 | rw [D.curvatureRicci_eq_double_trace] |
| 94 | have ht := D.covariantTensorDerivative_tensorTrace (hS.tensorTrace (g := g)) x a ![b, c] |
| 95 | simp only [Matrix.Fin.cons_vecCons] at ht |
| 96 | rw [ht] |
| 97 | have ht' (i : Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x))) := |
| 98 | D.covariantTensorDerivative_tensorTrace hS x a |
| 99 | ![g.orthonormalBasis x i, g.orthonormalBasis x i, b, c] |
| 100 | simp only [Matrix.Fin.cons_vecCons] at ht' |
| 101 | simp_rw [ht'] |
| 102 | rw [Finset.sum_comm] |
| 103 | apply Finset.sum_congr rfl |
| 104 | intro i _ |
| 105 | apply Finset.sum_congr rfl |
| 106 | intro j _ |
| 107 | change D.covariantTensorDerivative S x |
| 108 | ![a, g.orthonormalBasis x i, g.orthonormalBasis x i, |
| 109 | g.orthonormalBasis x j, g.orthonormalBasis x j, b, c] = _ |
| 110 | dsimp only [S] |
| 111 | rw [D.covariantTensorDerivative_reindex] |
| 112 | have hz : Fin.cons a (fun q : Fin 6 => |
| 113 | ![a, g.orthonormalBasis x i, g.orthonormalBasis x i, |
| 114 | g.orthonormalBasis x j, g.orthonormalBasis x j, b, c] (σ q).succ) = |
| 115 | ![a, b, g.orthonormalBasis x i, c, g.orthonormalBasis x j, |
| 116 | g.orthonormalBasis x i, g.orthonormalBasis x j] := by |
| 117 | ext q |
| 118 | fin_cases q <;> rfl |
| 119 | change D.covariantTensorDerivative (tensorProduct D.riemannEvaluation D.ricciEvaluation) x |
| 120 | (Fin.cons a (fun q : Fin 6 => |
| 121 | ![a, g.orthonormalBasis x i, g.orthonormalBasis x i, |
| 122 | g.orthonormalBasis x j, g.orthonormalBasis x j, b, c] (σ q).succ)) = _ |
| 123 | rw [hz] |
| 124 | have hp := D.covariantTensorDerivative_tensorProduct hD.1 hD.2.1 x a |
| 125 | ![b, g.orthonormalBasis x i, c, g.orthonormalBasis x j, |
| 126 | g.orthonormalBasis x i, g.orthonormalBasis x j] |
| 127 | simp only [Matrix.Fin.cons_vecCons] at hp |
| 128 | rw [hp] |
| 129 | have hv₁ : (fun q : Fin 4 => |
| 130 | ![b, g.orthonormalBasis x i, c, g.orthonormalBasis x j, |
| 131 | g.orthonormalBasis x i, g.orthonormalBasis x j] (Fin.castAdd 2 q)) = |
| 132 | ![b, g.orthonormalBasis x i, c, g.orthonormalBasis x j] := by |
| 133 | ext q |
| 134 | fin_cases q <;> rfl |
| 135 | have hv₂ : (fun q : Fin 2 => |
| 136 | ![b, g.orthonormalBasis x i, c, g.orthonormalBasis x j, |
| 137 | g.orthonormalBasis x i, g.orthonormalBasis x j] (Fin.natAdd 4 q)) = |
| 138 | ![g.orthonormalBasis x i, g.orthonormalBasis x j] := by |
| 139 | ext q |
| 140 | fin_cases q <;> rfl |
| 141 | rw [hv₁, hv₂] |
| 142 | rfl |
| 143 | |
| 144 | lemma isSmoothCovariantTensor_curvatureRicci |
| 145 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) : |
| 146 | IsSmoothCovariantTensor (fun y (z : Fin 2 → TangentSpace (𝓡 n) y) => |
| 147 | ∑ i, ∑ j, D.curvatureTensor y (z 0) (g.orthonormalBasis y i) (z 1) |
| 148 | (g.orthonormalBasis y j) * D.ricci y (g.orthonormalBasis y i) |
| 149 | (g.orthonormalBasis y j)) := by |
| 150 | rw [D.curvatureRicci_eq_double_trace] |
| 151 | exact ((isSmoothCovariantTensor_tensorProduct hD.1 hD.2.1).perm _).tensorTrace.tensorTrace |
| 152 | |
| 153 | lemma isSmoothCovariantTensor_ricciReaction |
| 154 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) : |
| 155 | IsSmoothCovariantTensor (fun y (z : Fin 2 → TangentSpace (𝓡 n) y) => |
| 156 | D.ricciReaction y (z 0) (z 1)) := by |
| 157 | exact ((D.isSmoothCovariantTensor_curvatureRicci hD).const_mul 2).sub |
| 158 | ((D.isSmoothCovariantTensor_tensorProduct_trace_order_two hD.2.1 hD.2.1).const_mul 2) |
| 159 | |
| 160 | /-- Spatial differentiation of both quadratic terms in Ricci evolution. -/ |
| 161 | lemma covariantTensorDerivative_ricciReaction |
| 162 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) |
| 163 | (x : M) (a b c : TangentSpace (𝓡 n) x) : |
| 164 | let e := g.orthonormalBasis x |
| 165 | D.covariantTensorDerivative (fun y z => D.ricciReaction y (z 0) (z 1)) x ![a, b, c] = |
| 166 | 2 * (∑ i, ∑ j, (D.covariantTensorDerivative D.riemannEvaluation x ![a, b, e i, c, e j] * |
| 167 | D.ricci x (e i) (e j) + D.curvatureTensor x b (e i) c (e j) * |
| 168 | D.covariantTensorDerivative D.ricciEvaluation x ![a, e i, e j])) - |
| 169 | 2 * (∑ i, (D.covariantTensorDerivative D.ricciEvaluation x ![a, b, e i] * |
| 170 | D.ricci x (e i) c + D.ricci x b (e i) * |
| 171 | D.covariantTensorDerivative D.ricciEvaluation x ![a, e i, c])) := by |
| 172 | have hC := D.isSmoothCovariantTensor_curvatureRicci hD |
| 173 | have hQ := D.isSmoothCovariantTensor_tensorProduct_trace_order_two hD.2.1 hD.2.1 |
| 174 | change D.covariantTensorDerivative (fun y z => |
| 175 | 2 * (∑ i, ∑ j, D.curvatureTensor y (z 0) (g.orthonormalBasis y i) (z 1) |
| 176 | (g.orthonormalBasis y j) * D.ricci y (g.orthonormalBasis y i) (g.orthonormalBasis y j)) - |
| 177 | 2 * (∑ i, D.ricciEvaluation y ![z 0, g.orthonormalBasis y i] * |
| 178 | D.ricciEvaluation y ![g.orthonormalBasis y i, z 1])) x ![a, b, c] = _ |
| 179 | rw [D.covariantTensorDerivative_sub (hC.const_mul 2) (hQ.const_mul 2)] |
| 180 | dsimp only |
| 181 | rw [D.covariantTensorDerivative_const_mul hC, D.covariantTensorDerivative_const_mul hQ] |
| 182 | dsimp only |
| 183 | rw [D.covariantTensorDerivative_curvatureRicci hD, |
| 184 | D.covariantTensorDerivative_tensorProduct_trace_order_two hD.2.1 hD.2.1] |
| 185 | rfl |
| 186 | |
| 187 | end PoincareMT.LeviCivitaData |