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.Gaussian |
| 2 | import Mathlib.Analysis.SpecialFunctions.Sqrt |
| 3 | |
| 4 | /-! |
| 5 | # The real Gaussian heat kernel |
| 6 | |
| 7 | The explicit real-coordinate kernel for the dimension-one case of Chow et al., |
| 8 | Part III, Proposition 26.49, equation (26.132), printed p. 378 (PDF p. 399). |
| 9 | The normalization is proved using Mathlib's Gaussian integral, and the heat |
| 10 | equation uses the ordinary second spatial derivative on the real line. |
| 11 | Identification with a manifold Laplacian requires an arclength-coordinate bridge. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open MeasureTheory ProbabilityTheory |
| 17 | open scoped ContDiff NNReal |
| 18 | |
| 19 | namespace Poincare.Analysis.Heat |
| 20 | |
| 21 | noncomputable def realHeatKernel (t x : ℝ) : ℝ := |
| 22 | (Real.sqrt (4 * Real.pi * t))⁻¹ * Real.exp (-x ^ 2 / (4 * t)) |
| 23 | |
| 24 | theorem realHeatKernel_eq_gaussianPDFReal {t : ℝ} (ht : 0 ≤ t) (x : ℝ) : |
| 25 | realHeatKernel t x = gaussianPDFReal 0 ⟨2 * t, by positivity⟩ x := by |
| 26 | change (Real.sqrt (4 * Real.pi * t))⁻¹ * Real.exp (-x ^ 2 / (4 * t)) = |
| 27 | (Real.sqrt (2 * Real.pi * (2 * t)))⁻¹ * Real.exp (-(x - 0) ^ 2 / (2 * (2 * t))) |
| 28 | congr 3 <;> ring |
| 29 | |
| 30 | theorem integrable_realHeatKernel {t : ℝ} (ht : 0 < t) : |
| 31 | Integrable (realHeatKernel t) := by |
| 32 | have heq : realHeatKernel t = gaussianPDFReal 0 ⟨2 * t, by positivity⟩ := |
| 33 | funext (realHeatKernel_eq_gaussianPDFReal ht.le) |
| 34 | rw [heq] |
| 35 | exact integrable_gaussianPDFReal _ _ |
| 36 | |
| 37 | theorem integral_realHeatKernel {t : ℝ} (ht : 0 < t) : |
| 38 | (∫ x, realHeatKernel t x) = 1 := by |
| 39 | simp_rw [realHeatKernel_eq_gaussianPDFReal ht.le] |
| 40 | apply integral_gaussianPDFReal_eq_one |
| 41 | apply ne_of_gt |
| 42 | change 0 < 2 * t |
| 43 | positivity |
| 44 | |
| 45 | theorem realHeatKernel_pos {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 46 | 0 < realHeatKernel t x := by |
| 47 | unfold realHeatKernel |
| 48 | positivity |
| 49 | |
| 50 | theorem hasDerivAt_realHeatKernel_space {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 51 | HasDerivAt (realHeatKernel t) (-x / (2 * t) * realHeatKernel t x) x := by |
| 52 | have h := (((hasDerivAt_id x).pow 2).neg.div_const (4 * t)).exp.const_mul |
| 53 | (Real.sqrt (4 * Real.pi * t))⁻¹ |
| 54 | convert! h using 1 |
| 55 | simp only [realHeatKernel, id_eq, Nat.cast_ofNat, mul_one, Pi.neg_apply, |
| 56 | Pi.pow_apply] |
| 57 | field_simp |
| 58 | ring |
| 59 | |
| 60 | theorem deriv_realHeatKernel_space {t : ℝ} (ht : 0 < t) : |
| 61 | deriv (realHeatKernel t) = fun x ↦ -x / (2 * t) * realHeatKernel t x := by |
| 62 | funext x |
| 63 | exact (hasDerivAt_realHeatKernel_space ht x).deriv |
| 64 | |
| 65 | theorem hasDerivAt_realHeatKernel_space_twice {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 66 | HasDerivAt (deriv (realHeatKernel t)) |
| 67 | ((x ^ 2 / (4 * t ^ 2) - 1 / (2 * t)) * realHeatKernel t x) x := by |
| 68 | rw [deriv_realHeatKernel_space ht] |
| 69 | have h := ((hasDerivAt_id x).neg.div_const (2 * t)).mul |
| 70 | (hasDerivAt_realHeatKernel_space ht x) |
| 71 | convert! h using 1 |
| 72 | simp only [Pi.neg_apply, id_eq] |
| 73 | field_simp |
| 74 | ring |
| 75 | |
| 76 | theorem hasDerivAt_realHeatKernel_time {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 77 | HasDerivAt (fun s ↦ realHeatKernel s x) |
| 78 | ((x ^ 2 / (4 * t ^ 2) - 1 / (2 * t)) * realHeatKernel t x) t := by |
| 79 | have hp : 0 < 4 * Real.pi * t := by positivity |
| 80 | have hs : Real.sqrt (4 * Real.pi * t) ≠ 0 := (Real.sqrt_pos.mpr hp).ne' |
| 81 | have hn := (((hasDerivAt_id t).const_mul (4 * Real.pi)).sqrt hp.ne').inv hs |
| 82 | have he := ((hasDerivAt_const t (-x ^ 2)).div |
| 83 | ((hasDerivAt_id t).const_mul 4) (by positivity : (4 : ℝ) * t ≠ 0)).exp |
| 84 | have h := hn.mul he |
| 85 | convert! h using 1 |
| 86 | simp only [realHeatKernel, id_eq, mul_one, zero_mul, zero_sub, Pi.div_apply, |
| 87 | Pi.inv_apply] |
| 88 | field_simp |
| 89 | rw [Real.sq_sqrt (by positivity : 0 ≤ 4 * t * Real.pi)] |
| 90 | ring |
| 91 | |
| 92 | theorem realHeatKernel_properties {t : ℝ} (ht : 0 < t) : |
| 93 | Integrable (realHeatKernel t) ∧ |
| 94 | (∫ x, realHeatKernel t x) = 1 ∧ |
| 95 | (∀ x, 0 < realHeatKernel t x) ∧ |
| 96 | (∀ x, HasDerivAt (fun s ↦ realHeatKernel s x) |
| 97 | (deriv (deriv (realHeatKernel t)) x) t) := by |
| 98 | refine ⟨integrable_realHeatKernel ht, integral_realHeatKernel ht, realHeatKernel_pos ht, ?_⟩ |
| 99 | intro x |
| 100 | rw [(hasDerivAt_realHeatKernel_space_twice ht x).deriv] |
| 101 | exact hasDerivAt_realHeatKernel_time ht x |
| 102 | |
| 103 | theorem contDiffOn_realHeatKernel : |
| 104 | ContDiffOn ℝ ∞ (fun p : ℝ × ℝ ↦ realHeatKernel p.1 p.2) |
| 105 | {p : ℝ × ℝ | 0 < p.1} := by |
| 106 | apply ContDiffOn.mul |
| 107 | · apply ContDiffOn.inv |
| 108 | · apply ContDiffOn.sqrt |
| 109 | · fun_prop |
| 110 | · intro p hp |
| 111 | change 0 < p.1 at hp |
| 112 | positivity |
| 113 | · intro p hp |
| 114 | change 0 < p.1 at hp |
| 115 | exact (Real.sqrt_pos.mpr (by positivity)).ne' |
| 116 | · apply ContDiffOn.exp |
| 117 | apply ContDiffOn.div |
| 118 | · fun_prop |
| 119 | · fun_prop |
| 120 | · intro p hp |
| 121 | change 0 < p.1 at hp |
| 122 | positivity |
| 123 | |
| 124 | /-- The averaging operator is integration against the explicit translated |
| 125 | heat kernel, with its normalization and variance constructed above. -/ |
| 126 | theorem gaussianAverage_eq_integral_realHeatKernel {f : ℝ → ℝ} |
| 127 | (hf : Continuous f) {t : ℝ} (ht : 0 < t) (x : ℝ) : |
| 128 | gaussianAverage f t x = ∫ y, realHeatKernel t (y - x) * f y := by |
| 129 | let v : ℝ≥0 := ⟨2 * t, by positivity⟩ |
| 130 | have hv : v ≠ 0 := by |
| 131 | apply ne_of_gt |
| 132 | change 0 < 2 * t |
| 133 | positivity |
| 134 | have hmap : (gaussianReal 0 1).map (fun z ↦ x + Real.sqrt (2 * t) * z) = |
| 135 | gaussianReal x v := by |
| 136 | change (gaussianReal 0 1).map ((fun y ↦ x + y) ∘ |
| 137 | (fun z ↦ Real.sqrt (2 * t) * z)) = gaussianReal x v |
| 138 | rw [← Measure.map_map (by fun_prop) (by fun_prop), gaussianReal_map_const_mul, |
| 139 | gaussianReal_map_const_add] |
| 140 | simp only [mul_zero, zero_add, mul_one] |
| 141 | congr 1 |
| 142 | apply Subtype.ext |
| 143 | exact Real.sq_sqrt (by positivity) |
| 144 | calc |
| 145 | gaussianAverage f t x = ∫ y, f y ∂gaussianReal x v := by |
| 146 | rw [← hmap, integral_map (by fun_prop) hf.aestronglyMeasurable] |
| 147 | rfl |
| 148 | _ = ∫ y, gaussianPDFReal x v y * f y := |
| 149 | integral_gaussianReal_eq_integral_smul hv |
| 150 | _ = ∫ y, realHeatKernel t (y - x) * f y := by |
| 151 | apply integral_congr_ae |
| 152 | filter_upwards [] with y |
| 153 | congr 1 |
| 154 | change (Real.sqrt (2 * Real.pi * (2 * t)))⁻¹ * |
| 155 | Real.exp (-(y - x) ^ 2 / (2 * (2 * t))) = |
| 156 | (Real.sqrt (4 * Real.pi * t))⁻¹ * Real.exp (-(y - x) ^ 2 / (4 * t)) |
| 157 | congr 3 <;> ring |
| 158 | |
| 159 | theorem integrable_pow_mul_realHeatKernel {t : ℝ} (ht : 0 < t) (m : ℕ) : |
| 160 | Integrable (fun x ↦ x ^ m * realHeatKernel t x) := by |
| 161 | have h := (integrable_rpow_mul_exp_neg_mul_sq |
| 162 | (by positivity : 0 < (4 * t)⁻¹) (s := (m : ℝ)) |
| 163 | (lt_of_lt_of_le (by norm_num) (Nat.cast_nonneg m))).const_mul |
| 164 | (Real.sqrt (4 * Real.pi * t))⁻¹ |
| 165 | simp only [Real.rpow_natCast] at h |
| 166 | convert! h using 1 |
| 167 | ext x |
| 168 | simp only [realHeatKernel] |
| 169 | rw [show -x ^ 2 / (4 * t) = -(4 * t)⁻¹ * x ^ 2 by ring] |
| 170 | ring |
| 171 | |
| 172 | theorem integral_abs_mul_realHeatKernel_le {t : ℝ} (ht : 0 < t) : |
| 173 | (∫ x, |x| * realHeatKernel t x) ≤ Real.sqrt (2 * t) := by |
| 174 | have hf : LipschitzWith 1 (fun x : ℝ ↦ |x|) := by |
| 175 | simpa only [← Real.norm_eq_abs] using! |
| 176 | (lipschitzWith_one_norm : LipschitzWith 1 (norm : ℝ → ℝ)) |
| 177 | have h := abs_gaussianAverage_sub_le hf t 0 |
| 178 | rw [gaussianAverage_eq_integral_realHeatKernel hf.continuous ht 0] at h |
| 179 | simp only [sub_zero, abs_zero, NNReal.coe_one, one_mul] at h |
| 180 | have heq : (∫ x, |x| * realHeatKernel t x) = ∫ x, realHeatKernel t x * |x| := by |
| 181 | congr 1 |
| 182 | ext x |
| 183 | ring |
| 184 | rw [heq] |
| 185 | exact (le_abs_self _).trans h |
| 186 | |
| 187 | theorem integral_sq_mul_realHeatKernel {t : ℝ} (ht : 0 < t) : |
| 188 | (∫ x, x ^ 2 * realHeatKernel t x) = 2 * t := by |
| 189 | have h := gaussianAverage_eq_integral_realHeatKernel |
| 190 | (f := fun x : ℝ ↦ x ^ 2) (by fun_prop) ht 0 |
| 191 | simp only [gaussianAverage, zero_add, sub_zero, mul_pow, integral_const_mul, |
| 192 | integral_sq_standardGaussian, mul_one, Real.sq_sqrt (by positivity : 0 ≤ 2 * t)] at h |
| 193 | rw [h] |
| 194 | congr 1 |
| 195 | ext x |
| 196 | ring |
| 197 | |
| 198 | theorem integrable_deriv_realHeatKernel {t : ℝ} (ht : 0 < t) : |
| 199 | Integrable (deriv (realHeatKernel t)) := by |
| 200 | rw [deriv_realHeatKernel_space ht] |
| 201 | convert! (integrable_pow_mul_realHeatKernel ht 1).const_mul (-1 / (2 * t)) using 1 |
| 202 | ext x |
| 203 | simp only [pow_one] |
| 204 | ring |
| 205 | |
| 206 | theorem integral_abs_deriv_realHeatKernel_le {t : ℝ} (ht : 0 < t) : |
| 207 | (∫ x, |deriv (realHeatKernel t) x|) ≤ (Real.sqrt (2 * t))⁻¹ := by |
| 208 | have heq : (fun x ↦ |deriv (realHeatKernel t) x|) = |
| 209 | fun x ↦ (2 * t)⁻¹ * (|x| * realHeatKernel t x) := by |
| 210 | funext x |
| 211 | rw [deriv_realHeatKernel_space ht] |
| 212 | simp only [abs_mul, abs_div, abs_neg, abs_of_pos (by positivity : 0 < 2 * t), |
| 213 | abs_of_pos (realHeatKernel_pos ht x)] |
| 214 | ring |
| 215 | rw [heq, integral_const_mul] |
| 216 | calc |
| 217 | (2 * t)⁻¹ * (∫ x, |x| * realHeatKernel t x) ≤ (2 * t)⁻¹ * Real.sqrt (2 * t) := |
| 218 | mul_le_mul_of_nonneg_left (integral_abs_mul_realHeatKernel_le ht) (by positivity) |
| 219 | _ = (Real.sqrt (2 * t))⁻¹ := by |
| 220 | have hs := Real.sq_sqrt (by positivity : 0 ≤ 2 * t) |
| 221 | have hp : 0 < Real.sqrt (2 * t) := by positivity |
| 222 | field_simp |
| 223 | nlinarith |
| 224 | |
| 225 | theorem integrable_deriv_realHeatKernel_twice {t : ℝ} (ht : 0 < t) : |
| 226 | Integrable (deriv (deriv (realHeatKernel t))) := by |
| 227 | have h := ((integrable_pow_mul_realHeatKernel ht 2).div_const (4 * t ^ 2)).sub |
| 228 | ((integrable_realHeatKernel ht).div_const (2 * t)) |
| 229 | convert! h using 1 |
| 230 | ext x |
| 231 | rw [(hasDerivAt_realHeatKernel_space_twice ht x).deriv] |
| 232 | simp only [Pi.sub_apply] |
| 233 | ring |
| 234 | |
| 235 | theorem integral_abs_deriv_realHeatKernel_twice_le {t : ℝ} (ht : 0 < t) : |
| 236 | (∫ x, |deriv (deriv (realHeatKernel t)) x|) ≤ t⁻¹ := by |
| 237 | have hmajor := ((integrable_pow_mul_realHeatKernel ht 2).div_const (4 * t ^ 2)).add |
| 238 | ((integrable_realHeatKernel ht).div_const (2 * t)) |
| 239 | have hbound : ∀ x, |deriv (deriv (realHeatKernel t)) x| ≤ |
| 240 | x ^ 2 * realHeatKernel t x / (4 * t ^ 2) + realHeatKernel t x / (2 * t) := by |
| 241 | intro x |
| 242 | rw [(hasDerivAt_realHeatKernel_space_twice ht x).deriv, sub_mul] |
| 243 | have h := abs_sub_le (x ^ 2 / (4 * t ^ 2) * realHeatKernel t x) 0 |
| 244 | (1 / (2 * t) * realHeatKernel t x) |
| 245 | have hk := (realHeatKernel_pos ht x).le |
| 246 | simp only [sub_zero, zero_sub, abs_neg] at h |
| 247 | rw [abs_of_nonneg (show 0 ≤ x ^ 2 / (4 * t ^ 2) * realHeatKernel t x |
| 248 | from mul_nonneg (by positivity) hk), |
| 249 | abs_of_nonneg (show 0 ≤ 1 / (2 * t) * realHeatKernel t x |
| 250 | from mul_nonneg (by positivity) hk)] at h |
| 251 | simpa only [div_mul_eq_mul_div, one_mul] using h |
| 252 | have hi := integral_mono (integrable_deriv_realHeatKernel_twice ht).abs hmajor hbound |
| 253 | simp only [Pi.add_apply, integral_add |
| 254 | ((integrable_pow_mul_realHeatKernel ht 2).div_const (4 * t ^ 2)) |
| 255 | ((integrable_realHeatKernel ht).div_const (2 * t)), |
| 256 | integral_div, integral_sq_mul_realHeatKernel ht, integral_realHeatKernel ht] at hi |
| 257 | convert! hi using 1 |
| 258 | field_simp |
| 259 | ring |
| 260 | |
| 261 | end Poincare.Analysis.Heat |