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.MeasureTheory.Measure.Haar.Unique |
| 2 | import Mathlib.Topology.MetricSpace.HausdorffDimension |
| 3 | import Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries |
| 4 | import Mathlib.Analysis.Calculus.ContDiff.Basic |
| 5 | import Mathlib.Analysis.Calculus.ContDiff.Operations |
| 6 | import Mathlib.Analysis.Calculus.TaylorIntegral |
| 7 | import Mathlib.MeasureTheory.Function.Jacobian |
| 8 | |
| 9 | /-! |
| 10 | # Hölder image nullity for the scalar Sard frontier |
| 11 | |
| 12 | Taylor estimates and Hausdorff dimension bounds give nullity of images of |
| 13 | flat critical strata. The final lemmas select regular values from nullity. |
| 14 | -/ |
| 15 | |
| 16 | open MeasureTheory Set |
| 17 | open scoped ContDiff |
| 18 | |
| 19 | namespace Poincare.Analysis |
| 20 | |
| 21 | /- The affine line restriction used in the flat critical stratum. Keeping this |
| 22 | identity explicit avoids unfolding the composition formula at each Taylor |
| 23 | estimate. -/ |
| 24 | noncomputable def lineMap {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 25 | (y v : E) : ℝ →L[ℝ] E := |
| 26 | (ContinuousLinearMap.id ℝ ℝ).smulRight v |
| 27 | |
| 28 | theorem iteratedFDeriv_lineMap |
| 29 | {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 30 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 31 | (f : E → F) (y v : E) (i : ℕ) |
| 32 | (hf : ContDiff ℝ i f) (t : ℝ) : |
| 33 | iteratedFDeriv ℝ i (fun u : ℝ => f (y + u • v)) t = |
| 34 | (iteratedFDeriv ℝ i f (y + t • v)).compContinuousLinearMap |
| 35 | (fun _ : Fin i => lineMap y v) := by |
| 36 | let g : E → F := fun z => f (y + z) |
| 37 | have hg : ContDiff ℝ i g := by |
| 38 | change ContDiff ℝ i (f ∘ fun z : E => y + z) |
| 39 | exact hf.comp (contDiff_const.add contDiff_id) |
| 40 | have hcomp := ContinuousLinearMap.iteratedFDeriv_comp_right |
| 41 | (lineMap y v) (f := g) hg t (i := i) (by rfl) |
| 42 | simp only [g, lineMap] at hcomp |
| 43 | rw [iteratedFDeriv_comp_add_left] at hcomp |
| 44 | have hline : (fun u : ℝ => f (y + u • v)) = |
| 45 | (fun z : E => f (y + z)) ∘ lineMap y v := by |
| 46 | funext u |
| 47 | rfl |
| 48 | rw [hline] |
| 49 | exact hcomp |
| 50 | |
| 51 | /- Taylor's integral remainder after the first `n` directional jets vanish. |
| 52 | The bound is stated for the diagonal `(n+1)`-derivative, which is the form |
| 53 | needed for the Holder estimate on the flat critical stratum. -/ |
| 54 | theorem norm_sub_le_of_flat_iteratedFDeriv |
| 55 | {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 56 | [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] |
| 57 | {f : E → F} {x y : E} {n : ℕ} {C : ℝ} |
| 58 | (hf : ∀ (t : ℝ) (_ht : t ∈ Icc 0 1), |
| 59 | ContDiffAt ℝ (n + 1) f (x + t • y)) |
| 60 | (hflat : ∀ k, 1 ≤ k → k ≤ n → |
| 61 | iteratedFDeriv ℝ k f x (fun _ : Fin k => y) = 0) |
| 62 | (hbound : ∀ (t : ℝ) (_ht : t ∈ Icc 0 1), |
| 63 | ‖iteratedFDeriv ℝ (n + 1) f (x + t • y) |
| 64 | (fun _ : Fin (n + 1) => y)‖ ≤ C) : |
| 65 | ‖f (x + y) - f x‖ ≤ C / (Nat.factorial n : ℝ) := by |
| 66 | have sum_flat : ∀ N : ℕ, (∀ k, 1 ≤ k → k ≤ N → |
| 67 | iteratedFDeriv ℝ k f x (fun _ : Fin k => y) = 0) → |
| 68 | (∑ k ∈ Finset.range (N + 1), |
| 69 | (Nat.factorial k : ℝ)⁻¹ • |
| 70 | (iteratedFDeriv ℝ k f x (fun _ : Fin k => y))) = f x := by |
| 71 | intro N hN |
| 72 | induction N with |
| 73 | | zero => simp |
| 74 | | succ n ih => |
| 75 | rw [Finset.sum_range_succ] |
| 76 | rw [ih (fun k hk hkn => hN k hk (by omega))] |
| 77 | have hz := hN (n + 1) (by omega) (by omega) |
| 78 | simp [hz] |
| 79 | have hsum := sum_flat n hflat |
| 80 | have hTaylor := map_add_eq_sum_add_integral_iteratedFDeriv |
| 81 | (f := f) (x := x) (y := y) (n := n) hf |
| 82 | rw [hTaylor, hsum] |
| 83 | rw [add_sub_cancel_left] |
| 84 | rw [norm_smul] |
| 85 | have hInt : ‖∫ t in (0 : ℝ)..1, |
| 86 | (1 - t) ^ n • (iteratedFDeriv ℝ (n + 1) f (x + t • y)) |
| 87 | (fun _ : Fin (n + 1) => y)‖ ≤ C := by |
| 88 | have hI := intervalIntegral.norm_integral_le_of_norm_le_const |
| 89 | (a := (0 : ℝ)) (b := 1) (C := C) |
| 90 | (f := fun t : ℝ => (1 - t) ^ n • |
| 91 | (iteratedFDeriv ℝ (n + 1) f (x + t • y)) |
| 92 | (fun _ : Fin (n + 1) => y)) |
| 93 | (by |
| 94 | intro t ht |
| 95 | rw [uIoc_of_le (by norm_num)] at ht |
| 96 | rw [norm_smul] |
| 97 | rw [norm_pow, Real.norm_eq_abs, abs_of_nonneg (by linarith [ht.2])] |
| 98 | have hp : (1 - t) ^ n ≤ (1 : ℝ) := by |
| 99 | exact pow_le_one₀ (by linarith [ht.2]) (by linarith [ht.1]) |
| 100 | calc |
| 101 | (1 - t) ^ n * ‖(iteratedFDeriv ℝ (n + 1) f (x + t • y)) |
| 102 | (fun _ : Fin (n + 1) => y)‖ ≤ |
| 103 | 1 * ‖(iteratedFDeriv ℝ (n + 1) f (x + t • y)) |
| 104 | (fun _ : Fin (n + 1) => y)‖ := |
| 105 | mul_le_mul_of_nonneg_right hp (norm_nonneg _) |
| 106 | _ ≤ C := by simpa using hbound t ⟨ht.1.le, ht.2⟩) |
| 107 | simpa using hI |
| 108 | have hn : 0 ≤ (Nat.factorial n : ℝ)⁻¹ := by positivity |
| 109 | calc |
| 110 | ‖(Nat.factorial n : ℝ)⁻¹‖ * ‖∫ t in (0 : ℝ)..1, |
| 111 | (1 - t) ^ n • (iteratedFDeriv ℝ (n + 1) f (x + t • y)) |
| 112 | (fun _ : Fin (n + 1) => y)‖ = |
| 113 | (Nat.factorial n : ℝ)⁻¹ * ‖∫ t in (0 : ℝ)..1, |
| 114 | (1 - t) ^ n • (iteratedFDeriv ℝ (n + 1) f (x + t • y)) |
| 115 | (fun _ : Fin (n + 1) => y)‖ := by |
| 116 | rw [Real.norm_eq_abs, abs_of_nonneg hn] |
| 117 | _ ≤ (Nat.factorial n : ℝ)⁻¹ * C := |
| 118 | mul_le_mul_of_nonneg_left hInt hn |
| 119 | _ = C / (Nat.factorial n : ℝ) := by |
| 120 | rw [div_eq_mul_inv, mul_comm] |
| 121 | |
| 122 | theorem iteratedFDeriv_apply_const_le |
| 123 | {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 124 | [NormedAddCommGroup F] [NormedSpace ℝ F] {n : ℕ} |
| 125 | {D : ContinuousMultilinearMap ℝ (fun _ : Fin (n + 1) => E) F} |
| 126 | {v : E} {C : ℝ} (hD : ‖D‖ ≤ C) : |
| 127 | ‖D (fun _ : Fin (n + 1) => v)‖ ≤ C * ‖v‖ ^ (n + 1) := by |
| 128 | calc |
| 129 | ‖D (fun _ : Fin (n + 1) => v)‖ ≤ ‖D‖ * ∏ _ : Fin (n + 1), ‖v‖ := D.le_opNorm _ |
| 130 | _ ≤ C * ‖v‖ ^ (n + 1) := by |
| 131 | rw [Finset.prod_const, Finset.card_fin] |
| 132 | gcongr |
| 133 | |
| 134 | theorem norm_sub_le_of_flat_iteratedFDeriv_of_norm_le |
| 135 | {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 136 | [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] |
| 137 | {f : E → F} {x y : E} {n : ℕ} {C : ℝ} |
| 138 | (hf : ∀ (t : ℝ) (_ht : t ∈ Icc 0 1), |
| 139 | ContDiffAt ℝ (n + 1) f (x + t • y)) |
| 140 | (hflat : ∀ k, 1 ≤ k → k ≤ n → |
| 141 | iteratedFDeriv ℝ k f x (fun _ : Fin k => y) = 0) |
| 142 | (hbound : ∀ (t : ℝ) (_ht : t ∈ Icc 0 1), |
| 143 | ‖iteratedFDeriv ℝ (n + 1) f (x + t • y)‖ ≤ C) : |
| 144 | ‖f (x + y) - f x‖ ≤ C * ‖y‖ ^ (n + 1) / (Nat.factorial n : ℝ) := by |
| 145 | apply norm_sub_le_of_flat_iteratedFDeriv hf hflat |
| 146 | intro t ht |
| 147 | exact iteratedFDeriv_apply_const_le (hbound t ht) |
| 148 | |
| 149 | theorem holderOnWith_of_flat_iteratedFDeriv |
| 150 | {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 151 | [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] |
| 152 | {s t : Set E} {f : E → F} {n : ℕ} {C : ℝ} |
| 153 | (hs : Convex ℝ s) (hC : 0 ≤ C) |
| 154 | (hts : t ⊆ s) |
| 155 | (hf : ∀ z ∈ s, ContDiffAt ℝ (n + 1) f z) |
| 156 | (hflat : ∀ z ∈ t, ∀ k, 1 ≤ k → k ≤ n → |
| 157 | iteratedFDeriv ℝ k f z = 0) |
| 158 | (hbound : ∀ z ∈ s, ‖iteratedFDeriv ℝ (n + 1) f z‖ ≤ C) : |
| 159 | HolderOnWith (⟨C / (Nat.factorial n : ℝ), by positivity⟩ : NNReal) |
| 160 | (⟨(n + 1 : ℕ), by positivity⟩ : NNReal) f t := by |
| 161 | let K : NNReal := ⟨C / (Nat.factorial n : ℝ), by positivity⟩ |
| 162 | let q : NNReal := ⟨(n + 1 : ℕ), by positivity⟩ |
| 163 | change HolderOnWith K q f t |
| 164 | intro x hx y hy |
| 165 | rw [edist_dist, edist_dist] |
| 166 | rw [dist_eq_norm] |
| 167 | rw [ENNReal.coe_nnreal_eq] |
| 168 | change ENNReal.ofReal ‖f x - f y‖ ≤ |
| 169 | ENNReal.ofReal (K : ℝ) * ENNReal.ofReal (dist x y) ^ (q : ℝ) |
| 170 | have hK : (K : ℝ) = C / (Nat.factorial n : ℝ) := by rfl |
| 171 | have hq : (q : ℝ) = (n + 1 : ℕ) := by rfl |
| 172 | rw [hK, hq] |
| 173 | rw [ENNReal.ofReal_rpow_of_nonneg (dist_nonneg) (by positivity)] |
| 174 | rw [← ENNReal.ofReal_mul (div_nonneg hC (by positivity))] |
| 175 | apply ENNReal.ofReal_le_ofReal |
| 176 | rw [norm_sub_rev] |
| 177 | rw [dist_eq_norm] |
| 178 | have hr := norm_sub_le_of_flat_iteratedFDeriv_of_norm_le |
| 179 | (f := f) (x := x) (y := y - x) (n := n) (C := C) |
| 180 | (by |
| 181 | intro t ht |
| 182 | exact hf _ (hs.add_smul_sub_mem (hts hx) (hts hy) ht)) |
| 183 | (by |
| 184 | intro k hk hkn |
| 185 | simpa using congr_arg (fun D => D (fun _ : Fin k => y - x)) |
| 186 | (hflat x hx k hk hkn)) |
| 187 | (by |
| 188 | intro t ht |
| 189 | exact hbound _ (hs.add_smul_sub_mem (hts hx) (hts hy) ht)) |
| 190 | have hxy : ‖y - x‖ = ‖x - y‖ := norm_sub_rev _ _ |
| 191 | rw [hxy] at hr |
| 192 | rw [Real.rpow_natCast] |
| 193 | simpa [sub_eq_add_neg, add_assoc, add_left_comm, add_comm, div_eq_mul_inv, |
| 194 | mul_comm, mul_left_comm, mul_assoc] using hr |
| 195 | |
| 196 | variable {m n : ℕ} |
| 197 | variable [MeasurableSpace (EuclideanSpace ℝ (Fin m))] |
| 198 | [BorelSpace (EuclideanSpace ℝ (Fin m))] |
| 199 | [MeasurableSpace (EuclideanSpace ℝ (Fin n))] |
| 200 | [BorelSpace (EuclideanSpace ℝ (Fin n))] |
| 201 | |
| 202 | /-- A locally Hölder map has null image when its dimension quotient is below the |
| 203 | target dimension. This is the analytic closure used for the flat critical |
| 204 | stratum in Sard's theorem. -/ |
| 205 | theorem measure_zero_image_of_locallyHolderOnWith_of_finrank_div_lt |
| 206 | {s : Set (EuclideanSpace ℝ (Fin m))} |
| 207 | {f : EuclideanSpace ℝ (Fin m) → EuclideanSpace ℝ (Fin n)} |
| 208 | (μ : Measure (EuclideanSpace ℝ (Fin n))) [μ.IsAddHaarMeasure] |
| 209 | {r : NNReal} (hr : 0 < r) |
| 210 | (hholder : |
| 211 | ∀ x ∈ s, ∃ C : NNReal, ∃ t ∈ nhdsWithin x s, |
| 212 | HolderOnWith C r f t) |
| 213 | (hdim : |
| 214 | (Module.finrank ℝ (EuclideanSpace ℝ (Fin m)) : ENNReal) / r < |
| 215 | Module.finrank ℝ (EuclideanSpace ℝ (Fin n))) : |
| 216 | μ (f '' s) = 0 := by |
| 217 | have hsourceDim : |
| 218 | dimH s ≤ Module.finrank ℝ (EuclideanSpace ℝ (Fin m)) := by |
| 219 | rw [← Real.dimH_univ_eq_finrank (EuclideanSpace ℝ (Fin m))] |
| 220 | exact dimH_mono (Set.subset_univ _) |
| 221 | have hdimImage : |
| 222 | dimH (f '' s) < Module.finrank ℝ (EuclideanSpace ℝ (Fin n)) := by |
| 223 | calc |
| 224 | dimH (f '' s) ≤ dimH s / r := |
| 225 | dimH_image_le_of_locally_holder_on hr hholder |
| 226 | _ ≤ (Module.finrank ℝ (EuclideanSpace ℝ (Fin m)) : ENNReal) / r := by |
| 227 | exact ENNReal.div_le_div_right hsourceDim r |
| 228 | _ < Module.finrank ℝ (EuclideanSpace ℝ (Fin n)) := hdim |
| 229 | have hhausdorff : |
| 230 | Measure.hausdorffMeasure |
| 231 | (Module.finrank ℝ (EuclideanSpace ℝ (Fin n)) : ℝ) |
| 232 | (f '' s) = 0 := by |
| 233 | simpa using hausdorffMeasure_of_dimH_lt hdimImage |
| 234 | rw [Measure.isAddLeftInvariant_eq_smul μ |
| 235 | (Measure.hausdorffMeasure (Module.finrank ℝ (EuclideanSpace ℝ (Fin n)) : ℝ))] |
| 236 | rw [Measure.smul_apply, hhausdorff] |
| 237 | simp |
| 238 | |
| 239 | theorem dense_compl_of_measure_zero_image |
| 240 | {α : Type*} [AddGroup α] [TopologicalSpace α] [MeasurableSpace α] |
| 241 | {A : Set α} (μ : Measure α) [μ.IsAddHaarMeasure] |
| 242 | (hA : μ A = 0) : Dense Aᶜ := by |
| 243 | rw [dense_iff_inter_open] |
| 244 | intro U hU hne |
| 245 | by_contra h |
| 246 | have hsub : U ⊆ A := by |
| 247 | intro x hx |
| 248 | by_contra hxA |
| 249 | exact h ⟨x, hx, hxA⟩ |
| 250 | have hUzero : μ U = 0 := measure_mono_null hsub hA |
| 251 | exact (hU.measure_pos μ hne).ne' (by simpa [hUzero]) |
| 252 | |
| 253 | theorem critical_values_null_one_dim |
| 254 | {s : Set ℝ} {f : ℝ → ℝ} (μ : Measure ℝ) [μ.IsAddHaarMeasure] |
| 255 | (hf' : ∀ x ∈ s, HasFDerivWithinAt f (fderiv ℝ f x) s x) |
| 256 | (hcrit : ∀ x ∈ s, (fderiv ℝ f x).det = 0) : |
| 257 | μ (f '' s) = 0 := by |
| 258 | exact addHaar_image_eq_zero_of_det_fderivWithin_eq_zero μ hf' hcrit |
| 259 | |
| 260 | theorem exists_regular_value_one_dim |
| 261 | {f : ℝ → ℝ} (hf : ContDiff ℝ ∞ f) {I : Set ℝ} |
| 262 | (hI : IsOpen I) (hIn : I.Nonempty) : |
| 263 | ∃ c ∈ I, ∀ x, f x = c → Function.Surjective (fderiv ℝ f x) := by |
| 264 | let s : Set ℝ := {x | (fderiv ℝ f x).det = 0} |
| 265 | have hnull : volume (f '' s) = 0 := by |
| 266 | apply critical_values_null_one_dim volume |
| 267 | · intro x hx |
| 268 | exact ((hf.differentiable (by simp)).differentiableAt).hasFDerivAt.hasFDerivWithinAt |
| 269 | · intro x hx |
| 270 | exact hx |
| 271 | have hdense : Dense (f '' s)ᶜ := |
| 272 | dense_compl_of_measure_zero_image volume hnull |
| 273 | rcases (dense_iff_inter_open.mp hdense I hI hIn) with ⟨c, hcI, hcn⟩ |
| 274 | refine ⟨c, hcI, ?_⟩ |
| 275 | intro x hxc |
| 276 | by_contra hsurj |
| 277 | apply hcn |
| 278 | refine ⟨x, ?_, hxc⟩ |
| 279 | change (fderiv ℝ f x).det = 0 |
| 280 | have hz : (fderiv ℝ f x).toLinearMap = 0 := by |
| 281 | have hne : ¬ (fderiv ℝ f x).toLinearMap ≠ 0 := by |
| 282 | intro hne |
| 283 | exact hsurj (LinearMap.surjective hne) |
| 284 | exact not_not.mp hne |
| 285 | simp [ContinuousLinearMap.det, hz] |
| 286 | |
| 287 | theorem dense_regular_values_of_null_critical_image |
| 288 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 289 | {f : E → ℝ} (μ : Measure ℝ) [μ.IsAddHaarMeasure] |
| 290 | (hcrit : μ (f '' {x | ¬ Function.Surjective (fderiv ℝ f x)}) = 0) : |
| 291 | Dense {c : ℝ | ∀ x, f x = c → Function.Surjective (fderiv ℝ f x)} := by |
| 292 | let C : Set ℝ := f '' {x | ¬ Function.Surjective (fderiv ℝ f x)} |
| 293 | have hC : Dense Cᶜ := dense_compl_of_measure_zero_image μ hcrit |
| 294 | have hregular : {c : ℝ | ∀ x, f x = c → Function.Surjective (fderiv ℝ f x)} = Cᶜ := by |
| 295 | ext c |
| 296 | constructor |
| 297 | · intro hc ⟨x, hx, hfx⟩ |
| 298 | exact hx (hc x hfx) |
| 299 | · intro hc x hfx |
| 300 | by_contra hns |
| 301 | exact hc ⟨x, hns, hfx⟩ |
| 302 | rw [hregular] |
| 303 | exact hC |
| 304 | |
| 305 | end Poincare.Analysis |
| 306 |