| 1 | module |
| 2 | |
| 3 | public import E424.NaturalDensity.L41 |
| 4 | |
| 5 | @[expose] public section |
| 6 | |
| 7 | /-! |
| 8 | # Section 10: Lemma 42 (proved from Lemma 41) |
| 9 | -/ |
| 10 | |
| 11 | set_option linter.style.header false |
| 12 | open Finset |
| 13 | |
| 14 | namespace E424 |
| 15 | |
| 16 | /-- `#(B ∩ (X, 2X])`. -/ |
| 17 | noncomputable def bcount (X : ℝ) : ℝ := ∑ n ∈ Ioc ⌊X⌋₊ ⌊2 * X⌋₊, f n |
| 18 | |
| 19 | /-- **Lemma 42.** -/ |
| 20 | theorem L42 : ∃ C > 0, ∀ (J : ℕ) (T : Finset ℕ), IsBlocks J T → ∀ X : ℝ, 2 ≤ X → |
| 21 | (∀ s ∈ T, s ∈ A ∧ s % 3 = 2 ∧ (s : ℝ) ≤ X ^ (0.1 : ℝ)) → |
| 22 | bcount X * ms T ≤ (∑ s ∈ T, bcount (X / s)) + C * Real.sqrt J * X + ms T := by |
| 23 | obtain ⟨C, hC, h41⟩ := L41 |
| 24 | refine ⟨Real.sqrt (2 * C), by positivity, fun J T hT X hX hmem => ?_⟩ |
| 25 | have hX0 : 0 < X := by linarith |
| 26 | set I := Ioc ⌊X⌋₊ ⌊2 * X⌋₊ with hI |
| 27 | have hmemI : ∀ n ∈ I, X < n ∧ (n : ℝ) ≤ 2 * X := fun n hn => by |
| 28 | rw [hI, mem_Ioc, Nat.floor_lt hX0.le, Nat.le_floor_iff (by positivity)] at hn; exact hn |
| 29 | have hcardI : (I.card : ℝ) ≤ 2 * X := by |
| 30 | have : I.card ≤ ⌊2 * X⌋₊ := by rw [hI, Nat.card_Ioc]; omega |
| 31 | calc (I.card : ℝ) ≤ ⌊2 * X⌋₊ := by exact_mod_cast this |
| 32 | _ ≤ 2 * X := Nat.floor_le (by positivity) |
| 33 | -- shift by one |
| 34 | have hshift : bcount X - 1 ≤ ∑ n ∈ I, f (n - 1) := by |
| 35 | unfold bcount |
| 36 | have hle : ⌊X⌋₊ ≤ ⌊2 * X⌋₊ := Nat.floor_mono (by linarith) |
| 37 | have hre : ∑ n ∈ I, f (n - 1) = ∑ n ∈ Ico ⌊X⌋₊ ⌊2 * X⌋₊, f n := by |
| 38 | refine sum_bij' (fun n _ => n - 1) (fun n _ => n + 1) ?_ ?_ ?_ ?_ ?_ <;> |
| 39 | simp only [hI, mem_Ioc, mem_Ico] <;> intros <;> first | omega | trivial |
| 40 | rw [hre] |
| 41 | have h1 : ∑ n ∈ Ioc ⌊X⌋₊ ⌊2 * X⌋₊, f n ≤ (∑ n ∈ Ico ⌊X⌋₊ ⌊2 * X⌋₊, f n) + f ⌊2 * X⌋₊ := by |
| 42 | have hsub : Ioc ⌊X⌋₊ ⌊2 * X⌋₊ ⊆ insert ⌊2 * X⌋₊ (Ico ⌊X⌋₊ ⌊2 * X⌋₊) := by |
| 43 | intro n hn |
| 44 | simp only [mem_Ioc, mem_insert, mem_Ico] at hn ⊢ |
| 45 | omega |
| 46 | refine (sum_le_sum_of_subset_of_nonneg hsub fun n _ _ => f_nonneg n).trans ?_ |
| 47 | rw [sum_insert (by simp)] |
| 48 | linarith |
| 49 | linarith [f_le_one ⌊2 * X⌋₊] |
| 50 | -- divisor side |
| 51 | have hdiv : ∑ n ∈ I, f (n - 1) * rc T n ≤ ∑ s ∈ T, bcount (X / s) := by |
| 52 | have h1 : ∑ n ∈ I, f (n - 1) * rc T n = ∑ s ∈ T, ∑ n ∈ I with s ∣ n, f (n - 1) := by |
| 53 | simp_rw [sum_filter] |
| 54 | rw [sum_comm] |
| 55 | refine sum_congr rfl fun n _ => ?_ |
| 56 | rw [rc_eq_sum, mul_sum] |
| 57 | refine sum_congr rfl fun s _ => ?_ |
| 58 | split_ifs <;> simp |
| 59 | rw [h1] |
| 60 | refine sum_le_sum fun s hs => ?_ |
| 61 | obtain ⟨hsA, hs3, hsX⟩ := hmem s hs |
| 62 | have hs1 : 1 ≤ s := by omega |
| 63 | have hs0 : (0 : ℝ) < s := by exact_mod_cast hs1 |
| 64 | unfold bcount |
| 65 | have h2 : ∑ n ∈ I with s ∣ n, f (n - 1) = |
| 66 | ∑ y ∈ Ioc ⌊X / s⌋₊ ⌊2 * (X / s)⌋₊, f (s * y - 1) := by |
| 67 | symm |
| 68 | refine sum_bij' (fun y _ => s * y) (fun n _ => n / s) ?_ ?_ ?_ ?_ ?_ |
| 69 | · intro y hy |
| 70 | rw [mem_Ioc, Nat.floor_lt (by positivity), Nat.le_floor_iff (by positivity), |
| 71 | div_lt_iff₀ hs0, mul_div_assoc', le_div_iff₀ hs0] at hy |
| 72 | rw [mem_filter, hI, mem_Ioc, Nat.floor_lt hX0.le, Nat.le_floor_iff (by positivity)] |
| 73 | push_cast |
| 74 | exact ⟨⟨by linarith, by linarith⟩, dvd_mul_right s y⟩ |
| 75 | · intro n hn |
| 76 | obtain ⟨hn, y, rfl⟩ := mem_filter.mp hn |
| 77 | have := hmemI _ hn |
| 78 | rw [Nat.mul_div_cancel_left y hs1, mem_Ioc, Nat.floor_lt (by positivity), |
| 79 | Nat.le_floor_iff (by positivity), div_lt_iff₀ hs0, mul_div_assoc', le_div_iff₀ hs0] |
| 80 | push_cast at this |
| 81 | exact ⟨by linarith, by linarith⟩ |
| 82 | · intro y _; exact Nat.mul_div_cancel_left y hs1 |
| 83 | · intro n hn; exact Nat.mul_div_cancel' (mem_filter.mp hn).2 |
| 84 | · intro y _; rfl |
| 85 | rw [h2] |
| 86 | refine sum_le_sum fun y hy => ?_ |
| 87 | rw [mem_Ioc, Nat.floor_lt (by positivity), div_lt_iff₀ hs0] at hy |
| 88 | by_cases hyU : y ∈ U |
| 89 | · refine L4 hsA hyU fun hsy => ?_ |
| 90 | have h3 : (s : ℝ) * s ≤ X := by |
| 91 | calc (s : ℝ) * s ≤ X ^ (0.1 : ℝ) * X ^ (0.1 : ℝ) := by gcongr |
| 92 | _ = X ^ (0.2 : ℝ) := by rw [← Real.rpow_add hX0]; norm_num |
| 93 | _ ≤ X ^ (1 : ℝ) := Real.rpow_le_rpow_of_exponent_le (by linarith) (by norm_num) |
| 94 | _ = X := Real.rpow_one X |
| 95 | rw [← hsy] at hy |
| 96 | linarith [hy.1] |
| 97 | · rw [f_eq_zero_of_not_U hyU] |
| 98 | refine (f_eq_zero_of_not_U fun hU => hyU ?_).le |
| 99 | have hy1 : 1 ≤ y := by |
| 100 | by_contra h0 |
| 101 | have : y = 0 := by omega |
| 102 | rw [this] at hy |
| 103 | have := hy.1 |
| 104 | simp at this |
| 105 | linarith |
| 106 | exact (mem_U_iff_of_mod hs3 hy1).mp hU |
| 107 | -- Cauchy-Schwarz |
| 108 | have hcs : ∑ n ∈ I, |rc T n - ms T| ≤ Real.sqrt (2 * C) * Real.sqrt J * X := by |
| 109 | have h1 := sum_mul_sq_le_sq_mul_sq I (fun _ => (1 : ℝ)) fun n => |rc T n - ms T| |
| 110 | simp only [one_mul, one_pow, sum_const, nsmul_eq_mul, mul_one, sq_abs] at h1 |
| 111 | have h2 := h41 J T hT X (by linarith) fun s hs => (hmem s hs).2.2 |
| 112 | have h3 : (∑ n ∈ I, |rc T n - ms T|) ^ 2 ≤ (Real.sqrt (2 * C) * Real.sqrt J * X) ^ 2 := by |
| 113 | rw [mul_pow, mul_pow, Real.sq_sqrt (by positivity), Real.sq_sqrt (by positivity)] |
| 114 | calc _ ≤ (I.card : ℝ) * ∑ n ∈ I, (rc T n - ms T) ^ 2 := h1 |
| 115 | _ ≤ 2 * X * (C * J * X) := by |
| 116 | refine mul_le_mul hcardI h2 (sum_nonneg fun _ _ => sq_nonneg _) (by positivity) |
| 117 | _ = _ := by ring |
| 118 | exact le_of_sq_le_sq h3 (by positivity) |
| 119 | have hsplit : (∑ n ∈ I, f (n - 1)) * ms T ≤ |
| 120 | ∑ n ∈ I, f (n - 1) * rc T n + ∑ n ∈ I, |rc T n - ms T| := by |
| 121 | rw [sum_mul, ← sum_add_distrib] |
| 122 | refine sum_le_sum fun n _ => ?_ |
| 123 | have h1 := neg_abs_le (rc T n - ms T) |
| 124 | have h2 := f_nonneg (n - 1) |
| 125 | have h3 := f_le_one (n - 1) |
| 126 | have h4 := abs_nonneg (rc T n - ms T) |
| 127 | nlinarith |
| 128 | have hms := ms_nonneg T |
| 129 | nlinarith |
| 130 | |
| 131 | end E424 |
| 132 | |