AFTD Auto-Formalizing Theoretical Domains

layer_mono_five_seven_ge_eight

theoremverified

Every $2$-colouring of the $5\times 7$ grid contains at least $8$ monochromatic rectangles, counting both colours: $\rho(5,7) \ge 8$. Combined with the layer bound this yields $N(5,7)\le 52$.

Statement

theorem layer_mono_five_seven_ge_eight (h : Fin 5 → Fin 7 → Bool) : 8 ≤ (layer_mono (fun x y (_ : Fin 1) => h x y) 0).card
Source
step towards grid_box_free_max_five_seven
Verified
28 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 5
  • layer_monoFor a $2$-colouring $f$ of $[a]\times[b]\times[c]$ and a layer index $z$, $\mathrm{layer\_mono}(f,z)$ is the finite set of coloured…
  • grid57_column_agreementsThe number of agreeing unordered row pairs in a column of a binary five-by-seven layer.
  • grid57_agreements_le_rectangles_add_twentyThe total column agreements are at most the number of monochromatic rectangles plus twenty.
  • BoxPatternA coloured rectangle pattern in an $a\times b$ grid: a pair of rows $x_1<x_2$, a pair of columns $y_1<y_2$, and a colour, encoded as the…
  • cFor a group $G$ and an element $s \in G$, the local count $c_G(s)$ is the cardinality of the set of elements $g \in G$ such that…
Used by 3

The proof, explained

To show that every 2-colouring of the $5 \times 7$ grid contains at least 8 monochromatic rectangles, the proof double-counts monochromatic pairs of cells in each column. First, a pigeonhole argument (verified by exhaustive check over all $2^5 = 32$ boolean 5-tuples) shows that every column of length 5 has at least 4 agreeing pairs of rows, giving at least $7 \times 4 = 28$ agreements across the 7 columns. Combining this lower bound with the known upper bound that total column agreements cannot exceed the number of monochromatic rectangles plus 20, linear arithmetic establishes that there are at least $28 - 20 = 8$ monochromatic rectangles.

  1. Any boolean 5-tuple has at least 4 pairs of matching entries.

    We define `count g` to be the number of pairs $i < j$ in $\{0, 1, 2, 3, 4\}$ where $g(i) = g(j)$. By exhaustive evaluation of all $2^5 = 32$ possible boolean 5-tuples (`decide`), Lean verifies that every 5-tuple satisfies $4 \le \text{count} ![a, b, c, d, e]$, matching the pigeonhole bound $\binom{3}{2} + \binom{2}{2} = 4$.

    lines 6–10

      let count (g : Fin 5 → Bool) := ((Finset.univ : Finset (Fin 5 × Fin 5)).filter
        (fun p => p.1 < p.2 ∧ g p.1 = g p.2)).card
      have columns : ∀ a b c d e : Bool, 4 ≤ count ![a,b,c,d,e] := by
        unfold count
        decide
  2. Every column of a $5 \times 7$ grid contains at least 4 monochromatic pairs of cells.

    We define $\text{col}$ to be the $j$-th column $i \mapsto f(i, j)$. By function extensionality (`funext`) and finite case exhaustion on $\text{Fin } 5$ (`fin_cases`), $\text{col}$ equals the explicit 5-tuple of its entries. Rewriting by this equality allows us to apply the 5-tuple bound from the previous step, establishing $4 \le \text{grid57_column_agreements } f\ j$.

    lines 11–17

      let col : Fin 5 → Bool := fun i => f i j
      have hcol : col = ![col 0,col 1,col 2,col 3,col 4] := by
        funext x
        fin_cases x <;> rfl
      change 4 ≤ count col
      rw [hcol]
      apply columns
  3. The sum of column agreements across all 7 columns is at least 28.

    We sum the per-column lower bound $4 \le \text{grid57_column_agreements } h\ j$ over all $j \in \text{Fin } 7$ using `Finset.sum_le_sum`. Since the grid has 7 columns, the sum of 4 over all columns simplifies (`simpa`) to $7 \times 4 = 28$.

    lines 21–22

    uses Finset.sum_le_sum, grid57EachColumnFour

      have hsum := Finset.sum_le_sum (s := Finset.univ) (fun j _ => grid57EachColumnFour h j)
      have low : 28 ≤ ∑ j, grid57_column_agreements h j := by simpa using hsum
  4. The grid contains at least 8 monochromatic rectangles.

    We invoke `grid57_agreements_le_rectangles_add_twenty`, which bounds the total number of column agreements from above by the number of monochromatic rectangles plus 20. Combining this with the lower bound of 28 from the previous step, linear integer arithmetic (`omega`) deduces that the number of monochromatic rectangles is at least $28 - 20 = 8$.

    lines 23–24

    uses grid57_agreements_le_rectangles_add_twenty

      have high := grid57_agreements_le_rectangles_add_twenty h
      omega
Finset.sum_le_sum
If $f(i) \le g(i)$ for all elements $i$ in a finite set $s$, then the sum of $f$ over $s$ is at most the sum of $g$ over $s$.
grid57EachColumnFour
In any 2-colouring of a $5 \times 7$ grid, each column contains at least 4 pairs of rows with the same colour.
grid57_agreements_le_rectangles_add_twenty
For any 2-colouring of a $5 \times 7$ grid, the sum over all columns of the number of agreeing row pairs is at most the number of monochromatic rectangles plus 20.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

set_option maxRecDepth 10000set_option maxHeartbeats 1200000private theorem grid57EachColumnFour (f : Fin 5 → Fin 7 → Bool) (j : Fin 7) :    4 ≤ grid57_column_agreements f j := by  let count (g : Fin 5 → Bool) := ((Finset.univ : Finset (Fin 5 × Fin 5)).filter    (fun p => p.1 < p.2 ∧ g p.1 = g p.2)).card  have columns : ∀ a b c d e : Bool, 4 ≤ count ![a,b,c,d,e] := by    unfold count    decide  let col : Fin 5 → Bool := fun i => f i j  have hcol : col = ![col 0,col 1,col 2,col 3,col 4] := by    funext x    fin_cases x <;> rfl  change 4 ≤ count col  rw [hcol]  apply columns/-- $\rho(5,7)\ge 8$: every $5\times7$ layer has at least 8 monochromatic rectangles (both colours counted). -/theorem layer_mono_five_seven_ge_eight (h : Fin 5 → Fin 7 → Bool) : 8 ≤ (layer_mono (fun x y (_ : Fin 1) => h x y) 0).card := by  have hsum := Finset.sum_le_sum (s := Finset.univ) (fun j _ => grid57EachColumnFour h j)  have low : 28 ≤ ∑ j, grid57_column_agreements h j := by simpa using hsum  have high := grid57_agreements_le_rectangles_add_twenty h  omega
See it in the graphDiscuss this resultChallenge it