| | @@ -0,0 +1,60 @@ |
| 1 | +import ErdosSwarm.Erdos30Lower |
| 2 | + |
| 3 | +/-! |
| 4 | +# Spaced finite Sidon sets for Erdős problem 329 |
| 5 | + |
| 6 | +Each positive difference in a Sidon set occurs at most once. Deleting the lower |
| 7 | +endpoints of pairs at distance less than `t` gives the spacing required by |
| 8 | +`sidon_union`. For prime `p`, the Ruzsa bound supplies at least `p - 1` points |
| 9 | +in `[1, (p - 1)²]` before deletion. |
| 10 | +-/ |
| 11 | + |
| 12 | +namespace ErdosSwarm.Erdos329 |
| 13 | + |
| 14 | +open Finset |
| 15 | + |
| 16 | +/-- Deleting at most `t - 1` points from a finite Sidon set leaves gaps of size at least `t`. -/ |
| 17 | +theorem exists_spaced_subset {F : Finset ℕ} (hF : IsSidon (F : Set ℕ)) (t : ℕ) : |
| 18 | + ∃ B ⊆ F, F.card ≤ B.card + (t - 1) ∧ |
| 19 | + ∀ x ∈ B, ∀ y ∈ B, x = y ∨ x + t ≤ y ∨ y + t ≤ x := by |
| 20 | + let pairs := (F ×ˢ F).filter fun q => q.1 < q.2 ∧ q.2 < q.1 + t |
| 21 | + have mem_pairs {x y : ℕ} : |
| 22 | + (x, y) ∈ pairs ↔ x ∈ F ∧ y ∈ F ∧ x < y ∧ y < x + t := by |
| 23 | + simp [pairs, and_assoc] |
| 24 | + have hpairs : pairs.card ≤ (Ico 1 t).card := by |
| 25 | + apply card_le_card_of_injOn (fun q : ℕ × ℕ => q.2 - q.1) |
| 26 | + · rintro ⟨x, y⟩ hxy |
| 27 | + obtain ⟨_, _, hlt, hnear⟩ := mem_pairs.mp hxy |
| 28 | + exact mem_Ico.mpr ⟨by dsimp; omega, by dsimp; omega⟩ |
| 29 | + · rintro ⟨x, y⟩ hxy ⟨u, v⟩ huv heq |
| 30 | + obtain ⟨hx, hy, hlt, _⟩ := mem_pairs.mp hxy |
| 31 | + obtain ⟨hu, hv, hlt', _⟩ := mem_pairs.mp huv |
| 32 | + obtain ⟨rfl, rfl⟩ := Finset.IsSidon.eq_of_tsub hF hy hx hv hu hlt hlt' heq |
| 33 | + rfl |
| 34 | + let removed := pairs.image Prod.fst |
| 35 | + have hremoved : removed.card ≤ t - 1 := by |
| 36 | + simpa only [Nat.card_Ico] using (card_image_le (f := Prod.fst)).trans hpairs |
| 37 | + have gap {x y : ℕ} (hx : x ∈ F \ removed) (hy : y ∈ F) (hxy : x < y) : x + t ≤ y := by |
| 38 | + by_contra! hnear |
| 39 | + exact (mem_sdiff.mp hx).2 (mem_image.mpr |
| 40 | + ⟨(x, y), mem_pairs.mpr ⟨sdiff_subset hx, hy, hxy, hnear⟩, rfl⟩) |
| 41 | + refine ⟨F \ removed, sdiff_subset, |
| 42 | + card_le_card_sdiff_add_card.trans (Nat.add_le_add_left hremoved _), ?_⟩ |
| 43 | + intro x hx y hy |
| 44 | + rcases lt_trichotomy x y with h | h | h |
| 45 | + · exact Or.inr (Or.inl (gap hx (sdiff_subset hy) h)) |
| 46 | + · exact Or.inl h |
| 47 | + · exact Or.inr (Or.inr (gap hy (sdiff_subset hx) h)) |
| 48 | + |
| 49 | +/-- For prime `p`, imposing gaps of size `t` on a Sidon set in `[1, (p - 1)²]` |
| 50 | +costs at most `t - 1` of the `p - 1` points supplied by the Ruzsa bound. -/ |
| 51 | +theorem exists_spaced_sidon_prime_sq (p : ℕ) (hp : p.Prime) (t : ℕ) : |
| 52 | + ∃ B ⊆ Icc 1 ((p - 1) ^ 2), IsSidon (B : Set ℕ) ∧ p - 1 ≤ B.card + (t - 1) ∧ |
| 53 | + ∀ x ∈ B, ∀ y ∈ B, x = y ∨ x + t ≤ y ∨ y + t ≤ x := by |
| 54 | + obtain ⟨F, hFI, hF, hcard⟩ := Erdos30.exists_eq_h ((p - 1) ^ 2) |
| 55 | + obtain ⟨B, hBF, hsize, hgap⟩ := exists_spaced_subset hF t |
| 56 | + have hlower := Erdos30.pred_prime_le_h_sq p hp |
| 57 | + rw [← hcard] at hlower |
| 58 | + exact ⟨B, hBF.trans hFI, Set.IsSidon.subset hF hBF, hlower.trans hsize, hgap⟩ |
| 59 | + |
| 60 | +end ErdosSwarm.Erdos329 |