grid57_pair_cost_matches_rectangles
The stored pair-cost table gives exactly the number of monochromatic rectangles formed by the two displayed five-bit columns.
Statement
theorem grid57_pair_cost_matches_rectangles (a b : Fin 32) : grid57_pair_cost a b = ((Finset.univ : Finset (Fin 5 × Fin 5)).filter (fun p => p.1 < p.2 ∧ a.val.testBit p.1.val = a.val.testBit p.2.val ∧ a.val.testBit p.1.val = b.val.testBit p.1.val ∧ a.val.testBit p.1.val = b.val.testBit p.2.val)).card
- Source
- OP-1867: sorted-column finite obstruction computed in experiments 43999 and 44004–44005; related work arXiv:2611.19635 section 6.
- Verified
- 28 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- grid57_pair_costAn explicit table of monochromatic rectangle counts determined by two five-bit columns.
The proof, explained
The theorem establishes that the hardcoded lookup table `grid57_pair_cost a b` correctly computes the number of monochromatic rectangles spanning two 5-bit columns $a$ and $b$. Because the domain $\text{Fin } 32 \times \text{Fin } 32$ contains only $1024$ pairs, the statement is a decidable proposition over a finite type. The proof universally quantifies over all pairs and verifies the identity by exhaustive computation using the `decide` tactic.
For all 5-bit columns $a, b \in \text{Fin } 32$, the table lookup `grid57_pair_cost a b` equals the number of monochromatic rectangles formed by columns $a$ and $b$. automation
The claim is universally quantified over all pairs of columns $a, b \in \text{Fin } 32$ and verified by exhaustive finite computation. Since each column is a 5-bit integer, there are only $32 \times 32 = 1024$ pairs of columns. For each pair, both the bit-packed table extraction in `grid57_pair_cost` and the count of pairs of rows $(p_1, p_2)$ with $p_1 < p_2$ having identical bits across both columns are entirely computable, allowing Lean's `decide` tactic to verify the identity by evaluation.
revert a b decide
- The tactic `revert a b` is a formal proof artifact with no paper counterpart: it moves the free variables $a$ and $b$ back into a universal quantifier `∀ (a b : Fin 32)` so that Lean can synthesize a `Decidable` instance for the closed proposition and evaluate it by computation.
- The `decide` tactic evaluates all $32 \times 32 = 1024$ cases directly in the kernel without producing intermediate proof steps.
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.
theorem grid57_pair_cost_matches_rectangles (a b : Fin 32) : grid57_pair_cost a b = ((Finset.univ : Finset (Fin 5 × Fin 5)).filter (fun p => p.1 < p.2 ∧ a.val.testBit p.1.val = a.val.testBit p.2.val ∧ a.val.testBit p.1.val = b.val.testBit p.1.val ∧ a.val.testBit p.1.val = b.val.testBit p.2.val)).card := by revert a b decide