Navier–Stokes: the Lean blow-up proof, cleaned up together
OpenAI's 2026 Lean proofs of blowup for forced Navier–Stokes and Euler, rerun by others, not refereed, no ruling from Clay; cleaned up together: more readable, faster to build

| 1 | import NavierStokes.PulseLag |
| 2 | import NavierStokes.OutgoingHistories |
| 3 | import NavierStokes.OutgoingEntranceCone |
| 4 | import NavierStokes.PulseEnergyHistory |
| 5 | import NavierStokes.ShapedWaitBounds |
| 6 | |
| 7 | /-! |
| 8 | # The actual pulse contribution to the outgoing stress cone |
| 9 | |
| 10 | The endpoint lower bound, pulse stress expansions, and numerical cone |
| 11 | margins are derived from the actual corrected fields and their histories. |
| 12 | One small-parameter threshold preserves every prechosen reset witness. |
| 13 | -/ |
| 14 | |
| 15 | noncomputable section |
| 16 | |
| 17 | namespace NavierStokes.PulseCone |
| 18 | |
| 19 | open Set Filter MeasureTheory |
| 20 | open scoped Topology ContDiff |
| 21 | open OutgoingSchedule OutgoingPulseBounds PulseLag |
| 22 | |
| 23 | noncomputable def forceConstant (P m : ℝ) : ℝ := mainBound + correctionJetBound P m 0 |
| 24 | |
| 25 | theorem forceConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : 0 < forceConstant P m := |
| 26 | add_pos mainBound_pos (correctionJetBound_pos hP m 0) |
| 27 | |
| 28 | theorem forcing_abs_le (c : Parameters) (hsmall : c.lam ≤ 1 / 120) (q A y : ℝ) : |
| 29 | |forcing c q A y| ≤ forceConstant c.P c.m * (|q| + |A|) := by |
| 30 | have hc := affineProfile_jet_bound c hsmall q A 0 y |
| 31 | simp only [iteratedDeriv_zero] at hc |
| 32 | have he : Real.exp (-(1 / (4 * c.lam))) ≤ 1 := |
| 33 | Real.exp_le_one_iff.mpr (neg_nonpos.mpr (by have hp := c.lam_pos; positivity)) |
| 34 | have hc' : |affineProfile c q A y| ≤ correctionJetBound c.P c.m 0 * (|q| + |A|) := by |
| 35 | refine hc.trans ?_ |
| 36 | have h := mul_le_mul_of_nonneg_right |
| 37 | (mul_le_mul_of_nonneg_left he (correctionJetBound_pos c.P_pos c.m 0).le) (by positivity : 0 ≤ |q| + |A|) |
| 38 | simpa only [mul_one] using h |
| 39 | have hm : |A * mainPulse (c.lam * y)| ≤ mainBound * |A| := by |
| 40 | rw [abs_mul] |
| 41 | nlinarith [mul_le_mul_of_nonneg_left (mainPulse_abs_le (c.lam * y)) (abs_nonneg A)] |
| 42 | calc |
| 43 | _ ≤ |A * mainPulse (c.lam * y)| + |affineProfile c q A y| := abs_add_le _ _ |
| 44 | _ ≤ mainBound * |A| + correctionJetBound c.P c.m 0 * (|q| + |A|) := add_le_add hm hc' |
| 45 | _ ≤ _ := by dsimp [forceConstant]; nlinarith [mul_nonneg mainBound_pos.le (abs_nonneg q)] |
| 46 | |
| 47 | theorem initial_coefficient_le (c : Parameters) |
| 48 | (hwait : c.wait = 60 * Real.log (1 / c.lam)) (hsmall : c.lam ≤ 1 / 120) : |
| 49 | |prefixCoefficient c 0| ≤ prefixBound c.P c.m 0 := by |
| 50 | apply (prefixCoefficient_small c hwait hsmall 0).trans |
| 51 | have hp : c.lam ^ 29 ≤ 1 := pow_le_one₀ c.lam_pos.le (by linarith [c.lam_lt]) |
| 52 | simpa only [mul_one] using mul_le_mul_of_nonneg_left hp (prefixBound_pos c.P_pos c.m 0).le |
| 53 | |
| 54 | theorem decay_div_le_three (c : Parameters) {M : ℝ} (hM : 0 ≤ M) : |
| 55 | M / decay c ≤ 3 * M := by |
| 56 | have hd : (2 / 5 : ℝ) ≤ decay c := by dsimp [decay]; linarith [c.lam_lt] |
| 57 | apply (div_le_iff₀ (decay_pos c)).mpr |
| 58 | nlinarith [mul_nonneg hM (show 0 ≤ 3 * decay c - 1 by linarith)] |
| 59 | |
| 60 | theorem affineLag_abs_le (c : Parameters) |
| 61 | (hwait : c.wait = 60 * Real.log (1 / c.lam)) (hsmall : c.lam ≤ 1 / 120) |
| 62 | (q A : ℝ) {y : ℝ} (hy : 0 ≤ y) : |
| 63 | |affineLag c q A y| ≤ prefixBound c.P c.m 0 * |q| + |
| 64 | 3 * forceConstant c.P c.m * (|q| + |A|) := by |
| 65 | have hB : 0 ≤ forceConstant c.P c.m * (|q| + |A|) := |
| 66 | mul_nonneg (forceConstant_pos c.P_pos c.m).le (by positivity) |
| 67 | have hc := convolution_abs_le (decay_pos c) hB hy (forcing_contDiff c q A).continuous |
| 68 | (fun t _ => forcing_abs_le c hsmall q A t) |
| 69 | have hc' := hc.trans (decay_div_le_three c hB) |
| 70 | have he : Real.exp (-decay c * y) ≤ 1 := |
| 71 | Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (decay_pos c).le) hy) |
| 72 | have hp : |(prefixCoefficient c 0 * q) * Real.exp (-decay c * y)| ≤ |
| 73 | prefixBound c.P c.m 0 * |q| := by |
| 74 | rw [abs_mul, abs_mul, abs_of_pos (Real.exp_pos _)] |
| 75 | have h := mul_le_mul (mul_le_mul_of_nonneg_right (initial_coefficient_le c hwait hsmall) (abs_nonneg q)) |
| 76 | he (Real.exp_pos _).le (mul_nonneg (prefixBound_pos c.P_pos c.m 0).le (abs_nonneg q)) |
| 77 | simpa only [mul_one] using h |
| 78 | calc |
| 79 | _ ≤ |(prefixCoefficient c 0 * q) * Real.exp (-decay c * y)| + |
| 80 | |convolution (decay c) (forcing c q A) y| := abs_add_le _ _ |
| 81 | _ ≤ prefixBound c.P c.m 0 * |q| + 3 * (forceConstant c.P c.m * (|q| + |A|)) := |
| 82 | add_le_add hp hc' |
| 83 | _ = _ := by ring |
| 84 | |
| 85 | noncomputable def averageConstant (P m : ℝ) : ℝ := 4 * prefixBound P m 0 + 18 * forceConstant P m |
| 86 | |
| 87 | theorem averageConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : 0 < averageConstant P m := by |
| 88 | have hp := prefixBound_pos hP m 0 |
| 89 | have hf := forceConstant_pos hP m |
| 90 | dsimp [averageConstant] |
| 91 | linarith |
| 92 | |
| 93 | /-- Uniform bounds for the actual pulse ratio, normalized mass history, |
| 94 | and its first parameter derivative. -/ |
| 95 | theorem pulse_data_bounds (c : Parameters) |
| 96 | (hwait : c.wait = 60 * Real.log (1 / c.lam)) (hsmall : c.lam ≤ 1 / 120) |
| 97 | {amp : ℝ → ℝ} {eta amp' : ℝ} (ha : HasDerivAt amp amp' eta) |
| 98 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |amp'| ≤ 1) |
| 99 | {y : ℝ} (hy : 0 ≤ y) : |
| 100 | |pulseRatio c amp (y, eta)| ≤ 6 * forceConstant c.P c.m ∧ |
| 101 | |normalizedLag c amp eta y| ≤ averageConstant c.P c.m ∧ |
| 102 | |deriv (fun t => normalizedLag c amp t y) eta| ≤ averageConstant c.P c.m := by |
| 103 | have hq := parameterPolynomial_bound heta |
| 104 | have hq' : |1 + 3 * eta ^ 2| ≤ 4 := by |
| 105 | simpa only [(parameterPolynomial_hasDerivAt eta).deriv] using parameterPolynomial_derivative_bound heta |
| 106 | have hp := prefixBound_pos c.P_pos c.m 0 |
| 107 | have hf := forceConstant_pos c.P_pos c.m |
| 108 | constructor |
| 109 | · rw [← forcing_eq_pulseRatio c amp eta y] |
| 110 | apply (forcing_abs_le c hsmall _ _ y).trans |
| 111 | nlinarith [mul_le_mul_of_nonneg_left (show |parameterPolynomial eta| + |amp eta| ≤ 6 by linarith) hf.le] |
| 112 | constructor |
| 113 | · rw [normalizedLag_eq_affineLag c amp eta hy] |
| 114 | apply (affineLag_abs_le c hwait hsmall _ _ hy).trans |
| 115 | dsimp [averageConstant] |
| 116 | have hs : |parameterPolynomial eta| + |amp eta| ≤ 6 := by linarith |
| 117 | nlinarith [mul_le_mul_of_nonneg_left hq hp.le, mul_le_mul_of_nonneg_left hs hf.le] |
| 118 | · rw [(normalizedLag_eta_hasDerivAt c ha hy).deriv] |
| 119 | apply (affineLag_abs_le c hwait hsmall _ _ hy).trans |
| 120 | dsimp [averageConstant] |
| 121 | have hs : |1 + 3 * eta ^ 2| + |amp'| ≤ 6 := by linarith |
| 122 | nlinarith [mul_le_mul_of_nonneg_left hq' hp.le, mul_le_mul_of_nonneg_left hs hf.le] |
| 123 | |
| 124 | noncomputable def energyConstant (P m : ℝ) : ℝ := P * Real.exp (Real.exp m + 12) |
| 125 | |
| 126 | theorem energyConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : 0 < energyConstant P m := |
| 127 | mul_pos hP (Real.exp_pos _) |
| 128 | |
| 129 | theorem shape_le_one (eta : ℝ) : shape eta ≤ 1 := by |
| 130 | unfold shape |
| 131 | rw [← one_div] |
| 132 | apply (div_le_one (by positivity : 0 < 1 + eta ^ 2)).mpr |
| 133 | nlinarith [sq_nonneg eta] |
| 134 | |
| 135 | theorem pulse_angular_small (c : Parameters) |
| 136 | (hwait : c.wait = 60 * Real.log (1 / c.lam)) (eta : ℝ) {y : ℝ} (hy : 0 ≤ y) : |
| 137 | angular c.P c.dropLength c.lam (c.pulseStart + y, eta) ≤ |
| 138 | energyConstant c.P c.m * c.lam ^ 30 := by |
| 139 | rw [angular_pulse c eta (by linarith)] |
| 140 | have hsub : c.pulseStart + y - c.pulseStart = y := by ring |
| 141 | rw [hsub] |
| 142 | have he : Real.exp (-(1 / 2 + c.lam) * y) ≤ 1 := |
| 143 | Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg |
| 144 | (by linarith [c.lam_pos]) hy) |
| 145 | have h := mul_le_mul (mul_le_mul (pulseAmplitude_small c hwait) (shape_le_one eta) |
| 146 | (shape_pos eta).le (by have hp := c.P_pos; positivity)) he (Real.exp_pos _).le |
| 147 | (by have hp := c.P_pos; positivity) |
| 148 | simpa only [mul_one, energyConstant] using h |
| 149 | |
| 150 | noncomputable def shapeGradient (eta : ℝ) : ℝ := 2 * eta / (1 + eta ^ 2) |
| 151 | |
| 152 | theorem shapeGradient_bound {eta : ℝ} (heta : |eta| ≤ 1) : |shapeGradient eta| ≤ 2 := by |
| 153 | rw [shapeGradient, abs_div, abs_mul, abs_of_nonneg (by norm_num : (0 : ℝ) ≤ 2), |
| 154 | abs_of_pos (by positivity : 0 < 1 + eta ^ 2)] |
| 155 | apply (div_le_iff₀ (by positivity : 0 < 1 + eta ^ 2)).mpr |
| 156 | nlinarith [sq_nonneg eta] |
| 157 | |
| 158 | theorem source_remainder_bound {E lam a b c m mp R M F : ℝ} |
| 159 | (hE : 0 ≤ E) (hlam : 0 ≤ lam) (hlam' : lam ≤ 1) |
| 160 | (ha : |a| ≤ 3) (hb : |b| ≤ 1) (hc : |c| ≤ 3) |
| 161 | (hm : |m| ≤ M) (hmp : |mp| ≤ M) (hR : |R| ≤ F) : |
| 162 | |E * (-lam * (a * m + b * mp) + c * R)| ≤ E * (4 * M + 3 * F) := by |
| 163 | have hm₁ : |a * m| ≤ 3 * M := by |
| 164 | rw [abs_mul] |
| 165 | exact mul_le_mul ha hm (abs_nonneg m) (by norm_num) |
| 166 | have hm₂ : |b * mp| ≤ M := by |
| 167 | rw [abs_mul] |
| 168 | simpa only [one_mul] using mul_le_mul hb hmp (abs_nonneg mp) (by norm_num) |
| 169 | have hsum : |a * m + b * mp| ≤ 4 * M := by |
| 170 | exact (abs_add_le _ _).trans (by linarith) |
| 171 | have hterm : |-lam * (a * m + b * mp)| ≤ 4 * M := by |
| 172 | rw [abs_mul, abs_neg, abs_of_nonneg hlam] |
| 173 | have h := mul_le_mul hlam' hsum (abs_nonneg _) (by norm_num) |
| 174 | simpa only [one_mul] using h |
| 175 | have hr : |c * R| ≤ 3 * F := by |
| 176 | rw [abs_mul] |
| 177 | exact mul_le_mul hc hR (abs_nonneg R) (by norm_num) |
| 178 | rw [abs_mul, abs_of_nonneg hE] |
| 179 | exact mul_le_mul_of_nonneg_left ((abs_add_le _ _).trans (add_le_add hterm hr)) hE |
| 180 | |
| 181 | theorem geometric_coefficient_bounds {h eta : ℝ} (hh : 0 ≤ h) (hh' : h ≤ 1 / 2) |
| 182 | (heta : |eta| ≤ 1) : |
| 183 | |2 * (1 / 2 - h) * eta - (1 - eta ^ 2) * shapeGradient eta| ≤ 3 ∧ |
| 184 | |1 - eta ^ 2| ≤ 1 ∧ |2 * h * eta + (1 - eta ^ 2) * shapeGradient eta| ≤ 3 := by |
| 185 | have hs : eta ^ 2 ≤ 1 := by nlinarith [sq_abs eta, sq_le_sq₀ (abs_nonneg eta) (by norm_num : (0 : ℝ) ≤ 1) |>.mpr heta] |
| 186 | have hd : |1 - eta ^ 2| ≤ 1 := by rw [abs_of_nonneg (by linarith)]; nlinarith [sq_nonneg eta] |
| 187 | have hD : |1 / 2 - h| ≤ 1 / 2 := by rw [abs_of_nonneg (by linarith)]; linarith |
| 188 | have hg : |(1 - eta ^ 2) * shapeGradient eta| ≤ 2 := by |
| 189 | rw [abs_mul] |
| 190 | have hm := mul_le_mul hd (shapeGradient_bound heta) (abs_nonneg _) (by norm_num) |
| 191 | norm_num at hm ⊢ |
| 192 | exact hm |
| 193 | have hDeta : |2 * (1 / 2 - h) * eta| ≤ 1 := by |
| 194 | rw [abs_mul, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2)] |
| 195 | nlinarith [mul_le_mul hD heta (abs_nonneg eta) (by norm_num)] |
| 196 | have heta' : |2 * h * eta| ≤ 1 := by |
| 197 | rw [abs_mul, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2), abs_of_nonneg hh] |
| 198 | nlinarith [mul_le_mul hh' heta (abs_nonneg eta) (by norm_num)] |
| 199 | exact ⟨(abs_sub _ _).trans (by linarith), hd, (abs_add_le _ _).trans (by linarith)⟩ |
| 200 | |
| 201 | noncomputable def pulseAngularSource (c : Parameters) (h : ℝ) (amp : ℝ → ℝ) (eta y : ℝ) : ℝ := |
| 202 | let E := angular c.P c.dropLength c.lam (c.pulseStart + y, eta) |
| 203 | let R := pulseRatio c amp (y, eta) |
| 204 | let m := normalizedLag c amp eta y |
| 205 | let mp := deriv (fun t => normalizedLag c amp t y) eta |
| 206 | c.lam * (1 - 2 * (1 / 2 - h) * eta * E * m - |
| 207 | (1 - eta ^ 2) * E * (mp - shapeGradient eta * m)) - |
| 208 | h * (1 - 2 * eta * E * R) + |
| 209 | ((1 / 2 - h) * eta + (1 - eta ^ 2) * E * R) * shapeGradient eta |
| 210 | |
| 211 | theorem pulseAngularSource_error_identity (c : Parameters) (h : ℝ) (amp : ℝ → ℝ) (eta y : ℝ) : |
| 212 | pulseAngularSource c h amp eta y - (c.lam - h + (1 / 2 - h) * eta * shapeGradient eta) = |
| 213 | angular c.P c.dropLength c.lam (c.pulseStart + y, eta) * |
| 214 | (-c.lam * ((2 * (1 / 2 - h) * eta - (1 - eta ^ 2) * shapeGradient eta) * |
| 215 | normalizedLag c amp eta y + (1 - eta ^ 2) * deriv (fun t => normalizedLag c amp t y) eta) + |
| 216 | (2 * h * eta + (1 - eta ^ 2) * shapeGradient eta) * pulseRatio c amp (y, eta)) := by |
| 217 | unfold pulseAngularSource |
| 218 | ring |
| 219 | |
| 220 | noncomputable def sourceConstant (P m : ℝ) : ℝ := |
| 221 | energyConstant P m * (4 * averageConstant P m + 18 * forceConstant P m) |
| 222 | |
| 223 | theorem sourceConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : 0 < sourceConstant P m := by |
| 224 | have he := energyConstant_pos hP m |
| 225 | have ha := averageConstant_pos hP m |
| 226 | have hf := forceConstant_pos hP m |
| 227 | dsimp [sourceConstant] |
| 228 | positivity |
| 229 | |
| 230 | theorem pulseAngularSource_error_bound (c : Parameters) |
| 231 | (hwait : c.wait = 60 * Real.log (1 / c.lam)) (hsmall : c.lam ≤ 1 / 120) |
| 232 | {h : ℝ} (hh : 0 ≤ h) (hh' : h ≤ 1 / 2) |
| 233 | {amp : ℝ → ℝ} {eta amp' : ℝ} (ha : HasDerivAt amp amp' eta) |
| 234 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |amp'| ≤ 1) |
| 235 | {y : ℝ} (hy : 0 ≤ y) : |
| 236 | |pulseAngularSource c h amp eta y - (c.lam - h + (1 / 2 - h) * eta * shapeGradient eta)| ≤ |
| 237 | sourceConstant c.P c.m * c.lam ^ 30 := by |
| 238 | obtain ⟨hR, hm, hmp⟩ := pulse_data_bounds c hwait hsmall ha heta hamp hamp' hy |
| 239 | obtain ⟨hc₁, hc₂, hc₃⟩ := geometric_coefficient_bounds hh hh' heta |
| 240 | rw [pulseAngularSource_error_identity] |
| 241 | have hb := source_remainder_bound |
| 242 | (angular_pos c.P_pos c.dropLength c.lam (c.pulseStart + y, eta)).le |
| 243 | c.lam_pos.le (show c.lam ≤ 1 by linarith [c.lam_lt]) |
| 244 | hc₁ hc₂ hc₃ hm hmp hR |
| 245 | refine hb.trans ?_ |
| 246 | have hp : 0 ≤ 4 * averageConstant c.P c.m + 18 * forceConstant c.P c.m := by |
| 247 | have ha := averageConstant_pos c.P_pos c.m |
| 248 | have hf := forceConstant_pos c.P_pos c.m |
| 249 | positivity |
| 250 | have he := mul_le_mul_of_nonneg_right (pulse_angular_small c hwait eta hy) hp |
| 251 | dsimp [sourceConstant] |
| 252 | nlinarith |
| 253 | |
| 254 | theorem pulseAngularSource_lower (d : OutgoingTail.TailData) |
| 255 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 256 | (herr : sourceConstant d.core.P d.core.m * d.core.lam ^ 29 ≤ 1 / 8) |
| 257 | {amp : ℝ → ℝ} {eta amp' : ℝ} (ha : HasDerivAt amp amp' eta) |
| 258 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |amp'| ≤ 1) |
| 259 | {y : ℝ} (hy : 0 ≤ y) : |
| 260 | 3 * d.core.lam / 8 ≤ pulseAngularSource d.core d.h amp eta y := by |
| 261 | have he := pulseAngularSource_error_bound d.core hwait hsmall d.h_pos.le d.h_lt_half.le |
| 262 | ha heta hamp hamp' hy |
| 263 | have herr' := mul_le_mul_of_nonneg_right herr d.core.lam_pos.le |
| 264 | have hpow : d.core.lam ^ 29 * d.core.lam = d.core.lam ^ 30 := by ring |
| 265 | rw [mul_assoc, hpow] at herr' |
| 266 | have hg : 0 ≤ eta * shapeGradient eta := by |
| 267 | have heq : eta * shapeGradient eta = 2 * eta ^ 2 / (1 + eta ^ 2) := by |
| 268 | unfold shapeGradient |
| 269 | ring |
| 270 | rw [heq] |
| 271 | positivity |
| 272 | have hc := mul_nonneg (show 0 ≤ 1 / 2 - d.h by linarith [d.h_lt_half]) hg |
| 273 | have hlo := (abs_le.mp he).1 |
| 274 | nlinarith [d.h_small] |
| 275 | |
| 276 | /-- A lower barrier for the exact scalar lag equation on a finite interval. |
| 277 | Only the differential equation and a lower source bound are used. -/ |
| 278 | theorem ode_lower_barrier {r s L : ℝ} (hr : 0 < r) (hL : 0 ≤ L) |
| 279 | {Q S : ℝ → ℝ} |
| 280 | (hQ : ∀ t ∈ Icc (0 : ℝ) L, HasDerivAt Q (S t - r * Q t) t) |
| 281 | (hS : ∀ t ∈ Icc (0 : ℝ) L, s ≤ S t) : |
| 282 | s / r + (Q 0 - s / r) * Real.exp (-r * L) ≤ Q L := by |
| 283 | let G : ℝ → ℝ := fun t => Real.exp (r * t) * (Q t - s / r) |
| 284 | have hd (t : ℝ) (ht : t ∈ Icc (0 : ℝ) L) : |
| 285 | HasDerivAt G (Real.exp (r * t) * (S t - s)) t := by |
| 286 | convert! (((hasDerivAt_id t).const_mul r).exp).mul ((hQ t ht).sub_const (s / r)) using 1 |
| 287 | dsimp [G] |
| 288 | field_simp ; ring |
| 289 | have hcont : ContinuousOn G (Icc (0 : ℝ) L) := |
| 290 | fun t ht => (hd t ht).continuousAt.continuousWithinAt |
| 291 | have hm : MonotoneOn G (Icc (0 : ℝ) L) := |
| 292 | monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _) hcont |
| 293 | (fun t ht => (hd t (interior_subset ht)).hasDerivWithinAt) |
| 294 | (fun t ht => mul_nonneg (Real.exp_pos _).le (sub_nonneg.mpr (hS t (interior_subset ht)))) |
| 295 | have hg := hm ⟨le_rfl, hL⟩ ⟨hL, le_rfl⟩ hL |
| 296 | have hp := mul_le_mul_of_nonneg_right hg (Real.exp_pos (-r * L)).le |
| 297 | have he : Real.exp (r * L) * Real.exp (-r * L) = 1 := by |
| 298 | rw [← Real.exp_add] |
| 299 | convert! Real.exp_zero using 1 |
| 300 | ring_nf |
| 301 | dsimp [G] at hp |
| 302 | simp only [mul_zero, Real.exp_zero, one_mul] at hp |
| 303 | have hre : (Real.exp (r * L) * (Q L - s / r)) * Real.exp (-r * L) = Q L - s / r := by |
| 304 | calc |
| 305 | _ = (Real.exp (r * L) * Real.exp (-r * L)) * (Q L - s / r) := by ring |
| 306 | _ = _ := by rw [he, one_mul] |
| 307 | rw [hre] at hp |
| 308 | linarith |
| 309 | |
| 310 | theorem pulse_memory_small (c : Parameters) : |
| 311 | Real.exp (-(1 - c.lam) * c.pulseLength) ≤ 1 / 3 := by |
| 312 | have htime : 2 ≤ (1 - c.lam) * c.pulseLength := by |
| 313 | unfold Parameters.pulseLength |
| 314 | rw [← mul_div_assoc] |
| 315 | apply (le_div_iff₀ c.lam_pos).mpr |
| 316 | linarith [c.lam_lt] |
| 317 | have hex : 3 ≤ Real.exp ((1 - c.lam) * c.pulseLength) := by |
| 318 | linarith [Real.add_one_le_exp ((1 - c.lam) * c.pulseLength)] |
| 319 | have hi := one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 3) hex |
| 320 | rw [one_div, ← Real.exp_neg] at hi |
| 321 | convert! hi using 1 |
| 322 | ring_nf |
| 323 | |
| 324 | /-- The long actual pulse turns a nonnegative incoming angular lag and |
| 325 | the lower source `3*lambda/8` into the endpoint bound needed by the tail. -/ |
| 326 | theorem pulse_endpoint_lower (c : Parameters) {Q S : ℝ → ℝ} (hQ₀ : 0 ≤ Q 0) |
| 327 | (hQ : ∀ t ∈ Icc (0 : ℝ) c.pulseLength, |
| 328 | HasDerivAt Q (S t - (1 - c.lam) * Q t) t) |
| 329 | (hS : ∀ t ∈ Icc (0 : ℝ) c.pulseLength, 3 * c.lam / 8 ≤ S t) : |
| 330 | c.lam / 4 ≤ Q c.pulseLength := by |
| 331 | have hr : 0 < 1 - c.lam := by linarith [c.lam_lt] |
| 332 | have hlower := ode_lower_barrier hr c.pulseLength_pos.le hQ hS |
| 333 | have hm := pulse_memory_small c |
| 334 | have he := Real.exp_pos (-(1 - c.lam) * c.pulseLength) |
| 335 | have hpos : 0 ≤ (3 * c.lam / 8) / (1 - c.lam) := by have hl := c.lam_pos; positivity |
| 336 | have hdiv : 3 * c.lam / 8 ≤ (3 * c.lam / 8) / (1 - c.lam) := by |
| 337 | apply (le_div_iff₀ hr).mpr |
| 338 | nlinarith [c.lam_pos] |
| 339 | have hmain := mul_le_mul hdiv (show (2 / 3 : ℝ) ≤ 1 - Real.exp (-(1 - c.lam) * c.pulseLength) by linarith) |
| 340 | (by norm_num : (0 : ℝ) ≤ 2 / 3) hpos |
| 341 | have hini := mul_nonneg hQ₀ he.le |
| 342 | nlinarith |
| 343 | |
| 344 | /-! ## Binding the pulse formulas to the actual corrected histories -/ |
| 345 | |
| 346 | open OutgoingHistories |
| 347 | open OutgoingTail (TailData) |
| 348 | open UniformAngularReset (ResetWitness) |
| 349 | |
| 350 | variable {d : TailData} {K : ℝ} |
| 351 | |
| 352 | /-- One-sided equality before the endpoint determines the true radial |
| 353 | derivative there as well, since both profiles are smooth. -/ |
| 354 | theorem E_radial_before (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 355 | (hy : y ≤ d.core.endpoint) : |
| 356 | dY (E w) (y, eta) = angular d.core.P d.core.dropLength d.core.lam (y, eta) * |
| 357 | (slope d.core.dropLength d.core.lam y - 1 / 2) := by |
| 358 | have hd := ((radialAmplitude_hasDerivAt d.core.P d.core.dropLength d.core.lam y).mul_const |
| 359 | (shape eta)).hasDerivWithinAt (s := Iic d.core.endpoint) |
| 360 | have hd' := hd.congr (fun t ht => E_before w eta ht) (E_before w eta hy) |
| 361 | have he := (uniqueDiffOn_Iic d.core.endpoint y hy).eq_deriv _ |
| 362 | (dY_hasDerivAt (E_smooth w) (y, eta)).hasDerivWithinAt hd' |
| 363 | calc |
| 364 | _ = (radialAmplitude d.core.P d.core.dropLength d.core.lam y * |
| 365 | (slope d.core.dropLength d.core.lam y - 1 / 2)) * shape eta := he |
| 366 | _ = _ := by unfold angular; ring |
| 367 | |
| 368 | theorem E_parameter_before (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 369 | (hy : y ≤ d.core.endpoint) : |
| 370 | dEta (E w) (y, eta) = E w (y, eta) * (-shapeGradient eta) := by |
| 371 | have hd := (UniformAngularReset.shape_hasDerivAt eta).const_mul |
| 372 | (radialAmplitude d.core.P d.core.dropLength d.core.lam y) |
| 373 | have hd' := hd.congr_of_eventuallyEq (Filter.Eventually.of_forall |
| 374 | (fun t => E_before w t hy)) |
| 375 | calc |
| 376 | _ = radialAmplitude d.core.P d.core.dropLength d.core.lam y * |
| 377 | (shape eta * (-(2 * eta / (1 + eta ^ 2)))) := |
| 378 | (dEta_hasDerivAt (E_smooth w) (y, eta)).unique hd' |
| 379 | _ = _ := by rw [E_before w eta hy]; unfold angular shapeGradient; ring |
| 380 | |
| 381 | theorem E_parameter_ratio_before (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 382 | (hy : y ≤ d.core.endpoint) : |
| 383 | dEta (E w) (y, eta) / E w (y, eta) = -shapeGradient eta := by |
| 384 | rw [E_parameter_before w eta hy] |
| 385 | field_simp [(E_pos w (y, eta)).ne'] |
| 386 | |
| 387 | theorem H_radial_ratio_before (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 388 | (hy : y ≤ d.core.endpoint) : |
| 389 | dY (H w) (y, eta) / H w (y, eta) = slope d.core.dropLength d.core.lam y := by |
| 390 | have hd := (((hasDerivAt_id y).div_const 2).exp).fun_mul |
| 391 | (dY_hasDerivAt (E_smooth w) (y, eta)) |
| 392 | have he := (dY_hasDerivAt (H_smooth w) (y, eta)).unique hd |
| 393 | rw [he, E_radial_before w eta hy, ← E_before w eta hy] |
| 394 | unfold H |
| 395 | dsimp only [Prod.fst, id_eq] |
| 396 | field_simp [(Real.exp_pos (y / 2)).ne', (E_pos w (y, eta)).ne'] ; ring |
| 397 | |
| 398 | theorem H_radial_ratio_pulse (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 399 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 400 | dY (H w) (d.core.pulseStart + y, eta) / H w (d.core.pulseStart + y, eta) = |
| 401 | -d.core.lam := by |
| 402 | rw [H_radial_ratio_before w eta (by dsimp [Parameters.endpoint]; linarith)] |
| 403 | apply slope_hold d.core.dropLength_pos.le |
| 404 | have hh := d.core.pulseStart_ge_hold |
| 405 | dsimp [Parameters.holdStart] at hh |
| 406 | linarith |
| 407 | |
| 408 | theorem U_pulse (w : ResetWitness d K) (amp : ℝ → ℝ) (eta : ℝ) {y : ℝ} |
| 409 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 410 | U d amp (d.core.pulseStart + y, eta) = |
| 411 | E w (d.core.pulseStart + y, eta) * pulseRatio d.core amp (y, eta) := by |
| 412 | rw [U, axial_pulse d.core amp eta (by linarith), radialPulse_exp, |
| 413 | E_before w eta (by dsimp [Parameters.endpoint]; linarith)] |
| 414 | congr 2 |
| 415 | ring_nf |
| 416 | |
| 417 | theorem Ubar_pulse (w : ResetWitness d K) (amp : ℝ → ℝ) (eta : ℝ) {y : ℝ} |
| 418 | (hy' : y ≤ d.core.pulseLength) : |
| 419 | Ubar d amp (d.core.pulseStart + y, eta) = |
| 420 | E w (d.core.pulseStart + y, eta) * normalizedLag d.core amp eta y := by |
| 421 | rw [Ubar, M_eq_massMoment, |
| 422 | E_before w eta (by dsimp [Parameters.endpoint]; linarith)] |
| 423 | unfold normalizedLag X |
| 424 | dsimp only [Prod.fst] |
| 425 | field_simp [(Real.exp_pos (d.core.pulseStart + y)).ne', |
| 426 | (angular_pos d.core.P_pos d.core.dropLength d.core.lam (d.core.pulseStart + y, eta)).ne'] |
| 427 | |
| 428 | theorem Ubar_parameter_pulse (w : ResetWitness d K) {amp : ℝ → ℝ} |
| 429 | (ha : ContDiff ℝ ∞ amp) (eta : ℝ) {y : ℝ} |
| 430 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 431 | dEta (Ubar d amp) (d.core.pulseStart + y, eta) = |
| 432 | E w (d.core.pulseStart + y, eta) * |
| 433 | (deriv (fun t => normalizedLag d.core amp t y) eta - |
| 434 | shapeGradient eta * normalizedLag d.core amp eta y) := by |
| 435 | have hn := (normalizedLag_eta_hasDerivAt d.core |
| 436 | ((ha.differentiable (by simp) eta).hasDerivAt) hy).differentiableAt.hasDerivAt |
| 437 | have hd := (dEta_hasDerivAt (E_smooth w) (d.core.pulseStart + y, eta)).mul hn |
| 438 | have hd' := hd.congr_of_eventuallyEq (Filter.Eventually.of_forall |
| 439 | (fun t => Ubar_pulse w amp t hy')) |
| 440 | have he := (dEta_hasDerivAt (Ubar_smooth d ha) (d.core.pulseStart + y, eta)).unique hd' |
| 441 | rw [he, E_parameter_before w eta (by dsimp [Parameters.endpoint]; linarith)] |
| 442 | ring |
| 443 | |
| 444 | /-- The source estimate is for the actual stress history: no source |
| 445 | formula or lag approximation is an input. -/ |
| 446 | theorem Sq_pulse (w : ResetWitness d K) {amp : ℝ → ℝ} |
| 447 | (ha : ContDiff ℝ ∞ amp) (eta : ℝ) {y : ℝ} |
| 448 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 449 | Sq w amp (d.core.pulseStart + y, eta) = pulseAngularSource d.core d.h amp eta y := by |
| 450 | rw [Sq_formula, H_radial_ratio_pulse w eta hy hy', |
| 451 | E_parameter_ratio_before w eta (by dsimp [Parameters.endpoint]; linarith), |
| 452 | W_formula d ha, Ubar_pulse w amp eta hy', Ubar_parameter_pulse w ha eta hy hy', |
| 453 | U_pulse w amp eta hy hy', E_before w eta (by dsimp [Parameters.endpoint]; linarith)] |
| 454 | dsimp only [Prod.snd, StressAlgebra.axialExponent, StressAlgebra.coordinateFactor, |
| 455 | pulseAngularSource] |
| 456 | ring |
| 457 | |
| 458 | theorem Qs_pulse_hasDerivAt (w : ResetWitness d K) {amp : ℝ → ℝ} |
| 459 | (ha : ContDiff ℝ ∞ amp) (eta : ℝ) {y : ℝ} |
| 460 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 461 | HasDerivAt (fun t => Qs w amp (d.core.pulseStart + t, eta)) |
| 462 | (pulseAngularSource d.core d.h amp eta y - |
| 463 | (1 - d.core.lam) * Qs w amp (d.core.pulseStart + y, eta)) y := by |
| 464 | have hd := (Qs_hasDerivAt w ha (d.core.pulseStart + y, eta)).comp y |
| 465 | ((hasDerivAt_id y).const_add d.core.pulseStart) |
| 466 | rw [Sq_pulse w ha eta hy hy', H_radial_ratio_pulse w eta hy hy'] at hd |
| 467 | simp only [mul_one, Function.comp_def] at hd |
| 468 | exact hd |
| 469 | |
| 470 | /-- The actual angular lag at the endpoint, initially conditional only |
| 471 | on its incoming sign and explicit schedule/amplitude bounds. -/ |
| 472 | theorem Qs_endpoint_lower_of_nonnegative_entry (w : ResetWitness d K) |
| 473 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 474 | (herr : sourceConstant d.core.P d.core.m * d.core.lam ^ 29 ≤ 1 / 8) |
| 475 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta : ℝ} |
| 476 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) |
| 477 | (hentry : 0 ≤ Qs w amp (d.core.pulseStart, eta)) : |
| 478 | d.core.lam / 4 ≤ Qs w amp (d.core.endpoint, eta) := by |
| 479 | have h := pulse_endpoint_lower d.core |
| 480 | (Q := fun t => Qs w amp (d.core.pulseStart + t, eta)) |
| 481 | (S := pulseAngularSource d.core d.h amp eta) |
| 482 | (by simpa only [add_zero] using hentry) |
| 483 | (fun t ht => Qs_pulse_hasDerivAt w ha eta ht.1 ht.2) |
| 484 | (fun t ht => pulseAngularSource_lower d hwait hsmall herr |
| 485 | ((ha.differentiable (by simp) eta).hasDerivAt) heta hamp hamp' ht.1) |
| 486 | exact h |
| 487 | |
| 488 | /-- A positive threshold selected from the two fixed prefix parameters. -/ |
| 489 | noncomputable def sourceThreshold (P m : ℝ) : ℝ := |
| 490 | min (1 / 120) (1 / (8 * sourceConstant P m)) |
| 491 | |
| 492 | theorem sourceThreshold_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 493 | 0 < sourceThreshold P m := by |
| 494 | have hc := sourceConstant_pos hP m |
| 495 | unfold sourceThreshold |
| 496 | positivity |
| 497 | |
| 498 | theorem source_error_small (c : Parameters) |
| 499 | (hsmall : c.lam ≤ sourceThreshold c.P c.m) : |
| 500 | sourceConstant c.P c.m * c.lam ^ 29 ≤ 1 / 8 := by |
| 501 | have hc := sourceConstant_pos c.P_pos c.m |
| 502 | have hlam : c.lam ≤ 1 := by |
| 503 | have h := hsmall.trans (min_le_left _ _) |
| 504 | linarith |
| 505 | have hp : c.lam ^ 29 ≤ c.lam := by |
| 506 | simpa only [pow_one] using |
| 507 | pow_le_pow_of_le_one c.lam_pos.le hlam (show 1 ≤ 29 by norm_num) |
| 508 | have hprod := (le_div_iff₀ (show 0 < 8 * sourceConstant c.P c.m by positivity)).mp |
| 509 | (hsmall.trans (min_le_right _ _)) |
| 510 | have hm := mul_le_mul_of_nonneg_left hp hc.le |
| 511 | nlinarith |
| 512 | |
| 513 | /-- Exact stability estimate for a scalar lag around a constant source. |
| 514 | The source error is allowed to have either sign. -/ |
| 515 | theorem ode_equilibrium_error {r s δ L : ℝ} (hr : 0 < r) (hδ : 0 ≤ δ) (hL : 0 ≤ L) |
| 516 | {Q S : ℝ → ℝ} |
| 517 | (hQ : ∀ t ∈ Icc (0 : ℝ) L, HasDerivAt Q (S t - r * Q t) t) |
| 518 | (hS : ∀ t ∈ Icc (0 : ℝ) L, |S t - s| ≤ δ) : |
| 519 | |Q L - s / r| ≤ |Q 0 - s / r| * Real.exp (-r * L) + δ / r := by |
| 520 | have hlo := ode_lower_barrier hr hL hQ |
| 521 | (s := s - δ) (fun t ht => by have h := (abs_le.mp (hS t ht)).1; linarith) |
| 522 | have hneg (t : ℝ) (ht : t ∈ Icc (0 : ℝ) L) : |
| 523 | HasDerivAt (fun t => -Q t) (-S t - r * (-Q t)) t := by |
| 524 | convert! (hQ t ht).neg using 1 |
| 525 | ring |
| 526 | have hhi := ode_lower_barrier hr hL hneg |
| 527 | (s := -(s + δ)) (S := fun t => -S t) |
| 528 | (fun t ht => by |
| 529 | have h := (abs_le.mp (hS t ht)).2 |
| 530 | change -(s + δ) ≤ -S t |
| 531 | linarith) |
| 532 | have he : 0 ≤ Real.exp (-r * L) := (Real.exp_pos _).le |
| 533 | have hp := mul_le_mul_of_nonneg_right (le_abs_self (Q 0 - s / r)) he |
| 534 | have hm := mul_le_mul_of_nonneg_right (neg_abs_le (Q 0 - s / r)) he |
| 535 | have hδr : 0 ≤ δ / r := div_nonneg hδ hr.le |
| 536 | have hδe := mul_nonneg hδr he |
| 537 | rw [abs_le] |
| 538 | constructor |
| 539 | · rw [sub_div] at hlo |
| 540 | nlinarith |
| 541 | · rw [neg_div, add_div] at hhi |
| 542 | nlinarith |
| 543 | |
| 544 | /-- Uniform angular-lag error throughout the actual pulse; the incoming |
| 545 | error is retained explicitly for the shaped-wait theorem to supply. -/ |
| 546 | theorem Qs_pulse_equilibrium_error (w : ResetWitness d K) |
| 547 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 548 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y : ℝ} |
| 549 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) |
| 550 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 551 | |Qs w amp (d.core.pulseStart + y, eta) - |
| 552 | (d.core.lam - d.h + (1 / 2 - d.h) * eta * shapeGradient eta) / (1 - d.core.lam)| ≤ |
| 553 | |Qs w amp (d.core.pulseStart, eta) - |
| 554 | (d.core.lam - d.h + (1 / 2 - d.h) * eta * shapeGradient eta) / (1 - d.core.lam)| * |
| 555 | Real.exp (-(1 - d.core.lam) * y) + |
| 556 | sourceConstant d.core.P d.core.m * d.core.lam ^ 30 / (1 - d.core.lam) := by |
| 557 | have h := ode_equilibrium_error (show 0 < 1 - d.core.lam by linarith [d.core.lam_lt]) |
| 558 | (show 0 ≤ sourceConstant d.core.P d.core.m * d.core.lam ^ 30 by |
| 559 | have hc := sourceConstant_pos d.core.P_pos d.core.m; positivity) hy |
| 560 | (Q := fun t => Qs w amp (d.core.pulseStart + t, eta)) |
| 561 | (S := pulseAngularSource d.core d.h amp eta) |
| 562 | (fun t ht => Qs_pulse_hasDerivAt w ha eta ht.1 (ht.2.trans hy')) |
| 563 | (fun t ht => pulseAngularSource_error_bound d.core hwait hsmall d.h_pos.le d.h_lt_half.le |
| 564 | ((ha.differentiable (by simp) eta).hasDerivAt) heta hamp hamp' ht.1) |
| 565 | simpa only [add_zero] using h |
| 566 | |
| 567 | /-- The actual endpoint lower bound follows from the constructed incoming |
| 568 | history and numerical parameter restrictions, with no incoming-lag or |
| 569 | source estimate assumed. -/ |
| 570 | theorem Qs_endpoint_lower (w : ResetWitness d K) |
| 571 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 572 | (hpulse : sourceConstant d.core.P d.core.m * d.core.lam ^ 29 ≤ 1 / 8) |
| 573 | (hh₁ : d.h ≤ 1 / 100) |
| 574 | (hhT : d.h ≤ Real.exp (-(d.core.holdStart + 3 / 5)) / 8) |
| 575 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta : ℝ} |
| 576 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) : |
| 577 | d.core.lam / 4 ≤ Qs w amp (d.core.endpoint, eta) := |
| 578 | Qs_endpoint_lower_of_nonnegative_entry w hwait hsmall hpulse ha heta hamp hamp' |
| 579 | (OutgoingEntranceCone.canonical_Qs_pos_at_pulseStart w ha hh₁ hhT heta).le |
| 580 | |
| 581 | theorem Qs_endpoint_lower_of_threshold (w : ResetWitness d K) |
| 582 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) |
| 583 | (hsmall : d.core.lam ≤ sourceThreshold d.core.P d.core.m) |
| 584 | (hh₁ : d.h ≤ 1 / 100) |
| 585 | (hhT : d.h ≤ Real.exp (-(d.core.holdStart + 3 / 5)) / 8) |
| 586 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta : ℝ} |
| 587 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) : |
| 588 | d.core.lam / 4 ≤ Qs w amp (d.core.endpoint, eta) := |
| 589 | Qs_endpoint_lower w hwait (hsmall.trans (min_le_left _ _)) |
| 590 | (source_error_small d.core hsmall) hh₁ hhT ha heta hamp hamp' |
| 591 | |
| 592 | /-- The final energy-closing amplitude, including the angular reset, is |
| 593 | the amplitude used in this endpoint theorem. -/ |
| 594 | theorem corrected_Qs_endpoint_lower (w : ResetWitness d K) (hK : 0 < K) |
| 595 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 596 | (hscale : CorrectedPulseAmplitude.combinedScale d K ≤ 1 / 1000) |
| 597 | (hpulse : sourceConstant d.core.P d.core.m * d.core.lam ^ 29 ≤ 1 / 8) |
| 598 | (hh₁ : d.h ≤ 1 / 100) |
| 599 | (hhT : d.h ≤ Real.exp (-(d.core.holdStart + 3 / 5)) / 8) |
| 600 | {eta : ℝ} (heta : |eta| ≤ 1) : |
| 601 | d.core.lam / 4 ≤ Qs w (CorrectedPulseAmplitude.amplitude d w.coefficients) |
| 602 | (d.core.endpoint, eta) := by |
| 603 | have hs := CorrectedPulseAmplitude.amplitude_spec w hK hsmall hwait hscale |
| 604 | have heta₂ : eta ^ 2 ≤ 1 := by |
| 605 | have h := (sq_le_sq₀ (abs_nonneg eta) (by norm_num : (0 : ℝ) ≤ 1)).mpr heta |
| 606 | nlinarith [sq_abs eta] |
| 607 | have hb := hs.2 eta heta₂ |
| 608 | apply Qs_endpoint_lower w hwait hsmall hpulse hh₁ hhT hs.1 heta |
| 609 | · rw [abs_of_pos (CorrectedPulseAmplitude.amplitude_pos d w.coefficients eta)] |
| 610 | exact hb.2.1.le |
| 611 | · have hd := hb.2.2.2.1 |
| 612 | linarith |
| 613 | |
| 614 | /-! ## The axial identity and the genuine pressure remainder -/ |
| 615 | |
| 616 | theorem Ns_integrated_Ubar (w : ResetWitness d K) {amp : ℝ → ℝ} |
| 617 | (ha : ContDiff ℝ ∞ amp) (p : Point) : |
| 618 | Ns w amp p = -W d amp p * U d amp p + |
| 619 | StressAlgebra.axialExponent d.h * (Ubar d amp p - p.2 * dEta (Ubar d amp) p) + |
| 620 | (4 * d.h * p.2 * S w amp p - StressAlgebra.coordinateFactor p.2 * dEta (S w amp) p) / X p + |
| 621 | 4 * StressAlgebra.velocityExponent d.h * p.2 * Pi w p - |
| 622 | StressAlgebra.coordinateFactor p.2 * dEta (Pi w) p := by |
| 623 | rw [Ns_integrated, Ubar_parameter d ha] |
| 624 | unfold Ubar |
| 625 | ring |
| 626 | |
| 627 | noncomputable def axialHistoryError (w : ResetWitness d K) (amp : ℝ → ℝ) |
| 628 | (eta y : ℝ) : ℝ := |
| 629 | let p := (d.core.pulseStart + y, eta) |
| 630 | (1 - W d amp p) * pulseRatio d.core amp (y, eta) + |
| 631 | ((4 * d.h * eta * S w amp p - (1 - eta ^ 2) * dEta (S w amp) p) / X p + |
| 632 | 4 * (1 / 2 + d.h) * eta * Pi w p - (1 - eta ^ 2) * dEta (Pi w) p) / E w p |
| 633 | |
| 634 | /-- Exact substitution in the integrated axial stress. The error is an |
| 635 | explicit expression in the same constructed energy and pressure histories. -/ |
| 636 | theorem Ns_pulse_identity (w : ResetWitness d K) {amp : ℝ → ℝ} |
| 637 | (ha : ContDiff ℝ ∞ amp) (eta : ℝ) {y : ℝ} |
| 638 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 639 | Ns w amp (d.core.pulseStart + y, eta) / E w (d.core.pulseStart + y, eta) = |
| 640 | -pulseRatio d.core amp (y, eta) + |
| 641 | ((1 / 2 - d.h) + (1 / 2 - d.h) * eta * shapeGradient eta) * normalizedLag d.core amp eta y - |
| 642 | (1 / 2 - d.h) * eta * deriv (fun t => normalizedLag d.core amp t y) eta + |
| 643 | axialHistoryError w amp eta y := by |
| 644 | rw [Ns_integrated_Ubar w ha, U_pulse w amp eta hy hy', Ubar_pulse w amp eta hy', |
| 645 | Ubar_parameter_pulse w ha eta hy hy'] |
| 646 | dsimp only [Prod.snd, StressAlgebra.axialExponent, StressAlgebra.velocityExponent, |
| 647 | StressAlgebra.coordinateFactor, axialHistoryError] |
| 648 | field_simp [(E_pos w (d.core.pulseStart + y, eta)).ne'] ; ring |
| 649 | |
| 650 | theorem Pi_before (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 651 | (hy : 0 ≤ y) (hy' : y ≤ d.core.endpoint) : |
| 652 | Pi w (y, eta) = FuturePressureBounds.Pi d y eta := by |
| 653 | have hI : (∫ t in (0 : ℝ)..y, pressureWeight w (t, eta)) = |
| 654 | (shape eta ^ 2 / 2) * |
| 655 | ∫ t in (0 : ℝ)..y, radialAmplitude d.core.P d.core.dropLength d.core.lam t ^ 2 := by |
| 656 | rw [← intervalIntegral.integral_const_mul] |
| 657 | apply intervalIntegral.integral_congr |
| 658 | intro t ht |
| 659 | have ht' : t ≤ d.core.endpoint := ((uIcc_of_le hy ▸ ht).2).trans hy' |
| 660 | change E w (t, eta) ^ 2 / 2 = _ |
| 661 | rw [E_before w eta ht'] |
| 662 | unfold angular |
| 663 | ring |
| 664 | rw [FuturePressureBounds.Pi_eq_radial_history d hy hy' eta] |
| 665 | change initialPi d eta + (∫ t in (0 : ℝ)..y, pressureWeight w (t, eta)) = _ |
| 666 | rw [hI] |
| 667 | unfold initialPi |
| 668 | ring |
| 669 | |
| 670 | theorem Pi_parameter_before (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 671 | (hy : 0 ≤ y) (hy' : y ≤ d.core.endpoint) : |
| 672 | dEta (Pi w) (y, eta) = deriv (FuturePressureBounds.Pi d y) eta := by |
| 673 | rw [dEta_eq_deriv (Pi_smooth w)] |
| 674 | have he : (fun eta => Pi w (y, eta)) = FuturePressureBounds.Pi d y := |
| 675 | funext (fun eta => Pi_before w eta hy hy') |
| 676 | rw [he] |
| 677 | |
| 678 | /-- Uniform value and first parameter derivative bounds for the actual |
| 679 | canonical pressure throughout the pulse. -/ |
| 680 | theorem pulse_pressure_bounds (w : ResetWitness d K) {eta y : ℝ} |
| 681 | (heta : |eta| ≤ 1) (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 682 | |Pi w (d.core.pulseStart + y, eta)| ≤ (FuturePressureBounds.envelopeConstant / 2) * |
| 683 | E w (d.core.pulseStart + y, eta) ^ 2 ∧ |
| 684 | |dEta (Pi w) (d.core.pulseStart + y, eta)| ≤ |
| 685 | 2 * FuturePressureBounds.envelopeConstant * |eta| * E w (d.core.pulseStart + y, eta) ^ 2 := by |
| 686 | have hy₀ : 0 ≤ d.core.pulseStart + y := by linarith [d.core.pulseStart_pos] |
| 687 | have hyend : d.core.pulseStart + y ≤ d.core.endpoint := by |
| 688 | dsimp [Parameters.endpoint] |
| 689 | linarith |
| 690 | rw [Pi_before w eta hy₀ hyend, Pi_parameter_before w eta hy₀ hyend, E_before w eta hyend] |
| 691 | have h := FuturePressureBounds.uniform_pressure_bounds d hy₀ heta |
| 692 | rw [OutgoingTail.finalAngular_before d eta hyend] at h |
| 693 | exact ⟨h.1, h.2.1⟩ |
| 694 | |
| 695 | /-! ## Actual viscous coefficients on the pulse -/ |
| 696 | |
| 697 | noncomputable def radialA (w : ResetWitness d K) (p : Point) : ℝ := |
| 698 | 2 - 2 * (dY (H w) p / H w p) |
| 699 | |
| 700 | noncomputable def shearB (w : ResetWitness d K) (amp : ℝ → ℝ) (p : Point) : ℝ := |
| 701 | 2 * dY (U d amp) p / E w p |
| 702 | |
| 703 | noncomputable def directionRatio (w : ResetWitness d K) (amp : ℝ → ℝ) (p : Point) : ℝ := |
| 704 | Ns w amp p / (E w p * Qs w amp p) |
| 705 | |
| 706 | theorem radialA_pulse (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 707 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 708 | radialA w (d.core.pulseStart + y, eta) = 2 + 2 * d.core.lam := by |
| 709 | rw [radialA, H_radial_ratio_pulse w eta hy hy'] |
| 710 | ring |
| 711 | |
| 712 | theorem E_radial_pulse (w : ResetWitness d K) (eta : ℝ) {y : ℝ} |
| 713 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 714 | dY (E w) (d.core.pulseStart + y, eta) = |
| 715 | E w (d.core.pulseStart + y, eta) * (-(1 / 2 + d.core.lam)) := by |
| 716 | have hyend : d.core.pulseStart + y ≤ d.core.endpoint := by |
| 717 | dsimp [Parameters.endpoint] |
| 718 | linarith |
| 719 | rw [E_radial_before w eta hyend, ← E_before w eta hyend, |
| 720 | slope_hold d.core.dropLength_pos.le (by |
| 721 | have h := d.core.pulseStart_ge_hold |
| 722 | dsimp [Parameters.holdStart] at h |
| 723 | linarith)] |
| 724 | ring |
| 725 | |
| 726 | theorem U_radial_pulse (w : ResetWitness d K) {amp : ℝ → ℝ} |
| 727 | (ha : ContDiff ℝ ∞ amp) (eta : ℝ) {y : ℝ} |
| 728 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 729 | dY (U d amp) (d.core.pulseStart + y, eta) = |
| 730 | E w (d.core.pulseStart + y, eta) * |
| 731 | (deriv (fun t => pulseRatio d.core amp (t, eta)) y - |
| 732 | (1 / 2 + d.core.lam) * pulseRatio d.core amp (y, eta)) := by |
| 733 | have hshift := (hasDerivAt_id y).const_add d.core.pulseStart |
| 734 | have hU := (dY_hasDerivAt (U_smooth d ha) (d.core.pulseStart + y, eta)).comp y hshift |
| 735 | have hE := (dY_hasDerivAt (E_smooth w) (d.core.pulseStart + y, eta)).comp y hshift |
| 736 | have hRsmooth : ContDiff ℝ ∞ (fun t => pulseRatio d.core amp (t, eta)) := |
| 737 | (pulseRatio_contDiff d.core ha).comp (contDiff_id.prodMk contDiff_const) |
| 738 | have hR := (hRsmooth.differentiable (by simp) y).hasDerivAt |
| 739 | have hp := (hE.mul hR).hasDerivWithinAt (s := Icc (0 : ℝ) d.core.pulseLength) |
| 740 | have hp' := hp.congr (fun t ht => U_pulse w amp eta ht.1 ht.2) (U_pulse w amp eta hy hy') |
| 741 | have he := (uniqueDiffOn_Icc d.core.pulseLength_pos y ⟨hy, hy'⟩).eq_deriv _ |
| 742 | hU.hasDerivWithinAt hp' |
| 743 | simp only [mul_one] at he |
| 744 | change dY (U d amp) (d.core.pulseStart + y, eta) = |
| 745 | dY (E w) (d.core.pulseStart + y, eta) * pulseRatio d.core amp (y, eta) + |
| 746 | E w (d.core.pulseStart + y, eta) * deriv (fun t => pulseRatio d.core amp (t, eta)) y at he |
| 747 | rw [he, E_radial_pulse w eta hy hy'] |
| 748 | ring |
| 749 | |
| 750 | theorem shearB_pulse (w : ResetWitness d K) {amp : ℝ → ℝ} |
| 751 | (ha : ContDiff ℝ ∞ amp) (eta : ℝ) {y : ℝ} |
| 752 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 753 | shearB w amp (d.core.pulseStart + y, eta) = -pulseRatio d.core amp (y, eta) + |
| 754 | 2 * d.core.lam * (deriv (scaledPulse d.core amp eta) (d.core.lam * y) - |
| 755 | pulseRatio d.core amp (y, eta)) := by |
| 756 | rw [shearB, U_radial_pulse w ha eta hy hy', ← scaledPulse_deriv d.core amp eta y] |
| 757 | field_simp [(E_pos w (d.core.pulseStart + y, eta)).ne'] ; ring |
| 758 | |
| 759 | /-! ## Quantitative pulse jets and parameter sensitivity -/ |
| 760 | |
| 761 | theorem mainPulse_deriv_formula (z : ℝ) : |
| 762 | deriv mainPulse z = sigma (50 * z) * (1 - sigma (z - 10)) - |
| 763 | pulseRamp z * deriv sigma (z - 10) := by |
| 764 | have hr : HasDerivAt pulseRamp (sigma (50 * z)) z := |
| 765 | primitive_hasDerivAt (sigma_contDiff.continuous.comp (continuous_const.mul continuous_id)) z |
| 766 | have hs := (sigma_contDiff.differentiable (by simp) (z - 10)).hasDerivAt.comp z |
| 767 | ((hasDerivAt_id z).sub_const 10) |
| 768 | have h := hr.fun_mul ((hasDerivAt_const z (1 : ℝ)).fun_sub hs) |
| 769 | change HasDerivAt mainPulse _ z at h |
| 770 | rw [h.deriv] |
| 771 | simp only [Function.comp_apply, id_eq] |
| 772 | ring |
| 773 | |
| 774 | /-- Only this upper derivative bound is used for the favorable cutoff sign. -/ |
| 775 | theorem mainPulse_deriv_le_one {z : ℝ} (hz : 0 ≤ z) : deriv mainPulse z ≤ 1 := by |
| 776 | rw [mainPulse_deriv_formula] |
| 777 | have hprod := mul_le_mul (sigma_le_one (50 * z)) |
| 778 | (show 1 - sigma (z - 10) ≤ 1 by linarith [sigma_nonneg (z - 10)]) |
| 779 | (sub_nonneg.mpr (sigma_le_one (z - 10))) zero_le_one |
| 780 | have hcut := mul_nonneg (PulseAmplitude.pulseRamp_nonneg hz) |
| 781 | (OutgoingTail.sigma_derivative_nonneg (z - 10)) |
| 782 | nlinarith |
| 783 | |
| 784 | noncomputable def mainFirstBound : ℝ := 1 + Classical.choose |
| 785 | (LocalizedMomentRepair.smooth_compact_derivative_bound mainPulse |
| 786 | mainPulse_contDiff mainPulse_hasCompactSupport 1) |
| 787 | |
| 788 | theorem mainFirstBound_pos : 0 < mainFirstBound := by |
| 789 | have h := (Classical.choose_spec (LocalizedMomentRepair.smooth_compact_derivative_bound mainPulse |
| 790 | mainPulse_contDiff mainPulse_hasCompactSupport 1)).1 |
| 791 | dsimp [mainFirstBound] |
| 792 | linarith |
| 793 | |
| 794 | theorem main_first_le (z : ℝ) : |deriv mainPulse z| ≤ mainFirstBound := by |
| 795 | have h := (Classical.choose_spec (LocalizedMomentRepair.smooth_compact_derivative_bound mainPulse |
| 796 | mainPulse_contDiff mainPulse_hasCompactSupport 1)).2 z |
| 797 | have he : |deriv mainPulse z| = |iteratedDeriv 1 mainPulse z| := by rw [iteratedDeriv_one] |
| 798 | rw [he] |
| 799 | dsimp [mainFirstBound] |
| 800 | linarith |
| 801 | |
| 802 | theorem scaledPulse_deriv_formula (c : Parameters) (amp : ℝ → ℝ) (eta y : ℝ) : |
| 803 | deriv (scaledPulse c amp eta) (c.lam * y) = |
| 804 | amp eta * deriv mainPulse (c.lam * y) + |
| 805 | deriv (affineProfile c (parameterPolynomial eta) (amp eta)) y / c.lam := by |
| 806 | have hs := scaledPulse_deriv c amp eta y |
| 807 | have heq : (fun t => pulseRatio c amp (t, eta)) = |
| 808 | forcing c (parameterPolynomial eta) (amp eta) := |
| 809 | funext (fun t => (forcing_eq_pulseRatio c amp eta t).symm) |
| 810 | rw [heq] at hs |
| 811 | have hf := forcing_jet_formula c (parameterPolynomial eta) (amp eta) 1 y |
| 812 | simp only [iteratedDeriv_one, pow_one] at hf |
| 813 | rw [hf] at hs |
| 814 | apply mul_left_cancel₀ c.lam_pos.ne' |
| 815 | calc |
| 816 | _ = amp eta * c.lam * deriv mainPulse (c.lam * y) + |
| 817 | deriv (affineProfile c (parameterPolynomial eta) (amp eta)) y := hs |
| 818 | _ = _ := by field_simp [c.lam_pos.ne'] |
| 819 | |
| 820 | noncomputable def valueRepairConstant (P m : ℝ) : ℝ := 384 * correctionJetBound P m 0 |
| 821 | noncomputable def derivativeRepairConstant (P m : ℝ) : ℝ := 384 * correctionJetBound P m 1 |
| 822 | |
| 823 | theorem valueRepairConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 824 | 0 < valueRepairConstant P m := mul_pos (by norm_num) (correctionJetBound_pos hP m 0) |
| 825 | theorem derivativeRepairConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 826 | 0 < derivativeRepairConstant P m := mul_pos (by norm_num) (correctionJetBound_pos hP m 1) |
| 827 | |
| 828 | theorem scaledPulse_correction_bounds (c : Parameters) (hsmall : c.lam ≤ 1 / 120) |
| 829 | (amp : ℝ → ℝ) {eta : ℝ} (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (y : ℝ) : |
| 830 | |pulseRatio c amp (y, eta) - amp eta * mainPulse (c.lam * y)| ≤ |
| 831 | valueRepairConstant c.P c.m * c.lam ^ 2 ∧ |
| 832 | |deriv (scaledPulse c amp eta) (c.lam * y) - amp eta * deriv mainPulse (c.lam * y)| ≤ |
| 833 | derivativeRepairConstant c.P c.m * c.lam := by |
| 834 | have hq : |parameterPolynomial eta| + |amp eta| ≤ 6 := by |
| 835 | linarith [parameterPolynomial_bound heta] |
| 836 | have hb (k : ℕ) : |iteratedDeriv k (affineProfile c (parameterPolynomial eta) (amp eta)) y| ≤ |
| 837 | 384 * correctionJetBound c.P c.m k * c.lam ^ 2 := by |
| 838 | apply (affineProfile_jet_bound c hsmall _ _ k y).trans |
| 839 | have h := mul_le_mul |
| 840 | (mul_le_mul_of_nonneg_left (exponential_correction_quadratic c.lam_pos) |
| 841 | (correctionJetBound_pos c.P_pos c.m k).le) hq |
| 842 | (by positivity : 0 ≤ |parameterPolynomial eta| + |amp eta|) |
| 843 | (by have hc := correctionJetBound_pos c.P_pos c.m k; positivity : |
| 844 | 0 ≤ correctionJetBound c.P c.m k * (64 * c.lam ^ 2)) |
| 845 | convert! h using 1 |
| 846 | ring |
| 847 | constructor |
| 848 | · rw [← forcing_eq_pulseRatio c amp eta y] |
| 849 | simpa only [forcing, add_sub_cancel_left, iteratedDeriv_zero, valueRepairConstant] using hb 0 |
| 850 | · rw [scaledPulse_deriv_formula, add_sub_cancel_left, abs_div, abs_of_pos c.lam_pos] |
| 851 | apply (div_le_iff₀ c.lam_pos).mpr |
| 852 | simpa only [iteratedDeriv_one, derivativeRepairConstant, pow_two, mul_assoc] using hb 1 |
| 853 | |
| 854 | noncomputable def derivativeConstant (P m : ℝ) : ℝ := |
| 855 | 2 * mainFirstBound + derivativeRepairConstant P m |
| 856 | |
| 857 | theorem derivativeConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 858 | 0 < derivativeConstant P m := by |
| 859 | have hm := mainFirstBound_pos |
| 860 | have hc := derivativeRepairConstant_pos hP m |
| 861 | dsimp [derivativeConstant] |
| 862 | positivity |
| 863 | |
| 864 | theorem scaledPulse_deriv_abs_le (c : Parameters) (hsmall : c.lam ≤ 1 / 120) |
| 865 | (amp : ℝ → ℝ) {eta : ℝ} (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (y : ℝ) : |
| 866 | |deriv (scaledPulse c amp eta) (c.lam * y)| ≤ derivativeConstant c.P c.m := by |
| 867 | have he := (scaledPulse_correction_bounds c hsmall amp heta hamp y).2 |
| 868 | have hm : |amp eta * deriv mainPulse (c.lam * y)| ≤ 2 * mainFirstBound := by |
| 869 | rw [abs_mul] |
| 870 | exact (mul_le_mul hamp (main_first_le _) (abs_nonneg _) (by norm_num)).trans |
| 871 | (by nlinarith [mainFirstBound_pos]) |
| 872 | have hc := mul_le_mul_of_nonneg_left (show c.lam ≤ 1 by linarith [c.lam_lt]) |
| 873 | (derivativeRepairConstant_pos c.P_pos c.m).le |
| 874 | have htriangle := abs_add_le (deriv (scaledPulse c amp eta) (c.lam * y) - |
| 875 | amp eta * deriv mainPulse (c.lam * y)) (amp eta * deriv mainPulse (c.lam * y)) |
| 876 | rw [sub_add_cancel] at htriangle |
| 877 | dsimp [derivativeConstant] |
| 878 | nlinarith |
| 879 | |
| 880 | theorem forcing_fine_abs_le (c : Parameters) (hsmall : c.lam ≤ 1 / 120) (q A y : ℝ) : |
| 881 | |forcing c q A y| ≤ mainBound * |A| + |
| 882 | 64 * correctionJetBound c.P c.m 0 * (|q| + |A|) * c.lam ^ 2 := by |
| 883 | have hc := affineProfile_jet_bound c hsmall q A 0 y |
| 884 | simp only [iteratedDeriv_zero] at hc |
| 885 | have he := mul_le_mul_of_nonneg_right |
| 886 | (mul_le_mul_of_nonneg_left (exponential_correction_quadratic c.lam_pos) |
| 887 | (correctionJetBound_pos c.P_pos c.m 0).le) (by positivity : 0 ≤ |q| + |A|) |
| 888 | have hm : |A * mainPulse (c.lam * y)| ≤ mainBound * |A| := by |
| 889 | rw [abs_mul] |
| 890 | nlinarith [mul_le_mul_of_nonneg_left (mainPulse_abs_le (c.lam * y)) (abs_nonneg A)] |
| 891 | apply (abs_add_le _ _).trans |
| 892 | change |A * mainPulse (c.lam * y)| + |affineProfile c q A y| ≤ _ |
| 893 | nlinarith |
| 894 | |
| 895 | theorem affineLag_fine_abs_le (c : Parameters) |
| 896 | (hwait : c.wait = 60 * Real.log (1 / c.lam)) (hsmall : c.lam ≤ 1 / 120) |
| 897 | (q A : ℝ) {y : ℝ} (hy : 0 ≤ y) : |
| 898 | |affineLag c q A y| ≤ 3 * mainBound * |A| + |
| 899 | (prefixBound c.P c.m 0 * |q| + 192 * correctionJetBound c.P c.m 0 * (|q| + |A|)) * c.lam ^ 2 := by |
| 900 | have hB : 0 ≤ mainBound * |A| + 64 * correctionJetBound c.P c.m 0 * (|q| + |A|) * c.lam ^ 2 := by |
| 901 | have hm := mainBound_pos |
| 902 | have hc := correctionJetBound_pos c.P_pos c.m 0 |
| 903 | positivity |
| 904 | have hc := (convolution_abs_le (decay_pos c) hB hy (forcing_contDiff c q A).continuous |
| 905 | (fun t _ => forcing_fine_abs_le c hsmall q A t)).trans (decay_div_le_three c hB) |
| 906 | have hi := initial_memory_bound c hwait hsmall q hy |
| 907 | have ht := abs_add_le ((prefixCoefficient c 0 * q) * Real.exp (-decay c * y)) |
| 908 | (convolution (decay c) (forcing c q A) y) |
| 909 | change |affineLag c q A y| ≤ _ at ht |
| 910 | nlinarith |
| 911 | |
| 912 | noncomputable def parameterLagConstant (P m : ℝ) : ℝ := |
| 913 | 4 * prefixBound P m 0 + 960 * correctionJetBound P m 0 |
| 914 | |
| 915 | theorem parameterLagConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 916 | 0 < parameterLagConstant P m := by |
| 917 | have hp := prefixBound_pos hP m 0 |
| 918 | have hc := correctionJetBound_pos hP m 0 |
| 919 | dsimp [parameterLagConstant] |
| 920 | positivity |
| 921 | |
| 922 | /-- The parameter derivative has the small amplitude-derivative factor; |
| 923 | the remaining dependence is quadratically small in lambda. -/ |
| 924 | theorem normalizedLag_parameter_fine_bound (c : Parameters) |
| 925 | (hwait : c.wait = 60 * Real.log (1 / c.lam)) (hsmall : c.lam ≤ 1 / 120) |
| 926 | {amp : ℝ → ℝ} {eta amp' : ℝ} (ha : HasDerivAt amp amp' eta) |
| 927 | (heta : |eta| ≤ 1) (hamp' : |amp'| ≤ 1) {y : ℝ} (hy : 0 ≤ y) : |
| 928 | |deriv (fun t => normalizedLag c amp t y) eta| ≤ |
| 929 | 3 * mainBound * |amp'| + parameterLagConstant c.P c.m * c.lam ^ 2 := by |
| 930 | rw [(normalizedLag_eta_hasDerivAt c ha hy).deriv] |
| 931 | apply (affineLag_fine_abs_le c hwait hsmall _ _ hy).trans |
| 932 | have hq : |1 + 3 * eta ^ 2| ≤ 4 := by |
| 933 | simpa only [(parameterPolynomial_hasDerivAt eta).deriv] using parameterPolynomial_derivative_bound heta |
| 934 | have hp := mul_le_mul_of_nonneg_left hq (prefixBound_pos c.P_pos c.m 0).le |
| 935 | have hs := mul_le_mul_of_nonneg_left (show |1 + 3 * eta ^ 2| + |amp'| ≤ 5 by linarith) |
| 936 | (correctionJetBound_pos c.P_pos c.m 0).le |
| 937 | have hcoeff : prefixBound c.P c.m 0 * |1 + 3 * eta ^ 2| + |
| 938 | 192 * correctionJetBound c.P c.m 0 * (|1 + 3 * eta ^ 2| + |amp'|) ≤ parameterLagConstant c.P c.m := by |
| 939 | dsimp [parameterLagConstant] |
| 940 | nlinarith |
| 941 | exact add_le_add_right (mul_le_mul_of_nonneg_right hcoeff (sq_nonneg c.lam)) _ |
| 942 | |
| 943 | /-! ## The coefficient in the pulse-direction expansion -/ |
| 944 | |
| 945 | noncomputable def geometricSource (d : TailData) (eta : ℝ) : ℝ := |
| 946 | (1 / 2 - d.h) * eta * shapeGradient eta |
| 947 | |
| 948 | noncomputable def equilibriumNumerator (d : TailData) (eta : ℝ) : ℝ := |
| 949 | d.core.lam - d.h + geometricSource d eta |
| 950 | |
| 951 | noncomputable def angularEquilibrium (d : TailData) (eta : ℝ) : ℝ := |
| 952 | equilibriumNumerator d eta / (1 - d.core.lam) |
| 953 | |
| 954 | noncomputable def derivativeCoefficient (d : TailData) (eta : ℝ) : ℝ := |
| 955 | d.core.lam * ((1 / 2 - d.h) + geometricSource d eta) * (1 - d.core.lam) / |
| 956 | (decay d.core ^ 2 * equilibriumNumerator d eta) |
| 957 | |
| 958 | theorem eta_shapeGradient_nonneg (eta : ℝ) : 0 ≤ eta * shapeGradient eta := by |
| 959 | have he : eta * shapeGradient eta = 2 * eta ^ 2 / (1 + eta ^ 2) := by |
| 960 | unfold shapeGradient |
| 961 | ring |
| 962 | rw [he] |
| 963 | positivity |
| 964 | |
| 965 | theorem eta_shapeGradient_bounds {eta : ℝ} (heta : |eta| ≤ 1) : |
| 966 | eta ^ 2 ≤ eta * shapeGradient eta ∧ eta * shapeGradient eta ≤ 1 := by |
| 967 | have he : eta * shapeGradient eta = 2 * eta ^ 2 / (1 + eta ^ 2) := by |
| 968 | unfold shapeGradient |
| 969 | ring |
| 970 | have hs : eta ^ 2 ≤ 1 := by |
| 971 | have h := (sq_le_sq₀ (abs_nonneg eta) (by norm_num : (0 : ℝ) ≤ 1)).mpr heta |
| 972 | nlinarith [sq_abs eta] |
| 973 | rw [he] |
| 974 | constructor |
| 975 | · apply (le_div_iff₀ (by positivity : 0 < 1 + eta ^ 2)).mpr |
| 976 | nlinarith [mul_nonneg (sq_nonneg eta) (sub_nonneg.mpr hs)] |
| 977 | · apply (div_le_iff₀ (by positivity : 0 < 1 + eta ^ 2)).mpr |
| 978 | linarith |
| 979 | |
| 980 | theorem geometricSource_nonneg (d : TailData) (eta : ℝ) : 0 ≤ geometricSource d eta := by |
| 981 | have h := mul_nonneg (show 0 ≤ 1 / 2 - d.h by linarith [d.h_lt_half]) |
| 982 | (eta_shapeGradient_nonneg eta) |
| 983 | simpa only [geometricSource, mul_assoc] using h |
| 984 | |
| 985 | theorem equilibriumNumerator_pos (d : TailData) (eta : ℝ) : 0 < equilibriumNumerator d eta := by |
| 986 | have hg := geometricSource_nonneg d eta |
| 987 | dsimp [equilibriumNumerator] |
| 988 | linarith [d.h_small, d.core.lam_pos] |
| 989 | |
| 990 | theorem pulse_geometric_bounds (d : TailData) {eta : ℝ} (heta : |eta| ≤ 1) : |
| 991 | (1 / 2 - d.h) + geometricSource d eta ≤ 1 ∧ |
| 992 | d.core.lam / 2 + (2 / 5) * eta ^ 2 ≤ equilibriumNumerator d eta := by |
| 993 | obtain ⟨hg₁, hg₂⟩ := eta_shapeGradient_bounds heta |
| 994 | have hD : (2 / 5 : ℝ) ≤ 1 / 2 - d.h := by linarith [d.h_small, d.core.lam_lt] |
| 995 | have hc₁ := mul_le_mul_of_nonneg_left hg₁ (show 0 ≤ 1 / 2 - d.h by linarith) |
| 996 | have hc₂ := mul_le_mul_of_nonneg_left hg₂ (show 0 ≤ 1 / 2 - d.h by linarith) |
| 997 | have hc₃ := mul_le_mul_of_nonneg_right hD (sq_nonneg eta) |
| 998 | dsimp [geometricSource, equilibriumNumerator] at * |
| 999 | constructor <;> nlinarith [d.h_pos, d.h_small] |
| 1000 | |
| 1001 | theorem derivativeCoefficient_nonneg (d : TailData) (eta : ℝ) : |
| 1002 | 0 ≤ derivativeCoefficient d eta := by |
| 1003 | have hg := geometricSource_nonneg d eta |
| 1004 | have hA := (equilibriumNumerator_pos d eta).le |
| 1005 | have hD : 0 ≤ 1 / 2 - d.h := by linarith [d.h_lt_half] |
| 1006 | have hr : 0 ≤ 1 - d.core.lam := by linarith [d.core.lam_lt] |
| 1007 | have hl := d.core.lam_pos.le |
| 1008 | dsimp [derivativeCoefficient] |
| 1009 | positivity |
| 1010 | |
| 1011 | /-- A concrete version of `C_d <= 2+o(1)`, uniform in the parameter. -/ |
| 1012 | theorem derivativeCoefficient_le (d : TailData) |
| 1013 | (hsmall : d.core.lam ≤ 1 / 100000) (hh : d.h ≤ d.core.lam / 100000) (eta : ℝ) : |
| 1014 | derivativeCoefficient d eta ≤ 2001 / 1000 := by |
| 1015 | have hb : (49999 / 100000 : ℝ) ≤ decay d.core := by dsimp [decay]; linarith |
| 1016 | have hb₂ := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 49999 / 100000) hb 2 |
| 1017 | have hbase : (1 / 2 : ℝ) ≤ (2001 / 1000) * decay d.core ^ 2 * (99999 / 100000) := by |
| 1018 | nlinarith |
| 1019 | have hg := geometricSource_nonneg d eta |
| 1020 | have hD : 0 ≤ 1 / 2 - d.h := by linarith [d.h_lt_half] |
| 1021 | have hA : (99999 / 100000) * d.core.lam + geometricSource d eta ≤ equilibriumNumerator d eta := by |
| 1022 | dsimp [equilibriumNumerator] |
| 1023 | linarith |
| 1024 | have hnum : d.core.lam * ((1 / 2 - d.h) + geometricSource d eta) * (1 - d.core.lam) ≤ |
| 1025 | d.core.lam * (1 / 2 + geometricSource d eta) := by |
| 1026 | have hm := mul_le_mul_of_nonneg_left (show 1 - d.core.lam ≤ 1 by linarith [d.core.lam_pos]) |
| 1027 | (mul_nonneg d.core.lam_pos.le (add_nonneg hD hg)) |
| 1028 | have hh' := mul_le_mul_of_nonneg_left d.h_pos.le d.core.lam_pos.le |
| 1029 | nlinarith |
| 1030 | have hbase' := mul_le_mul_of_nonneg_right hbase d.core.lam_pos.le |
| 1031 | have hc : d.core.lam ≤ (2001 / 1000) * decay d.core ^ 2 := by nlinarith [d.core.lam_pos] |
| 1032 | have hc' := mul_le_mul_of_nonneg_right hc hg |
| 1033 | have hA' := mul_le_mul_of_nonneg_left hA |
| 1034 | (show 0 ≤ (2001 / 1000) * decay d.core ^ 2 by positivity) |
| 1035 | unfold derivativeCoefficient |
| 1036 | apply (div_le_iff₀ (mul_pos (sq_pos_of_pos (decay_pos d.core)) (equilibriumNumerator_pos d eta))).mpr |
| 1037 | nlinarith |
| 1038 | |
| 1039 | noncomputable def mainDirection (d : TailData) (amp : ℝ → ℝ) (eta y : ℝ) : ℝ := |
| 1040 | ((1 - d.core.lam) / decay d.core) * pulseRatio d.core amp (y, eta) - |
| 1041 | derivativeCoefficient d eta * deriv (scaledPulse d.core amp eta) (d.core.lam * y) |
| 1042 | |
| 1043 | private theorem direction_identity_algebra {β C A r : ℝ} (lam R Z : ℝ) |
| 1044 | (hβ : β ≠ 0) (hA : A ≠ 0) (hr : r ≠ 0) (hrel : A = C - β) : |
| 1045 | -R + C * (R / β - lam * Z / β ^ 2) = |
| 1046 | A / r * (r / β * R - (lam * C * r / (β ^ 2 * A)) * Z) := by |
| 1047 | rw [hrel] at hA ⊢ |
| 1048 | field_simp ; ring |
| 1049 | |
| 1050 | theorem mainDirection_identity (d : TailData) (eta R Z : ℝ) : |
| 1051 | -R + ((1 / 2 - d.h) + geometricSource d eta) * |
| 1052 | (R / decay d.core - d.core.lam * Z / decay d.core ^ 2) = |
| 1053 | angularEquilibrium d eta * (((1 - d.core.lam) / decay d.core) * R - |
| 1054 | derivativeCoefficient d eta * Z) := by |
| 1055 | have hr : 1 - d.core.lam ≠ 0 := by linarith [d.core.lam_lt] |
| 1056 | apply direction_identity_algebra d.core.lam R Z (decay_pos d.core).ne' |
| 1057 | (equilibriumNumerator_pos d eta).ne' hr |
| 1058 | dsimp [equilibriumNumerator, decay] |
| 1059 | ring |
| 1060 | |
| 1061 | /-- The actual mass expansion is inserted into the actual axial history. -/ |
| 1062 | theorem Ns_pulse_expansion (w : ResetWitness d K) {amp : ℝ → ℝ} |
| 1063 | (ha : ContDiff ℝ ∞ amp) (eta : ℝ) {y : ℝ} |
| 1064 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1065 | Ns w amp (d.core.pulseStart + y, eta) / E w (d.core.pulseStart + y, eta) = |
| 1066 | angularEquilibrium d eta * mainDirection d amp eta y + |
| 1067 | ((1 / 2 - d.h) + geometricSource d eta) * fullError d.core amp eta y - |
| 1068 | (1 / 2 - d.h) * eta * deriv (fun t => normalizedLag d.core amp t y) eta + |
| 1069 | axialHistoryError w amp eta y := by |
| 1070 | rw [Ns_pulse_identity w ha eta hy hy'] |
| 1071 | unfold mainDirection |
| 1072 | rw [← mainDirection_identity] |
| 1073 | unfold fullError geometricSource |
| 1074 | ring |
| 1075 | |
| 1076 | /-! ## Strict numerical margins, stable under quantified errors -/ |
| 1077 | |
| 1078 | theorem first_quadratic_margin (R : ℝ) : |
| 1079 | -2 * R ^ 2 + (241 / 100) * R ≤ 73 / 100 := by |
| 1080 | nlinarith [sq_nonneg (R - 241 / 400)] |
| 1081 | |
| 1082 | theorem second_quadratic_margin (R : ℝ) : |
| 1083 | -(7 / 2) * R ^ 2 + (241 / 50) * R ≤ 167 / 100 := by |
| 1084 | nlinarith [sq_nonneg (R - 241 / 350)] |
| 1085 | |
| 1086 | theorem ideal_cross_bound {R C Z : ℝ} (hR : 0 ≤ R) (hC : 0 ≤ C) |
| 1087 | (hC' : C ≤ 2001 / 1000) (hZ : Z ≤ 6 / 5) : |
| 1088 | -R * (2 * R - C * Z) ≤ -2 * R ^ 2 + (241 / 100) * R := by |
| 1089 | have hc := mul_le_mul_of_nonneg_left hZ hC |
| 1090 | have hcz : C * Z ≤ 241 / 100 := by nlinarith |
| 1091 | have hm := mul_le_mul_of_nonneg_left hcz hR |
| 1092 | nlinarith |
| 1093 | |
| 1094 | noncomputable def coneErrorBudget (F M eps lam : ℝ) : ℝ := |
| 1095 | 2 * eps * (M + F + 1) + eps * (2 * F + 1) / 2 + 2 * lam * (M + 1) ^ 2 |
| 1096 | |
| 1097 | /-- A completely numerical perturbation lemma. The actual profile |
| 1098 | estimates below supply both errors and the small budget. -/ |
| 1099 | theorem perturbed_cone_margins {lam R C Z b v eps F M : ℝ} |
| 1100 | (hlam : 0 ≤ lam) (hF : 0 ≤ F) (hM : 0 ≤ M) (heps : 0 ≤ eps) (heps' : eps ≤ 1) |
| 1101 | (hR : 0 ≤ R) (hR' : R ≤ F) (hC : 0 ≤ C) (hC' : C ≤ 2001 / 1000) |
| 1102 | (hZ : Z ≤ 6 / 5) (hmain : |2 * R - C * Z| ≤ M) |
| 1103 | (hb : |b + R| ≤ eps) (hv : |v - (2 * R - C * Z)| ≤ eps) |
| 1104 | (hbudget : coneErrorBudget F M eps lam ≤ 1 / 100) : |
| 1105 | b * v ≤ 74 / 100 ∧ |
| 1106 | 2 * b * v + b ^ 2 / (2 + 2 * lam) + 2 * lam * v ^ 2 ≤ 168 / 100 := by |
| 1107 | let v₀ := 2 * R - C * Z |
| 1108 | have hvabs : |v| ≤ M + 1 := by |
| 1109 | have h := abs_add_le (v - v₀) v₀ |
| 1110 | rw [sub_add_cancel] at h |
| 1111 | change |v - v₀| ≤ eps at hv |
| 1112 | change |v₀| ≤ M at hmain |
| 1113 | linarith |
| 1114 | have hbabs : |b| ≤ F + 1 := by |
| 1115 | have h := abs_sub (b + R) R |
| 1116 | rw [add_sub_cancel_right, abs_of_nonneg hR] at h |
| 1117 | linarith |
| 1118 | have hcross : |b * v + R * v₀| ≤ eps * (M + F + 1) := by |
| 1119 | have he : b * v + R * v₀ = (b + R) * v - R * (v - v₀) := by ring |
| 1120 | rw [he] |
| 1121 | apply (abs_sub _ _).trans |
| 1122 | rw [abs_mul, abs_mul, abs_of_nonneg hR] |
| 1123 | have h₁ := mul_le_mul hb hvabs (abs_nonneg v) heps |
| 1124 | have h₂ := mul_le_mul hR' hv (abs_nonneg _) hF |
| 1125 | nlinarith |
| 1126 | have hdiff : |b - R| ≤ 2 * F + 1 := by |
| 1127 | have h := abs_sub b R |
| 1128 | rw [abs_of_nonneg hR] at h |
| 1129 | linarith |
| 1130 | have hsq : b ^ 2 ≤ R ^ 2 + eps * (2 * F + 1) := by |
| 1131 | have hprod := mul_le_mul hb hdiff (abs_nonneg (b - R)) heps |
| 1132 | rw [← abs_mul] at hprod |
| 1133 | have he : (b + R) * (b - R) = b ^ 2 - R ^ 2 := by ring |
| 1134 | rw [he] at hprod |
| 1135 | have h := (abs_le.mp hprod).2 |
| 1136 | linarith |
| 1137 | have ha : (2 : ℝ) ≤ 2 + 2 * lam := by linarith |
| 1138 | have hdiv := div_le_div_of_nonneg_left (sq_nonneg b) (by norm_num : (0 : ℝ) < 2) ha |
| 1139 | have hvsq : v ^ 2 ≤ (M + 1) ^ 2 := by |
| 1140 | have h := (sq_le_sq₀ (abs_nonneg v) (by linarith : 0 ≤ M + 1)).mpr hvabs |
| 1141 | simpa only [sq_abs] using h |
| 1142 | have hvsq' := mul_le_mul_of_nonneg_left hvsq (show 0 ≤ 2 * lam by linarith) |
| 1143 | have hideal := ideal_cross_bound hR hC hC' hZ |
| 1144 | change -R * v₀ ≤ -2 * R ^ 2 + (241 / 100) * R at hideal |
| 1145 | have hcross' := (abs_le.mp hcross).2 |
| 1146 | have hnonneg₁ : 0 ≤ eps * (2 * F + 1) / 2 := by positivity |
| 1147 | have hnonneg₂ : 0 ≤ 2 * lam * (M + 1) ^ 2 := by positivity |
| 1148 | dsimp [coneErrorBudget] at hbudget |
| 1149 | have hcrossBound : b * v ≤ -2 * R ^ 2 + (241 / 100) * R + eps * (M + F + 1) := by |
| 1150 | calc |
| 1151 | _ = (b * v + R * v₀) + (-R * v₀) := by ring |
| 1152 | _ ≤ eps * (M + F + 1) + (-2 * R ^ 2 + (241 / 100) * R) := add_le_add hcross' hideal |
| 1153 | _ = _ := by ring |
| 1154 | constructor |
| 1155 | · have herr : eps * (M + F + 1) ≤ 1 / 200 := by |
| 1156 | nlinarith only [hbudget, hnonneg₁, hnonneg₂] |
| 1157 | calc |
| 1158 | _ ≤ -2 * R ^ 2 + (241 / 100) * R + eps * (M + F + 1) := hcrossBound |
| 1159 | _ ≤ 73 / 100 + 1 / 200 := add_le_add (first_quadratic_margin R) herr |
| 1160 | _ ≤ _ := by norm_num |
| 1161 | · have hdiv' : b ^ 2 / (2 + 2 * lam) ≤ R ^ 2 / 2 + eps * (2 * F + 1) / 2 := by |
| 1162 | apply hdiv.trans |
| 1163 | linarith only [hsq] |
| 1164 | have hsum := add_le_add |
| 1165 | (add_le_add (mul_le_mul_of_nonneg_left hcrossBound (by norm_num : (0 : ℝ) ≤ 2)) hdiv') hvsq' |
| 1166 | calc |
| 1167 | _ ≤ 2 * (-2 * R ^ 2 + (241 / 100) * R + eps * (M + F + 1)) + |
| 1168 | (R ^ 2 / 2 + eps * (2 * F + 1) / 2) + 2 * lam * (M + 1) ^ 2 := by |
| 1169 | convert! hsum using 1 |
| 1170 | ring |
| 1171 | _ = (-(7 / 2) * R ^ 2 + (241 / 50) * R) + |
| 1172 | (2 * eps * (M + F + 1) + eps * (2 * F + 1) / 2 + 2 * lam * (M + 1) ^ 2) := by ring |
| 1173 | _ ≤ 167 / 100 + 1 / 100 := add_le_add (second_quadratic_margin R) hbudget |
| 1174 | _ = _ := by norm_num |
| 1175 | |
| 1176 | theorem perturbed_true_cone {lam R C Z b v eps F M : ℝ} |
| 1177 | (hlam : 0 < lam) (hF : 0 ≤ F) (hM : 0 ≤ M) (heps : 0 ≤ eps) (heps' : eps ≤ 1) |
| 1178 | (hR : 0 ≤ R) (hR' : R ≤ F) (hC : 0 ≤ C) (hC' : C ≤ 2001 / 1000) |
| 1179 | (hZ : Z ≤ 6 / 5) (hmain : |2 * R - C * Z| ≤ M) |
| 1180 | (hb : |b + R| ≤ eps) (hv : |v - (2 * R - C * Z)| ≤ eps) |
| 1181 | (hbudget : coneErrorBudget F M eps lam ≤ 1 / 100) : |
| 1182 | 0 < (2 + 2 * lam) - b * v ∧ |
| 1183 | 2 * b * v + b ^ 2 / (2 + 2 * lam) + ((2 + 2 * lam) - 2) * v ^ 2 < 2 ∧ |
| 1184 | 2 < (2 + 2 * lam) * (1 + (b / (2 + 2 * lam)) ^ 2) := by |
| 1185 | have h := perturbed_cone_margins hlam.le hF hM heps heps' hR hR' hC hC' hZ hmain hb hv hbudget |
| 1186 | have hsq := sq_nonneg (b / (2 + 2 * lam)) |
| 1187 | have hprod := mul_nonneg (show 0 ≤ 2 + 2 * lam by linarith) hsq |
| 1188 | constructor |
| 1189 | · linarith [h.1] |
| 1190 | constructor |
| 1191 | · nlinarith [h.2] |
| 1192 | · nlinarith |
| 1193 | |
| 1194 | /-! ## The axial history error is derived from actual moments -/ |
| 1195 | |
| 1196 | theorem W_pulse_error_bound (w : ResetWitness d K) |
| 1197 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 1198 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y : ℝ} |
| 1199 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) |
| 1200 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1201 | |1 - W d amp (d.core.pulseStart + y, eta)| ≤ |
| 1202 | 4 * averageConstant d.core.P d.core.m * E w (d.core.pulseStart + y, eta) := by |
| 1203 | have hid : 1 - W d amp (d.core.pulseStart + y, eta) = E w (d.core.pulseStart + y, eta) * |
| 1204 | ((2 * (1 / 2 - d.h) * eta - (1 - eta ^ 2) * shapeGradient eta) * normalizedLag d.core amp eta y + |
| 1205 | (1 - eta ^ 2) * deriv (fun t => normalizedLag d.core amp t y) eta) := by |
| 1206 | rw [W_formula d ha, Ubar_pulse w amp eta hy', Ubar_parameter_pulse w ha eta hy hy'] |
| 1207 | dsimp only [Prod.snd, StressAlgebra.axialExponent, StressAlgebra.coordinateFactor] |
| 1208 | ring |
| 1209 | have hdata := pulse_data_bounds d.core hwait hsmall |
| 1210 | ((ha.differentiable (by simp) eta).hasDerivAt) heta hamp hamp' hy |
| 1211 | obtain ⟨hcoef, hd, _⟩ := geometric_coefficient_bounds d.h_pos.le d.h_lt_half.le heta |
| 1212 | have h₁ := mul_le_mul hcoef hdata.2.1 (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 3) |
| 1213 | have h₂ := mul_le_mul hd hdata.2.2 (abs_nonneg _) zero_le_one |
| 1214 | rw [← abs_mul] at h₁ h₂ |
| 1215 | have hs := abs_add_le |
| 1216 | ((2 * (1 / 2 - d.h) * eta - (1 - eta ^ 2) * shapeGradient eta) * normalizedLag d.core amp eta y) |
| 1217 | ((1 - eta ^ 2) * deriv (fun t => normalizedLag d.core amp t y) eta) |
| 1218 | rw [hid, abs_mul, abs_of_pos (E_pos w _)] |
| 1219 | have hm : |(2 * (1 / 2 - d.h) * eta - (1 - eta ^ 2) * shapeGradient eta) * normalizedLag d.core amp eta y + |
| 1220 | (1 - eta ^ 2) * deriv (fun t => normalizedLag d.core amp t y) eta| ≤ 4 * averageConstant d.core.P d.core.m := by |
| 1221 | linarith |
| 1222 | convert! mul_le_mul_of_nonneg_left hm (E_pos w _).le using 1 |
| 1223 | ring |
| 1224 | |
| 1225 | private theorem normalized_axial_bound {E u R a b c S Seta P Peta M F Ks Kp Kpe : ℝ} |
| 1226 | (hE : 0 ≤ E) (hu : |u| ≤ M) (hR : |R| ≤ F) |
| 1227 | (ha : |a| ≤ 2) (hb : |b| ≤ 1) (hc : |c| ≤ 4) |
| 1228 | (hS : |S| ≤ Ks) (hSe : |Seta| ≤ Ks) (hP : |P| ≤ Kp) (hPe : |Peta| ≤ Kpe) : |
| 1229 | |E * (u * R + a * S - b * Seta + c * P - b * Peta)| ≤ E * (M * F + 3 * Ks + 4 * Kp + Kpe) := by |
| 1230 | have huR := mul_le_mul hu hR (abs_nonneg R) ((abs_nonneg u).trans hu) |
| 1231 | have haS := mul_le_mul ha hS (abs_nonneg S) (by norm_num : (0 : ℝ) ≤ 2) |
| 1232 | have hbSe := mul_le_mul hb hSe (abs_nonneg Seta) zero_le_one |
| 1233 | have hcP := mul_le_mul hc hP (abs_nonneg P) (by norm_num : (0 : ℝ) ≤ 4) |
| 1234 | have hbPe := mul_le_mul hb hPe (abs_nonneg Peta) zero_le_one |
| 1235 | rw [← abs_mul] at huR haS hbSe hcP hbPe |
| 1236 | have hs : |u * R + a * S - b * Seta + c * P - b * Peta| ≤ M * F + 3 * Ks + 4 * Kp + Kpe := by |
| 1237 | linarith [abs_add_le (u * R) (a * S), abs_sub (u * R + a * S) (b * Seta), |
| 1238 | abs_add_le (u * R + a * S - b * Seta) (c * P), |
| 1239 | abs_sub (u * R + a * S - b * Seta + c * P) (b * Peta)] |
| 1240 | rw [abs_mul, abs_of_nonneg hE] |
| 1241 | exact mul_le_mul_of_nonneg_left hs hE |
| 1242 | |
| 1243 | noncomputable def axialErrorConstant (P m : ℝ) : ℝ := energyConstant P m * |
| 1244 | (24 * averageConstant P m * forceConstant P m + |
| 1245 | 3 * PulseEnergyHistory.historyConstant P m * Real.exp 26 + 4 * FuturePressureBounds.envelopeConstant) |
| 1246 | |
| 1247 | theorem axialErrorConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : 0 < axialErrorConstant P m := by |
| 1248 | have he := energyConstant_pos hP m |
| 1249 | have hm := averageConstant_pos hP m |
| 1250 | have hf := forceConstant_pos hP m |
| 1251 | have hh := PulseEnergyHistory.historyConstant_pos P m |
| 1252 | have hp := FuturePressureBounds.envelopeConstant_pos |
| 1253 | dsimp [axialErrorConstant] |
| 1254 | positivity |
| 1255 | |
| 1256 | theorem axialHistoryError_bound (w : ResetWitness d K) |
| 1257 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 1258 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y : ℝ} |
| 1259 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) |
| 1260 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1261 | |axialHistoryError w amp eta y| ≤ axialErrorConstant d.core.P d.core.m * d.core.lam ^ 29 := by |
| 1262 | let p := (d.core.pulseStart + y, eta) |
| 1263 | have hE : 0 < E w p := E_pos w p |
| 1264 | have hX : 0 < X p := X_pos p |
| 1265 | have hEsq : 0 < E w p ^ 2 := sq_pos_of_pos hE |
| 1266 | have hden : 0 < X p * E w p ^ 2 := mul_pos hX hEsq |
| 1267 | have hdata := pulse_data_bounds d.core hwait hsmall |
| 1268 | ((ha.differentiable (by simp) eta).hasDerivAt) heta hamp hamp' hy |
| 1269 | have hW := W_pulse_error_bound w hwait hsmall ha heta hamp hamp' hy hy' |
| 1270 | have hS := PulseEnergyHistory.pulse_history_bounds w ha hwait hsmall heta hamp hamp' hy hy' |
| 1271 | have hP := pulse_pressure_bounds w heta hy hy' |
| 1272 | have hcoef := geometric_coefficient_bounds d.h_pos.le d.h_lt_half.le heta |
| 1273 | have ha' : |4 * d.h * eta| ≤ 2 := by |
| 1274 | rw [abs_mul, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 4), abs_of_pos d.h_pos] |
| 1275 | have h := mul_le_mul d.h_lt_half.le heta (abs_nonneg eta) (by norm_num : (0 : ℝ) ≤ 1 / 2) |
| 1276 | nlinarith |
| 1277 | have hc' : |4 * (1 / 2 + d.h) * eta| ≤ 4 := by |
| 1278 | rw [abs_mul, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 4), |
| 1279 | abs_of_pos (by linarith [d.h_pos] : 0 < 1 / 2 + d.h)] |
| 1280 | have h := mul_le_mul (show 1 / 2 + d.h ≤ 1 by linarith [d.h_lt_half]) heta (abs_nonneg eta) zero_le_one |
| 1281 | nlinarith |
| 1282 | have hw' : |(1 - W d amp p) / E w p| ≤ 4 * averageConstant d.core.P d.core.m := by |
| 1283 | rw [abs_div, abs_of_pos hE] |
| 1284 | exact (div_le_iff₀ hE).mpr hW |
| 1285 | have hs' : |S w amp p / (X p * E w p ^ 2)| ≤ |
| 1286 | PulseEnergyHistory.historyConstant d.core.P d.core.m * Real.exp 26 / d.core.lam := by |
| 1287 | rw [abs_div, abs_of_pos hden] |
| 1288 | exact hS.1 |
| 1289 | have hse' : |dEta (S w amp) p / (X p * E w p ^ 2)| ≤ |
| 1290 | PulseEnergyHistory.historyConstant d.core.P d.core.m * Real.exp 26 / d.core.lam := by |
| 1291 | rw [abs_div, abs_of_pos hden] |
| 1292 | exact hS.2 |
| 1293 | have hp' : |Pi w p / E w p ^ 2| ≤ FuturePressureBounds.envelopeConstant / 2 := by |
| 1294 | rw [abs_div, abs_of_pos hEsq] |
| 1295 | exact (div_le_iff₀ hEsq).mpr hP.1 |
| 1296 | have hpe' : |dEta (Pi w) p / E w p ^ 2| ≤ 2 * FuturePressureBounds.envelopeConstant := by |
| 1297 | rw [abs_div, abs_of_pos hEsq] |
| 1298 | apply (div_le_iff₀ hEsq).mpr |
| 1299 | apply hP.2.trans |
| 1300 | have h := mul_le_mul_of_nonneg_left heta |
| 1301 | (mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) FuturePressureBounds.envelopeConstant_pos.le) |
| 1302 | have h' := mul_le_mul_of_nonneg_right h hEsq.le |
| 1303 | simpa only [mul_one] using h' |
| 1304 | have hid : axialHistoryError w amp eta y = E w p * |
| 1305 | (((1 - W d amp p) / E w p) * pulseRatio d.core amp (y, eta) + |
| 1306 | (4 * d.h * eta) * (S w amp p / (X p * E w p ^ 2)) - |
| 1307 | (1 - eta ^ 2) * (dEta (S w amp) p / (X p * E w p ^ 2)) + |
| 1308 | (4 * (1 / 2 + d.h) * eta) * (Pi w p / E w p ^ 2) - |
| 1309 | (1 - eta ^ 2) * (dEta (Pi w) p / E w p ^ 2)) := by |
| 1310 | unfold axialHistoryError |
| 1311 | dsimp only [p] at * |
| 1312 | field_simp [hE.ne', hX.ne'] ; ring |
| 1313 | have hb := normalized_axial_bound hE.le hw' hdata.1 ha' hcoef.2.1 hc' hs' hse' hp' hpe' |
| 1314 | rw [← hid] at hb |
| 1315 | let A := 24 * averageConstant d.core.P d.core.m * forceConstant d.core.P d.core.m + |
| 1316 | 4 * FuturePressureBounds.envelopeConstant |
| 1317 | let B := 3 * PulseEnergyHistory.historyConstant d.core.P d.core.m * Real.exp 26 |
| 1318 | have hA : 0 ≤ A := by |
| 1319 | have hm := averageConstant_pos d.core.P_pos d.core.m |
| 1320 | have hf := forceConstant_pos d.core.P_pos d.core.m |
| 1321 | have hp := FuturePressureBounds.envelopeConstant_pos |
| 1322 | dsimp [A] |
| 1323 | positivity |
| 1324 | have hB : 0 ≤ B := by |
| 1325 | have hh := PulseEnergyHistory.historyConstant_pos d.core.P d.core.m |
| 1326 | dsimp [B] |
| 1327 | positivity |
| 1328 | have hb' : |axialHistoryError w amp eta y| ≤ E w p * (A + B / d.core.lam) := by |
| 1329 | convert! hb using 1 |
| 1330 | dsimp [A, B] |
| 1331 | ring |
| 1332 | have hAB : A + B / d.core.lam ≤ (A + B) / d.core.lam := by |
| 1333 | apply (le_div_iff₀ d.core.lam_pos).mpr |
| 1334 | have hl : d.core.lam ≤ 1 := by linarith [d.core.lam_lt] |
| 1335 | have hx := mul_le_mul_of_nonneg_left hl hA |
| 1336 | rw [add_mul, div_mul_cancel₀ _ d.core.lam_pos.ne'] |
| 1337 | simpa only [mul_one] using add_le_add_left hx B |
| 1338 | have he : E w p ≤ energyConstant d.core.P d.core.m * d.core.lam ^ 30 := by |
| 1339 | rw [E_before w eta (by dsimp [Parameters.endpoint]; linarith)] |
| 1340 | exact pulse_angular_small d.core hwait eta hy |
| 1341 | calc |
| 1342 | _ ≤ E w p * (A + B) / d.core.lam := by |
| 1343 | simpa only [mul_div_assoc] using hb'.trans (mul_le_mul_of_nonneg_left hAB hE.le) |
| 1344 | _ ≤ (energyConstant d.core.P d.core.m * d.core.lam ^ 30) * (A + B) / d.core.lam := by |
| 1345 | exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right he (add_nonneg hA hB)) d.core.lam_pos.le |
| 1346 | _ = axialErrorConstant d.core.P d.core.m * d.core.lam ^ 29 := by |
| 1347 | have hc : axialErrorConstant d.core.P d.core.m = energyConstant d.core.P d.core.m * (A + B) := by |
| 1348 | dsimp [axialErrorConstant, A, B] |
| 1349 | ring |
| 1350 | rw [hc] |
| 1351 | field_simp [d.core.lam_pos.ne'] |
| 1352 | |
| 1353 | /-! ## Division by the angular lag near the equator -/ |
| 1354 | |
| 1355 | theorem denominator_bounds (d : TailData) {eta Q : ℝ} (heta : |eta| ≤ 1) |
| 1356 | (hQ : equilibriumNumerator d eta / 2 ≤ Q) : |
| 1357 | 0 < Q ∧ 1 / Q ≤ 4 / d.core.lam ∧ |eta| / Q ≤ 4 / Real.sqrt d.core.lam := by |
| 1358 | have hA := (pulse_geometric_bounds d heta).2 |
| 1359 | have hq : d.core.lam / 4 + eta ^ 2 / 5 ≤ Q := by linarith |
| 1360 | have hQpos : 0 < Q := by nlinarith [d.core.lam_pos, sq_nonneg eta] |
| 1361 | have hs := Real.sqrt_pos.mpr d.core.lam_pos |
| 1362 | have hs₂ := Real.sq_sqrt d.core.lam_pos.le |
| 1363 | refine ⟨hQpos, ?_, ?_⟩ |
| 1364 | · apply (div_le_div_iff₀ hQpos d.core.lam_pos).mpr |
| 1365 | nlinarith [sq_nonneg eta] |
| 1366 | · apply (div_le_div_iff₀ hQpos hs).mpr |
| 1367 | nlinarith [sq_nonneg (Real.sqrt d.core.lam - |eta| / 2), sq_abs eta] |
| 1368 | |
| 1369 | noncomputable def mainDirectionBound (P m : ℝ) : ℝ := |
| 1370 | 18 * forceConstant P m + 3 * derivativeConstant P m |
| 1371 | |
| 1372 | theorem mainDirectionBound_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 1373 | 0 < mainDirectionBound P m := by |
| 1374 | have hf := forceConstant_pos hP m |
| 1375 | have hd := derivativeConstant_pos hP m |
| 1376 | dsimp [mainDirectionBound] |
| 1377 | positivity |
| 1378 | |
| 1379 | theorem mainDirection_abs_le (d : TailData) |
| 1380 | (hsmall : d.core.lam ≤ 1 / 100000) (hh : d.h ≤ d.core.lam / 100000) |
| 1381 | {amp : ℝ → ℝ} {eta : ℝ} (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (y : ℝ) : |
| 1382 | |mainDirection d amp eta y| ≤ mainDirectionBound d.core.P d.core.m := by |
| 1383 | have hc := derivativeCoefficient_le d hsmall hh eta |
| 1384 | have hc₀ := derivativeCoefficient_nonneg d eta |
| 1385 | have hR : |pulseRatio d.core amp (y, eta)| ≤ 6 * forceConstant d.core.P d.core.m := by |
| 1386 | rw [← forcing_eq_pulseRatio] |
| 1387 | apply (forcing_abs_le d.core (by linarith) _ _ y).trans |
| 1388 | have hsum : |parameterPolynomial eta| + |amp eta| ≤ 6 := by linarith [parameterPolynomial_bound heta] |
| 1389 | simpa only [mul_comm] using |
| 1390 | mul_le_mul_of_nonneg_left hsum (forceConstant_pos d.core.P_pos d.core.m).le |
| 1391 | have hZ := scaledPulse_deriv_abs_le d.core (by linarith) amp heta hamp y |
| 1392 | have hr₀ : 0 ≤ (1 - d.core.lam) / decay d.core := |
| 1393 | div_nonneg (by linarith [d.core.lam_lt]) (decay_pos d.core).le |
| 1394 | have hr : (1 - d.core.lam) / decay d.core ≤ 3 := by |
| 1395 | apply (div_le_iff₀ (decay_pos d.core)).mpr |
| 1396 | dsimp [decay] |
| 1397 | linarith [d.core.lam_lt] |
| 1398 | have h₁ := mul_le_mul hr hR (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 3) |
| 1399 | have h₂ := mul_le_mul (hc.trans (by norm_num : (2001 / 1000 : ℝ) ≤ 3)) hZ |
| 1400 | (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 3) |
| 1401 | rw [mainDirection] |
| 1402 | apply (abs_sub _ _).trans |
| 1403 | rw [abs_mul, abs_mul, abs_of_nonneg hr₀, abs_of_nonneg hc₀] |
| 1404 | dsimp [mainDirectionBound] |
| 1405 | nlinarith |
| 1406 | |
| 1407 | private theorem quotient_remainder_bound |
| 1408 | {N Q q B C D eta e m H eQ eE eM eH BM I J : ℝ} |
| 1409 | (hQ : 0 < Q) (hid : N = q * B + C * e - D * eta * m + H) |
| 1410 | (hC : |C| ≤ 1) (hD : |D| ≤ 1) (hq : |Q - q| ≤ eQ) |
| 1411 | (he : |e| ≤ eE) (hm : |m| ≤ eM) (hH : |H| ≤ eH) (hB : |B| ≤ BM) |
| 1412 | (hI : 1 / Q ≤ I) (hJ : |eta| / Q ≤ J) : |
| 1413 | |N / Q - B| ≤ I * (eQ * BM + eE + eH) + J * eM := by |
| 1414 | have hq' : |q - Q| ≤ eQ := by simpa only [abs_sub_comm] using hq |
| 1415 | have ht₁ := mul_le_mul hq' hB (abs_nonneg B) ((abs_nonneg _).trans hq') |
| 1416 | have ht₂ := mul_le_mul hC he (abs_nonneg e) zero_le_one |
| 1417 | have hDeta : |D * eta| ≤ |eta| := by |
| 1418 | rw [abs_mul] |
| 1419 | simpa only [one_mul] using mul_le_mul_of_nonneg_right hD (abs_nonneg eta) |
| 1420 | have ht₃ := mul_le_mul hDeta hm (abs_nonneg m) (abs_nonneg eta) |
| 1421 | rw [← abs_mul] at ht₁ ht₂ ht₃ |
| 1422 | have hs : |(q - Q) * B + C * e + H - D * eta * m| ≤ |
| 1423 | eQ * BM + eE + eH + |eta| * eM := by |
| 1424 | linarith [abs_add_le ((q - Q) * B) (C * e), abs_add_le ((q - Q) * B + C * e) H, |
| 1425 | abs_sub ((q - Q) * B + C * e + H) (D * eta * m)] |
| 1426 | have heq : N / Q - B = ((q - Q) * B + C * e + H - D * eta * m) / Q := by |
| 1427 | rw [hid] |
| 1428 | field_simp ; ring |
| 1429 | rw [heq, abs_div, abs_of_pos hQ] |
| 1430 | have hA : 0 ≤ eQ * BM + eE + eH := by |
| 1431 | have heQ := (abs_nonneg _).trans hq |
| 1432 | have heB := (abs_nonneg _).trans hB |
| 1433 | have heE := (abs_nonneg _).trans he |
| 1434 | have heH := (abs_nonneg _).trans hH |
| 1435 | positivity |
| 1436 | calc |
| 1437 | _ ≤ (eQ * BM + eE + eH + |eta| * eM) / Q := div_le_div_of_nonneg_right hs hQ.le |
| 1438 | _ = (eQ * BM + eE + eH) * (1 / Q) + eM * (|eta| / Q) := by ring |
| 1439 | _ ≤ (eQ * BM + eE + eH) * I + eM * J := add_le_add |
| 1440 | (mul_le_mul_of_nonneg_left hI hA) |
| 1441 | (mul_le_mul_of_nonneg_left hJ ((abs_nonneg _).trans hm)) |
| 1442 | _ = _ := by ring |
| 1443 | |
| 1444 | /-- A quantified division step retaining every error term. Its two |
| 1445 | angular-lag hypotheses are supplied by the shaped-wait estimate. -/ |
| 1446 | theorem directionRatio_error_bound (w : ResetWitness d K) |
| 1447 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) |
| 1448 | (hsmall : d.core.lam ≤ 1 / 100000) (hh : d.h ≤ d.core.lam / 100000) |
| 1449 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y Cq : ℝ} |
| 1450 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) |
| 1451 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) |
| 1452 | (hQlow : equilibriumNumerator d eta / 2 ≤ Qs w amp (d.core.pulseStart + y, eta)) |
| 1453 | (hQerr : |Qs w amp (d.core.pulseStart + y, eta) - angularEquilibrium d eta| ≤ Cq * d.core.lam ^ 28) : |
| 1454 | |directionRatio w amp (d.core.pulseStart + y, eta) - mainDirection d amp eta y| ≤ |
| 1455 | (4 / d.core.lam) * (Cq * d.core.lam ^ 28 * mainDirectionBound d.core.P d.core.m + |
| 1456 | fullLagBound d.core.P d.core.m * d.core.lam ^ 2 + axialErrorConstant d.core.P d.core.m * d.core.lam ^ 29) + |
| 1457 | (4 / Real.sqrt d.core.lam) * (3 * mainBound * |deriv amp eta| + |
| 1458 | parameterLagConstant d.core.P d.core.m * d.core.lam ^ 2) := by |
| 1459 | have hden := denominator_bounds d heta hQlow |
| 1460 | have hdata := fullError_bounds_of_amplitude_bounds d.core hwait (by linarith) |
| 1461 | ((ha.differentiable (by simp) eta).hasDerivAt) heta hamp hamp' hy |
| 1462 | have hmp := normalizedLag_parameter_fine_bound d.core hwait (by linarith) |
| 1463 | ((ha.differentiable (by simp) eta).hasDerivAt) heta hamp' hy |
| 1464 | have hH := axialHistoryError_bound w hwait (by linarith) ha heta hamp hamp' hy hy' |
| 1465 | have hB := mainDirection_abs_le d hsmall hh heta hamp y |
| 1466 | have hC : |(1 / 2 - d.h) + geometricSource d eta| ≤ 1 := by |
| 1467 | rw [abs_of_nonneg (by have hg := geometricSource_nonneg d eta; linarith [d.h_lt_half])] |
| 1468 | exact (pulse_geometric_bounds d heta).1 |
| 1469 | have hD : |1 / 2 - d.h| ≤ 1 := by |
| 1470 | rw [abs_of_nonneg (by linarith [d.h_lt_half])] |
| 1471 | linarith [d.h_pos] |
| 1472 | have hb := quotient_remainder_bound hden.1 (Ns_pulse_expansion w ha eta hy hy') |
| 1473 | hC hD hQerr hdata.1 hmp hH hB hden.2.1 hden.2.2 |
| 1474 | simpa only [directionRatio, div_div] using hb |
| 1475 | |
| 1476 | noncomputable def mainRatio (c : Parameters) (amp : ℝ → ℝ) (eta y : ℝ) : ℝ := |
| 1477 | amp eta * mainPulse (c.lam * y) |
| 1478 | |
| 1479 | noncomputable def mainSlope (c : Parameters) (amp : ℝ → ℝ) (eta y : ℝ) : ℝ := |
| 1480 | amp eta * deriv mainPulse (c.lam * y) |
| 1481 | |
| 1482 | noncomputable def idealDirection (d : TailData) (amp : ℝ → ℝ) (eta y : ℝ) : ℝ := |
| 1483 | 2 * mainRatio d.core amp eta y - derivativeCoefficient d eta * mainSlope d.core amp eta y |
| 1484 | |
| 1485 | noncomputable def mainRatioBound : ℝ := 2 * mainBound |
| 1486 | noncomputable def idealDirectionBound : ℝ := 4 * mainBound + 6 * mainFirstBound |
| 1487 | |
| 1488 | theorem mainRatioBound_pos : 0 < mainRatioBound := mul_pos (by norm_num) mainBound_pos |
| 1489 | theorem idealDirectionBound_pos : 0 < idealDirectionBound := by |
| 1490 | have h₁ := mainBound_pos |
| 1491 | have h₂ := mainFirstBound_pos |
| 1492 | dsimp [idealDirectionBound] |
| 1493 | positivity |
| 1494 | |
| 1495 | theorem main_profile_bounds (d : TailData) |
| 1496 | (hsmall : d.core.lam ≤ 1 / 100000) (hh : d.h ≤ d.core.lam / 100000) |
| 1497 | {amp : ℝ → ℝ} {eta y : ℝ} (hamp₀ : 0 ≤ amp eta) (hamp : |amp eta| ≤ 6 / 5) (hy : 0 ≤ y) : |
| 1498 | 0 ≤ mainRatio d.core amp eta y ∧ mainRatio d.core amp eta y ≤ mainRatioBound ∧ |
| 1499 | mainSlope d.core amp eta y ≤ 6 / 5 ∧ |idealDirection d amp eta y| ≤ idealDirectionBound := by |
| 1500 | have hR₀ : 0 ≤ mainRatio d.core amp eta y := mul_nonneg hamp₀ |
| 1501 | (PulseAmplitude.mainPulse_nonneg (mul_nonneg d.core.lam_pos.le hy)) |
| 1502 | have hR : |mainRatio d.core amp eta y| ≤ mainRatioBound := by |
| 1503 | rw [mainRatio, abs_mul] |
| 1504 | have h := mul_le_mul hamp (mainPulse_abs_le (d.core.lam * y)) (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 6 / 5) |
| 1505 | dsimp [mainRatioBound] |
| 1506 | nlinarith [mainBound_pos] |
| 1507 | have hZ : |mainSlope d.core amp eta y| ≤ 2 * mainFirstBound := by |
| 1508 | rw [mainSlope, abs_mul] |
| 1509 | have h := mul_le_mul hamp (main_first_le (d.core.lam * y)) (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 6 / 5) |
| 1510 | nlinarith [mainFirstBound_pos] |
| 1511 | have hZup := mul_le_mul_of_nonneg_left |
| 1512 | (mainPulse_deriv_le_one (mul_nonneg d.core.lam_pos.le hy)) hamp₀ |
| 1513 | have hCd : |derivativeCoefficient d eta| ≤ 3 := by |
| 1514 | rw [abs_of_nonneg (derivativeCoefficient_nonneg d eta)] |
| 1515 | exact (derivativeCoefficient_le d hsmall hh eta).trans (by norm_num) |
| 1516 | refine ⟨hR₀, (abs_le.mp hR).2, ?_, ?_⟩ |
| 1517 | · dsimp [mainSlope] |
| 1518 | have h := (abs_le.mp hamp).2 |
| 1519 | linarith |
| 1520 | · have h₂ := mul_le_mul hCd hZ (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 3) |
| 1521 | rw [idealDirection] |
| 1522 | apply (abs_sub _ _).trans |
| 1523 | rw [abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2), abs_mul] |
| 1524 | dsimp [idealDirectionBound, mainRatioBound] at * |
| 1525 | nlinarith |
| 1526 | |
| 1527 | theorem pulseRatio_abs_le (c : Parameters) (hsmall : c.lam ≤ 1 / 120) |
| 1528 | (amp : ℝ → ℝ) {eta : ℝ} (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (y : ℝ) : |
| 1529 | |pulseRatio c amp (y, eta)| ≤ 6 * forceConstant c.P c.m := by |
| 1530 | rw [← forcing_eq_pulseRatio] |
| 1531 | apply (forcing_abs_le c hsmall _ _ y).trans |
| 1532 | have hsum : |parameterPolynomial eta| + |amp eta| ≤ 6 := by linarith [parameterPolynomial_bound heta] |
| 1533 | simpa only [mul_comm] using mul_le_mul_of_nonneg_left hsum (forceConstant_pos c.P_pos c.m).le |
| 1534 | |
| 1535 | noncomputable def shearErrorConstant (P m : ℝ) : ℝ := |
| 1536 | valueRepairConstant P m + 2 * derivativeConstant P m + 12 * forceConstant P m |
| 1537 | |
| 1538 | noncomputable def directionMainErrorConstant (P m : ℝ) : ℝ := |
| 1539 | 18 * forceConstant P m + 2 * valueRepairConstant P m + 3 * derivativeRepairConstant P m |
| 1540 | |
| 1541 | theorem shearErrorConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 1542 | 0 < shearErrorConstant P m := by |
| 1543 | have hv := valueRepairConstant_pos hP m |
| 1544 | have hd := derivativeConstant_pos hP m |
| 1545 | have hf := forceConstant_pos hP m |
| 1546 | dsimp [shearErrorConstant] |
| 1547 | positivity |
| 1548 | |
| 1549 | theorem directionMainErrorConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 1550 | 0 < directionMainErrorConstant P m := by |
| 1551 | have hv := valueRepairConstant_pos hP m |
| 1552 | have hd := derivativeRepairConstant_pos hP m |
| 1553 | have hf := forceConstant_pos hP m |
| 1554 | dsimp [directionMainErrorConstant] |
| 1555 | positivity |
| 1556 | |
| 1557 | theorem shearB_main_error (w : ResetWitness d K) (hsmall : d.core.lam ≤ 1 / 120) |
| 1558 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y : ℝ} |
| 1559 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1560 | |shearB w amp (d.core.pulseStart + y, eta) + mainRatio d.core amp eta y| ≤ |
| 1561 | shearErrorConstant d.core.P d.core.m * d.core.lam := by |
| 1562 | have hR := pulseRatio_abs_le d.core hsmall amp heta hamp y |
| 1563 | have hZ := scaledPulse_deriv_abs_le d.core hsmall amp heta hamp y |
| 1564 | have he := (scaledPulse_correction_bounds d.core hsmall amp heta hamp y).1 |
| 1565 | have hpow : d.core.lam ^ 2 ≤ d.core.lam := by nlinarith [d.core.lam_pos, d.core.lam_lt] |
| 1566 | have hscale := mul_le_mul_of_nonneg_left hpow (valueRepairConstant_pos d.core.P_pos d.core.m).le |
| 1567 | have hid : shearB w amp (d.core.pulseStart + y, eta) + mainRatio d.core amp eta y = |
| 1568 | -(pulseRatio d.core amp (y, eta) - mainRatio d.core amp eta y) + 2 * d.core.lam * |
| 1569 | (deriv (scaledPulse d.core amp eta) (d.core.lam * y) - pulseRatio d.core amp (y, eta)) := by |
| 1570 | rw [shearB_pulse w ha eta hy hy'] |
| 1571 | ring |
| 1572 | rw [hid] |
| 1573 | apply (abs_add_le _ _).trans |
| 1574 | rw [abs_neg, abs_mul, abs_of_nonneg (show 0 ≤ 2 * d.core.lam by linarith [d.core.lam_pos])] |
| 1575 | have hdiff := (abs_sub (deriv (scaledPulse d.core amp eta) (d.core.lam * y)) |
| 1576 | (pulseRatio d.core amp (y, eta))).trans (add_le_add hZ hR) |
| 1577 | have hm := mul_le_mul_of_nonneg_left hdiff (show 0 ≤ 2 * d.core.lam by linarith [d.core.lam_pos]) |
| 1578 | dsimp only [mainRatio] at * |
| 1579 | dsimp [shearErrorConstant] |
| 1580 | nlinarith |
| 1581 | |
| 1582 | theorem mainDirection_ideal_error (d : TailData) |
| 1583 | (hsmall : d.core.lam ≤ 1 / 100000) (hh : d.h ≤ d.core.lam / 100000) |
| 1584 | {amp : ℝ → ℝ} {eta : ℝ} (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (y : ℝ) : |
| 1585 | |mainDirection d amp eta y - idealDirection d amp eta y| ≤ |
| 1586 | directionMainErrorConstant d.core.P d.core.m * d.core.lam := by |
| 1587 | have hR := pulseRatio_abs_le d.core (by linarith) amp heta hamp y |
| 1588 | have hc := scaledPulse_correction_bounds d.core (by linarith) amp heta hamp y |
| 1589 | have hCd : |derivativeCoefficient d eta| ≤ 3 := by |
| 1590 | rw [abs_of_nonneg (derivativeCoefficient_nonneg d eta)] |
| 1591 | exact (derivativeCoefficient_le d hsmall hh eta).trans (by norm_num) |
| 1592 | have hratio : |d.core.lam / decay d.core| ≤ 3 * d.core.lam := by |
| 1593 | rw [abs_of_pos (div_pos d.core.lam_pos (decay_pos d.core))] |
| 1594 | exact decay_div_le_three d.core d.core.lam_pos.le |
| 1595 | have hid : mainDirection d amp eta y - idealDirection d amp eta y = |
| 1596 | (d.core.lam / decay d.core) * pulseRatio d.core amp (y, eta) + |
| 1597 | 2 * (pulseRatio d.core amp (y, eta) - mainRatio d.core amp eta y) - |
| 1598 | derivativeCoefficient d eta * |
| 1599 | (deriv (scaledPulse d.core amp eta) (d.core.lam * y) - mainSlope d.core amp eta y) := by |
| 1600 | unfold mainDirection idealDirection |
| 1601 | field_simp [(decay_pos d.core).ne'] |
| 1602 | dsimp [decay] |
| 1603 | ring |
| 1604 | have h₁ := mul_le_mul hratio hR (abs_nonneg _) (show 0 ≤ 3 * d.core.lam by linarith [d.core.lam_pos]) |
| 1605 | have h₃ := mul_le_mul hCd hc.2 (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 3) |
| 1606 | have hpow : d.core.lam ^ 2 ≤ d.core.lam := by nlinarith [d.core.lam_pos, d.core.lam_lt] |
| 1607 | have hscale := mul_le_mul_of_nonneg_left hpow (valueRepairConstant_pos d.core.P_pos d.core.m).le |
| 1608 | rw [hid] |
| 1609 | apply (abs_sub _ _).trans |
| 1610 | apply (add_le_add_left (abs_add_le _ _) _).trans |
| 1611 | rw [abs_mul, abs_mul, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2)] |
| 1612 | dsimp [directionMainErrorConstant, mainRatio, mainSlope] at * |
| 1613 | nlinarith |
| 1614 | |
| 1615 | /-! ## The shaped wait supplies the actual angular equilibrium error -/ |
| 1616 | |
| 1617 | theorem canonical_wait_for_power28 (c : Parameters) |
| 1618 | (hwait : c.wait = 60 * Real.log (1 / c.lam)) : |
| 1619 | ShapedWaitBounds.waitForPower c 28 ≤ c.wait := by |
| 1620 | rw [hwait] |
| 1621 | unfold ShapedWaitBounds.waitForPower |
| 1622 | rw [one_div, Real.log_inv] |
| 1623 | norm_num only [Nat.cast_ofNat] |
| 1624 | apply (div_le_iff₀ (show 0 < 1 - c.lam by linarith [c.lam_lt])).mpr |
| 1625 | have hl : 0 ≤ -Real.log c.lam := by |
| 1626 | have h := PulseAmplitude.log_inverse_nonneg c |
| 1627 | simpa only [one_div, Real.log_inv] using h |
| 1628 | have hm := mul_nonneg hl (show 0 ≤ (1 : ℝ) / 10 - c.lam by linarith [c.lam_lt]) |
| 1629 | nlinarith |
| 1630 | |
| 1631 | noncomputable def angularErrorConstant (P m : ℝ) : ℝ := 19 + 2 * sourceConstant P m |
| 1632 | |
| 1633 | theorem angularErrorConstant_pos {P : ℝ} (hP : 0 < P) (m : ℝ) : |
| 1634 | 0 < angularErrorConstant P m := by |
| 1635 | have h := sourceConstant_pos hP m |
| 1636 | dsimp [angularErrorConstant] |
| 1637 | positivity |
| 1638 | |
| 1639 | /-- The equilibrium approximation now has no initial-error hypothesis. -/ |
| 1640 | theorem actual_Qs_pulse_error (w : ResetWitness d K) |
| 1641 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 1642 | (hh : d.h ≤ 1 / 100) {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y : ℝ} |
| 1643 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) |
| 1644 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1645 | |Qs w amp (d.core.pulseStart + y, eta) - angularEquilibrium d eta| ≤ |
| 1646 | angularErrorConstant d.core.P d.core.m * d.core.lam ^ 28 := by |
| 1647 | have hi := ShapedWaitBounds.canonical_Qs_pulseStart_power_error w ha hh heta 28 |
| 1648 | (canonical_wait_for_power28 d.core hwait) |
| 1649 | change |Qs w amp (d.core.pulseStart, eta) - angularEquilibrium d eta| ≤ 19 * d.core.lam ^ 28 at hi |
| 1650 | have hb := Qs_pulse_equilibrium_error w hwait hsmall ha heta hamp hamp' hy hy' |
| 1651 | change |Qs w amp (d.core.pulseStart + y, eta) - angularEquilibrium d eta| ≤ |
| 1652 | |Qs w amp (d.core.pulseStart, eta) - angularEquilibrium d eta| * |
| 1653 | Real.exp (-(1 - d.core.lam) * y) + _ at hb |
| 1654 | have hr : 0 < 1 - d.core.lam := by linarith [d.core.lam_lt] |
| 1655 | have hexp : Real.exp (-(1 - d.core.lam) * y) ≤ 1 := |
| 1656 | Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hr.le) hy) |
| 1657 | have hiprod := mul_le_mul hi hexp (Real.exp_pos _).le |
| 1658 | (show 0 ≤ 19 * d.core.lam ^ 28 by positivity) |
| 1659 | have hpow : d.core.lam ^ 30 ≤ d.core.lam ^ 28 := |
| 1660 | pow_le_pow_of_le_one d.core.lam_pos.le (by linarith [d.core.lam_lt]) (by norm_num) |
| 1661 | have hs := mul_le_mul_of_nonneg_left hpow (sourceConstant_pos d.core.P_pos d.core.m).le |
| 1662 | have hfac : 1 ≤ 2 * (1 - d.core.lam) := by linarith [d.core.lam_lt] |
| 1663 | have hfac' := mul_le_mul_of_nonneg_left hfac |
| 1664 | (mul_nonneg (sourceConstant_pos d.core.P_pos d.core.m).le (pow_nonneg d.core.lam_pos.le 28)) |
| 1665 | have hc : sourceConstant d.core.P d.core.m * d.core.lam ^ 30 / (1 - d.core.lam) ≤ |
| 1666 | 2 * sourceConstant d.core.P d.core.m * d.core.lam ^ 28 := by |
| 1667 | apply (div_le_iff₀ hr).mpr |
| 1668 | nlinarith only [hs, hfac'] |
| 1669 | dsimp [angularErrorConstant] |
| 1670 | nlinarith only [hb, hiprod, hc] |
| 1671 | |
| 1672 | theorem actual_Qs_pulse_lower (w : ResetWitness d K) |
| 1673 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) (hsmall : d.core.lam ≤ 1 / 120) |
| 1674 | (hh : d.h ≤ 1 / 100) |
| 1675 | (hnum : angularErrorConstant d.core.P d.core.m * d.core.lam ^ 27 ≤ 1 / 4) |
| 1676 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y : ℝ} |
| 1677 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) |
| 1678 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1679 | equilibriumNumerator d eta / 2 ≤ Qs w amp (d.core.pulseStart + y, eta) := by |
| 1680 | have he := actual_Qs_pulse_error w hwait hsmall hh ha heta hamp hamp' hy hy' |
| 1681 | have herr := mul_le_mul_of_nonneg_right hnum d.core.lam_pos.le |
| 1682 | have hpow : d.core.lam ^ 27 * d.core.lam = d.core.lam ^ 28 := by ring |
| 1683 | rw [mul_assoc, hpow] at herr |
| 1684 | have hA := (pulse_geometric_bounds d heta).2 |
| 1685 | have heq : equilibriumNumerator d eta ≤ angularEquilibrium d eta := by |
| 1686 | apply (le_div_iff₀ (show 0 < 1 - d.core.lam by linarith [d.core.lam_lt])).mpr |
| 1687 | nlinarith [mul_nonneg (equilibriumNumerator_pos d eta).le d.core.lam_pos.le] |
| 1688 | have hlo := (abs_le.mp he).1 |
| 1689 | nlinarith [sq_nonneg eta] |
| 1690 | |
| 1691 | /-! ## A single explicit vanishing rate for the cone errors -/ |
| 1692 | |
| 1693 | noncomputable def coneRate (lam : ℝ) : ℝ := |
| 1694 | lam + Real.sqrt lam * (1 + Real.log (1 / lam)) |
| 1695 | |
| 1696 | theorem coneRate_parts {lam : ℝ} (hlam : 0 < lam) (hsmall : lam ≤ 1) : |
| 1697 | 0 ≤ coneRate lam ∧ lam ≤ coneRate lam ∧ |
| 1698 | Real.sqrt lam * (1 + Real.log (1 / lam)) ≤ coneRate lam := by |
| 1699 | have hl : 0 ≤ Real.log (1 / lam) := |
| 1700 | Real.log_nonneg ((le_div_iff₀ hlam).mpr (by simpa only [one_mul] using hsmall)) |
| 1701 | have hs := Real.sqrt_nonneg lam |
| 1702 | have hp : 0 ≤ Real.sqrt lam * (1 + Real.log (1 / lam)) := by positivity |
| 1703 | dsimp [coneRate] |
| 1704 | exact ⟨add_nonneg hlam.le hp, le_add_of_nonneg_right hp, le_add_of_nonneg_left hlam.le⟩ |
| 1705 | |
| 1706 | theorem coneRate_tendsto_zero : Tendsto coneRate (𝓝[>] (0 : ℝ)) (𝓝 0) := by |
| 1707 | have hi : Tendsto (fun x : ℝ => x) (𝓝[>] (0 : ℝ)) (𝓝 0) := |
| 1708 | continuousAt_id.tendsto.mono_left inf_le_left |
| 1709 | have hs : Tendsto Real.sqrt (𝓝[>] (0 : ℝ)) (𝓝 0) := by |
| 1710 | have h : Tendsto (fun x : ℝ => Real.sqrt x) (𝓝[>] (0 : ℝ)) (𝓝 (Real.sqrt 0)) := |
| 1711 | (Real.continuous_sqrt.tendsto 0).mono_left inf_le_left |
| 1712 | simp only [Real.sqrt_zero] at h |
| 1713 | exact h |
| 1714 | have hl : Tendsto (fun x : ℝ => Real.log x * Real.sqrt x) (𝓝[>] (0 : ℝ)) (𝓝 0) := by |
| 1715 | simpa only [Real.sqrt_eq_rpow] using |
| 1716 | (tendsto_log_mul_rpow_nhdsGT_zero (by norm_num : (0 : ℝ) < 1 / 2)) |
| 1717 | convert! (hi.add hs).sub hl using 1 |
| 1718 | · funext x |
| 1719 | simp only [coneRate, one_div, Real.log_inv] |
| 1720 | ring |
| 1721 | · norm_num |
| 1722 | |
| 1723 | private theorem raw_error_le_rate {lam Q B M H P A F v : ℝ} |
| 1724 | (hlam : 0 < lam) (hsmall : lam ≤ 1) |
| 1725 | (hQ : 0 ≤ Q) (hB : 0 ≤ B) (hM : 0 ≤ M) (hH : 0 ≤ H) |
| 1726 | (hP : 0 ≤ P) (hA : 0 ≤ A) (hF : 0 ≤ F) |
| 1727 | (hv : v ≤ A * lam * (1 + Real.log (1 / lam))) : |
| 1728 | (4 / lam) * (Q * lam ^ 28 * B + M * lam ^ 2 + H * lam ^ 29) + |
| 1729 | (4 / Real.sqrt lam) * (3 * F * v + P * lam ^ 2) ≤ |
| 1730 | (4 * (Q * B + M + H + P) + 12 * F * A) * coneRate lam := by |
| 1731 | have hs : 0 < Real.sqrt lam := Real.sqrt_pos.mpr hlam |
| 1732 | have hs₂ := Real.sq_sqrt hlam.le |
| 1733 | have hp28 : lam ^ 28 ≤ lam ^ 2 := pow_le_pow_of_le_one hlam.le hsmall (by norm_num) |
| 1734 | have hp29 : lam ^ 29 ≤ lam ^ 2 := pow_le_pow_of_le_one hlam.le hsmall (by norm_num) |
| 1735 | have hfirstInside : Q * lam ^ 28 * B + M * lam ^ 2 + H * lam ^ 29 ≤ |
| 1736 | (Q * B + M + H) * lam ^ 2 := by |
| 1737 | have h₁ := mul_le_mul_of_nonneg_left hp28 (mul_nonneg hQ hB) |
| 1738 | have h₂ := mul_le_mul_of_nonneg_left hp29 hH |
| 1739 | nlinarith only [h₁, h₂] |
| 1740 | have hfirst : (4 / lam) * (Q * lam ^ 28 * B + M * lam ^ 2 + H * lam ^ 29) ≤ |
| 1741 | 4 * (Q * B + M + H) * lam := by |
| 1742 | have h := mul_le_mul_of_nonneg_left hfirstInside (by positivity : 0 ≤ 4 / lam) |
| 1743 | convert! h using 1 |
| 1744 | field_simp [hlam.ne'] |
| 1745 | have hv' : v / Real.sqrt lam ≤ A * Real.sqrt lam * (1 + Real.log (1 / lam)) := by |
| 1746 | apply (div_le_iff₀ hs).mpr |
| 1747 | calc |
| 1748 | v ≤ A * lam * (1 + Real.log (1 / lam)) := hv |
| 1749 | _ = A * Real.sqrt lam * (1 + Real.log (1 / lam)) * Real.sqrt lam := by |
| 1750 | calc |
| 1751 | _ = A * (Real.sqrt lam) ^ 2 * (1 + Real.log (1 / lam)) := by rw [hs₂] |
| 1752 | _ = _ := by ring |
| 1753 | have hp2 : lam ^ 2 / Real.sqrt lam ≤ lam := by |
| 1754 | apply (div_le_iff₀ hs).mpr |
| 1755 | have hl : lam ≤ Real.sqrt lam := Real.le_sqrt_of_sq_le (by nlinarith only [hlam, hsmall]) |
| 1756 | nlinarith only [mul_le_mul_of_nonneg_left hl hlam.le] |
| 1757 | have hsecond : (4 / Real.sqrt lam) * (3 * F * v + P * lam ^ 2) ≤ |
| 1758 | 12 * F * A * (Real.sqrt lam * (1 + Real.log (1 / lam))) + 4 * P * lam := by |
| 1759 | have h₁ := mul_le_mul_of_nonneg_left hv' (mul_nonneg (by norm_num : (0 : ℝ) ≤ 12) hF) |
| 1760 | have h₂ := mul_le_mul_of_nonneg_left hp2 (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) hP) |
| 1761 | calc |
| 1762 | _ = 12 * F * (v / Real.sqrt lam) + 4 * P * (lam ^ 2 / Real.sqrt lam) := by ring |
| 1763 | _ ≤ _ := by |
| 1764 | convert! add_le_add h₁ h₂ using 1 |
| 1765 | ring |
| 1766 | have hr := coneRate_parts hlam hsmall |
| 1767 | have hlinear := mul_le_mul_of_nonneg_left hr.2.1 |
| 1768 | (show 0 ≤ 4 * (Q * B + M + H + P) by positivity) |
| 1769 | have hparameter := mul_le_mul_of_nonneg_left hr.2.2 |
| 1770 | (show 0 ≤ 12 * F * A by positivity) |
| 1771 | nlinarith only [hfirst, hsecond, hlinear, hparameter] |
| 1772 | |
| 1773 | noncomputable def directionErrorConstant (P m A : ℝ) : ℝ := |
| 1774 | 4 * (angularErrorConstant P m * mainDirectionBound P m + fullLagBound P m + |
| 1775 | axialErrorConstant P m + parameterLagConstant P m) + 12 * mainBound * A |
| 1776 | |
| 1777 | theorem directionErrorConstant_pos {P A : ℝ} (hP : 0 < P) (m : ℝ) (hA : 0 ≤ A) : |
| 1778 | 0 < directionErrorConstant P m A := by |
| 1779 | have hq := angularErrorConstant_pos hP m |
| 1780 | have hb := mainDirectionBound_pos hP m |
| 1781 | have hm := fullLagBound_pos hP m |
| 1782 | have hh := axialErrorConstant_pos hP m |
| 1783 | have hp := parameterLagConstant_pos hP m |
| 1784 | have hf := mainBound_pos |
| 1785 | dsimp [directionErrorConstant] |
| 1786 | positivity |
| 1787 | |
| 1788 | noncomputable def componentConstant (P m A : ℝ) : ℝ := |
| 1789 | directionErrorConstant P m A + directionMainErrorConstant P m + shearErrorConstant P m + 1 |
| 1790 | |
| 1791 | theorem componentConstant_pos {P A : ℝ} (hP : 0 < P) (m : ℝ) (hA : 0 ≤ A) : |
| 1792 | 0 < componentConstant P m A := by |
| 1793 | have hd := directionErrorConstant_pos hP m hA |
| 1794 | have hm := directionMainErrorConstant_pos hP m |
| 1795 | have hs := shearErrorConstant_pos hP m |
| 1796 | dsimp [componentConstant] |
| 1797 | positivity |
| 1798 | |
| 1799 | theorem actual_component_errors (w : ResetWitness d K) |
| 1800 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) |
| 1801 | (hsmall : d.core.lam ≤ 1 / 100000) (hh : d.h ≤ d.core.lam / 100000) |
| 1802 | (hnum : angularErrorConstant d.core.P d.core.m * d.core.lam ^ 27 ≤ 1 / 4) |
| 1803 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y A : ℝ} (hA : 0 ≤ A) |
| 1804 | (heta : |eta| ≤ 1) (hamp : |amp eta| ≤ 6 / 5) (hamp' : |deriv amp eta| ≤ 1) |
| 1805 | (hamprate : |deriv amp eta| ≤ A * d.core.lam * (1 + Real.log (1 / d.core.lam))) |
| 1806 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1807 | |shearB w amp (d.core.pulseStart + y, eta) + mainRatio d.core amp eta y| ≤ |
| 1808 | componentConstant d.core.P d.core.m A * coneRate d.core.lam ∧ |
| 1809 | |directionRatio w amp (d.core.pulseStart + y, eta) - idealDirection d amp eta y| ≤ |
| 1810 | componentConstant d.core.P d.core.m A * coneRate d.core.lam := by |
| 1811 | have hlam_le : d.core.lam ≤ 1 := by linarith |
| 1812 | have hh₁ : d.h ≤ 1 / 100 := by linarith |
| 1813 | have hQlow := actual_Qs_pulse_lower w hwait (by linarith) hh₁ hnum ha heta hamp hamp' hy hy' |
| 1814 | have hQerr := actual_Qs_pulse_error w hwait (by linarith) hh₁ ha heta hamp hamp' hy hy' |
| 1815 | have hraw := directionRatio_error_bound w hwait hsmall hh ha heta hamp hamp' hy hy' hQlow hQerr |
| 1816 | have hr := raw_error_le_rate d.core.lam_pos hlam_le |
| 1817 | (angularErrorConstant_pos d.core.P_pos d.core.m).le |
| 1818 | (mainDirectionBound_pos d.core.P_pos d.core.m).le |
| 1819 | (fullLagBound_pos d.core.P_pos d.core.m).le |
| 1820 | (axialErrorConstant_pos d.core.P_pos d.core.m).le |
| 1821 | (parameterLagConstant_pos d.core.P_pos d.core.m).le hA mainBound_pos.le hamprate |
| 1822 | have hmain : |directionRatio w amp (d.core.pulseStart + y, eta) - mainDirection d amp eta y| ≤ |
| 1823 | directionErrorConstant d.core.P d.core.m A * coneRate d.core.lam := hraw.trans hr |
| 1824 | have hparts := coneRate_parts d.core.lam_pos hlam_le |
| 1825 | have hD := directionErrorConstant_pos d.core.P_pos d.core.m hA |
| 1826 | have hM := directionMainErrorConstant_pos d.core.P_pos d.core.m |
| 1827 | have hS := shearErrorConstant_pos d.core.P_pos d.core.m |
| 1828 | have hbig₁ : shearErrorConstant d.core.P d.core.m ≤ componentConstant d.core.P d.core.m A := by |
| 1829 | dsimp [componentConstant] |
| 1830 | linarith |
| 1831 | have hbig₂ : directionErrorConstant d.core.P d.core.m A + directionMainErrorConstant d.core.P d.core.m ≤ |
| 1832 | componentConstant d.core.P d.core.m A := by |
| 1833 | dsimp [componentConstant] |
| 1834 | linarith |
| 1835 | constructor |
| 1836 | · exact (shearB_main_error w (by linarith) ha heta hamp hy hy').trans |
| 1837 | ((mul_le_mul_of_nonneg_left hparts.2.1 hS.le).trans |
| 1838 | (mul_le_mul_of_nonneg_right hbig₁ hparts.1)) |
| 1839 | · have hdelta := mainDirection_ideal_error d hsmall hh heta hamp y |
| 1840 | have hdelta' := hdelta.trans (mul_le_mul_of_nonneg_left hparts.2.1 hM.le) |
| 1841 | have htri := abs_add_le (directionRatio w amp (d.core.pulseStart + y, eta) - mainDirection d amp eta y) |
| 1842 | (mainDirection d amp eta y - idealDirection d amp eta y) |
| 1843 | rw [sub_add_sub_cancel] at htri |
| 1844 | have hsum := htri.trans (add_le_add hmain hdelta') |
| 1845 | rw [← add_mul] at hsum |
| 1846 | exact hsum.trans (mul_le_mul_of_nonneg_right hbig₂ hparts.1) |
| 1847 | |
| 1848 | noncomputable def pulseBudget (P m A lam : ℝ) : ℝ := |
| 1849 | coneErrorBudget mainRatioBound idealDirectionBound (componentConstant P m A * coneRate lam) lam |
| 1850 | |
| 1851 | private theorem cone_budget_eps_le_one {F M eps lam : ℝ} |
| 1852 | (hF : 0 ≤ F) (hM : 0 ≤ M) (heps : 0 ≤ eps) (hlam : 0 ≤ lam) |
| 1853 | (hb : coneErrorBudget F M eps lam ≤ 1 / 100) : eps ≤ 1 := by |
| 1854 | have h₁ := mul_nonneg heps (add_nonneg hM hF) |
| 1855 | have h₂ : 0 ≤ eps * (2 * F + 1) / 2 := by positivity |
| 1856 | have h₃ : 0 ≤ 2 * lam * (M + 1) ^ 2 := by positivity |
| 1857 | dsimp [coneErrorBudget] at hb |
| 1858 | nlinarith only [h₁, h₂, h₃, hb] |
| 1859 | |
| 1860 | /-- The numerical margins refer only to the actual global stress histories |
| 1861 | and the actual first radial derivatives of the corrected fields. -/ |
| 1862 | structure PulseConeAt (w : ResetWitness d K) (amp : ℝ → ℝ) (p : Point) : Prop where |
| 1863 | angular_positive : 0 < Qs w amp p |
| 1864 | first_margin : shearB w amp p * directionRatio w amp p ≤ 74 / 100 |
| 1865 | second_margin : 2 * shearB w amp p * directionRatio w amp p + |
| 1866 | shearB w amp p ^ 2 / radialA w p + (radialA w p - 2) * directionRatio w amp p ^ 2 ≤ 168 / 100 |
| 1867 | radial_gt_two : 2 < radialA w p |
| 1868 | |
| 1869 | theorem PulseConeAt.true_criterion {w : ResetWitness d K} {amp : ℝ → ℝ} {p : Point} |
| 1870 | (h : PulseConeAt w amp p) : |
| 1871 | 0 < radialA w p - shearB w amp p * directionRatio w amp p ∧ |
| 1872 | 2 * shearB w amp p * directionRatio w amp p + shearB w amp p ^ 2 / radialA w p + |
| 1873 | (radialA w p - 2) * directionRatio w amp p ^ 2 < 2 ∧ |
| 1874 | 2 < radialA w p * (1 + (shearB w amp p / radialA w p) ^ 2) := by |
| 1875 | have ha := h.radial_gt_two |
| 1876 | have hmul := mul_nonneg (show 0 ≤ radialA w p by linarith) |
| 1877 | (sq_nonneg (shearB w amp p / radialA w p)) |
| 1878 | refine ⟨?_, ?_, ?_⟩ |
| 1879 | · linarith [h.first_margin] |
| 1880 | · linarith [h.second_margin] |
| 1881 | · nlinarith only [ha, hmul] |
| 1882 | |
| 1883 | /-- The full pulse cone for any smooth amplitude with the proved size and |
| 1884 | first-derivative rate. Every further hypothesis is a scalar parameter bound. -/ |
| 1885 | theorem actual_pulse_cone (w : ResetWitness d K) |
| 1886 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) |
| 1887 | (hsmall : d.core.lam ≤ 1 / 100000) (hh : d.h ≤ d.core.lam / 100000) |
| 1888 | (hnum : angularErrorConstant d.core.P d.core.m * d.core.lam ^ 27 ≤ 1 / 4) |
| 1889 | {amp : ℝ → ℝ} (ha : ContDiff ℝ ∞ amp) {eta y A : ℝ} (hA : 0 ≤ A) |
| 1890 | (heta : |eta| ≤ 1) (hamp₀ : 0 ≤ amp eta) (hamp : |amp eta| ≤ 6 / 5) |
| 1891 | (hamp' : |deriv amp eta| ≤ 1) |
| 1892 | (hamprate : |deriv amp eta| ≤ A * d.core.lam * (1 + Real.log (1 / d.core.lam))) |
| 1893 | (hbudget : pulseBudget d.core.P d.core.m A d.core.lam ≤ 1 / 100) |
| 1894 | (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1895 | PulseConeAt w amp (d.core.pulseStart + y, eta) := by |
| 1896 | let eps := componentConstant d.core.P d.core.m A * coneRate d.core.lam |
| 1897 | have heps : 0 ≤ eps := mul_nonneg (componentConstant_pos d.core.P_pos d.core.m hA).le |
| 1898 | (coneRate_parts d.core.lam_pos (by linarith)).1 |
| 1899 | have heps' : eps ≤ 1 := cone_budget_eps_le_one mainRatioBound_pos.le idealDirectionBound_pos.le |
| 1900 | heps d.core.lam_pos.le hbudget |
| 1901 | have he := actual_component_errors w hwait hsmall hh hnum ha hA heta hamp hamp' hamprate hy hy' |
| 1902 | have hm := main_profile_bounds d hsmall hh hamp₀ hamp hy |
| 1903 | have hc := perturbed_cone_margins d.core.lam_pos.le mainRatioBound_pos.le idealDirectionBound_pos.le |
| 1904 | heps heps' hm.1 hm.2.1 (derivativeCoefficient_nonneg d eta) (derivativeCoefficient_le d hsmall hh eta) |
| 1905 | hm.2.2.1 hm.2.2.2 he.1 he.2 hbudget |
| 1906 | have hQ := actual_Qs_pulse_lower w hwait (by linarith) (by linarith) hnum ha heta hamp hamp' hy hy' |
| 1907 | refine ⟨(denominator_bounds d heta hQ).1, hc.1, ?_, ?_⟩ |
| 1908 | · rw [radialA_pulse w eta hy hy'] |
| 1909 | convert! hc.2 using 1 |
| 1910 | ring |
| 1911 | · rw [radialA_pulse w eta hy hy'] |
| 1912 | linarith [d.core.lam_pos] |
| 1913 | |
| 1914 | noncomputable def amplitudeDerivativeConstant (P m K : ℝ) : ℝ := |
| 1915 | 128 * CorrectedPulseAmplitude.combinedConstant P m K |
| 1916 | |
| 1917 | theorem amplitudeDerivativeConstant_pos {P K : ℝ} (hP : 0 < P) (m : ℝ) (hK : 0 < K) : |
| 1918 | 0 < amplitudeDerivativeConstant P m K := |
| 1919 | mul_pos (by norm_num) (CorrectedPulseAmplitude.combinedConstant_pos hP m K hK) |
| 1920 | |
| 1921 | noncomputable def correctedPulseBudget (P m K lam : ℝ) : ℝ := |
| 1922 | pulseBudget P m (amplitudeDerivativeConstant P m K) lam |
| 1923 | |
| 1924 | /-- The full actual pulse cone for the same corrected amplitude and reset |
| 1925 | witness as the global schedule. No stress or cone estimate is assumed. -/ |
| 1926 | theorem corrected_pulse_cone (w : ResetWitness d K) (hK : 0 < K) |
| 1927 | (hwait : d.core.wait = 60 * Real.log (1 / d.core.lam)) |
| 1928 | (hsmall : d.core.lam ≤ 1 / 100000) (hh : d.h ≤ d.core.lam / 100000) |
| 1929 | (hscale : CorrectedPulseAmplitude.combinedScale d K ≤ 1 / 1000) |
| 1930 | (hnum : angularErrorConstant d.core.P d.core.m * d.core.lam ^ 27 ≤ 1 / 4) |
| 1931 | (hbudget : correctedPulseBudget d.core.P d.core.m K d.core.lam ≤ 1 / 100) |
| 1932 | {eta y : ℝ} (heta : |eta| ≤ 1) (hy : 0 ≤ y) (hy' : y ≤ d.core.pulseLength) : |
| 1933 | PulseConeAt w (CorrectedPulseAmplitude.amplitude d w.coefficients) |
| 1934 | (d.core.pulseStart + y, eta) := by |
| 1935 | have hs := CorrectedPulseAmplitude.amplitude_spec w hK (by linarith) hwait hscale |
| 1936 | have heta₂ : eta ^ 2 ≤ 1 := by |
| 1937 | have h := (sq_le_sq₀ (abs_nonneg eta) (by norm_num : (0 : ℝ) ≤ 1)).mpr heta |
| 1938 | nlinarith [sq_abs eta] |
| 1939 | have hb := hs.2 eta heta₂ |
| 1940 | have hamp : |CorrectedPulseAmplitude.amplitude d w.coefficients eta| ≤ 6 / 5 := by |
| 1941 | rw [abs_of_pos (CorrectedPulseAmplitude.amplitude_pos d w.coefficients eta)] |
| 1942 | exact hb.2.1.le |
| 1943 | have hamp' : |deriv (CorrectedPulseAmplitude.amplitude d w.coefficients) eta| ≤ 1 := by |
| 1944 | have hd := hb.2.2.2.1 |
| 1945 | linarith |
| 1946 | have hrate : |deriv (CorrectedPulseAmplitude.amplitude d w.coefficients) eta| ≤ |
| 1947 | amplitudeDerivativeConstant d.core.P d.core.m K * d.core.lam * |
| 1948 | (1 + Real.log (1 / d.core.lam)) := by |
| 1949 | convert! hb.2.2.2.1 using 1 |
| 1950 | dsimp [amplitudeDerivativeConstant, CorrectedPulseAmplitude.combinedScale, PulseAmplitude.logarithmicRate] |
| 1951 | ring |
| 1952 | exact actual_pulse_cone w hwait hsmall hh hnum hs.1 |
| 1953 | (amplitudeDerivativeConstant_pos d.core.P_pos d.core.m hK).le heta |
| 1954 | (by linarith [hb.1]) hamp hamp' hrate hbudget hy hy' |
| 1955 | |
| 1956 | theorem pulseBudget_tendsto_zero (P m A : ℝ) : |
| 1957 | Tendsto (pulseBudget P m A) (𝓝[>] (0 : ℝ)) (𝓝 0) := by |
| 1958 | have hi : Tendsto (fun x : ℝ => x) (𝓝[>] (0 : ℝ)) (𝓝 0) := |
| 1959 | continuousAt_id.tendsto.mono_left inf_le_left |
| 1960 | have he := coneRate_tendsto_zero.const_mul (componentConstant P m A) |
| 1961 | have h := ((he.const_mul (2 * (idealDirectionBound + mainRatioBound + 1))).add |
| 1962 | (he.const_mul ((2 * mainRatioBound + 1) / 2))).add |
| 1963 | (hi.const_mul (2 * (idealDirectionBound + 1) ^ 2)) |
| 1964 | convert! h using 1 |
| 1965 | · funext lam |
| 1966 | dsimp [pulseBudget, coneErrorBudget] |
| 1967 | ring |
| 1968 | · ring_nf |
| 1969 | |
| 1970 | theorem exists_pulseBudget_threshold (P m A : ℝ) : |
| 1971 | ∃ δ : ℝ, 0 < δ ∧ ∀ lam : ℝ, 0 < lam → lam < δ → pulseBudget P m A lam ≤ 1 / 100 := by |
| 1972 | have he : ∀ᶠ lam in 𝓝[>] (0 : ℝ), pulseBudget P m A lam < 1 / 100 := |
| 1973 | (pulseBudget_tendsto_zero P m A).eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 1 / 100)) |
| 1974 | obtain ⟨δ, hδ, hsub⟩ := mem_nhdsGT_iff_exists_Ioo_subset.mp he |
| 1975 | exact ⟨δ, hδ, fun lam hlam hlt => (hsub ⟨hlam, hlt⟩).le⟩ |
| 1976 | |
| 1977 | /-- One threshold is chosen after the fixed prefix and reset constant. |
| 1978 | It works for every supplied reset witness, keeps its actual energy-closing |
| 1979 | amplitude, and is uniform over the full pulse and the physical parameter band. -/ |
| 1980 | theorem exists_corrected_pulse_threshold (P m K : ℝ) (hP : 0 < P) (hK : 0 < K) : |
| 1981 | ∃ lam₀ : ℝ, 0 < lam₀ ∧ ∀ d : TailData, |
| 1982 | d.core.P = P → d.core.m = m → d.core.wait = 60 * Real.log (1 / d.core.lam) → |
| 1983 | d.core.lam < lam₀ → d.h ≤ d.core.lam / 100000 → ∀ w : ResetWitness d K, |
| 1984 | ∀ eta y : ℝ, |eta| ≤ 1 → 0 ≤ y → y ≤ d.core.pulseLength → |
| 1985 | PulseConeAt w (CorrectedPulseAmplitude.amplitude d w.coefficients) |
| 1986 | (d.core.pulseStart + y, eta) := by |
| 1987 | obtain ⟨δbudget, hδbudget, hbudget⟩ := exists_pulseBudget_threshold P m (amplitudeDerivativeConstant P m K) |
| 1988 | obtain ⟨δscale, hδscale, hscale⟩ := |
| 1989 | PulseAmplitude.exists_rate_threshold (CorrectedPulseAmplitude.combinedConstant P m K) |
| 1990 | have hC := angularErrorConstant_pos hP m |
| 1991 | refine ⟨min δbudget (min δscale (min (1 / 100000) (1 / (4 * angularErrorConstant P m)))), |
| 1992 | lt_min hδbudget (lt_min hδscale (lt_min (by norm_num) (by positivity))), ?_⟩ |
| 1993 | intro d hdP hdm hwait hlam hh w eta y heta hy hy' |
| 1994 | have hb : d.core.lam < δbudget := hlam.trans_le (min_le_left _ _) |
| 1995 | have hr := hlam.trans_le (min_le_right _ _) |
| 1996 | have hs : d.core.lam < δscale := hr.trans_le (min_le_left _ _) |
| 1997 | have hr' := hr.trans_le (min_le_right _ _) |
| 1998 | have hsmall : d.core.lam ≤ 1 / 100000 := (hr'.trans_le (min_le_left _ _)).le |
| 1999 | have hCsmall : d.core.lam ≤ 1 / (4 * angularErrorConstant P m) := |
| 2000 | (hr'.trans_le (min_le_right _ _)).le |
| 2001 | have hnum : angularErrorConstant d.core.P d.core.m * d.core.lam ^ 27 ≤ 1 / 4 := by |
| 2002 | rw [hdP, hdm] |
| 2003 | have hp : d.core.lam ^ 27 ≤ d.core.lam := by |
| 2004 | simpa only [pow_one] using pow_le_pow_of_le_one d.core.lam_pos.le |
| 2005 | (show d.core.lam ≤ 1 by linarith) (show 1 ≤ 27 by norm_num) |
| 2006 | have hm := mul_le_mul_of_nonneg_left hp hC.le |
| 2007 | have hd := (le_div_iff₀ (show 0 < 4 * angularErrorConstant P m by positivity)).mp hCsmall |
| 2008 | nlinarith only [hm, hd] |
| 2009 | have hscale' : CorrectedPulseAmplitude.combinedScale d K ≤ 1 / 1000 := by |
| 2010 | dsimp [CorrectedPulseAmplitude.combinedScale] |
| 2011 | rw [hdP, hdm] |
| 2012 | exact hscale d.core.lam d.core.lam_pos hs |
| 2013 | have hbudget' : correctedPulseBudget d.core.P d.core.m K d.core.lam ≤ 1 / 100 := by |
| 2014 | dsimp only [correctedPulseBudget] |
| 2015 | rw [hdP, hdm] |
| 2016 | exact hbudget d.core.lam d.core.lam_pos hb |
| 2017 | exact corrected_pulse_cone w hK hwait hsmall hh hscale' hnum hbudget' heta hy hy' |
| 2018 | |
| 2019 | end NavierStokes.PulseCone |
| 2020 | |
| 2021 | end |