| | @@ -0,0 +1,151 @@ |
| 1 | +import ErdosSwarm.Erdos530ConditionalProjection |
| 2 | +import ErdosSwarm.Erdos530ZModCount |
| 3 | +import Mathlib.Algebra.Order.BigOperators.Expect |
| 4 | +import Mathlib.Algebra.Group.Pointwise.Finset.Basic |
| 5 | +import Mathlib.Data.Real.Basic |
| 6 | + |
| 7 | +/-! |
| 8 | +# Sidon points in the fibres of a projection for Erdős problem 530 |
| 9 | + |
| 10 | +Every ordered pair of distinct points of a Sidon set in one fibre uses a different |
| 11 | +nonzero source difference killed by the projection. This bounds the benefit of |
| 12 | +keeping several points in a cell of a target template. For a uniform linear map, |
| 13 | +each nonzero source difference is killed with probability `1 / |W|`. |
| 14 | +-/ |
| 15 | + |
| 16 | +namespace ErdosSwarm.Erdos530KernelDifferences |
| 17 | + |
| 18 | +open Finset |
| 19 | +open scoped Pointwise BigOperators |
| 20 | + |
| 21 | +variable {V W : Type*} [AddCommGroup V] [AddCommGroup W] [DecidableEq V] [DecidableEq W] |
| 22 | + |
| 23 | +/-- Nonzero differences of points of `A` killed by `L`, counted without multiplicity. -/ |
| 24 | +def kernelDifferences (A : Finset V) (L : V →+ W) : Finset V := |
| 25 | + ((A - A).erase 0).filter fun d => L d = 0 |
| 26 | + |
| 27 | +/-- Ordered pairs of distinct Sidon points in the same fibre use distinct kernel differences. -/ |
| 28 | +theorem sum_fiber_card_mul_pred_le {A S : Finset V} (hSA : S ⊆ A) |
| 29 | + (hS : IsSidon (S : Set V)) (L : V →+ W) : |
| 30 | + (∑ y ∈ S.image L, let k := (S.filter fun x => L x = y).card |
| 31 | + k * (k - 1)) ≤ (kernelDifferences A L).card := by |
| 32 | + let pairs := S.offDiag.filter fun u => L u.1 = L u.2 |
| 33 | + have fiber (y : W) : pairs.filter (fun u => L u.1 = y) = |
| 34 | + (S.filter fun x => L x = y).offDiag := by |
| 35 | + ext u |
| 36 | + simp only [pairs, mem_filter, mem_offDiag] |
| 37 | + grind |
| 38 | + have count := card_eq_sum_card_fiberwise (s := pairs) (t := S.image L) |
| 39 | + (f := fun u => L u.1) (fun u hu => |
| 40 | + mem_image_of_mem L (mem_offDiag.mp (mem_filter.mp hu).1).1) |
| 41 | + simp_rw [fiber, offDiag_card, ← Nat.mul_sub_one] at count |
| 42 | + rw [← count] |
| 43 | + apply card_le_card_of_injOn (fun u => u.1 - u.2) |
| 44 | + · intro u hu |
| 45 | + obtain ⟨hp, heq⟩ := mem_filter.mp hu |
| 46 | + obtain ⟨ha, hb, hab⟩ := mem_offDiag.mp hp |
| 47 | + exact mem_filter.mpr ⟨mem_erase.mpr ⟨sub_ne_zero.mpr hab, sub_mem_sub (hSA ha) (hSA hb)⟩, |
| 48 | + (map_sub L _ _).trans (sub_eq_zero.mpr heq)⟩ |
| 49 | + · have hinj : (S.offDiag : Set (V × V)).InjOn (fun u => u.1 - u.2) := by |
| 50 | + simpa only [coe_offDiag] using sidon_injOn_sub_offDiag hS |
| 51 | + exact hinj.mono (filter_subset _ _) |
| 52 | + |
| 53 | +/-- Two directed differences are needed for each point in excess of one per occupied fibre. -/ |
| 54 | +theorem two_mul_excess_le {A S : Finset V} (hSA : S ⊆ A) (hS : IsSidon (S : Set V)) |
| 55 | + (L : V →+ W) : 2 * (S.card - (S.image L).card) ≤ (kernelDifferences A L).card := by |
| 56 | + let k (y : W) := (S.filter fun x => L x = y).card |
| 57 | + have step (n : ℕ) : 2 * n ≤ 2 + n * (n - 1) := by |
| 58 | + cases n with |
| 59 | + | zero => decide |
| 60 | + | succ n => |
| 61 | + cases n with |
| 62 | + | zero => decide |
| 63 | + | succ n => |
| 64 | + simp only [Nat.succ_sub_one] |
| 65 | + nlinarith |
| 66 | + have hcount : 2 * S.card ≤ 2 * (S.image L).card + ∑ y ∈ S.image L, k y * (k y - 1) := calc |
| 67 | + 2 * S.card = ∑ y ∈ S.image L, 2 * k y := by |
| 68 | + rw [← mul_sum, card_eq_sum_card_image L S] |
| 69 | + _ ≤ ∑ y ∈ S.image L, (2 + k y * (k y - 1)) := sum_le_sum fun y _ => step (k y) |
| 70 | + _ = _ := by simp [sum_add_distrib, mul_comm] |
| 71 | + have hpairs := sum_fiber_card_mul_pred_le hSA hS L |
| 72 | + change (∑ y ∈ S.image L, k y * (k y - 1)) ≤ _ at hpairs |
| 73 | + omega |
| 74 | + |
| 75 | +/-- The occupied cells of any target template control every Sidon subset above it. -/ |
| 76 | +theorem two_mul_card_le_of_image_subset {A S : Finset V} (hSA : S ⊆ A) |
| 77 | + (hS : IsSidon (S : Set V)) (L : V →+ W) {T : Finset W} (hST : S.image L ⊆ T) : |
| 78 | + 2 * S.card ≤ 2 * (A.image L ∩ T).card + (kernelDifferences A L).card := by |
| 79 | + have hI : S.image L ⊆ A.image L ∩ T := |
| 80 | + fun _ hy => mem_inter.mpr ⟨image_mono L hSA hy, hST hy⟩ |
| 81 | + have himage := card_le_card hI |
| 82 | + have hexcess := two_mul_excess_le hSA hS L |
| 83 | + omega |
| 84 | + |
| 85 | +/-- A target set may be chosen after the map. Its occupied cells and the killed differences |
| 86 | +bound the largest Sidon subset of its full preimage in `A`. -/ |
| 87 | +theorem maxSidonSubsetCard_preimage_le (A : Finset V) (L : V →+ W) (T : Finset W) : |
| 88 | + (A.filter fun x => L x ∈ T).maxSidonSubsetCard ≤ |
| 89 | + (A.image L ∩ T).card + (kernelDifferences A L).card / 2 := by |
| 90 | + unfold Finset.maxSidonSubsetCard |
| 91 | + apply Finset.sup_le |
| 92 | + intro S hS |
| 93 | + obtain ⟨hsub, hsid⟩ := mem_filter.mp hS |
| 94 | + have hST := mem_powerset.mp hsub |
| 95 | + have hSA := hST.trans (filter_subset _ _) |
| 96 | + have himage : S.image L ⊆ T := by |
| 97 | + intro y hy |
| 98 | + obtain ⟨x, hx, rfl⟩ := mem_image.mp hy |
| 99 | + exact (mem_filter.mp (hST hx)).2 |
| 100 | + have h := two_mul_card_le_of_image_subset hSA hsid L himage |
| 101 | + omega |
| 102 | + |
| 103 | +/-- Each nonzero difference is killed by a fraction `1 / |W|` of all linear maps. -/ |
| 104 | +theorem expect_card_kernelDifferences (F : Type*) [Field F] [Module F V] [Module F W] |
| 105 | + [Fintype W] [Fintype (V →ₗ[F] W)] (A : Finset V) : |
| 106 | + (𝔼 L : V →ₗ[F] W, ((kernelDifferences A L.toAddMonoidHom).card : ℝ)) = |
| 107 | + (((A - A).erase 0).card : ℝ) / Fintype.card W := by |
| 108 | + have kill (d : V) (hd : d ≠ 0) : |
| 109 | + (𝔼 L : V →ₗ[F] W, if L d = 0 then (1 : ℝ) else 0) = 1 / Fintype.card W := by |
| 110 | + rw [Fintype.expect_eq_sum_div_card, sum_boole, |
| 111 | + div_eq_div_iff (Nat.cast_ne_zero.mpr Fintype.card_ne_zero) |
| 112 | + (Nat.cast_ne_zero.mpr Fintype.card_ne_zero), one_mul, mul_comm] |
| 113 | + exact_mod_cast (by simpa only [map_zero] using |
| 114 | + (Erdos530ConditionalProjection.card_pair_collision (F := F) (W := W) hd) : |
| 115 | + Fintype.card W * (univ.filter fun L : V →ₗ[F] W => L d = 0).card = |
| 116 | + Fintype.card (V →ₗ[F] W)) |
| 117 | + have expand (L : V →ₗ[F] W) : ((kernelDifferences A L.toAddMonoidHom).card : ℝ) = |
| 118 | + ∑ d ∈ (A - A).erase 0, if L d = 0 then (1 : ℝ) else 0 := by |
| 119 | + change ((((A - A).erase 0).filter fun d => L d = 0).card : ℝ) = _ |
| 120 | + simp only [card_filter, Nat.cast_sum, Nat.cast_ite, Nat.cast_one, Nat.cast_zero] |
| 121 | + simp_rw [expand] |
| 122 | + rw [expect_sum_comm] |
| 123 | + calc |
| 124 | + _ = ∑ _d ∈ (A - A).erase 0, (1 : ℝ) / Fintype.card W := |
| 125 | + sum_congr rfl fun d hd => kill d (mem_erase.mp hd).1 |
| 126 | + _ = _ := by simp [div_eq_mul_inv] |
| 127 | + |
| 128 | +/-- Expected excess above the occupied target cells, even for a map-dependent template. |
| 129 | +Natural subtraction counts only positive excess. -/ |
| 130 | +theorem expect_excess_preimage_le (F : Type*) [Field F] [Module F V] [Module F W] |
| 131 | + [Fintype W] [Fintype (V →ₗ[F] W)] (A : Finset V) (T : (V →ₗ[F] W) → Finset W) : |
| 132 | + (𝔼 L : V →ₗ[F] W, (((A.filter fun x => L x ∈ T L).maxSidonSubsetCard - |
| 133 | + (A.image L ∩ T L).card : ℕ) : ℝ)) ≤ |
| 134 | + (((A - A).erase 0).card : ℝ) / (2 * Fintype.card W) := by |
| 135 | + let excess (L : V →ₗ[F] W) := |
| 136 | + (A.filter fun x => L x ∈ T L).maxSidonSubsetCard - (A.image L ∩ T L).card |
| 137 | + have point (L : V →ₗ[F] W) : 2 * excess L ≤ (kernelDifferences A L.toAddMonoidHom).card := by |
| 138 | + have h := maxSidonSubsetCard_preimage_le A L.toAddMonoidHom (T L) |
| 139 | + change (A.filter fun x => L x ∈ T L).maxSidonSubsetCard ≤ |
| 140 | + (A.image L ∩ T L).card + _ at h |
| 141 | + dsimp [excess] |
| 142 | + omega |
| 143 | + have havg : 2 * (𝔼 L : V →ₗ[F] W, (excess L : ℝ)) ≤ |
| 144 | + (((A - A).erase 0).card : ℝ) / Fintype.card W := by |
| 145 | + rw [mul_expect, ← expect_card_kernelDifferences (W := W) F A] |
| 146 | + exact expect_le_expect fun L _ => by exact_mod_cast point L |
| 147 | + change (𝔼 L : V →ₗ[F] W, (excess L : ℝ)) ≤ _ |
| 148 | + rw [mul_comm (2 : ℝ), ← div_div] |
| 149 | + linarith |
| 150 | + |
| 151 | +end ErdosSwarm.Erdos530KernelDifferences |