| 1 | module |
| 2 | |
| 3 | public import E424.DivisorMoments.L13 |
| 4 | public import E424.DivisorMoments.L17Aux |
| 5 | |
| 6 | @[expose] public section |
| 7 | |
| 8 | /-! |
| 9 | # Section 4 of the outline: L17. Un-normalised window sums, valid on arbitrarily short windows. |
| 10 | -/ |
| 11 | |
| 12 | set_option linter.style.header false |
| 13 | open Finset |
| 14 | |
| 15 | namespace E424 |
| 16 | |
| 17 | /-- **Lemma 17**, exact dilation by `s`. -/ |
| 18 | theorem L17_dilate (W : Win) (hlo : 0 ≤ W.lo) (hhi : W.lo ≤ W.hi) {s : ℕ} (hs : 1 ≤ s) (G : ℕ → ℝ) : |
| 19 | W.sum (fun n => if s ∣ n then G (n / s) else 0) = (W.div s).sum G / s := by |
| 20 | have hs0 : (0 : ℝ) < s := by exact_mod_cast hs |
| 21 | have hhi0 : 0 ≤ W.hi := hlo.trans hhi |
| 22 | unfold Win.sum |
| 23 | simp only [ite_div, zero_div] |
| 24 | rw [← sum_filter, sum_div] |
| 25 | symm |
| 26 | refine sum_bij' (fun y _ => s * y) (fun n _ => n / s) ?_ ?_ ?_ ?_ ?_ |
| 27 | · intro y hy |
| 28 | rw [Win.mem_pts (by simp only [Win.div]; positivity) (by simp only [Win.div]; positivity)] at hy |
| 29 | simp only [Win.div] at hy |
| 30 | rw [div_lt_iff₀ hs0, le_div_iff₀ hs0] at hy |
| 31 | rw [mem_filter, Win.mem_pts hlo hhi0] |
| 32 | push_cast |
| 33 | exact ⟨⟨by linarith [hy.1], by linarith [hy.2]⟩, dvd_mul_right s y⟩ |
| 34 | · intro n hn |
| 35 | rw [mem_filter, Win.mem_pts hlo hhi0] at hn |
| 36 | obtain ⟨⟨h1, h2⟩, y, rfl⟩ := hn |
| 37 | rw [Nat.mul_div_cancel_left y hs] |
| 38 | rw [Win.mem_pts (by simp only [Win.div]; positivity) (by simp only [Win.div]; positivity)] |
| 39 | simp only [Win.div] |
| 40 | rw [div_lt_iff₀ hs0, le_div_iff₀ hs0] |
| 41 | push_cast at h1 h2 |
| 42 | exact ⟨by linarith, by linarith⟩ |
| 43 | · intro y _; exact Nat.mul_div_cancel_left y hs |
| 44 | · intro n hn; exact Nat.mul_div_cancel' (mem_filter.mp hn).2 |
| 45 | · intro y _ |
| 46 | rw [Nat.mul_div_cancel_left y hs]; push_cast; rw [div_div, mul_comm (s : ℝ)] |
| 47 | |
| 48 | /-- **Lemma 17**, exact: divisor sums over a family. -/ |
| 49 | theorem L17_family (W : Win) (hlo : 0 ≤ W.lo) (hhi : W.lo ≤ W.hi) (S : Finset ℕ) (hS : ∀ s ∈ S, 1 ≤ s) |
| 50 | (G : ℕ → ℕ → ℝ) : |
| 51 | W.sum (fun n => ∑ s ∈ S with s ∣ n, G s (n / s)) = ∑ s ∈ S, (W.div s).sum (G s) / s := by |
| 52 | have : (fun n => ∑ s ∈ S with s ∣ n, G s (n / s)) = |
| 53 | fun n => ∑ s ∈ S, if s ∣ n then G s (n / s) else 0 := by |
| 54 | funext n; rw [sum_filter] |
| 55 | rw [this, Win.sum_finset_sum] |
| 56 | exact sum_congr rfl fun s hs => L17_dilate W hlo hhi (hS s hs) (G s) |
| 57 | |
| 58 | /-- **Lemma 17**, change of window under dilation. -/ |
| 59 | theorem L17_div (W : Win) (hlo : 0 < W.lo) (hhi : W.lo ≤ W.hi) (c : ℝ) (hc : 1 ≤ c) (G : ℕ → ℝ) |
| 60 | (h0 : ∀ n, 0 ≤ G n) (h1 : ∀ n, G n ≤ 1) : |
| 61 | |(W.div c).sum G - W.sum G| ≤ Real.log c + c / W.lo := by |
| 62 | exact L17Aux.div_bound hlo hhi hc G h0 h1 |
| 63 | |
| 64 | /-- **Lemma 17**, shifts. -/ |
| 65 | theorem L17_shift (W : Win) (hlo : 1 ≤ W.lo) (hhi : W.lo ≤ W.hi) (h : ℕ) (G : ℕ → ℝ) (M : ℝ) |
| 66 | (hG : ∀ n, |G n| ≤ M) : |W.sum (fun n => G (n + h)) - W.sum G| ≤ 4 * h * M / W.lo := by |
| 67 | exact L17Aux.shift_bound (hi := W.hi) hlo h G hG |
| 68 | |
| 69 | /-- **Lemma 17**, preimage under multiplication. -/ |
| 70 | theorem L17_mul (W : Win) (hlo : 1 ≤ W.lo) (hhi : W.lo ≤ W.hi) (c : ℕ) (hc : 1 ≤ c) (G : ℕ → ℝ) |
| 71 | (h0 : ∀ n, 0 ≤ G n) (h1 : ∀ n, G n ≤ 1) : |
| 72 | W.sum (fun n => G (c * n)) ≤ c * (W.sum G + Real.log c + 1 / W.lo) := by |
| 73 | have h := L17Aux.mul_bound (hi := W.hi) hlo hhi c hc G h0 h1 |
| 74 | calc W.sum (fun n => G (c * n)) ≤ (c : ℝ) * (W.sum G + (Real.log c + 1 / W.lo)) := h |
| 75 | _ = (c : ℝ) * (W.sum G + Real.log c + 1 / W.lo) := by ring |
| 76 | |
| 77 | end E424 |
| 78 | |