| | @@ -0,0 +1,293 @@ |
| 1 | +import ErdosSwarm.Erdos530RowProjection |
| 2 | +import Mathlib.Analysis.SpecialFunctions.Log.Basic |
| 3 | +import Mathlib.Data.Nat.Choose.Cast |
| 4 | + |
| 5 | +/-! |
| 6 | +# Choosing the prime for rows in Erdős problem 530: display (5) |
| 7 | + |
| 8 | +Lean version of display (5) in "Finding the prime", Theorem 2 of |
| 9 | +`experiments/erdos530/lower-middle-energy/NOTES.md`, §2. For a finite set `X` of integer row |
| 10 | +labels and a finite set `Q` of primes, reducing `X` modulo `q` loses at most the number of |
| 11 | +unordered pairs of labels congruent modulo `q`, and the primes of `Q` dividing a positive |
| 12 | +difference `y - x` have product at most `y - x`. Hence |
| 13 | + |
| 14 | +`∑ q ∈ Q, (|X| - |X mod q|) * log q ≤ ∑_{x < y} log (y - x) ≤ (|X| choose 2) * log D` |
| 15 | + |
| 16 | +when all differences are at most `D`, and some `q ∈ Q` loses at most |
| 17 | +`(|X| choose 2) * log D / (|Q| * log Q₀)` rows if every prime of `Q` is at least `Q₀` |
| 18 | +(`exists_prime_lost_rows_le`). Keeping one row per residue class modulo that prime |
| 19 | +(`exists_sidon_subset_of_int_rows_mod`; `exists_sidon_subset_of_int_rows_zmod` counts the classes |
| 20 | +in `ZMod p`) and applying inequality (3) |
| 21 | +(`Erdos530RowProjection.exists_sidon_subset_of_int_rows`) gives |
| 22 | +`exists_prime_sidon_subset_of_int_rows`, a finite form of (4). |
| 23 | + |
| 24 | +Display (5) only counts the prime divisors of the label differences. The prime number theorem |
| 25 | +enters the note in the next step and is not in this file: the number of primes in `[Q, (1 + η) Q]`, |
| 26 | +which the note uses to conclude that some prime `q ∼ √(3kL/2)` loses `o(k)` rows, and hence the |
| 27 | +asymptotic (4). Inequality (2) with the gcd count and the integer model for real labels are not in |
| 28 | +this file either. |
| 29 | +-/ |
| 30 | + |
| 31 | +namespace ErdosSwarm.Erdos530RowPrime |
| 32 | + |
| 33 | +open Finset |
| 34 | + |
| 35 | +/-- Display (5), counted over ordered pairs: twice the weighted number of rows lost modulo the |
| 36 | +primes of `Q` is at most the sum of `log |y - x|` over ordered pairs of distinct labels. -/ |
| 37 | +theorem two_mul_sum_lost_rows_mul_log_le (X : Finset ℤ) (Q : Finset ℕ) (hQ : ∀ q ∈ Q, q.Prime) : |
| 38 | + 2 * ∑ q ∈ Q, ((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * Real.log q ≤ |
| 39 | + ∑ z ∈ X.offDiag, Real.log ((z.2 - z.1).natAbs : ℝ) := by |
| 40 | + classical |
| 41 | + have h1 : ∀ q ∈ Q, |
| 42 | + 2 * (((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * Real.log q) ≤ |
| 43 | + ∑ z ∈ X.offDiag, if (q : ℤ) ∣ z.2 - z.1 then Real.log q else 0 := by |
| 44 | + intro q _ |
| 45 | + have hlog : 0 ≤ Real.log q := Real.log_natCast_nonneg q |
| 46 | + have hc := Erdos530RowProjection.two_mul_card_le_image_add_collisions X |
| 47 | + (fun x : ℤ => x % (q : ℤ)) |
| 48 | + have hsub : (X.offDiag.filter fun z => z.1 % (q : ℤ) = z.2 % (q : ℤ)) ⊆ |
| 49 | + X.offDiag.filter fun z => (q : ℤ) ∣ z.2 - z.1 := by |
| 50 | + intro z hz |
| 51 | + rw [mem_filter] at hz ⊢ |
| 52 | + exact ⟨hz.1, Int.dvd_of_emod_eq_zero (Int.emod_eq_emod_iff_emod_sub_eq_zero.mp hz.2.symm)⟩ |
| 53 | + have hc' := hc.trans (Nat.add_le_add_left (card_le_card hsub) _) |
| 54 | + have hcR : (2 : ℝ) * X.card ≤ 2 * ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ) + |
| 55 | + ((X.offDiag.filter fun z => (q : ℤ) ∣ z.2 - z.1).card : ℝ) := by exact_mod_cast hc' |
| 56 | + rw [← sum_filter, sum_const, nsmul_eq_mul] |
| 57 | + nlinarith |
| 58 | + calc 2 * ∑ q ∈ Q, ((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * Real.log q |
| 59 | + = ∑ q ∈ Q, |
| 60 | + 2 * (((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * Real.log q) := by |
| 61 | + rw [mul_sum] |
| 62 | + _ ≤ ∑ q ∈ Q, ∑ z ∈ X.offDiag, if (q : ℤ) ∣ z.2 - z.1 then Real.log q else 0 := |
| 63 | + sum_le_sum h1 |
| 64 | + _ = ∑ z ∈ X.offDiag, ∑ q ∈ Q, if (q : ℤ) ∣ z.2 - z.1 then Real.log q else 0 := sum_comm |
| 65 | + _ ≤ ∑ z ∈ X.offDiag, Real.log ((z.2 - z.1).natAbs : ℝ) := by |
| 66 | + refine sum_le_sum fun z hz => ?_ |
| 67 | + have hne : z.2 - z.1 ≠ 0 := sub_ne_zero.mpr (mem_offDiag.mp hz).2.2.symm |
| 68 | + have hn : 0 < (z.2 - z.1).natAbs := Int.natAbs_pos.mpr hne |
| 69 | + rw [← sum_filter] |
| 70 | + have hdvd : ∏ q ∈ Q.filter (fun q : ℕ => (q : ℤ) ∣ z.2 - z.1), q ∣ (z.2 - z.1).natAbs := |
| 71 | + Finset.prod_primes_dvd _ (fun q hq => (hQ q (mem_filter.mp hq).1).prime) |
| 72 | + (fun q hq => Int.natCast_dvd.mp (mem_filter.mp hq).2) |
| 73 | + have hle := Nat.le_of_dvd hn hdvd |
| 74 | + have hpos : ∀ q ∈ Q.filter (fun q : ℕ => (q : ℤ) ∣ z.2 - z.1), (q : ℝ) ≠ 0 := by |
| 75 | + intro q hq |
| 76 | + exact_mod_cast (hQ q (mem_filter.mp hq).1).ne_zero |
| 77 | + rw [← Real.log_prod hpos] |
| 78 | + have hprodpos : (0 : ℝ) < ∏ q ∈ Q.filter (fun q : ℕ => (q : ℤ) ∣ z.2 - z.1), (q : ℝ) := |
| 79 | + prod_pos fun q hq => by exact_mod_cast (hQ q (mem_filter.mp hq).1).pos |
| 80 | + refine Real.log_le_log hprodpos ?_ |
| 81 | + rw [← Nat.cast_prod] |
| 82 | + exact_mod_cast hle |
| 83 | + |
| 84 | +/-- **Display (5).** If all differences of the integer labels `X` are at most `D`, then |
| 85 | +`∑ q ∈ Q, (|X| - |X mod q|) * log q ≤ (|X| choose 2) * log D` for every finite set `Q` of |
| 86 | +primes. -/ |
| 87 | +theorem sum_lost_rows_mul_log_le (X : Finset ℤ) (Q : Finset ℕ) (hQ : ∀ q ∈ Q, q.Prime) (D : ℕ) |
| 88 | + (hD : ∀ x ∈ X, ∀ y ∈ X, y - x ≤ (D : ℤ)) : |
| 89 | + ∑ q ∈ Q, ((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * Real.log q ≤ |
| 90 | + (X.card.choose 2 : ℝ) * Real.log D := by |
| 91 | + have h := two_mul_sum_lost_rows_mul_log_le X Q hQ |
| 92 | + have hbound : ∑ z ∈ X.offDiag, Real.log ((z.2 - z.1).natAbs : ℝ) ≤ |
| 93 | + ∑ _z ∈ X.offDiag, Real.log D := by |
| 94 | + refine sum_le_sum fun z hz => ?_ |
| 95 | + obtain ⟨h1, h2, hne⟩ := mem_offDiag.mp hz |
| 96 | + have hn : 0 < (z.2 - z.1).natAbs := Int.natAbs_pos.mpr (sub_ne_zero.mpr hne.symm) |
| 97 | + have hle : (z.2 - z.1).natAbs ≤ D := by |
| 98 | + have a1 := hD _ h1 _ h2 |
| 99 | + have a2 := hD _ h2 _ h1 |
| 100 | + omega |
| 101 | + exact Real.log_le_log (by exact_mod_cast hn) (by exact_mod_cast hle) |
| 102 | + rw [sum_const, offDiag_card, nsmul_eq_mul] at hbound |
| 103 | + have hcast : ((X.card * X.card - X.card : ℕ) : ℝ) = 2 * (X.card.choose 2 : ℝ) := by |
| 104 | + rw [Nat.cast_choose_two, Nat.cast_sub (Nat.le_mul_self _)] |
| 105 | + push_cast |
| 106 | + ring |
| 107 | + rw [hcast] at hbound |
| 108 | + linarith |
| 109 | + |
| 110 | +/-- Some prime of `Q` loses few rows: if every prime of the nonempty set `Q` is at least `Q₀` and |
| 111 | +all differences of the labels are at most `D`, then for some `q ∈ Q` |
| 112 | +`(|X| - |X mod q|) * (|Q| * log Q₀) ≤ (|X| choose 2) * log D`. -/ |
| 113 | +theorem exists_prime_lost_rows_le (X : Finset ℤ) (Q : Finset ℕ) (hQ : ∀ q ∈ Q, q.Prime) |
| 114 | + (hne : Q.Nonempty) (Q₀ : ℕ) (hQ₀ : ∀ q ∈ Q, Q₀ ≤ q) (D : ℕ) |
| 115 | + (hD : ∀ x ∈ X, ∀ y ∈ X, y - x ≤ (D : ℤ)) : |
| 116 | + ∃ q ∈ Q, ((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * |
| 117 | + (Q.card * Real.log Q₀) ≤ (X.card.choose 2 : ℝ) * Real.log D := by |
| 118 | + classical |
| 119 | + have h := sum_lost_rows_mul_log_le X Q hQ D hD |
| 120 | + obtain ⟨q, hq, hmin⟩ := exists_min_image Q |
| 121 | + (fun q : ℕ => (X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) hne |
| 122 | + refine ⟨q, hq, le_trans ?_ h⟩ |
| 123 | + have hlost : ∀ q' ∈ Q, 0 ≤ (X.card : ℝ) - ((X.image fun x : ℤ => x % (q' : ℤ)).card : ℝ) := by |
| 124 | + intro q' _ |
| 125 | + have : (X.image fun x : ℤ => x % (q' : ℤ)).card ≤ X.card := card_image_le |
| 126 | + have : ((X.image fun x : ℤ => x % (q' : ℤ)).card : ℝ) ≤ X.card := by exact_mod_cast this |
| 127 | + linarith |
| 128 | + calc ((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * (Q.card * Real.log Q₀) |
| 129 | + = ∑ _q' ∈ Q, ((X.card : ℝ) - ((X.image fun x : ℤ => x % (q : ℤ)).card : ℝ)) * |
| 130 | + Real.log Q₀ := by |
| 131 | + rw [sum_const, nsmul_eq_mul] |
| 132 | + ring |
| 133 | + _ ≤ ∑ q' ∈ Q, ((X.card : ℝ) - ((X.image fun x : ℤ => x % (q' : ℤ)).card : ℝ)) * |
| 134 | + Real.log q' := by |
| 135 | + refine sum_le_sum fun q' hq' => ?_ |
| 136 | + have hlogle : Real.log Q₀ ≤ Real.log q' := by |
| 137 | + rcases Nat.eq_zero_or_pos Q₀ with h0 | h0 |
| 138 | + · rw [h0] |
| 139 | + simpa using Real.log_natCast_nonneg q' |
| 140 | + · exact Real.log_le_log (by exact_mod_cast h0) (by exact_mod_cast hQ₀ q' hq') |
| 141 | + exact mul_le_mul (hmin q' hq') hlogle (Real.log_natCast_nonneg Q₀) (hlost q' hq') |
| 142 | + |
| 143 | +/-- Inequality (3) of Theorem 2 at a prime that does not separate all the row labels: keep one |
| 144 | +row in each residue class modulo `p`. With `k` rows, `k'` residue classes and offsets below |
| 145 | +`L ≤ p * (p - 1)`, at most `(k - k') * L` points are discarded, and |
| 146 | +`Erdos530RowProjection.exists_sidon_subset_of_int_rows` applies to the rest. -/ |
| 147 | +theorem exists_sidon_subset_of_int_rows_mod {p : ℕ} [Fact p.Prime] {α : Type*} [AddCommMonoid α] |
| 148 | + (B : Finset α) (x : α → ℤ) (j : α → ℕ) (L : ℕ) (hL : L ≤ p * (p - 1)) |
| 149 | + (hj : ∀ a ∈ B, j a < L) |
| 150 | + (hinj : ∀ a ∈ B, ∀ b ∈ B, x a = x b → j a = j b → a = b) |
| 151 | + (hsum : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → |
| 152 | + x a + x b = x c + x d ∧ j a + j b = j c + j d) : |
| 153 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ |
| 154 | + 2 * p * (p - 1) * (B.card - |
| 155 | + ((B.image x).card - ((B.image x).image fun n : ℤ => n % (p : ℤ)).card) * L) ≤ |
| 156 | + 2 * p ^ 2 * (p - 1) * S.card + B.card * ((B.image x).card - 1) * (L + p - 2) := by |
| 157 | + classical |
| 158 | + -- one label in each residue class |
| 159 | + obtain ⟨X', hX'X', hX'inj, hX'img⟩ := |
| 160 | + Finset.exists_subset_injOn_image_eq_of_surjOn (f := fun n : ℤ => n % (p : ℤ)) |
| 161 | + ((B.image x : Finset ℤ) : Set ℤ) ((B.image x).image fun n : ℤ => n % (p : ℤ)) (by |
| 162 | + intro r hr |
| 163 | + obtain ⟨n, hn, rfl⟩ := mem_image.mp (mem_coe.mp hr) |
| 164 | + exact ⟨n, mem_coe.mpr hn, rfl⟩) |
| 165 | + have hX'X : X' ⊆ B.image x := coe_subset.mp hX'X' |
| 166 | + have hX'card : X'.card = ((B.image x).image fun n : ℤ => n % (p : ℤ)).card := by |
| 167 | + rw [← hX'img, card_image_of_injOn hX'inj] |
| 168 | + have hB'sub : B.filter (fun a => x a ∈ X') ⊆ B := filter_subset _ _ |
| 169 | + have hB'img : (B.filter fun a => x a ∈ X').image x = X' := by |
| 170 | + ext n |
| 171 | + constructor |
| 172 | + · intro hn |
| 173 | + obtain ⟨a, ha, rfl⟩ := mem_image.mp hn |
| 174 | + exact (mem_filter.mp ha).2 |
| 175 | + · intro hn |
| 176 | + obtain ⟨a, ha, rfl⟩ := mem_image.mp (hX'X hn) |
| 177 | + exact mem_image_of_mem x (mem_filter.mpr ⟨ha, hn⟩) |
| 178 | + -- the discarded points |
| 179 | + have hlost : (B.filter fun a => ¬ x a ∈ X').card ≤ L * ((B.image x).card - X'.card) := by |
| 180 | + have h1 := card_le_mul_card_image (f := x) (B.filter fun a => ¬ x a ∈ X') L (by |
| 181 | + intro n _ |
| 182 | + have hle : ((B.filter fun a => ¬ x a ∈ X').filter fun a => x a = n).card ≤ |
| 183 | + (range L).card := by |
| 184 | + refine card_le_card_of_injOn j ?_ ?_ |
| 185 | + · intro a ha |
| 186 | + have ha' := (mem_filter.mp (mem_filter.mp (mem_coe.mp ha)).1).1 |
| 187 | + exact mem_coe.mpr (mem_range.mpr (hj a ha')) |
| 188 | + · intro a ha b hb hab |
| 189 | + have ha' := mem_filter.mp (mem_coe.mp ha) |
| 190 | + have hb' := mem_filter.mp (mem_coe.mp hb) |
| 191 | + exact hinj a (mem_filter.mp ha'.1).1 b (mem_filter.mp hb'.1).1 |
| 192 | + (ha'.2.trans hb'.2.symm) hab |
| 193 | + rwa [card_range] at hle) |
| 194 | + have h2 : ((B.filter fun a => ¬ x a ∈ X').image x) ⊆ B.image x \ X' := by |
| 195 | + intro n hn |
| 196 | + obtain ⟨a, ha, rfl⟩ := mem_image.mp hn |
| 197 | + obtain ⟨haB, hax⟩ := mem_filter.mp ha |
| 198 | + exact mem_sdiff.mpr ⟨mem_image_of_mem x haB, hax⟩ |
| 199 | + have h3 := card_sdiff_add_card_eq_card hX'X |
| 200 | + have h4 := card_le_card h2 |
| 201 | + exact h1.trans (Nat.mul_le_mul_left L (by omega)) |
| 202 | + have hsplit := card_filter_add_card_filter_not (s := B) (fun a => x a ∈ X') |
| 203 | + -- inequality (3) on the kept rows |
| 204 | + obtain ⟨S, hSB, hS, hcard⟩ := Erdos530RowProjection.exists_sidon_subset_of_int_rows |
| 205 | + (B.filter fun a => x a ∈ X') x j L hL (fun a ha => hj a (hB'sub ha)) |
| 206 | + (fun a ha b hb hab => hX'inj (mem_coe.mpr (mem_filter.mp ha).2) (mem_coe.mpr (mem_filter.mp hb).2) |
| 207 | + ((ZMod.intCast_eq_intCast_iff' _ _ _).mp hab)) |
| 208 | + (fun a ha b hb => hinj a (hB'sub ha) b (hB'sub hb)) |
| 209 | + (fun a ha b hb c hc d hd => hsum a (hB'sub ha) b (hB'sub hb) c (hB'sub hc) d (hB'sub hd)) |
| 210 | + refine ⟨S, hSB.trans hB'sub, hS, ?_⟩ |
| 211 | + rw [hB'img] at hcard |
| 212 | + rw [← hX'card] |
| 213 | + have hkk : X'.card ≤ (B.image x).card := card_le_card hX'X |
| 214 | + have hNN : (B.filter fun a => x a ∈ X').card ≤ B.card := card_le_card hB'sub |
| 215 | + have hkeep : B.card - ((B.image x).card - X'.card) * L ≤ (B.filter fun a => x a ∈ X').card := by |
| 216 | + rw [mul_comm] |
| 217 | + omega |
| 218 | + calc 2 * p * (p - 1) * (B.card - ((B.image x).card - X'.card) * L) |
| 219 | + ≤ 2 * p * (p - 1) * (B.filter fun a => x a ∈ X').card := Nat.mul_le_mul_left _ hkeep |
| 220 | + _ ≤ 2 * p ^ 2 * (p - 1) * S.card + |
| 221 | + (B.filter fun a => x a ∈ X').card * (X'.card - 1) * (L + p - 2) := hcard |
| 222 | + _ ≤ 2 * p ^ 2 * (p - 1) * S.card + B.card * ((B.image x).card - 1) * (L + p - 2) := |
| 223 | + Nat.add_le_add_left |
| 224 | + (Nat.mul_le_mul_right _ (Nat.mul_le_mul hNN (Nat.sub_le_sub_right hkk 1))) _ |
| 225 | + |
| 226 | +/-- The number of residue classes modulo `p` of a finite set of integers is the same counted by |
| 227 | +remainders in `ℤ` or by images in `ZMod p`. -/ |
| 228 | +theorem card_image_emod_eq_card_image_intCast (X : Finset ℤ) (p : ℕ) : |
| 229 | + (X.image fun n : ℤ => n % (p : ℤ)).card = (X.image fun n : ℤ => (n : ZMod p)).card := by |
| 230 | + have himage : (X.image fun n : ℤ => (n : ZMod p)) = |
| 231 | + (X.image fun n : ℤ => n % (p : ℤ)).image fun n : ℤ => (n : ZMod p) := by |
| 232 | + rw [image_image] |
| 233 | + refine image_congr fun n _ => ?_ |
| 234 | + exact (ZMod.intCast_mod n p).symm |
| 235 | + rw [himage] |
| 236 | + refine (card_image_of_injOn ?_).symm |
| 237 | + intro r hr s hs hrs |
| 238 | + obtain ⟨m, -, rfl⟩ := mem_image.mp (mem_coe.mp hr) |
| 239 | + obtain ⟨n, -, rfl⟩ := mem_image.mp (mem_coe.mp hs) |
| 240 | + have h := (ZMod.intCast_eq_intCast_iff' _ _ _).mp hrs |
| 241 | + simpa only [Int.emod_emod] using h |
| 242 | + |
| 243 | +/-- `exists_sidon_subset_of_int_rows_mod` with the number `k'` of residue classes of the labels |
| 244 | +counted in `ZMod p`: `k' = (B.image fun a => (x a : ZMod p)).card`. -/ |
| 245 | +theorem exists_sidon_subset_of_int_rows_zmod {p : ℕ} [Fact p.Prime] {α : Type*} |
| 246 | + [AddCommMonoid α] |
| 247 | + (B : Finset α) (x : α → ℤ) (j : α → ℕ) (L : ℕ) (hL : L ≤ p * (p - 1)) |
| 248 | + (hj : ∀ a ∈ B, j a < L) |
| 249 | + (hinj : ∀ a ∈ B, ∀ b ∈ B, x a = x b → j a = j b → a = b) |
| 250 | + (hsum : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → |
| 251 | + x a + x b = x c + x d ∧ j a + j b = j c + j d) : |
| 252 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ |
| 253 | + 2 * p * (p - 1) * (B.card - |
| 254 | + ((B.image x).card - (B.image fun a => (x a : ZMod p)).card) * L) ≤ |
| 255 | + 2 * p ^ 2 * (p - 1) * S.card + B.card * ((B.image x).card - 1) * (L + p - 2) := by |
| 256 | + classical |
| 257 | + have h := exists_sidon_subset_of_int_rows_mod B x j L hL hj hinj hsum |
| 258 | + have hk : (B.image fun a => (x a : ZMod p)).card = |
| 259 | + ((B.image x).image fun n : ℤ => n % (p : ℤ)).card := by |
| 260 | + rw [card_image_emod_eq_card_image_intCast, image_image] |
| 261 | + rfl |
| 262 | + rwa [hk] |
| 263 | + |
| 264 | +/-- **A finite form of (4)**, with the prime count as the only missing input. Let `B` have row |
| 265 | +coordinates `(x, j)` with integer labels of differences at most `D` and offsets below `L`, and |
| 266 | +let `Q` be a nonempty finite set of primes `q ≥ Q₀` with `L ≤ q * (q - 1)`. Then some `q ∈ Q` |
| 267 | +loses `ℓ` rows with `ℓ * (|Q| * log Q₀) ≤ (k choose 2) * log D`, and `B` has a Sidon subset `S` |
| 268 | +with `2 * q * (q - 1) * (N - ℓ * L) ≤ 2 * q ^ 2 * (q - 1) * |S| + N * (k - 1) * (L + q - 2)`. -/ |
| 269 | +theorem exists_prime_sidon_subset_of_int_rows {α : Type*} [AddCommMonoid α] |
| 270 | + (B : Finset α) (x : α → ℤ) (j : α → ℕ) (L : ℕ) |
| 271 | + (Q : Finset ℕ) (hQ : ∀ q ∈ Q, q.Prime) (hne : Q.Nonempty) (Q₀ : ℕ) (hQ₀ : ∀ q ∈ Q, Q₀ ≤ q) |
| 272 | + (hLQ : ∀ q ∈ Q, L ≤ q * (q - 1)) (D : ℕ) (hD : ∀ a ∈ B, ∀ b ∈ B, x b - x a ≤ (D : ℤ)) |
| 273 | + (hj : ∀ a ∈ B, j a < L) |
| 274 | + (hinj : ∀ a ∈ B, ∀ b ∈ B, x a = x b → j a = j b → a = b) |
| 275 | + (hsum : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → |
| 276 | + x a + x b = x c + x d ∧ j a + j b = j c + j d) : |
| 277 | + ∃ q ∈ Q, ∃ ℓ : ℕ, |
| 278 | + (ℓ : ℝ) * (Q.card * Real.log Q₀) ≤ ((B.image x).card.choose 2 : ℝ) * Real.log D ∧ |
| 279 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ |
| 280 | + 2 * q * (q - 1) * (B.card - ℓ * L) ≤ |
| 281 | + 2 * q ^ 2 * (q - 1) * S.card + B.card * ((B.image x).card - 1) * (L + q - 2) := by |
| 282 | + classical |
| 283 | + obtain ⟨q, hq, hlost⟩ := exists_prime_lost_rows_le (B.image x) Q hQ hne Q₀ hQ₀ D (by |
| 284 | + intro m hm n hn |
| 285 | + obtain ⟨a, ha, rfl⟩ := mem_image.mp hm |
| 286 | + obtain ⟨b, hb, rfl⟩ := mem_image.mp hn |
| 287 | + exact hD a ha b hb) |
| 288 | + have : Fact q.Prime := ⟨hQ q hq⟩ |
| 289 | + refine ⟨q, hq, (B.image x).card - ((B.image x).image fun n : ℤ => n % (q : ℤ)).card, ?_, |
| 290 | + exists_sidon_subset_of_int_rows_mod B x j L (hLQ q hq) hj hinj hsum⟩ |
| 291 | + rwa [Nat.cast_sub card_image_le] |
| 292 | + |
| 293 | +end ErdosSwarm.Erdos530RowPrime |