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.Analysis.Heat.RealKernel |
| 2 | import Mathlib.MeasureTheory.Integral.IntegralEqImproper |
| 3 | |
| 4 | /-! |
| 5 | # Evolution of Lipschitz functions on the real line |
| 6 | |
| 7 | Differentiation and Gaussian integration by parts for the explicit evolution |
| 8 | used in the dimension-one case of Chow et al., Part III, Proposition 26.49, |
| 9 | equation (26.132), printed p. 378 (PDF p. 399). |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open MeasureTheory ProbabilityTheory Filter |
| 15 | open scoped Topology NNReal |
| 16 | |
| 17 | namespace Poincare.Analysis.Heat |
| 18 | |
| 19 | theorem integrable_standardGaussian_iff {f : ℝ → ℝ} : |
| 20 | Integrable f (gaussianReal 0 1) ↔ |
| 21 | Integrable (fun z ↦ gaussianPDFReal 0 1 z * f z) := by |
| 22 | rw [gaussianReal_of_var_ne_zero _ one_ne_zero, |
| 23 | integrable_withDensity_iff_integrable_smul' (measurable_gaussianPDF _ _) |
| 24 | (ae_of_all _ fun _ ↦ gaussianPDF_lt_top)] |
| 25 | simp |
| 26 | |
| 27 | theorem integrable_id_mul_of_lipschitz_standardGaussian {L : ℝ≥0} {f : ℝ → ℝ} |
| 28 | (hf : LipschitzWith L f) : |
| 29 | Integrable (fun z ↦ z * f z) (gaussianReal 0 1) := by |
| 30 | have hsq : Integrable (fun z : ℝ ↦ z ^ 2) (gaussianReal 0 1) := by |
| 31 | simpa only [id_eq, Real.norm_eq_abs, sq_abs] using |
| 32 | (memLp_id_gaussianReal (μ := 0) (v := 1) 2).integrable_norm_pow (by norm_num) |
| 33 | apply ((integrable_abs_standardGaussian.mul_const |f 0|).add |
| 34 | (hsq.const_mul (L : ℝ))).mono' (continuous_id.mul hf.continuous).aestronglyMeasurable |
| 35 | filter_upwards [] with z |
| 36 | have h := hf.dist_le_mul z 0 |
| 37 | simp only [Real.dist_eq, sub_zero] at h |
| 38 | have htri := abs_add_le (f 0) (f z - f 0) |
| 39 | simp only [add_sub_cancel] at htri |
| 40 | simp only [Pi.add_apply, Real.norm_eq_abs, Pi.mul_apply, id_eq, abs_mul] |
| 41 | calc |
| 42 | |z| * |f z| ≤ |z| * (|f 0| + (L : ℝ) * |z|) := |
| 43 | mul_le_mul_of_nonneg_left (htri.trans (add_le_add_right h _)) (abs_nonneg z) |
| 44 | _ = |z| * |f 0| + (L : ℝ) * z ^ 2 := by |
| 45 | rw [mul_add, mul_left_comm |z| (L : ℝ), ← sq, sq_abs] |
| 46 | |
| 47 | theorem integrable_deriv_of_lipschitz_standardGaussian {L : ℝ≥0} {f : ℝ → ℝ} |
| 48 | (hf : LipschitzWith L f) : |
| 49 | Integrable (deriv f) (gaussianReal 0 1) := by |
| 50 | exact (integrable_const (L : ℝ)).mono' (measurable_deriv f).aestronglyMeasurable |
| 51 | (ae_of_all _ fun _ ↦ norm_deriv_le_of_lipschitz hf) |
| 52 | |
| 53 | /-- Gaussian integration by parts for differentiable Lipschitz functions. |
| 54 | The integrability version of integration by parts proves the boundary decay. -/ |
| 55 | theorem integral_deriv_standardGaussian {L : ℝ≥0} {f : ℝ → ℝ} |
| 56 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) : |
| 57 | (∫ z, deriv f z ∂gaussianReal 0 1) = |
| 58 | ∫ z, z * f z ∂gaussianReal 0 1 := by |
| 59 | have hk : realHeatKernel (1 / 2) = gaussianPDFReal 0 1 := by |
| 60 | funext z |
| 61 | rw [realHeatKernel_eq_gaussianPDFReal (by norm_num : 0 ≤ (1 : ℝ) / 2)] |
| 62 | congr 1 |
| 63 | apply Subtype.ext |
| 64 | norm_num |
| 65 | have hK (z : ℝ) : HasDerivAt (gaussianPDFReal 0 1) |
| 66 | (-z * gaussianPDFReal 0 1 z) z := by |
| 67 | have h := hasDerivAt_realHeatKernel_space (by norm_num : 0 < (1 : ℝ) / 2) z |
| 68 | norm_num [hk] at h ⊢ |
| 69 | exact h |
| 70 | have hi : Integrable (fun z ↦ gaussianPDFReal 0 1 z * f z) := by |
| 71 | apply integrable_standardGaussian_iff.mp |
| 72 | simpa using |
| 73 | integrable_gaussianAverage hf (1 / 2) 0 |
| 74 | have hiz := integrable_standardGaussian_iff.mp |
| 75 | (integrable_id_mul_of_lipschitz_standardGaussian hf) |
| 76 | have hid := integrable_standardGaussian_iff.mp |
| 77 | (integrable_deriv_of_lipschitz_standardGaussian hf) |
| 78 | have h := integral_mul_deriv_eq_deriv_mul_of_integrable |
| 79 | (u := gaussianPDFReal 0 1) (v := f) |
| 80 | (u' := fun z ↦ -z * gaussianPDFReal 0 1 z) (v' := deriv f) |
| 81 | (fun z _ ↦ hK z) (fun z _ ↦ (hdf z).hasDerivAt) hid ?_ hi |
| 82 | · simp_rw [integral_gaussianReal_eq_integral_smul (v := (1 : ℝ≥0)) one_ne_zero, |
| 83 | smul_eq_mul] |
| 84 | rw [h] |
| 85 | rw [← integral_neg] |
| 86 | apply integral_congr_ae |
| 87 | filter_upwards [] with z |
| 88 | ring |
| 89 | · convert! hiz.neg using 1 |
| 90 | ext z |
| 91 | simp only [Pi.neg_apply, Pi.mul_apply] |
| 92 | ring |
| 93 | |
| 94 | theorem lipschitzWith_gaussianIntegrand {L : ℝ≥0} {f : ℝ → ℝ} |
| 95 | (hf : LipschitzWith L f) (t x : ℝ) : |
| 96 | LipschitzWith (L * Real.nnabs (Real.sqrt (2 * t))) |
| 97 | (fun z ↦ f (x + Real.sqrt (2 * t) * z)) := by |
| 98 | apply LipschitzWith.of_dist_le_mul |
| 99 | intro z w |
| 100 | have h := hf.dist_le_mul (x + Real.sqrt (2 * t) * z) |
| 101 | (x + Real.sqrt (2 * t) * w) |
| 102 | simpa only [NNReal.coe_mul, Real.coe_nnabs, Real.dist_eq, |
| 103 | add_sub_add_left_eq_sub, ← mul_sub, abs_mul, mul_assoc] using h |
| 104 | |
| 105 | theorem gaussianAverage_deriv_eq {L : ℝ≥0} {f : ℝ → ℝ} |
| 106 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) |
| 107 | {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 108 | gaussianAverage (deriv f) t x = |
| 109 | ∫ z, (z / Real.sqrt (2 * t)) * f (x + Real.sqrt (2 * t) * z) |
| 110 | ∂gaussianReal 0 1 := by |
| 111 | have ha : Real.sqrt (2 * t) ≠ 0 := (Real.sqrt_pos.mpr (by positivity)).ne' |
| 112 | have hd (z : ℝ) : HasDerivAt (fun w ↦ f (x + Real.sqrt (2 * t) * w)) |
| 113 | (deriv f (x + Real.sqrt (2 * t) * z) * Real.sqrt (2 * t)) z := by |
| 114 | simpa only [Function.comp_def, id_eq, mul_one] using! |
| 115 | (hdf _).hasDerivAt.comp z (((hasDerivAt_id z).const_mul _).const_add x) |
| 116 | have h := integral_deriv_standardGaussian (lipschitzWith_gaussianIntegrand hf t x) |
| 117 | (fun z ↦ (hd z).differentiableAt) |
| 118 | simp_rw [(hd _).deriv] at h |
| 119 | rw [integral_mul_const] at h |
| 120 | apply (eq_div_iff ha).mpr at h |
| 121 | unfold gaussianAverage |
| 122 | rw [h, ← integral_div] |
| 123 | apply integral_congr_ae |
| 124 | filter_upwards [] with z |
| 125 | ring |
| 126 | |
| 127 | theorem hasDerivAt_gaussianAverage_twice {L : ℝ≥0} {f : ℝ → ℝ} |
| 128 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) |
| 129 | {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 130 | HasDerivAt (deriv (gaussianAverage f t)) |
| 131 | (∫ z, (z / Real.sqrt (2 * t)) * deriv f (x + Real.sqrt (2 * t) * z) |
| 132 | ∂gaussianReal 0 1) x := by |
| 133 | have heq : deriv (gaussianAverage f t) = fun a ↦ |
| 134 | ∫ z, (z / Real.sqrt (2 * t)) * f (a + Real.sqrt (2 * t) * z) |
| 135 | ∂gaussianReal 0 1 := by |
| 136 | funext a |
| 137 | rw [(hasDerivAt_gaussianAverage hf hdf t a).deriv, |
| 138 | gaussianAverage_deriv_eq hf hdf ht] |
| 139 | rw [heq] |
| 140 | have h := hasDerivAt_integral_of_dominated_loc_of_deriv_le |
| 141 | (μ := gaussianReal 0 1) (s := Set.univ) |
| 142 | (bound := fun z : ℝ ↦ (|z| / Real.sqrt (2 * t)) * (L : ℝ)) |
| 143 | (F := fun a z : ℝ ↦ (z / Real.sqrt (2 * t)) * f (a + Real.sqrt (2 * t) * z)) |
| 144 | (F' := fun a z : ℝ ↦ (z / Real.sqrt (2 * t)) * deriv f (a + Real.sqrt (2 * t) * z)) |
| 145 | (x₀ := x) univ_mem ?_ ?_ ?_ ?_ ?_ ?_ |
| 146 | · exact h.2 |
| 147 | · exact Eventually.of_forall fun a ↦ |
| 148 | ((continuous_id.div_const _).mul (hf.continuous.comp (by fun_prop))).aestronglyMeasurable |
| 149 | · convert! (integrable_id_mul_of_lipschitz_standardGaussian |
| 150 | (lipschitzWith_gaussianIntegrand hf t x)).div_const (Real.sqrt (2 * t)) using 1 |
| 151 | ext z |
| 152 | ring |
| 153 | · exact ((measurable_id.div_const _).mul |
| 154 | ((measurable_deriv f).comp (by fun_prop))).aestronglyMeasurable |
| 155 | · filter_upwards [] with z |
| 156 | intro a _ |
| 157 | rw [Real.norm_eq_abs, abs_mul, abs_div, abs_of_nonneg (Real.sqrt_nonneg _)] |
| 158 | exact mul_le_mul_of_nonneg_left (norm_deriv_le_of_lipschitz hf) (by positivity) |
| 159 | · exact (integrable_abs_standardGaussian.div_const _).mul_const _ |
| 160 | · filter_upwards [] with z |
| 161 | intro a _ |
| 162 | have hd := (hdf _).hasDerivAt.comp a |
| 163 | ((hasDerivAt_id a).add_const (Real.sqrt (2 * t) * z)) |
| 164 | simpa only [Function.comp_def, id_eq, mul_one] using! |
| 165 | hd.const_mul (z / Real.sqrt (2 * t)) |
| 166 | |
| 167 | theorem hasDerivAt_gaussianAverage_time {L : ℝ≥0} {f : ℝ → ℝ} |
| 168 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) |
| 169 | {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 170 | HasDerivAt (fun s ↦ gaussianAverage f s x) |
| 171 | (∫ z, deriv f (x + Real.sqrt (2 * t) * z) * |
| 172 | (z / Real.sqrt (2 * t)) ∂gaussianReal 0 1) t := by |
| 173 | have h := hasDerivAt_integral_of_dominated_loc_of_deriv_le |
| 174 | (μ := gaussianReal 0 1) (s := Set.Ioi (t / 2)) |
| 175 | (bound := fun z : ℝ ↦ (L : ℝ) * (|z| / Real.sqrt t)) |
| 176 | (F := fun s z : ℝ ↦ f (x + Real.sqrt (2 * s) * z)) |
| 177 | (F' := fun s z : ℝ ↦ deriv f (x + Real.sqrt (2 * s) * z) * |
| 178 | (z / Real.sqrt (2 * s))) |
| 179 | (x₀ := t) (Ioi_mem_nhds (by linarith)) ?_ |
| 180 | (integrable_gaussianAverage hf t x) ?_ ?_ ?_ ?_ |
| 181 | · exact h.2 |
| 182 | · exact Eventually.of_forall fun s ↦ |
| 183 | (integrable_gaussianAverage hf s x).aestronglyMeasurable |
| 184 | · exact (((measurable_deriv f).comp (by fun_prop)).mul |
| 185 | (by fun_prop)).aestronglyMeasurable |
| 186 | · filter_upwards [] with z |
| 187 | intro s hs |
| 188 | have hs0 : 0 < s := by change t / 2 < s at hs; linarith |
| 189 | rw [Real.norm_eq_abs, abs_mul, abs_div, abs_of_nonneg (Real.sqrt_nonneg _)] |
| 190 | apply mul_le_mul |
| 191 | · exact norm_deriv_le_of_lipschitz hf |
| 192 | · apply div_le_div_of_nonneg_left (abs_nonneg _) (Real.sqrt_pos.mpr ht) |
| 193 | apply Real.sqrt_le_sqrt |
| 194 | change t / 2 < s at hs |
| 195 | linarith |
| 196 | · positivity |
| 197 | · positivity |
| 198 | · exact (integrable_abs_standardGaussian.div_const _).const_mul _ |
| 199 | · filter_upwards [] with z |
| 200 | intro s hs |
| 201 | have hs0 : 0 < s := by change t / 2 < s at hs; linarith |
| 202 | have hd := (((hasDerivAt_id s).const_mul 2).sqrt |
| 203 | (by positivity : 2 * s ≠ 0)).mul_const z |
| 204 | have hc := (hdf (x + Real.sqrt (2 * s) * z)).hasDerivAt.comp s |
| 205 | (hd.const_add x) |
| 206 | convert! hc using 1 |
| 207 | simp only [id_eq, mul_one] |
| 208 | field_simp |
| 209 | |
| 210 | theorem gaussianAverage_heatEquation {L : ℝ≥0} {f : ℝ → ℝ} |
| 211 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) |
| 212 | {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 213 | HasDerivAt (fun s ↦ gaussianAverage f s x) |
| 214 | (deriv (deriv (gaussianAverage f t)) x) t := by |
| 215 | rw [(hasDerivAt_gaussianAverage_twice hf hdf ht x).deriv] |
| 216 | convert! hasDerivAt_gaussianAverage_time hf hdf ht x using 1 |
| 217 | apply integral_congr_ae |
| 218 | filter_upwards [] with z |
| 219 | ring |
| 220 | |
| 221 | theorem realHeatEvolution_estimates {L : ℝ≥0} {f : ℝ → ℝ} |
| 222 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) : |
| 223 | TendstoUniformly (gaussianAverage f) f (𝓝[>] (0 : ℝ)) ∧ |
| 224 | ∀ t : ℝ, 0 < t → |
| 225 | Differentiable ℝ (gaussianAverage f t) ∧ |
| 226 | Differentiable ℝ (deriv (gaussianAverage f t)) ∧ |
| 227 | ∀ x : ℝ, |
| 228 | HasDerivAt (fun s ↦ gaussianAverage f s x) |
| 229 | (deriv (deriv (gaussianAverage f t)) x) t ∧ |
| 230 | |gaussianAverage f t x - f x| ≤ (L : ℝ) * Real.sqrt (2 * t) ∧ |
| 231 | |deriv (gaussianAverage f t) x| ≤ (L : ℝ) := by |
| 232 | refine ⟨tendstoUniformly_gaussianAverage hf, fun t ht ↦ ⟨?_, ?_, ?_⟩⟩ |
| 233 | · exact fun x ↦ (hasDerivAt_gaussianAverage hf hdf t x).differentiableAt |
| 234 | · exact fun x ↦ (hasDerivAt_gaussianAverage_twice hf hdf ht x).differentiableAt |
| 235 | · exact fun x ↦ ⟨gaussianAverage_heatEquation hf hdf ht x, |
| 236 | abs_gaussianAverage_sub_le hf t x, abs_deriv_gaussianAverage_le hf t x⟩ |
| 237 | |
| 238 | theorem abs_deriv_gaussianAverage_twice_le {L : ℝ≥0} {f : ℝ → ℝ} |
| 239 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) |
| 240 | {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 241 | |deriv (deriv (gaussianAverage f t)) x| ≤ (L : ℝ) / Real.sqrt (2 * t) := by |
| 242 | rw [(hasDerivAt_gaussianAverage_twice hf hdf ht x).deriv] |
| 243 | have hb : ∀ᵐ z ∂gaussianReal 0 1, |
| 244 | ‖(z / Real.sqrt (2 * t)) * deriv f (x + Real.sqrt (2 * t) * z)‖ ≤ |
| 245 | ((L : ℝ) / Real.sqrt (2 * t)) * |z| := by |
| 246 | filter_upwards [] with z |
| 247 | rw [Real.norm_eq_abs, abs_mul, abs_div, abs_of_nonneg (Real.sqrt_nonneg _)] |
| 248 | calc |
| 249 | _ ≤ (|z| / Real.sqrt (2 * t)) * (L : ℝ) := |
| 250 | mul_le_mul_of_nonneg_left (norm_deriv_le_of_lipschitz hf) (by positivity) |
| 251 | _ = _ := by ring |
| 252 | have h := norm_integral_le_of_norm_le |
| 253 | (integrable_abs_standardGaussian.const_mul ((L : ℝ) / Real.sqrt (2 * t))) hb |
| 254 | rw [integral_const_mul] at h |
| 255 | exact h.trans (by |
| 256 | simpa using mul_le_mul_of_nonneg_left integral_abs_standardGaussian_le_one |
| 257 | (by positivity : 0 ≤ (L : ℝ) / Real.sqrt (2 * t))) |
| 258 | |
| 259 | theorem lipschitzWith_deriv_gaussianAverage {L : ℝ≥0} {f : ℝ → ℝ} |
| 260 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) |
| 261 | {t : ℝ} (ht : 0 < t) : |
| 262 | LipschitzWith (L / Real.nnabs (Real.sqrt (2 * t))) (deriv (gaussianAverage f t)) := by |
| 263 | apply lipschitzWith_of_nnnorm_deriv_le |
| 264 | (fun x ↦ (hasDerivAt_gaussianAverage_twice hf hdf ht x).differentiableAt) |
| 265 | intro x |
| 266 | apply NNReal.coe_le_coe.mp |
| 267 | simpa only [coe_nnnorm, Real.norm_eq_abs, NNReal.coe_div, Real.coe_nnabs, |
| 268 | abs_of_nonneg (Real.sqrt_nonneg _)] using abs_deriv_gaussianAverage_twice_le hf hdf ht x |
| 269 | |
| 270 | end Poincare.Analysis.Heat |