AFTD Auto-Formalizing Theoretical Domains

grid_five_seven_fifty_two_witness_box_free

theoremverifiedoriginal

The explicit binary coloring with the specified 35 masks contains no monochromatic axis-parallel box anywhere in the five-by-seven-by-fifty-two grid.

Statement

theorem grid_five_seven_fifty_two_witness_box_free : grid_box_free (fun (x : Fin 5) (j : Fin 7) (z : Fin 52) => (grid_five_seven_fifty_two_layer_masks x j).testBit z.val)
Related work
arXiv:2611.19635, sections 5 and 6. OP-1867. Experiments 44354 and 44355 construct and independently check the order-three orbit packing.
Verified
28 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
  • grid_box_freeA 2-coloring $f : [a] \times [b] \times [c] \to \{0, 1\}$ is box-free if for all $x_1 < x_2 \le a$, $y_1 < y_2 \le b$, and…
  • grid_five_seven_fifty_two_layer_masksThe thirty-five cell masks of a fifty-two-layer box-free coloring. At row x and column j, bit z is the color in layer z. The coloring…
Used by 1

Read back from the Lean

The function $f : \text{Fin } 5 \to \text{Fin } 7 \to \text{Fin } 52 \to \text{Bool}$ defined by $f(x, j, z) = (\text{grid\_five\_seven\_fifty\_two\_layer\_masks}(x, j)).\text{testBit}(z.\text{val})$ is box-free. That is, for all $x_1, x_2 \in \text{Fin } 5$, $y_1, y_2 \in \text{Fin } 7$, and $z_1, z_2 \in \text{Fin } 52$, if $x_1 < x_2$, $y_1 < y_2$, and $z_1 < z_2$, then it is not the case that $f$ takes the same value at all eight corners of the box: $(x_1, y_1, z_1)$, $(x_1, y_2, z_1)$, $(x_2, y_1, z_1)$, $(x_2, y_2, z_1)$, $(x_1, y_1, z_2)$, $(x_1, y_2, z_2)$, $(x_2, y_1, z_2)$, and $(x_2, y_2, z_2)$.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

