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.Theory |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Mul |
| 4 | import Mathlib.Analysis.Normed.Module.FiniteDimension |
| 5 | import Mathlib.Tactic.FinCases |
| 6 | import Mathlib.Tactic.Ring |
| 7 | |
| 8 | /-! Curvature evolution evaluated on Ricci-driven moving inputs. |
| 9 | |
| 10 | The fixed-input curvature equation in `RicciFlowCurvatureTheory` contains the |
| 11 | four negative Ricci contractions forced by the evolving metric. This module |
| 12 | records the elementary moving-input calculation which cancels those terms. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | open scoped Manifold ContDiff Bundle Topology BigOperators |
| 19 | open Bundle Filter Set |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | namespace PoincareMT.RicciFlow |
| 24 | |
| 25 | open PoincareMT |
| 26 | |
| 27 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 28 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 29 | {g : RiemannianMetric n M} |
| 30 | {J : Set ℝ} |
| 31 | |
| 32 | private lemma differentiableWithinAt_clm_of_apply |
| 33 | {E G : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 34 | [NormedAddCommGroup G] [NormedSpace ℝ G] [FiniteDimensional ℝ E] |
| 35 | {f : ℝ → E →L[ℝ] G} {S : Set ℝ} {t : ℝ} |
| 36 | (hf : ∀ v, DifferentiableWithinAt ℝ (fun s => f s v) S t) : |
| 37 | DifferentiableWithinAt ℝ f S t := by |
| 38 | let d := Module.finrank ℝ E |
| 39 | have hd : d = Module.finrank ℝ (Fin d → ℝ) := (Module.finrank_fin_fun ℝ).symm |
| 40 | let e₁ : E ≃L[ℝ] (Fin d → ℝ) := ContinuousLinearEquiv.ofFinrankEq hd |
| 41 | let e₂ := (e₁.arrowCongr (1 : G ≃L[ℝ] G)).trans |
| 42 | (ContinuousLinearEquiv.piRing (Fin d)) |
| 43 | rw [← Function.id_comp f, ← e₂.symm_comp_self] |
| 44 | exact e₂.symm.differentiableAt.comp_differentiableWithinAt t |
| 45 | (differentiableWithinAt_pi.mpr fun i => hf _) |
| 46 | |
| 47 | private lemma hasDerivWithinAt_linear_moving |
| 48 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 49 | [FiniteDimensional ℝ E] {S : Set ℝ} {t : ℝ} |
| 50 | (ht : UniqueDiffWithinAt ℝ S t) (L : ℝ → E →L[ℝ] ℝ) |
| 51 | (hL : ∀ a, DifferentiableWithinAt ℝ (fun s => L s a) S t) |
| 52 | {v : ℝ → E} {v' : E} {d : ℝ} |
| 53 | (hv : HasDerivWithinAt v v' S t) |
| 54 | (hd : HasDerivWithinAt (fun s => L s (v t)) d S t) : |
| 55 | HasDerivWithinAt (fun s => L s (v s)) (d + L t v') S t := by |
| 56 | have h := (differentiableWithinAt_clm_of_apply hL).hasDerivWithinAt |
| 57 | have hfixed := h.clm_apply (hasDerivWithinAt_const t S (v t)) |
| 58 | have he := hd.derivWithin ht |
| 59 | have he' := hfixed.derivWithin ht |
| 60 | have hval : d = (derivWithin L S t) (v t) := by |
| 61 | calc |
| 62 | d = derivWithin (fun s => L s (v t)) S t := he.symm |
| 63 | _ = (derivWithin L S t) (v t) := by simpa only [map_zero, add_zero] using he' |
| 64 | have hh := h.clm_apply hv |
| 65 | simpa only [hval, add_comm] using hh |
| 66 | |
| 67 | private lemma hasDerivWithinAt_four_moving |
| 68 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 69 | [FiniteDimensional ℝ E] {S : Set ℝ} {t : ℝ} |
| 70 | (ht : UniqueDiffWithinAt ℝ S t) |
| 71 | (A : ℝ → MultilinearMap ℝ (fun _ : Fin 4 => E) ℝ) |
| 72 | (dA : (Fin 4 → E) → ℝ) |
| 73 | (hA : ∀ q, HasDerivWithinAt (fun s => A s q) (dA q) S t) |
| 74 | {u v w z : ℝ → E} {u' v' w' z' : E} |
| 75 | (hu : HasDerivWithinAt u u' S t) (hv : HasDerivWithinAt v v' S t) |
| 76 | (hw : HasDerivWithinAt w w' S t) (hz : HasDerivWithinAt z z' S t) : |
| 77 | HasDerivWithinAt (fun s => A s ![u s, v s, w s, z s]) |
| 78 | (dA ![u t, v t, w t, z t] + A t ![u', v t, w t, z t] + |
| 79 | A t ![u t, v', w t, z t] + A t ![u t, v t, w', z t] + |
| 80 | A t ![u t, v t, w t, z']) S t := by |
| 81 | classical |
| 82 | let L (s : ℝ) (q : Fin 4 → E) (i : Fin 4) := |
| 83 | ((A s).toLinearMap q i).toContinuousLinearMap |
| 84 | have hL (s : ℝ) (q : Fin 4 → E) (i : Fin 4) (a : E) : |
| 85 | L s q i a = A s (Function.update q i a) := rfl |
| 86 | have e0 (a b c d r : E) : Function.update ![a, b, c, d] 0 r = ![r, b, c, d] := by |
| 87 | ext i; fin_cases i <;> simp |
| 88 | have e1 (a b c d r : E) : Function.update ![a, b, c, d] 1 r = ![a, r, c, d] := by |
| 89 | ext i; fin_cases i <;> simp |
| 90 | have e2 (a b c d r : E) : Function.update ![a, b, c, d] 2 r = ![a, b, r, d] := by |
| 91 | ext i; fin_cases i <;> simp |
| 92 | have e3 (a b c d r : E) : Function.update ![a, b, c, d] 3 r = ![a, b, c, r] := by |
| 93 | ext i; fin_cases i <;> simp |
| 94 | have h1 (b c d : E) : HasDerivWithinAt (fun s => A s ![u s, b, c, d]) |
| 95 | (dA ![u t, b, c, d] + A t ![u', b, c, d]) S t := by |
| 96 | simpa only [hL, e0] using hasDerivWithinAt_linear_moving ht |
| 97 | (fun s => L s ![0, b, c, d] 0) |
| 98 | (fun a => by simpa only [hL, e0] using (hA ![a, b, c, d]).differentiableWithinAt) |
| 99 | hu (by simpa only [hL, e0] using hA ![u t, b, c, d]) |
| 100 | have h2 (c d : E) : HasDerivWithinAt (fun s => A s ![u s, v s, c, d]) |
| 101 | (dA ![u t, v t, c, d] + A t ![u', v t, c, d] + |
| 102 | A t ![u t, v', c, d]) S t := by |
| 103 | simpa only [hL, e1] using hasDerivWithinAt_linear_moving ht |
| 104 | (fun s => L s ![u s, 0, c, d] 1) |
| 105 | (fun b => by simpa only [hL, e1] using (h1 b c d).differentiableWithinAt) |
| 106 | hv (by simpa only [hL, e1] using h1 (v t) c d) |
| 107 | have h3 (d : E) : HasDerivWithinAt (fun s => A s ![u s, v s, w s, d]) |
| 108 | (dA ![u t, v t, w t, d] + A t ![u', v t, w t, d] + |
| 109 | A t ![u t, v', w t, d] + A t ![u t, v t, w', d]) S t := by |
| 110 | simpa only [hL, e2] using hasDerivWithinAt_linear_moving ht |
| 111 | (fun s => L s ![u s, v s, 0, d] 2) |
| 112 | (fun c => by simpa only [hL, e2] using (h2 c d).differentiableWithinAt) |
| 113 | hw (by simpa only [hL, e2] using h2 (w t) d) |
| 114 | simpa only [hL, e3] using hasDerivWithinAt_linear_moving ht |
| 115 | (fun s => L s ![u s, v s, w s, 0] 3) |
| 116 | (fun d => by simpa only [hL, e3] using (h3 d).differentiableWithinAt) |
| 117 | hz (by simpa only [hL, e3] using h3 (z t)) |
| 118 | |
| 119 | /- The Ricci endomorphism in the metric at time `t`, written in its |
| 120 | orthonormal basis. This is the displayed ODE used by moving frames. -/ |
| 121 | noncomputable def ricciSharp (D : LeviCivitaData g) (x : M) |
| 122 | (v : TangentSpace (𝓡 n) x) : TangentSpace (𝓡 n) x := |
| 123 | let b := g.orthonormalBasis x |
| 124 | ∑ i, D.ricci x v (b i) • b i |
| 125 | |
| 126 | private lemma curvatureReaction_add_ricciSharp |
| 127 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) (x : M) |
| 128 | (u v w z : TangentSpace (𝓡 n) x) : |
| 129 | D.curvatureReaction x u v w z + |
| 130 | D.curvatureTensor x (ricciSharp D x u) v w z + |
| 131 | D.curvatureTensor x u (ricciSharp D x v) w z + |
| 132 | D.curvatureTensor x u v (ricciSharp D x w) z + |
| 133 | D.curvatureTensor x u v w (ricciSharp D x z) = |
| 134 | 2 * (D.curvatureB x u v w z - D.curvatureB x u v z w - |
| 135 | D.curvatureB x u z v w + D.curvatureB x u w v z) := by |
| 136 | classical |
| 137 | obtain ⟨A, hA⟩ := hD.1.1 x |
| 138 | have hslot (q : Fin 4 → TangentSpace (𝓡 n) x) (i : Fin 4) : |
| 139 | D.riemannEvaluation x (Function.update q i (ricciSharp D x (q i))) = |
| 140 | ∑ j, D.ricci x (q i) (g.orthonormalBasis x j) * |
| 141 | D.riemannEvaluation x (Function.update q i (g.orthonormalBasis x j)) := by |
| 142 | simp_rw [hA, ricciSharp, A.map_update_sum, A.map_update_smul, smul_eq_mul] |
| 143 | have h0 := hslot ![u, v, w, z] 0 |
| 144 | have h1 := hslot ![u, v, w, z] 1 |
| 145 | have h2 := hslot ![u, v, w, z] 2 |
| 146 | have h3 := hslot ![u, v, w, z] 3 |
| 147 | simp [LeviCivitaData.riemannEvaluation, Function.update] at h0 h1 h2 h3 |
| 148 | rw [h0, h1, h2, h3, LeviCivitaData.curvatureReaction] |
| 149 | simp only [Finset.sum_add_distrib] |
| 150 | ring |
| 151 | |
| 152 | /-! The cancellation is also an integration boundary for the parabolic |
| 153 | consumer: downstream moving-frame proofs should not need to unfold the |
| 154 | fixed-input reaction or the Ricci contraction. -/ |
| 155 | |
| 156 | theorem curvatureReaction_add_ricciSharp_eq |
| 157 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) (x : M) |
| 158 | (u v w z : TangentSpace (𝓡 n) x) : |
| 159 | D.curvatureReaction x u v w z + |
| 160 | D.curvatureTensor x (ricciSharp D x u) v w z + |
| 161 | D.curvatureTensor x u (ricciSharp D x v) w z + |
| 162 | D.curvatureTensor x u v (ricciSharp D x w) z + |
| 163 | D.curvatureTensor x u v w (ricciSharp D x z) = |
| 164 | 2 * (D.curvatureB x u v w z - D.curvatureB x u v z w - |
| 165 | D.curvatureB x u z v w + D.curvatureB x u w v z) := by |
| 166 | exact curvatureReaction_add_ricciSharp D hD x u v w z |
| 167 | |
| 168 | /-- |
| 169 | The retained curvature evolution on four inputs satisfying the Ricci-driven |
| 170 | linear ODE. The reaction is the fixed-input reaction from Equation (3.5); |
| 171 | the four input terms cancel its four negative Ricci contractions. |
| 172 | -/ |
| 173 | theorem hasDerivWithinAt_curvature_moving_inputs |
| 174 | (hC : RicciFlowCurvatureTheory.{u}) (F : RicciFlow n M J) |
| 175 | {t : ℝ} (ht : t ∈ interior J) (x : M) |
| 176 | (u v w z : ℝ → TangentSpace (𝓡 n) x) |
| 177 | (hu : HasDerivWithinAt u (ricciSharp (F.connection t) x (u t)) J t) |
| 178 | (hv : HasDerivWithinAt v (ricciSharp (F.connection t) x (v t)) J t) |
| 179 | (hw : HasDerivWithinAt w (ricciSharp (F.connection t) x (w t)) J t) |
| 180 | (hz : HasDerivWithinAt z (ricciSharp (F.connection t) x (z t)) J t) : |
| 181 | HasDerivWithinAt |
| 182 | (fun s => (F.connection s).curvatureTensor x (u s) (v s) (w s) (z s)) |
| 183 | ((F.connection t).tensorLaplacian (F.connection t).riemannEvaluation x |
| 184 | ![u t, v t, w t, z t] + |
| 185 | 2 * ((F.connection t).curvatureB x (u t) (v t) (w t) (z t) - |
| 186 | (F.connection t).curvatureB x (u t) (v t) (z t) (w t) - |
| 187 | (F.connection t).curvatureB x (u t) (z t) (v t) (w t) + |
| 188 | (F.connection t).curvatureB x (u t) (w t) (v t) (z t))) J t := by |
| 189 | classical |
| 190 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 191 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 192 | let : FiniteDimensional ℝ (TangentSpace (𝓡 n) x) := |
| 193 | VectorBundle.finiteDimensional ℝ (EuclideanSpace ℝ (Fin n)) |
| 194 | (TangentSpace (𝓡 n) : M → Type _) x |
| 195 | choose A hA using fun s => |
| 196 | (hC.tensor_calculus n M (F.metric s) (F.connection s)).1.1 x |
| 197 | let dA (q : Fin 4 → TangentSpace (𝓡 n) x) := |
| 198 | (F.connection t).tensorLaplacian (F.connection t).riemannEvaluation x |
| 199 | ![q 0, q 1, q 2, q 3] + |
| 200 | (F.connection t).curvatureReaction x (q 0) (q 1) (q 2) (q 3) |
| 201 | have hfixed (q : Fin 4 → TangentSpace (𝓡 n) x) : |
| 202 | HasDerivWithinAt (fun s => A s q) (dA q) J t := by |
| 203 | simpa only [← hA, LeviCivitaData.riemannEvaluation] using |
| 204 | hC.curvature_evolution n M J F t (interior_subset ht) x (q 0) (q 1) (q 2) (q 3) |
| 205 | have hmoving := hasDerivWithinAt_four_moving |
| 206 | (uniqueDiffWithinAt_of_mem_nhds (mem_interior_iff_mem_nhds.mp ht)) |
| 207 | A dA hfixed hu hv hw hz |
| 208 | simp [← hA, LeviCivitaData.riemannEvaluation, dA] at hmoving |
| 209 | apply hmoving.congr_deriv |
| 210 | have hcancel := curvatureReaction_add_ricciSharp (F.connection t) |
| 211 | (hC.tensor_calculus n M (F.metric t) (F.connection t)) x (u t) (v t) (w t) (z t) |
| 212 | linear_combination hcancel |
| 213 | |
| 214 | end PoincareMT.RicciFlow |