| 1 | module |
| 2 | |
| 3 | public import E424.DirichletError.L29AuxD |
| 4 | public import E424.HighBand.L33Aux |
| 5 | |
| 6 | @[expose] public section |
| 7 | |
| 8 | /-! |
| 9 | # Lemma 34, auxiliary 2: the dyadic overlap, Jensen for the L33 average, and Proposition D on `W / s` |
| 10 | |
| 11 | `dy_sum_bound`: summing `g(y)/N` over the dyadic scales `N = 2^k ∈ 𝒩(W)`, with `y ∈ sS(N/s)`, is at most |
| 12 | `(40/s)` times the `1/y`-weighted sum of `g` over the window `W / s`. |
| 13 | `jensen_centred`: `(b - H-average)²` is at most the average of `ind(b(y+j) ≠ b y)`, for 0/1 `b`. |
| 14 | `sum_pts_le`: that average summed over `W / s`, weighted by `1/y`, is `len * D_{W/s}` (Proposition D(ii)). |
| 15 | -/ |
| 16 | |
| 17 | set_option linter.style.header false |
| 18 | open Finset MeasureTheory |
| 19 | |
| 20 | namespace E424 |
| 21 | |
| 22 | /-- At most five dyadic `2^k` lie in `[P/8, P/2)`-type windows: `P ≤ 8·2^k` and `2^k < 2P` for at most 5 `k`. -/ |
| 23 | lemma dyadic_window_card (P : ℕ) (hP : 0 < P) (T : Finset ℕ) : |
| 24 | (T.filter fun k => P ≤ 8 * 2 ^ k ∧ 2 ^ k < 2 * P).card ≤ 5 := by |
| 25 | set L := Nat.log 2 P with hL |
| 26 | have hsub : T.filter (fun k => P ≤ 8 * 2 ^ k ∧ 2 ^ k < 2 * P) ⊆ Finset.Ico (L - 3) (L + 2) := by |
| 27 | intro k hk |
| 28 | obtain ⟨-, h1, h2⟩ := mem_filter.1 hk |
| 29 | rw [mem_Ico] |
| 30 | have a1 : 2 ^ L ≤ P := Nat.pow_log_le_self 2 hP.ne' |
| 31 | have a2 : P < 2 ^ (L + 1) := Nat.lt_pow_succ_log_self (by norm_num) P |
| 32 | have b1 : 2 ^ L ≤ 2 ^ (k + 3) := by |
| 33 | refine a1.trans (h1.trans ?_) |
| 34 | rw [pow_add]; omega |
| 35 | have b2 : 2 ^ k < 2 ^ (L + 2) := by |
| 36 | refine h2.trans ?_ |
| 37 | rw [pow_add]; omega |
| 38 | have c1 : L ≤ k + 3 := (Nat.pow_le_pow_iff_right (by norm_num)).1 b1 |
| 39 | have c2 : k < L + 2 := (Nat.pow_lt_pow_iff_right (by norm_num)).1 b2 |
| 40 | constructor <;> omega |
| 41 | refine (card_le_card hsub).trans ?_ |
| 42 | rw [Nat.card_Ico]; omega |
| 43 | |
| 44 | /-- For `y ∈ sS Y`: `y ≤ 8Y`, `Y < 2y`, and `y ≥ 1` once `Y > 0`. -/ |
| 45 | lemma mem_sS_bounds {Y : ℝ} {y : ℕ} (hY : 0 < Y) (hy : y ∈ sS Y) : |
| 46 | (y : ℝ) ≤ 8 * Y ∧ Y < 2 * y ∧ 1 ≤ y := by |
| 47 | unfold sS at hy |
| 48 | obtain ⟨h1, h2⟩ := mem_Ioc.1 hy |
| 49 | have hA : (y : ℝ) ≤ 8 * Y := by |
| 50 | have : (⌊8 * Y⌋₊ : ℝ) ≤ 8 * Y := Nat.floor_le (by positivity) |
| 51 | have hy' : (y : ℝ) ≤ (⌊8 * Y⌋₊ : ℝ) := by exact_mod_cast h2 |
| 52 | linarith |
| 53 | have hB : Y / 2 < (y : ℝ) := by |
| 54 | have : Y / 2 < (⌊Y / 2⌋₊ : ℝ) + 1 := Nat.lt_floor_add_one _ |
| 55 | have hy' : (⌊Y / 2⌋₊ : ℝ) + 1 ≤ (y : ℝ) := by exact_mod_cast Nat.succ_le_of_lt h1 |
| 56 | linarith |
| 57 | refine ⟨hA, by linarith, ?_⟩ |
| 58 | by_contra hc |
| 59 | have h0 : y = 0 := by omega |
| 60 | subst h0 |
| 61 | simp at hB |
| 62 | linarith |
| 63 | |
| 64 | /-- Natural-number form of `y ∈ sS(2^k/s)`: `s y ≤ 8·2^k < 16 s y`-type bounds, and `y ≥ 1`. -/ |
| 65 | lemma sS_nat_bounds (k s : ℕ) (hs : 1 ≤ s) {y : ℕ} (hy : y ∈ sS ((2 : ℝ) ^ k / s)) : |
| 66 | s * y ≤ 8 * 2 ^ k ∧ 2 ^ k < 2 * (s * y) ∧ 1 ≤ y := by |
| 67 | have hs0 : (0 : ℝ) < s := by exact_mod_cast hs |
| 68 | obtain ⟨hA, hB, hy1⟩ := mem_sS_bounds (by positivity) hy |
| 69 | have h1 : (s : ℝ) * y ≤ 8 * 2 ^ k := |
| 70 | calc (s : ℝ) * y ≤ s * (8 * ((2 : ℝ) ^ k / s)) := mul_le_mul_of_nonneg_left hA hs0.le |
| 71 | _ = 8 * 2 ^ k := by field_simp |
| 72 | have h2 : (2 : ℝ) ^ k < 2 * (s * y) := |
| 73 | calc (2 : ℝ) ^ k = s * ((2 : ℝ) ^ k / s) := by field_simp |
| 74 | _ < s * (2 * y) := mul_lt_mul_of_pos_left hB hs0 |
| 75 | _ = 2 * (s * y) := by ring |
| 76 | exact ⟨by exact_mod_cast h1, by exact_mod_cast h2, hy1⟩ |
| 77 | |
| 78 | /-- The pieces `sS(2^k/s)` for `k ∈ 𝒩(W)` lie in the window `W / s`. -/ |
| 79 | lemma sS_sub_div_pts (W : Win) (hlo : 0 < W.lo) (s : ℕ) (hs : 1 ≤ s) (k : ℕ) |
| 80 | (hk : 4 * W.lo ≤ 2 ^ k ∧ 16 * (2 : ℝ) ^ k ≤ W.hi) : |
| 81 | sS ((2 : ℝ) ^ k / s) ⊆ (W.div s).pts := by |
| 82 | have hs0 : (0 : ℝ) < s := by exact_mod_cast hs |
| 83 | intro y hy |
| 84 | have hpos : (0 : ℝ) < (2 : ℝ) ^ k / s := by positivity |
| 85 | obtain ⟨hA, hB, hy1⟩ := mem_sS_bounds hpos hy |
| 86 | have hyR : (0 : ℝ) < y := by exact_mod_cast hy1 |
| 87 | have hB' : (2 : ℝ) ^ k < 2 * y * s := (div_lt_iff₀ hs0).1 hB |
| 88 | have hA' : (y : ℝ) * s ≤ 8 * 2 ^ k := |
| 89 | calc (y : ℝ) * s ≤ 8 * ((2 : ℝ) ^ k / s) * s := mul_le_mul_of_nonneg_right hA hs0.le |
| 90 | _ = 8 * 2 ^ k := by field_simp |
| 91 | rw [Win.mem_pts (W := W.div s) (div_nonneg hlo.le hs0.le) |
| 92 | (div_nonneg (hlo.trans_le (by linarith [hk.1, (by positivity : (0 : ℝ) ≤ 2 ^ k)])).le hs0.le)] |
| 93 | constructor |
| 94 | · show W.lo / s < y |
| 95 | rw [div_lt_iff₀ hs0] |
| 96 | nlinarith [hk.1, hB'] |
| 97 | · show (y : ℝ) ≤ W.hi / s |
| 98 | rw [le_div_iff₀ hs0] |
| 99 | nlinarith [hk.2, hA'] |
| 100 | |
| 101 | /-- The overlap of the dyadic pieces `sS(2^k/s)`: `1/2^k ≤ 8/(s y)` on each piece, and each `y` |
| 102 | lies in at most five of them. -/ |
| 103 | lemma dy_sum_bound (W : Win) (hlo : 0 < W.lo) (s : ℕ) (hs : 1 ≤ s) (g : ℕ → ℝ) (hg : ∀ n, 0 ≤ g n) : |
| 104 | ∑ k ∈ W.dy, (1 / (2 : ℝ) ^ k) * ∑ y ∈ sS ((2 : ℝ) ^ k / s), g y ≤ |
| 105 | (40 / (s : ℝ)) * ∑ y ∈ (W.div s).pts, g y / y := by |
| 106 | have hs0 : (0 : ℝ) < s := by exact_mod_cast hs |
| 107 | set h : ℕ → ℝ := fun y => 8 / (s : ℝ) * (g y / y) with hh |
| 108 | have hh0 : ∀ y, 0 ≤ h y := fun y => |
| 109 | mul_nonneg (by positivity) (div_nonneg (hg y) (Nat.cast_nonneg y)) |
| 110 | have step1 : ∀ k ∈ W.dy, (1 / (2 : ℝ) ^ k) * ∑ y ∈ sS ((2 : ℝ) ^ k / s), g y ≤ |
| 111 | ∑ y ∈ sS ((2 : ℝ) ^ k / s), h y := by |
| 112 | intro k _ |
| 113 | rw [Finset.mul_sum] |
| 114 | refine sum_le_sum fun y hy => ?_ |
| 115 | obtain ⟨hle, -, hy1⟩ := sS_nat_bounds k s hs hy |
| 116 | have hyR : (1 : ℝ) ≤ y := by exact_mod_cast hy1 |
| 117 | have hle' : (s : ℝ) * y ≤ 8 * 2 ^ k := by exact_mod_cast hle |
| 118 | have key : 1 / (2 : ℝ) ^ k ≤ 8 / (s : ℝ) / y := by |
| 119 | rw [div_div, div_le_div_iff₀ (by positivity) (by positivity)] |
| 120 | nlinarith |
| 121 | calc 1 / (2 : ℝ) ^ k * g y ≤ 8 / (s : ℝ) / y * g y := mul_le_mul_of_nonneg_right key (hg y) |
| 122 | _ = h y := by simp only [hh]; ring |
| 123 | have hcount : ∀ y : ℕ, (W.dy.filter fun k => y ∈ sS ((2 : ℝ) ^ k / s)).card ≤ 5 := by |
| 124 | intro y |
| 125 | rcases Nat.eq_zero_or_pos y with rfl | hy |
| 126 | · have : W.dy.filter (fun k => 0 ∈ sS ((2 : ℝ) ^ k / s)) = ∅ := by |
| 127 | ext k |
| 128 | simp only [mem_filter, Finset.notMem_empty, iff_false, not_and] |
| 129 | intro _ h0 |
| 130 | have := (sS_nat_bounds k s hs h0).2.2 |
| 131 | omega |
| 132 | rw [this]; simp |
| 133 | · refine (card_le_card ?_).trans (dyadic_window_card (s * y) (by positivity) W.dy) |
| 134 | intro k hk |
| 135 | obtain ⟨hk1, hk2⟩ := mem_filter.1 hk |
| 136 | obtain ⟨hb1, hb2, -⟩ := sS_nat_bounds k s hs hk2 |
| 137 | exact mem_filter.2 ⟨hk1, hb1, hb2⟩ |
| 138 | calc ∑ k ∈ W.dy, (1 / (2 : ℝ) ^ k) * ∑ y ∈ sS ((2 : ℝ) ^ k / s), g y |
| 139 | ≤ ∑ k ∈ W.dy, ∑ y ∈ sS ((2 : ℝ) ^ k / s), h y := sum_le_sum step1 |
| 140 | _ = ∑ k ∈ W.dy, ∑ y ∈ (W.div s).pts, if y ∈ sS ((2 : ℝ) ^ k / s) then h y else 0 := by |
| 141 | refine sum_congr rfl fun k hk => ?_ |
| 142 | rw [sum_ite_mem, inter_eq_right.2] |
| 143 | intro y hy |
| 144 | exact sS_sub_div_pts W hlo s hs k (dy_spec hk) hy |
| 145 | _ = ∑ y ∈ (W.div s).pts, ∑ k ∈ W.dy, if y ∈ sS ((2 : ℝ) ^ k / s) then h y else 0 := |
| 146 | sum_comm |
| 147 | _ = ∑ y ∈ (W.div s).pts, ((W.dy.filter fun k => y ∈ sS ((2 : ℝ) ^ k / s)).card : ℝ) * h y := by |
| 148 | refine sum_congr rfl fun y _ => ?_ |
| 149 | rw [← sum_filter, sum_const, nsmul_eq_mul] |
| 150 | _ ≤ ∑ y ∈ (W.div s).pts, 5 * h y := |
| 151 | sum_le_sum fun y _ => mul_le_mul_of_nonneg_right (by exact_mod_cast hcount y) (hh0 y) |
| 152 | _ = (40 / (s : ℝ)) * ∑ y ∈ (W.div s).pts, g y / y := by |
| 153 | rw [mul_sum] |
| 154 | refine sum_congr rfl fun y _ => ?_ |
| 155 | simp only [hh] |
| 156 | ring |
| 157 | |
| 158 | /-- Jensen for the L33 centring: for a `0/1` sequence `b`, `(b y - H-average)²` is at most the average |
| 159 | of the indicators `ind (b (y + j) ≠ b y)` over `j < H`. -/ |
| 160 | lemma jensen_centred (b : ℕ → ℝ) (hb : ∀ n, b n = 0 ∨ b n = 1) {H : ℕ} (hH : 1 ≤ H) (y : ℕ) : |
| 161 | (b y - (∑ j ∈ range H, b (y + j)) / H) ^ 2 ≤ |
| 162 | (1 / (H : ℝ)) * ∑ j ∈ range H, ind (b (y + j) ≠ b y) := by |
| 163 | have hHpos : (0 : ℝ) < H := by exact_mod_cast hH |
| 164 | have hsum : b y - (∑ j ∈ range H, b (y + j)) / H = |
| 165 | (1 / (H : ℝ)) * ∑ j ∈ range H, (b y - b (y + j)) := by |
| 166 | have h1 : ∑ j ∈ range H, (b y - b (y + j)) = H * b y - ∑ j ∈ range H, b (y + j) := by |
| 167 | rw [sum_sub_distrib, sum_const, card_range, nsmul_eq_mul] |
| 168 | rw [h1] |
| 169 | field_simp |
| 170 | have hCS := sq_sum_le_card_mul_sum_sq (s := range H) (f := fun j => b y - b (y + j)) |
| 171 | rw [card_range] at hCS |
| 172 | have hsq : ∑ j ∈ range H, (b y - b (y + j)) ^ 2 = ∑ j ∈ range H, ind (b (y + j) ≠ b y) := by |
| 173 | refine sum_congr rfl fun j _ => ?_ |
| 174 | rcases hb y with h1 | h1 <;> rcases hb (y + j) with h2 | h2 <;> |
| 175 | simp [ind, h1, h2] <;> norm_num |
| 176 | rw [hsum, ← hsq] |
| 177 | calc ((1 / (H : ℝ)) * ∑ j ∈ range H, (b y - b (y + j))) ^ 2 |
| 178 | = (1 / (H : ℝ)) ^ 2 * (∑ j ∈ range H, (b y - b (y + j))) ^ 2 := by ring |
| 179 | _ ≤ (1 / (H : ℝ)) ^ 2 * ((H : ℝ) * ∑ j ∈ range H, (b y - b (y + j)) ^ 2) := |
| 180 | mul_le_mul_of_nonneg_left hCS (sq_nonneg _) |
| 181 | _ = (1 / (H : ℝ)) * ∑ j ∈ range H, (b y - b (y + j)) ^ 2 := by |
| 182 | field_simp |
| 183 | |
| 184 | /-- The `1/y`-weighted sum of the Jensen bound over the window `W / s`, with the averages of `F` |
| 185 | controlled by Proposition D(ii) on `W / s` (`j < H`, `1 ≤ j`, `D_{W/s}(j) ≤ e'`). -/ |
| 186 | lemma sum_pts_le (W : Win) (hlen : 0 < W.len) (s : ℕ) (hs : 1 ≤ s) {H : ℕ} (hH : 1 ≤ H) |
| 187 | {e' : ℝ} (he' : 0 ≤ e') (hD : ∀ j, 1 ≤ j → j < H → (W.div s).D j ≤ e') |
| 188 | (g : ℕ → ℝ) (hg : ∀ y, 0 ≤ g y ∧ g y ≤ (1 / (H : ℝ)) * ∑ j ∈ range H, ind (F (y + j) ≠ F y)) : |
| 189 | ∑ y ∈ (W.div s).pts, g y / y ≤ W.len * e' := by |
| 190 | have hs0 : (0 : ℝ) < s := by exact_mod_cast hs |
| 191 | have hHpos : (0 : ℝ) < H := by exact_mod_cast hH |
| 192 | have hlen' : (W.div s).len = W.len := Win.len_div hs0.ne' |
| 193 | have hpos' : 0 < (W.div s).len := hlen' ▸ hlen |
| 194 | have hsumD : ∀ j, ∑ y ∈ (W.div s).pts, ind (F (y + j) ≠ F y) / y = W.len * (W.div s).D j := by |
| 195 | intro j |
| 196 | have hD : (W.div s).D j = (W.div s).sum (fun n => ind (F (n + j) ≠ F n)) / (W.div s).len := rfl |
| 197 | rw [hD, ← hlen'] |
| 198 | field_simp |
| 199 | rfl |
| 200 | calc ∑ y ∈ (W.div s).pts, g y / y |
| 201 | ≤ ∑ y ∈ (W.div s).pts, (1 / (H : ℝ)) * ∑ j ∈ range H, ind (F (y + j) ≠ F y) / y := by |
| 202 | refine sum_le_sum fun y _ => ?_ |
| 203 | rcases Nat.eq_zero_or_pos y with rfl | hy |
| 204 | · simp |
| 205 | · have hy' : (0 : ℝ) < y := by exact_mod_cast hy |
| 206 | calc g y / y ≤ ((1 / (H : ℝ)) * ∑ j ∈ range H, ind (F (y + j) ≠ F y)) / y := |
| 207 | div_le_div_of_nonneg_right (hg y).2 hy'.le |
| 208 | _ = (1 / (H : ℝ)) * ∑ j ∈ range H, ind (F (y + j) ≠ F y) / y := by |
| 209 | rw [mul_div_assoc, sum_div] |
| 210 | _ = (1 / (H : ℝ)) * ∑ j ∈ range H, W.len * (W.div s).D j := by |
| 211 | rw [← mul_sum, sum_comm] |
| 212 | congr 1 |
| 213 | refine sum_congr rfl fun j _ => ?_ |
| 214 | exact hsumD j |
| 215 | _ ≤ (1 / (H : ℝ)) * ∑ j ∈ range H, W.len * e' := by |
| 216 | refine mul_le_mul_of_nonneg_left (sum_le_sum fun j hj => ?_) (by positivity) |
| 217 | refine mul_le_mul_of_nonneg_left ?_ hlen.le |
| 218 | rcases Nat.eq_zero_or_pos j with rfl | hj1 |
| 219 | · have h0 : (W.div s).D 0 = 0 := by simp [Win.D, Win.E, Win.sum, ind] |
| 220 | rw [h0]; exact he' |
| 221 | · exact hD j hj1 (mem_range.1 hj) |
| 222 | _ = W.len * e' := by |
| 223 | rw [sum_const, card_range, nsmul_eq_mul] |
| 224 | field_simp |
| 225 | |
| 226 | end E424 |
| 227 | |