| | @@ -0,0 +1,73 @@ |
| 1 | +import ErdosSwarm.Erdos530ZModCount |
| 2 | +import FormalConjecturesForMathlib.Data.ZMod.PerfectDifferenceSet |
| 3 | + |
| 4 | +/-! |
| 5 | +# Perfect difference sets from equality in the cyclic Sidon bound |
| 6 | + |
| 7 | +A cyclic Sidon set of size `k` has `k * (k - 1)` distinct nonzero differences. |
| 8 | +If these exhaust the nonzero residues, the least natural representatives form a perfect |
| 9 | +difference set in the sense of Erdős problem 707. For instance, the size-`q + 1` Sidon sets |
| 10 | +in Singer's covering attain this count modulo `q^2 + q + 1` |
| 11 | +(Bailleul–Riblet, *On the largest Sidon subset in a finite subset of ℝᴺ*, arXiv:2605.03181). |
| 12 | +-/ |
| 13 | + |
| 14 | +namespace ErdosSwarm.Erdos707 |
| 15 | + |
| 16 | +open Finset |
| 17 | + |
| 18 | +/-- Equality in the cyclic Sidon bound makes subtraction bijective onto the nonzero residues. -/ |
| 19 | +theorem bijOn_sub_of_sidon_card_eq {m : ℕ} [NeZero m] (S : Finset (ZMod m)) |
| 20 | + (hS : IsSidon (S : Set (ZMod m))) (hcard : S.card * (S.card - 1) = m - 1) : |
| 21 | + Set.BijOn (fun p : ZMod m × ZMod m => p.1 - p.2) (S : Set _).offDiag {x | x ≠ 0} := by |
| 22 | + let diff (p : ZMod m × ZMod m) := p.1 - p.2 |
| 23 | + let T := univ.erase (0 : ZMod m) |
| 24 | + have hmap : Set.MapsTo diff (S.offDiag : Set _) (T : Set _) := by |
| 25 | + intro p hp |
| 26 | + exact mem_erase.mpr ⟨sub_ne_zero.mpr (mem_offDiag.mp hp).2.2, mem_univ _⟩ |
| 27 | + have hinj : Set.InjOn diff (S.offDiag : Set _) := by |
| 28 | + simpa only [coe_offDiag] using sidon_injOn_sub_offDiag hS |
| 29 | + have hsize : T.card = S.offDiag.card := by |
| 30 | + rw [offDiag_card, ← Nat.mul_sub_one, hcard] |
| 31 | + simp [T, ZMod.card] |
| 32 | + have hT : (T : Set (ZMod m)) = {x | x ≠ 0} := by |
| 33 | + ext x |
| 34 | + simp [T] |
| 35 | + rw [← coe_offDiag, ← hT] |
| 36 | + exact ⟨hmap, hinj, surjOn_of_injOn_of_card_le diff hmap hinj hsize.le⟩ |
| 37 | + |
| 38 | +/-- An injective change of representatives preserves ordered pairs of distinct elements. -/ |
| 39 | +private theorem offDiag_image_of_injective {α β : Type*} (s : Set α) {f : α → β} |
| 40 | + (hf : Function.Injective f) : (f '' s).offDiag = Prod.map f f '' s.offDiag := by |
| 41 | + apply Set.Subset.antisymm |
| 42 | + · rintro ⟨_, _⟩ ⟨⟨a, ha, rfl⟩, ⟨b, hb, rfl⟩, hne⟩ |
| 43 | + exact ⟨(a, b), ⟨ha, hb, fun h => hne (congrArg f h)⟩, rfl⟩ |
| 44 | + · rintro _ ⟨⟨a, b⟩, ⟨ha, hb, hne⟩, rfl⟩ |
| 45 | + exact ⟨⟨a, ha, rfl⟩, ⟨b, hb, rfl⟩, hf.ne hne⟩ |
| 46 | + |
| 47 | +/-- The least natural representatives of a cyclic Sidon set attaining the difference bound |
| 48 | +form a perfect difference set of the same size. -/ |
| 49 | +theorem isPerfectDifferenceSet_of_sidon_card_eq {m : ℕ} [NeZero m] (S : Finset (ZMod m)) |
| 50 | + (hS : IsSidon (S : Set (ZMod m))) (hcard : S.card * (S.card - 1) = m - 1) : |
| 51 | + let B := ZMod.val '' (S : Set (ZMod m)) |
| 52 | + IsPerfectDifferenceSet B m ∧ B.ncard = S.card := by |
| 53 | + dsimp only |
| 54 | + have hval := ZMod.val_injective m |
| 55 | + refine ⟨?_, by rw [Set.ncard_image_of_injective _ hval, Set.ncard_coe_finset]⟩ |
| 56 | + unfold IsPerfectDifferenceSet |
| 57 | + rw [offDiag_image_of_injective _ hval] |
| 58 | + apply (Set.bijOn_comp_iff (hval.prodMap hval).injOn).mp |
| 59 | + apply (bijOn_sub_of_sidon_card_eq S hS hcard).congr |
| 60 | + rintro ⟨a, b⟩ _ |
| 61 | + simp |
| 62 | + |
| 63 | +/-- The least representatives of the three-element cyclic Sidon set modulo seven. -/ |
| 64 | +theorem isPerfectDifferenceSet_zero_one_three : |
| 65 | + IsPerfectDifferenceSet ({0, 1, 3} : Set ℕ) 7 ∧ ({0, 1, 3} : Set ℕ).ncard = 3 := by |
| 66 | + let S : Finset (ZMod 7) := {0, 1, 3} |
| 67 | + have hcard : S.card = 3 := by decide |
| 68 | + have hrep : ZMod.val '' (S : Set (ZMod 7)) = ({0, 1, 3} : Set ℕ) := by |
| 69 | + simp [S, Set.image_insert_eq, ZMod.val_one_eq_one_mod, show (3 : ZMod 7).val = 3 by decide] |
| 70 | + simpa only [hrep, hcard] using |
| 71 | + isPerfectDifferenceSet_of_sidon_card_eq S (by decide) (by rw [hcard]) |
| 72 | + |
| 73 | +end ErdosSwarm.Erdos707 |