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.Surgery.StandardCap.Persistence.Analysis.Jets.UniformCompactDerivative |
| 2 | import PoincareLib.Geometry.RicciFlow.Surgery.StandardCap.Persistence.Analysis.ODE.ODEModelBuffer |
| 3 | import PoincareLib.Analysis.Calculus.MixedDerivatives |
| 4 | |
| 5 | /-! |
| 6 | # First variations of smoothly varying ODE solutions |
| 7 | |
| 8 | The first variation is an actual solution of the differentiated field. |
| 9 | Compact convergence of the original fields and derivatives passes to |
| 10 | this augmented field. This supplies the first derivative stability for |
| 11 | Morgan--Tian, Claim 16.6, pp. 371-372; see |
| 12 | `derivations/17-first-variational-convergence.md`. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set Filter Metric |
| 18 | open scoped ContDiff Topology |
| 19 | |
| 20 | section FirstVariation |
| 21 | |
| 22 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 23 | |
| 24 | /-- The autonomous first variational equation records both the actual |
| 25 | trajectory and one directional derivative of its initial-data family. -/ |
| 26 | noncomputable def firstVariationalField (F : E → E) (z : E × E) : E × E := |
| 27 | (F z.1, fderiv ℝ F z.1 z.2) |
| 28 | |
| 29 | /-- A smooth field has a smooth first variational field. -/ |
| 30 | theorem ContDiff.firstVariationalField {F : E → E} (hF : ContDiff ℝ ∞ F) : |
| 31 | ContDiff ℝ ∞ (firstVariationalField F) := |
| 32 | (hF.comp contDiff_fst).prodMk |
| 33 | (((hF.fderiv_right (m := ∞) (by simp)).comp contDiff_fst).clm_apply contDiff_snd) |
| 34 | |
| 35 | /-- Mixed derivative symmetry gives the variational equation for an |
| 36 | actual smooth initial-data family on an open parameter neighborhood. -/ |
| 37 | theorem hasDerivAt_first_variation |
| 38 | {P : Type*} [NormedAddCommGroup P] [NormedSpace ℝ P] |
| 39 | {F : E → E} {γ : P × ℝ → E} {p : P} {t : ℝ} |
| 40 | (hγ : ContDiffAt ℝ ∞ γ (p, t)) |
| 41 | (hode : ∀ᶠ q in 𝓝 p, HasDerivAt (fun s => γ (q, s)) (F (γ (q, t))) t) |
| 42 | (hF : DifferentiableAt ℝ F (γ (p, t))) (v : P) : |
| 43 | HasDerivAt |
| 44 | (fun s => (γ (p, s), fderiv ℝ (fun q => γ (q, s)) p v)) |
| 45 | (firstVariationalField F (γ (p, t), fderiv ℝ (fun q => γ (q, t)) p v)) t := by |
| 46 | have hswap : ContDiffAt ℝ ∞ (fun z : ℝ × P => γ (z.2, z.1)) (t, p) := |
| 47 | hγ.comp (t, p) (contDiffAt_snd.prodMk contDiffAt_fst) |
| 48 | have hd := Poincare.Analysis.hasDerivAt_fderiv_time_of_eventually hswap hode v |
| 49 | have hspace : DifferentiableAt ℝ (fun q => γ (q, t)) p := |
| 50 | (hγ.comp p (contDiffAt_id.prodMk contDiffAt_const)).differentiableAt (by simp) |
| 51 | have hchain := fderiv_comp p hF hspace |
| 52 | change fderiv ℝ (fun q => F (γ (q, t))) p = |
| 53 | (fderiv ℝ F (γ (p, t))).comp (fderiv ℝ (fun q => γ (q, t)) p) at hchain |
| 54 | rw [hchain] at hd |
| 55 | exact hode.self_of_nhds.prodMk hd |
| 56 | |
| 57 | /-- Compact C1 convergence of fields yields compact convergence of the |
| 58 | augmented first variational fields. -/ |
| 59 | theorem tendstoUniformlyOn_firstVariationalField |
| 60 | [FiniteDimensional ℝ E] {ι : Type*} {l : Filter ι} |
| 61 | {F : ι → E → E} {G : E → E} (hG : ContDiff ℝ 1 G) |
| 62 | {K V : Set E} (hK : IsCompact K) (hV : IsCompact V) |
| 63 | (hzero : TendstoUniformlyOn F G l K) |
| 64 | (hone : TendstoUniformlyOn (fun i => fderiv ℝ (F i)) (fderiv ℝ G) l K) : |
| 65 | TendstoUniformlyOn (fun i => firstVariationalField (F i)) |
| 66 | (firstVariationalField G) l (K ×ˢ V) := by |
| 67 | let H (z : E × (E →L[ℝ] E) × E) : E × E := (z.1, z.2.1 z.2.2) |
| 68 | have hH : Continuous H := by dsimp [H]; fun_prop |
| 69 | have h0 := (hzero.comp Prod.fst).mono (fun _ hz => hz.1 : K ×ˢ V ⊆ Prod.fst ⁻¹' K) |
| 70 | have h1 := (hone.comp Prod.fst).mono (fun _ hz => hz.1 : K ×ˢ V ⊆ Prod.fst ⁻¹' K) |
| 71 | have hv : TendstoUniformlyOn (fun _ : ι => (Prod.snd : E × E → E)) Prod.snd l (K ×ˢ V) := |
| 72 | Metric.tendstoUniformlyOn_iff.mpr fun epsilon hepsilon => |
| 73 | Eventually.of_forall fun _ _ _ => by simpa only [dist_self] using hepsilon |
| 74 | have hJ : Continuous (fun z : E × E => (G z.1, fderiv ℝ G z.1, z.2)) := |
| 75 | (hG.continuous.comp continuous_fst).prodMk |
| 76 | ((((hG.fderiv_right (m := 0) (by simp)).continuous).comp continuous_fst).prodMk |
| 77 | continuous_snd) |
| 78 | exact hH.continuousOn.comp_tendstoUniformlyOn_of_compact_image isOpen_univ |
| 79 | ((hK.prod hV).image hJ) (fun _ _ => mem_univ _) (h0.prodMk_same (h1.prodMk_same hv)) |
| 80 | |
| 81 | end FirstVariation |
| 82 | |
| 83 | section SolutionFamilies |
| 84 | |
| 85 | variable {E P : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 86 | [NormedAddCommGroup P] [NormedSpace ℝ P] |
| 87 | |
| 88 | /-- The actual value and one spatial directional derivative of a |
| 89 | parameterized trajectory, evaluated at a fixed time. -/ |
| 90 | noncomputable def firstVariation (γ : P × ℝ → E) (z : P × P) (t : ℝ) : E × E := |
| 91 | (γ (z.1, t), fderiv ℝ (fun p => γ (p, t)) z.1 z.2) |
| 92 | |
| 93 | /-- First variations inherit smoothness from the actual joint family. |
| 94 | The spatial derivative is computed from the full joint derivative. -/ |
| 95 | theorem ContDiffAt.firstVariation {γ : P × ℝ → E} {p v : P} {t : ℝ} |
| 96 | (hγ : ContDiffAt ℝ ∞ γ (p, t)) : |
| 97 | ContDiffAt ℝ ∞ (fun z : (P × P) × ℝ => firstVariation γ z.1 z.2) ((p, v), t) := by |
| 98 | have harg : ContDiff ℝ ∞ (fun z : (P × P) × ℝ => (z.1.1, z.2)) := by fun_prop |
| 99 | have hdir : ContDiff ℝ ∞ (fun z : (P × P) × ℝ => (z.1.2, (0 : ℝ))) := by fun_prop |
| 100 | have hformula : ContDiffAt ℝ ∞ |
| 101 | (fun z : (P × P) × ℝ => |
| 102 | (γ (z.1.1, z.2), fderiv ℝ γ (z.1.1, z.2) (z.1.2, 0))) ((p, v), t) := |
| 103 | (hγ.comp (f := fun z : (P × P) × ℝ => (z.1.1, z.2)) ((p, v), t) |
| 104 | harg.contDiffAt).prodMk |
| 105 | (((hγ.fderiv_right (m := ∞) (by simp)).comp |
| 106 | (f := fun z : (P × P) × ℝ => (z.1.1, z.2)) ((p, v), t) |
| 107 | harg.contDiffAt).clm_apply hdir.contDiffAt) |
| 108 | have hnear : ∀ᶠ q in 𝓝 (p, t), DifferentiableAt ℝ γ q := |
| 109 | ((hγ.of_le (by simp : (1 : WithTop ℕ∞) ≤ ∞)).eventually (by decide)).mono |
| 110 | (fun _ h => h.differentiableAt one_ne_zero) |
| 111 | apply hformula.congr_of_eventuallyEq |
| 112 | filter_upwards [harg.continuous.continuousAt.eventually hnear] with z hz |
| 113 | change DifferentiableAt ℝ γ (z.1.1, z.2) at hz |
| 114 | have hinc : HasFDerivAt (fun q : P => (q, z.2)) |
| 115 | ((ContinuousLinearMap.id ℝ P).prod (0 : P →L[ℝ] ℝ)) z.1.1 := by |
| 116 | exact (hasFDerivAt_id (𝕜 := ℝ) z.1.1).prodMk |
| 117 | (hasFDerivAt_const (𝕜 := ℝ) z.2 z.1.1) |
| 118 | have hspace := hz.hasFDerivAt.comp z.1.1 hinc |
| 119 | change (γ (z.1.1, z.2), fderiv ℝ (fun p => γ (p, z.2)) z.1.1 z.1.2) = _ |
| 120 | refine Prod.ext rfl ?_ |
| 121 | simpa only [firstVariation, Function.comp_def, ContinuousLinearMap.comp_apply, |
| 122 | ContinuousLinearMap.prod_apply, ContinuousLinearMap.id_apply, |
| 123 | zero_apply] using congrArg (fun D => D z.1.2) hspace.fderiv |
| 124 | |
| 125 | /-- Smooth model families and compact C1 field convergence give uniform |
| 126 | first-variation convergence, including the endpoints of the time interval. |
| 127 | Only the initial variation error is prescribed. -/ |
| 128 | theorem tendstoUniformlyOn_firstVariation_of_compact_model |
| 129 | [FiniteDimensional ℝ E] {ι : Type*} {l : Filter ι} |
| 130 | {F : ι → E → E} {G : E → E} {γ : ι → P × ℝ → E} {η : P × ℝ → E} |
| 131 | {U K V : Set P} {I : Set ℝ} {T : ℝ} |
| 132 | (hU : IsOpen U) (hI : IsOpen I) (hT : 0 ≤ T) (hTI : Icc (0 : ℝ) T ⊆ I) |
| 133 | (hK : IsCompact K) (hV : IsCompact V) (hKU : K ⊆ U) |
| 134 | (hG : ContDiff ℝ ∞ G) (hηsmooth : ContDiffOn ℝ ∞ η (U ×ˢ I)) |
| 135 | (hγsmooth : ∀ᶠ i in l, ContDiffOn ℝ ∞ (γ i) (U ×ˢ I)) |
| 136 | (hγode : ∀ᶠ i in l, ∀ p ∈ U, ∀ t ∈ I, |
| 137 | HasDerivAt (fun s => γ i (p, s)) (F i (γ i (p, t))) t) |
| 138 | (hF : ∀ᶠ i in l, ∀ p ∈ U, ∀ t ∈ I, DifferentiableAt ℝ (F i) (γ i (p, t))) |
| 139 | (hηode : ∀ p ∈ U, ∀ t ∈ I, |
| 140 | HasDerivAt (fun s => η (p, s)) (G (η (p, t))) t) |
| 141 | (hzero : ∀ R : ℝ, TendstoUniformlyOn F G l (closedBall 0 R)) |
| 142 | (hone : ∀ R : ℝ, TendstoUniformlyOn (fun i => fderiv ℝ (F i)) |
| 143 | (fderiv ℝ G) l (closedBall 0 R)) |
| 144 | (hinitial : TendstoUniformlyOn (fun i z => firstVariation (γ i) z 0) |
| 145 | (fun z => firstVariation η z 0) l (K ×ˢ V)) : |
| 146 | TendstoUniformlyOn (fun i (z : (P × P) × ℝ) => firstVariation (γ i) z.1 z.2) |
| 147 | (fun z => firstVariation η z.1 z.2) l ((K ×ˢ V) ×ˢ Icc (0 : ℝ) T) := by |
| 148 | have hmodel : ContinuousOn (fun z : (P × P) × ℝ => firstVariation η z.1 z.2) |
| 149 | ((K ×ˢ V) ×ˢ Icc (0 : ℝ) T) := by |
| 150 | intro z hz |
| 151 | exact ((hηsmooth.contDiffAt |
| 152 | ((hU.prod hI).mem_nhds ⟨hKU hz.1.1, hTI hz.2⟩)).firstVariation |
| 153 | (v := z.1.2)).continuousAt.continuousWithinAt |
| 154 | have hmodelODE : ∀ z ∈ K ×ˢ V, ∀ t ∈ Icc (0 : ℝ) T, |
| 155 | HasDerivAt (firstVariation η z) |
| 156 | (firstVariationalField G (firstVariation η z t)) t := by |
| 157 | intro z hz t ht |
| 158 | exact hasDerivAt_first_variation |
| 159 | (hηsmooth.contDiffAt ((hU.prod hI).mem_nhds ⟨hKU hz.1, hTI ht⟩)) |
| 160 | ((show ∀ᶠ p in 𝓝 z.1, p ∈ U from hU.mem_nhds (hKU hz.1)).mono |
| 161 | (fun p hp => hηode p hp t (hTI ht))) |
| 162 | (hG.differentiable (by simp) _) z.2 |
| 163 | have hactualODE : ∀ᶠ i in l, ∀ z ∈ K ×ˢ V, ∀ t ∈ Icc (0 : ℝ) T, |
| 164 | HasDerivAt (firstVariation (γ i) z) |
| 165 | (firstVariationalField (F i) (firstVariation (γ i) z t)) t := by |
| 166 | filter_upwards [hγsmooth, hγode, hF] with i his hio hif |
| 167 | intro z hz t ht |
| 168 | exact hasDerivAt_first_variation |
| 169 | (his.contDiffAt ((hU.prod hI).mem_nhds ⟨hKU hz.1, hTI ht⟩)) |
| 170 | ((show ∀ᶠ p in 𝓝 z.1, p ∈ U from hU.mem_nhds (hKU hz.1)).mono |
| 171 | (fun p hp => hio p hp t (hTI ht))) |
| 172 | (hif z.1 (hKU hz.1) t (hTI ht)) z.2 |
| 173 | have hfield : ∀ R : ℝ, |
| 174 | TendstoUniformlyOn (fun i => firstVariationalField (F i)) |
| 175 | (firstVariationalField G) l (closedBall (0 : E × E) R) := by |
| 176 | intro R |
| 177 | rw [show (0 : E × E) = (0, 0) from rfl, ← closedBall_prod_same] |
| 178 | exact tendstoUniformlyOn_firstVariationalField (hG.of_le (by simp)) |
| 179 | (isCompact_closedBall _ _) (isCompact_closedBall _ _) (hzero R) (hone R) |
| 180 | exact tendstoUniformlyOn_ode_of_compact_model hT |
| 181 | (hG.firstVariationalField.of_le (by simp)) (hK.prod hV) hmodel |
| 182 | hactualODE hmodelODE hfield hinitial |
| 183 | |
| 184 | end SolutionFamilies |