| | @@ -0,0 +1,207 @@ |
| 1 | +import ErdosSwarm.Erdos530Parabola |
| 2 | +import ErdosSwarm.Erdos530Projection |
| 3 | +import ErdosSwarm.Erdos530Spread |
| 4 | +import Mathlib.Algebra.Field.ZMod |
| 5 | + |
| 6 | +/-! |
| 7 | +# The finite-field test for Erdős problem 530: inequality (8) |
| 8 | + |
| 9 | +Lean version of inequality (8) of Theorem 4 in |
| 10 | +`experiments/erdos530/lower-middle-energy/NOTES.md`, §4 (after Proposition 7.2 of the |
| 11 | +October 2026 sidon-palomar report). Let `F` be a finite field with `2 ≠ 0` and `q = |F|` (in the |
| 12 | +note, `F = ZMod p` for an odd prime `p`), and let `f` map a finite set `B` of an additive |
| 13 | +commutative monoid into a finite-dimensional vector space `V` over `F`, taking equal pair sums in |
| 14 | +`B` to equal pair sums. If `f` has at least `h` distinct values on `B`, then `B` has a Sidon |
| 15 | +subset `S` with |
| 16 | + |
| 17 | + `|S| ≥ (h - (h choose 2) / q ^ 2) / q`. |
| 18 | + |
| 19 | +* `exists_sidon_of_image_sidon`: a Sidon set inside the image of a sum-preserving map pulls |
| 20 | + back, one preimage per point, to a Sidon set of the same size. |
| 21 | +* `exists_sidon_subset_of_plane_map`: a sum-preserving map `g` into the plane `F × F` gives a |
| 22 | + Sidon subset with `|g(B)| ≤ q * |S|`. The `q` vertical translates of the parabola partition |
| 23 | + the plane, each is Sidon by `Erdos530Parabola.parabola_isSidon`, and one of them contains at |
| 24 | + least the average number of points of `g(B)`. |
| 25 | +* `exists_sidon_subset_of_modular_classes`: inequality (8), cleared of divisions, as |
| 26 | + `q ^ 2 * h ≤ q ^ 3 * |S| + h choose 2`. The linear map to the plane applied to `h` |
| 27 | + representatives is `Erdos530Projection.exists_plane_projection`. |
| 28 | +* `exists_sidon_subset_of_modular_classes_zmod` and |
| 29 | + `exists_sidon_subset_real_of_modular_classes`: the case `F = ZMod p`, `p` an odd prime, with |
| 30 | + `p` in place of `|F|`, and its real form as written in (8). |
| 31 | + |
| 32 | +## What is and is not Lean-checked |
| 33 | + |
| 34 | +Lean-checked: the finite inequality (8) for a given map into an `F`-vector space that preserves |
| 35 | +equal pair sums. Not Lean-checked: that the note's symbol map into `V_p(B)` is such a map with |
| 36 | +`d_p(B)` distinct values (this file takes `V` and `f` as given and does not construct them); the |
| 37 | +asymptotic consequences stated after (8), namely the threshold `ρ > 1/2` at `p ~ √(3N/4)` and |
| 38 | +the gain `c₀(ε - 2ε²)`; and the remaining implication of the open task on the middle-energy |
| 39 | +lower bound, which is open. Nothing here is the Formal Conjectures statement of problem 530. |
| 40 | +-/ |
| 41 | + |
| 42 | +namespace ErdosSwarm.Erdos530PrimeField |
| 43 | + |
| 44 | +open Finset |
| 45 | +open scoped BigOperators |
| 46 | + |
| 47 | +/-- A Sidon set inside the image of a map that preserves equal pair sums on `B` pulls back to a |
| 48 | +Sidon subset of `B` of the same size: choose one preimage for each of its points. -/ |
| 49 | +theorem exists_sidon_of_image_sidon {α G : Type*} [AddCommMonoid α] [AddCommMonoid G] |
| 50 | + [DecidableEq G] (B : Finset α) (g : α → G) |
| 51 | + (hg : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → g a + g b = g c + g d) |
| 52 | + (T : Finset G) (hT : T ⊆ B.image g) (hS : IsSidon (T : Set G)) : |
| 53 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ S.card = T.card := by |
| 54 | + classical |
| 55 | + rcases B.eq_empty_or_nonempty with rfl | ⟨a0, -⟩ |
| 56 | + · have hTe : T = ∅ := by simpa using hT |
| 57 | + refine ⟨∅, subset_rfl, ?_, by simp [hTe]⟩ |
| 58 | + intro a ha |
| 59 | + simp at ha |
| 60 | + have : Nonempty α := ⟨a0⟩ |
| 61 | + have hex : ∀ y ∈ B.image g, ∃ a, a ∈ B ∧ g a = y := fun y hy => by simpa using hy |
| 62 | + choose! s hsB hsg using hex |
| 63 | + have hinj : Set.InjOn s T := by |
| 64 | + intro y hy z hz hyz |
| 65 | + have := congrArg g hyz |
| 66 | + rwa [hsg y (hT hy), hsg z (hT hz)] at this |
| 67 | + refine ⟨T.image s, ?_, ?_, card_image_of_injOn hinj⟩ |
| 68 | + · intro a ha |
| 69 | + obtain ⟨y, hy, rfl⟩ := mem_image.mp ha |
| 70 | + exact hsB y (hT hy) |
| 71 | + · intro a ha c hc b hb d hd h |
| 72 | + rw [mem_coe, mem_image] at ha hb hc hd |
| 73 | + obtain ⟨y1, h1, rfl⟩ := ha |
| 74 | + obtain ⟨y3, h3, rfl⟩ := hc |
| 75 | + obtain ⟨y2, h2, rfl⟩ := hb |
| 76 | + obtain ⟨y4, h4, rfl⟩ := hd |
| 77 | + have h' := hg _ (hsB _ (hT h1)) _ (hsB _ (hT h2)) _ (hsB _ (hT h3)) _ (hsB _ (hT h4)) h |
| 78 | + rw [hsg _ (hT h1), hsg _ (hT h2), hsg _ (hT h3), hsg _ (hT h4)] at h' |
| 79 | + rcases hS y1 h1 y3 h3 y2 h2 y4 h4 h' with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ |
| 80 | + · exact Or.inl ⟨rfl, rfl⟩ |
| 81 | + · exact Or.inr ⟨rfl, rfl⟩ |
| 82 | + |
| 83 | +/-- A map into the plane over a finite field `F` with `2 ≠ 0` that preserves equal pair sums on |
| 84 | +`B` gives a Sidon subset of `B` of size at least `|g(B)| / |F|`: the `|F|` vertical translates of |
| 85 | +the parabola partition the plane, so some translate of the parabola contains at least that many |
| 86 | +points of `g(B)`. -/ |
| 87 | +theorem exists_sidon_subset_of_plane_map {F : Type*} [Field F] [Fintype F] [DecidableEq F] |
| 88 | + (h2 : (2 : F) ≠ 0) {α : Type*} [AddCommMonoid α] (B : Finset α) (g : α → F × F) |
| 89 | + (hg : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → g a + g b = g c + g d) : |
| 90 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ (B.image g).card ≤ Fintype.card F * S.card := by |
| 91 | + classical |
| 92 | + have hq0 : 0 < Fintype.card F := Fintype.card_pos |
| 93 | + let P : Finset (F × F) := univ.image fun r : F => (r, r ^ 2) |
| 94 | + have hPcard : P.card = Fintype.card F := by |
| 95 | + rw [card_image_of_injective _ (fun a b h => congrArg Prod.fst h), card_univ] |
| 96 | + obtain ⟨t, ht⟩ := |
| 97 | + Erdos530.exists_card_mul_card_le_card_mul_card_filter_sub_mem (B.image g) P |
| 98 | + have hTsidon : |
| 99 | + IsSidon (((B.image g).filter fun a => a - t ∈ P : Finset (F × F)) : Set (F × F)) := by |
| 100 | + have hpar := Erdos530Parabola.parabola_isSidon (F := F) h2 |
| 101 | + have hm : ∀ y ∈ (((B.image g).filter fun a => a - t ∈ P : Finset (F × F)) : Set (F × F)), |
| 102 | + y - t ∈ Set.range fun r : F => (r, r ^ 2) := by |
| 103 | + intro y hy |
| 104 | + rw [mem_coe, mem_filter] at hy |
| 105 | + obtain ⟨r, -, hr⟩ := mem_image.mp hy.2 |
| 106 | + exact ⟨r, hr⟩ |
| 107 | + intro a ha c hc b hb d hd h |
| 108 | + have h' : (a - t) + (b - t) = (c - t) + (d - t) := by |
| 109 | + rw [sub_add_sub_comm, sub_add_sub_comm, h] |
| 110 | + rcases hpar _ (hm a ha) _ (hm c hc) _ (hm b hb) _ (hm d hd) h' with ⟨e1, e2⟩ | ⟨e1, e2⟩ |
| 111 | + · exact Or.inl ⟨sub_left_inj.mp e1, sub_left_inj.mp e2⟩ |
| 112 | + · exact Or.inr ⟨sub_left_inj.mp e1, sub_left_inj.mp e2⟩ |
| 113 | + obtain ⟨S, hSB, hS, hcard⟩ := |
| 114 | + exists_sidon_of_image_sidon B g hg _ (filter_subset _ _) hTsidon |
| 115 | + refine ⟨S, hSB, hS, ?_⟩ |
| 116 | + rw [hPcard, Fintype.card_prod, ← hcard] at ht |
| 117 | + exact Nat.le_of_mul_le_mul_left (by linarith) hq0 |
| 118 | + |
| 119 | +/-- **Inequality (8) of Theorem 4.** Let `F` be a finite field with `2 ≠ 0`, `q = |F|`, and `f` |
| 120 | +a map from `B` into a finite-dimensional `F`-vector space that preserves equal pair sums in `B`. |
| 121 | +If `f` takes at least `h` distinct values on `B`, then `B` has a Sidon subset `S` with |
| 122 | +`q ^ 2 * h ≤ q ^ 3 * |S| + h choose 2`, that is `|S| ≥ (h - (h choose 2) / q ^ 2) / q`. |
| 123 | + |
| 124 | +The space `V` and the map `f` are hypotheses: that the note's symbol map into `V_p(B)` is such a |
| 125 | +map with `d_p(B)` distinct values is not Lean-checked, and neither are the asymptotic |
| 126 | +consequences of (8). -/ |
| 127 | +theorem exists_sidon_subset_of_modular_classes {F : Type*} [Field F] [Fintype F] [DecidableEq F] |
| 128 | + (h2 : (2 : F) ≠ 0) {α V : Type*} [AddCommMonoid α] [AddCommGroup V] [Module F V] |
| 129 | + [FiniteDimensional F V] [DecidableEq V] (B : Finset α) (f : α → V) |
| 130 | + (hf : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → f a + f b = f c + f d) |
| 131 | + (h : ℕ) (hh : h ≤ (B.image f).card) : |
| 132 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ |
| 133 | + (Fintype.card F) ^ 2 * h ≤ (Fintype.card F) ^ 3 * S.card + h.choose 2 := by |
| 134 | + classical |
| 135 | + -- `h` representatives with distinct values |
| 136 | + obtain ⟨H, hHsub, hHcard⟩ := exists_subset_card_eq hh |
| 137 | + obtain ⟨R, hRB, hRinj, hRimg⟩ := |
| 138 | + Finset.exists_subset_injOn_image_eq_of_surjOn (f := f) (B : Set α) H (by |
| 139 | + intro u hu |
| 140 | + have := hHsub hu |
| 141 | + rw [mem_image] at this |
| 142 | + obtain ⟨a, ha, rfl⟩ := this |
| 143 | + exact ⟨a, ha, rfl⟩) |
| 144 | + obtain ⟨L, hL⟩ := Erdos530Projection.exists_plane_projection (F := F) H |
| 145 | + have hgL : ∀ a ∈ R, ∀ b ∈ R, ∀ c ∈ R, ∀ d ∈ R, |
| 146 | + a + b = c + d → L (f a) + L (f b) = L (f c) + L (f d) := by |
| 147 | + intro a ha b hb c hc d hd habcd |
| 148 | + rw [← map_add, ← map_add, hf a (hRB ha) b (hRB hb) c (hRB hc) d (hRB hd) habcd] |
| 149 | + obtain ⟨S, hSR, hS, hScard⟩ := exists_sidon_subset_of_plane_map h2 R (fun a => L (f a)) hgL |
| 150 | + refine ⟨S, fun a ha => hRB (hSR ha), hS, ?_⟩ |
| 151 | + have himg : R.image (fun a => L (f a)) = H.image L := by |
| 152 | + rw [← hRimg, image_image] |
| 153 | + rfl |
| 154 | + rw [himg] at hScard |
| 155 | + rw [hHcard] at hL |
| 156 | + have h1 : (Fintype.card F) ^ 2 * (H.image L).card ≤ |
| 157 | + (Fintype.card F) ^ 2 * (Fintype.card F * S.card) := Nat.mul_le_mul_left _ hScard |
| 158 | + have h4 : (Fintype.card F) ^ 2 * (Fintype.card F * S.card) = |
| 159 | + (Fintype.card F) ^ 3 * S.card := by ring |
| 160 | + omega |
| 161 | + |
| 162 | +/-- In `ZMod p` with `p` a prime other than `2`, `2 ≠ 0`. -/ |
| 163 | +theorem two_ne_zero_zmod {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) : (2 : ZMod p) ≠ 0 := by |
| 164 | + intro h0 |
| 165 | + have hdvd : p ∣ 2 := (ZMod.natCast_eq_zero_iff 2 p).mp (by exact_mod_cast h0) |
| 166 | + exact hp ((Nat.prime_dvd_prime_iff_eq Fact.out Nat.prime_two).mp hdvd) |
| 167 | + |
| 168 | +/-- The parabola-translate extraction for `F = ZMod p`, `p` an odd prime: a map into |
| 169 | +`ZMod p × ZMod p` preserving equal pair sums on `B` gives a Sidon `S ⊆ B` with |
| 170 | +`|g(B)| ≤ p * |S|`. -/ |
| 171 | +theorem exists_sidon_subset_of_plane_map_zmod {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) |
| 172 | + {α : Type*} [AddCommMonoid α] (B : Finset α) (g : α → ZMod p × ZMod p) |
| 173 | + (hg : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → g a + g b = g c + g d) : |
| 174 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ (B.image g).card ≤ p * S.card := by |
| 175 | + have h := exists_sidon_subset_of_plane_map (two_ne_zero_zmod hp) B g hg |
| 176 | + rwa [ZMod.card] at h |
| 177 | + |
| 178 | +/-- Inequality (8) of Theorem 4 for `F = ZMod p`, `p` an odd prime, cleared of divisions: |
| 179 | +`p ^ 2 * h ≤ p ^ 3 * |S| + h choose 2`. As in `exists_sidon_subset_of_modular_classes`, the |
| 180 | +space `V` and the sum-preserving map `f` are hypotheses. -/ |
| 181 | +theorem exists_sidon_subset_of_modular_classes_zmod {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) |
| 182 | + {α V : Type*} [AddCommMonoid α] [AddCommGroup V] [Module (ZMod p) V] |
| 183 | + [FiniteDimensional (ZMod p) V] [DecidableEq V] (B : Finset α) (f : α → V) |
| 184 | + (hf : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → f a + f b = f c + f d) |
| 185 | + (h : ℕ) (hh : h ≤ (B.image f).card) : |
| 186 | + ∃ S ⊆ B, IsSidon (S : Set α) ∧ p ^ 2 * h ≤ p ^ 3 * S.card + h.choose 2 := by |
| 187 | + have h' := exists_sidon_subset_of_modular_classes (two_ne_zero_zmod hp) B f hf h hh |
| 188 | + rwa [ZMod.card] at h' |
| 189 | + |
| 190 | +/-- Inequality (8) of Theorem 4 for a finite real set and an odd prime `p`, in the note's form |
| 191 | +`s(A) ≥ (h - (h choose 2) / p ^ 2) / p`. As in `exists_sidon_subset_of_modular_classes`, the |
| 192 | +space `V` and the sum-preserving map `f` are hypotheses. -/ |
| 193 | +theorem exists_sidon_subset_real_of_modular_classes {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) |
| 194 | + {V : Type*} [AddCommGroup V] [Module (ZMod p) V] [FiniteDimensional (ZMod p) V] |
| 195 | + [DecidableEq V] (B : Finset ℝ) (f : ℝ → V) |
| 196 | + (hf : ∀ a ∈ B, ∀ b ∈ B, ∀ c ∈ B, ∀ d ∈ B, a + b = c + d → f a + f b = f c + f d) |
| 197 | + (h : ℕ) (hh : h ≤ (B.image f).card) : |
| 198 | + ∃ S ⊆ B, IsSidon (S : Set ℝ) ∧ |
| 199 | + ((h : ℝ) - (h.choose 2 : ℝ) / (p : ℝ) ^ 2) / p ≤ S.card := by |
| 200 | + obtain ⟨S, hSB, hS, hcard⟩ := exists_sidon_subset_of_modular_classes_zmod hp B f hf h hh |
| 201 | + refine ⟨S, hSB, hS, ?_⟩ |
| 202 | + have hp0 : (0 : ℝ) < p := by exact_mod_cast (Fact.out : p.Prime).pos |
| 203 | + have hc : ((p : ℝ) ^ 2 * h) ≤ (p : ℝ) ^ 3 * S.card + h.choose 2 := by exact_mod_cast hcard |
| 204 | + rw [div_le_iff₀ hp0, sub_le_iff_le_add, ← sub_le_iff_le_add', le_div_iff₀ (by positivity)] |
| 205 | + nlinarith [hc] |
| 206 | + |
| 207 | +end ErdosSwarm.Erdos530PrimeField |