| | @@ -0,0 +1,219 @@ |
| 1 | +import ErdosSwarm.Erdos530RowPrime |
| 2 | +import Mathlib.NumberTheory.Chebyshev |
| 3 | +import Mathlib.Analysis.Complex.ExponentialBounds |
| 4 | + |
| 5 | +/-! |
| 6 | +# Rows in Erdős problem 530 without the prime number theorem |
| 7 | + |
| 8 | +The note `experiments/erdos530/lower-middle-energy/NOTES.md`, §2, chooses the prime of |
| 9 | +inequality (3) among the primes of `[Q, (1 + η) Q]` and counts them by the prime number theorem. |
| 10 | +This file replaces that count by Chebyshev's bounds, which are in Mathlib: with |
| 11 | +`θ x = ∑_{p ≤ x} log p` (`Chebyshev.theta`), |
| 12 | + |
| 13 | +`θ (μ x) - θ x ≥ (μ - 2) * log 2 * x - log 2 - log (μ x + 2) - 2 * √(μ x) * log (μ x)` |
| 14 | + |
| 15 | +(`theta_sub_theta_ge`, from `Chebyshev.theta_ge'` and `Chebyshev.theta_le_log4_mul_x`), which is |
| 16 | +of order `x` for every fixed `μ > 2`. Display (5) (`Erdos530RowPrime.sum_lost_rows_mul_log_le`) |
| 17 | +then gives a prime `q ∈ (Q₁, Q₂]` losing `ℓ` rows with `ℓ * (θ Q₂ - θ Q₁) ≤ (k choose 2) * log D` |
| 18 | +(`exists_prime_lost_rows_mul_sum_log_le`), and inequality (3) at that prime is |
| 19 | +`exists_prime_sidon_subset_of_int_rows_theta`; `exists_prime_sidon_subset_of_int_rows_chebyshev` |
| 20 | +is the same with `Q₂ = μ Q₁` and the explicit lower bound in place of `θ Q₂ - θ Q₁`. |
| 21 | + |
| 22 | +Everything in this file is a finite inequality with no unproved input. Not in this file: the |
| 23 | +asymptotic evaluation (a paper computation in the note: for `k log D = o(√(kL))` and `k = o(L)` the |
| 24 | +window `(λ₀ √(kL), μ λ₀ √(kL)]` with `λ₀² = 7/8` and `μ ↓ 2` gives the coefficient |
| 25 | +`6 √14 / 49 · √σ`), the sharper coefficient `c₀ √(2σ)` of (4), which needs primes in |
| 26 | +`[Q, (1 + η) Q]` (the prime number theorem), and the integer model for real labels. |
| 27 | +-/ |
| 28 | + |
| 29 | +namespace ErdosSwarm.Erdos530RowChebyshev |
| 30 | + |
| 31 | +open Finset Chebyshev |
| 32 | + |
| 33 | +/-- `θ y - θ x` is the sum of `log q` over the primes `q` with `⌊x⌋ < q ≤ ⌊y⌋`. -/ |
| 34 | +theorem theta_sub_theta_eq_sum {x y : ℝ} (hxy : x ≤ y) : |
| 35 | + θ y - θ x = ∑ q ∈ (Ioc ⌊x⌋₊ ⌊y⌋₊).filter Nat.Prime, Real.log q := by |
| 36 | + have hfl : ⌊x⌋₊ ≤ ⌊y⌋₊ := Nat.floor_le_floor hxy |
| 37 | + unfold Chebyshev.theta |
| 38 | + rw [sum_filter, sum_filter, sum_filter, ← Finset.sum_Ioc_consecutive _ (Nat.zero_le _) hfl] |
| 39 | + ring |
| 40 | + |
| 41 | +/-- Chebyshev's bounds for the primes of `(x, μ x]`: |
| 42 | +`θ (μ x) - θ x ≥ (μ - 2) * log 2 * x - log 2 - log (μ x + 2) - 2 * √(μ x) * log (μ x)`. -/ |
| 43 | +theorem theta_sub_theta_ge {x μ : ℝ} (hx : 1 ≤ x) (hμ : 1 ≤ μ) : |
| 44 | + (μ - 2) * Real.log 2 * x - Real.log 2 - Real.log (μ * x + 2) - |
| 45 | + 2 * √(μ * x) * Real.log (μ * x) ≤ θ (μ * x) - θ x := by |
| 46 | + have h1 : 1 ≤ μ * x := by nlinarith |
| 47 | + have hge := theta_ge' h1 |
| 48 | + have hle := theta_le_log4_mul_x (x := x) (by linarith) |
| 49 | + have h4 : Real.log 4 = 2 * Real.log 2 := by |
| 50 | + rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow] |
| 51 | + norm_num |
| 52 | + rw [h4] at hle |
| 53 | + linarith |
| 54 | + |
| 55 | +/-- Display (5) with the weights summed: some prime of the nonempty set `Q` loses `ℓ` row labels |
| 56 | +with `ℓ * ∑_{q ∈ Q} log q ≤ (|X| choose 2) * log D`. -/ |
| 57 | +theorem exists_prime_lost_rows_mul_sum_log_le (X : Finset ℤ) (Q : Finset ℕ) |
| 58 | + (hQ : ∀ q ∈ Q, q.Prime) (hne : Q.Nonempty) (D : ℕ) |
| 59 | + (hD : ∀ x ∈ X, ∀ y ∈ X, y - x ≤ (D : ℤ)) : |
| 60 | + ∃ q ∈ Q, ((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * |
| 61 | + (∑ q' ∈ Q, Real.log q') ≤ (X.card.choose 2 : ℝ) * Real.log D := by |
| 62 | + classical |
| 63 | + have h := Erdos530RowPrime.sum_lost_rows_mul_log_le X Q hQ D hD |
| 64 | + obtain ⟨q, hq, hmin⟩ := exists_min_image Q |
| 65 | + (fun q : ℕ => (X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) hne |
| 66 | + refine ⟨q, hq, le_trans ?_ h⟩ |
| 67 | + rw [mul_sum] |
| 68 | + exact sum_le_sum fun q' hq' => |
| 69 | + mul_le_mul_of_nonneg_right (hmin q' hq') (Real.log_natCast_nonneg q') |
| 70 | + |
| 71 | +/-- **Inequality (3) at a prime of a window, weighted by Chebyshev's `θ`.** Let `B` have row |
| 72 | +coordinates `(x, j)` with integer labels of differences at most `D` and offsets below `L`, and let |
| 73 | +`1 ≤ Q₁` with `L ≤ Q₁ * (Q₁ - 1)` and `θ Q₁ < θ Q₂`. Then some prime `Q₁ < q ≤ Q₂` loses `ℓ` rows |
| 74 | +with `ℓ * (θ Q₂ - θ Q₁) ≤ (k choose 2) * log D`, and `B` has a Sidon subset `S` with |
| 75 | +`2 * q * (q - 1) * (N - ℓ * L) ≤ 2 * q ^ 2 * (q - 1) * |S| + N * (k - 1) * (L + q - 2)`. -/ |
| 76 | +theorem exists_prime_sidon_subset_of_int_rows_theta {α : Type*} [AddCommMonoid α] |
| 77 | + (B : Finset α) (x : α → ℤ) (j : α → ℕ) (L : ℕ) (Q₁ Q₂ : ℝ) (hQ₁ : 1 ≤ Q₁) |
| 78 | + (hL : (L : ℝ) ≤ Q₁ * (Q₁ - 1)) (hθ : θ Q₁ < θ Q₂) |
| 79 | + (D : ℕ) (hD : ∀ a ∈ B, ∀ b ∈ B, x b - x a ≤ (D : ℤ)) |
| 80 | + (hj : ∀ a ∈ B, j a < L) |
| 81 | + (hinj : ∀ a ∈ B, ∀ b ∈ B, x a = x b → j a = j b → a = b) |
| 82 | + (hsum : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → |
| 83 | + x a + x b = x c + x d ∧ j a + j b = j c + j d) : |
| 84 | + ∃ q : ℕ, q.Prime ∧ Q₁ < q ∧ (q : ℝ) ≤ Q₂ ∧ ∃ ℓ : ℕ, |
| 85 | + (ℓ : ℝ) * (θ Q₂ - θ Q₁) ≤ ((B.image x).card.choose 2 : ℝ) * Real.log D ∧ |
| 86 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ |
| 87 | + 2 * q * (q - 1) * (B.card - ℓ * L) ≤ |
| 88 | + 2 * q ^ 2 * (q - 1) * S.card + B.card * ((B.image x).card - 1) * (L + q - 2) := by |
| 89 | + classical |
| 90 | + have hle : Q₁ ≤ Q₂ := by |
| 91 | + by_contra hcon |
| 92 | + exact absurd (theta_mono (le_of_not_ge hcon)) (not_le.mpr hθ) |
| 93 | + have hsumQ : θ Q₂ - θ Q₁ = ∑ q ∈ (Ioc ⌊Q₁⌋₊ ⌊Q₂⌋₊).filter Nat.Prime, Real.log q := |
| 94 | + theta_sub_theta_eq_sum hle |
| 95 | + have hQp : ∀ q ∈ (Ioc ⌊Q₁⌋₊ ⌊Q₂⌋₊).filter Nat.Prime, q.Prime := fun q hq => (mem_filter.mp hq).2 |
| 96 | + have hne : ((Ioc ⌊Q₁⌋₊ ⌊Q₂⌋₊).filter Nat.Prime).Nonempty := by |
| 97 | + by_contra hemp |
| 98 | + rw [not_nonempty_iff_eq_empty] at hemp |
| 99 | + rw [hemp, sum_empty] at hsumQ |
| 100 | + linarith |
| 101 | + obtain ⟨q, hq, hlost⟩ := exists_prime_lost_rows_mul_sum_log_le (B.image x) _ hQp hne D (by |
| 102 | + intro m hm n hn |
| 103 | + obtain ⟨a, ha, rfl⟩ := mem_image.mp hm |
| 104 | + obtain ⟨b, hb, rfl⟩ := mem_image.mp hn |
| 105 | + exact hD a ha b hb) |
| 106 | + have hqm := mem_filter.mp hq |
| 107 | + have hq1 : Q₁ < q := (Nat.floor_lt (by linarith)).mp (mem_Ioc.mp hqm.1).1 |
| 108 | + have hq2 : (q : ℝ) ≤ Q₂ := (Nat.le_floor_iff (by linarith)).mp (mem_Ioc.mp hqm.1).2 |
| 109 | + have : Fact q.Prime := ⟨hqm.2⟩ |
| 110 | + have hLq : L ≤ q * (q - 1) := by |
| 111 | + have hqpos : 1 ≤ q := hqm.2.one_lt.le |
| 112 | + have h1 : (L : ℝ) ≤ (q : ℝ) * ((q : ℝ) - 1) := by nlinarith |
| 113 | + have h2 : ((q * (q - 1) : ℕ) : ℝ) = (q : ℝ) * ((q : ℝ) - 1) := by |
| 114 | + rw [Nat.cast_mul, Nat.cast_sub hqpos, Nat.cast_one] |
| 115 | + rw [← h2] at h1 |
| 116 | + exact_mod_cast h1 |
| 117 | + refine ⟨q, hqm.2, hq1, hq2, |
| 118 | + (B.image x).card - ((B.image x).image fun n : ℤ => n % (q : ℤ)).card, ?_, |
| 119 | + Erdos530RowPrime.exists_sidon_subset_of_int_rows_mod B x j L hLq hj hinj hsum⟩ |
| 120 | + rw [hsumQ, Nat.cast_sub card_image_le] |
| 121 | + exact hlost |
| 122 | + |
| 123 | +/-- **Rows without the prime number theorem (finite form).** For `1 ≤ Q₁`, `1 ≤ μ`, |
| 124 | +`L ≤ Q₁ * (Q₁ - 1)` and |
| 125 | +`E = (μ - 2) * log 2 * Q₁ - log 2 - log (μ Q₁ + 2) - 2 * √(μ Q₁) * log (μ Q₁) > 0`, some prime |
| 126 | +`Q₁ < q ≤ μ Q₁` loses `ℓ` rows with `ℓ * E ≤ (k choose 2) * log D`, and `B` has a Sidon subset `S` |
| 127 | +with `2 * q * (q - 1) * (N - ℓ * L) ≤ 2 * q ^ 2 * (q - 1) * |S| + N * (k - 1) * (L + q - 2)`. -/ |
| 128 | +theorem exists_prime_sidon_subset_of_int_rows_chebyshev {α : Type*} [AddCommMonoid α] |
| 129 | + (B : Finset α) (x : α → ℤ) (j : α → ℕ) (L : ℕ) (Q₁ μ : ℝ) (hQ₁ : 1 ≤ Q₁) (hμ : 1 ≤ μ) |
| 130 | + (hL : (L : ℝ) ≤ Q₁ * (Q₁ - 1)) |
| 131 | + (hE : 0 < (μ - 2) * Real.log 2 * Q₁ - Real.log 2 - Real.log (μ * Q₁ + 2) - |
| 132 | + 2 * √(μ * Q₁) * Real.log (μ * Q₁)) |
| 133 | + (D : ℕ) (hD : ∀ a ∈ B, ∀ b ∈ B, x b - x a ≤ (D : ℤ)) |
| 134 | + (hj : ∀ a ∈ B, j a < L) |
| 135 | + (hinj : ∀ a ∈ B, ∀ b ∈ B, x a = x b → j a = j b → a = b) |
| 136 | + (hsum : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → |
| 137 | + x a + x b = x c + x d ∧ j a + j b = j c + j d) : |
| 138 | + ∃ q : ℕ, q.Prime ∧ Q₁ < q ∧ (q : ℝ) ≤ μ * Q₁ ∧ ∃ ℓ : ℕ, |
| 139 | + (ℓ : ℝ) * ((μ - 2) * Real.log 2 * Q₁ - Real.log 2 - Real.log (μ * Q₁ + 2) - |
| 140 | + 2 * √(μ * Q₁) * Real.log (μ * Q₁)) ≤ ((B.image x).card.choose 2 : ℝ) * Real.log D ∧ |
| 141 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ |
| 142 | + 2 * q * (q - 1) * (B.card - ℓ * L) ≤ |
| 143 | + 2 * q ^ 2 * (q - 1) * S.card + B.card * ((B.image x).card - 1) * (L + q - 2) := by |
| 144 | + have hge := theta_sub_theta_ge hQ₁ hμ |
| 145 | + obtain ⟨q, hqp, hq1, hq2, ℓ, hℓ, hS⟩ := |
| 146 | + exists_prime_sidon_subset_of_int_rows_theta B x j L Q₁ (μ * Q₁) hQ₁ hL (by linarith) D hD hj |
| 147 | + hinj hsum |
| 148 | + exact ⟨q, hqp, hq1, hq2, ℓ, |
| 149 | + (mul_le_mul_of_nonneg_left hge (Nat.cast_nonneg ℓ)).trans hℓ, hS⟩ |
| 150 | + |
| 151 | +/-- A numerical instance of the window weight: for the primes of `(10^6, 3 * 10^6]` the explicit |
| 152 | +lower bound of `theta_sub_theta_ge` is at least `600000`. -/ |
| 153 | +theorem window_weight_example : (600000 : ℝ) ≤ |
| 154 | + ((3 : ℝ) - 2) * Real.log 2 * 10 ^ 6 - Real.log 2 - Real.log (3 * 10 ^ 6 + 2) - |
| 155 | + 2 * √(3 * 10 ^ 6) * Real.log (3 * 10 ^ 6) := by |
| 156 | + have l1 := Real.log_two_gt_d9 |
| 157 | + have l2 := Real.log_two_lt_d9 |
| 158 | + have h22 : Real.log ((2 : ℝ) ^ 22) = 22 * Real.log 2 := by |
| 159 | + rw [Real.log_pow] |
| 160 | + norm_num |
| 161 | + have ha : Real.log ((3 : ℝ) * 10 ^ 6 + 2) ≤ 22 * Real.log 2 := by |
| 162 | + rw [← h22] |
| 163 | + exact Real.log_le_log (by norm_num) (by norm_num) |
| 164 | + have hb : Real.log ((3 : ℝ) * 10 ^ 6) ≤ 22 * Real.log 2 := by |
| 165 | + rw [← h22] |
| 166 | + exact Real.log_le_log (by norm_num) (by norm_num) |
| 167 | + have hb0 : 0 ≤ Real.log ((3 : ℝ) * 10 ^ 6) := Real.log_nonneg (by norm_num) |
| 168 | + have hs : √((3 : ℝ) * 10 ^ 6) ≤ 1733 := by |
| 169 | + rw [Real.sqrt_le_left (by norm_num)] |
| 170 | + norm_num |
| 171 | + have hs0 : 0 ≤ √((3 : ℝ) * 10 ^ 6) := Real.sqrt_nonneg _ |
| 172 | + have hprod := mul_le_mul hs hb hb0 (by norm_num : (0 : ℝ) ≤ 1733) |
| 173 | + nlinarith |
| 174 | + |
| 175 | +/-- An unconditional instance in which no row is lost: every set with row coordinates, at most |
| 176 | +`100` integer row labels of differences at most `10^9` and offsets below `L ≤ 10^11` satisfies |
| 177 | +inequality (3) at some prime `10^6 < q ≤ 3 * 10^6`. -/ |
| 178 | +theorem exists_prime_sidon_subset_of_hundred_int_rows {α : Type*} [AddCommMonoid α] |
| 179 | + (B : Finset α) (x : α → ℤ) (j : α → ℕ) (L : ℕ) (hL : L ≤ 10 ^ 11) |
| 180 | + (hk : (B.image x).card ≤ 100) |
| 181 | + (hD : ∀ a ∈ B, ∀ b ∈ B, x b - x a ≤ ((10 ^ 9 : ℕ) : ℤ)) |
| 182 | + (hj : ∀ a ∈ B, j a < L) |
| 183 | + (hinj : ∀ a ∈ B, ∀ b ∈ B, x a = x b → j a = j b → a = b) |
| 184 | + (hsum : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → |
| 185 | + x a + x b = x c + x d ∧ j a + j b = j c + j d) : |
| 186 | + ∃ q : ℕ, q.Prime ∧ 10 ^ 6 < q ∧ q ≤ 3 * 10 ^ 6 ∧ ∃ S ⊆ B, IsSidon (S : Set α) ∧ |
| 187 | + 2 * q * (q - 1) * B.card ≤ |
| 188 | + 2 * q ^ 2 * (q - 1) * S.card + B.card * ((B.image x).card - 1) * (L + q - 2) := by |
| 189 | + have hE := window_weight_example |
| 190 | + have hLr : (L : ℝ) ≤ (10 : ℝ) ^ 6 * ((10 : ℝ) ^ 6 - 1) := by |
| 191 | + have : (L : ℝ) ≤ 10 ^ 11 := by exact_mod_cast hL |
| 192 | + norm_num at this ⊢ |
| 193 | + linarith |
| 194 | + obtain ⟨q, hqp, hq1, hq2, ℓ, hℓ, S, hSB, hS, hineq⟩ := |
| 195 | + exists_prime_sidon_subset_of_int_rows_chebyshev B x j L (10 ^ 6) 3 (by norm_num) (by norm_num) |
| 196 | + hLr (by linarith) (10 ^ 9) hD hj hinj hsum |
| 197 | + have hchoose : ((B.image x).card.choose 2 : ℝ) ≤ 4950 := by |
| 198 | + have := Nat.choose_le_choose 2 hk |
| 199 | + have h100 : Nat.choose 100 2 = 4950 := by decide |
| 200 | + rw [h100] at this |
| 201 | + exact_mod_cast this |
| 202 | + have hlogD : Real.log ((10 ^ 9 : ℕ) : ℝ) ≤ 30 * Real.log 2 := by |
| 203 | + have h30 : Real.log ((2 : ℝ) ^ 30) = 30 * Real.log 2 := by |
| 204 | + rw [Real.log_pow] |
| 205 | + norm_num |
| 206 | + rw [← h30] |
| 207 | + exact Real.log_le_log (by norm_num) (by norm_num) |
| 208 | + have hlogD0 : 0 ≤ Real.log ((10 ^ 9 : ℕ) : ℝ) := Real.log_natCast_nonneg _ |
| 209 | + have l2 := Real.log_two_lt_d9 |
| 210 | + have hℓ0 : ℓ = 0 := by |
| 211 | + by_contra hne |
| 212 | + have h1 : (1 : ℝ) ≤ ℓ := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hne |
| 213 | + have hprod := mul_le_mul hchoose hlogD hlogD0 (by norm_num : (0 : ℝ) ≤ 4950) |
| 214 | + nlinarith |
| 215 | + subst hℓ0 |
| 216 | + refine ⟨q, hqp, by exact_mod_cast hq1, by exact_mod_cast hq2, S, hSB, hS, ?_⟩ |
| 217 | + simpa using hineq |
| 218 | + |
| 219 | +end ErdosSwarm.Erdos530RowChebyshev |