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.Curvature.Calculus |
| 2 | import PoincareLib.Geometry.RicciFlow.Splitting.NullSectionEnergy |
| 3 | import PoincareLib.Geometry.Riemannian.Tensor.Commutation.Contractions |
| 4 | import PoincareLib.Geometry.Riemannian.Tensor.DerivativeOnFields |
| 5 | import PoincareLib.Geometry.Riemannian.Tensor.RicciDerivative |
| 6 | import PoincareLib.Geometry.RicciFlow.Connection.Variation |
| 7 | import PoincareLib.Geometry.RicciFlow.Connection.BoundaryRegularity |
| 8 | import PoincareLib.Geometry.RicciFlow.Harnack.Regularity |
| 9 | |
| 10 | /-! |
| 11 | # Connection variation along Ricci-null directions |
| 12 | |
| 13 | A parallel Ricci kernel annihilates the covariant curvature derivative. |
| 14 | Contracted second Bianchi then also annihilates the derivative direction of |
| 15 | the Ricci derivative, as needed by the connection variation formula. |
| 16 | -/ |
| 17 | |
| 18 | set_option autoImplicit false |
| 19 | set_option backward.isDefEq.respectTransparency false |
| 20 | set_option maxHeartbeats 800000 |
| 21 | |
| 22 | open Set Filter |
| 23 | open scoped Manifold ContDiff Bundle Topology BigOperators |
| 24 | |
| 25 | universe u |
| 26 | |
| 27 | namespace PoincareMT.RicciFlow.Splitting |
| 28 | |
| 29 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 30 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 31 | {g : RiemannianMetric n M} |
| 32 | |
| 33 | theorem covariantRiemannDerivative_null_section |
| 34 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) |
| 35 | (hsec : D.NonnegativeSectionalCurvature) |
| 36 | (V : (y : M) → TangentSpace (𝓡 n) y) {x : M} |
| 37 | (hV : ContMDiffAt (𝓡 n) ((𝓡 n).prod (𝓡 n)) ∞ (T% V) x) |
| 38 | (hnull : ∀ᶠ y in 𝓝 x, D.ricci y (V y) (V y) = 0) |
| 39 | (hDV : ∀ a, D.ricci x (D.connection V x a) (D.connection V x a) = 0) |
| 40 | (a u w z : TangentSpace (𝓡 n) x) : |
| 41 | D.covariantTensorDerivative D.riemannEvaluation x ![a, V x, u, w, z] = 0 := by |
| 42 | let W : Fin 4 → (y : M) → TangentSpace (𝓡 n) y := |
| 43 | ![V, FiberBundle.extend (EuclideanSpace ℝ (Fin n)) u, |
| 44 | FiberBundle.extend (EuclideanSpace ℝ (Fin n)) w, |
| 45 | FiberBundle.extend (EuclideanSpace ℝ (Fin n)) z] |
| 46 | have hW (i : Fin 4) : |
| 47 | MDifferentiableAt (𝓡 n) ((𝓡 n).prod (𝓡 n)) (T% (W i)) x := by |
| 48 | fin_cases i |
| 49 | · exact hV.mdifferentiableAt (by simp) |
| 50 | all_goals exact FiberBundle.mdifferentiableAt_extend (𝓡 n) _ _ |
| 51 | have h := D.covariantTensorDerivative_on_fields hD.1 W x hW a |
| 52 | have heq : (fun y => D.riemannEvaluation y (fun i => W i y)) =ᶠ[𝓝 x] |
| 53 | fun _ => 0 := by |
| 54 | filter_upwards [hnull] with y hy |
| 55 | exact curvatureTensor_eq_zero_of_ricci_self_eq_zero D hD y (hsec y) hy _ _ _ |
| 56 | have hsum : (∑ i, D.riemannEvaluation x |
| 57 | (Function.update (fun j => W j x) i (D.connection (W i) x a))) = 0 := by |
| 58 | apply Finset.sum_eq_zero |
| 59 | intro i _ |
| 60 | fin_cases i |
| 61 | · simpa [W, LeviCivitaData.riemannEvaluation] using |
| 62 | curvatureTensor_eq_zero_of_ricci_self_eq_zero D hD x (hsec x) (hDV a) u w z |
| 63 | all_goals |
| 64 | simpa [W, LeviCivitaData.riemannEvaluation] using |
| 65 | curvatureTensor_eq_zero_of_ricci_self_eq_zero D hD x (hsec x) |
| 66 | hnull.self_of_nhds _ _ _ |
| 67 | have hvalues : Fin.cons a (fun i => W i x) = ![a, V x, u, w, z] := by |
| 68 | ext i |
| 69 | fin_cases i <;> simp [W] |
| 70 | rw [hvalues, Poincare.mvfderiv_eq_of_eventuallyEq heq, mvfderiv_const, hsum] at h |
| 71 | simpa only [zero_apply, sub_zero] using h |
| 72 | |
| 73 | /-- All three slots of the Ricci derivative annihilate a local null section |
| 74 | whose covariant derivatives remain null. -/ |
| 75 | theorem covariantRicciDerivative_all_slots_null_section |
| 76 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) |
| 77 | (hsec : D.NonnegativeSectionalCurvature) |
| 78 | (V : (y : M) → TangentSpace (𝓡 n) y) {x : M} |
| 79 | (hV : ContMDiffAt (𝓡 n) ((𝓡 n).prod (𝓡 n)) ∞ (T% V) x) |
| 80 | (hnull : ∀ᶠ y in 𝓝 x, D.ricci y (V y) (V y) = 0) |
| 81 | (hDV : ∀ a, D.ricci x (D.connection V x a) (D.connection V x a) = 0) |
| 82 | (a w : TangentSpace (𝓡 n) x) : |
| 83 | D.covariantTensorDerivative D.ricciEvaluation x ![a, V x, w] = 0 ∧ |
| 84 | D.covariantTensorDerivative D.ricciEvaluation x ![a, w, V x] = 0 ∧ |
| 85 | D.covariantTensorDerivative D.ricciEvaluation x ![V x, a, w] = 0 := by |
| 86 | have hRic (y : M) (u : TangentSpace (𝓡 n) y) : 0 ≤ D.ricci y u u := |
| 87 | Finset.sum_nonneg fun i _ => hsec y u (g.orthonormalBasis y i) |
| 88 | have hn : ∀ᶠ y in 𝓝 x, ∀ z, D.ricci y (V y) z = 0 := by |
| 89 | filter_upwards [hnull] with y hy |
| 90 | exact ricci_eq_zero_of_nonneg_of_self_eq_zero D hD y (hRic y) hy |
| 91 | have hslot (c d : TangentSpace (𝓡 n) x) : |
| 92 | D.covariantTensorDerivative D.ricciEvaluation x ![c, V x, d] = 0 := by |
| 93 | rw [covariantRicciDerivative_on_null_section D hD V hV hn, |
| 94 | ricci_eq_zero_of_nonneg_of_self_eq_zero D hD x (hRic x) (hDV c), neg_zero] |
| 95 | refine ⟨hslot a w, ?_, ?_⟩ |
| 96 | · rw [D.covariantTensorDerivative_ricciEvaluation_symm hD] |
| 97 | exact hslot a w |
| 98 | · have hB := D.sum_covariantTensorDerivative_riemannEvaluation_divergence hD x a (V x) w |
| 99 | have hzero (i) : D.covariantTensorDerivative D.riemannEvaluation x |
| 100 | ![g.orthonormalBasis x i, a, g.orthonormalBasis x i, w, V x] = 0 := by |
| 101 | rw [D.covariantTensorDerivative_riemannEvaluation_pair_swap hD, |
| 102 | D.covariantTensorDerivative_riemannEvaluation_skew_first hD, |
| 103 | covariantRiemannDerivative_null_section D hD hsec V hV hnull hDV, neg_zero] |
| 104 | simp only [hzero, Finset.sum_const_zero] at hB |
| 105 | rw [D.covariantTensorDerivative_ricciEvaluation_symm hD x w a (V x), hslot] at hB |
| 106 | linarith |
| 107 | |
| 108 | theorem covariantRicciDerivative_all_slots_eq_zero_of_terminal_null |
| 109 | (hC : RicciFlowCurvatureCalculus.{u}) {a b : ℝ} (hab : a < b) |
| 110 | (F : RicciFlow n M (Icc a b)) |
| 111 | (hsec : ∀ t ∈ Icc a b, (F.connection t).NonnegativeSectionalCurvature) |
| 112 | (V : (y : M) → TangentSpace (𝓡 n) y) {x : M} |
| 113 | (hV : ContMDiffAt (𝓡 n) ((𝓡 n).prod (𝓡 n)) ∞ (T% V) x) |
| 114 | (hnull : ∀ᶠ y in 𝓝 x, (F.connection b).ricci y (V y) (V y) = 0) |
| 115 | (u w : TangentSpace (𝓡 n) x) : |
| 116 | (F.connection b).covariantTensorDerivative (F.connection b).ricciEvaluation |
| 117 | x ![u, V x, w] = 0 ∧ |
| 118 | (F.connection b).covariantTensorDerivative (F.connection b).ricciEvaluation |
| 119 | x ![u, w, V x] = 0 ∧ |
| 120 | (F.connection b).covariantTensorDerivative (F.connection b).ricciEvaluation |
| 121 | x ![V x, u, w] = 0 := by |
| 122 | apply covariantRicciDerivative_all_slots_null_section (F.connection b) |
| 123 | (hC.tensor_calculus n M (F.metric b) (F.connection b)) |
| 124 | (hsec b ⟨hab.le, le_rfl⟩) V hV hnull |
| 125 | intro c |
| 126 | exact ricci_connection_eq_zero_of_terminal_null hC hab F hsec V hV hnull c _ |
| 127 | |
| 128 | /-- Differentiating the first Ricci derivative along a parallel null |
| 129 | distribution annihilates every mixed null pairing in the second derivative. -/ |
| 130 | theorem secondCovariantRicciDerivative_eq_zero_of_null_section |
| 131 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) |
| 132 | (V : (y : M) → TangentSpace (𝓡 n) y) {x : M} |
| 133 | (hV : ContMDiffAt (𝓡 n) ((𝓡 n).prod (𝓡 n)) ∞ (T% V) x) |
| 134 | (hnull : ∀ᶠ y in 𝓝 x, D.ricci y (V y) (V y) = 0) |
| 135 | (hDV : ∀ a, D.ricci x (D.connection V x a) (D.connection V x a) = 0) |
| 136 | (hfirst : ∀ᶠ y in 𝓝 x, ∀ v : TangentSpace (𝓡 n) y, |
| 137 | D.ricci y v v = 0 → ∀ a w, |
| 138 | D.covariantTensorDerivative D.ricciEvaluation y ![a, v, w] = 0) |
| 139 | (a b w : TangentSpace (𝓡 n) x) : |
| 140 | D.covariantTensorDerivative (D.covariantTensorDerivative D.ricciEvaluation) |
| 141 | x ![a, b, V x, w] = 0 := by |
| 142 | let W : Fin 3 → (y : M) → TangentSpace (𝓡 n) y := |
| 143 | ![FiberBundle.extend (EuclideanSpace ℝ (Fin n)) b, V, |
| 144 | FiberBundle.extend (EuclideanSpace ℝ (Fin n)) w] |
| 145 | have hW (i : Fin 3) : |
| 146 | MDifferentiableAt (𝓡 n) ((𝓡 n).prod (𝓡 n)) (T% (W i)) x := by |
| 147 | fin_cases i |
| 148 | · exact FiberBundle.mdifferentiableAt_extend (𝓡 n) _ _ |
| 149 | · exact hV.mdifferentiableAt (by simp) |
| 150 | · exact FiberBundle.mdifferentiableAt_extend (𝓡 n) _ _ |
| 151 | have h := D.covariantTensorDerivative_on_fields |
| 152 | (hD.2.2.1 2 D.ricciEvaluation hD.2.1) W x hW a |
| 153 | have heq : (fun y => D.covariantTensorDerivative D.ricciEvaluation y |
| 154 | (fun i => W i y)) =ᶠ[𝓝 x] fun _ => 0 := by |
| 155 | filter_upwards [hnull, hfirst] with y hy hfy |
| 156 | have htuple : (fun i => W i y) = ![W 0 y, V y, W 2 y] := by |
| 157 | ext i |
| 158 | fin_cases i <;> rfl |
| 159 | rw [htuple] |
| 160 | exact hfy (V y) hy _ _ |
| 161 | have hu₀ (z : TangentSpace (𝓡 n) x) : |
| 162 | Function.update (fun j => W j x) 0 z = ![z, V x, w] := by |
| 163 | ext j |
| 164 | fin_cases j <;> simp [W] |
| 165 | have hu₁ (z : TangentSpace (𝓡 n) x) : |
| 166 | Function.update (fun j => W j x) 1 z = ![b, z, w] := by |
| 167 | ext j |
| 168 | fin_cases j <;> simp [W] |
| 169 | have hu₂ (z : TangentSpace (𝓡 n) x) : |
| 170 | Function.update (fun j => W j x) 2 z = ![b, V x, z] := by |
| 171 | ext j |
| 172 | fin_cases j <;> simp [W] |
| 173 | have hsum : (∑ i, D.covariantTensorDerivative D.ricciEvaluation x |
| 174 | (Function.update (fun j => W j x) i (D.connection (W i) x a))) = 0 := by |
| 175 | apply Finset.sum_eq_zero |
| 176 | intro i _ |
| 177 | fin_cases i |
| 178 | · change D.covariantTensorDerivative D.ricciEvaluation x |
| 179 | (Function.update (fun j => W j x) 0 (D.connection (W 0) x a)) = 0 |
| 180 | rw [hu₀] |
| 181 | exact hfirst.self_of_nhds (V x) hnull.self_of_nhds _ w |
| 182 | · change D.covariantTensorDerivative D.ricciEvaluation x |
| 183 | (Function.update (fun j => W j x) 1 (D.connection (W 1) x a)) = 0 |
| 184 | rw [hu₁] |
| 185 | exact hfirst.self_of_nhds (D.connection V x a) (hDV a) b w |
| 186 | · change D.covariantTensorDerivative D.ricciEvaluation x |
| 187 | (Function.update (fun j => W j x) 2 (D.connection (W 2) x a)) = 0 |
| 188 | rw [hu₂] |
| 189 | exact hfirst.self_of_nhds (V x) hnull.self_of_nhds b _ |
| 190 | have hvalues : Fin.cons a (fun i => W i x) = ![a, b, V x, w] := by |
| 191 | ext i |
| 192 | fin_cases i <;> simp [W] |
| 193 | rw [hvalues, Poincare.mvfderiv_eq_of_eventuallyEq heq, mvfderiv_const, hsum] at h |
| 194 | simpa only [zero_apply, sub_zero] using h |
| 195 | |
| 196 | theorem connection_hasDerivAt_zero_of_covariantRicciDerivative_eq_zero |
| 197 | {J : Set ℝ} (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 198 | (V : (y : M) → TangentSpace (𝓡 n) y) {x : M} |
| 199 | (hV : ContMDiffAt (𝓡 n) ((𝓡 n).prod (𝓡 n)) ∞ (T% V) x) |
| 200 | (hzero : ∀ u w : TangentSpace (𝓡 n) x, |
| 201 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation |
| 202 | x ![u, V x, w] = 0 ∧ |
| 203 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation |
| 204 | x ![u, w, V x] = 0 ∧ |
| 205 | (F.connection t).covariantTensorDerivative (F.connection t).ricciEvaluation |
| 206 | x ![V x, u, w] = 0) : |
| 207 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 208 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 209 | HasDerivAt (fun s => (F.connection s).connection V x) 0 t := by |
| 210 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 211 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 212 | let W := FiberBundle.extend (EuclideanSpace ℝ (Fin n)) (V x) |
| 213 | have hW := FiberBundle.mdifferentiableAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (V x) |
| 214 | obtain ⟨A, hA, hpair⟩ := F.connection_hasDerivAt_ricci_of_equation ht x (V x) |
| 215 | have hAzero : A = 0 := by |
| 216 | ext u |
| 217 | apply ext_inner_right ℝ |
| 218 | intro w |
| 219 | change (F.metric t).inner x (A u) w = (F.metric t).inner x 0 w |
| 220 | rw [hpair, (hzero u w).1, (hzero u w).2.2, (hzero w u).2.1] |
| 221 | simp |
| 222 | have heq (s : ℝ) : (F.connection s).connection V x = |
| 223 | (F.connection s).connection W x + |
| 224 | ((F.connection t).connection V x - (F.connection t).connection W x) := by |
| 225 | have hd := (F.connection s).connection.isCovariantDerivativeOnUniv.difference_apply |
| 226 | (F.connection t).connection.isCovariantDerivativeOnUniv (by simp) |
| 227 | (hV.mdifferentiableAt (by simp)) |
| 228 | have hw := (F.connection s).connection.isCovariantDerivativeOnUniv.difference_apply |
| 229 | (F.connection t).connection.isCovariantDerivativeOnUniv (by simp) hW |
| 230 | simp only [FiberBundle.extend_apply_self] at hw |
| 231 | have hdiff := hd.symm.trans hw |
| 232 | change (F.connection s).connection V x - (F.connection t).connection V x = |
| 233 | (F.connection s).connection W x - (F.connection t).connection W x at hdiff |
| 234 | rw [sub_eq_iff_eq_add] at hdiff |
| 235 | rw [hdiff] |
| 236 | abel |
| 237 | rw [hAzero] at hA |
| 238 | exact (hA.add_const ((F.connection t).connection V x - |
| 239 | (F.connection t).connection W x)).congr_of_eventuallyEq (Eventually.of_forall heq) |
| 240 | |
| 241 | /-- A fixed smooth field lying in every positive-time Ricci kernel has a |
| 242 | time-independent covariant derivative, including both endpoints. -/ |
| 243 | theorem connection_eq_terminal_of_ricci_null |
| 244 | (hC : RicciFlowCurvatureCalculus.{u}) {a b : ℝ} (hab : a < b) |
| 245 | (F : RicciFlow n M (Icc a b)) |
| 246 | (hsec : ∀ t ∈ Icc a b, (F.connection t).NonnegativeSectionalCurvature) |
| 247 | (V : (y : M) → TangentSpace (𝓡 n) y) |
| 248 | (hV : ContMDiff (𝓡 n) ((𝓡 n).prod (𝓡 n)) ∞ (T% V)) |
| 249 | (hnull : ∀ t ∈ Ioc a b, ∀ x, (F.connection t).ricci x (V x) (V x) = 0) : |
| 250 | ∀ t ∈ Icc a b, ∀ x, (F.connection t).connection V x = |
| 251 | (F.connection b).connection V x := by |
| 252 | intro t ht x |
| 253 | ext u |
| 254 | let v := trivializationAt (EuclideanSpace ℝ (Fin n)) (TangentSpace (𝓡 n)) x |
| 255 | let e := v.continuousLinearEquivAt ℝ x (mem_baseSet_trivializationAt _ _ x) |
| 256 | let q : ℝ → EuclideanSpace ℝ (Fin n) := fun s => e ((F.connection s).connection V x u) |
| 257 | have hc : ContinuousOn q (Icc a b) := by |
| 258 | intro s hs |
| 259 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 260 | ⟨(F.metric s).toRiemannianMetric⟩ |
| 261 | exact e.continuous.continuousAt.comp_continuousWithinAt |
| 262 | (((F.contDiffWithinAt_connection hs (hV x)).clm_apply |
| 263 | (contDiffWithinAt_const (c := u))).continuousWithinAt) |
| 264 | have hd (s : ℝ) (hs : s ∈ Ioo a b) : HasDerivAt q 0 s := by |
| 265 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 266 | ⟨(F.metric s).toRiemannianMetric⟩ |
| 267 | have hsub : Icc a s ⊆ Icc a b := Icc_subset_Icc le_rfl hs.2.le |
| 268 | let G := Poincare.Geometry.RicciFlow.Harnack.restrictFlow F hsub |
| 269 | ordConnected_Icc ⟨a, left_mem_Icc.mpr hs.1.le, s, right_mem_Icc.mpr hs.1.le, hs.1.ne⟩ |
| 270 | have hz := covariantRicciDerivative_all_slots_eq_zero_of_terminal_null hC hs.1 G |
| 271 | (fun r hr => hsec r (hsub hr)) V (hV x) |
| 272 | (Eventually.of_forall (hnull s ⟨hs.1, hs.2.le⟩)) |
| 273 | have hh := connection_hasDerivAt_zero_of_covariantRicciDerivative_eq_zero F |
| 274 | (by simpa only [interior_Icc] using hs) V (hV x) hz |
| 275 | have hv := hh.clm_apply (hasDerivAt_const s u) |
| 276 | convert! e.toContinuousLinearMap.hasFDerivAt.comp_hasDerivAt s hv using 1 |
| 277 | simp |
| 278 | let c := (a + b) / 2 |
| 279 | have hc₀ : c ∈ Ioo a b := ⟨by dsimp [c]; linarith, by dsimp [c]; linarith⟩ |
| 280 | have heq : EqOn q (fun _ => q c) (Ioo a b) := by |
| 281 | intro s hs |
| 282 | have hbound := (convex_Ioo a b).norm_image_sub_le_of_norm_hasDerivWithin_le |
| 283 | (fun r hr => (hd r hr).hasDerivWithinAt) (fun r hr => le_refl ‖(0 : EuclideanSpace ℝ (Fin n))‖) |
| 284 | hc₀ hs |
| 285 | simpa only [norm_zero, zero_mul, norm_le_zero_iff, sub_eq_zero] using hbound |
| 286 | have hclosed : EqOn q (fun _ => q c) (Icc a b) := |
| 287 | heq.of_subset_closure hc continuousOn_const Ioo_subset_Icc_self |
| 288 | (by rw [closure_Ioo hab.ne]) |
| 289 | apply e.injective |
| 290 | exact (hclosed ht).trans (hclosed ⟨hab.le, le_rfl⟩).symm |
| 291 | |
| 292 | end PoincareMT.RicciFlow.Splitting |