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.Analysis.Convex.UpperSupport |
| 2 | import Mathlib.Analysis.SpecialFunctions.Trigonometric.DerivHyp |
| 3 | |
| 4 | /-! |
| 5 | # Hyperbolic comparison from scalar upper supports |
| 6 | |
| 7 | The inequality `f'' <= f`, interpreted by smooth local upper supports, places |
| 8 | `f` above its hyperbolic chords. A touching upper support at the initial |
| 9 | endpoint then gives the corresponding hyperbolic tangent upper bound. |
| 10 | -/ |
| 11 | |
| 12 | noncomputable section |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set Filter |
| 16 | open scoped Topology |
| 17 | |
| 18 | namespace Poincare.Alexandrov |
| 19 | |
| 20 | /-- A solution of `L'' = L` lying below both endpoint values also lies below |
| 21 | a continuous function whose local upper supports satisfy `u'' <= f + epsilon`. |
| 22 | -/ |
| 23 | theorem ode_lower_comparison_of_approximate_upper_support |
| 24 | {f L : ℝ → ℝ} {a b : ℝ} |
| 25 | (hf : ContinuousOn f (Icc a b)) (hL : ContDiff ℝ 2 L) |
| 26 | (hode : ∀ t ∈ Ioo a b, deriv (deriv L) t = L t) |
| 27 | (ha : L a ≤ f a) (hb : L b ≤ f b) |
| 28 | (hsupport : ∀ t ∈ Ioo a b, ∀ ε : ℝ, 0 < ε → |
| 29 | ∃ u : ℝ → ℝ, ContDiffAt ℝ 2 u t ∧ u t = f t ∧ |
| 30 | (∀ᶠ s in 𝓝 t, f s ≤ u s) ∧ deriv (deriv u) t ≤ f t + ε) : |
| 31 | ∀ t ∈ Icc a b, L t ≤ f t := by |
| 32 | intro t ht |
| 33 | by_contra hnot |
| 34 | let F : ℝ → ℝ := fun s => f s - L s |
| 35 | have hFc : ContinuousOn F (Icc a b) := hf.sub hL.continuous.continuousOn |
| 36 | obtain ⟨x, hx, hmin⟩ := isCompact_Icc.exists_isMinOn ⟨t, ht⟩ hFc |
| 37 | have hFx : F x < 0 := (hmin ht).trans_lt (sub_neg.mpr (lt_of_not_ge hnot)) |
| 38 | have hax : a < x := lt_of_le_of_ne hx.1 (by |
| 39 | intro h |
| 40 | have hFa : 0 ≤ F a := sub_nonneg.mpr ha |
| 41 | rw [← h] at hFx |
| 42 | exact (not_lt_of_ge hFa) hFx) |
| 43 | have hxb : x < b := lt_of_le_of_ne hx.2 (by |
| 44 | intro h |
| 45 | have hFb : 0 ≤ F b := sub_nonneg.mpr hb |
| 46 | rw [h] at hFx |
| 47 | exact (not_lt_of_ge hFb) hFx) |
| 48 | obtain ⟨u, hu, htouch, hupper, hsecond⟩ := |
| 49 | hsupport x ⟨hax, hxb⟩ (-F x / 2) (by linarith) |
| 50 | have humin : IsLocalMin (fun s => u s - L s) x := by |
| 51 | filter_upwards [hmin.isLocalMin (Icc_mem_nhds hax hxb), hupper] with s hs hsu |
| 52 | change f x - L x ≤ f s - L s at hs |
| 53 | rw [htouch] |
| 54 | linarith |
| 55 | have hnonneg := Poincare.Analysis.nonneg_second_deriv_of_local_min |
| 56 | (hu.sub hL.contDiffAt) humin |
| 57 | have hfirst : deriv (fun s => u s - L s) =ᶠ[𝓝 x] |
| 58 | (fun s => deriv u s - deriv L s) := by |
| 59 | filter_upwards [hu.eventually (by norm_num)] with s hs |
| 60 | exact deriv_fun_sub (hs.differentiableAt (by norm_num)) |
| 61 | (hL.differentiable (by norm_num) s) |
| 62 | have hud : DifferentiableAt ℝ (deriv u) x := |
| 63 | (hu.derivWithin (m := 1) (by norm_num)).differentiableAt (by norm_num) |
| 64 | have hLd : DifferentiableAt ℝ (deriv L) x := |
| 65 | (hL.contDiffAt.derivWithin (m := 1) (by norm_num)).differentiableAt (by norm_num) |
| 66 | rw [hfirst.deriv_eq, deriv_fun_sub hud hLd, hode x ⟨hax, hxb⟩] at hnonneg |
| 67 | dsimp [F] at hsecond hFx |
| 68 | linarith |
| 69 | |
| 70 | private theorem hyperbolic_combination_hasDerivAt (A B t : ℝ) : |
| 71 | HasDerivAt (fun s => A * Real.cosh s + B * Real.sinh s) |
| 72 | (A * Real.sinh t + B * Real.cosh t) t := |
| 73 | ((Real.hasDerivAt_cosh t).const_mul A).add |
| 74 | ((Real.hasDerivAt_sinh t).const_mul B) |
| 75 | |
| 76 | private theorem hyperbolic_combination_second_deriv (A B t : ℝ) : |
| 77 | deriv (deriv (fun s => A * Real.cosh s + B * Real.sinh s)) t = |
| 78 | A * Real.cosh t + B * Real.sinh t := by |
| 79 | have hfirst : deriv (fun s => A * Real.cosh s + B * Real.sinh s) = |
| 80 | (fun s => A * Real.sinh s + B * Real.cosh s) := by |
| 81 | funext s |
| 82 | exact (hyperbolic_combination_hasDerivAt A B s).deriv |
| 83 | rw [hfirst] |
| 84 | exact (((Real.hasDerivAt_sinh t).const_mul A).add |
| 85 | ((Real.hasDerivAt_cosh t).const_mul B)).deriv |
| 86 | |
| 87 | /-- The hyperbolic tangent upper bound follows from arbitrarily accurate |
| 88 | local upper supports for `f'' <= f` and a differentiable initial upper support. |
| 89 | -/ |
| 90 | theorem hyperbolic_upper_comparison_of_approximate_upper_support |
| 91 | {f u : ℝ → ℝ} {b v₀ : ℝ} (hb : 0 < b) |
| 92 | (hf : ContinuousOn f (Icc 0 b)) |
| 93 | (htouch : u 0 = f 0) (hupper : ∀ᶠ s in 𝓝 0, f s ≤ u s) |
| 94 | (hu : HasDerivAt u v₀ 0) |
| 95 | (hsupport : ∀ t ∈ Ioo 0 b, ∀ ε : ℝ, 0 < ε → |
| 96 | ∃ v : ℝ → ℝ, ContDiffAt ℝ 2 v t ∧ v t = f t ∧ |
| 97 | (∀ᶠ s in 𝓝 t, f s ≤ v s) ∧ deriv (deriv v) t ≤ f t + ε) : |
| 98 | f b ≤ f 0 * Real.cosh b + v₀ * Real.sinh b := by |
| 99 | let B : ℝ := (f b - f 0 * Real.cosh b) / Real.sinh b |
| 100 | let L : ℝ → ℝ := fun t => f 0 * Real.cosh t + B * Real.sinh t |
| 101 | have hsinh : 0 < Real.sinh b := Real.sinh_pos_iff.mpr hb |
| 102 | have hL0 : L 0 = f 0 := by simp [L] |
| 103 | have hLb : L b = f b := by |
| 104 | dsimp [L, B] |
| 105 | rw [div_mul_cancel₀ _ hsinh.ne'] |
| 106 | ring |
| 107 | have hLle : ∀ t ∈ Icc 0 b, L t ≤ f t := |
| 108 | ode_lower_comparison_of_approximate_upper_support hf (by dsimp [L]; fun_prop) |
| 109 | (fun t _ => hyperbolic_combination_second_deriv (f 0) B t) |
| 110 | hL0.le hLb.le hsupport |
| 111 | have hLd : HasDerivAt L B 0 := by |
| 112 | simpa [L] using hyperbolic_combination_hasDerivAt (f 0) B 0 |
| 113 | have hBle : B ≤ v₀ := by |
| 114 | apply le_of_tendsto_of_tendsto |
| 115 | (hLd.tendsto_slope.mono_left (nhdsGT_le_nhdsNE 0)) |
| 116 | (hu.tendsto_slope.mono_left (nhdsGT_le_nhdsNE 0)) |
| 117 | filter_upwards [self_mem_nhdsWithin, |
| 118 | (eventually_lt_nhds hb).filter_mono nhdsWithin_le_nhds, |
| 119 | hupper.filter_mono nhdsWithin_le_nhds] with t ht htb htu |
| 120 | have htpos : 0 < t := ht |
| 121 | simp only [slope_def_field, hL0, htouch] |
| 122 | exact div_le_div_of_nonneg_right |
| 123 | (sub_le_sub_right ((hLle t ⟨htpos.le, htb.le⟩).trans htu) _) |
| 124 | (sub_nonneg.mpr htpos.le) |
| 125 | have h := (div_le_iff₀ hsinh).mp hBle |
| 126 | linarith |
| 127 | |
| 128 | end Poincare.Alexandrov |