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.RicciFlow.Harnack.Matrix.Positivity.Diagonal |
| 2 | import PoincareLib.Geometry.Riemannian.Tensor.MetricDuality |
| 3 | |
| 4 | /-! # Coordinate changes of the Hamilton block |
| 5 | |
| 6 | Positive semidefiniteness is preserved when all covariant inputs of Hamilton's |
| 7 | block are changed by the same linear map. |
| 8 | -/ |
| 9 | |
| 10 | set_option autoImplicit false |
| 11 | set_option backward.isDefEq.respectTransparency false |
| 12 | |
| 13 | open scoped BigOperators Manifold ContDiff Bundle |
| 14 | open Matrix |
| 15 | |
| 16 | namespace Poincare.RicciFlow.Harnack |
| 17 | |
| 18 | variable {I J : Type*} [Fintype I] [Fintype J] |
| 19 | |
| 20 | /-- Covariant change of coordinates preserves positivity of the full |
| 21 | curvature/mixed/two-tensor block. The coordinate map need not be invertible. -/ |
| 22 | lemma hamiltonBlock_posSemidef_change_coordinates |
| 23 | (R : I → I → I → I → ℝ) (P : I → I → I → ℝ) (M : I → I → ℝ) |
| 24 | (C : J → I → ℝ) |
| 25 | (hQ : (Matrix.fromBlocks |
| 26 | (fun ac bd : I × I => R ac.1 ac.2 bd.1 bd.2) |
| 27 | (fun (ac : I × I) d => P ac.1 ac.2 d) |
| 28 | (fun c (bd : I × I) => P bd.1 bd.2 c) M).PosSemidef) : |
| 29 | (Matrix.fromBlocks |
| 30 | (fun ac bd : J × J => ∑ a, ∑ b, ∑ c, ∑ d, |
| 31 | C ac.1 a * C ac.2 b * R a b c d * C bd.1 c * C bd.2 d) |
| 32 | (fun (ac : J × J) d => ∑ a, ∑ b, ∑ c, |
| 33 | C ac.1 a * C ac.2 b * P a b c * C d c) |
| 34 | (fun c (bd : J × J) => ∑ a, ∑ b, ∑ d, |
| 35 | C bd.1 a * C bd.2 b * P a b d * C c d) |
| 36 | (fun a b => ∑ c, ∑ d, C a c * M c d * C b d)).PosSemidef := by |
| 37 | classical |
| 38 | let B : Matrix ((J × J) ⊕ J) ((I × I) ⊕ I) ℝ := |
| 39 | Matrix.fromBlocks (fun ab cd => C ab.1 cd.1 * C ab.2 cd.2) 0 0 C |
| 40 | have h := hQ.mul_mul_conjTranspose_same B |
| 41 | have hsum (f : I → I → I → I → ℝ) : |
| 42 | (∑ a, ∑ b, ∑ c, ∑ d, f a b c d) = ∑ c, ∑ d, ∑ a, ∑ b, f a b c d := by |
| 43 | rw [Finset.sum_comm_cycle] |
| 44 | apply Finset.sum_congr rfl |
| 45 | intro c _ |
| 46 | exact Finset.sum_comm_cycle |
| 47 | convert h using 1 |
| 48 | ext (ab | a) (cd | c) |
| 49 | · simp only [Matrix.mul_apply, B, Fintype.sum_sum_type, Fintype.sum_prod_type, |
| 50 | Matrix.fromBlocks_apply₁₁, Matrix.fromBlocks_apply₁₂, |
| 51 | Matrix.conjTranspose_apply, star_trivial, Matrix.zero_apply, |
| 52 | zero_mul, mul_zero, Finset.sum_const_zero, add_zero, Finset.sum_mul] |
| 53 | rw [hsum] |
| 54 | apply Finset.sum_congr rfl |
| 55 | intro i _ |
| 56 | apply Finset.sum_congr rfl |
| 57 | intro j _ |
| 58 | apply Finset.sum_congr rfl |
| 59 | intro k _ |
| 60 | apply Finset.sum_congr rfl |
| 61 | intro l _ |
| 62 | ring |
| 63 | · simp only [Matrix.mul_apply, B, Fintype.sum_sum_type, Fintype.sum_prod_type, |
| 64 | Matrix.fromBlocks_apply₁₁, Matrix.fromBlocks_apply₁₂, |
| 65 | Matrix.fromBlocks_apply₂₁, Matrix.fromBlocks_apply₂₂, |
| 66 | Matrix.conjTranspose_apply, star_trivial, Matrix.zero_apply, |
| 67 | zero_mul, mul_zero, Finset.sum_const_zero, add_zero, zero_add, |
| 68 | Finset.sum_mul] |
| 69 | rw [Finset.sum_comm_cycle] |
| 70 | · simp only [Matrix.mul_apply, B, Fintype.sum_sum_type, Fintype.sum_prod_type, |
| 71 | Matrix.fromBlocks_apply₁₁, Matrix.fromBlocks_apply₁₂, |
| 72 | Matrix.fromBlocks_apply₂₁, Matrix.fromBlocks_apply₂₂, |
| 73 | Matrix.conjTranspose_apply, star_trivial, Matrix.zero_apply, |
| 74 | zero_mul, mul_zero, Finset.sum_const_zero, add_zero, zero_add, |
| 75 | Finset.sum_mul] |
| 76 | apply Finset.sum_congr rfl |
| 77 | intro i _ |
| 78 | apply Finset.sum_congr rfl |
| 79 | intro j _ |
| 80 | apply Finset.sum_congr rfl |
| 81 | intro k _ |
| 82 | ring |
| 83 | · simp only [Matrix.mul_apply, B, Fintype.sum_sum_type, |
| 84 | Matrix.fromBlocks_apply₂₁, Matrix.fromBlocks_apply₂₂, |
| 85 | Matrix.conjTranspose_apply, star_trivial, Matrix.zero_apply, |
| 86 | zero_mul, mul_zero, Finset.sum_const_zero, zero_add, Finset.sum_mul] |
| 87 | rw [Finset.sum_comm] |
| 88 | |
| 89 | open PoincareMT |
| 90 | |
| 91 | universe u |
| 92 | |
| 93 | variable {n : ℕ} {N : Type u} [TopologicalSpace N] |
| 94 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) N] [IsManifold (𝓡 n) ∞ N] |
| 95 | |
| 96 | lemma tensor_two_expansion (g : RiemannianMetric n N) |
| 97 | {T : CovariantTensorEvaluation n N 2} (hT : IsSmoothCovariantTensor T) |
| 98 | (x : N) (u v : TangentSpace (𝓡 n) x) : |
| 99 | T x ![u, v] = ∑ a, ∑ b, g.inner x u (g.orthonormalBasis x a) * |
| 100 | T x ![g.orthonormalBasis x a, g.orthonormalBasis x b] * |
| 101 | g.inner x v (g.orthonormalBasis x b) := by |
| 102 | have h₀ : T x ![u, v] = ∑ a, g.inner x u (g.orthonormalBasis x a) * |
| 103 | T x ![g.orthonormalBasis x a, v] := by |
| 104 | have he (q) : Function.update ![u, v] 0 q = ![q, v] := by |
| 105 | ext i; fin_cases i <;> simp [Function.update] |
| 106 | simpa only [he] using hT.update_eq_sum g x ![u, v] 0 u |
| 107 | have h₁ (w) : T x ![w, v] = ∑ b, g.inner x v (g.orthonormalBasis x b) * |
| 108 | T x ![w, g.orthonormalBasis x b] := by |
| 109 | have he (q) : Function.update ![w, v] 1 q = ![w, q] := by |
| 110 | ext i; fin_cases i <;> simp [Function.update] |
| 111 | simpa only [he] using hT.update_eq_sum g x ![w, v] 1 v |
| 112 | rw [h₀] |
| 113 | simp_rw [h₁, Finset.mul_sum] |
| 114 | apply Finset.sum_congr rfl |
| 115 | intro a _ |
| 116 | apply Finset.sum_congr rfl |
| 117 | intro b _ |
| 118 | ring |
| 119 | |
| 120 | lemma tensor_three_expansion (g : RiemannianMetric n N) |
| 121 | {T : CovariantTensorEvaluation n N 3} (hT : IsSmoothCovariantTensor T) |
| 122 | (x : N) (u v w : TangentSpace (𝓡 n) x) : |
| 123 | T x ![u, v, w] = ∑ a, ∑ b, ∑ c, |
| 124 | g.inner x u (g.orthonormalBasis x a) * g.inner x v (g.orthonormalBasis x b) * |
| 125 | T x ![g.orthonormalBasis x a, g.orthonormalBasis x b, g.orthonormalBasis x c] * |
| 126 | g.inner x w (g.orthonormalBasis x c) := by |
| 127 | have h₀ : T x ![u, v, w] = ∑ a, g.inner x u (g.orthonormalBasis x a) * |
| 128 | T x ![g.orthonormalBasis x a, v, w] := by |
| 129 | have he (q) : Function.update ![u, v, w] 0 q = ![q, v, w] := by |
| 130 | ext i; fin_cases i <;> simp [Function.update] |
| 131 | simpa only [he] using hT.update_eq_sum g x ![u, v, w] 0 u |
| 132 | have h₁ (q) : T x ![q, v, w] = ∑ b, g.inner x v (g.orthonormalBasis x b) * |
| 133 | T x ![q, g.orthonormalBasis x b, w] := by |
| 134 | have he (r) : Function.update ![q, v, w] 1 r = ![q, r, w] := by |
| 135 | ext i; fin_cases i <;> simp [Function.update] |
| 136 | simpa only [he] using hT.update_eq_sum g x ![q, v, w] 1 v |
| 137 | have h₂ (q r) : T x ![q, r, w] = ∑ c, g.inner x w (g.orthonormalBasis x c) * |
| 138 | T x ![q, r, g.orthonormalBasis x c] := by |
| 139 | have he (s) : Function.update ![q, r, w] 2 s = ![q, r, s] := by |
| 140 | ext i; fin_cases i <;> simp [Function.update] |
| 141 | simpa only [he] using hT.update_eq_sum g x ![q, r, w] 2 w |
| 142 | rw [h₀] |
| 143 | simp_rw [h₁, h₂, Finset.mul_sum] |
| 144 | apply Finset.sum_congr rfl |
| 145 | intro a _ |
| 146 | apply Finset.sum_congr rfl |
| 147 | intro b _ |
| 148 | apply Finset.sum_congr rfl |
| 149 | intro c _ |
| 150 | ring |
| 151 | |
| 152 | lemma tensor_four_expansion (g : RiemannianMetric n N) |
| 153 | {T : CovariantTensorEvaluation n N 4} (hT : IsSmoothCovariantTensor T) |
| 154 | (x : N) (u v w z : TangentSpace (𝓡 n) x) : |
| 155 | T x ![u, v, w, z] = ∑ a, ∑ b, ∑ c, ∑ d, |
| 156 | g.inner x u (g.orthonormalBasis x a) * g.inner x v (g.orthonormalBasis x b) * |
| 157 | T x ![g.orthonormalBasis x a, g.orthonormalBasis x b, |
| 158 | g.orthonormalBasis x c, g.orthonormalBasis x d] * |
| 159 | g.inner x w (g.orthonormalBasis x c) * g.inner x z (g.orthonormalBasis x d) := by |
| 160 | have h₀ : T x ![u, v, w, z] = ∑ a, g.inner x u (g.orthonormalBasis x a) * |
| 161 | T x ![g.orthonormalBasis x a, v, w, z] := by |
| 162 | have he (q) : Function.update ![u, v, w, z] 0 q = ![q, v, w, z] := by |
| 163 | ext i; fin_cases i <;> simp [Function.update] |
| 164 | simpa only [he] using hT.update_eq_sum g x ![u, v, w, z] 0 u |
| 165 | have h₁ (q) : T x ![q, v, w, z] = ∑ b, g.inner x v (g.orthonormalBasis x b) * |
| 166 | T x ![q, g.orthonormalBasis x b, w, z] := by |
| 167 | have he (r) : Function.update ![q, v, w, z] 1 r = ![q, r, w, z] := by |
| 168 | ext i; fin_cases i <;> simp [Function.update] |
| 169 | simpa only [he] using hT.update_eq_sum g x ![q, v, w, z] 1 v |
| 170 | have h₂ (q r) : T x ![q, r, w, z] = ∑ c, g.inner x w (g.orthonormalBasis x c) * |
| 171 | T x ![q, r, g.orthonormalBasis x c, z] := by |
| 172 | have he (s) : Function.update ![q, r, w, z] 2 s = ![q, r, s, z] := by |
| 173 | ext i; fin_cases i <;> simp [Function.update] |
| 174 | simpa only [he] using hT.update_eq_sum g x ![q, r, w, z] 2 w |
| 175 | have h₃ (q r s) : T x ![q, r, s, z] = ∑ d, g.inner x z (g.orthonormalBasis x d) * |
| 176 | T x ![q, r, s, g.orthonormalBasis x d] := by |
| 177 | have he (t) : Function.update ![q, r, s, z] 3 t = ![q, r, s, t] := by |
| 178 | ext i; fin_cases i <;> simp [Function.update] |
| 179 | simpa only [he] using hT.update_eq_sum g x ![q, r, s, z] 3 z |
| 180 | rw [h₀] |
| 181 | simp_rw [h₁, h₂, h₃, Finset.mul_sum] |
| 182 | apply Finset.sum_congr rfl |
| 183 | intro a _ |
| 184 | apply Finset.sum_congr rfl |
| 185 | intro b _ |
| 186 | apply Finset.sum_congr rfl |
| 187 | intro c _ |
| 188 | apply Finset.sum_congr rfl |
| 189 | intro d _ |
| 190 | ring |
| 191 | |
| 192 | /-- Positivity in the metric's canonical basis implies positivity on any |
| 193 | finite family of tangent inputs, including the radial contact fields. -/ |
| 194 | theorem tensor_block_posSemidef_of_basis |
| 195 | (g : RiemannianMetric n N) |
| 196 | {R : CovariantTensorEvaluation n N 4} {P : CovariantTensorEvaluation n N 3} |
| 197 | {B : CovariantTensorEvaluation n N 2} |
| 198 | (hR : IsSmoothCovariantTensor R) (hP : IsSmoothCovariantTensor P) |
| 199 | (hB : IsSmoothCovariantTensor B) (x : N) |
| 200 | (hQ : (Matrix.fromBlocks |
| 201 | (fun ac bd : Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x)) × |
| 202 | Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x)) => |
| 203 | R x ![g.orthonormalBasis x ac.1, g.orthonormalBasis x ac.2, |
| 204 | g.orthonormalBasis x bd.1, g.orthonormalBasis x bd.2]) |
| 205 | (fun ac d => P x ![g.orthonormalBasis x ac.1, g.orthonormalBasis x ac.2, |
| 206 | g.orthonormalBasis x d]) |
| 207 | (fun c bd => P x ![g.orthonormalBasis x bd.1, g.orthonormalBasis x bd.2, |
| 208 | g.orthonormalBasis x c]) |
| 209 | (fun a b => B x ![g.orthonormalBasis x a, g.orthonormalBasis x b])).PosSemidef) |
| 210 | (e : J → TangentSpace (𝓡 n) x) : |
| 211 | (Matrix.fromBlocks (fun ac bd : J × J => R x ![e ac.1, e ac.2, e bd.1, e bd.2]) |
| 212 | (fun ac d => P x ![e ac.1, e ac.2, e d]) |
| 213 | (fun c bd => P x ![e bd.1, e bd.2, e c]) |
| 214 | (fun a b => B x ![e a, e b])).PosSemidef := by |
| 215 | have h := hamiltonBlock_posSemidef_change_coordinates |
| 216 | (fun a b c d => R x ![g.orthonormalBasis x a, g.orthonormalBasis x b, |
| 217 | g.orthonormalBasis x c, g.orthonormalBasis x d]) |
| 218 | (fun a b c => P x ![g.orthonormalBasis x a, g.orthonormalBasis x b, |
| 219 | g.orthonormalBasis x c]) |
| 220 | (fun a b => B x ![g.orthonormalBasis x a, g.orthonormalBasis x b]) |
| 221 | (fun a b => g.inner x (e a) (g.orthonormalBasis x b)) hQ |
| 222 | simpa only [← tensor_two_expansion g hB, ← tensor_three_expansion g hP, |
| 223 | ← tensor_four_expansion g hR] using h |
| 224 | |
| 225 | end Poincare.RicciFlow.Harnack |