To show that the explicit 3D grid coloring has no monochromatic box, the proof first establishes a general certificate criterion (`grid57CertSound`): if for every pair of rows, pair of columns, and color, the bitwise AND of the four corresponding masks has population count at most 1 (encoded as being 0 or a power of 2), then no monochromatic box can exist, since two monochromatic layers would force two distinct set bits in that mask. The theorem `grid_five_seven_fifty_two_witness_box_free` then applies this criterion and closes the goal with `decide`, which exhaustively checks the condition across all 420 configurations by finite bitwise computation.

  1. Assume for contradiction that a monochromatic box exists, and fix its color.

    We introduce the box coordinates x < u in the first dimension, j < k in the second, and z < v in the third, along with hypotheses stating that all eight vertices of the box share the same color b, defined as the color at (x, j, z).

    lines 16–18

      intro x u j k z v hx hj hz hv
      obtain ⟨h₂,h₃,h₄,h₅,h₆,h₇,h₈⟩ := hv
      let b := (w x j).testBit z.val
  2. The color-selected mask has bit l set whenever the underlying word has color b at bit l.

    We establish a helper lemma `selected`: if bit l of a word a equals `color`, then bit l of `grid57ColorBits n a color` is true. The proof proceeds by case analysis on whether `color` is true or false, simplifying the conditional and bitwise complement definitions using l < n.

    lines 19–21

      have selected (a : ℕ) (l : Fin n) (color : Bool) (ha : a.testBit l.val = color) :
          (grid57ColorBits n a color).testBit l.val = true := by
        cases color <;> simp [grid57ColorBits, ha, l.isLt]
  3. The slot mask has bit l set whenever all four corner vertices at layer l share color b.

    We establish a helper lemma `hit`: unfolding the definition of `grid57SlotBits` and rewriting the bitwise AND with `Nat.testBit_and`, each of the four corner terms evaluates to true via `selected`, so their conjunction is true by `Bool.and_self`.

    lines 22–26

    uses Nat.testBit_and, Bool.and_self

      have hit (l : Fin n) (ha : (w x j).testBit l.val = b) (hb : (w x k).testBit l.val = b)
          (hd : (w u j).testBit l.val = b) (he : (w u k).testBit l.val = b) :
          (grid57SlotBits n w x u j k b).testBit l.val = true := by
        simp only [grid57SlotBits, Nat.testBit_and, selected _ l b ha, selected _ l b hb,
          selected _ l b hd, selected _ l b he, Bool.and_self]
  4. The slot mask has both its z-th and v-th bits set to true.

    Applying the helper lemma `hit` at layer z using the monochromaticity of the four corner vertices at depth z yields that bit z of the slot mask is true. Applying `hit` similarly at layer v yields that bit v is also true.

    lines 27–28

      have h₁ := hit z rfl h₂.symm h₃.symm h₄.symm
      have h₂' := hit v h₅.symm h₆.symm h₇.symm h₈.symm
  5. Both cases of the certificate condition yield a contradiction.

    The certificate hypothesis `hc` asserts that the slot mask m is either 0 or a power of 2. If m = 0, its z-th bit cannot be true, contradicting that bit z is set. If m = 2^k, rewriting with `Nat.testBit_two_pow` and `decide_eq_true_eq` forces both z and v to equal the unique set bit index k = ⌊log₂ m⌋, so z = v. But z < v implies z ≠ v by `Nat.ne_of_lt`, yielding a contradiction in both branches.

    lines 29–33

    uses Nat.testBit_two_pow, decide_eq_true_eq, Nat.ne_of_lt

      rcases hc x u j k b hx hj with h | h
      · rw [h] at h₁
        simp at h₁
      · rw [h, Nat.testBit_two_pow, decide_eq_true_eq] at h₁ h₂'
        exact (Nat.ne_of_lt hz) (h₁.symm.trans h₂')
  6. The explicit coloring on the 5 × 7 × 52 grid contains no monochromatic box. automation

    Applying the certificate soundness theorem `grid57CertSound` reduces the box-freeness goal to verifying that all slot bitmasks are either 0 or a power of 2. The `decide` tactic checks this condition exhaustively for all (5 choose 2) × (7 choose 2) × 2 = 420 configurations by direct computation on the concrete 52-bit masks.

    lines 36–37

    uses grid57CertSound

      apply grid57CertSound
      decide
Nat.testBit_and
The i-th bit of the bitwise AND of two natural numbers is the boolean AND of their respective i-th bits: (x &&& y).testBit i = (x.testBit i && y.testBit i).
Bool.and_self
The boolean conjunction of any boolean value with itself equals that value: b && b = b.
Nat.testBit_two_pow
The m-th bit of 2^n is true if and only if m = n.
decide_eq_true_eq
For any decidable proposition p, the boolean decision decide p equals true if and only if p holds.
Nat.ne_of_lt
If a natural number is strictly less than another, then the two numbers are not equal.
grid57CertSound
For any grid mask configuration of depth n, if every row pair, column pair, and color yields a slot bitmask that is either 0 or a power of 2, then the resulting 3D grid coloring contains no monochromatic box.

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 6000set_option maxHeartbeats 1500000private def grid57ColorBits (n w : ℕ) (b : Bool) : ℕ :=  if b then w else w ^^^ (2^n - 1)private def grid57SlotBits (n : ℕ) (w : Fin 5 → Fin 7 → ℕ) (x u : Fin 5) (j k : Fin 7) (b : Bool) : ℕ :=  grid57ColorBits n (w x j) b &&& grid57ColorBits n (w x k) b &&&  grid57ColorBits n (w u j) b &&& grid57ColorBits n (w u k) bprivate theorem grid57CertSound {n : ℕ} (w : Fin 5 → Fin 7 → ℕ)    (hc : ∀ x u : Fin 5, ∀ j k : Fin 7, ∀ b : Bool, x < u → j < k →      let m := grid57SlotBits n w x u j k b      m = 0 ∨ m = 2 ^ m.log2) :    grid_box_free (fun x j (z : Fin n) => (w x j).testBit z.val) := by  intro x u j k z v hx hj hz hv  obtain ⟨h₂,h₃,h₄,h₅,h₆,h₇,h₈⟩ := hv  let b := (w x j).testBit z.val  have selected (a : ℕ) (l : Fin n) (color : Bool) (ha : a.testBit l.val = color) :      (grid57ColorBits n a color).testBit l.val = true := by    cases color <;> simp [grid57ColorBits, ha, l.isLt]  have hit (l : Fin n) (ha : (w x j).testBit l.val = b) (hb : (w x k).testBit l.val = b)      (hd : (w u j).testBit l.val = b) (he : (w u k).testBit l.val = b) :      (grid57SlotBits n w x u j k b).testBit l.val = true := by    simp only [grid57SlotBits, Nat.testBit_and, selected _ l b ha, selected _ l b hb,      selected _ l b hd, selected _ l b he, Bool.and_self]  have h₁ := hit z rfl h₂.symm h₃.symm h₄.symm  have h₂' := hit v h₅.symm h₆.symm h₇.symm h₈.symm  rcases hc x u j k b hx hj with h | h  · rw [h] at h₁    simp at h₁  · rw [h, Nat.testBit_two_pow, decide_eq_true_eq] at h₁ h₂'    exact (Nat.ne_of_lt hz) (h₁.symm.trans h₂')theorem grid_five_seven_fifty_two_witness_box_free : grid_box_free (fun (x : Fin 5) (j : Fin 7) (z : Fin 52) => (grid_five_seven_fifty_two_layer_masks x j).testBit z.val) := by  apply grid57CertSound  decide
See it in the graphDiscuss this resultChallenge it