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.Connection.Regularity |
| 2 | import PoincareLib.Geometry.RicciFlow.Curvature.Regularity |
| 3 | import PoincareLib.Geometry.RicciFlow.Curvature.Theory |
| 4 | import PoincareLib.Geometry.Manifold.ContDiff.TimeDerivative |
| 5 | import PoincareLib.Geometry.Riemannian.Tensor.LocalCalculus |
| 6 | import Mathlib.Tactic.FinCases |
| 7 | import Mathlib.Tactic.Ring |
| 8 | |
| 9 | /-! # Time variation of the Levi-Civita connection along Ricci flow -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | set_option backward.isDefEq.respectTransparency false |
| 13 | |
| 14 | open scoped Manifold ContDiff Bundle Topology BigOperators |
| 15 | open Bundle Filter Set |
| 16 | |
| 17 | universe u |
| 18 | |
| 19 | namespace PoincareMT.RicciFlow |
| 20 | |
| 21 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 22 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 23 | {J : Set ℝ} |
| 24 | |
| 25 | private lemma ricci_symm_of_equation |
| 26 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 27 | (x : M) (a b : TangentSpace (𝓡 n) x) : |
| 28 | (F.connection t).ricci x a b = (F.connection t).ricci x b a := by |
| 29 | have hi (u v : TangentSpace (𝓡 n) x) := |
| 30 | (F.equation t (interior_subset ht) x u v).hasDerivAt |
| 31 | (mem_interior_iff_mem_nhds.mp ht) |
| 32 | have h := (hi a b).unique (by simpa only [(F.metric _).symm] using hi b a) |
| 33 | linarith |
| 34 | |
| 35 | private lemma ricci_sub_left_of_equation |
| 36 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 37 | (x : M) (a b c : TangentSpace (𝓡 n) x) : |
| 38 | (F.connection t).ricci x (a - b) c = |
| 39 | (F.connection t).ricci x a c - (F.connection t).ricci x b c := by |
| 40 | have hi (u v : TangentSpace (𝓡 n) x) := |
| 41 | (F.equation t (interior_subset ht) x u v).hasDerivAt |
| 42 | (mem_interior_iff_mem_nhds.mp ht) |
| 43 | have h := (hi (a - b) c).unique (((hi a c).sub (hi b c)).congr_of_eventuallyEq |
| 44 | (Filter.Eventually.of_forall fun s => by simp only [map_sub, sub_apply, Pi.sub_apply])) |
| 45 | linarith |
| 46 | |
| 47 | private lemma ricci_contMDiffAt_fields |
| 48 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) {x : M} |
| 49 | {Y Z : (x : M) → TangentSpace (𝓡 n) x} |
| 50 | (hY : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) |
| 51 | (hZ : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Z) x) : |
| 52 | ContMDiffAt (𝓡 n) 𝓘(ℝ, ℝ) ∞ |
| 53 | (fun y => (F.connection t).ricci y (Y y) (Z y)) x := by |
| 54 | exact (F.contMDiffAt_ricci_fields ht hY hZ).comp x |
| 55 | (contMDiffAt_const.prodMk contMDiffAt_id) |
| 56 | |
| 57 | lemma metric_directional_hasDerivAt_of_equation |
| 58 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 59 | {x : M} |
| 60 | {Y Z : (x : M) → TangentSpace (𝓡 n) x} |
| 61 | (hY : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) |
| 62 | (hZ : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Z) x) |
| 63 | (v : TangentSpace (𝓡 n) x) : |
| 64 | HasDerivAt (fun s => mvfderiv (𝓡 n) |
| 65 | (fun y => (F.metric s).inner y (Y y) (Z y)) x v) |
| 66 | (-2 * mvfderiv (𝓡 n) (fun y => (F.connection t).ricci y (Y y) (Z y)) x v) t := by |
| 67 | have hR := (ricci_contMDiffAt_fields F ht hY hZ).mdifferentiableAt (by simp) |
| 68 | have h := Poincare.Manifold.hasDerivAt_mvfderiv_time |
| 69 | (F.contMDiffAt_inner_fields ht hY hZ) |
| 70 | (fun y => (F.equation t (interior_subset ht) y (Y y) (Z y)).hasDerivAt |
| 71 | (mem_interior_iff_mem_nhds.mp ht)) v |
| 72 | apply h.congr_deriv |
| 73 | rw [mvfderiv_fun_mul mdifferentiableAt_const hR] |
| 74 | simp [mvfderiv] |
| 75 | |
| 76 | lemma metric_directional_hasDerivAt |
| 77 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 78 | (hD : (F.connection t).CurvatureTensorCalculus) {x : M} |
| 79 | {Y Z : (x : M) → TangentSpace (𝓡 n) x} |
| 80 | (hY : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) |
| 81 | (hZ : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Z) x) |
| 82 | (v : TangentSpace (𝓡 n) x) : |
| 83 | HasDerivAt (fun s => mvfderiv (𝓡 n) |
| 84 | (fun y => (F.metric s).inner y (Y y) (Z y)) x v) |
| 85 | (-2 * mvfderiv (𝓡 n) (fun y => (F.connection t).ricci y (Y y) (Z y)) x v) t := by |
| 86 | have _ := hD |
| 87 | exact F.metric_directional_hasDerivAt_of_equation ht hY hZ v |
| 88 | |
| 89 | private lemma metric_connection_hasDerivAt |
| 90 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) {x : M} |
| 91 | {Y : (y : M) → TangentSpace (𝓡 n) y} |
| 92 | (hY : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) |
| 93 | (u w : TangentSpace (𝓡 n) x) : |
| 94 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 95 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 96 | HasDerivAt (fun s => (F.metric s).inner x ((F.connection s).connection Y x u) w) |
| 97 | (-2 * (F.connection t).ricci x ((F.connection t).connection Y x u) w + |
| 98 | (F.metric t).inner x ((deriv (fun s => (F.connection s).connection Y x) t) u) w) t := by |
| 99 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 100 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 101 | let : NormedAddCommGroup (TangentSpace (𝓡 n) x) := inferInstance |
| 102 | let : NormedSpace ℝ (TangentSpace (𝓡 n) x) := inferInstance |
| 103 | let : NormedAddCommGroup (TangentSpace (𝓡 n) x →L[ℝ] ℝ) := inferInstance |
| 104 | let : NormedSpace ℝ (TangentSpace (𝓡 n) x →L[ℝ] ℝ) := inferInstance |
| 105 | have ha := (F.contDiffAt_inner ht x).differentiableAt (by simp) |>.hasDerivAt |
| 106 | have hb := (F.contDiffAt_connection ht hY).differentiableAt (by simp) |>.hasDerivAt |
| 107 | have hbu := hb.clm_apply (hasDerivAt_const t u) |
| 108 | have h := (ha.clm_apply hbu).clm_apply (hasDerivAt_const t w) |
| 109 | have hc := (ha.clm_apply (hasDerivAt_const t ((F.connection t).connection Y x u))).clm_apply |
| 110 | (hasDerivAt_const t w) |
| 111 | have heq := hc.unique ((F.equation t (interior_subset ht) x |
| 112 | ((F.connection t).connection Y x u) w).hasDerivAt (mem_interior_iff_mem_nhds.mp ht)) |
| 113 | simp only [map_zero, add_zero, add_apply] at h heq |
| 114 | exact h.congr_deriv (by rw [heq]) |
| 115 | |
| 116 | private lemma connection_timeDerivative_koszul |
| 117 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 118 | {x : M} |
| 119 | {X Y Z : (x : M) → TangentSpace (𝓡 n) x} |
| 120 | (hX : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% X) x) |
| 121 | (hY : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) |
| 122 | (hZ : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Z) x) : |
| 123 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 124 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 125 | (F.metric t).inner x ((deriv (fun s => (F.connection s).connection Y x) t) (X x)) (Z x) = |
| 126 | -mvfderiv (𝓡 n) (fun y => (F.connection t).ricci y (Y y) (Z y)) x (X x) - |
| 127 | mvfderiv (𝓡 n) (fun y => (F.connection t).ricci y (Z y) (X y)) x (Y x) + |
| 128 | mvfderiv (𝓡 n) (fun y => (F.connection t).ricci y (X y) (Y y)) x (Z x) - |
| 129 | (F.connection t).ricci x (VectorField.mlieBracket (𝓡 n) X Y x) (Z x) + |
| 130 | (F.connection t).ricci x (VectorField.mlieBracket (𝓡 n) Y Z x) (X x) - |
| 131 | (F.connection t).ricci x (VectorField.mlieBracket (𝓡 n) Z X x) (Y x) + |
| 132 | 2 * (F.connection t).ricci x ((F.connection t).connection Y x (X x)) (Z x) := by |
| 133 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 134 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 135 | have hi (a b : TangentSpace (𝓡 n) x) := |
| 136 | (F.equation t (interior_subset ht) x a b).hasDerivAt (mem_interior_iff_mem_nhds.mp ht) |
| 137 | have h := (((((metric_directional_hasDerivAt_of_equation F ht hY hZ (X x)).add |
| 138 | (metric_directional_hasDerivAt_of_equation F ht hZ hX (Y x))).sub |
| 139 | (metric_directional_hasDerivAt_of_equation F ht hX hY (Z x))).add |
| 140 | (hi (VectorField.mlieBracket (𝓡 n) X Y x) (Z x))).sub |
| 141 | (hi (VectorField.mlieBracket (𝓡 n) Y Z x) (X x))).add |
| 142 | (hi (VectorField.mlieBracket (𝓡 n) Z X x) (Y x)) |
| 143 | have heq : (fun s => 2 * (F.metric s).inner x ((F.connection s).connection Y x (X x)) (Z x)) |
| 144 | =ᶠ[𝓝 t] (fun s => |
| 145 | mvfderiv (𝓡 n) (fun y => (F.metric s).inner y (Y y) (Z y)) x (X x) + |
| 146 | mvfderiv (𝓡 n) (fun y => (F.metric s).inner y (Z y) (X y)) x (Y x) - |
| 147 | mvfderiv (𝓡 n) (fun y => (F.metric s).inner y (X y) (Y y)) x (Z x) + |
| 148 | (F.metric s).inner x (VectorField.mlieBracket (𝓡 n) X Y x) (Z x) - |
| 149 | (F.metric s).inner x (VectorField.mlieBracket (𝓡 n) Y Z x) (X x) + |
| 150 | (F.metric s).inner x (VectorField.mlieBracket (𝓡 n) Z X x) (Y x)) := |
| 151 | Filter.Eventually.of_forall fun s => (F.connection s).koszul_identity |
| 152 | (hX.mdifferentiableAt (by simp)) (hY.mdifferentiableAt (by simp)) (hZ.mdifferentiableAt (by simp)) |
| 153 | have hl := (metric_connection_hasDerivAt F ht hY (X x) (Z x)).const_mul 2 |
| 154 | have he := hl.unique (h.congr_of_eventuallyEq heq) |
| 155 | linarith |
| 156 | |
| 157 | /-- Christoffel variation, expressed through the retained connection and the |
| 158 | covariant derivative of its Ricci tensor. The norm in the time derivative is |
| 159 | fixed at the metric at `t`. -/ |
| 160 | theorem inner_deriv_connection_extend_of_equation |
| 161 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 162 | (x : M) (u v w : TangentSpace (𝓡 n) x) : |
| 163 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 164 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 165 | (F.metric t).inner x |
| 166 | ((deriv (fun s => (F.connection s).connection |
| 167 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) v) x) t) u) w = |
| 168 | -(F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![u, v, w] - |
| 169 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![v, u, w] + |
| 170 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![w, u, v] := by |
| 171 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 172 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 173 | have hX := FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (k := ∞) u |
| 174 | have hY := FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (k := ∞) v |
| 175 | have hZ := FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (k := ∞) w |
| 176 | have hs (y : M) (a b : TangentSpace (𝓡 n) y) : |
| 177 | (F.connection t).ricci y a b = (F.connection t).ricci y b a := |
| 178 | ricci_symm_of_equation F ht y a b |
| 179 | have hsub (a b c : TangentSpace (𝓡 n) x) : |
| 180 | (F.connection t).ricci x (a - b) c = |
| 181 | (F.connection t).ricci x a c - (F.connection t).ricci x b c := |
| 182 | ricci_sub_left_of_equation F ht x a b c |
| 183 | have h := connection_timeDerivative_koszul F ht hX hY hZ |
| 184 | rw [← (F.connection t).covariantDerivativeOnFields_sub_swap |
| 185 | (hX.mdifferentiableAt (by simp)) (hY.mdifferentiableAt (by simp)), |
| 186 | ← (F.connection t).covariantDerivativeOnFields_sub_swap |
| 187 | (hY.mdifferentiableAt (by simp)) (hZ.mdifferentiableAt (by simp)), |
| 188 | ← (F.connection t).covariantDerivativeOnFields_sub_swap |
| 189 | (hZ.mdifferentiableAt (by simp)) (hX.mdifferentiableAt (by simp))] at h |
| 190 | simp only [LeviCivitaData.covariantDerivativeOnFields, FiberBundle.extend_apply_self, |
| 191 | hsub] at h |
| 192 | simp only [LeviCivitaData.covariantTensorDerivative, LeviCivitaData.ricciEvaluation, |
| 193 | Fin.sum_univ_two] |
| 194 | simp only [Matrix.cons_val_succ, Matrix.cons_val_zero, Matrix.cons_val_one, Fin.isValue, |
| 195 | Function.update_self, Function.update_of_ne (by decide : (1 : Fin 2) ≠ 0), |
| 196 | Function.update_of_ne (by decide : (0 : Fin 2) ≠ 1)] |
| 197 | rw [h] |
| 198 | simp only [hs x _ ((F.connection t).connection _ x _)] |
| 199 | have he : (fun y => (F.connection t).ricci y |
| 200 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) w y) |
| 201 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) u y)) = |
| 202 | (fun y => (F.connection t).ricci y |
| 203 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) u y) |
| 204 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) w y)) := funext fun y => hs y _ _ |
| 205 | rw [he] |
| 206 | ring |
| 207 | |
| 208 | /-- Compatibility wrapper for consumers supplying curvature calculus. -/ |
| 209 | theorem inner_deriv_connection_extend |
| 210 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 211 | (hD : (F.connection t).CurvatureTensorCalculus) |
| 212 | (x : M) (u v w : TangentSpace (𝓡 n) x) : |
| 213 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 214 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 215 | (F.metric t).inner x |
| 216 | ((deriv (fun s => (F.connection s).connection |
| 217 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) v) x) t) u) w = |
| 218 | -(F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![u, v, w] - |
| 219 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![v, u, w] + |
| 220 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![w, u, v] := by |
| 221 | have _ := hD |
| 222 | exact F.inner_deriv_connection_extend_of_equation ht x u v w |
| 223 | |
| 224 | /-- The actual operator time derivative, identified by its metric pairings. -/ |
| 225 | theorem connection_hasDerivAt_ricci_of_equation |
| 226 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 227 | (x : M) (v : TangentSpace (𝓡 n) x) : |
| 228 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 229 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 230 | ∃ A : TangentSpace (𝓡 n) x →L[ℝ] TangentSpace (𝓡 n) x, |
| 231 | HasDerivAt (fun s => (F.connection s).connection |
| 232 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) v) x) A t ∧ |
| 233 | ∀ u w : TangentSpace (𝓡 n) x, |
| 234 | (F.metric t).inner x (A u) w = |
| 235 | -(F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![u, v, w] - |
| 236 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![v, u, w] + |
| 237 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![w, u, v] := by |
| 238 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 239 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 240 | refine ⟨_, (F.contDiffAt_connection ht |
| 241 | (FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) v)).differentiableAt |
| 242 | (by simp) |>.hasDerivAt, ?_⟩ |
| 243 | intro u w |
| 244 | exact F.inner_deriv_connection_extend_of_equation ht x u v w |
| 245 | |
| 246 | /-- Compatibility wrapper for consumers supplying curvature calculus. -/ |
| 247 | theorem connection_hasDerivAt_ricci |
| 248 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 249 | (hD : (F.connection t).CurvatureTensorCalculus) |
| 250 | (x : M) (v : TangentSpace (𝓡 n) x) : |
| 251 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 252 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 253 | ∃ A : TangentSpace (𝓡 n) x →L[ℝ] TangentSpace (𝓡 n) x, |
| 254 | HasDerivAt (fun s => (F.connection s).connection |
| 255 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) v) x) A t ∧ |
| 256 | ∀ u w : TangentSpace (𝓡 n) x, |
| 257 | (F.metric t).inner x (A u) w = |
| 258 | -(F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![u, v, w] - |
| 259 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![v, u, w] + |
| 260 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation x ![w, u, v] := by |
| 261 | have _ := hD |
| 262 | exact F.connection_hasDerivAt_ricci_of_equation ht x v |
| 263 | |
| 264 | end PoincareMT.RicciFlow |