layer_mono_card_sum_le
Layer bound (Lemma 4.1 core): for a box-free colouring of $[a]\times[b]\times[c]$, the total number of monochromatic rectangles summed over all $c$ layers is at most the number $|\mathrm{ordered\_patterns}\,a\,b| = 2\binom a2\binom b2$ of coloured rectangle slots. Hence $c\cdot\rho(a,b) \le 2\binom a2\binom b2$.
Statement
theorem layer_mono_card_sum_le {a b c : ℕ} (f : Fin a → Fin b → Fin c → Bool) (hf : grid_box_free f) : ∑ z : Fin c, (layer_mono f z).card ≤ (ordered_patterns a b).card- Source
- step towards grid_box_free_max_five_seven
- Verified
- 28 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 6
- grid_box_free_iff_layers_disjointA colouring $f$ of $[a]\times[b]\times[c]$ is box-free if and only if any two distinct layers have disjoint sets of monochromatic coloured…
- 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…
- 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…
- 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…
- mem_layer_monoMembership in $\mathrm{layer\_mono}(f,z)$: a pattern $(x_1,x_2,y_1,y_2,\mathrm{col})$ lies in the layer iff $x_1<x_2$, $y_1<y_2$, and all…
- 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 proof bounds the total number of monochromatic rectangles across all layers by observing that in a box-free colouring, no monochromatic rectangle can appear in two distinct layers. As a result, the sets of monochromatic rectangles on different layers are pairwise disjoint, so their sum equals the cardinality of their union. Since every monochromatic rectangle satisfies the coordinate inequalities defining an ordered pattern, this union is a subset of the ordered pattern slots, completing the inequality.
The sets of monochromatic rectangles in distinct layers are pairwise disjoint.
Because the colouring f is box-free, grid_box_free_iff_layers_disjoint implies that any two distinct layers z₁ ≠ z₂ have disjoint sets of monochromatic rectangles layer_mono f z₁ and layer_mono f z₂. Lines 4–6 introduce this fact as the pairwise disjointness property of the family over all layers in Finset.univ.
uses
grid_box_free_iff_layers_disjointhave hd := (grid_box_free_iff_layers_disjoint f).mp hf have dd : ((Finset.univ : Finset (Fin c)) : Set (Fin c)).PairwiseDisjoint (layer_mono f) := by intro z _ v _ hzv exact hd z v hzv
The sum of the counts of monochromatic rectangles over all layers equals the size of their union.
Since the sets layer_mono f z are pairwise disjoint, Finset.card_biUnion rewrites the sum of their cardinalities ∑ z, (layer_mono f z).card into the cardinality of their union, (Finset.univ.biUnion (layer_mono f)).card.
uses
Finset.card_biUnionrw [← Finset.card_biUnion dd]It suffices to show that the union of monochromatic rectangles is contained in the set of ordered patterns.
By Finset.card_le_card, an inclusion of finite sets s ⊆ t implies s.card ≤ t.card. Applying this reduces the inequality between cardinalities to showing that the union over all layers is a subset of ordered_patterns a b.
uses
Finset.card_le_cardapply Finset.card_le_cardEvery monochromatic rectangle from any layer belongs to the set of ordered patterns.
Let p be an element of the union. By Finset.mem_biUnion.mp, p belongs to layer_mono f z for some layer z. By mem_layer_mono, p satisfies the coordinate ordering conditions x₁ < x₂ and y₁ < y₂. By Finset.mem_filter.mpr and Finset.mem_univ, satisfying these two coordinate inequalities means p is a member of ordered_patterns a b.
uses
Finset.mem_biUnion.mp,mem_layer_mono,Finset.mem_filter.mpr,Finset.mem_univintro p hp obtain ⟨z,_,hz⟩ := Finset.mem_biUnion.mp hp obtain ⟨hx,hy,_⟩ := (mem_layer_mono f z p).mp hz exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hx,hy⟩
grid_box_free_iff_layers_disjoint- A 3D grid colouring is box-free if and only if any two distinct layers have disjoint sets of monochromatic rectangles.
Finset.card_biUnion- The cardinality of a union of pairwise disjoint finite sets is the sum of the cardinalities of the individual sets.
Finset.card_le_card- If one finite set is a subset of another, its cardinality is at most the other's cardinality.
Finset.mem_biUnion.mp- If an element belongs to the union of a family of sets, it belongs to at least one member set of that family.
mem_layer_mono- A pattern belongs to the monochromatic rectangles of layer z if and only if its coordinates satisfy the ordering conditions x₁ < x₂ and y₁ < y₂ and all four rectangle corners in layer z share the pattern's colour.
Finset.mem_filter.mpr- An element belongs to a filtered set if it belongs to the unfiltered set and satisfies the filter's predicate.
Finset.mem_univ- Every element of a finite type belongs to its universal set Finset.univ.
- Lines 4–6 are purely formal bookkeeping to adapt the pairwise disjointness hypothesis `hd` to the `Set.PairwiseDisjoint` predicate required by `Finset.card_biUnion`.
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.
/-- Total monochromatic rectangles across the layers of a box-free colouring fit into the ordered pattern slots. -/theorem layer_mono_card_sum_le {a b c : ℕ} (f : Fin a → Fin b → Fin c → Bool) (hf : grid_box_free f) : ∑ z : Fin c, (layer_mono f z).card ≤ (ordered_patterns a b).card := by have hd := (grid_box_free_iff_layers_disjoint f).mp hf have dd : ((Finset.univ : Finset (Fin c)) : Set (Fin c)).PairwiseDisjoint (layer_mono f) := by intro z _ v _ hzv exact hd z v hzv rw [← Finset.card_biUnion dd] apply Finset.card_le_card intro p hp obtain ⟨z,_,hz⟩ := Finset.mem_biUnion.mp hp obtain ⟨hx,hy,_⟩ := (mem_layer_mono f z p).mp hz exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hx,hy⟩