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.Geometry.CurveShortening.Comparison.Geometry |
| 2 | import Mathlib.Analysis.Calculus.MeanValue |
| 3 | |
| 4 | /-! |
| 5 | # Initial endpoint transfer for the annular forward estimate |
| 6 | |
| 7 | Continuous Dini comparison on interior intervals, followed by continuity |
| 8 | at the initial endpoint, supplies its exact forward bound. This is the |
| 9 | endpoint passage for MT2007 Lemma 19.15, pp. 447-449; it does not require |
| 10 | an attained smooth annulus at the initial time. |
| 11 | |
| 12 | Morgan--Tian context: Lemma 19.15 and its annular area-to-energy construction, printed pp. |
| 13 | 447-449. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | |
| 18 | open Set Filter |
| 19 | open scoped Topology |
| 20 | |
| 21 | namespace PoincareMT |
| 22 | |
| 23 | /-- The frozen upper forward bound implies the frequent strict slope bound used by |
| 24 | continuous Dini comparison. Source: Morgan--Tian (2007), Lemma 19.15 and Corollary 19.16, |
| 25 | pp. 447-449; project derivation |
| 26 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 27 | theorem m64AnnulusForwardDerivativeBound.frequently_slope_lt |
| 28 | {f : ℝ → ℝ} {q t R : ℝ} |
| 29 | (hf : AnnulusForwardDerivativeBound f q t) (hR : q < R) : |
| 30 | ∃ᶠ z in 𝓝[>] t, slope f t z < R := by |
| 31 | obtain ⟨delta, hdelta, hbound⟩ := |
| 32 | mem_nhdsGT_iff_exists_Ioo_subset.mp (hf ((R - q) / 2) (by linarith)) |
| 33 | have hsmall : ∀ᶠ z in 𝓝[>] t, z ∈ Ioo t (t + delta) := |
| 34 | Ioo_mem_nhdsGT (lt_add_of_pos_right t hdelta) |
| 35 | apply (hsmall.mono ?_).frequently |
| 36 | intro z hz |
| 37 | have h := hbound (show z - t ∈ Ioo (0 : ℝ) delta by |
| 38 | constructor <;> linarith [hz.1, hz.2]) |
| 39 | change (f (t + (z - t)) - f t) / (z - t) ≤ q + (R - q) / 2 at h |
| 40 | rw [show t + (z - t) = z by ring] at h |
| 41 | rw [slope_def_field] |
| 42 | linarith |
| 43 | |
| 44 | /-- A continuous function whose upper forward bounds are at most a constant lies below the |
| 45 | corresponding affine comparison function. Source: Morgan--Tian (2007), Lemma 19.15 and |
| 46 | Corollary 19.16, pp. 447-449; project derivation |
| 47 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 48 | theorem m64AnnulusForwardDerivativeBound.linear_comparison |
| 49 | {f q : ℝ → ℝ} {s t C : ℝ} (hst : s ≤ t) |
| 50 | (hf : ContinuousOn f (Icc s t)) |
| 51 | (hforward : ∀ x ∈ Ico s t, AnnulusForwardDerivativeBound f (q x) x) |
| 52 | (hq : ∀ x ∈ Ico s t, q x ≤ C) : |
| 53 | f t ≤ f s + C * (t - s) := by |
| 54 | have hderiv (x : ℝ) : HasDerivAt (fun y => f s + C * (y - s)) C x := by |
| 55 | simpa using (((hasDerivAt_id x).sub_const s).const_mul C).const_add (f s) |
| 56 | apply image_le_of_liminf_slope_right_le_deriv_boundary hf |
| 57 | (B := fun x => f s + C * (x - s)) (B' := fun _ => C) |
| 58 | (by simp) (by fun_prop) (fun x _ => (hderiv x).hasDerivWithinAt) ?_ ⟨hst, le_rfl⟩ |
| 59 | intro x hx R hR |
| 60 | exact m64AnnulusForwardDerivativeBound.frequently_slope_lt |
| 61 | (hforward x hx) ((hq x hx).trans_lt hR) |
| 62 | |
| 63 | /-- Interior upper forward bounds extend to the included initial time when the function and |
| 64 | rate are continuous there. Source: Morgan--Tian (2007), Lemma 19.15 and Corollary 19.16, pp. |
| 65 | 447-449; project derivation |
| 66 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 67 | theorem m64AnnulusForwardDerivativeBound.at_initial |
| 68 | {f q : ℝ → ℝ} {a b : ℝ} (hab : a < b) |
| 69 | (hf : ContinuousOn f (Icc a b)) |
| 70 | (hq : ContinuousWithinAt q (Icc a b) a) |
| 71 | (hforward : ∀ t ∈ Ioo a b, AnnulusForwardDerivativeBound f (q t) t) : |
| 72 | AnnulusForwardDerivativeBound f (q a) a := by |
| 73 | intro eta heta |
| 74 | have hrate : ∀ᶠ x in 𝓝[Icc a b] a, q x < q a + eta := |
| 75 | hq (Iio_mem_nhds (by linarith)) |
| 76 | have hright : ∀ᶠ x in 𝓝[>] a, q x < q a + eta := |
| 77 | nhdsWithin_le_of_mem (Icc_mem_nhdsGT_of_mem ⟨le_rfl, hab⟩) hrate |
| 78 | obtain ⟨c, hc, hqc⟩ := (mem_nhdsGT_iff_exists_mem_Ioc_Ioo_subset hab).mp hright |
| 79 | have hbound (z : ℝ) (hz : z ∈ Ioo a c) : |
| 80 | f z ≤ f a + (q a + eta) * (z - a) := by |
| 81 | have hzab : z < b := hz.2.trans_le hc.2 |
| 82 | have hsub : Ioo a z ⊆ Icc a b := fun x hx => |
| 83 | ⟨hx.1.le, hx.2.le.trans hzab.le⟩ |
| 84 | have haclosure : a ∈ closure (Ioo a z) := by |
| 85 | rw [closure_Ioo hz.1.ne] |
| 86 | exact ⟨le_rfl, hz.1.le⟩ |
| 87 | apply ContinuousWithinAt.closure_le haclosure continuousWithinAt_const |
| 88 | (((hf a ⟨le_rfl, hab.le⟩).mono hsub).add |
| 89 | (continuousWithinAt_const.mul |
| 90 | (continuousWithinAt_const.sub continuousWithinAt_id))) |
| 91 | intro s hs |
| 92 | apply m64AnnulusForwardDerivativeBound.linear_comparison hs.2.le |
| 93 | (hf.mono (Icc_subset_Icc hs.1.le hzab.le)) |
| 94 | · intro x hx |
| 95 | exact hforward x ⟨hs.1.trans_le hx.1, hx.2.trans hzab⟩ |
| 96 | · intro x hx |
| 97 | exact (hqc ⟨hs.1.trans_le hx.1, hx.2.trans hz.2⟩).le |
| 98 | have hsmall : ∀ᶠ h : ℝ in 𝓝[>] 0, h ∈ Ioo 0 (c - a) := |
| 99 | Ioo_mem_nhdsGT (sub_pos.mpr hc.1) |
| 100 | filter_upwards [hsmall] with h hh |
| 101 | have h := hbound (a + h) (by constructor <;> linarith [hh.1, hh.2]) |
| 102 | apply (div_le_iff₀ hh.1).mpr |
| 103 | nlinarith |
| 104 | |
| 105 | /-- Continuous rates extend the entire interior forward conclusion to the half-closed |
| 106 | interval, with no endpoint regularity premise. Source: Morgan--Tian (2007), Lemma 19.15 and |
| 107 | Corollary 19.16, pp. 447-449; project derivation |
| 108 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 109 | theorem m64AnnulusForwardDerivativeBound.on_Ico_of_on_Ioo |
| 110 | {f q : ℝ → ℝ} {a b : ℝ} |
| 111 | (hf : ContinuousOn f (Icc a b)) (hq : ContinuousOn q (Icc a b)) |
| 112 | (hforward : ∀ t ∈ Ioo a b, AnnulusForwardDerivativeBound f (q t) t) : |
| 113 | ∀ t ∈ Ico a b, AnnulusForwardDerivativeBound f (q t) t := by |
| 114 | intro t ht |
| 115 | rcases ht.1.eq_or_lt with hta | hta |
| 116 | · subst t |
| 117 | exact m64AnnulusForwardDerivativeBound.at_initial ht.2 hf |
| 118 | (hq a ⟨le_rfl, ht.2.le⟩) hforward |
| 119 | · exact hforward t ⟨hta, ht.2⟩ |
| 120 | |
| 121 | end PoincareMT |