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.MeanValue |
| 2 | import Mathlib.Analysis.Calculus.Deriv.AffineMap |
| 3 | |
| 4 | /-! |
| 5 | Adapted from Mapher `PoincareMT/Proofs/M10/BarrierLipschitz.lean` at |
| 6 | revision `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. |
| 7 | |
| 8 | # First-order upper supports and Lipschitz estimates |
| 9 | |
| 10 | Continuous functions with uniformly bounded first-order upper supports are |
| 11 | Lipschitz on convex sets. The supports can vary independently at every point. |
| 12 | This is the Dini comparison step used with the barriers in Morgan-Tian |
| 13 | Proposition 7.5; it requires no differentiability of the supported function. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | |
| 18 | open Set Filter |
| 19 | open scoped Topology NNReal |
| 20 | |
| 21 | namespace PoincareMT.SurgeryVolume.Measure |
| 22 | |
| 23 | /-- A touching upper support bounds the right slopes of the supported function. -/ |
| 24 | theorem frequently_slope_lt_of_upper_support {f g : ℝ → ℝ} {x d r : ℝ} |
| 25 | (hg : HasDerivAt g d x) (heq : g x = f x) |
| 26 | (hle : ∀ᶠ y in 𝓝 x, f y ≤ g y) (hdr : d < r) : |
| 27 | ∃ᶠ y in 𝓝[>] x, slope f x y < r := by |
| 28 | have hs := hg.hasDerivWithinAt.limsup_slope_le' (s := Ioi x) (lt_irrefl x) hdr |
| 29 | have hnear : ∀ᶠ y in 𝓝[>] x, f y ≤ g y := nhdsWithin_le_nhds hle |
| 30 | apply Filter.Eventually.frequently |
| 31 | filter_upwards [hs, hnear, self_mem_nhdsWithin] with y hys hy hxy |
| 32 | apply lt_of_le_of_lt _ hys |
| 33 | rw [slope_def_field, slope_def_field, heq] |
| 34 | exact div_le_div_of_nonneg_right (sub_le_sub_right hy _) (sub_pos.mpr hxy).le |
| 35 | |
| 36 | set_option backward.isDefEq.respectTransparency false in |
| 37 | /-- First-order upper supports with derivative at most `C` bound endpoint growth. -/ |
| 38 | theorem sub_le_mul_of_upper_supports {f : ℝ → ℝ} {a b C : ℝ} |
| 39 | (hab : a ≤ b) (hf : ContinuousOn f (Icc a b)) |
| 40 | (hsupport : ∀ x ∈ Ico a b, ∃ g : ℝ → ℝ, ∃ d : ℝ, |
| 41 | HasDerivAt g d x ∧ g x = f x ∧ |
| 42 | (∀ᶠ y in 𝓝 x, f y ≤ g y) ∧ d ≤ C) : |
| 43 | f b - f a ≤ C * (b - a) := by |
| 44 | have hcomparison : ∀ x ∈ Icc a b, f x ≤ f a + C * (x - a) := by |
| 45 | apply image_le_of_liminf_slope_right_le_deriv_boundary hf |
| 46 | (B' := fun _ ↦ C) |
| 47 | · simp |
| 48 | · fun_prop |
| 49 | · intro x _ |
| 50 | simpa only [mul_one, id_eq] using |
| 51 | ((((hasDerivAt_id x).sub_const a).const_mul C).const_add (f a)).hasDerivWithinAt |
| 52 | · intro x hx r hr |
| 53 | obtain ⟨g, d, hd, heq, hle, hC⟩ := hsupport x hx |
| 54 | exact frequently_slope_lt_of_upper_support hd heq hle (hC.trans_lt hr) |
| 55 | exact sub_le_iff_le_add.mpr (by simpa only [add_comm] using hcomparison b ⟨hab, le_rfl⟩) |
| 56 | |
| 57 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 58 | |
| 59 | /-- A bounded upper support at every point gives a one-sided segment estimate. -/ |
| 60 | theorem sub_le_norm_of_upper_supports {S : Set E} (hS : Convex ℝ S) |
| 61 | {f : E → ℝ} (hf : ContinuousOn f S) {C : ℝ} |
| 62 | (hsupport : ∀ z ∈ S, ∃ g : E → ℝ, ∃ L : E →L[ℝ] ℝ, |
| 63 | HasFDerivAt g L z ∧ g z = f z ∧ |
| 64 | (∀ᶠ w in 𝓝 z, f w ≤ g w) ∧ ‖L‖ ≤ C) |
| 65 | {x y : E} (hx : x ∈ S) (hy : y ∈ S) : |
| 66 | f y - f x ≤ C * ‖y - x‖ := by |
| 67 | let c : ℝ → E := AffineMap.lineMap x y |
| 68 | have hc : Continuous c := AffineMap.lineMap_continuous |
| 69 | have hcS : MapsTo c (Icc 0 1) S := fun _ ht ↦ hS.lineMap_mem hx hy ht |
| 70 | have hseg := sub_le_mul_of_upper_supports (f := f ∘ c) (C := C * ‖y - x‖) |
| 71 | zero_le_one (hf.comp hc.continuousOn hcS) (fun t ht ↦ ?_) |
| 72 | · simpa only [Function.comp_apply, c, AffineMap.lineMap_apply_zero, |
| 73 | AffineMap.lineMap_apply_one, sub_zero, mul_one] using hseg |
| 74 | obtain ⟨g, L, hL, heq, hdom, hbound⟩ := hsupport (c t) (hcS (Ico_subset_Icc_self ht)) |
| 75 | refine ⟨g ∘ c, L (y - x), |
| 76 | hL.comp_hasDerivAt t AffineMap.hasDerivAt_lineMap, heq, |
| 77 | hc.continuousAt hdom, ?_⟩ |
| 78 | exact (le_abs_self _).trans ((L.le_opNorm _).trans |
| 79 | (mul_le_mul_of_nonneg_right hbound (norm_nonneg _))) |
| 80 | |
| 81 | /-- Uniformly bounded upper contact differentials imply Lipschitz continuity. -/ |
| 82 | theorem lipschitzOnWith_of_upper_supports {S : Set E} (hS : Convex ℝ S) |
| 83 | {f : E → ℝ} (hf : ContinuousOn f S) {C : ℝ≥0} |
| 84 | (hsupport : ∀ z ∈ S, ∃ g : E → ℝ, ∃ L : E →L[ℝ] ℝ, |
| 85 | HasFDerivAt g L z ∧ g z = f z ∧ |
| 86 | (∀ᶠ w in 𝓝 z, f w ≤ g w) ∧ ‖L‖ ≤ C) : |
| 87 | LipschitzOnWith C f S := by |
| 88 | apply LipschitzOnWith.of_dist_le_mul |
| 89 | intro x hx y hy |
| 90 | rw [Real.dist_eq, dist_eq_norm] |
| 91 | apply abs_le.mpr |
| 92 | constructor |
| 93 | · have h := sub_le_norm_of_upper_supports hS hf hsupport hx hy |
| 94 | rw [norm_sub_rev] at h |
| 95 | linarith |
| 96 | · exact sub_le_norm_of_upper_supports hS hf hsupport hy hx |
| 97 | |
| 98 | end PoincareMT.SurgeryVolume.Measure |