| 1 | module |
| 2 | |
| 3 | public import E424.DirichletError.L29AuxC |
| 4 | public import E424.Tools.T4 |
| 5 | |
| 6 | @[expose] public section |
| 7 | |
| 8 | /-! |
| 9 | # L29, step 4: summation over the dyadic scales of a window, and `e_2` by the mean value theorem |
| 10 | -/ |
| 11 | |
| 12 | set_option linter.style.header false |
| 13 | open Finset MeasureTheory |
| 14 | |
| 15 | namespace E424 |
| 16 | |
| 17 | theorem dy_spec {W : Win} {k : ℕ} (hk : k ∈ W.dy) : 4 * W.lo ≤ 2 ^ k ∧ 16 * (2 : ℝ) ^ k ≤ W.hi := |
| 18 | (mem_filter.mp hk).2 |
| 19 | |
| 20 | /-- The dyadic pieces overlap at most twice. -/ |
| 21 | theorem dy_overlap (W : Win) (hlo : 0 < W.lo) (s : ℕ → Finset ℕ) |
| 22 | (hs : ∀ k ∈ W.dy, ∀ p ∈ s k, (2 : ℝ) ^ k < p ∧ (p : ℝ) < 4 * 2 ^ k) (G : ℕ → ℝ) |
| 23 | (hG : ∀ n, 0 ≤ G n) : ∑ k ∈ W.dy, ∑ p ∈ s k, G p / p ≤ 2 * W.sum G := by |
| 24 | have hG' : ∀ p : ℕ, 0 ≤ G p / p := fun p => div_nonneg (hG p) (Nat.cast_nonneg p) |
| 25 | have h1 : ∀ k ∈ W.dy, ∑ p ∈ s k, G p / p ≤ |
| 26 | ∑ p ∈ W.pts, if 2 ^ k < p ∧ p < 2 ^ (k + 2) then G p / p else 0 := by |
| 27 | intro k hk |
| 28 | obtain ⟨hk1, hk2⟩ := dy_spec hk |
| 29 | have hpow : (0 : ℝ) < 2 ^ k := by positivity |
| 30 | rw [← sum_filter] |
| 31 | refine sum_le_sum_of_subset_of_nonneg (fun p hp => ?_) fun p _ _ => hG' p |
| 32 | obtain ⟨h2, h3⟩ := hs k hk p hp |
| 33 | rw [mem_filter, Win.mem_pts hlo.le (by linarith)] |
| 34 | refine ⟨⟨by linarith, by linarith⟩, by exact_mod_cast h2, ?_⟩ |
| 35 | have : (p : ℝ) < 2 ^ (k + 2) := by rw [pow_add]; linarith |
| 36 | exact_mod_cast this |
| 37 | refine (sum_le_sum h1).trans ?_ |
| 38 | rw [sum_comm, Win.sum, mul_sum] |
| 39 | refine sum_le_sum fun p _ => ?_ |
| 40 | rw [← sum_filter, sum_const, nsmul_eq_mul] |
| 41 | refine mul_le_mul_of_nonneg_right ?_ (hG' p) |
| 42 | have hsub : (W.dy.filter fun k => 2 ^ k < p ∧ p < 2 ^ (k + 2)) ⊆ |
| 43 | Icc (Nat.log 2 p - 1) (Nat.log 2 p) := by |
| 44 | intro k hk |
| 45 | obtain ⟨-, h2, h3⟩ := mem_filter.mp hk |
| 46 | have hp : p ≠ 0 := by rintro rfl; exact absurd h2 (Nat.not_lt_zero _) |
| 47 | have h4 := Nat.le_log_of_pow_le (by norm_num) h2.le |
| 48 | have h5 := Nat.log_lt_of_lt_pow hp h3 |
| 49 | rw [mem_Icc]; omega |
| 50 | have := (card_le_card hsub).trans (by rw [Nat.card_Icc]; omega : _ ≤ 2) |
| 51 | exact_mod_cast this |
| 52 | |
| 53 | theorem dy_card (W : Win) (hlo : 0 < W.lo) (hlen : 0 ≤ W.len) : (W.dy.card : ℝ) ≤ 2 * W.len := by |
| 54 | rcases W.dy.eq_empty_or_nonempty with he | hne |
| 55 | · rw [he, card_empty]; push_cast; linarith |
| 56 | · obtain ⟨k0, hk0⟩ := hne |
| 57 | obtain ⟨h1, h2⟩ := dy_spec hk0 |
| 58 | have hp : (0 : ℝ) < 2 ^ k0 := by positivity |
| 59 | have hhi : 0 < W.hi := by linarith |
| 60 | have hl2 : 0 < Real.log 2 := Real.log_pos one_lt_two |
| 61 | have hl2' : 1 / 2 ≤ Real.log 2 := by linarith [Real.log_two_gt_d9] |
| 62 | set a := W.dy.min' ⟨k0, hk0⟩ with ha |
| 63 | set b := W.dy.max' ⟨k0, hk0⟩ with hb |
| 64 | have hab : a ≤ b := min'_le_max' _ _ |
| 65 | obtain ⟨ha1, -⟩ := dy_spec (W.dy.min'_mem ⟨k0, hk0⟩) |
| 66 | obtain ⟨-, hb2⟩ := dy_spec (W.dy.max'_mem ⟨k0, hk0⟩) |
| 67 | rw [← ha] at ha1 |
| 68 | rw [← hb] at hb2 |
| 69 | have hcard : W.dy.card ≤ b + 1 - a := by |
| 70 | rw [← Nat.card_Icc] |
| 71 | exact card_le_card fun k hk => mem_Icc.mpr ⟨min'_le _ _ hk, le_max' _ _ hk⟩ |
| 72 | have hcard' : (W.dy.card : ℝ) ≤ b + 1 - a := by |
| 73 | refine (Nat.cast_le.mpr hcard).trans (le_of_eq ?_) |
| 74 | rw [Nat.cast_sub (by omega)]; push_cast; ring |
| 75 | have h3 : (2 : ℝ) ^ b * 64 ≤ W.hi / W.lo * 2 ^ a := by |
| 76 | rw [div_mul_eq_mul_div, le_div_iff₀ hlo] |
| 77 | have : (0 : ℝ) < 2 ^ b := by positivity |
| 78 | nlinarith [mul_le_mul hb2 ha1 (by positivity) hhi.le] |
| 79 | have h4 := Real.log_le_log (by positivity) h3 |
| 80 | rw [Real.log_mul (by positivity) (by norm_num), Real.log_mul (by positivity) (by positivity), |
| 81 | Real.log_pow, Real.log_pow, show (64 : ℝ) = 2 ^ 6 by norm_num, Real.log_pow] at h4 |
| 82 | change _ ≤ W.len + _ at h4 |
| 83 | push_cast at h4 |
| 84 | have hab' : (a : ℝ) ≤ b := by exact_mod_cast hab |
| 85 | nlinarith |
| 86 | |
| 87 | /-- Cauchy-Schwarz for window averages of `ind * u²`. -/ |
| 88 | theorem window_cs (W : Win) (hlen : 0 < W.len) (q : ℕ → Prop) (u : ℕ → ℝ) {y V : ℝ} |
| 89 | (hy : W.E (fun n => ind (q n)) ≤ y) (hV : W.E (fun n => u n ^ 4) ≤ V) : |
| 90 | W.sum (fun n => ind (q n) * u n ^ 2) ≤ W.len * Real.sqrt (y * V) := by |
| 91 | have hy0 : 0 ≤ W.E (fun n => ind (q n)) := Win.E_nonneg hlen.le fun _ _ => ind_nonneg _ |
| 92 | have hV0 : 0 ≤ W.E (fun n => u n ^ 4) := Win.E_nonneg hlen.le fun _ _ => by positivity |
| 93 | have hind : ∀ n, ind (q n) ^ 2 = ind (q n) := fun n => by unfold ind; split_ifs <;> norm_num |
| 94 | have h := Real.sum_mul_le_sqrt_mul_sqrt W.pts (fun n => ind (q n) / Real.sqrt n) |
| 95 | (fun n => u n ^ 2 / Real.sqrt n) |
| 96 | have e1 : ∀ n ∈ W.pts, ind (q n) / Real.sqrt n * (u n ^ 2 / Real.sqrt n) = |
| 97 | ind (q n) * u n ^ 2 / n := fun n _ => by |
| 98 | rw [div_mul_div_comm, Real.mul_self_sqrt (Nat.cast_nonneg n)] |
| 99 | have e2 : ∀ n ∈ W.pts, (ind (q n) / Real.sqrt n) ^ 2 = ind (q n) / n := fun n _ => by |
| 100 | rw [div_pow, Real.sq_sqrt (Nat.cast_nonneg n), hind] |
| 101 | have e3 : ∀ n ∈ W.pts, (u n ^ 2 / Real.sqrt n) ^ 2 = u n ^ 4 / n := fun n _ => by |
| 102 | rw [div_pow, Real.sq_sqrt (Nat.cast_nonneg n)]; ring |
| 103 | rw [sum_congr rfl e1, sum_congr rfl e2, sum_congr rfl e3] at h |
| 104 | change W.sum (fun n => ind (q n) * u n ^ 2) ≤ Real.sqrt (W.sum fun n => ind (q n)) * |
| 105 | Real.sqrt (W.sum fun n => u n ^ 4) at h |
| 106 | refine h.trans ?_ |
| 107 | rw [Win.sum_eq_E_mul hlen, Win.sum_eq_E_mul hlen, ← Real.sqrt_mul (by positivity)] |
| 108 | have e4 : W.len * Real.sqrt (y * V) = Real.sqrt (W.len ^ 2 * (y * V)) := by |
| 109 | rw [Real.sqrt_mul (sq_nonneg _), Real.sqrt_sq hlen.le] |
| 110 | rw [e4] |
| 111 | refine Real.sqrt_le_sqrt ?_ |
| 112 | calc _ = W.len ^ 2 * (W.E (fun n => ind (q n)) * W.E (fun n => u n ^ 4)) := by ring |
| 113 | _ ≤ _ := by gcongr; exact hy0.trans hy |
| 114 | |
| 115 | /-- Sum of `Dsum` over the dyadic scales. -/ |
| 116 | theorem Dsum_total (W : Win) (hlo : 0 < W.lo) (hlen : 0 < W.len) (S : Finset ℕ) {H y V : ℝ} (hH : 1 ≤ H) |
| 117 | (hy : ∀ h : ℕ, (h : ℝ) ≤ 8 * H → W.D h ≤ y) |
| 118 | (hV : ∀ h : ℕ, (h : ℝ) ≤ 8 * H → W.E (fun n => (ms S - rc S (n + h)) ^ 4) ≤ V) : |
| 119 | ∑ k ∈ W.dy, Dsum S (2 ^ k) H ≤ 16 * H * W.len * Real.sqrt (y * V) := by |
| 120 | unfold Dsum |
| 121 | rw [sum_comm] |
| 122 | have h1 : ∀ h ∈ Icc 1 ⌊8 * H⌋₊, ∑ k ∈ W.dy, ∑ p ∈ Icc ⌈(2 : ℝ) ^ k / 2⌉₊ ⌊4 * (2 : ℝ) ^ k⌋₊ with |
| 123 | (2 : ℝ) ^ k < (p : ℕ) ∧ (p : ℝ) < 4 * 2 ^ k, |
| 124 | ind (F (p + h) ≠ F p) * (ms S - rc S (p + h)) ^ 2 / p ≤ 2 * (W.len * Real.sqrt (y * V)) := by |
| 125 | intro h hh |
| 126 | have hh' : (h : ℝ) ≤ 8 * H := (Nat.le_floor_iff (by linarith)).mp (mem_Icc.mp hh).2 |
| 127 | refine (dy_overlap W hlo _ (fun k _ p hp => (mem_filter.mp hp).2) |
| 128 | (fun p => ind (F (p + h) ≠ F p) * (ms S - rc S (p + h)) ^ 2) |
| 129 | fun p => mul_nonneg (ind_nonneg _) (sq_nonneg _)).trans ?_ |
| 130 | exact mul_le_mul_of_nonneg_left (window_cs W hlen (fun n => F (n + h) ≠ F n) |
| 131 | (fun n => ms S - rc S (n + h)) (hy h hh') (hV h hh')) (by norm_num) |
| 132 | refine (sum_le_sum h1).trans ?_ |
| 133 | rw [sum_const, Nat.card_Icc, Nat.add_sub_cancel, nsmul_eq_mul] |
| 134 | have hfl : (⌊8 * H⌋₊ : ℝ) ≤ 8 * H := Nat.floor_le (by linarith) |
| 135 | have : 0 ≤ W.len * Real.sqrt (y * V) := by positivity |
| 136 | nlinarith |
| 137 | |
| 138 | /-- `∑_{s ∣ n} (F n - F (n/s))`. -/ |
| 139 | noncomputable def e2 (S : Finset ℕ) (n : ℕ) : ℝ := ∑ s ∈ S with s ∣ n, (F n - F (n / s)) |
| 140 | |
| 141 | theorem e2_sq_le (S : Finset ℕ) (n : ℕ) : e2 S n ^ 2 ≤ rc S n * badCount S n := by |
| 142 | have h1 : |e2 S n| ≤ badCount S n := by |
| 143 | rw [badCount_eq]; exact abs_sum_le_sum_abs _ _ |
| 144 | have h2 : badCount S n ≤ rc S n := by |
| 145 | rw [rc_eq_sum']; exact sum_le_sum fun s _ => ind_le_one _ |
| 146 | have h3 := abs_nonneg (e2 S n) |
| 147 | rw [← sq_abs] |
| 148 | nlinarith |
| 149 | |
| 150 | /-- `e_2` on one scale. -/ |
| 151 | theorem e2_step : ∃ C > 0, ∀ (S : Finset ℕ) (N H : ℝ), 1 ≤ H → 40 * H ≤ N → |
| 152 | ∫ t in (-(N / H))..(N / H), ‖∑ n ∈ Icc 1 ⌊4 * N⌋₊, ((wt N n * e2 S n : ℝ) : ℂ) * nit n t‖ ^ 2 ≤ |
| 153 | C * ∑ n ∈ Icc 1 ⌊4 * N⌋₊ with N < (n : ℕ) ∧ (n : ℝ) < 4 * N, rc S n * badCount S n / n := by |
| 154 | obtain ⟨C, hC, h4⟩ := T4_mean_value |
| 155 | refine ⟨2 * C, by positivity, fun S N H hH hN => ?_⟩ |
| 156 | have hN0 : 0 < N := by linarith |
| 157 | have hT : 0 ≤ N / H := by positivity |
| 158 | set s := (Icc 1 ⌊4 * N⌋₊).filter fun n : ℕ => N < (n : ℕ) ∧ (n : ℝ) < 4 * N with hs |
| 159 | have e : ∀ t, ∑ n ∈ Icc 1 ⌊4 * N⌋₊, ((wt N n * e2 S n : ℝ) : ℂ) * nit n t = |
| 160 | ∑ n ∈ s, ((wt N n * e2 S n : ℝ) : ℂ) * nit n t := by |
| 161 | intro t |
| 162 | refine (sum_subset (filter_subset _ _) fun n hn hns => ?_).symm |
| 163 | have : wt N n = 0 := by |
| 164 | by_contra h |
| 165 | exact hns (mem_filter.mpr ⟨hn, wt_supp hN0 h⟩) |
| 166 | rw [this]; simp |
| 167 | simp only [e] |
| 168 | refine (h4 N (N / H) (by linarith) hT s (fun n => ((wt N n * e2 S n : ℝ) : ℂ)) fun n hn => ?_).trans ?_ |
| 169 | · obtain ⟨-, h1, h2⟩ := mem_filter.mp hn |
| 170 | constructor <;> linarith |
| 171 | · have hTN : N / H + N ≤ 2 * N := by |
| 172 | have : N / H ≤ N := div_le_self hN0.le hH |
| 173 | linarith |
| 174 | have hterm : ∀ n ∈ s, ‖((wt N n * e2 S n : ℝ) : ℂ)‖ ^ 2 ≤ 1 / N * (rc S n * badCount S n / n) := by |
| 175 | intro n hn |
| 176 | obtain ⟨-, h1, -⟩ := mem_filter.mp hn |
| 177 | have hn0 : (0 : ℝ) < n := by linarith |
| 178 | rw [Complex.norm_real, Real.norm_eq_abs, sq_abs, mul_pow] |
| 179 | have h3 : wt N n ≤ 1 / n := by |
| 180 | unfold wt; exact div_le_div_of_nonneg_right (gw_le_one _) hn0.le |
| 181 | have h5 : wt N n ^ 2 ≤ 1 / N * (1 / n) := by |
| 182 | rw [sq]; exact mul_le_mul (wt_le hN0 n) h3 (wt_nonneg N n) (by positivity) |
| 183 | calc wt N n ^ 2 * e2 S n ^ 2 ≤ 1 / N * (1 / n) * (rc S n * badCount S n) := |
| 184 | mul_le_mul h5 (e2_sq_le S n) (sq_nonneg _) (by positivity) |
| 185 | _ = _ := by ring |
| 186 | have hnn : 0 ≤ ∑ n ∈ s, rc S n * badCount S n / n := sum_nonneg fun n _ => |
| 187 | div_nonneg ((sq_nonneg _).trans (e2_sq_le S n)) (Nat.cast_nonneg n) |
| 188 | calc C * (N / H + N) * ∑ n ∈ s, ‖((wt N n * e2 S n : ℝ) : ℂ)‖ ^ 2 |
| 189 | ≤ C * (2 * N) * ∑ n ∈ s, 1 / N * (rc S n * badCount S n / n) := by |
| 190 | gcongr with n hn |
| 191 | exact hterm n hn |
| 192 | _ = _ := by rw [← mul_sum]; field_simp |
| 193 | |
| 194 | end E424 |
| 195 | |