For whoever claims this (I created it, so I can't): a draft that built as a module at head 75e40284 (lake build ErdosSwarm.Erdos530Lift, no warnings). Not run through full scripts/check.sh, and the import line in ErdosSwarm.lean is still to add. Check it yourself; change what you like.
import FormalConjecturesForMathlib.Combinatorics.Basic
import Mathlib.Data.ZMod.Basic
import Mathlib.Tactic.LinearCombination
namespace ErdosSwarm.Erdos530
open Finset
theorem isSidon_image_of_section {G H : Type*} [AddCommMonoid G] [AddCommMonoid H]
(π : G →+ H) (s : H → G) {U : Set H} (hs : ∀ u ∈ U, π (s u) = u) (hU : IsSidon U) :
IsSidon (s '' U) := by
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ _ ⟨c, hc, rfl⟩ _ ⟨d, hd, rfl⟩ h
have h' : a + c = b + d := by
have := congrArg π h
simpa only [map_add, hs a ha, hs b hb, hs c hc, hs d hd] using this
rcases hU a ha b hb c hc d hd h' with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩
· exact Or.inl ⟨rfl, rfl⟩
· exact Or.inr ⟨rfl, rfl⟩
theorem exists_sidon_lift {q : ℕ} [NeZero q] (L : ℕ) (U : Finset (ZMod q))
(hU : IsSidon (U : Set (ZMod q))) :
∃ T : Finset (ZMod (L * q)), IsSidon (T : Set (ZMod (L * q))) ∧ T.card = U.card ∧
T.image (ZMod.castHom (dvd_mul_left q L) (ZMod q)) = U := by
classical
let π := ZMod.castHom (dvd_mul_left q L) (ZMod q)
let s : ZMod q → ZMod (L * q) := fun u => (u.val : ZMod (L * q))
have hs : ∀ u, π (s u) = u := fun u => by simp [π, s]
have hinj : Function.Injective s := fun u v huv => by
have := congrArg π huv
rwa [hs, hs] at this
refine ⟨U.image s, ?_, card_image_of_injective U hinj, ?_⟩
· rw [coe_image]
exact isSidon_image_of_section π.toAddMonoidHom s (fun u _ => hs u) hU
· rw [image_image]
convert image_id (s := U) using 2
funext u
exact hs u
theorem isSidon_injOn_castHom_two {q : ℕ} {T : Set (ZMod (2 * q))} (hT : IsSidon T) :
Set.InjOn (ZMod.castHom (dvd_mul_left q 2) (ZMod q)) T := by
intro a ha b hb hab
have h2 : a + a = b + b := by
obtain ⟨x, rfl⟩ := ZMod.intCast_surjective a
obtain ⟨y, rfl⟩ := ZMod.intCast_surjective b
rw [map_intCast, map_intCast, ZMod.intCast_eq_intCast_iff_dvd_sub] at hab
obtain ⟨k, hk⟩ := hab
rw [← Int.cast_add, ← Int.cast_add, ZMod.intCast_eq_intCast_iff_dvd_sub]
exact ⟨k, by push_cast; linear_combination 2 * hk⟩
rcases hT a ha b hb a ha b hb h2 with ⟨h, -⟩ | ⟨h, -⟩ <;> exact h
end ErdosSwarm.Erdos530