grid_five_seven_fifty_one_at_most_six_unbalanced_layers
A box-free five-by-seven-by-fifty-one binary coloring has at most six layers containing an unbalanced column.
Statement
theorem grid_five_seven_fifty_one_at_most_six_unbalanced_layers (f : Fin 5 → Fin 7 → Fin 51 → Bool) (hf : grid_box_free f) : ((Finset.univ : Finset (Fin 51)).filter (fun z => ∃ y : Fin 7, let ones := ((Finset.univ : Finset (Fin 5)).filter (fun x => f x y z = true)).card; ones ≠ 2 ∧ ones ≠ 3)).card ≤ 6
- Source
- OP-1867: layer-packing slack and balanced-column bound, related to arXiv:2611.19635 section 6.
- Verified
- 28 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 8
- 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…
- 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…
- layer_mono_card_sum_leLayer bound (Lemma 4.1 core): for a box-free colouring of $[a]\times[b]\times[c]$, the total number of monochromatic rectangles summed…
- layer_mono_five_seven_ge_eightEvery $2$-colouring of the $5\times 7$ grid contains at least $8$ monochromatic rectangles, counting both colours: $\rho(5,7) \ge 8$.…
- ordered_patterns_five_seven_cardThe $5\times 7$ grid has exactly $2\binom52\binom72 = 420$ ordered coloured rectangle slots.
- grid_five_seven_nine_rectangles_balanced_columnsIn every binary five-by-seven layer with at most nine monochromatic rectangles, each column contains exactly two or three true entries.
- 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…
- 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…
The proof, explained
The proof double-counts the total number of monochromatic rectangles across all 51 layers of the grid. Because the coloring contains no monochromatic 3D boxes, each monochromatic rectangle pattern can appear at most once across the entire grid, bounding the total rectangle count from above by 420. On the other hand, every layer with an unbalanced column has at least 10 monochromatic rectangles, while every other layer has at least 8; this yields the lower bound 10|U| + 8(51 - |U|) ≤ 420, which simplifies to |U| ≤ 6.
The 51 layers are partitioned into the set U of unbalanced layers and its complement of size 51 - |U|, splitting the total rectangle sum accordingly.
We define U to be the set of layers z ∈ {0, …, 50} containing an unbalanced column (where the number of ones is neither 2 nor 3). Since U is formed by filtering, U ⊆ Finset.univ by Finset.filter_subset. Splitting the sum of monochromatic rectangles across U and its complement (Finset.sum_sdiff) gives ∑_{z ∉ U} |layer_mono(f, z)| + ∑_{z ∈ U} |layer_mono(f, z)| = ∑_z |layer_mono(f, z)|. By Finset.card_sdiff_of_subset, the number of balanced layers is |univ \ U| = 51 - |U|.
uses
Finset.filter_subset,Finset.sum_sdiff,Finset.card_sdiff_of_subsetset U := (Finset.univ : Finset (Fin 51)).filter (fun z => ∃ y : Fin 7, let ones := ((Finset.univ : Finset (Fin 5)).filter (fun x => f x y z = true)).card; ones ≠ 2 ∧ ones ≠ 3) have hU_sub : U ⊆ Finset.univ := Finset.filter_subset _ _ have h_split : ∑ z ∈ Finset.univ \ U, (layer_mono f z).card + ∑ z ∈ U, (layer_mono f z).card = ∑ z : Fin 51, (layer_mono f z).card := Finset.sum_sdiff hU_sub have h_card_sdiff : (Finset.univ \ U).card = 51 - U.card := by rw [Finset.card_sdiff_of_subset hU_sub] simp
Every unbalanced layer z ∈ U contains at least 10 monochromatic rectangles.
Suppose, for contradiction, that some layer z ∈ U has fewer than 10 monochromatic rectangles, hence at most 9. By grid_five_seven_nine_rectangles_balanced_columns, any 5 × 7 binary coloring with at most 9 monochromatic rectangles must have balanced columns (every column has 2 or 3 ones). But by definition of z ∈ U (Finset.mem_filter), layer z contains a column y with a count of ones that is neither 2 nor 3, a contradiction.
uses
Finset.mem_filter,grid_five_seven_nine_rectangles_balanced_columnshave h_ge_ten : ∀ z ∈ U, 10 ≤ (layer_mono f z).card := by intro z hz rw [Finset.mem_filter] at hz rcases hz with ⟨-, hz⟩ by_contra! h have h_slice : (layer_mono (fun x y (_ : Fin 1) => f x y z) 0).card ≤ 9 := by change (layer_mono f z).card ≤ 9 omega have h_bal := grid_five_seven_nine_rectangles_balanced_columns (fun x y => f x y z) h_slice rcases hz with ⟨y, hy⟩ have hy_bal := h_bal y rcases hy_bal with h2 | h3 · exact hy.1 h2 · exact hy.2 h3
Every layer in univ \ U contains at least 8 monochromatic rectangles.
By layer_mono_five_seven_ge_eight, every binary coloring of a 5 × 7 grid contains at least 8 monochromatic rectangles, which applies to each layer in the complement of U.
uses
layer_mono_five_seven_ge_eighthave h_ge_eight : ∀ z ∈ Finset.univ \ U, 8 ≤ (layer_mono f z).card := by intro z _ exact layer_mono_five_seven_ge_eight (fun x y => f x y z)
The sum of rectangle counts over U is at least 10|U|, and over univ \ U is at least 8(51 - |U|).
Summing the lower bound of 10 over all layers in U gives 10|U| ≤ ∑_{z ∈ U} |layer_mono(f, z)| via Finset.card_nsmul_le_sum and nsmul_eq_mul. Likewise, summing the lower bound of 8 over the 51 - |U| balanced layers gives 8(51 - |U|) ≤ ∑_{z ∉ U} |layer_mono(f, z)|.
uses
Finset.card_nsmul_le_sum,nsmul_eq_mulhave h_sum_U : U.card * 10 ≤ ∑ z ∈ U, (layer_mono f z).card := by have := Finset.card_nsmul_le_sum U (fun z => (layer_mono f z).card) 10 h_ge_ten simpa [nsmul_eq_mul] using this have h_sum_sdiff : (Finset.univ \ U).card * 8 ≤ ∑ z ∈ Finset.univ \ U, (layer_mono f z).card := by have := Finset.card_nsmul_le_sum (Finset.univ \ U) (fun z => (layer_mono f z).card) 8 h_ge_eight simpa [nsmul_eq_mul] using this
The total number of monochromatic rectangles across all 51 layers is at most 420.
Because f is box-free (grid_box_free), no two layers can contain the same monochromatic rectangle with the same color; hence the sum of rectangle counts over all layers cannot exceed the total number of ordered rectangle patterns (layer_mono_card_sum_le). Since there are 420 such patterns on a 5 × 7 grid (ordered_patterns_five_seven_card), the total sum is at most 420.
uses
layer_mono_card_sum_le,ordered_patterns_five_seven_cardhave h_total_le : ∑ z : Fin 51, (layer_mono f z).card ≤ 420 := by have h1 := layer_mono_card_sum_le f hf have h2 := ordered_patterns_five_seven_card omega
The set U satisfies |U| ≤ 51.
Since U is a subset of the 51 layers of the grid, its cardinality is at most 51 by Finset.card_le_card.
uses
Finset.card_le_cardhave h_card_le : U.card ≤ 51 := by have := Finset.card_le_card hU_sub simpa using this
At most 6 layers have an unbalanced column: |U| ≤ 6.
Combining the bounds gives 10|U| + 8(51 - |U|) ≤ ∑_z |layer_mono(f, z)| ≤ 420, which simplifies to 408 + 2|U| ≤ 420, or 2|U| ≤ 12. Thus |U| ≤ 6, which Lean's linear arithmetic procedure (omega) concludes from the collected inequalities.
omega
Finset.filter_subset- Filtering a finite set by a predicate yields a subset of the original set.
Finset.sum_sdiff- The sum of a function over a finite set splits into the sum over a subset and the sum over its set difference complement.
Finset.card_sdiff_of_subset- For finite sets s ⊆ t, the cardinality of t \ s is |t| - |s|.
Finset.mem_filter- An element belongs to a filtered set if and only if it belongs to the base set and satisfies the filtering predicate.
grid_five_seven_nine_rectangles_balanced_columns- Any binary coloring of a 5 × 7 grid with at most 9 monochromatic rectangles has balanced columns (every column contains exactly 2 or 3 ones).
layer_mono_five_seven_ge_eight- Any binary coloring of a 5 × 7 grid contains at least 8 monochromatic rectangles.
Finset.card_nsmul_le_sum- If every term in a sum over a finite set s is bounded below by a constant c, then the sum is bounded below by c · |s|.
nsmul_eq_mul- Scalar multiplication of a natural number by an element in a semiring equals their ordinary product.
layer_mono_card_sum_le- In a box-free 3D grid coloring, the sum across all layers of the monochromatic rectangle counts cannot exceed the total number of ordered rectangle patterns.
ordered_patterns_five_seven_card- There are exactly 420 monochromatic rectangle patterns on a 5 × 7 grid.
Finset.card_le_card- If a finite set s is a subset of t, then |s| ≤ |t|.
- In lines 15–16 and 26, a 2D layer f(-, -, z) is formally represented as a 3D grid of depth 1 (using `fun x y (_ : Fin 1) => f x y z`), which is a Lean formalization detail allowing 2D slices to reuse 3D definitions and theorems.
- The arithmetic deductions (deriving ≤ 9 from < 10 at line 17, combining the pattern counts at line 36, and deducing |U| ≤ 6 at line 40) are verified by Lean's `omega` Presburger arithmetic tactic.
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 grid_five_seven_fifty_one_at_most_six_unbalanced_layers (f : Fin 5 → Fin 7 → Fin 51 → Bool) (hf : grid_box_free f) : ((Finset.univ : Finset (Fin 51)).filter (fun z => ∃ y : Fin 7, let ones := ((Finset.univ : Finset (Fin 5)).filter (fun x => f x y z = true)).card; ones ≠ 2 ∧ ones ≠ 3)).card ≤ 6 := by set U := (Finset.univ : Finset (Fin 51)).filter (fun z => ∃ y : Fin 7, let ones := ((Finset.univ : Finset (Fin 5)).filter (fun x => f x y z = true)).card; ones ≠ 2 ∧ ones ≠ 3) have hU_sub : U ⊆ Finset.univ := Finset.filter_subset _ _ have h_split : ∑ z ∈ Finset.univ \ U, (layer_mono f z).card + ∑ z ∈ U, (layer_mono f z).card = ∑ z : Fin 51, (layer_mono f z).card := Finset.sum_sdiff hU_sub have h_card_sdiff : (Finset.univ \ U).card = 51 - U.card := by rw [Finset.card_sdiff_of_subset hU_sub] simp have h_ge_ten : ∀ z ∈ U, 10 ≤ (layer_mono f z).card := by intro z hz rw [Finset.mem_filter] at hz rcases hz with ⟨-, hz⟩ by_contra! h have h_slice : (layer_mono (fun x y (_ : Fin 1) => f x y z) 0).card ≤ 9 := by change (layer_mono f z).card ≤ 9 omega have h_bal := grid_five_seven_nine_rectangles_balanced_columns (fun x y => f x y z) h_slice rcases hz with ⟨y, hy⟩ have hy_bal := h_bal y rcases hy_bal with h2 | h3 · exact hy.1 h2 · exact hy.2 h3 have h_ge_eight : ∀ z ∈ Finset.univ \ U, 8 ≤ (layer_mono f z).card := by intro z _ exact layer_mono_five_seven_ge_eight (fun x y => f x y z) have h_sum_U : U.card * 10 ≤ ∑ z ∈ U, (layer_mono f z).card := by have := Finset.card_nsmul_le_sum U (fun z => (layer_mono f z).card) 10 h_ge_ten simpa [nsmul_eq_mul] using this have h_sum_sdiff : (Finset.univ \ U).card * 8 ≤ ∑ z ∈ Finset.univ \ U, (layer_mono f z).card := by have := Finset.card_nsmul_le_sum (Finset.univ \ U) (fun z => (layer_mono f z).card) 8 h_ge_eight simpa [nsmul_eq_mul] using this have h_total_le : ∑ z : Fin 51, (layer_mono f z).card ≤ 420 := by have h1 := layer_mono_card_sum_le f hf have h2 := ordered_patterns_five_seven_card omega have h_card_le : U.card ≤ 51 := by have := Finset.card_le_card hU_sub simpa using this omega