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.SpecialFunctions.Log.NegMulLog |
| 2 | import Mathlib.Topology.Order.IntermediateValue |
| 3 | import Mathlib.Tactic.FieldSimp |
| 4 | import Mathlib.Tactic.Linarith |
| 5 | import Mathlib.Tactic.Positivity |
| 6 | import Mathlib.Tactic.Ring |
| 7 | |
| 8 | /-! |
| 9 | # The scalar Hamilton-Ivey region |
| 10 | |
| 11 | The logarithmic barrier, its second intersection with the horizontal trace |
| 12 | bound, and convexity and downward closure of the scalar region. |
| 13 | |
| 14 | Reference: Morgan--Tian, Claim 4.28, pp. 77--78. |
| 15 | -/ |
| 16 | |
| 17 | namespace Poincare.HamiltonIvey |
| 18 | |
| 19 | open Set |
| 20 | |
| 21 | noncomputable def logBarrier (t x : ℝ) : ℝ := |
| 22 | x * (Real.log x + Real.log (1 + t) - 3) |
| 23 | |
| 24 | theorem continuous_logBarrier (t : ℝ) : Continuous (logBarrier t) := by |
| 25 | convert! Real.continuous_mul_log.add |
| 26 | (continuous_id.mul_const (Real.log (1 + t) - 3)) using 1 |
| 27 | ext x |
| 28 | dsimp [logBarrier] |
| 29 | ring |
| 30 | |
| 31 | theorem strictConvexOn_logBarrier (t : ℝ) : |
| 32 | StrictConvexOn ℝ (Ici 0) (logBarrier t) := by |
| 33 | refine ⟨convex_Ici 0, ?_⟩ |
| 34 | intro x hx y hy hxy a b ha hb hab |
| 35 | have h := Real.strictConvexOn_mul_log.2 hx hy hxy ha hb hab |
| 36 | simp only [smul_eq_mul, logBarrier] at * |
| 37 | nlinarith |
| 38 | |
| 39 | theorem hasDerivAt_logBarrier (t : ℝ) {x : ℝ} (hx : x ≠ 0) : |
| 40 | HasDerivAt (logBarrier t) (Real.log x + Real.log (1 + t) - 2) x := by |
| 41 | convert! (Real.hasDerivAt_mul_log hx).add |
| 42 | ((hasDerivAt_id x).mul_const (Real.log (1 + t) - 3)) using 1 |
| 43 | · ext y |
| 44 | dsimp [logBarrier] |
| 45 | ring |
| 46 | · ring |
| 47 | |
| 48 | theorem exists_base_cutoff : |
| 49 | ∃ x : ℝ, Real.exp 2 < x ∧ logBarrier 0 x = -3 := by |
| 50 | have he : (3 : ℝ) < Real.exp 2 := by |
| 51 | convert Real.add_one_lt_exp (show (2 : ℝ) ≠ 0 by norm_num) using 1 |
| 52 | norm_num |
| 53 | have hab : Real.exp (2 : ℝ) ≤ Real.exp 3 := Real.exp_le_exp.mpr (by norm_num) |
| 54 | have hmem : (-3 : ℝ) ∈ Icc (logBarrier 0 (Real.exp 2)) |
| 55 | (logBarrier 0 (Real.exp 3)) := by |
| 56 | simp only [logBarrier, Real.log_exp, add_zero, Real.log_one] |
| 57 | constructor <;> linarith |
| 58 | obtain ⟨x, hx, hroot⟩ := |
| 59 | intermediate_value_Icc hab (continuous_logBarrier 0).continuousOn hmem |
| 60 | refine ⟨x, ?_, hroot⟩ |
| 61 | have hne : Real.exp 2 ≠ x := by |
| 62 | rintro rfl |
| 63 | simp only [logBarrier, Real.log_exp, add_zero, Real.log_one] at hroot |
| 64 | linarith |
| 65 | exact lt_of_le_of_ne hx.1 hne |
| 66 | |
| 67 | noncomputable def baseCutoff : ℝ := Classical.choose exists_base_cutoff |
| 68 | |
| 69 | theorem baseCutoff_spec : Real.exp 2 < baseCutoff ∧ logBarrier 0 baseCutoff = -3 := |
| 70 | Classical.choose_spec exists_base_cutoff |
| 71 | |
| 72 | theorem baseCutoff_pos : 0 < baseCutoff := |
| 73 | (Real.exp_pos 2).trans baseCutoff_spec.1 |
| 74 | |
| 75 | noncomputable def cutoff (t : ℝ) : ℝ := baseCutoff / (1 + t) |
| 76 | |
| 77 | theorem logBarrier_div {t x : ℝ} (ht : 0 ≤ t) (hx : 0 < x) : |
| 78 | logBarrier t (x / (1 + t)) = logBarrier 0 x / (1 + t) := by |
| 79 | have hc : 0 < 1 + t := by linarith |
| 80 | simp only [logBarrier, Real.log_div hx.ne' hc.ne', add_zero, Real.log_one] |
| 81 | ring |
| 82 | |
| 83 | theorem cutoff_pos {t : ℝ} (ht : 0 ≤ t) : 0 < cutoff t := |
| 84 | div_pos baseCutoff_pos (by linarith) |
| 85 | |
| 86 | theorem cutoff_gt_first {t : ℝ} (ht : 0 ≤ t) : 1 / (1 + t) < cutoff t := by |
| 87 | have hbase : (1 : ℝ) < baseCutoff := by |
| 88 | have := Real.add_one_le_exp (2 : ℝ) |
| 89 | linarith [baseCutoff_spec.1] |
| 90 | exact (div_lt_div_iff_of_pos_right (by linarith : 0 < 1 + t)).mpr hbase |
| 91 | |
| 92 | theorem logBarrier_cutoff {t : ℝ} (ht : 0 ≤ t) : |
| 93 | logBarrier t (cutoff t) = -3 / (1 + t) := by |
| 94 | rw [cutoff, logBarrier_div ht baseCutoff_pos, baseCutoff_spec.2] |
| 95 | |
| 96 | theorem logBarrier_first {t : ℝ} (ht : 0 ≤ t) : |
| 97 | logBarrier t (1 / (1 + t)) = -3 / (1 + t) := by |
| 98 | rw [logBarrier_div ht (by norm_num : (0 : ℝ) < 1)] |
| 99 | norm_num [logBarrier] |
| 100 | |
| 101 | theorem cutoff_spec {t : ℝ} (ht : 0 ≤ t) : |
| 102 | 1 / (1 + t) < cutoff t ∧ |
| 103 | logBarrier t (cutoff t) = -3 / (1 + t) ∧ |
| 104 | ∀ x : ℝ, 1 / (1 + t) < x → |
| 105 | logBarrier t x = -3 / (1 + t) → x = cutoff t := by |
| 106 | refine ⟨cutoff_gt_first ht, logBarrier_cutoff ht, ?_⟩ |
| 107 | intro x hx hroot |
| 108 | have hfirst : 0 < 1 / (1 + t) := by positivity |
| 109 | have hc := cutoff_gt_first ht |
| 110 | rcases lt_trichotomy x (cutoff t) with hlt | heq | hgt |
| 111 | · have h := (strictConvexOn_logBarrier t).lt_on_openSegment |
| 112 | hfirst.le (cutoff_pos ht).le hc.ne |
| 113 | (show x ∈ openSegment ℝ (1 / (1 + t)) (cutoff t) by |
| 114 | rw [openSegment_eq_Ioo hc] |
| 115 | exact ⟨hx, hlt⟩) |
| 116 | rw [hroot, logBarrier_first ht, logBarrier_cutoff ht, max_self] at h |
| 117 | exact (lt_irrefl _ h).elim |
| 118 | · exact heq |
| 119 | · have h := (strictConvexOn_logBarrier t).lt_on_openSegment |
| 120 | hfirst.le (hfirst.trans hx).le hx.ne |
| 121 | (show cutoff t ∈ openSegment ℝ (1 / (1 + t)) x by |
| 122 | rw [openSegment_eq_Ioo hx] |
| 123 | exact ⟨hc, hgt⟩) |
| 124 | rw [logBarrier_cutoff ht, logBarrier_first ht, hroot, max_self] at h |
| 125 | exact (lt_irrefl _ h).elim |
| 126 | |
| 127 | theorem strictMonoOn_logBarrier {t : ℝ} (ht : 0 ≤ t) : |
| 128 | StrictMonoOn (logBarrier t) (Ici (cutoff t)) := by |
| 129 | apply strictMonoOn_of_deriv_pos (convex_Ici _) (continuous_logBarrier t).continuousOn |
| 130 | intro x hx |
| 131 | have hcut : cutoff t ≤ x := interior_subset hx |
| 132 | have hxpos : 0 < x := (cutoff_pos ht).trans_le hcut |
| 133 | rw [(hasDerivAt_logBarrier t hxpos.ne').deriv] |
| 134 | have hlog : 2 < Real.log baseCutoff := by |
| 135 | have := Real.log_lt_log (Real.exp_pos 2) baseCutoff_spec.1 |
| 136 | simpa only [Real.log_exp] using this |
| 137 | have hle := Real.log_le_log (cutoff_pos ht) hcut |
| 138 | rw [cutoff, Real.log_div baseCutoff_pos.ne' (by linarith : 1 + t ≠ 0)] at hle |
| 139 | linarith |
| 140 | |
| 141 | def scalarRegion (t : ℝ) : Set (ℝ × ℝ) := |
| 142 | {p | -3 / (1 + t) ≤ p.1 ∧ (cutoff t ≤ p.2 → logBarrier t p.2 ≤ p.1)} |
| 143 | |
| 144 | /-- The horizontal barrier joined to the increasing logarithmic branch. -/ |
| 145 | noncomputable def clippedBarrier (t X : ℝ) : ℝ := |
| 146 | logBarrier t (max (cutoff t) X) |
| 147 | |
| 148 | theorem monotone_clippedBarrier {t : ℝ} (ht : 0 ≤ t) : |
| 149 | Monotone (clippedBarrier t) := by |
| 150 | intro x y hxy |
| 151 | exact (strictMonoOn_logBarrier ht).monotoneOn |
| 152 | (mem_Ici.mpr (le_max_left _ _)) (mem_Ici.mpr (le_max_left _ _)) |
| 153 | (max_le_max_left _ hxy) |
| 154 | |
| 155 | theorem convexOn_clippedBarrier {t : ℝ} (ht : 0 ≤ t) : |
| 156 | ConvexOn ℝ univ (clippedBarrier t) := by |
| 157 | refine ⟨convex_univ, ?_⟩ |
| 158 | intro x hx y hy a b ha hb hab |
| 159 | have hcx := le_max_left (cutoff t) x |
| 160 | have hcy := le_max_left (cutoff t) y |
| 161 | have hcx' := le_max_right (cutoff t) x |
| 162 | have hcy' := le_max_right (cutoff t) y |
| 163 | have hmix : cutoff t ≤ a * max (cutoff t) x + b * max (cutoff t) y := by |
| 164 | have h := add_le_add (mul_le_mul_of_nonneg_left hcx ha) |
| 165 | (mul_le_mul_of_nonneg_left hcy hb) |
| 166 | rwa [← add_mul, hab, one_mul] at h |
| 167 | have hmax : max (cutoff t) (a * x + b * y) ≤ |
| 168 | a * max (cutoff t) x + b * max (cutoff t) y := by |
| 169 | apply max_le hmix |
| 170 | exact add_le_add (mul_le_mul_of_nonneg_left hcx' ha) |
| 171 | (mul_le_mul_of_nonneg_left hcy' hb) |
| 172 | change logBarrier t (max (cutoff t) (a * x + b * y)) ≤ |
| 173 | a * logBarrier t (max (cutoff t) x) + b * logBarrier t (max (cutoff t) y) |
| 174 | calc |
| 175 | _ ≤ logBarrier t (a * max (cutoff t) x + b * max (cutoff t) y) := |
| 176 | (strictMonoOn_logBarrier ht).monotoneOn |
| 177 | (mem_Ici.mpr (le_max_left _ _)) hmix hmax |
| 178 | _ ≤ _ := (strictConvexOn_logBarrier t).convexOn.2 |
| 179 | ((cutoff_pos ht).le.trans hcx) ((cutoff_pos ht).le.trans hcy) ha hb hab |
| 180 | |
| 181 | theorem mem_scalarRegion_iff {t S X : ℝ} (ht : 0 ≤ t) : |
| 182 | (S, X) ∈ scalarRegion t ↔ clippedBarrier t X ≤ S := by |
| 183 | change (-3 / (1 + t) ≤ S ∧ (cutoff t ≤ X → logBarrier t X ≤ S)) ↔ |
| 184 | logBarrier t (max (cutoff t) X) ≤ S |
| 185 | by_cases hX : cutoff t ≤ X |
| 186 | · rw [max_eq_right hX] |
| 187 | constructor |
| 188 | · exact fun h => h.2 hX |
| 189 | · intro h |
| 190 | refine ⟨?_, fun _ => h⟩ |
| 191 | rw [← logBarrier_cutoff ht] |
| 192 | exact ((strictMonoOn_logBarrier ht).monotoneOn (mem_Ici.mpr (le_refl _)) hX hX).trans h |
| 193 | · rw [max_eq_left (le_of_not_ge hX), logBarrier_cutoff ht] |
| 194 | simp only [hX, false_implies, and_true] |
| 195 | |
| 196 | theorem convex_scalarRegion {t : ℝ} (ht : 0 ≤ t) : |
| 197 | Convex ℝ (scalarRegion t) := by |
| 198 | intro p hp q hq a b ha hb hab |
| 199 | rw [mem_scalarRegion_iff ht] at hp hq |
| 200 | apply (mem_scalarRegion_iff ht).mpr |
| 201 | change clippedBarrier t (a * p.2 + b * q.2) ≤ a * p.1 + b * q.1 |
| 202 | exact ((convexOn_clippedBarrier ht).2 (mem_univ _) (mem_univ _) ha hb hab).trans |
| 203 | (add_le_add (mul_le_mul_of_nonneg_left hp ha) (mul_le_mul_of_nonneg_left hq hb)) |
| 204 | |
| 205 | theorem scalarRegion_downward {t S X Y : ℝ} (ht : 0 ≤ t) |
| 206 | (h : (S, X) ∈ scalarRegion t) (hYX : Y ≤ X) : |
| 207 | (S, Y) ∈ scalarRegion t := by |
| 208 | rw [mem_scalarRegion_iff ht] at h ⊢ |
| 209 | exact (monotone_clippedBarrier ht hYX).trans h |
| 210 | |
| 211 | end Poincare.HamiltonIvey |