grid57_seven_column_repetition_bound_via_choose
For any set of seven column positions, its size is at most one more than the number of increasing pairs it contains.
Statement
theorem grid57_seven_column_repetition_bound_via_choose (g : Fin 7 → Bool) : ((Finset.univ : Finset (Fin 7)).filter (fun y => g y = true)).card ≤ ((Finset.univ : Finset (Fin 7 × Fin 7)).filter (fun p => p.1 < p.2 ∧ g p.1 = true ∧ g p.2 = true)).card + 1
- Source
- OP-1867: row-pair/color class repetition, related to arXiv:2611.19635 section 6.
- Verified
- 28 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 1
- grid57_agreements_le_rectangles_add_twentyThe total column agreements are at most the number of monochromatic rectangles plus twenty.
The proof, explained
The theorem states that for any boolean predicate g on a 7-element set, the number of satisfying elements |s| is at most one more than the number of increasing satisfying pairs. The proof first identifies the count of such increasing pairs with the binomial coefficient (|s| choose 2). Since s is a subset of Fin 7, its cardinality satisfies |s| ≤ 7, and the resulting inequality |s| ≤ (|s| choose 2) + 1 is verified by exhaustive computation over all eight possible values |s| ∈ {0, ..., 7}.
Let s be the subset of Fin 7 on which g is true; then |s| ≤ 7.
We define s ⊆ Fin 7 as the set of elements y such that g y = true. Because Fin 7 has 7 elements, any of its subsets has cardinality at most 7 by Finset.card_le_univ.
uses
Finset.card_le_univlet s : Finset (Fin 7) := Finset.univ.filter (fun y => g y = true) have hs : s.card ≤ 7 := by simpa using Finset.card_le_univ s
The number of increasing pairs (p₁, p₂) on which g is true equals (|s| choose 2).
By Finset.card_product_filter_lt, the number of pairs (p₁, p₂) ∈ s × s with p₁ < p₂ is (|s| choose 2). Congruence reduces the claim to showing that the set of satisfying pairs in Fin 7 × Fin 7 equals {p ∈ s × s | p₁ < p₂}. By extensionality, a pair p belongs to the first set if and only if p₁ < p₂ and g p₁ = true and g p₂ = true. Unfolding the definition of s with Finset.mem_filter, Finset.mem_product, Finset.mem_univ, and true_and, and rearranging conjunctions using and_assoc, and_left_comm, and and_comm, shows this is equivalent to (p₁ ∈ s ∧ p₂ ∈ s) ∧ p₁ < p₂, which is membership in the second set.
uses
Finset.card_product_filter_lt,Finset.mem_filter,Finset.mem_product,Finset.mem_univ,true_and,and_assoc,and_left_comm,and_commhave hp : ((Finset.univ : Finset (Fin 7 × Fin 7)).filter (fun p => p.1 < p.2 ∧ g p.1 = true ∧ g p.2 = true)).card = s.card.choose 2 := by rw [← Finset.card_product_filter_lt (s := s)] congr 1 ext p simp only [Finset.mem_filter, Finset.mem_product, Finset.mem_univ, true_and] simp [s, and_assoc, and_left_comm, and_comm]
The main goal reduces to showing that |s| ≤ (|s| choose 2) + 1.
Rewriting with the pair-count equality replaces the pair count with (|s| choose 2), reducing the required inequality to |s| ≤ (|s| choose 2) + 1.
rw [hp] change s.card ≤ Nat.choose s.card 2 + 1
The inequality |s| ≤ (|s| choose 2) + 1 holds.
Since |s| ≤ 7, the cardinality |s| must be an integer between 0 and 7. The tactic interval_cases splits into the eight cases |s| ∈ {0, 1, 2, 3, 4, 5, 6, 7}, and norm_num verifies the inequality by direct numerical evaluation of (k choose 2) + 1 in each case.
interval_cases hs' : s.card <;> norm_num [hs', Nat.choose]
Finset.card_le_univ- The cardinality of any finite subset of a finite type is at most the cardinality of the whole type.
Finset.card_product_filter_lt- In any linearly ordered finite set s, the number of pairs (x, y) in s × s with x < y equals (card s choose 2).
Finset.mem_filter- An element x belongs to Finset.filter p s if and only if x is in s and p x holds.
Finset.mem_product- A pair (x, y) belongs to the Cartesian product s × t if and only if x is in s and y is in t.
Finset.mem_univ- Every element of a finite type belongs to the universal finset.
true_and- The conjunction of True with any proposition p is logically equivalent to p.
and_assoc- Logical conjunction is associative: ((a ∧ b) ∧ c) is equivalent to (a ∧ b ∧ c).
and_left_comm- Conjunction satisfies left-commutativity: (a ∧ b ∧ c) is equivalent to (b ∧ a ∧ c).
and_comm- Logical conjunction is commutative: (a ∧ b) is equivalent to (b ∧ a).
- Rather than proving the algebraic inequality k ≤ Nat.choose k 2 + 1 for all natural numbers k, the formal proof bounds |s| ≤ 7 and verifies the inequality by exhaustive computation over the eight cases 0 ≤ |s| ≤ 7.
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.
set_option maxHeartbeats 4000000set_option maxRecDepth 10000set_option linter.all falsetheorem grid57_seven_column_repetition_bound_via_choose (g : Fin 7 → Bool) : ((Finset.univ : Finset (Fin 7)).filter (fun y => g y = true)).card ≤ ((Finset.univ : Finset (Fin 7 × Fin 7)).filter (fun p => p.1 < p.2 ∧ g p.1 = true ∧ g p.2 = true)).card + 1 := by let s : Finset (Fin 7) := Finset.univ.filter (fun y => g y = true) have hs : s.card ≤ 7 := by simpa using Finset.card_le_univ s have hp : ((Finset.univ : Finset (Fin 7 × Fin 7)).filter (fun p => p.1 < p.2 ∧ g p.1 = true ∧ g p.2 = true)).card = s.card.choose 2 := by rw [← Finset.card_product_filter_lt (s := s)] congr 1 ext p simp only [Finset.mem_filter, Finset.mem_product, Finset.mem_univ, true_and] simp [s, and_assoc, and_left_comm, and_comm] rw [hp] change s.card ≤ Nat.choose s.card 2 + 1 interval_cases hs' : s.card <;> norm_num [hs', Nat.choose]