| | @@ -0,0 +1,124 @@ |
| 1 | +import ErdosSwarm.Erdos530OccupancyMoments |
| 2 | +import ErdosSwarm.Erdos530PrimeField |
| 3 | +import ErdosSwarm.Erdos530ProjectionMoments |
| 4 | +import Mathlib.Algebra.Order.BigOperators.Expect |
| 5 | + |
| 6 | +/-! |
| 7 | +# A Sidon subset from bounded triple spans |
| 8 | + |
| 9 | +Equation (1) of §1 in |
| 10 | +`experiments/erdos530/lower-middle-energy2/box-occupancy/NOTES.md`. |
| 11 | +The fourth-moment inequality bounds the mean occupancy surplus of a linear |
| 12 | +projection. An odd-prime plane admits parabola extraction from its occupied |
| 13 | +cells, as in Proposition 7.2 of the October 2026 sidon-palomar report. |
| 14 | +-/ |
| 15 | + |
| 16 | +namespace ErdosSwarm.Erdos530TripleSpan |
| 17 | + |
| 18 | +open Finset Erdos530Monochromatic Erdos530Occupancy Erdos530ProjectionMoments |
| 19 | +open scoped BigOperators Classical |
| 20 | + |
| 21 | +/-- The total surplus of the fibres is the number of occupied cells minus |
| 22 | +the number of points, plus the number of colliding pairs. -/ |
| 23 | +private theorem sum_fibre_surplus {V W : Type*} [DecidableEq V] [DecidableEq W] [Fintype W] |
| 24 | + (X : Finset V) (f : V → W) : |
| 25 | + (∑ b, (surplus (fibre X f b).card : ℝ)) = |
| 26 | + ((X.image f).card : ℝ) - X.card + (monoSubsets X f 2).card := by |
| 27 | + have hsupport : (univ.filter fun b => 0 < (fibre X f b).card) = X.image f := by |
| 28 | + ext b |
| 29 | + simp [card_pos, fibre, filter_nonempty_iff, mem_image] |
| 30 | + have htotal : ∑ b, (fibre X f b).card = X.card := |
| 31 | + (card_eq_sum_card_fiberwise fun a _ => mem_univ (f a)).symm |
| 32 | + have h := sum_surplus_eq univ (fun b => (fibre X f b).card) |
| 33 | + rw [hsupport, ← Nat.cast_sum, ← Nat.cast_sum, htotal, |
| 34 | + ← card_monoSubsets_univ X f (by decide : 0 < 2)] at h |
| 35 | + exact_mod_cast h |
| 36 | + |
| 37 | +/-- A uniform cap on the number of points in each triple span gives a linear |
| 38 | +map whose image attains the pair-count bound plus a positive triple term. |
| 39 | +Here the target cardinality is `q`, and it is `p²` for a plane over `ZMod p`. -/ |
| 40 | +theorem exists_projection_of_triple_span_bound |
| 41 | + (F : Type*) {V : Type*} (W : Type*) [Field F] [AddCommGroup V] [Module F V] |
| 42 | + [AddCommGroup W] [Module F W] [Fintype W] [Fintype (V →ₗ[F] W)] |
| 43 | + [DecidableEq V] [DecidableEq W] (X : Finset V) (hn : 3 ≤ X.card) (M : ℝ) |
| 44 | + (hM : ∀ T ∈ X.powersetCard 3, (spanCount F X T : ℝ) ≤ M) : |
| 45 | + ∃ L : V →ₗ[F] W, |
| 46 | + (X.card : ℝ) - (X.card.choose 2 : ℝ) / Fintype.card W + |
| 47 | + 3 * (X.card.choose 3 : ℝ) / |
| 48 | + ((Fintype.card W : ℝ) ^ 2 * (M + ((X.card : ℝ) - 3) / Fintype.card W)) ≤ |
| 49 | + (X.image L).card := by |
| 50 | + let m (L : V →ₗ[F] W) (b : W) := (fibre X L b).card |
| 51 | + let U : ℝ := 𝔼 L : V →ₗ[F] W, ∑ b, (surplus (m L b) : ℝ) |
| 52 | + let D := M + ((X.card : ℝ) - 3) / Fintype.card W |
| 53 | + let T := meanCollisions F W X 3 |
| 54 | + let Q := meanCollisions F W X 4 |
| 55 | + have hU : 0 ≤ U := expect_nonneg fun _ _ => sum_nonneg fun _ _ => Nat.cast_nonneg _ |
| 56 | + have hT : 0 < T := meanCollisions_three_pos F W hn |
| 57 | + have hQ : 0 ≤ Q := div_nonneg (sum_nonneg fun _ _ => Nat.cast_nonneg _) (Nat.cast_nonneg _) |
| 58 | + have hcount {k : ℕ} (hk : 0 < k) : meanCollisions F W X k = |
| 59 | + (∑ L : V →ₗ[F] W, ∑ b, ((m L b).choose k : ℝ)) / Fintype.card (V →ₗ[F] W) := by |
| 60 | + simp only [meanCollisions, card_monoSubsets_univ X _ hk, Nat.cast_sum, m] |
| 61 | + have hmoment : 3 * T ^ 2 ≤ U * (3 * T + 4 * Q) := by |
| 62 | + dsimp only [T, Q, U] |
| 63 | + rw [hcount (by decide : 0 < 3), hcount (by decide : 0 < 4), Fintype.expect_eq_sum_div_card] |
| 64 | + simpa only [card_univ] using |
| 65 | + fibre_inequality_avg (univ : Finset (V →ₗ[F] W)) univ_nonempty univ m |
| 66 | + have hfactor : 3 * T + 4 * Q ≤ T * D := by |
| 67 | + have hcap := four_mul_meanCollisions_four_le F W X M hM |
| 68 | + dsimp only [T, Q, D] |
| 69 | + linarith only [hcap] |
| 70 | + have hD : 0 < D := pos_of_mul_pos_right |
| 71 | + (lt_of_lt_of_le (by positivity : 0 < 3 * T + 4 * Q) hfactor) hT.le |
| 72 | + have hcancel : 3 * T ≤ U * D := by |
| 73 | + apply (mul_le_mul_iff_left₀ hT).mp |
| 74 | + calc |
| 75 | + (3 * T) * T = 3 * T ^ 2 := by ring |
| 76 | + _ ≤ U * (3 * T + 4 * Q) := hmoment |
| 77 | + _ ≤ U * (T * D) := mul_le_mul_of_nonneg_left hfactor hU |
| 78 | + _ = (U * D) * T := by ring |
| 79 | + have hgain : 3 * (X.card.choose 3 : ℝ) / ((Fintype.card W : ℝ) ^ 2 * D) ≤ U := by |
| 80 | + rw [← div_div, div_le_iff₀ hD, mul_div_assoc] |
| 81 | + exact (mul_le_mul_of_nonneg_left (meanCollisions_three_ge F W X) (by norm_num)).trans hcancel |
| 82 | + have hid : U = (𝔼 L : V →ₗ[F] W, ((X.image L).card : ℝ)) - X.card + |
| 83 | + meanCollisions F W X 2 := by |
| 84 | + unfold meanCollisions |
| 85 | + rw [← Fintype.expect_eq_sum_div_card] |
| 86 | + simp only [U, m, sum_fibre_surplus, expect_add_distrib, expect_sub_distrib, Fintype.expect_const] |
| 87 | + obtain ⟨L, _, hL⟩ := exists_le_of_le_expect (f := fun L : V →ₗ[F] W => ((X.image L).card : ℝ)) |
| 88 | + univ_nonempty le_rfl |
| 89 | + refine ⟨L, ?_⟩ |
| 90 | + rw [hid, meanCollisions_two] at hgain |
| 91 | + dsimp only [D] at hgain |
| 92 | + linarith only [hgain, hL] |
| 93 | + |
| 94 | +/-- Finite Sidon bound (1). The model is injective on `A` and carries every |
| 95 | +equality of pair sums in `A` forward. The cap `M` counts model points in the |
| 96 | +affine span of each triple of distinct model points. -/ |
| 97 | +theorem exists_sidon_subset_of_triple_span_bound {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) |
| 98 | + {α V : Type*} [AddCommMonoid α] [AddCommGroup V] [Module (ZMod p) V] |
| 99 | + [FiniteDimensional (ZMod p) V] [DecidableEq V] |
| 100 | + (A : Finset α) (hn : 3 ≤ A.card) (f : α → V) (hinj : Set.InjOn f A) |
| 101 | + (hf : ∀ a ∈ A, ∀ b ∈ A, ∀ c ∈ A, ∀ d ∈ A, a + b = c + d → f a + f b = f c + f d) |
| 102 | + (M : ℝ) (hM : ∀ T ∈ (A.image f).powersetCard 3, (spanCount (ZMod p) (A.image f) T : ℝ) ≤ M) : |
| 103 | + ∃ S ⊆ A, IsSidon (S : Set α) ∧ |
| 104 | + (A.card : ℝ) - (A.card.choose 2 : ℝ) / (p : ℝ) ^ 2 + |
| 105 | + 3 * (A.card.choose 3 : ℝ) / ((p : ℝ) ^ 4 * (M + ((A.card : ℝ) - 3) / (p : ℝ) ^ 2)) ≤ |
| 106 | + (p : ℝ) * S.card := by |
| 107 | + classical |
| 108 | + let W := ZMod p × ZMod p |
| 109 | + have : Finite (V →ₗ[ZMod p] W) := Module.finite_of_finite (ZMod p) |
| 110 | + let _ := Fintype.ofFinite (V →ₗ[ZMod p] W) |
| 111 | + have hnX : (A.image f).card = A.card := card_image_of_injOn hinj |
| 112 | + obtain ⟨L, hL⟩ := exists_projection_of_triple_span_bound (ZMod p) W (A.image f) |
| 113 | + (hnX.symm ▸ hn) M hM |
| 114 | + have hq : (Fintype.card W : ℝ) = (p : ℝ) ^ 2 := by simp [W, Fintype.card_prod, ZMod.card, sq] |
| 115 | + rw [hnX, hq, show ((p : ℝ) ^ 2) ^ 2 = (p : ℝ) ^ 4 by ring] at hL |
| 116 | + obtain ⟨S, hSA, hS, hcard⟩ := Erdos530PrimeField.exists_sidon_subset_of_plane_map_zmod hp |
| 117 | + A (fun a => L (f a)) (by |
| 118 | + intro a ha b hb c hc d hd habcd |
| 119 | + rw [← map_add, ← map_add, hf a ha b hb c hc d hd habcd]) |
| 120 | + refine ⟨S, hSA, hS, hL.trans ?_⟩ |
| 121 | + rw [image_image] |
| 122 | + exact_mod_cast hcard |
| 123 | + |
| 124 | +end ErdosSwarm.Erdos530TripleSpan |