ordered_patterns_five_seven_card
The $5\times 7$ grid has exactly $2\binom52\binom72 = 420$ ordered coloured rectangle slots.
Statement
theorem ordered_patterns_five_seven_card : (ordered_patterns 5 7).card = 420- Source
- step towards grid_box_free_max_five_seven
- Verified
- 28 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- ordered_patternsThe finite set of ordered coloured rectangle patterns of an $a\times b$ grid, i.e. the patterns with $x_1<x_2$ and $y_1<y_2$. Its…
- 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…
- Used by 3
- grid_five_seven_fifty_one_at_most_six_unbalanced_layersA box-free five-by-seven-by-fifty-one binary coloring has at most six layers containing an unbalanced column.
- grid_five_seven_fifty_one_many_minimum_layersEvery box-free binary coloring of a five-by-seven-by-fifty-one grid has at least thirty-nine layers with exactly eight monochromatic…
- grid57_stack_at_most_fifty_twoEvery box-free binary coloring of a five-by-seven-by-n grid has at most 52 layers.
The proof, explained
The theorem states that there are exactly 420 ordered coloured rectangle slots in a $5 \times 7$ grid. Because the set of patterns is defined by filtering a finite product of `Fin` and `Bool` types with decidable inequalities, the cardinality assertion is decidable. The proof proceeds entirely by computational evaluation using the `decide` tactic, which exhaustively enumerates the valid configurations.
(ordered_patterns 5 7).card = 420 automation
The proposition is verified by finite computational reflection. Because `BoxPattern 5 7` is built from finite types (`Fin 5`, `Fin 7`, and `Bool`) and the filtering conditions ($r_1 < r_2$ and $c_1 < c_2$) are decidable, Lean evaluates the cardinality of the resulting finite set by exhaustive enumeration and verifies that it equals 420.
theorem ordered_patterns_five_seven_card : (ordered_patterns 5 7).card = 420 := by decide
- The proof relies on Lean's kernel evaluation to determine the cardinality by exhaustively testing all 2,450 candidate tuples in the product Fin 5 × Fin 5 × Fin 7 × Fin 7 × Bool. To accommodate this finite computation, execution limits (maxRecDepth and maxHeartbeats) are explicitly increased on lines 1–2.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
set_option maxRecDepth 10000set_option maxHeartbeats 1200000/-- There are 420 coloured rectangle slots in the $5\times 7$ grid. -/theorem ordered_patterns_five_seven_card : (ordered_patterns 5 7).card = 420 := by decide