| | @@ -0,0 +1,89 @@ |
| 1 | +import ErdosSwarm.Erdos530ProjectionMoments |
| 2 | +import Mathlib.Algebra.Field.ZMod |
| 3 | +import Mathlib.LinearAlgebra.Dual.Lemmas |
| 4 | + |
| 5 | +/-! |
| 6 | +# Affine spans in coordinate boxes for Erdős problem 530 |
| 7 | + |
| 8 | +A finite set with at most `b` values in each coordinate has at most `b ^ d` |
| 9 | +points in any affine subspace of dimension `d`. In particular the affine span |
| 10 | +of a triple meets any subset of the eight-digit box in at most 64 points. |
| 11 | +This is the geometric input to the box bound in §2 of |
| 12 | +`experiments/erdos530/lower-middle-energy2/box-occupancy/NOTES.md`. |
| 13 | +-/ |
| 14 | + |
| 15 | +namespace ErdosSwarm.Erdos530BoxSpan |
| 16 | + |
| 17 | +open Finset Erdos530ProjectionMoments |
| 18 | +open scoped Classical |
| 19 | + |
| 20 | +variable {F ι : Type*} [Field F] [Fintype ι] [DecidableEq F] |
| 21 | + |
| 22 | +/-- The intersection of a coordinate box of width `b` with an affine |
| 23 | +subspace of dimension `d` has at most `b ^ d` points. Each coordinate |
| 24 | +may have a different set of allowed values. -/ |
| 25 | +theorem card_filter_affineSubspace_le (X : Finset (ι → F)) (P : AffineSubspace F (ι → F)) |
| 26 | + {b : ℕ} (hb : 0 < b) (hX : ∀ i, (X.image fun x => x i).card ≤ b) : |
| 27 | + (X.filter fun x => x ∈ P).card ≤ b ^ Module.finrank F P.direction := by |
| 28 | + let coord (i : ι) : Module.Dual F P.direction := (LinearMap.proj i).domRestrict P.direction |
| 29 | + -- These coordinates span all the coordinate functionals on the direction space. |
| 30 | + obtain ⟨κ, j, hj, hspan, hli⟩ := exists_linearIndependent' F coord |
| 31 | + let : Finite κ := Finite.of_injective j hj |
| 32 | + let _ := Fintype.ofFinite κ |
| 33 | + have hrank : Fintype.card κ ≤ Module.finrank F P.direction := |
| 34 | + hli.fintype_card_le_finrank.trans_eq Subspace.dual_finrank_eq |
| 35 | + let points := X.filter fun x => x ∈ P |
| 36 | + let values (k : κ) := X.image fun x => x (j k) |
| 37 | + let restrict (x : points) (k : κ) : values k := |
| 38 | + ⟨x.val (j k), mem_image_of_mem _ (mem_filter.mp x.property).1⟩ |
| 39 | + have hinj : Function.Injective restrict := by |
| 40 | + intro x y h |
| 41 | + let z : P.direction := ⟨x.val - y.val, AffineSubspace.vsub_mem_direction |
| 42 | + (mem_filter.mp x.property).2 (mem_filter.mp y.property).2⟩ |
| 43 | + -- If the selected coordinates vanish on the difference, every coordinate does. |
| 44 | + have hker : Submodule.span F (Set.range coord) ≤ (LinearMap.applyₗ z).ker := by |
| 45 | + rw [← hspan, Submodule.span_le] |
| 46 | + rintro _ ⟨k, rfl⟩ |
| 47 | + exact sub_eq_zero.mpr (congrArg Subtype.val (congrFun h k)) |
| 48 | + apply Subtype.ext |
| 49 | + funext i |
| 50 | + exact sub_eq_zero.mp (hker (Submodule.subset_span (Set.mem_range_self i))) |
| 51 | + calc |
| 52 | + points.card ≤ Fintype.card ((k : κ) → values k) := by |
| 53 | + simpa only [Fintype.card_coe] using Fintype.card_le_of_injective restrict hinj |
| 54 | + _ = ∏ k : κ, (values k).card := by simp only [Fintype.card_pi, Fintype.card_coe] |
| 55 | + _ ≤ ∏ _k : κ, b := Finset.prod_le_prod' fun k _ => hX (j k) |
| 56 | + _ = b ^ Fintype.card κ := by simp |
| 57 | + _ ≤ b ^ Module.finrank F P.direction := Nat.pow_le_pow_right hb hrank |
| 58 | + |
| 59 | +/-- The affine span of three points has dimension at most two, including |
| 60 | +when the points are collinear. -/ |
| 61 | +theorem spanCount_le_sq_of_coord_card {X T : Finset (ι → F)} {b : ℕ} |
| 62 | + (hb : 0 < b) (hX : ∀ i, (X.image fun x => x i).card ≤ b) (hT : T ∈ X.powersetCard 3) : |
| 63 | + spanCount F X T ≤ b ^ 2 := by |
| 64 | + refine (card_filter_affineSubspace_le X (affineSpan F (T : Set (ι → F))) hb hX).trans |
| 65 | + (Nat.pow_le_pow_right hb ?_) |
| 66 | + rw [direction_affineSpan, ← @Subtype.range_coe _ (T : Set (ι → F))] |
| 67 | + apply finrank_vectorSpan_range_le |
| 68 | + calc |
| 69 | + _ = Fintype.card ↥T := Fintype.card_congr (Equiv.refl ↥T) |
| 70 | + _ = T.card := Fintype.card_coe T |
| 71 | + _ = 2 + 1 := (mem_powersetCard.mp hT).2 |
| 72 | + |
| 73 | +/-- In particular, the bound is 64 for any subset of the modular eight-digit |
| 74 | +box in any finite number of coordinates. -/ |
| 75 | +theorem spanCount_le_64_of_digit_box {p : ℕ} [Fact p.Prime] {X T : Finset (ι → ZMod p)} |
| 76 | + (hbox : ∀ x ∈ X, ∀ i, (x i).val < 8) (hT : T ∈ X.powersetCard 3) : |
| 77 | + spanCount (ZMod p) X T ≤ 64 := by |
| 78 | + apply spanCount_le_sq_of_coord_card (b := 8) (by decide) _ hT |
| 79 | + intro i |
| 80 | + calc |
| 81 | + (X.image fun x => x i).card ≤ ((range 8).image fun n : ℕ => (n : ZMod p)).card := by |
| 82 | + apply card_le_card |
| 83 | + rintro y hy |
| 84 | + obtain ⟨x, hx, rfl⟩ := mem_image.mp hy |
| 85 | + exact mem_image.mpr ⟨(x i).val, mem_range.mpr (hbox x hx i), ZMod.natCast_zmod_val _⟩ |
| 86 | + _ ≤ (range 8).card := card_image_le |
| 87 | + _ = 8 := card_range _ |
| 88 | + |
| 89 | +end ErdosSwarm.Erdos530BoxSpan |