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 | /-! |
| 3 | # Directional increments from differentiable upper supports |
| 4 | |
| 5 | The mean-value inequality applies to local upper supports without assuming |
| 6 | differentiability of the supported function. |
| 7 | -/ |
| 8 | |
| 9 | set_option autoImplicit false |
| 10 | |
| 11 | open Set Filter |
| 12 | open scoped Topology |
| 13 | namespace Poincare.Analysis |
| 14 | |
| 15 | /-- An upper support with derivative at most `C` at every point bounds the total increment. -/ |
| 16 | theorem sub_le_mul_sub_of_hasDerivAt_upper_support |
| 17 | {f : ℝ → ℝ} {a b C : ℝ} (hab : a ≤ b) |
| 18 | (hf : ContinuousOn f (Icc a b)) |
| 19 | (hsupport : ∀ x ∈ Ico a b, ∃ (g : ℝ → ℝ) (d : ℝ), |
| 20 | HasDerivAt g d x ∧ g x = f x ∧ (∀ᶠ y in 𝓝 x, f y ≤ g y) ∧ d ≤ C) : |
| 21 | f b - f a ≤ C * (b - a) := by |
| 22 | have hb : f b ≤ f a + C * (b - a) := by |
| 23 | apply image_le_of_liminf_slope_right_le_deriv_boundary hf |
| 24 | (B := fun x => f a + C * (x - a)) (B' := fun _ => C) |
| 25 | (by simp) (by fun_prop) ?_ ?_ ⟨hab, le_rfl⟩ |
| 26 | · intro x _ |
| 27 | simpa only [mul_one, id_eq] using ((((hasDerivAt_id x).sub_const a).const_mul C).const_add (f a)).hasDerivWithinAt |
| 28 | · intro x hx r hr |
| 29 | obtain ⟨g, d, hg, heq, hmajor, hd⟩ := hsupport x hx |
| 30 | have hslopes : ∀ᶠ y in 𝓝[>] x, slope f x y ≤ slope g x y := by |
| 31 | filter_upwards [hmajor.filter_mono nhdsWithin_le_nhds, |
| 32 | self_mem_nhdsWithin] with y hy hxy |
| 33 | simp only [slope_def_field, heq] |
| 34 | exact div_le_div_of_nonneg_right (sub_le_sub_right hy _) (sub_nonneg.mpr (le_of_lt hxy)) |
| 35 | exact ((hg.hasDerivWithinAt.liminf_right_slope_le (hd.trans_lt hr)).and_eventually |
| 36 | hslopes).mono (fun y hy => hy.2.trans_lt hy.1) |
| 37 | linarith |
| 38 | |
| 39 | /-- Restricting upper supports to an affine segment bounds its directional increment. -/ |
| 40 | theorem increment_le_of_fderiv_upper_support |
| 41 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 42 | {s : Set E} (hs : Convex ℝ s) {f : E → ℝ} (hf : ContinuousOn f s) |
| 43 | {v : E} {C : ℝ} |
| 44 | (hsupport : ∀ x ∈ s, ∃ g : E → ℝ, DifferentiableAt ℝ g x ∧ |
| 45 | g x = f x ∧ (∀ᶠ y in 𝓝 x, f y ≤ g y) ∧ fderiv ℝ g x v ≤ C) |
| 46 | {y : E} (hy : y ∈ s) {t : ℝ} (ht : 0 ≤ t) (hz : y + t • v ∈ s) : |
| 47 | f (y + t • v) - f y ≤ t * C := by |
| 48 | rcases ht.eq_or_lt with ht | ht |
| 49 | · subst t |
| 50 | simp |
| 51 | have hmem : ∀ q ∈ Icc (0 : ℝ) t, y + q • v ∈ s := by |
| 52 | intro q hq |
| 53 | have hm := hs.add_smul_sub_mem hy hz |
| 54 | (show q / t ∈ Icc (0 : ℝ) 1 from |
| 55 | ⟨div_nonneg hq.1 ht.le, (div_le_one ht).mpr hq.2⟩) |
| 56 | simpa only [add_sub_cancel_left, smul_smul, div_mul_cancel₀ _ ht.ne'] using hm |
| 57 | have hb := sub_le_mul_sub_of_hasDerivAt_upper_support ht.le |
| 58 | (hf.comp (by fun_prop : ContinuousOn (fun q : ℝ => y + q • v) (Icc 0 t)) hmem) |
| 59 | (C := C) (fun q hq => ?_) |
| 60 | · simpa only [Function.comp_apply, zero_smul, add_zero, sub_zero, mul_comm] using hb |
| 61 | obtain ⟨g, hg, heq, hmajor, hbound⟩ := hsupport (y + q • v) (hmem q ⟨hq.1, hq.2.le⟩) |
| 62 | refine ⟨fun q : ℝ => g (y + q • v), fderiv ℝ g (y + q • v) v, ?_, heq, ?_, hbound⟩ |
| 63 | · have hline : HasDerivAt (fun q : ℝ => y + q • v) v q := by |
| 64 | simpa only [id_eq, one_smul] using ((hasDerivAt_id q).smul_const v).const_add y |
| 65 | exact hg.hasFDerivAt.comp_hasDerivAt q hline |
| 66 | · exact (show ContinuousAt (fun q : ℝ => y + q • v) q by fun_prop).tendsto.eventually hmajor |
| 67 | |
| 68 | /-- Two-sided bounds on upper-support derivatives give two-sided directional increments. -/ |
| 69 | theorem increment_bounds_of_fderiv_upper_support |
| 70 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 71 | {s : Set E} (hs : Convex ℝ s) {f : E → ℝ} (hf : ContinuousOn f s) |
| 72 | {v : E} {lo hi : ℝ} |
| 73 | (hsupport : ∀ x ∈ s, ∃ g : E → ℝ, DifferentiableAt ℝ g x ∧ |
| 74 | g x = f x ∧ (∀ᶠ y in 𝓝 x, f y ≤ g y) ∧ |
| 75 | lo ≤ fderiv ℝ g x v ∧ fderiv ℝ g x v ≤ hi) |
| 76 | {y : E} (hy : y ∈ s) {t : ℝ} (ht : 0 ≤ t) (hz : y + t • v ∈ s) : |
| 77 | t * lo ≤ f (y + t • v) - f y ∧ f (y + t • v) - f y ≤ t * hi := by |
| 78 | refine ⟨?_, increment_le_of_fderiv_upper_support hs hf |
| 79 | (fun x hx => by |
| 80 | obtain ⟨g, hg, heq, hmajor, _, hb⟩ := hsupport x hx |
| 81 | exact ⟨g, hg, heq, hmajor, hb⟩) hy ht hz⟩ |
| 82 | have hback : (y + t • v) + t • (-v) = y := by simp |
| 83 | have hrev := increment_le_of_fderiv_upper_support hs hf (v := -v) (C := -lo) |
| 84 | (fun x hx => by |
| 85 | obtain ⟨g, hg, heq, hmajor, hb, _⟩ := hsupport x hx |
| 86 | refine ⟨g, hg, heq, hmajor, ?_⟩ |
| 87 | simpa only [map_neg, neg_le_neg_iff] using hb) hz ht (by simpa only [hback] using hy) |
| 88 | rw [hback] at hrev |
| 89 | linarith |
| 90 | |
| 91 | end Poincare.Analysis |
| 92 |