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.Deriv.MeanValue |
| 2 | import Mathlib.Topology.Order.Compact |
| 3 | |
| 4 | /-! |
| 5 | # Scalar control near a finite terminal time |
| 6 | |
| 7 | A quadratic derivative bound, required only above a positive threshold, |
| 8 | prevents a scalar from doubling on a sufficiently short time interval. |
| 9 | This is the temporal estimate used in Morgan--Tian, Lemmas 11.2 and 11.21, |
| 10 | pp. 268--269 and 280. The level-crossing proof adapts the Axel workspace |
| 11 | `SingularTimeGeometry/ScalarControl.lean` at `0ec4f42f6d3bf5d5ad2bf75e30b744a1a042d809`. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Set |
| 17 | |
| 18 | namespace PoincareMT.SingularRegularLimit |
| 19 | |
| 20 | private theorem exists_first_level {f : ℝ → ℝ} {a b H : ℝ} (hab : a ≤ b) |
| 21 | (hf : ContinuousOn f (Icc a b)) (ha : f a < H) (hb : H ≤ f b) : |
| 22 | ∃ c ∈ Ioc a b, f c = H ∧ ∀ t ∈ Ico a c, f t < H := by |
| 23 | let S := Icc a b ∩ f ⁻¹' {H} |
| 24 | have hS : IsCompact S := |
| 25 | isCompact_Icc.of_isClosed_subset |
| 26 | (hf.preimage_isClosed_of_isClosed isClosed_Icc isClosed_singleton) inter_subset_left |
| 27 | obtain ⟨x, hx, hfx⟩ := intermediate_value_Icc hab hf ⟨ha.le, hb⟩ |
| 28 | obtain ⟨c, hc, hmin⟩ := hS.exists_isMinOn ⟨x, hx, hfx⟩ continuousOn_id |
| 29 | have hcH : f c = H := hc.2 |
| 30 | have hac : a < c := lt_of_le_of_ne hc.1.1 (by |
| 31 | intro h |
| 32 | subst c |
| 33 | exact ha.ne hcH) |
| 34 | refine ⟨c, ⟨hac, hc.1.2⟩, hcH, ?_⟩ |
| 35 | intro t ht |
| 36 | by_contra h |
| 37 | obtain ⟨u, hu, hfu⟩ := intermediate_value_Icc ht.1 |
| 38 | (hf.mono (Icc_subset_Icc le_rfl (ht.2.le.trans hc.1.2))) |
| 39 | ⟨ha.le, le_of_not_gt h⟩ |
| 40 | have hcu : c ≤ u := hmin ⟨⟨hu.1, hu.2.trans (ht.2.le.trans hc.1.2)⟩, hfu⟩ |
| 41 | exact (not_lt_of_ge (hcu.trans hu.2)) ht.2 |
| 42 | |
| 43 | private theorem exists_last_level_below {f : ℝ → ℝ} {a b H : ℝ} (hab : a ≤ b) |
| 44 | (hf : ContinuousOn f (Icc a b)) (ha : H ≤ f a) (hb : f b < H) : |
| 45 | ∃ c ∈ Ico a b, f c = H ∧ ∀ t ∈ Ioc c b, f t < H := by |
| 46 | let S := Icc a b ∩ f ⁻¹' {H} |
| 47 | have hS : IsCompact S := |
| 48 | isCompact_Icc.of_isClosed_subset |
| 49 | (hf.preimage_isClosed_of_isClosed isClosed_Icc isClosed_singleton) inter_subset_left |
| 50 | obtain ⟨x, hx, hfx⟩ := intermediate_value_Icc' hab hf ⟨hb.le, ha⟩ |
| 51 | obtain ⟨c, hc, hmax⟩ := hS.exists_isMaxOn ⟨x, hx, hfx⟩ continuousOn_id |
| 52 | have hcH : f c = H := hc.2 |
| 53 | have hcb : c < b := lt_of_le_of_ne hc.1.2 (by |
| 54 | intro h |
| 55 | subst c |
| 56 | exact hb.ne hcH) |
| 57 | refine ⟨c, ⟨hc.1.1, hcb⟩, hcH, ?_⟩ |
| 58 | intro t ht |
| 59 | by_contra h |
| 60 | obtain ⟨u, hu, hfu⟩ := intermediate_value_Icc' ht.2 |
| 61 | (hf.mono (Icc_subset_Icc (hc.1.1.trans ht.1.le) le_rfl)) |
| 62 | ⟨hb.le, le_of_not_gt h⟩ |
| 63 | have huc : u ≤ c := hmax ⟨⟨(hc.1.1.trans ht.1.le).trans hu.1, hu.2⟩, hfu⟩ |
| 64 | exact (not_lt_of_ge (hu.1.trans huc)) ht.1 |
| 65 | |
| 66 | private theorem exists_last_level_above {f : ℝ → ℝ} {a b H : ℝ} (hab : a ≤ b) |
| 67 | (hf : ContinuousOn f (Icc a b)) (ha : f a ≤ H) (hb : H < f b) : |
| 68 | ∃ c ∈ Ico a b, f c = H ∧ ∀ t ∈ Ioc c b, H < f t := by |
| 69 | obtain ⟨c, hc, he, hafter⟩ := exists_last_level_below hab hf.neg |
| 70 | (neg_le_neg ha) (neg_lt_neg hb) |
| 71 | exact ⟨c, hc, neg_injective he, fun t ht => neg_lt_neg_iff.mp (hafter t ht)⟩ |
| 72 | |
| 73 | /-- A superthreshold quadratic derivative bound prevents doubling on a short interval. |
| 74 | No derivative control or positivity is required below the threshold. -/ |
| 75 | theorem scalar_lt_two_mul_of_short_interval {f : ℝ → ℝ} {s T C rho K : ℝ} |
| 76 | (hC : 0 ≤ C) (hrho : 0 < rho) (hrhoK : rho ≤ K) |
| 77 | (hf : ContinuousOn f (Icc s T)) (hs : f s < K) |
| 78 | (hd : ∀ t ∈ Ioo s T, rho ≤ f t → |
| 79 | ∃ d, HasDerivAt f d t ∧ |d| ≤ C * f t ^ 2) |
| 80 | (hshort : T - s < 1 / (4 * (C + 1) * K)) : |
| 81 | ∀ t ∈ Icc s T, f t < 2 * K := by |
| 82 | have hK : 0 < K := hrho.trans_le hrhoK |
| 83 | intro t ht |
| 84 | by_contra hbad |
| 85 | have hst : ContinuousOn f (Icc s t) := hf.mono (Icc_subset_Icc le_rfl ht.2) |
| 86 | obtain ⟨v, hv, hfv, hbefore⟩ := exists_first_level ht.1 hst |
| 87 | (by linarith : f s < 2 * K) (le_of_not_gt hbad) |
| 88 | have hsv : ContinuousOn f (Icc s v) := hst.mono (Icc_subset_Icc le_rfl hv.2) |
| 89 | obtain ⟨u, hu, hfu, hafter⟩ := exists_last_level_above hv.1.le hsv |
| 90 | hs.le (by rw [hfv]; linarith) |
| 91 | have huv : ContinuousOn f (Icc u v) := hsv.mono (Icc_subset_Icc hu.1 le_rfl) |
| 92 | have hder : ∀ z ∈ Ioo u v, ∃ d, HasDerivAt f d z ∧ |d| ≤ 4 * C * K ^ 2 := by |
| 93 | intro z hz |
| 94 | have hlo := hafter z ⟨hz.1, hz.2.le⟩ |
| 95 | have hhi := hbefore z ⟨hu.1.trans hz.1.le, hz.2⟩ |
| 96 | obtain ⟨d, hdz, hbound⟩ := hd z |
| 97 | ⟨hu.1.trans_lt hz.1, hz.2.trans_le (hv.2.trans ht.2)⟩ |
| 98 | (hrhoK.trans hlo.le) |
| 99 | refine ⟨d, hdz, hbound.trans ?_⟩ |
| 100 | have hsq : f z ^ 2 ≤ 4 * K ^ 2 := by nlinarith |
| 101 | nlinarith [mul_le_mul_of_nonneg_left hsq hC] |
| 102 | have hdiff : DifferentiableOn ℝ f (Ioo u v) := by |
| 103 | intro z hz |
| 104 | obtain ⟨d, hdz, _⟩ := hder z hz |
| 105 | exact hdz.differentiableAt.differentiableWithinAt |
| 106 | obtain ⟨z, hz, he⟩ := exists_deriv_eq_slope f hu.2 huv hdiff |
| 107 | obtain ⟨d, hdz, hbound⟩ := hder z hz |
| 108 | rw [hdz.deriv, hfv, hfu] at he |
| 109 | have hslope : K ≤ (4 * C * K ^ 2) * (v - u) := by |
| 110 | have hb : (2 * K - K) / (v - u) ≤ 4 * C * K ^ 2 := |
| 111 | he ▸ (le_abs_self d).trans hbound |
| 112 | have := (div_le_iff₀ (sub_pos.mpr hu.2)).mp hb |
| 113 | linarith |
| 114 | have htime : (v - u) * (4 * (C + 1) * K) < 1 := by |
| 115 | apply (lt_div_iff₀ (by positivity : 0 < 4 * (C + 1) * K)).mp |
| 116 | exact lt_of_le_of_lt (sub_le_sub (hv.2.trans ht.2) hu.1) hshort |
| 117 | have hmul := mul_lt_mul_of_pos_right htime hK |
| 118 | have hnonneg : 0 ≤ K ^ 2 * (v - u) := |
| 119 | mul_nonneg (sq_nonneg K) (sub_nonneg.mpr hu.2.le) |
| 120 | nlinarith |
| 121 | |
| 122 | /-- The same control on a half-open final interval needs no terminal value. -/ |
| 123 | theorem scalar_lt_two_mul_of_short_tail {f : ℝ → ℝ} {s T C rho K : ℝ} |
| 124 | (hC : 0 ≤ C) (hrho : 0 < rho) (hrhoK : rho ≤ K) |
| 125 | (hf : ContinuousOn f (Ico s T)) (hs : f s < K) |
| 126 | (hd : ∀ t ∈ Ioo s T, rho ≤ f t → |
| 127 | ∃ d, HasDerivAt f d t ∧ |d| ≤ C * f t ^ 2) |
| 128 | (hshort : T - s < 1 / (4 * (C + 1) * K)) : |
| 129 | ∀ t ∈ Ico s T, f t < 2 * K := by |
| 130 | intro t ht |
| 131 | exact scalar_lt_two_mul_of_short_interval hC hrho hrhoK |
| 132 | (hf.mono (fun z hz => ⟨hz.1, hz.2.trans_lt ht.2⟩)) hs |
| 133 | (fun z hz => hd z ⟨hz.1, hz.2.trans ht.2⟩) |
| 134 | ((sub_le_sub_right ht.2.le s).trans_lt hshort) t ⟨ht.1, le_rfl⟩ |
| 135 | |
| 136 | /-- Absolute derivative control also prevents backward doubling. -/ |
| 137 | theorem scalar_lt_two_mul_of_short_interval_backward {f : ℝ → ℝ} {s T C rho K : ℝ} |
| 138 | (hC : 0 ≤ C) (hrho : 0 < rho) (hrhoK : rho ≤ K) |
| 139 | (hf : ContinuousOn f (Icc s T)) (hT : f T < K) |
| 140 | (hd : ∀ t ∈ Ioo s T, rho ≤ f t → |
| 141 | ∃ d, HasDerivAt f d t ∧ |d| ≤ C * f t ^ 2) |
| 142 | (hshort : T - s < 1 / (4 * (C + 1) * K)) : |
| 143 | ∀ t ∈ Icc s T, f t < 2 * K := by |
| 144 | have hc : ContinuousOn (fun t => f (-t)) (Icc (-T) (-s)) := |
| 145 | hf.comp continuous_neg.continuousOn (fun t ht => ⟨by linarith [ht.2], by linarith [ht.1]⟩) |
| 146 | have hd' : ∀ t ∈ Ioo (-T) (-s), rho ≤ f (-t) → |
| 147 | ∃ d, HasDerivAt (fun z => f (-z)) d t ∧ |d| ≤ C * f (-t) ^ 2 := by |
| 148 | intro t ht hR |
| 149 | obtain ⟨d, hdf, hbound⟩ := hd (-t) ⟨by linarith [ht.2], by linarith [ht.1]⟩ hR |
| 150 | refine ⟨-d, ?_, by simpa only [abs_neg] using hbound⟩ |
| 151 | simpa only [Function.comp_def, neg_mul, mul_one, mul_neg, id_eq] using |
| 152 | hdf.comp t (hasDerivAt_id t).neg |
| 153 | intro t ht |
| 154 | have h := scalar_lt_two_mul_of_short_interval hC hrho hrhoK hc |
| 155 | (by simpa only [neg_neg] using hT) hd' (by linarith) (-t) |
| 156 | ⟨by linarith [ht.2], by linarith [ht.1]⟩ |
| 157 | simpa only [neg_neg] using h |
| 158 | |
| 159 | end PoincareMT.SingularRegularLimit |