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.Integral.IntervalIntegral.FundThmCalculus |
| 2 | import Mathlib.Analysis.SpecialFunctions.ExpDeriv |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Slope |
| 4 | import Mathlib.Tactic.Linarith |
| 5 | import Mathlib.Tactic.Ring |
| 6 | |
| 7 | /-! Elementary differential estimates for the smooth-time width comparison profile. -/ |
| 8 | |
| 9 | open Set Filter MeasureTheory |
| 10 | open scoped Topology intervalIntegral |
| 11 | |
| 12 | namespace PoincareMT |
| 13 | |
| 14 | noncomputable def smoothWidthProfile (r : ℝ → ℝ) (a w s : ℝ) : ℝ := |
| 15 | Real.exp (-(∫ v in a..s, r v / 2)) * |
| 16 | (w - 2 * Real.pi * ∫ v in a..s, Real.exp (∫ x in a..v, r x / 2)) |
| 17 | |
| 18 | theorem smoothWidthProfile_initial (r : ℝ → ℝ) (a w : ℝ) : |
| 19 | smoothWidthProfile r a w a = w := by |
| 20 | simp [smoothWidthProfile] |
| 21 | |
| 22 | theorem smoothWidthProfile_hasDerivWithinAt {r : ℝ → ℝ} {a b w : ℝ} |
| 23 | (hab : a ≤ b) (hr : ContinuousOn r (Icc a b)) : |
| 24 | HasDerivWithinAt (smoothWidthProfile r a w) |
| 25 | (-2 * Real.pi - r a / 2 * w) (Icc a b) a := by |
| 26 | let : Fact (a ∈ Icc a b) := ⟨⟨le_rfl, hab⟩⟩ |
| 27 | have hc : ContinuousOn (fun x => r x / 2) (Icc a b) := hr.div_const 2 |
| 28 | have hi : IntervalIntegrable (fun x => r x / 2) volume a b := |
| 29 | hc.intervalIntegrable_of_Icc hab |
| 30 | have hd : HasDerivWithinAt (fun s => ∫ v in a..s, r v / 2) |
| 31 | (r a / 2) (Icc a b) a := |
| 32 | intervalIntegral.integral_hasDerivWithinAt_right (by simp) |
| 33 | (hc.stronglyMeasurableAtFilter_nhdsWithin measurableSet_Icc a) |
| 34 | (hc a ⟨le_rfl, hab⟩) |
| 35 | have hp : ContinuousOn (fun s => ∫ v in a..s, r v / 2) (Icc a b) := by |
| 36 | simpa [uIcc_of_le hab] using |
| 37 | (intervalIntegral.continuousOn_primitive_interval' hi (left_mem_uIcc : a ∈ uIcc a b)) |
| 38 | have he := Real.continuous_exp.comp_continuousOn hp |
| 39 | have hde : HasDerivWithinAt |
| 40 | (fun s => ∫ v in a..s, Real.exp (∫ x in a..v, r x / 2)) |
| 41 | 1 (Icc a b) a := by |
| 42 | simpa using intervalIntegral.integral_hasDerivWithinAt_right (a := a) (b := a) |
| 43 | (by simp : IntervalIntegrable |
| 44 | (fun v => Real.exp (∫ x in a..v, r x / 2)) volume a a) |
| 45 | (he.stronglyMeasurableAtFilter_nhdsWithin measurableSet_Icc a) |
| 46 | (he a ⟨le_rfl, hab⟩) |
| 47 | have hprofile := hd.neg.exp.mul ((hasDerivWithinAt_const a (Icc a b) w).sub |
| 48 | (hde.const_mul (2 * Real.pi))) |
| 49 | simp only [Pi.neg_apply, Pi.sub_apply, intervalIntegral.integral_same, neg_zero, Real.exp_zero, mul_one, |
| 50 | mul_zero, sub_zero, one_mul, zero_sub] at hprofile |
| 51 | have heq : -(r a / 2) * w + -(2 * Real.pi) = -2 * Real.pi - r a / 2 * w := by ring |
| 52 | rw [heq] at hprofile |
| 53 | exact hprofile |
| 54 | |
| 55 | theorem smoothWidthProfile_forward_bound {r : ℝ → ℝ} {a b w : ℝ} |
| 56 | (hab : a ≤ b) (hr : ContinuousOn r (Icc a b)) |
| 57 | {epsilon : ℝ} (hepsilon : 0 < epsilon) : |
| 58 | ∃ delta : ℝ, 0 < delta ∧ ∀ s ∈ Icc a b, a < s → s < a + delta → |
| 59 | (smoothWidthProfile r a w s - w) / (s - a) ≤ |
| 60 | -2 * Real.pi - r a / 2 * w + epsilon := by |
| 61 | have h := (smoothWidthProfile_hasDerivWithinAt (w := w) hab hr).limsup_slope_le |
| 62 | (lt_add_of_pos_right _ hepsilon) |
| 63 | rcases Metric.mem_nhdsWithin_iff.mp h with ⟨delta, hdelta, hball⟩ |
| 64 | refine ⟨delta, hdelta, ?_⟩ |
| 65 | intro s hs has hsd |
| 66 | have hsball : s ∈ Metric.ball a delta := by |
| 67 | rw [Metric.mem_ball, Real.dist_eq, abs_of_pos (sub_pos.mpr has)] |
| 68 | linarith |
| 69 | have hbound := hball ⟨hsball, hs, by simpa using ne_of_gt has⟩ |
| 70 | change slope (smoothWidthProfile r a w) a s < _ at hbound |
| 71 | rw [slope_def_field, smoothWidthProfile_initial] at hbound |
| 72 | exact hbound.le |
| 73 | |
| 74 | end PoincareMT |