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.Frame.Transport.Regularity |
| 2 | import Mathlib.Analysis.Calculus.FDeriv.Symmetric |
| 3 | import Mathlib.Analysis.Calculus.FDeriv.Extend |
| 4 | |
| 5 | /-! |
| 6 | # Spatial variational equation for linear transport |
| 7 | |
| 8 | Spatial derivatives satisfy the differentiated linear equation on a closed |
| 9 | time interval. Mixed derivatives commute in the interior, and continuity of |
| 10 | the variational right-hand side extends the identity to both endpoints. |
| 11 | -/ |
| 12 | |
| 13 | open Set Filter |
| 14 | open scoped Topology ContDiff |
| 15 | |
| 16 | noncomputable section |
| 17 | |
| 18 | namespace PoincareMT.RicciFlow.Frame |
| 19 | |
| 20 | variable {P G : Type*} [NormedAddCommGroup P] [NormedSpace ℝ P] |
| 21 | [NormedAddCommGroup G] [NormedSpace ℝ G] |
| 22 | |
| 23 | private theorem spatial_fderiv_eq |
| 24 | {f : P × ℝ → G} {q : P × ℝ} (hf : DifferentiableAt ℝ f q) : |
| 25 | fderiv ℝ (fun x => f (x, q.2)) q.1 = |
| 26 | (fderiv ℝ f q).comp (ContinuousLinearMap.inl ℝ P ℝ) := by |
| 27 | exact (hf.hasFDerivAt.comp q.1 (hasFDerivAt_prodMk_left q.1 q.2)).fderiv |
| 28 | |
| 29 | private theorem hasDerivAt_fderiv_param_of_contDiffOn |
| 30 | {f : P × ℝ → G} {g : P × ℝ → G} {U : Set P} (hU : IsOpen U) |
| 31 | {T : Set ℝ} (hT : IsOpen T) |
| 32 | (hf : ContDiffOn ℝ ∞ f (U ×ˢ T)) |
| 33 | (ht : ∀ q ∈ U ×ˢ T, HasDerivAt (fun t => f (q.1, t)) (g q) q.2) |
| 34 | {x : P} (hx : x ∈ U) {t : ℝ} (htmem : t ∈ T) : |
| 35 | HasDerivAt (fun t => fderiv ℝ (fun p => f (p, t)) x) |
| 36 | (fderiv ℝ (fun p => g (p, t)) x) t := by |
| 37 | let j := ContinuousLinearMap.inl ℝ P ℝ |
| 38 | let e : P × ℝ := (0, 1) |
| 39 | let D := fderiv ℝ (fderiv ℝ f) (x, t) |
| 40 | have hopen : IsOpen (U ×ˢ T) := hU.prod hT |
| 41 | have hp : (x, t) ∈ U ×ˢ T := ⟨hx, htmem⟩ |
| 42 | have hfd : ∀ q ∈ U ×ˢ T, DifferentiableAt ℝ f q := fun q hq => |
| 43 | ((hf q hq).contDiffAt (hopen.mem_nhds hq)).differentiableAt (by simp) |
| 44 | have hD : HasFDerivAt (fderiv ℝ f) D (x, t) := |
| 45 | (((hf _ hp).contDiffAt (hopen.mem_nhds hp)).fderiv_right |
| 46 | (m := 1) (by decide)).differentiableAt |
| 47 | (by simp) |>.hasFDerivAt |
| 48 | have htime : HasDerivAt (fun s => fderiv ℝ f (x, s)) (D e) t := by |
| 49 | exact hD.comp_hasDerivAt t ((hasDerivAt_const t x).prodMk (hasDerivAt_id t)) |
| 50 | have htimej : HasDerivAt (fun s => (fderiv ℝ f (x, s)).comp j) ((D e).comp j) t := by |
| 51 | simpa using htime.clm_comp (hasDerivAt_const t j) |
| 52 | have htimeeq : (fun s => (fderiv ℝ f (x, s)).comp j) =ᶠ[𝓝 t] |
| 53 | (fun s => fderiv ℝ (fun p => f (p, s)) x) := by |
| 54 | filter_upwards [hT.mem_nhds htmem] with s hs |
| 55 | exact (spatial_fderiv_eq (hfd (x, s) ⟨hx, hs⟩)).symm |
| 56 | have hgeq : (fun p => (fderiv ℝ f (p, t)) e) =ᶠ[𝓝 x] |
| 57 | (fun p => g (p, t)) := by |
| 58 | filter_upwards [hU.mem_nhds hx] with y hy |
| 59 | have hcurve : HasDerivAt (fun s : ℝ => (y, s)) e t := |
| 60 | (hasDerivAt_const t y).prodMk (hasDerivAt_id t) |
| 61 | have hd := (hfd (y, t) ⟨hy, htmem⟩).hasFDerivAt.comp_hasDerivAt t hcurve |
| 62 | exact hd.unique (ht (y, t) ⟨hy, htmem⟩) |
| 63 | have hgderiv : HasFDerivAt (fun p => g (p, t)) ((D.flip e).comp j) x := by |
| 64 | have h1 := (hD.clm_apply (hasFDerivAt_const (𝕜 := ℝ) e (x, t))).comp x |
| 65 | (hasFDerivAt_prodMk_left (𝕜 := ℝ) x t) |
| 66 | have h2 : HasFDerivAt (fun p => (fderiv ℝ f (p, t)) e) ((D.flip e).comp j) x := by |
| 67 | simpa [j, Function.comp_def] using h1 |
| 68 | exact h2.congr_of_eventuallyEq hgeq.symm |
| 69 | have hsymm : (D e).comp j = (D.flip e).comp j := by |
| 70 | ext v |
| 71 | exact ((hf _ hp).contDiffAt (hopen.mem_nhds hp)).isSymmSndFDerivAt |
| 72 | (by simp only [minSmoothness_of_isRCLikeNormedField]; decide) e (j v) |
| 73 | rw [hgderiv.fderiv, ← hsymm] |
| 74 | exact htimej.congr_of_eventuallyEq htimeeq.symm |
| 75 | |
| 76 | private theorem hasDerivWithinAt_Icc_of_continuousOn |
| 77 | {f g : ℝ → G} {a b : ℝ} (hab : a < b) |
| 78 | (hf : ContinuousOn f (Icc a b)) (hg : ContinuousOn g (Icc a b)) |
| 79 | (hd : ∀ s ∈ Ioo a b, HasDerivAt f (g s) s) |
| 80 | {t : ℝ} (ht : t ∈ Icc a b) : |
| 81 | HasDerivWithinAt f (g t) (Icc a b) t := by |
| 82 | have hcl : closure (Ioo a b) = Icc a b := closure_Ioo hab.ne |
| 83 | have hc : ∀ s ∈ closure (Ioo a b), ContinuousWithinAt f (Ioo a b) s := by |
| 84 | intro s hs |
| 85 | rw [hcl] at hs |
| 86 | exact (hf s hs).mono Ioo_subset_Icc_self |
| 87 | have hlim : Tendsto (fun s => fderiv ℝ f s) (𝓝[Ioo a b] t) |
| 88 | (𝓝 (ContinuousLinearMap.toSpanSingleton ℝ (g t))) := by |
| 89 | have hcont : ContinuousWithinAt (fun s => ContinuousLinearMap.toSpanSingleton ℝ (g s)) |
| 90 | (Icc a b) t := |
| 91 | ContinuousLinearMap.toSpanSingletonCLE.continuous.continuousAt.comp_continuousWithinAt |
| 92 | (hg t ht) |
| 93 | apply (hcont.mono Ioo_subset_Icc_self).congr' |
| 94 | filter_upwards [self_mem_nhdsWithin] with s hs |
| 95 | exact (hd s hs).hasFDerivAt.fderiv.symm |
| 96 | have hfderiv := hasFDerivWithinAt_closure_of_tendsto_fderiv |
| 97 | (fun s hs => (hd s hs).differentiableAt.differentiableWithinAt) |
| 98 | (convex_Ioo a b) isOpen_Ioo hc hlim |
| 99 | rw [hcl] at hfderiv |
| 100 | simpa using hfderiv.hasDerivWithinAt |
| 101 | |
| 102 | /-- The spatial derivative of a smooth parameter family of linear equations |
| 103 | satisfies the variational equation on the whole closed time interval. -/ |
| 104 | theorem linearODE_hasDerivWithinAt_fderiv_param |
| 105 | [FiniteDimensional ℝ P] [CompleteSpace G] |
| 106 | (A : P → ℝ → G →L[ℝ] G) {a b : ℝ} (hab : a ≤ b) |
| 107 | {U : Set P} (hU : IsOpen U) |
| 108 | (hA : ContDiffOn ℝ ∞ (Function.uncurry A) (U ×ˢ Icc a b)) |
| 109 | (Φ : P → ℝ → G) (hinit : ContDiffOn ℝ ∞ (fun p => Φ p a) U) |
| 110 | (hsol : ∀ p ∈ U, ∀ t ∈ Icc a b, |
| 111 | HasDerivWithinAt (Φ p) (A p t (Φ p t)) (Icc a b) t) |
| 112 | {x : P} (hx : x ∈ U) {t : ℝ} (ht : t ∈ Icc a b) : |
| 113 | HasDerivWithinAt (fun s => fderiv ℝ (fun p => Φ p s) x) |
| 114 | ((fderiv ℝ (fun p => A p t) x).flip (Φ x t) + |
| 115 | (A x t).comp (fderiv ℝ (fun p => Φ p t) x)) (Icc a b) t := by |
| 116 | rcases eq_or_lt_of_le hab with heq | hlt |
| 117 | · subst b |
| 118 | simp only [Icc_self] at * |
| 119 | rw [hasDerivWithinAt_iff_hasFDerivWithinAt] |
| 120 | exact HasFDerivWithinAt.singleton |
| 121 | let DΦ : P × ℝ → P →L[ℝ] G := fun q => fderiv ℝ (fun p => Φ p q.2) q.1 |
| 122 | let DA : P × ℝ → P →L[ℝ] G →L[ℝ] G := fun q => fderiv ℝ (fun p => A p q.2) q.1 |
| 123 | let R : P × ℝ → P →L[ℝ] G := fun q => |
| 124 | (DA q).flip (Φ q.1 q.2) + (A q.1 q.2).comp (DΦ q) |
| 125 | have hΦcont := linearODE_continuousOn A hab hU hA Φ hinit hsol |
| 126 | have hDΦcont : ContinuousOn DΦ (U ×ˢ Icc a b) := |
| 127 | linearODE_continuousOn_fderiv_param A hab hU hA Φ hinit hsol |
| 128 | have hDAcont : ContinuousOn DA (U ×ˢ Icc a b) := |
| 129 | (contDiffOn_fderiv_param_Icc hlt hU hA).continuousOn |
| 130 | have hRcont : ContinuousOn R (U ×ˢ Icc a b) := by |
| 131 | exact ((ContinuousLinearMap.flipₗᵢ ℝ P G G).continuous.comp_continuousOn hDAcont).clm_apply |
| 132 | hΦcont |>.add (hA.continuousOn.clm_comp hDΦcont) |
| 133 | have hslice : ContinuousOn (fun s : ℝ => (x, s)) (Icc a b) := |
| 134 | (continuous_const.prodMk continuous_id).continuousOn |
| 135 | have hmaps : MapsTo (fun s : ℝ => (x, s)) (Icc a b) (U ×ˢ Icc a b) := |
| 136 | fun _ hs => ⟨hx, hs⟩ |
| 137 | change HasDerivWithinAt (fun s => DΦ (x, s)) (R (x, t)) (Icc a b) t |
| 138 | apply hasDerivWithinAt_Icc_of_continuousOn hlt |
| 139 | (hDΦcont.comp hslice hmaps) (hRcont.comp hslice hmaps) ?_ ht |
| 140 | intro s hs |
| 141 | have hΦsmooth := linearODE_contDiffOn_interior A hab hU hA Φ hinit hsol |
| 142 | have hd := hasDerivAt_fderiv_param_of_contDiffOn hU isOpen_Ioo hΦsmooth |
| 143 | (g := fun q => A q.1 q.2 (Φ q.1 q.2)) |
| 144 | (fun q hq => (hsol q.1 hq.1 q.2 (Ioo_subset_Icc_self hq.2)).hasDerivAt |
| 145 | (Icc_mem_nhds hq.2.1 hq.2.2)) hx hs |
| 146 | have hAt : ContDiffOn ℝ ∞ (fun p => A p s) U := |
| 147 | hA.comp (contDiffOn_id.prodMk contDiffOn_const) |
| 148 | (fun _ hp => ⟨hp, Ioo_subset_Icc_self hs⟩) |
| 149 | have hΦt := linearODE_contDiffOn_spatial A hab hU hA Φ hinit hsol |
| 150 | (Ioo_subset_Icc_self hs) |
| 151 | have hdA := ((hAt x hx).contDiffAt (hU.mem_nhds hx)).differentiableAt (by simp) |
| 152 | have hdΦ := ((hΦt x hx).contDiffAt (hU.mem_nhds hx)).differentiableAt (by simp) |
| 153 | have hR : fderiv ℝ (fun p => A p s (Φ p s)) x = R (x, s) := by |
| 154 | rw [(hdA.hasFDerivAt.clm_apply hdΦ.hasFDerivAt).fderiv] |
| 155 | exact add_comm _ _ |
| 156 | rw [hR] at hd |
| 157 | exact hd |
| 158 | |
| 159 | /-- Directional form of the spatial variational equation. -/ |
| 160 | theorem linearODE_hasDerivWithinAt_fderiv_param_apply |
| 161 | [FiniteDimensional ℝ P] [CompleteSpace G] |
| 162 | (A : P → ℝ → G →L[ℝ] G) {a b : ℝ} (hab : a ≤ b) |
| 163 | {U : Set P} (hU : IsOpen U) |
| 164 | (hA : ContDiffOn ℝ ∞ (Function.uncurry A) (U ×ˢ Icc a b)) |
| 165 | (Φ : P → ℝ → G) (hinit : ContDiffOn ℝ ∞ (fun p => Φ p a) U) |
| 166 | (hsol : ∀ p ∈ U, ∀ t ∈ Icc a b, |
| 167 | HasDerivWithinAt (Φ p) (A p t (Φ p t)) (Icc a b) t) |
| 168 | {x : P} (hx : x ∈ U) {t : ℝ} (ht : t ∈ Icc a b) (v : P) : |
| 169 | HasDerivWithinAt (fun s => (fderiv ℝ (fun p => Φ p s) x) v) |
| 170 | ((fderiv ℝ (fun p => A p t) x) v (Φ x t) + |
| 171 | A x t ((fderiv ℝ (fun p => Φ p t) x) v)) (Icc a b) t := by |
| 172 | simpa using (linearODE_hasDerivWithinAt_fderiv_param A hab hU hA Φ hinit hsol hx ht).clm_apply |
| 173 | (hasDerivWithinAt_const t (Icc a b) v) |
| 174 | |
| 175 | end PoincareMT.RicciFlow.Frame |