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.Analysis.Calculus.Deriv.MeanValue |
| 2 | import Mathlib.Analysis.SpecialFunctions.ExpDeriv |
| 3 | import Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus |
| 4 | import Mathlib.Tactic.FieldSimp |
| 5 | import Mathlib.Tactic.Linarith |
| 6 | import Mathlib.Tactic.Ring |
| 7 | |
| 8 | /-! |
| 9 | # Scalar differential inequalities |
| 10 | |
| 11 | Integrating factors turn a scalar differential inequality into an endpoint |
| 12 | comparison without requiring the scalar function to be positive. Applied to |
| 13 | scalar curvature along a spacetime path, these estimates supply the real-analysis |
| 14 | step of the integrated Harnack inequality, including the elapsed-time factors. |
| 15 | The coefficient need only be integrable and continuous in the interior; its |
| 16 | values at the endpoints need not agree with its one-sided limits. |
| 17 | |
| 18 | The geometric application is Morgan--Tian, *Ricci Flow and the Poincare |
| 19 | Conjecture*, Theorem 4.40, p. 82, using Theorem 4.37, p. 81. These elementary |
| 20 | scalar lemmas are not separately numbered in that source. |
| 21 | -/ |
| 22 | |
| 23 | set_option autoImplicit false |
| 24 | |
| 25 | open Set MeasureTheory |
| 26 | open scoped intervalIntegral |
| 27 | |
| 28 | namespace Poincare.ODE |
| 29 | |
| 30 | /-- An integrating factor gives a lower bound even when `f` vanishes or is negative. -/ |
| 31 | theorem mul_exp_neg_integral_le_of_deriv_add_mul_nonneg |
| 32 | {a b : ℝ} (hab : a ≤ b) {f f' q : ℝ → ℝ} |
| 33 | (hf : ContinuousOn f (Icc a b)) (hq : ContinuousOn q (Ioo a b)) |
| 34 | (hqInt : IntervalIntegrable q volume a b) |
| 35 | (hf' : ∀ t ∈ Ioo a b, HasDerivAt f (f' t) t) |
| 36 | (hineq : ∀ t ∈ Ioo a b, 0 ≤ f' t + q t * f t) : |
| 37 | f a * Real.exp (-(∫ t in a..b, q t)) ≤ f b := by |
| 38 | let Q : ℝ → ℝ := fun t ↦ ∫ s in a..t, q s |
| 39 | have hQ : ContinuousOn Q (Icc a b) := by |
| 40 | simpa only [Q, uIcc_of_le hab] using |
| 41 | (intervalIntegral.continuousOn_primitive_interval' hqInt left_mem_uIcc) |
| 42 | have hQ' (t : ℝ) (ht : t ∈ Ioo a b) : HasDerivAt Q (q t) t := by |
| 43 | apply intervalIntegral.integral_hasDerivAt_right |
| 44 | · exact hqInt.mono_set (uIcc_subset_uIcc_left (by |
| 45 | simpa only [uIcc_of_le hab] using Ioo_subset_Icc_self ht)) |
| 46 | · exact ContinuousOn.stronglyMeasurableAtFilter isOpen_Ioo hq t ht |
| 47 | · exact hq.continuousAt (isOpen_Ioo.mem_nhds ht) |
| 48 | have hprod (t : ℝ) (ht : t ∈ Ioo a b) : |
| 49 | HasDerivAt (fun s ↦ f s * Real.exp (Q s)) |
| 50 | ((f' t + q t * f t) * Real.exp (Q t)) t := by |
| 51 | convert! (hf' t ht).mul (hQ' t ht).exp using 1 |
| 52 | ring |
| 53 | have hmono : MonotoneOn (fun t ↦ f t * Real.exp (Q t)) (Icc a b) := by |
| 54 | apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc a b) |
| 55 | (hf.mul (Real.continuous_exp.comp_continuousOn hQ)) |
| 56 | · intro t ht |
| 57 | exact (hprod t (by simpa only [interior_Icc] using ht)).hasDerivWithinAt |
| 58 | · intro t ht |
| 59 | exact mul_nonneg (hineq t (by simpa only [interior_Icc] using ht)) |
| 60 | (Real.exp_pos _).le |
| 61 | have hend := hmono (left_mem_Icc.mpr hab) (right_mem_Icc.mpr hab) hab |
| 62 | change f a * Real.exp (Q a) ≤ f b * Real.exp (Q b) at hend |
| 63 | have hstart : Q a = 0 := by simp [Q] |
| 64 | rw [hstart, Real.exp_zero, mul_one] at hend |
| 65 | calc |
| 66 | f a * Real.exp (-Q b) ≤ (f b * Real.exp (Q b)) * Real.exp (-Q b) := |
| 67 | mul_le_mul_of_nonneg_right hend (Real.exp_pos _).le |
| 68 | _ = f b := by rw [mul_assoc, ← Real.exp_add]; simp |
| 69 | |
| 70 | /-- The finite-start comparison retains the elapsed-time factors at both endpoints. -/ |
| 71 | theorem finite_harnack_of_deriv_inequality |
| 72 | {T a b : ℝ} (hTa : T < a) (hab : a ≤ b) {f f' q : ℝ → ℝ} |
| 73 | (hf : ContinuousOn f (Icc a b)) (hq : ContinuousOn q (Ioo a b)) |
| 74 | (hqInt : IntervalIntegrable q volume a b) |
| 75 | (hf' : ∀ t ∈ Ioo a b, HasDerivAt f (f' t) t) |
| 76 | (hineq : ∀ t ∈ Ioo a b, 0 ≤ f' t + f t / (t - T) + q t * f t) : |
| 77 | f a * (a - T) * Real.exp (-(∫ t in a..b, q t)) ≤ f b * (b - T) := by |
| 78 | apply mul_exp_neg_integral_le_of_deriv_add_mul_nonneg hab |
| 79 | (hf.mul (continuousOn_id.sub continuousOn_const)) hq hqInt |
| 80 | (f' := fun t ↦ f' t * (t - T) + f t) |
| 81 | · intro t ht |
| 82 | convert! (hf' t ht).mul ((hasDerivAt_id t).sub_const T) using 1 |
| 83 | simp only [id_eq, mul_one] |
| 84 | · intro t ht |
| 85 | have htT : 0 < t - T := sub_pos.mpr (hTa.trans ht.1) |
| 86 | have h := mul_nonneg (hineq t ht) htT.le |
| 87 | have heq : |
| 88 | (f' t + f t / (t - T) + q t * f t) * (t - T) = |
| 89 | f' t * (t - T) + f t + q t * (f t * (t - T)) := by |
| 90 | field_simp [htT.ne'] |
| 91 | rwa [heq] at h |
| 92 | |
| 93 | /-- The path-energy form of the comparison, with no elapsed-time term. -/ |
| 94 | theorem harnack_of_energy_inequality |
| 95 | {a b : ℝ} (hab : a ≤ b) {f f' speedSq : ℝ → ℝ} |
| 96 | (hf : ContinuousOn f (Icc a b)) (hSpeed : ContinuousOn speedSq (Ioo a b)) |
| 97 | (hSpeedInt : IntervalIntegrable speedSq volume a b) |
| 98 | (hf' : ∀ t ∈ Ioo a b, HasDerivAt f (f' t) t) |
| 99 | (hineq : ∀ t ∈ Ioo a b, 0 ≤ f' t + speedSq t / 2 * f t) : |
| 100 | f a * Real.exp (-(∫ t in a..b, speedSq t) / 2) ≤ f b := by |
| 101 | simpa only [intervalIntegral.integral_div, neg_div] using |
| 102 | mul_exp_neg_integral_le_of_deriv_add_mul_nonneg hab hf (hSpeed.div_const 2) |
| 103 | (hSpeedInt.div_const 2) hf' hineq |
| 104 | |
| 105 | /-- The finite-start path-energy comparison is valid at zero scalar curvature. -/ |
| 106 | theorem finite_harnack_of_energy_inequality |
| 107 | {T a b : ℝ} (hTa : T < a) (hab : a ≤ b) {f f' speedSq : ℝ → ℝ} |
| 108 | (hf : ContinuousOn f (Icc a b)) (hSpeed : ContinuousOn speedSq (Ioo a b)) |
| 109 | (hSpeedInt : IntervalIntegrable speedSq volume a b) |
| 110 | (hf' : ∀ t ∈ Ioo a b, HasDerivAt f (f' t) t) |
| 111 | (hineq : ∀ t ∈ Ioo a b, |
| 112 | 0 ≤ f' t + f t / (t - T) + speedSq t / 2 * f t) : |
| 113 | f a * (a - T) * Real.exp (-(∫ t in a..b, speedSq t) / 2) ≤ f b * (b - T) := by |
| 114 | simpa only [intervalIntegral.integral_div, neg_div] using |
| 115 | finite_harnack_of_deriv_inequality hTa hab hf (hSpeed.div_const 2) |
| 116 | (hSpeedInt.div_const 2) hf' hineq |
| 117 | |
| 118 | end Poincare.ODE |