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 Mathlib.Analysis.Calculus.ContDiff.Operations |
| 2 | import Mathlib.Analysis.Calculus.FDeriv.CompCLM |
| 3 | |
| 4 | /-! |
| 5 | # Second derivative composition and smooth readouts |
| 6 | |
| 7 | The twice-differentiated chain rule is proved in arbitrary normed |
| 8 | spaces before applying it to nested metric jets. This is the scalar |
| 9 | finite-jet calculation used in Morgan--Tian, equation (3.7), p. 41, |
| 10 | and Lemma 16.8, pp. 372-373; M44 derivation 26. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Filter |
| 16 | open scoped ContDiff Topology BigOperators |
| 17 | |
| 18 | namespace PoincareMT.M44 |
| 19 | |
| 20 | variable {E J F K : Type*} |
| 21 | [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 22 | [NormedAddCommGroup J] [NormedSpace ℝ J] |
| 23 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 24 | [NormedAddCommGroup K] [NormedSpace ℝ K] |
| 25 | |
| 26 | /-- The actual second derivative of a composition, evaluated in two |
| 27 | directions. Only the smooth germs at the displayed points are used. |
| 28 | Source: the chain rule in the scalar finite-jet calculation, M44 derivation 26. -/ |
| 29 | theorem second_fderiv_comp_of_contDiffAt {f : E → J} {g : J → F} {x : E} |
| 30 | (hf : ContDiffAt ℝ ∞ f x) (hg : ContDiffAt ℝ ∞ g (f x)) (u v : E) : |
| 31 | fderiv ℝ (fderiv ℝ (g ∘ f)) x u v = |
| 32 | fderiv ℝ (fderiv ℝ g) (f x) (fderiv ℝ f x u) (fderiv ℝ f x v) + |
| 33 | fderiv ℝ g (f x) (fderiv ℝ (fderiv ℝ f) x u v) := by |
| 34 | have hf' := hf.fderiv_right (m := ∞) (by simp) |
| 35 | have hg' := hg.fderiv_right (m := ∞) (by simp) |
| 36 | have hchain := ((hg'.differentiableAt (by simp)).hasFDerivAt.comp x |
| 37 | (hf.differentiableAt (by simp)).hasFDerivAt).clm_apply |
| 38 | ((hf'.differentiableAt (by simp)).hasFDerivAt.clm_apply (hasFDerivAt_const v x)) |
| 39 | have hcomp : ContDiffAt ℝ ∞ (g ∘ f) x := hg.comp x hf |
| 40 | have heval := ((hcomp.fderiv_right (m := ∞) (by simp)).differentiableAt |
| 41 | (by simp)).hasFDerivAt.clm_apply (hasFDerivAt_const v x) |
| 42 | have heq : (fun y => fderiv ℝ (g ∘ f) y v) =ᶠ[𝓝 x] |
| 43 | (fun y => fderiv ℝ g (f y) (fderiv ℝ f y v)) := by |
| 44 | have hfe := (hf.of_le (show (1 : ℕ∞ω) ≤ ∞ by simp)).eventually (by simp) |
| 45 | have hge := (hg.of_le (show (1 : ℕ∞ω) ≤ ∞ by simp)).eventually (by simp) |
| 46 | filter_upwards [hfe, hf.continuousAt.eventually hge] with y hfy hgy |
| 47 | rw [fderiv_comp y (hgy.differentiableAt (by simp)) (hfy.differentiableAt (by simp))] |
| 48 | rfl |
| 49 | have h := congrArg (fun A => A u) |
| 50 | (heval.fderiv.symm.trans (heq.fderiv_eq.trans hchain.fderiv)) |
| 51 | simpa only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.flip_apply, |
| 52 | Function.comp_apply, add_apply, zero_apply, map_zero, zero_add, add_zero, add_comm] |
| 53 | using h |
| 54 | |
| 55 | /-- The second chain-rule readout is smooth when its scalar function |
| 56 | and four input maps are smooth. Source: the scalar finite-jet |
| 57 | calculation in M44 derivation 26. -/ |
| 58 | theorem contDiffAt_secondDerivative_readout {g : J → F} {a b c d : K → J} {x : K} |
| 59 | (hg : ContDiffAt ℝ ∞ g (a x)) (ha : ContDiffAt ℝ ∞ a x) |
| 60 | (hb : ContDiffAt ℝ ∞ b x) (hc : ContDiffAt ℝ ∞ c x) (hd : ContDiffAt ℝ ∞ d x) : |
| 61 | ContDiffAt ℝ ∞ (fun y => fderiv ℝ (fderiv ℝ g) (a y) (b y) (c y) + |
| 62 | fderiv ℝ g (a y) (d y)) x := by |
| 63 | have hg' := hg.fderiv_right (m := ∞) (by simp) |
| 64 | have hg'' := hg'.fderiv_right (m := ∞) (by simp) |
| 65 | exact (((hg''.comp x ha).clm_apply hb).clm_apply hc).add ((hg'.comp x ha).clm_apply hd) |
| 66 | |
| 67 | /-- The finite contraction of a second chain-rule jet, with its first |
| 68 | derivative correction, is smooth. The coefficient space is arbitrary; |
| 69 | in the scalar application it is the metric two-jet space. Source: |
| 70 | the coordinate Laplacian calculation in M44 derivation 26. -/ |
| 71 | theorem contDiffAt_secondDerivativeJet_contraction {ι : Type*} [Fintype ι] |
| 72 | {g : J → ℝ} (e : ι → E) {v : ι → J → E} {c : J → E} |
| 73 | {x : J × (E →L[ℝ] J) × (E →L[ℝ] E →L[ℝ] J)} |
| 74 | (hg : ContDiffAt ℝ ∞ g x.1) |
| 75 | (hv : ∀ i, ContDiffAt ℝ ∞ (v i) x.1) |
| 76 | (hc : ContDiffAt ℝ ∞ c x.1) : |
| 77 | ContDiffAt ℝ ∞ |
| 78 | (fun y : J × (E →L[ℝ] J) × (E →L[ℝ] E →L[ℝ] J) => |
| 79 | (∑ i, (fderiv ℝ (fderiv ℝ g) y.1 (y.2.1 (e i)) (y.2.1 (v i y.1)) + |
| 80 | fderiv ℝ g y.1 (y.2.2 (e i) (v i y.1)))) - |
| 81 | fderiv ℝ g y.1 (y.2.1 (c y.1))) x := by |
| 82 | have hA : ContDiffAt ℝ ∞ |
| 83 | (fun y : J × (E →L[ℝ] J) × (E →L[ℝ] E →L[ℝ] J) => y.2.1) x := |
| 84 | contDiffAt_snd.fst |
| 85 | have hB : ContDiffAt ℝ ∞ |
| 86 | (fun y : J × (E →L[ℝ] J) × (E →L[ℝ] E →L[ℝ] J) => y.2.2) x := |
| 87 | contDiffAt_snd.snd |
| 88 | apply ContDiffAt.sub |
| 89 | · apply ContDiffAt.sum |
| 90 | intro i _ |
| 91 | have hV := (hv i).comp x contDiffAt_fst |
| 92 | exact contDiffAt_secondDerivative_readout hg contDiffAt_fst |
| 93 | (hA.clm_apply contDiffAt_const) (hA.clm_apply hV) |
| 94 | ((hB.clm_apply contDiffAt_const).clm_apply hV) |
| 95 | · exact ((hg.fderiv_right (m := ∞) (by simp)).comp x contDiffAt_fst).clm_apply |
| 96 | (hA.clm_apply (hc.comp x contDiffAt_fst)) |
| 97 | |
| 98 | /-- The scalar chain-rule contraction with arbitrary parameter maps. |
| 99 | The parameter space needs only a topology for its continuity theorem. |
| 100 | Source: the finite scalar contraction in M44 derivation 26. -/ |
| 101 | noncomputable def secondDerivativeContractionReadout {X ι : Type*} [Fintype ι] |
| 102 | (g : J → ℝ) (e : ι → E) (a : X → J) (b : X → E →L[ℝ] J) |
| 103 | (d : X → E →L[ℝ] E →L[ℝ] J) (v : ι → X → E) (c : X → E) (x : X) : ℝ := |
| 104 | (∑ i, (fderiv ℝ (fderiv ℝ g) (a x) (b x (e i)) (b x (v i x)) + |
| 105 | fderiv ℝ g (a x) (d x (e i) (v i x)))) - fderiv ℝ g (a x) (b x (c x)) |
| 106 | |
| 107 | /-- Continuity of the actual second chain-rule contraction uses only |
| 108 | continuous parameter maps. Source: equation (3.7), M44 derivation 26. -/ |
| 109 | theorem continuousAt_secondDerivativeContractionReadout {X ι : Type*} |
| 110 | [TopologicalSpace X] [Fintype ι] |
| 111 | {g : J → ℝ} (e : ι → E) {a : X → J} {b : X → E →L[ℝ] J} |
| 112 | {d : X → E →L[ℝ] E →L[ℝ] J} {v : ι → X → E} {c : X → E} {x : X} |
| 113 | (hg : ContDiffAt ℝ ∞ g (a x)) (ha : ContinuousAt a x) (hb : ContinuousAt b x) |
| 114 | (hd : ContinuousAt d x) (hv : ∀ i, ContinuousAt (v i) x) (hc : ContinuousAt c x) : |
| 115 | ContinuousAt (secondDerivativeContractionReadout g e a b d v c) x := by |
| 116 | have hg' := hg.fderiv_right (m := ∞) (by simp) |
| 117 | have hg'' := hg'.fderiv_right (m := ∞) (by simp) |
| 118 | have hfirst := hg'.continuousAt.comp ha |
| 119 | have hsecond := hg''.continuousAt.comp ha |
| 120 | apply ContinuousAt.sub |
| 121 | · apply tendsto_finsetSum |
| 122 | intro i _ |
| 123 | exact ((hsecond.clm_apply (hb.clm_apply continuousAt_const)).clm_apply |
| 124 | (hb.clm_apply (hv i))).add |
| 125 | (hfirst.clm_apply ((hd.clm_apply continuousAt_const).clm_apply (hv i))) |
| 126 | · exact hfirst.clm_apply (hb.clm_apply hc) |
| 127 | |
| 128 | /-- The second chain-rule contraction, with its connection correction. |
| 129 | Keeping the jet space abstract shares the normed-space parameters in |
| 130 | the scalar application. Source: M44 derivation 26. -/ |
| 131 | noncomputable def secondDerivativeJetContraction {ι : Type*} [Fintype ι] |
| 132 | (g : J → ℝ) (e : ι → E) (v : ι → J → E) (c : J → E) |
| 133 | (y : J × (E →L[ℝ] J) × (E →L[ℝ] E →L[ℝ] J)) : ℝ := |
| 134 | (∑ i, (fderiv ℝ (fderiv ℝ g) y.1 (y.2.1 (e i)) (y.2.1 (v i y.1)) + |
| 135 | fderiv ℝ g y.1 (y.2.2 (e i) (v i y.1)))) - |
| 136 | fderiv ℝ g y.1 (y.2.1 (c y.1)) |
| 137 | |
| 138 | /-- The scalar second-derivative contraction is continuous when its |
| 139 | coefficient maps are continuous. This is the regularity needed for |
| 140 | compact finite-jet bounds in M44 derivation 26. -/ |
| 141 | theorem continuousAt_secondDerivativeJet_contraction {ι : Type*} [Fintype ι] |
| 142 | {g : J → ℝ} (e : ι → E) {v : ι → J → E} {c : J → E} |
| 143 | {x : J × (E →L[ℝ] J) × (E →L[ℝ] E →L[ℝ] J)} |
| 144 | (hg : ContDiffAt ℝ ∞ g x.1) |
| 145 | (hv : ∀ i, ContinuousAt (v i) x.1) |
| 146 | (hc : ContinuousAt c x.1) : |
| 147 | ContinuousAt (secondDerivativeJetContraction g e v c) x := by |
| 148 | have hA : ContinuousAt |
| 149 | (fun y : J × (E →L[ℝ] J) × (E →L[ℝ] E →L[ℝ] J) => y.2.1) x := |
| 150 | continuousAt_snd.fst |
| 151 | have hB : ContinuousAt |
| 152 | (fun y : J × (E →L[ℝ] J) × (E →L[ℝ] E →L[ℝ] J) => y.2.2) x := |
| 153 | continuousAt_snd.snd |
| 154 | have hg' := hg.fderiv_right (m := ∞) (by simp) |
| 155 | have hg'' := hg'.fderiv_right (m := ∞) (by simp) |
| 156 | have hfirst := hg'.continuousAt.comp continuousAt_fst |
| 157 | have hsecond := hg''.continuousAt.comp continuousAt_fst |
| 158 | apply ContinuousAt.sub |
| 159 | · apply tendsto_finsetSum |
| 160 | intro i _ |
| 161 | have hV := (hv i).comp continuousAt_fst |
| 162 | exact ((hsecond.clm_apply (hA.clm_apply continuousAt_const)).clm_apply |
| 163 | (hA.clm_apply hV)).add |
| 164 | (hfirst.clm_apply ((hB.clm_apply continuousAt_const).clm_apply hV)) |
| 165 | · exact hfirst.clm_apply (hA.clm_apply (hc.comp continuousAt_fst)) |
| 166 | |
| 167 | /-- A finite coordinate contraction of first and second chain-rule |
| 168 | derivatives. Only evaluations of the source jet are stored. Source: |
| 169 | the scalar Laplacian calculation in M44 derivation 26. -/ |
| 170 | noncomputable def secondDerivativeArrayContraction {X ι : Type*} [Fintype ι] |
| 171 | (g : J → ℝ) (a : X → J) (b : ι → X → J) (d : ι → ι → X → J) |
| 172 | (v : ι → ι → X → ℝ) (c : ι → X → ℝ) (x : X) : ℝ := |
| 173 | (∑ i, ∑ j, v i j x * (fderiv ℝ (fderiv ℝ g) (a x) (b i x) (b j x) + |
| 174 | fderiv ℝ g (a x) (d i j x))) - ∑ i, c i x * fderiv ℝ g (a x) (b i x) |
| 175 | |
| 176 | /-- Continuity of the finite coordinate chain-rule contraction. |
| 177 | The parameter space needs only a topology. Source: the finite-jet |
| 178 | compactness estimate in M44 derivation 26. -/ |
| 179 | theorem continuousAt_secondDerivativeArrayContraction {X ι : Type*} |
| 180 | [TopologicalSpace X] [Fintype ι] |
| 181 | {g : J → ℝ} {a : X → J} {b : ι → X → J} {d : ι → ι → X → J} |
| 182 | {v : ι → ι → X → ℝ} {c : ι → X → ℝ} {x : X} |
| 183 | (hg : ContDiffAt ℝ ∞ g (a x)) (ha : ContinuousAt a x) |
| 184 | (hb : ∀ i, ContinuousAt (b i) x) (hd : ∀ i j, ContinuousAt (d i j) x) |
| 185 | (hv : ∀ i j, ContinuousAt (v i j) x) (hc : ∀ i, ContinuousAt (c i) x) : |
| 186 | ContinuousAt (secondDerivativeArrayContraction g a b d v c) x := by |
| 187 | have hg' := hg.fderiv_right (m := ∞) (by simp) |
| 188 | have hg'' := hg'.fderiv_right (m := ∞) (by simp) |
| 189 | have hfirst := hg'.continuousAt.comp ha |
| 190 | have hsecond := hg''.continuousAt.comp ha |
| 191 | apply ContinuousAt.sub |
| 192 | · apply tendsto_finsetSum |
| 193 | intro i _ |
| 194 | apply tendsto_finsetSum |
| 195 | intro j _ |
| 196 | exact (hv i j).mul (((hsecond.clm_apply (hb i)).clm_apply (hb j)).add |
| 197 | (hfirst.clm_apply (hd i j))) |
| 198 | · apply tendsto_finsetSum |
| 199 | intro i _ |
| 200 | exact (hc i).mul (hfirst.clm_apply (hb i)) |
| 201 | |
| 202 | /-- Evaluation on vectors of norm at most one preserves a common |
| 203 | bound on the value and its first two derivative slots. Source: |
| 204 | the finite coordinate package in M44 derivation 26. -/ |
| 205 | theorem norm_coordinateDerivativeArray_le {ι : Type*} [Fintype ι] |
| 206 | (e : ι → E) (he : ∀ i, ‖e i‖ ≤ 1) (z : J) |
| 207 | (A : E →L[ℝ] J) (B : E →L[ℝ] E →L[ℝ] J) {C : ℝ} |
| 208 | (hz : ‖z‖ ≤ C) (hA : ‖A‖ ≤ C) (hB : ‖B‖ ≤ C) : |
| 209 | ‖(z, (fun i => A (e i)), (fun i j => B (e i) (e j)))‖ ≤ C := by |
| 210 | have hC : 0 ≤ C := (norm_nonneg z).trans hz |
| 211 | have hfirst (i : ι) : ‖A (e i)‖ ≤ C := |
| 212 | (A.le_opNorm (e i)).trans ((mul_le_mul hA (he i) (norm_nonneg _) hC).trans_eq (mul_one C)) |
| 213 | have hsec (i j : ι) : ‖B (e i) (e j)‖ ≤ C := by |
| 214 | have hi : ‖B (e i)‖ ≤ C := |
| 215 | (B.le_opNorm (e i)).trans |
| 216 | ((mul_le_mul hB (he i) (norm_nonneg _) hC).trans_eq (mul_one C)) |
| 217 | exact ((B (e i)).le_opNorm (e j)).trans |
| 218 | ((mul_le_mul hi (he j) (norm_nonneg _) hC).trans_eq (mul_one C)) |
| 219 | exact max_le hz (max_le ((pi_norm_le_iff_of_nonneg hC).mpr hfirst) |
| 220 | ((pi_norm_le_iff_of_nonneg hC).mpr fun i => (pi_norm_le_iff_of_nonneg hC).mpr (hsec i))) |
| 221 | |
| 222 | end PoincareMT.M44 |