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.GaussianSemigroup |
| 2 | import Mathlib.Analysis.Normed.Operator.Prod |
| 3 | |
| 4 | /-! |
| 5 | # Joint regularity of Gaussian evolution |
| 6 | |
| 7 | Polynomially weighted Gaussian averages can be differentiated in their |
| 8 | translation and scale parameters using finite Gaussian moments. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open MeasureTheory ProbabilityTheory Filter |
| 14 | open scoped Topology NNReal ContDiff |
| 15 | |
| 16 | namespace Poincare.Analysis.Heat |
| 17 | |
| 18 | private noncomputable def weightedAverage (m : ℕ) (f : ℝ → ℝ) (p : ℝ × ℝ) : ℝ := |
| 19 | ∫ z, z ^ m * f (p.2 + p.1 * z) ∂gaussianReal 0 1 |
| 20 | |
| 21 | private theorem integrable_abs_pow (m : ℕ) : |
| 22 | Integrable (fun z : ℝ ↦ |z| ^ m) (gaussianReal 0 1) := by |
| 23 | by_cases hm : m = 0 |
| 24 | · simp [hm] |
| 25 | · simpa only [id_eq, Real.norm_eq_abs] using |
| 26 | (memLp_id_gaussianReal (μ := 0) (v := 1) m).integrable_norm_pow (by positivity) |
| 27 | |
| 28 | private theorem integrable_weighted_of_lipschitz {L : ℝ≥0} {f : ℝ → ℝ} |
| 29 | (hf : LipschitzWith L f) (m : ℕ) (p : ℝ × ℝ) : |
| 30 | Integrable (fun z ↦ z ^ m * f (p.2 + p.1 * z)) (gaussianReal 0 1) := by |
| 31 | apply (((integrable_abs_pow m).mul_const |f p.2|).add |
| 32 | ((integrable_abs_pow (m + 1)).const_mul ((L : ℝ) * |p.1|))).mono' |
| 33 | (continuous_id.pow m |>.mul (hf.continuous.comp (by fun_prop))).aestronglyMeasurable |
| 34 | filter_upwards [] with z |
| 35 | have h := hf.dist_le_mul (p.2 + p.1 * z) p.2 |
| 36 | simp only [Real.dist_eq, add_sub_cancel_left, abs_mul] at h |
| 37 | have htri := abs_add_le (f p.2) (f (p.2 + p.1 * z) - f p.2) |
| 38 | simp only [add_sub_cancel] at htri |
| 39 | simp only [Pi.add_apply, Real.norm_eq_abs, Pi.mul_apply, Pi.pow_apply, |
| 40 | Function.comp_apply, id_eq, abs_mul, abs_pow] |
| 41 | calc |
| 42 | _ ≤ |z| ^ m * (|f p.2| + (L : ℝ) * (|p.1| * |z|)) := |
| 43 | mul_le_mul_of_nonneg_left (htri.trans (add_le_add_right h _)) (by positivity) |
| 44 | _ = _ := by rw [pow_succ]; ring |
| 45 | |
| 46 | private theorem integrable_weighted_deriv {L : ℝ≥0} {f : ℝ → ℝ} |
| 47 | (hf : LipschitzWith L f) (m : ℕ) (p : ℝ × ℝ) : |
| 48 | Integrable (fun z ↦ z ^ m * deriv f (p.2 + p.1 * z)) (gaussianReal 0 1) := by |
| 49 | apply ((integrable_abs_pow m).mul_const (L : ℝ)).mono' |
| 50 | ((measurable_id.pow_const m).mul ((measurable_deriv f).comp (by fun_prop))).aestronglyMeasurable |
| 51 | filter_upwards [] with z |
| 52 | simp only [Real.norm_eq_abs, Pi.mul_apply, Function.comp_apply, id_eq, abs_mul, abs_pow] |
| 53 | exact mul_le_mul_of_nonneg_left (norm_deriv_le_of_lipschitz hf) (by positivity) |
| 54 | |
| 55 | private theorem hasFDerivAt_weightedAverage {L : ℝ≥0} {f : ℝ → ℝ} |
| 56 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) (m : ℕ) (p : ℝ × ℝ) : |
| 57 | HasFDerivAt (weightedAverage m f) |
| 58 | (weightedAverage (m + 1) (deriv f) p • ContinuousLinearMap.fst ℝ ℝ ℝ + |
| 59 | weightedAverage m (deriv f) p • ContinuousLinearMap.snd ℝ ℝ ℝ) p := by |
| 60 | let F' (q : ℝ × ℝ) (z : ℝ) : (ℝ × ℝ) →L[ℝ] ℝ := |
| 61 | (z ^ (m + 1) * deriv f (q.2 + q.1 * z)) • ContinuousLinearMap.fst ℝ ℝ ℝ + |
| 62 | (z ^ m * deriv f (q.2 + q.1 * z)) • ContinuousLinearMap.snd ℝ ℝ ℝ |
| 63 | have hi (q : ℝ × ℝ) : Integrable (F' q) (gaussianReal 0 1) := by |
| 64 | exact ((integrable_weighted_deriv hf (m + 1) q).smul_const |
| 65 | (ContinuousLinearMap.fst ℝ ℝ ℝ)).add |
| 66 | ((integrable_weighted_deriv hf m q).smul_const (ContinuousLinearMap.snd ℝ ℝ ℝ)) |
| 67 | have h := hasFDerivAt_integral_of_dominated_of_fderiv_le |
| 68 | (μ := gaussianReal 0 1) (s := Set.univ) |
| 69 | (F := fun q z ↦ z ^ m * f (q.2 + q.1 * z)) (F' := F') (x₀ := p) |
| 70 | (bound := fun z : ℝ ↦ |z| ^ (m + 1) * (L : ℝ) + |z| ^ m * (L : ℝ)) |
| 71 | univ_mem ?_ (integrable_weighted_of_lipschitz hf m p) (hi p).aestronglyMeasurable |
| 72 | ?_ ?_ ?_ |
| 73 | · convert! h using 1 |
| 74 | simp only [F', integral_add |
| 75 | ((integrable_weighted_deriv hf (m + 1) p).smul_const _) |
| 76 | ((integrable_weighted_deriv hf m p).smul_const _), integral_smul_const, |
| 77 | weightedAverage] |
| 78 | · exact Eventually.of_forall fun q ↦ (integrable_weighted_of_lipschitz hf m q).aestronglyMeasurable |
| 79 | · filter_upwards [] with z |
| 80 | intro q _ |
| 81 | dsimp only [F'] |
| 82 | apply (norm_add_le _ _).trans |
| 83 | simp only [norm_smul, Real.norm_eq_abs, abs_mul, abs_pow, |
| 84 | ContinuousLinearMap.norm_fst, ContinuousLinearMap.norm_snd, mul_one] |
| 85 | exact add_le_add |
| 86 | (mul_le_mul_of_nonneg_left (norm_deriv_le_of_lipschitz hf) (by positivity)) |
| 87 | (mul_le_mul_of_nonneg_left (norm_deriv_le_of_lipschitz hf) (by positivity)) |
| 88 | · exact ((integrable_abs_pow (m + 1)).mul_const _).add |
| 89 | ((integrable_abs_pow m).mul_const _) |
| 90 | · filter_upwards [] with z |
| 91 | intro q _ |
| 92 | have hd := (hdf _).hasDerivAt.comp_hasFDerivAt q |
| 93 | ((hasFDerivAt_snd (𝕜 := ℝ)).add ((hasFDerivAt_fst (𝕜 := ℝ)).mul_const z)) |
| 94 | convert! hd.const_mul (z ^ m) using 1 |
| 95 | apply ContinuousLinearMap.ext |
| 96 | intro v |
| 97 | change z ^ (m + 1) * deriv f (q.2 + q.1 * z) * v.1 + |
| 98 | z ^ m * deriv f (q.2 + q.1 * z) * v.2 = |
| 99 | z ^ m * (deriv f (q.2 + q.1 * z) * (v.2 + z * v.1)) |
| 100 | rw [pow_succ] |
| 101 | ring |
| 102 | |
| 103 | private theorem contDiff_weightedAverage (m : ℕ) (f : ℝ → ℝ) |
| 104 | (hD : ∀ k : ℕ, Differentiable ℝ (deriv^[k] f)) |
| 105 | (hL : ∀ k : ℕ, ∃ C : ℝ≥0, LipschitzWith C (deriv^[k] f)) : |
| 106 | ContDiff ℝ ∞ (weightedAverage m f) := by |
| 107 | have hn (n : ℕ) : ∀ (m : ℕ) (f : ℝ → ℝ), |
| 108 | (∀ k : ℕ, Differentiable ℝ (deriv^[k] f)) → |
| 109 | (∀ k : ℕ, ∃ C : ℝ≥0, LipschitzWith C (deriv^[k] f)) → |
| 110 | ContDiff ℝ n (weightedAverage m f) := by |
| 111 | induction n with |
| 112 | | zero => |
| 113 | intro m f hD hL |
| 114 | obtain ⟨C, hC⟩ := hL 0 |
| 115 | apply contDiff_zero.mpr |
| 116 | exact Differentiable.continuous |
| 117 | (fun p ↦ (hasFDerivAt_weightedAverage hC (hD 0) m p).differentiableAt) |
| 118 | | succ n ih => |
| 119 | intro m f hD hL |
| 120 | obtain ⟨C, hC⟩ := hL 0 |
| 121 | have hD' : ∀ k : ℕ, Differentiable ℝ (deriv^[k] (deriv f)) := by |
| 122 | intro k |
| 123 | simpa only [Function.iterate_succ_apply] using hD (k + 1) |
| 124 | have hL' : ∀ k : ℕ, ∃ C : ℝ≥0, LipschitzWith C (deriv^[k] (deriv f)) := by |
| 125 | intro k |
| 126 | simpa only [Function.iterate_succ_apply] using hL (k + 1) |
| 127 | rw [Nat.cast_add, Nat.cast_one] |
| 128 | apply contDiff_succ_iff_hasFDerivAt.mpr |
| 129 | refine ⟨fun p ↦ weightedAverage (m + 1) (deriv f) p • ContinuousLinearMap.fst ℝ ℝ ℝ + |
| 130 | weightedAverage m (deriv f) p • ContinuousLinearMap.snd ℝ ℝ ℝ, ?_, ?_⟩ |
| 131 | · exact ((ih (m + 1) (deriv f) hD' hL').smul contDiff_const).add |
| 132 | ((ih m (deriv f) hD' hL').smul contDiff_const) |
| 133 | · exact hasFDerivAt_weightedAverage hC (hD 0) m |
| 134 | exact contDiff_infty.mpr fun n ↦ hn n m f hD hL |
| 135 | |
| 136 | theorem contDiffOn_gaussianAverage {L : ℝ≥0} {f : ℝ → ℝ} |
| 137 | (hf : LipschitzWith L f) (hdf : Differentiable ℝ f) : |
| 138 | ContDiffOn ℝ ∞ (fun p : ℝ × ℝ ↦ gaussianAverage f p.1 p.2) |
| 139 | {p : ℝ × ℝ | 0 < p.1} := by |
| 140 | intro p hp |
| 141 | have hp0 : 0 < p.1 := hp |
| 142 | have hh : 0 < p.1 / 2 := by positivity |
| 143 | have hg : ContDiff ℝ ∞ (weightedAverage 0 (gaussianAverage f (p.1 / 2))) := by |
| 144 | apply contDiff_weightedAverage |
| 145 | · intro k |
| 146 | exact ((contDiff_gaussianAverage hf hdf hh).iterate_deriv k).differentiable (by simp) |
| 147 | · exact fun k ↦ exists_lipschitzWith_iterate_deriv_gaussianAverage k hf hdf hh |
| 148 | have hparam : ContDiffAt ℝ ∞ |
| 149 | (fun q : ℝ × ℝ ↦ (Real.sqrt (2 * (q.1 - p.1 / 2)), q.2)) p := by |
| 150 | apply ContDiffAt.prodMk |
| 151 | · apply ContDiffAt.sqrt |
| 152 | · fun_prop |
| 153 | · nlinarith |
| 154 | · fun_prop |
| 155 | have hc := hg.contDiffAt.comp p hparam |
| 156 | apply ContDiffAt.contDiffWithinAt |
| 157 | apply hc.congr_of_eventuallyEq |
| 158 | have he : ∀ᶠ q : ℝ × ℝ in 𝓝 p, p.1 / 2 < q.1 := |
| 159 | (continuous_fst.tendsto p).eventually (Ioi_mem_nhds (by linarith)) |
| 160 | filter_upwards [he] with q hq |
| 161 | change gaussianAverage f q.1 q.2 = |
| 162 | ∫ z, z ^ 0 * gaussianAverage f (p.1 / 2) |
| 163 | (q.2 + Real.sqrt (2 * (q.1 - p.1 / 2)) * z) ∂gaussianReal 0 1 |
| 164 | simp only [pow_zero, one_mul] |
| 165 | change gaussianAverage f q.1 q.2 = |
| 166 | gaussianAverage (gaussianAverage f (p.1 / 2)) (q.1 - p.1 / 2) q.2 |
| 167 | rw [gaussianAverage_semigroup hf (by linarith) hh.le, sub_add_cancel] |
| 168 | |
| 169 | end Poincare.Analysis.Heat |