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.Tactic.FieldSimp |
| 3 | import Mathlib.Tactic.Linarith |
| 4 | import Mathlib.Tactic.Ring |
| 5 | import PoincareLib.Analysis.Calculus.Nonnegative |
| 6 | import PoincareLib.Geometry.RicciFlow.Pinching.Barrier |
| 7 | import PoincareLib.Geometry.RicciFlow.Pinching.Reaction |
| 8 | |
| 9 | /-! |
| 10 | # Invariance of the Hamilton--Ivey reaction barrier |
| 11 | |
| 12 | This module supplies the one-dimensional fencing argument for the ordered |
| 13 | curvature reaction equations. The horizontal comparison uses the trace |
| 14 | reaction inequality, while the logarithmic comparison uses |
| 15 | `pinchingReactionBarrier` at a boundary contact. |
| 16 | |
| 17 | Reference: Morgan--Tian, Claims 4.30--4.31, pp. 78--79. |
| 18 | -/ |
| 19 | |
| 20 | namespace Poincare.HamiltonIvey |
| 21 | |
| 22 | open Set |
| 23 | open scoped Topology |
| 24 | |
| 25 | |
| 26 | private theorem trace_reaction_lower_bound {lam mu nu : ℝ} : |
| 27 | 2 * (lam + mu + nu) ^ 2 / 3 ≤ |
| 28 | (lam ^ 2 + mu * nu) + (mu ^ 2 + lam * nu) + (nu ^ 2 + lam * mu) := by |
| 29 | nlinarith [sq_nonneg (lam - mu), sq_nonneg (mu - nu), sq_nonneg (lam - nu)] |
| 30 | |
| 31 | private theorem horizontal_boundary_strict |
| 32 | {t : ℝ} (ht : 0 ≤ t) {lam mu nu dS : ℝ} |
| 33 | (hS : lam + mu + nu = -3 / (1 + t)) |
| 34 | (hdS : dS = (lam ^ 2 + mu * nu) + (mu ^ 2 + lam * nu) + |
| 35 | (nu ^ 2 + lam * mu)) : |
| 36 | 3 / (1 + t) ^ 2 < dS := by |
| 37 | have hden : 0 < 1 + t := by linarith |
| 38 | have htrace := trace_reaction_lower_bound (lam := lam) (mu := mu) (nu := nu) |
| 39 | rw [hS] at htrace |
| 40 | rw [hdS] |
| 41 | have hp : 0 < 3 / (1 + t) ^ 2 := by positivity |
| 42 | have hsq : 2 * (-3 / (1 + t)) ^ 2 / 3 = 6 / (1 + t) ^ 2 := by |
| 43 | field_simp |
| 44 | ring |
| 45 | rw [hsq] at htrace |
| 46 | have hden2 : 0 < (1 + t) ^ 2 := sq_pos_of_pos hden |
| 47 | have htrace' := (div_le_iff₀ hden2).mp htrace |
| 48 | apply (div_lt_iff₀ hden2).2 |
| 49 | nlinarith |
| 50 | |
| 51 | /-- Horizontal scalar lower bound for an ordered reaction trajectory. |
| 52 | |
| 53 | The right derivative hypotheses are stated on `Ico a b`, which is the form |
| 54 | accepted by Mathlib's fencing theorem and includes the initial endpoint. |
| 55 | -/ |
| 56 | theorem reaction_trace_lower_bound |
| 57 | {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) |
| 58 | {lam mu nu S : ℝ → ℝ} |
| 59 | (hScont : ContinuousOn S (Icc a b)) |
| 60 | (hSval : ∀ t ∈ Icc a b, S t = lam t + mu t + nu t) |
| 61 | (hderiv : ∀ t ∈ Ico a b, HasDerivWithinAt S |
| 62 | ((lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 63 | (nu t ^ 2 + lam t * mu t)) (Ici t) t) |
| 64 | (hinit : -3 / (1 + a) ≤ S a) : |
| 65 | ∀ t ∈ Icc a b, -3 / (1 + t) ≤ S t := by |
| 66 | let r : ℝ → ℝ := fun t => -3 / (1 + t) |
| 67 | have hr {t : ℝ} (ht : 0 ≤ t) : HasDerivAt r (3 / (1 + t) ^ 2) t := by |
| 68 | have hden : HasDerivAt (fun s : ℝ => 1 + s) 1 t := by |
| 69 | simpa only [id_eq, add_comm] using (hasDerivAt_id t).const_add 1 |
| 70 | change HasDerivAt (fun s : ℝ => -3 / (1 + s)) (3 / (1 + t) ^ 2) t |
| 71 | have hder := (hasDerivAt_const t (-3)).div hden (by linarith) |
| 72 | have hfun : (fun _ : ℝ => (-3 : ℝ)) / (fun s : ℝ => 1 + s) = |
| 73 | (fun s => -3 / (1 + s)) := by |
| 74 | funext s |
| 75 | simp only [Pi.div_apply] |
| 76 | rw [hfun] at hder |
| 77 | have hval : (0 * (1 + t) - (-3) * 1) / (1 + t) ^ 2 = |
| 78 | 3 / (1 + t) ^ 2 := by ring |
| 79 | rw [hval] at hder |
| 80 | exact hder |
| 81 | have hrcont : ContinuousOn r (Icc a b) := by |
| 82 | apply ContinuousOn.div continuousOn_const |
| 83 | · fun_prop |
| 84 | · intro t ht |
| 85 | linarith [ha, ht.1] |
| 86 | have hbound : ∀ t ∈ Ico a b, r t = S t → |
| 87 | 3 / (1 + t) ^ 2 < |
| 88 | (lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 89 | (nu t ^ 2 + lam t * mu t) := by |
| 90 | intro t ht hEq |
| 91 | apply horizontal_boundary_strict (ht := ha.trans ht.1) |
| 92 | · have hsum := hSval t ⟨ht.1, ht.2.le⟩ |
| 93 | simpa [r] using (hEq.trans hsum).symm |
| 94 | · rfl |
| 95 | have hle := image_le_of_deriv_right_lt_deriv_boundary' |
| 96 | (f := r) (f' := fun t => 3 / (1 + t) ^ 2) |
| 97 | (B := S) (B' := fun t => |
| 98 | (lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 99 | (nu t ^ 2 + lam t * mu t)) |
| 100 | hrcont |
| 101 | (fun t ht => (hr (ha.trans ht.1)).hasDerivWithinAt) |
| 102 | (by simpa [r] using hinit) |
| 103 | hScont |
| 104 | (fun t ht => hderiv t ht) |
| 105 | hbound |
| 106 | intro t ht |
| 107 | exact hle ht |
| 108 | |
| 109 | private theorem logBarrier_comp_deriv |
| 110 | {X : ℝ → ℝ} {t dX : ℝ} (ht : 0 ≤ t) (hX : 0 < X t) |
| 111 | (hXd : HasDerivAt X dX t) : |
| 112 | HasDerivAt (fun s => logBarrier s (X s)) |
| 113 | (dX * (Real.log (X t) + Real.log (1 + t) - 2) + X t / (1 + t)) t := by |
| 114 | have hlog : HasDerivAt (fun s => Real.log (X s)) (dX / X t) t := |
| 115 | (hXd.log (ne_of_gt hX)) |
| 116 | have htime : HasDerivAt (fun s => Real.log (1 + s)) (1 / (1 + t)) t := by |
| 117 | have hden : HasDerivAt (fun s : ℝ => 1 + s) 1 t := by |
| 118 | simpa only [id_eq, add_comm] using (hasDerivAt_id t).const_add 1 |
| 119 | have hder := |
| 120 | (Real.hasDerivAt_log (x := 1 + t) (by linarith : (1 + t) ≠ 0)).comp t hden |
| 121 | have hfun : Real.log ∘ (fun s : ℝ => 1 + s) = |
| 122 | (fun s => Real.log (1 + s)) := by |
| 123 | funext s |
| 124 | rfl |
| 125 | rw [hfun] at hder |
| 126 | have hval : (1 + t)⁻¹ * 1 = 1 / (1 + t) := by simp [one_div] |
| 127 | rw [hval] at hder |
| 128 | exact hder |
| 129 | have hprod := hXd.mul ((hlog.add htime).sub_const 3) |
| 130 | change HasDerivAt (X * (fun s => Real.log (X s) + Real.log (1 + s) - 3)) _ t |
| 131 | have hprod' : HasDerivAt (X * (fun s => |
| 132 | Real.log (X s) + Real.log (1 + s) - 3)) |
| 133 | (dX * (Real.log (X t) + Real.log (1 + t) - 3) + |
| 134 | X t * (dX / X t + 1 / (1 + t))) t := by |
| 135 | exact hprod |
| 136 | convert hprod' using 1 <;> field_simp [ne_of_gt hX] <;> ring |
| 137 | |
| 138 | private theorem logarithmic_boundary_strict |
| 139 | {t : ℝ} (ht : 0 ≤ t) {lam mu nu S X : ℝ → ℝ} {dS dX : ℝ} |
| 140 | (hmu : mu t ≤ lam t) (hnu : nu t ≤ mu t) |
| 141 | (hXval : X t = -nu t) (hSval : S t = lam t + mu t + nu t) |
| 142 | (hS : HasDerivAt S dS t) (hX : HasDerivAt X dX t) |
| 143 | (hdS : dS = (lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 144 | (nu t ^ 2 + lam t * mu t)) |
| 145 | (hdX : dX = -(nu t) ^ 2 - mu t * lam t) |
| 146 | (hXpos : 0 < X t) (hcutX : cutoff t ≤ X t) |
| 147 | (hEq : logBarrier t (X t) = S t) : |
| 148 | deriv (fun s => logBarrier s (X s)) t < deriv S t := by |
| 149 | have hXfirst : 1 / (1 + t) < X t := |
| 150 | (cutoff_gt_first ht).trans_le hcutX |
| 151 | have hbar := pinchingReactionBarrier |
| 152 | (lam := lam t) (mu := mu t) (nu := nu t) (S := S) (X := X) |
| 153 | hmu hnu hXval hSval hS hX (by |
| 154 | rw [hXval] |
| 155 | nlinarith [hdS]) (by |
| 156 | rw [hXval] |
| 157 | nlinarith [hdX]) hXpos |
| 158 | have hW : X t ≤ deriv (fun s => S s / X s - Real.log (X s)) t := hbar |
| 159 | have hW' := ((hS.div hX (ne_of_gt hXpos)).sub |
| 160 | (hX.log (ne_of_gt hXpos))).deriv |
| 161 | change X t ≤ deriv (S / X - fun y => Real.log (X y)) t at hW |
| 162 | rw [hW'] at hW |
| 163 | have hF := logBarrier_comp_deriv ht hXpos hX |
| 164 | rw [hF.deriv] |
| 165 | rw [hS.deriv] |
| 166 | have hden : 0 < X t := hXpos |
| 167 | have htime : 0 < 1 + t := by linarith |
| 168 | have hstrict : 1 / (1 + t) < X t := hXfirst |
| 169 | have hEq' : S t = X t * (Real.log (X t) + Real.log (1 + t) - 3) := by |
| 170 | simpa [logBarrier] using hEq.symm |
| 171 | have hW'' : X t ≤ |
| 172 | (X t * dS - (S t + X t) * dX) / X t ^ 2 := by |
| 173 | calc |
| 174 | X t ≤ (dS * X t - S t * dX) / X t ^ 2 - dX / X t := hW |
| 175 | _ = (X t * dS - (S t + X t) * dX) / X t ^ 2 := by |
| 176 | field_simp [ne_of_gt hXpos] |
| 177 | ring |
| 178 | have hWmul : X t ^ 3 ≤ X t * dS - (S t + X t) * dX := by |
| 179 | simpa [pow_succ, mul_assoc, mul_left_comm, mul_comm] using |
| 180 | (le_div_iff₀ (sq_pos_of_pos hXpos)).mp hW'' |
| 181 | have hWdiv : X t ^ 2 ≤ |
| 182 | (X t * dS - (S t + X t) * dX) / X t := by |
| 183 | apply (le_div_iff₀ hXpos).2 |
| 184 | simpa [pow_succ, mul_assoc, mul_left_comm, mul_comm] using hWmul |
| 185 | have hWlin : X t ^ 2 ≤ dS - |
| 186 | (Real.log (X t) + Real.log (1 + t) - 2) * dX := by |
| 187 | calc |
| 188 | X t ^ 2 ≤ (X t * dS - (S t + X t) * dX) / X t := hWdiv |
| 189 | _ = dS - (Real.log (X t) + Real.log (1 + t) - 2) * dX := by |
| 190 | rw [hEq'] |
| 191 | field_simp [ne_of_gt hXpos] |
| 192 | ring |
| 193 | have hXsq : X t / (1 + t) < X t ^ 2 := by |
| 194 | apply (div_lt_iff₀ htime).2 |
| 195 | have hmul : 1 < X t * (1 + t) := (div_lt_iff₀ htime).mp hstrict |
| 196 | have hprodpos : 0 < X t * (X t * (1 + t) - 1) := |
| 197 | mul_pos hXpos (sub_pos.mpr hmul) |
| 198 | nlinarith |
| 199 | linarith |
| 200 | |
| 201 | /-! The following theorem is the logarithmic branch of the carrier argument. |
| 202 | The separate trace theorem above handles the complementary horizontal branch. |
| 203 | -/ |
| 204 | |
| 205 | /-- The ordered reaction equations preserve the scalar carrier while the |
| 206 | trajectory stays on the logarithmic branch `cutoff t ≤ X t`. -/ |
| 207 | theorem reaction_log_branch_invariance |
| 208 | {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) |
| 209 | {lam mu nu S X : ℝ → ℝ} |
| 210 | (hScont : ContinuousOn S (Icc a b)) |
| 211 | (hFcont : ContinuousOn (fun t => logBarrier t (X t)) (Icc a b)) |
| 212 | (hSval : ∀ t ∈ Icc a b, S t = lam t + mu t + nu t) |
| 213 | (hXval : ∀ t ∈ Icc a b, X t = -nu t) |
| 214 | (hord : ∀ t ∈ Icc a b, mu t ≤ lam t ∧ nu t ≤ mu t) |
| 215 | (hSderiv : ∀ t ∈ Ico a b, HasDerivAt S |
| 216 | ((lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 217 | (nu t ^ 2 + lam t * mu t)) t) |
| 218 | (hXderiv : ∀ t ∈ Ico a b, HasDerivAt X |
| 219 | (-(nu t) ^ 2 - mu t * lam t) t) |
| 220 | (hcut : ∀ t ∈ Icc a b, cutoff t ≤ X t) |
| 221 | (hinit : (S a, X a) ∈ scalarRegion a) : |
| 222 | ∀ t ∈ Icc a b, (S t, X t) ∈ scalarRegion t := by |
| 223 | have htrace : ∀ t ∈ Icc a b, -3 / (1 + t) ≤ S t := by |
| 224 | apply reaction_trace_lower_bound ha hab hScont hSval |
| 225 | · intro t ht |
| 226 | exact (hSderiv t ht).hasDerivWithinAt |
| 227 | · change -3 / (1 + a) ≤ S a ∧ _ at hinit |
| 228 | exact hinit.1 |
| 229 | have hFle : ∀ t ∈ Icc a b, logBarrier t (X t) ≤ S t := by |
| 230 | have haF : logBarrier a (X a) ≤ S a := by |
| 231 | have hm := (mem_scalarRegion_iff ha).mp hinit |
| 232 | simpa [clippedBarrier, max_eq_right (hcut a ⟨le_rfl, hab⟩)] using hm |
| 233 | have hbound : ∀ t ∈ Ico a b, |
| 234 | logBarrier t (X t) = S t → |
| 235 | (-(nu t) ^ 2 - mu t * lam t) * |
| 236 | (Real.log (X t) + Real.log (1 + t) - 2) + X t / (1 + t) < |
| 237 | ((lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 238 | (nu t ^ 2 + lam t * mu t)) := by |
| 239 | intro t ht hEq |
| 240 | rcases hord t ⟨ht.1, ht.2.le⟩ with ⟨hmu, hnu⟩ |
| 241 | have hb := logarithmic_boundary_strict (ha.trans ht.1) hmu hnu |
| 242 | (hXval t ⟨ht.1, ht.2.le⟩) (hSval t ⟨ht.1, ht.2.le⟩) |
| 243 | (hSderiv t ht) (hXderiv t ht) rfl rfl |
| 244 | ((cutoff_pos (ha.trans ht.1)).trans_le (hcut t ⟨ht.1, ht.2.le⟩)) |
| 245 | (hcut t ⟨ht.1, ht.2.le⟩) |
| 246 | hEq |
| 247 | rw [(logBarrier_comp_deriv (ha.trans ht.1) |
| 248 | ((cutoff_pos (ha.trans ht.1)).trans_le (hcut t ⟨ht.1, ht.2.le⟩)) |
| 249 | (hXderiv t ht)).deriv, (hSderiv t ht).deriv] at hb |
| 250 | exact hb |
| 251 | exact image_le_of_deriv_right_lt_deriv_boundary' |
| 252 | (f := fun t => logBarrier t (X t)) |
| 253 | (f' := fun t => (-(nu t) ^ 2 - mu t * lam t) * |
| 254 | (Real.log (X t) + Real.log (1 + t) - 2) + X t / (1 + t)) |
| 255 | (B := S) |
| 256 | (B' := fun t => |
| 257 | (lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 258 | (nu t ^ 2 + lam t * mu t)) |
| 259 | hFcont |
| 260 | (fun t ht => (logBarrier_comp_deriv (ha.trans ht.1) |
| 261 | ((cutoff_pos (ha.trans ht.1)).trans_le (hcut t ⟨ht.1, ht.2.le⟩)) |
| 262 | (hXderiv t ht)).hasDerivWithinAt) |
| 263 | haF hScont (fun t ht => (hSderiv t ht).hasDerivWithinAt) hbound |
| 264 | intro t ht |
| 265 | rw [mem_scalarRegion_iff (ha.trans ht.1)] |
| 266 | rw [clippedBarrier, max_eq_right (hcut t ht)] |
| 267 | exact hFle t ht |
| 268 | |
| 269 | private theorem reaction_trace_lower_bound_interior |
| 270 | {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) |
| 271 | {lam mu nu S : ℝ → ℝ} |
| 272 | (hScont : ContinuousOn S (Icc a b)) |
| 273 | (hSval : ∀ t ∈ Icc a b, S t = lam t + mu t + nu t) |
| 274 | (hderiv : ∀ t ∈ Ioo a b, HasDerivAt S |
| 275 | ((lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 276 | (nu t ^ 2 + lam t * mu t)) t) |
| 277 | (hinit : -3 / (1 + a) ≤ S a) : |
| 278 | ∀ t ∈ Icc a b, -3 / (1 + t) ≤ S t := by |
| 279 | have hZ := Poincare.nonneg_of_deriv_pos_on_neg hab |
| 280 | (f := fun t => (1 + t) * S t + 3) |
| 281 | ((continuousOn_const.add continuousOn_id).mul hScont |>.add continuousOn_const) |
| 282 | (by have := (div_le_iff₀ (by linarith : 0 < 1 + a)).mp hinit |
| 283 | nlinarith) |
| 284 | (by |
| 285 | intro t ht hneg |
| 286 | let dS := (lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 287 | (nu t ^ 2 + lam t * mu t) |
| 288 | have htime : 0 < 1 + t := by linarith [ht.1] |
| 289 | have hSt : S t < 0 := by nlinarith |
| 290 | have htrace : 2 * S t ^ 2 / 3 ≤ dS := by |
| 291 | rw [hSval t (Ioo_subset_Icc_self ht)] |
| 292 | exact trace_reaction_lower_bound |
| 293 | refine ⟨1 * S t + (1 + t) * dS + 0, ?_, ?_⟩ |
| 294 | · simpa using (((hasDerivAt_id t).const_add 1).mul (hderiv t ht)).add_const 3 |
| 295 | · have hscaled := mul_le_mul_of_nonneg_left htrace htime.le |
| 296 | have hprod := mul_pos (neg_pos.mpr hSt) (neg_pos.mpr hneg) |
| 297 | nlinarith) |
| 298 | intro t ht |
| 299 | apply (div_le_iff₀ (by linarith [ht.1] : 0 < 1 + t)).mpr |
| 300 | nlinarith [hZ t ht] |
| 301 | |
| 302 | private theorem normalized_barrier_nonneg_iff {t s y : ℝ} (hy : 0 < y) : |
| 303 | 0 ≤ s / y - Real.log y - Real.log (1 + t) + 3 ↔ logBarrier t y ≤ s := by |
| 304 | rw [logBarrier] |
| 305 | constructor |
| 306 | · intro h |
| 307 | have := (le_div_iff₀ hy).mp |
| 308 | (show Real.log y + Real.log (1 + t) - 3 ≤ s / y by linarith) |
| 309 | nlinarith |
| 310 | · intro h |
| 311 | have := (le_div_iff₀ hy).mpr |
| 312 | (show (Real.log y + Real.log (1 + t) - 3) * y ≤ s by nlinarith) |
| 313 | linarith |
| 314 | |
| 315 | /-- The ordered curvature reaction equations preserve the Hamilton--Ivey scalar |
| 316 | region on a closed time interval. Only interior derivatives are assumed. |
| 317 | |
| 318 | Reference: Morgan--Tian, Claim 4.30, pp. 78--79. |
| 319 | -/ |
| 320 | theorem reaction_invariance |
| 321 | {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) |
| 322 | {lam mu nu : ℝ → ℝ} |
| 323 | (hlam : ContinuousOn lam (Set.Icc a b)) |
| 324 | (hmu : ContinuousOn mu (Set.Icc a b)) |
| 325 | (hnu : ContinuousOn nu (Set.Icc a b)) |
| 326 | (hord : ∀ t ∈ Set.Icc a b, mu t ≤ lam t ∧ nu t ≤ mu t) |
| 327 | (hdlam : ∀ t ∈ Set.Ioo a b, |
| 328 | HasDerivAt lam (lam t ^ 2 + mu t * nu t) t) |
| 329 | (hdmu : ∀ t ∈ Set.Ioo a b, |
| 330 | HasDerivAt mu (mu t ^ 2 + lam t * nu t) t) |
| 331 | (hdnu : ∀ t ∈ Set.Ioo a b, |
| 332 | HasDerivAt nu (nu t ^ 2 + lam t * mu t) t) |
| 333 | (hinit : (lam a + mu a + nu a, max (-nu a) 0) ∈ scalarRegion a) : |
| 334 | ∀ t ∈ Set.Icc a b, |
| 335 | (lam t + mu t + nu t, max (-nu t) 0) ∈ scalarRegion t := by |
| 336 | let S : ℝ → ℝ := fun t => lam t + mu t + nu t |
| 337 | let X : ℝ → ℝ := fun t => -nu t |
| 338 | let Y : ℝ → ℝ := fun t => max (cutoff t) (X t) |
| 339 | let W : ℝ → ℝ := fun t => S t / Y t - Real.log (Y t) - Real.log (1 + t) + 3 |
| 340 | have htime : ∀ t ∈ Icc a b, 0 < 1 + t := by |
| 341 | intro t ht |
| 342 | linarith [ht.1] |
| 343 | have hSc : ContinuousOn S (Icc a b) := (hlam.add hmu).add hnu |
| 344 | have hXc : ContinuousOn X (Icc a b) := hnu.neg |
| 345 | have hSd : ∀ t ∈ Ioo a b, HasDerivAt S |
| 346 | ((lam t ^ 2 + mu t * nu t) + (mu t ^ 2 + lam t * nu t) + |
| 347 | (nu t ^ 2 + lam t * mu t)) t := |
| 348 | fun t ht => ((hdlam t ht).add (hdmu t ht)).add (hdnu t ht) |
| 349 | have htrace : ∀ t ∈ Icc a b, -3 / (1 + t) ≤ S t := |
| 350 | reaction_trace_lower_bound_interior ha hab hSc (fun _ _ => rfl) hSd hinit.1 |
| 351 | have hcutc : ContinuousOn cutoff (Icc a b) := |
| 352 | continuousOn_const.div (continuousOn_const.add continuousOn_id) |
| 353 | (fun t ht => (htime t ht).ne') |
| 354 | have hYc : ContinuousOn Y (Icc a b) := hcutc.sup hXc |
| 355 | have hYpos : ∀ t ∈ Icc a b, 0 < Y t := fun t ht => |
| 356 | (cutoff_pos (ha.trans ht.1)).trans_le (le_max_left _ _) |
| 357 | have hWc : ContinuousOn W (Icc a b) := |
| 358 | (((hSc.div hYc (fun t ht => (hYpos t ht).ne')).sub |
| 359 | (hYc.log (fun t ht => (hYpos t ht).ne'))).sub |
| 360 | ((continuousOn_const.add continuousOn_id).log |
| 361 | (fun t ht => (htime t ht).ne'))).add continuousOn_const |
| 362 | have hWiff : ∀ t ∈ Icc a b, |
| 363 | 0 ≤ W t ↔ (S t, max (X t) 0) ∈ scalarRegion t := by |
| 364 | intro t ht |
| 365 | rw [mem_scalarRegion_iff (ha.trans ht.1)] |
| 366 | have hmax : max (cutoff t) (max (X t) 0) = Y t := by |
| 367 | rw [← max_assoc, max_eq_left (hYpos t ht).le] |
| 368 | simpa only [W, clippedBarrier, hmax] using |
| 369 | normalized_barrier_nonneg_iff (s := S t) (t := t) (hYpos t ht) |
| 370 | have hWa : 0 ≤ W a := (hWiff a ⟨le_rfl, hab⟩).mpr hinit |
| 371 | have hWnonneg := Poincare.nonneg_of_deriv_pos_on_neg hab hWc hWa (by |
| 372 | intro t ht hneg |
| 373 | have htcc := Ioo_subset_Icc_self ht |
| 374 | have ht0 : 0 ≤ t := ha.trans htcc.1 |
| 375 | have hcutlt : cutoff t < X t := by |
| 376 | by_contra h |
| 377 | have hYeq : Y t = cutoff t := max_eq_left (le_of_not_gt h) |
| 378 | have hbar : logBarrier t (Y t) ≤ S t := by |
| 379 | rw [hYeq, (cutoff_spec ht0).2.1] |
| 380 | exact htrace t htcc |
| 381 | exact (not_le_of_gt hneg) |
| 382 | ((normalized_barrier_nonneg_iff (hYpos t htcc)).mpr hbar) |
| 383 | have hYeq : Y t = -nu t := max_eq_right hcutlt.le |
| 384 | have hlocal : Y =ᶠ[𝓝 t] X := by |
| 385 | have hlt := (hcutc.continuousAt (Icc_mem_nhds ht.1 ht.2)).eventually_lt |
| 386 | (hXc.continuousAt (Icc_mem_nhds ht.1 ht.2)) hcutlt |
| 387 | filter_upwards [hlt] with s hs using max_eq_right hs.le |
| 388 | have hYd : HasDerivAt Y (-(nu t ^ 2 + lam t * mu t)) t := |
| 389 | (hdnu t ht).neg.congr_of_eventuallyEq hlocal |
| 390 | have hD := ((hSd t ht).div hYd (hYpos t htcc).ne').sub |
| 391 | (hYd.log (hYpos t htcc).ne') |
| 392 | have hlogtime : HasDerivAt (fun s : ℝ => Real.log (1 + s)) |
| 393 | (1 / (1 + t)) t := by |
| 394 | simpa using ((hasDerivAt_id t).const_add 1).log (htime t htcc).ne' |
| 395 | have hbar := pinchingReactionBarrier (hord t htcc).1 (hord t htcc).2 |
| 396 | hYeq (show S t = lam t + mu t + nu t from rfl) (hSd t ht) hYd |
| 397 | (by rw [hYeq]; ring) (by rw [hYeq]; ring) (hYpos t htcc) |
| 398 | have hfirst : 1 / (1 + t) < Y t := |
| 399 | (cutoff_spec ht0).1.trans_le (le_max_left _ _) |
| 400 | change Y t ≤ deriv (S / Y - fun s => Real.log (Y s)) t at hbar |
| 401 | rw [hD.deriv] at hbar |
| 402 | exact ⟨_, (hD.sub hlogtime).add_const 3, by linarith⟩) |
| 403 | intro t ht |
| 404 | exact (hWiff t ht).mp (hWnonneg t ht) |
| 405 | |
| 406 | end Poincare.HamiltonIvey |