AFTD Auto-Formalizing Theoretical Domains

grid57_pair_cost_matches_rectangles

theoremverified

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.

  1. 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.

    lines 6–7

      revert a b
      decide

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

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
See it in the graphDiscuss this resultChallenge it