| 1 | module |
| 2 | |
| 3 | public import E424.LowBand.Defs |
| 4 | public import E424.LowBand.L36Aux2 |
| 5 | |
| 6 | @[expose] public section |
| 7 | |
| 8 | /-! |
| 9 | # Section 9 of the outline: L36 |
| 10 | -/ |
| 11 | |
| 12 | set_option linter.style.header false |
| 13 | open Finset MeasureTheory |
| 14 | |
| 15 | namespace E424 |
| 16 | |
| 17 | set_option maxHeartbeats 1600000 in |
| 18 | /-- **Lemma 36**, `S`-average of `d`. The factor `1/τ` on `√ςn` is missing in v2. `C` must not depend |
| 19 | on `τ`. -/ |
| 20 | theorem L36 (η cS : ℝ) (hη : 0 < η) (hη1 : η ≤ 1 / 1000) (hc : 0 < cS) : ∃ C > 0, ∀ τ e : ℝ, |
| 21 | 0 < τ → τ ≤ 1 / 100 → τ ≤ η / 4 → 0 < e → ∃ N0 : ℝ, ∀ W : Win, W.Adm η N0 → |
| 22 | W.len ≤ 21 / 10 * η * Real.log W.lo → |
| 23 | ∀ (ρ : ℕ) (S : Finset ℕ), ρ = 53 ∨ ρ = 23 → MacroFam cS τ (Y5 W) ρ S → ∀ ςn ςy q : ℝ, |
| 24 | 0 ≤ ςn → 0 ≤ ςy → L2err W ≤ ςn * W.len → L2err (Wy W) ≤ ςy * W.len → |
| 25 | W.E (badCount S) / ms S ≤ q → |
| 26 | (∑ s ∈ S, 1 / (s : ℝ) * dq W τ (Real.log s)) / ms S ≤ |
| 27 | C * (q + Real.sqrt ςn / τ + Real.sqrt ςy) + e := by |
| 28 | obtain ⟨N1, hN1⟩ := L35_bounds |
| 29 | obtain ⟨R, hRdef⟩ : ∃ R : ℝ, R = 2 ^ 252 := ⟨_, rfl⟩ |
| 30 | have hR0 : 0 < R := by rw [hRdef]; positivity |
| 31 | refine ⟨2 + 4 * R / cS, by positivity, fun τ e hτ hτ1 hτη he => ?_⟩ |
| 32 | -- everything needed for large `lo` |
| 33 | set M := 6 + 4 * R / (cS * τ) with hM |
| 34 | have hM0 : 0 < M := by positivity |
| 35 | have ev1 : ∀ᶠ lo : ℝ in Filter.atTop, max (20 / η) (5 / 2 / τ) ≤ Real.log lo := |
| 36 | Real.tendsto_log_atTop.eventually_ge_atTop _ |
| 37 | have ev2 : ∀ᶠ lo : ℝ in Filter.atTop, 4 * M / e ≤ lo ^ (0.01 : ℝ) := |
| 38 | (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop _ |
| 39 | have ev3 : ∀ᶠ lo : ℝ in Filter.atTop, 2 ≤ lo ^ (0.004 : ℝ) := |
| 40 | (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop _ |
| 41 | have ev4 : ∀ᶠ lo : ℝ in Filter.atTop, N1 ≤ lo ^ (0.6 : ℝ) := |
| 42 | (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop _ |
| 43 | obtain ⟨N2, hN2⟩ := Filter.eventually_atTop.mp (ev1.and (ev2.and (ev3.and ev4))) |
| 44 | refine ⟨max N1 N2, fun W hW _ ρ S _ hS ςn ςy q hςn hςy hVn hVy hq => ?_⟩ |
| 45 | obtain ⟨h1, h2, h3, h4⟩ := hN2 W.lo ((le_max_right _ _).trans hW.le_lo) |
| 46 | have hlo0 := hW.lo_pos |
| 47 | have hhi0 := hW.hi_pos |
| 48 | have hlo1 : 1 ≤ W.lo := by linarith [hW.three_le] |
| 49 | set lo := W.lo with hlo |
| 50 | set Lo := Real.log lo with hLo |
| 51 | have hLη : 20 ≤ η * Lo := by |
| 52 | have := (le_max_left _ _).trans h1 |
| 53 | rwa [div_le_iff₀ hη, mul_comm] at this |
| 54 | have hLτ : 5 / 2 ≤ τ * Lo := by |
| 55 | have := (le_max_right _ _).trans h1 |
| 56 | rwa [div_le_iff₀ hτ, mul_comm] at this |
| 57 | have hLo0 : 0 < Lo := by linarith [hW.one_lt_log] |
| 58 | have hLo20 : 20000 ≤ Lo := by nlinarith |
| 59 | have hlen1 := hW.le_len |
| 60 | have hlen2 := hW.len_le |
| 61 | have hlen : W.len = Real.log W.hi - Lo := Real.log_div hhi0.ne' hlo0.ne' |
| 62 | set Λ := W.len with hΛ |
| 63 | have hΛ20 : 20 ≤ Λ := by linarith |
| 64 | have hell : ell W = 0.4 * Lo := rfl |
| 65 | have hLt : Lt W τ = τ * (0.4 * Lo) := rfl |
| 66 | have hLt1 : 1 ≤ Lt W τ := by rw [hLt]; linarith |
| 67 | have hLt2 : Lt W τ ≤ 0.1 * Λ := by rw [hLt]; nlinarith |
| 68 | have hX : Xlen W τ = Λ - 6 - 2 * Lt W τ := rfl |
| 69 | have hX2 : Λ ≤ 2 * Xlen W τ := by rw [hX]; linarith |
| 70 | have hY0 : 0 < Y5 W := Real.rpow_pos_of_pos hlo0 _ |
| 71 | have hYlog : Real.log (Y5 W) = ell W := Real.log_rpow hlo0 _ |
| 72 | have hY1 : 1 ≤ Y5 W := Real.one_le_rpow hlo1 (by norm_num) |
| 73 | have hWlo : (Wy W).lo = lo ^ (0.6 : ℝ) := by |
| 74 | change lo / lo ^ (0.4 : ℝ) = _ |
| 75 | rw [div_eq_iff (by positivity), ← Real.rpow_add hlo0]; norm_num |
| 76 | have hWlog : Real.log (Wy W).lo = Lo - ell W := by |
| 77 | rw [hWlo, Real.log_rpow hlo0, hell]; ring |
| 78 | have hWhi : Real.log (Wy W).hi = Real.log W.hi - ell W := by |
| 79 | rw [← hYlog]; exact Real.log_div hhi0.ne' hY0.ne' |
| 80 | have hFn := hN1 lo ((le_max_left _ _).trans hW.le_lo) |
| 81 | have hFy := hN1 (Wy W).lo (by rw [hWlo]; exact h4) |
| 82 | have hWlo1 : 1 ≤ (Wy W).lo := by rw [hWlo]; exact Real.one_le_rpow hlo1 (by norm_num) |
| 83 | have hup : ∀ l : ℝ, 1 ≤ l → l ^ (-(0.4 : ℝ)) ≤ 1 := fun l h => |
| 84 | Real.rpow_le_one_of_one_le_of_nonpos h (by norm_num) |
| 85 | have hm0 : 0 < ms S := lt_of_lt_of_le (by positivity) hS.mass |
| 86 | have hQ0 : 0 ≤ Qs lo := Real.rpow_nonneg hlo0.le _ |
| 87 | set δ := 4 * lo ^ (-(0.01 : ℝ)) with hδ |
| 88 | have hδ0 : 0 < δ := by positivity |
| 89 | have hexp : Real.exp (-(Lo - ell W + 3)) ≤ lo ^ (-(0.6 : ℝ)) := by |
| 90 | rw [Real.rpow_def_of_pos hlo0] |
| 91 | refine Real.exp_le_exp.mpr ?_ |
| 92 | rw [← hLo, hell]; linarith |
| 93 | have hab : Lo - ell W + 3 ≤ Real.log W.hi - ell W - 3 - 2 * Lt W τ := by linarith |
| 94 | -- the core estimate |
| 95 | have key := L36_core (S := S) (φn := Fb (Qs lo)) (φy := Fb (Qs (Wy W).lo)) (a := Lo - ell W + 3) |
| 96 | (b := Real.log W.hi - ell W - 3 - 2 * Lt W τ) (α := Lo + 3) (β := Real.log W.hi - 3) (ℓ := ell W) |
| 97 | (t := Lt W τ) (δ := δ) (ςn := ςn) (ςy := ςy) (Λ := Λ) (Kn := 4 * Qs lo) (Ky := 4 * Qs (Wy W).lo) |
| 98 | (R := R) (by rw [hell]; linarith) (by rw [hell]; positivity) (by ring) (by ring) (by linarith) |
| 99 | (by linarith) |
| 100 | (by |
| 101 | intro s hs |
| 102 | obtain ⟨-, -, hs1, hs2, -⟩ := hS.mem s hs |
| 103 | have hs0 : (0 : ℝ) < s := by linarith |
| 104 | refine ⟨by exact_mod_cast hY1.trans hs1, ?_, ?_⟩ |
| 105 | · rw [← hYlog]; exact Real.log_le_log hY0 hs1 |
| 106 | · have := Real.log_le_log hs0 hs2 |
| 107 | rw [Real.log_rpow hY0, hYlog] at this |
| 108 | have : Lt W τ = τ * ell W := rfl |
| 109 | linarith) |
| 110 | (by |
| 111 | set β := Real.log W.hi - 3 |
| 112 | have hβ : 1 ≤ β := by simp only [β]; linarith |
| 113 | have e1 : Real.exp (β - Lt W τ) ≤ Real.exp (β - 1) := Real.exp_le_exp.mpr (by linarith) |
| 114 | have e2 : Real.exp β = Real.exp (β - 1) * Real.exp 1 := by rw [← Real.exp_add]; ring_nf |
| 115 | have e3 : 1 ≤ Real.exp (β - 1) := Real.one_le_exp (by linarith) |
| 116 | have e4 : 2 ≤ Real.exp 1 := by linarith [Real.exp_one_gt_d9] |
| 117 | nlinarith) |
| 118 | (by positivity) |
| 119 | (fun x hx => ⟨(hFn x (by linarith)).1, by linarith [(hFn x (by linarith)).2.1, hup lo hlo1]⟩) |
| 120 | (fun x x' hx hx' => (hFn x (by linarith)).2.2 x' (by linarith)) |
| 121 | (fun x hx => ⟨(hFy x (by linarith)).1, by |
| 122 | linarith [(hFy x (by linarith)).2.1, hup _ hWlo1]⟩) |
| 123 | (fun x x' hx hx' => (hFy x (by linarith)).2.2 x' (by linarith)) |
| 124 | (by |
| 125 | calc 4 * Qs lo * Real.exp (-(Lo - ell W + 3)) ≤ 4 * Qs lo * lo ^ (-(0.6 : ℝ)) := |
| 126 | mul_le_mul_of_nonneg_left hexp (by positivity) |
| 127 | _ = 4 * (lo ^ (0.59 : ℝ) * lo ^ (-(0.6 : ℝ))) := by unfold Qs; ring |
| 128 | _ = δ := by rw [← Real.rpow_add hlo0, hδ]; norm_num) |
| 129 | (by |
| 130 | have : lo ^ (-(0.6 : ℝ)) ≤ lo ^ (-(0.01 : ℝ)) := |
| 131 | Real.rpow_le_rpow_of_exponent_le hlo1 (by norm_num) |
| 132 | rw [hδ]; linarith [Real.rpow_nonneg hlo0.le (-(0.01 : ℝ))]) |
| 133 | hςn hςy (by linarith) (by linarith) hVn |
| 134 | (by |
| 135 | refine le_trans ?_ hVy |
| 136 | unfold L2err |
| 137 | rw [hWlog, hWhi] |
| 138 | have hcd : Lo - ell W + 3 ≤ Real.log W.hi - ell W - 3 := by linarith |
| 139 | refine intervalIntegral.integral_mono_interval le_rfl hab (by linarith) |
| 140 | (Filter.Eventually.of_forall fun x => by positivity) (ii_F_sub hcd ?_).2 |
| 141 | exact continuousOn_of_lip (C := 4 * Qs (Wy W).lo) fun x hx y hy => |
| 142 | (hFy x (by linarith [hx.1])).2.2 y (by linarith [hy.1])) |
| 143 | hR0.le |
| 144 | (by |
| 145 | intro n hn1 hn |
| 146 | rw [hRdef] |
| 147 | refine L14_pointwise (Y5 W ^ (1 / 100 : ℝ)) ?_ S (fun s hs => (hS.mem s hs).2.2.2.2) 252 n hn1 ?_ |
| 148 | · unfold Y5; rw [← Real.rpow_mul hlo0.le]; norm_num at h3 ⊢; exact h3 |
| 149 | · refine hn.trans ?_ |
| 150 | unfold Y5 |
| 151 | rw [← Real.rpow_mul hlo0.le, ← Real.rpow_natCast, ← Real.rpow_mul hlo0.le, Real.rpow_def_of_pos hlo0] |
| 152 | refine Real.exp_le_exp.mpr ?_ |
| 153 | rw [← hLo] |
| 154 | have : 8 * η * Lo ≤ 0.008 * Lo := mul_le_mul_of_nonneg_right (by linarith) hLo0.le |
| 155 | push_cast |
| 156 | linarith) |
| 157 | -- the middle term |
| 158 | have hΛ0 : 0 < Λ := by linarith |
| 159 | have hbc0 : ∀ n, 0 ≤ badCount S n := fun n => sum_nonneg fun _ _ => ind_nonneg _ |
| 160 | have hBS : ∑ n ∈ Ico ⌈Real.exp (Lo + 3)⌉₊ ⌊Real.exp (Real.log W.hi - 3)⌋₊, badCount S n / n ≤ |
| 161 | q * ms S * Λ := by |
| 162 | have hE : W.E (badCount S) ≤ q * ms S := (div_le_iff₀ hm0).mp hq |
| 163 | refine le_trans ?_ (mul_le_mul_of_nonneg_right hE hΛ0.le) |
| 164 | rw [← Win.sum_eq_E_mul hΛ0] |
| 165 | refine sum_le_sum_of_subset_of_nonneg (fun n hn => ?_) fun n _ _ => div_nonneg (hbc0 n) n.cast_nonneg |
| 166 | obtain ⟨ha, hb⟩ := mem_Ico.mp hn |
| 167 | rw [Win.mem_pts hlo0.le hhi0.le] |
| 168 | constructor |
| 169 | · refine lt_of_lt_of_le ?_ (Nat.ceil_le.mp ha) |
| 170 | rw [← hlo, ← Real.log_lt_iff_lt_exp hlo0]; linarith |
| 171 | · refine ((Nat.le_floor_iff (Real.exp_pos _).le).mp hb.le).trans ?_ |
| 172 | rw [← Real.le_log_iff_exp_le hhi0]; linarith |
| 173 | have hq0 : 0 ≤ q := le_trans (div_nonneg (Win.E_nonneg hΛ0.le fun n _ => hbc0 n) hm0.le) hq |
| 174 | -- conclusion |
| 175 | have hdq : ∑ s ∈ S, 1 / (s : ℝ) * dq W τ (Real.log s) = |
| 176 | (∑ s ∈ S, 1 / (s : ℝ) * ∫ x in (Lo - ell W + 3)..(Real.log W.hi - ell W - 3 - 2 * Lt W τ), |
| 177 | |Fb (Qs lo) (x + Real.log s) - Fb (Qs (Wy W).lo) x|) / Xlen W τ := by |
| 178 | rw [sum_div] |
| 179 | refine sum_congr rfl fun s _ => ?_ |
| 180 | unfold dq |
| 181 | rw [mul_div_assoc] |
| 182 | rw [hdq] |
| 183 | set T := ∑ s ∈ S, 1 / (s : ℝ) * ∫ x in (Lo - ell W + 3)..(Real.log W.hi - ell W - 3 - 2 * Lt W τ), |
| 184 | |Fb (Qs lo) (x + Real.log s) - Fb (Qs (Wy W).lo) x| with hT |
| 185 | have hX0 : 0 < Xlen W τ := by linarith |
| 186 | set u := Real.sqrt ςn with hu |
| 187 | set v := Real.sqrt ςy with hv |
| 188 | have hu0 : 0 ≤ u := Real.sqrt_nonneg _ |
| 189 | have hv0 : 0 ≤ v := Real.sqrt_nonneg _ |
| 190 | have hmass : 1 ≤ ms S / (cS * τ) := (one_le_div (by positivity)).mpr hS.mass |
| 191 | have hT1 : T ≤ ms S * Λ * (v + 3 * δ + q + 2 * R * (u + δ) / (cS * τ)) := by |
| 192 | have : R * (2 * (u * Λ + δ * Λ)) ≤ R * (2 * (u * Λ + δ * Λ)) * (ms S / (cS * τ)) := |
| 193 | le_mul_of_one_le_right (by positivity) hmass |
| 194 | have e1 : R * (2 * (u * Λ + δ * Λ)) * (ms S / (cS * τ)) = |
| 195 | ms S * Λ * (2 * R * (u + δ) / (cS * τ)) := by ring |
| 196 | linarith [key.trans (add_le_add_right hBS _)] |
| 197 | have hδe : M * δ ≤ e := by |
| 198 | have : lo ^ (-(0.01 : ℝ)) = 1 / lo ^ (0.01 : ℝ) := by rw [Real.rpow_neg hlo0.le, one_div] |
| 199 | rw [hδ, this] |
| 200 | rw [div_le_iff₀ he] at h2 |
| 201 | have hp : 0 < lo ^ (0.01 : ℝ) := by positivity |
| 202 | rw [show M * (4 * (1 / lo ^ (0.01 : ℝ))) = 4 * M / lo ^ (0.01 : ℝ) by ring, div_le_iff₀ hp] |
| 203 | linarith |
| 204 | set V := v + 3 * δ + q + 2 * R * (u + δ) / (cS * τ) with hV |
| 205 | have hV0 : 0 ≤ V := by positivity |
| 206 | have hfin : T / Xlen W τ / ms S ≤ 2 * V := by |
| 207 | rw [div_div, div_le_iff₀ (by positivity)] |
| 208 | refine hT1.trans ?_ |
| 209 | have : ms S * V * Λ ≤ ms S * V * (2 * Xlen W τ) := mul_le_mul_of_nonneg_left hX2 (by positivity) |
| 210 | linarith |
| 211 | refine hfin.trans ?_ |
| 212 | have e1 : 2 * V = 2 * v + 2 * q + 4 * R / cS * (u / τ) + M * δ := by |
| 213 | rw [hV, hM]; field_simp; ring |
| 214 | have hk : 0 ≤ 4 * R / cS := by positivity |
| 215 | have hut : 0 ≤ u / τ := by positivity |
| 216 | rw [e1] |
| 217 | linarith [mul_nonneg hk hq0, mul_nonneg hk hv0] |
| 218 | |
| 219 | end E424 |
| 220 | |