| 1 | module |
| 2 | |
| 3 | public import E424.NaturalDensity.L42 |
| 4 | public import E424.Tools.T3 |
| 5 | |
| 6 | @[expose] public section |
| 7 | |
| 8 | /-! |
| 9 | # Section 10: Lemma 43 |
| 10 | |
| 11 | Exchange the sums. For a fixed `n` in the window `(X/z^200, 2X/z]`, the `s ∈ S` with `n ∈ (X/s, 2X/s]` |
| 12 | are the `s` with `X/n < s ≤ 2X/n`. If `2X/n < z` there are none, since every `s ∈ S` exceeds `z`. |
| 13 | Otherwise they are `z`-rough numbers in an interval of length `2X/n ≥ z`, and T3 counts them by |
| 14 | `2X/(n log z)`. |
| 15 | -/ |
| 16 | |
| 17 | set_option linter.style.header false |
| 18 | open Finset |
| 19 | |
| 20 | namespace E424 |
| 21 | |
| 22 | /-- **Lemma 43.** -/ |
| 23 | theorem L43 : ∃ C > 0, ∀ z : ℝ, 4 ≤ z → ∀ S : Finset ℕ, IsFam z S → ∀ X : ℝ, 1 ≤ X → |
| 24 | ∑ s ∈ S, bcount (X / s) ≤ C * X / Real.log z * (Win.mk (X / z ^ 200) (2 * X / z)).sum f := by |
| 25 | obtain ⟨C, hC, hT3⟩ := T3_rough_interval |
| 26 | refine ⟨2 * C, by positivity, fun z hz S hS X hX => ?_⟩ |
| 27 | have hz0 : 0 < z := by linarith |
| 28 | have hX0 : 0 ≤ X := by linarith |
| 29 | have hlog : 0 < Real.log z := Real.log_pos (by linarith) |
| 30 | set V := Ioc ⌊X / z ^ 200⌋₊ ⌊2 * X / z⌋₊ with hV |
| 31 | have hW : (Win.mk (X / z ^ 200) (2 * X / z)).sum f = ∑ n ∈ V, f n / n := rfl |
| 32 | -- the `s`-term, as a sum over the window `V` |
| 33 | have hsV : ∀ s ∈ S, bcount (X / s) = |
| 34 | ∑ n ∈ V, if (X / (s : ℝ) < n ∧ (n : ℝ) ≤ 2 * (X / s)) then f n else 0 := by |
| 35 | intro s hs |
| 36 | obtain ⟨hzs, hsz, -⟩ := hS s hs |
| 37 | have hs0 : (0 : ℝ) < s := by linarith |
| 38 | have hsub : Ioc ⌊X / s⌋₊ ⌊2 * (X / s)⌋₊ ⊆ V := by |
| 39 | intro n hn |
| 40 | rw [mem_Ioc] at hn ⊢ |
| 41 | have h1 : X / z ^ 200 ≤ X / s := div_le_div_of_nonneg_left hX0 hs0 hsz |
| 42 | have h2 : 2 * (X / s) ≤ 2 * X / z := by |
| 43 | rw [← mul_div_assoc] |
| 44 | exact div_le_div_of_nonneg_left (by linarith) hz0 hzs.le |
| 45 | exact ⟨lt_of_le_of_lt (Nat.floor_mono h1) hn.1, hn.2.trans (Nat.floor_mono h2)⟩ |
| 46 | have hfilt : V.filter (fun n : ℕ => X / (s : ℝ) < n ∧ (n : ℝ) ≤ 2 * (X / s)) = |
| 47 | Ioc ⌊X / s⌋₊ ⌊2 * (X / s)⌋₊ := by |
| 48 | ext n |
| 49 | simp only [mem_filter, mem_Ioc] |
| 50 | constructor |
| 51 | · rintro ⟨-, h1, h2⟩ |
| 52 | exact ⟨(Nat.floor_lt (div_nonneg hX0 hs0.le)).2 h1, |
| 53 | (Nat.le_floor_iff (by have := div_nonneg hX0 hs0.le; linarith)).2 h2⟩ |
| 54 | · rintro ⟨h1, h2⟩ |
| 55 | exact ⟨hsub (mem_Ioc.2 ⟨h1, h2⟩), (Nat.floor_lt (div_nonneg hX0 hs0.le)).1 h1, |
| 56 | (Nat.le_floor_iff (by have := div_nonneg hX0 hs0.le; linarith)).1 h2⟩ |
| 57 | unfold bcount |
| 58 | rw [← sum_filter, hfilt] |
| 59 | -- for a fixed `n` in the window, at most `2C X/(n log z)` divisors `s ∈ S` |
| 60 | have key : ∀ n ∈ V, ((S.filter fun s : ℕ => X / (s : ℝ) < n ∧ (n : ℝ) ≤ 2 * (X / s)).card : ℝ) ≤ |
| 61 | 2 * C * X / n / Real.log z := by |
| 62 | intro n hn |
| 63 | have hn1 : 1 ≤ n := by have := (mem_Ioc.1 hn).1; omega |
| 64 | have hn0 : (0 : ℝ) < n := by exact_mod_cast hn1 |
| 65 | have hiff : ∀ s : ℕ, 0 < (s : ℝ) → |
| 66 | ((X / (s : ℝ) < n ∧ (n : ℝ) ≤ 2 * (X / s)) ↔ (X / (n : ℝ) < s ∧ (s : ℝ) ≤ 2 * (X / n))) := by |
| 67 | intro s hs |
| 68 | rw [div_lt_iff₀ hs, div_lt_iff₀ hn0, ← mul_div_assoc, le_div_iff₀ hs, ← mul_div_assoc, |
| 69 | le_div_iff₀ hn0, mul_comm (n : ℝ) s] |
| 70 | have hfilt : S.filter (fun s : ℕ => X / (s : ℝ) < n ∧ (n : ℝ) ≤ 2 * (X / s)) = |
| 71 | S.filter (fun s : ℕ => X / (n : ℝ) < s ∧ (s : ℝ) ≤ 2 * (X / n)) := |
| 72 | filter_congr fun s hs => hiff s (by linarith [(hS s hs).1]) |
| 73 | rw [hfilt] |
| 74 | rcases lt_or_ge (2 * (X / n)) z with hlt | hge |
| 75 | · have hempty : S.filter (fun s : ℕ => X / (n : ℝ) < s ∧ (s : ℝ) ≤ 2 * (X / n)) = ∅ := |
| 76 | filter_eq_empty_iff.2 fun s hs hP => by linarith [(hS s hs).1, hP.2] |
| 77 | rw [hempty, card_empty, Nat.cast_zero] |
| 78 | have : 0 ≤ X / (n : ℝ) := div_nonneg hX0 hn0.le |
| 79 | positivity |
| 80 | · have hcard := hT3 z (2 * (X / n)) (X / n) (by linarith) hge (div_nonneg hX0 hn0.le) |
| 81 | (S.filter fun s : ℕ => X / (n : ℝ) < s ∧ (s : ℝ) ≤ 2 * (X / n)) fun s hs => by |
| 82 | have hsS := (mem_filter.1 hs).1 |
| 83 | have hP := (mem_filter.1 hs).2 |
| 84 | exact ⟨hP.1, by linarith [hP.2], (hS s hsS).2.2⟩ |
| 85 | calc _ ≤ _ := hcard |
| 86 | _ = _ := by ring |
| 87 | calc ∑ s ∈ S, bcount (X / s) |
| 88 | = ∑ s ∈ S, ∑ n ∈ V, (if (X / (s : ℝ) < n ∧ (n : ℝ) ≤ 2 * (X / s)) then f n else 0) := |
| 89 | sum_congr rfl hsV |
| 90 | _ = ∑ n ∈ V, ∑ s ∈ S, (if (X / (s : ℝ) < n ∧ (n : ℝ) ≤ 2 * (X / s)) then f n else 0) := |
| 91 | sum_comm |
| 92 | _ = ∑ n ∈ V, f n * ((S.filter fun s : ℕ => X / (s : ℝ) < n ∧ (n : ℝ) ≤ 2 * (X / s)).card : ℝ) := by |
| 93 | refine sum_congr rfl fun n _ => ?_ |
| 94 | rw [← sum_filter, sum_const, nsmul_eq_mul, mul_comm] |
| 95 | _ ≤ ∑ n ∈ V, f n * (2 * C * X / n / Real.log z) := |
| 96 | sum_le_sum fun n hn => mul_le_mul_of_nonneg_left (key n hn) (f_nonneg n) |
| 97 | _ = 2 * C * X / Real.log z * (Win.mk (X / z ^ 200) (2 * X / z)).sum f := by |
| 98 | rw [hW, mul_sum] |
| 99 | refine sum_congr rfl fun n _ => ?_ |
| 100 | ring |
| 101 | |
| 102 | end E424 |
| 103 | |