import Mathlib /-! # Large cap sets in `𝔽₃^7` (record challenge, maximize) A *cap set* in the affine space `𝔽₃ⁿ` is a set of points no three of which are collinear. In `𝔽₃ⁿ` a line has exactly three points `x, x + d, x + 2d` (`d ≠ 0`), and three distinct points `x, y, z` are collinear iff `x + y + z = 0`. So a cap set is exactly a set with no non-trivial 3-term arithmetic progression, i.e. Mathlib's `ThreeAPFree` (`a + c = b + b → a = b`). The equivalence of `ThreeAPFree` with "no three distinct collinear points" (Mathlib's `Collinear` over the field `ZMod 3`), with "no pairwise distinct `x, y, z` with `x + y + z = 0`" and with "contains no line `{x, x + d, x + 2 • d}`" is proved in `Tests.lean` (`threeAPFree_iff_no_collinear`, `threeAPFree_iff_no_distinct_sum_zero`, `threeAPFree_iff_no_line`). Task: give a cap set in `𝔽₃^7` that is as large as possible. The score is its cardinality. The space `𝔽₃^7` is modelled as `Fin 7 → ZMod 3` (the same type as `𝔽₃ 7` in `FormalConjecturesForMathlib.Data.ZMod.Fp`). *References:* - Record (236 points): A. R. Calderbank and P. C. Fishburn, *Maximal three-independent subsets of {0,1,2}^n*, Des. Codes Cryptogr. 4 (1994), 203–211, doi:10.1007/BF01388452. - Upper bound `291` (computer-assisted, unrefereed): N. D. Versluis, *On the cap set problem: upper bounds on maximal cardinalities of caps in dimensions seven to ten*, Bachelor thesis, TU Delft, 2017. The exact maximum is known only for `n ≤ 6` (`112` for `n = 6`: A. Potechin, *Maximal caps in AG(6,3)*, Des. Codes Cryptogr. 46 (2008), 243–259). - Mathlib: `ThreeAPFree`, `Mathlib/Combinatorics/Additive/AP/Three/Defs.lean`. -/ namespace CapSetF3Dim7 /-- The solver's construction: a finite set of points of `𝔽₃^7` (`Fin 7 → ZMod 3`). This definition is the hole to fill. -/ def answerCap : Finset (Fin 7 → ZMod 3) := sorry /-- `answerCap` is a cap set: no three distinct points of it lie on a line, stated with Mathlib's `ThreeAPFree` (for all `a b c ∈ answerCap`, `a + c = b + b → a = b`). -/ theorem correct : ThreeAPFree ((answerCap : Finset (Fin 7 → ZMod 3)) : Set (Fin 7 → ZMod 3)) := sorry /-- The score: replace the hole by a natural-number literal `N` and prove `N ≤ |answerCap|`. Higher is better (best known: 236). -/ theorem metric_bound : (sorry : ℕ) ≤ answerCap.card := sorry end CapSetF3Dim7