import Mathlib /-! # Large cap sets in `𝔽₃^8` (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 `𝔽₃^8` that is as large as possible. The score is its cardinality. The space `𝔽₃^8` is modelled as `Fin 8 → ZMod 3` (the same type as `𝔽₃ 8` in `FormalConjecturesForMathlib.Data.ZMod.Fp`). *References:* - Record (512 points): B. Romera-Paredes, M. Barekatain, A. Novikov, M. Balog, M. P. Kumar, E. Dupont, F. J. R. Ruiz, J. S. Ellenberg, P. Wang, O. Fawzi, P. Kohli and A. Fawzi, *Mathematical discoveries from program search with large language models*, Nature 625 (2024), 468–475, doi:10.1038/s41586-023-06924-6 (found by FunSearch; the previous best, 496, is from Y. Edel, *Extensions of generalized product caps*, Des. Codes Cryptogr. 31 (2004), 5–14). - Upper bound `771` (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 CapSetF3Dim8 /-- The solver's construction: a finite set of points of `𝔽₃^8` (`Fin 8 → ZMod 3`). This definition is the hole to fill. -/ def answerCap : Finset (Fin 8 → 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 8 → ZMod 3)) : Set (Fin 8 → ZMod 3)) := sorry /-- The score: replace the hole by a natural-number literal `N` and prove `N ≤ |answerCap|`. Higher is better (best known: 512). -/ theorem metric_bound : (sorry : ℕ) ≤ answerCap.card := sorry end CapSetF3Dim8