good_slopes_finite_rows_no_vertical
A finite set has p rows and p columns, each of size q. Each x-fiber has size at most rp and each row-column-x fiber size at most r. On each column x is constant or injective. If 2q exceeds rp and q is at least p+r, x is not constant on any row.
Statement
theorem good_slopes_finite_rows_no_vertical {α ι κ : Type*} [DecidableEq α] [DecidableEq ι] [Fintype ι] [DecidableEq κ] (S : Finset α) (row col : α → ι) (x : α → κ) (p q r : ℕ) (hp : Fintype.card ι = p) (hsize : r*p < 2*q) (hgap : p+r ≤ q) (hrows : ∀ i, (S.filter fun z => row z = i).card = q) (hcols : ∀ j, (S.filter fun z => col z = j).card = q) (hbound : ∀ k, (S.filter fun z => x z = k).card ≤ r*p) (hcross : ∀ i j k, (S.filter fun z => row z = i ∧ col z = j ∧ x z = k).card ≤ r) (hclass : ∀ j, (∃ k, ∀ z ∈ S, col z = j → x z = k) ∨ Set.InjOn x {z | z ∈ S ∧ col z = j}) : ∀ i k, ¬ ∀ z ∈ S, row z = i → x z = k
- Source
- Generic slice-counting step for OP-1027.
- Verified
- 19 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 2
- good_slopes_colored_product_two_dense_rows_conditionalFor a colored pq-point set over finite fields satisfying the stated size and same-color injectivity conditions, if two distinct nonzero…
- good_slopes_five_levels_no_verticalA finite set has five rows and five columns, each of size eleven. If each x-fiber has at most fifteen points, each row-column-x fiber at…
The proof, explained
The theorem is proved by contradiction: suppose x is constant with value k on some row i. We partition this row into its intersections with the p columns. Since any two columns where x is identically k would together contain 2q > rp points with x = k, at most one such column exists. On every other column, x is either a non-k constant or injective, so its intersection with row i has size at most 1. Summing over the columns bounds the row size by r + p - 1 if one column has x identically k, and by p otherwise; both cases contradict the row size q being at least p + r.
Assume for contradiction that x is identically equal to k on row i, which has cardinality q.
We proceed by contradiction: assume there exist a row index i and a value k such that every z ∈ S with row(z) = i satisfies x(z) = k. Let A = {z ∈ S | row(z) = i} denote row i, which has size |A| = q by hypothesis hrows, and define B(j) to be the fiber of column j within row i. By assumption, x(z) = k for every z ∈ A.
uses
Finset.mem_filter.mpclassical intro i k hrow let A := S.filter fun z => row z = i let B (j : ι) := A.filter fun z => col z = j have hA : A.card = q := hrows i have hAk : ∀ z ∈ A, x z = k := by intro z hz exact hrow z (Finset.mem_filter.mp hz).1 (Finset.mem_filter.mp hz).2
Each column fiber B(j) within row i has size at most r.
Every point z ∈ B(j) belongs to S and satisfies row(z) = i, col(z) = j, and x(z) = k. Hence B(j) is a subset of the fiber {z ∈ S | row(z) = i ∧ col(z) = j ∧ x(z) = k}, whose cardinality is bounded by r according to hypothesis hcross.
uses
le_trans,Finset.card_le_card,Finset.mem_filter.mp,Finset.mem_filter.mprhave hBbound (j : ι) : (B j).card ≤ r := by apply le_trans (Finset.card_le_card ?_) (hcross i j k) intro z hz have hzB := Finset.mem_filter.mp hz have hzA := Finset.mem_filter.mp hzB.1 exact Finset.mem_filter.mpr ⟨hzA.1, hzA.2, hzB.2, hAk z hzB.1⟩
The size of row A is the sum of the sizes of its column fibers B(j).
Decomposing the elements of row A according to their column coordinate expresses |A| as the sum of |B(j)| over all j ∈ ι by Finset.card_eq_sum_card_fiberwise.
uses
Finset.card_eq_sum_card_fiberwise,Finset.mem_univhave hAsum : A.card = ∑ j : ι, (B j).card := by exact Finset.card_eq_sum_card_fiberwise (fun _ _ => Finset.mem_univ _)
The parameter r cannot be zero.
From p + r ≤ q and r * p < 2 * q, linear arithmetic gives q > 0. If r = 0, then each |B(j)| ≤ r = 0, so |B(j)| = 0 for all j. But then q = |A| = ∑_j 0 = 0, contradicting q > 0. Thus r > 0.
have hq : 0 < q := by omega by_cases hr : r = 0 · have hz : ∀ j, (B j).card = 0 := by intro j; have := hBbound j; omega rw [hAsum] at hA simp [hz] at hA omega
At most one column can have x identically equal to k.
Suppose two distinct columns j ≠ j' both had x ≡ k. The sets C and D of points in columns j and j' are disjoint subsets of S, each of cardinality q by hypothesis hcols. Since x is constant equal to k on each column, their union C ∪ D is contained in the fiber {z ∈ S | x(z) = k}. Therefore 2q = |C| + |D| = |C ∪ D| ≤ r * p by hypothesis hbound, which contradicts the given inequality r * p < 2q.
uses
Finset.disjoint_left.mpr,Finset.mem_filter.mp,Finset.mem_union.mp,Finset.mem_filter.mpr,Finset.card_le_card,Finset.card_union_of_disjointhave hUnique {j j' : ι} (hj : ∀ z ∈ S, col z = j → x z = k) (hj' : ∀ z ∈ S, col z = j' → x z = k) : j = j' := by by_contra hne let C := S.filter fun z => col z = j let D := S.filter fun z => col z = j' have hdisj : Disjoint C D := by apply Finset.disjoint_left.mpr intro z hzC hzD have hc := (Finset.mem_filter.mp hzC).2 have hd := (Finset.mem_filter.mp hzD).2 exact hne (hc.symm.trans hd) have hsub : C ∪ D ⊆ S.filter fun z => x z = k := by intro z hz rcases Finset.mem_union.mp hz with hz | hz · have hh := Finset.mem_filter.mp hz exact Finset.mem_filter.mpr ⟨hh.1, hj z hh.1 hh.2⟩ · have hh := Finset.mem_filter.mp hz exact Finset.mem_filter.mpr ⟨hh.1, hj' z hh.1 hh.2⟩ have h := (Finset.card_le_card hsub).trans (hbound k) rw [Finset.card_union_of_disjoint hdisj] at h have hC : C.card = q := hcols j have hD : D.card = q := hcols j' omega
If x is not identically k on column j, then |B(j)| ≤ 1.
By hypothesis hclass, x on column j is either constant or injective. If x is constant with value v, then v ≠ k (since column j is not identically k); but every z ∈ B(j) must have x(z) = k and x(z) = v, which is impossible, so B(j) is empty and |B(j)| = 0 ≤ 1. If x is injective on column j, any two points in B(j) have the same column coordinate j and both satisfy x = k, so injectivity forces them to coincide, giving |B(j)| ≤ 1.
uses
Finset.eq_empty_iff_forall_notMem.mpr,Finset.mem_filter.mp,Finset.card_le_one_iff.mprhave hsmall (j : ι) (hn : ¬ ∀ z ∈ S, col z = j → x z = k) : (B j).card ≤ 1 := by rcases hclass j with ⟨v,hv⟩ | hv · have hvne : v ≠ k := by intro h apply hn intro z hz hcol rw [← h] exact hv z hz hcol have hempty : B j = ∅ := by apply Finset.eq_empty_iff_forall_notMem.mpr intro z hz have hzB := Finset.mem_filter.mp hz have hzA := Finset.mem_filter.mp hzB.1 exact hvne ((hv z hzA.1 hzB.2).symm.trans (hAk z hzB.1)) simp [hempty] · apply Finset.card_le_one_iff.mpr intro z z' hz hz' have hzB := Finset.mem_filter.mp hz have hz'B := Finset.mem_filter.mp hz' have hzA := Finset.mem_filter.mp hzB.1 have hz'A := Finset.mem_filter.mp hz'B.1 exact hv ⟨hzA.1,hzB.2⟩ ⟨hz'A.1,hz'B.2⟩ ((hAk z hzB.1).trans (hAk z' hz'B.1).symm)
A contradiction is reached if there is a column on which x is identically k.
Suppose some column j satisfies x ≡ k. By uniqueness, no other column j' ≠ j is identically k, which means |B(j')| ≤ 1 for each of the remaining p - 1 columns. Summing over these columns gives ∑_{j' ≠ j} |B(j')| ≤ p - 1. Together with |B(j)| ≤ r, this yields q = |A| = |B(j)| + ∑_{j' ≠ j} |B(j')| ≤ r + p - 1 < p + r, contradicting the assumption p + r ≤ q.
uses
Finset.sum_le_sum,Finset.mem_erase.mp,Finset.add_sum_erase,Finset.mem_univ,Fintype.card_pos_iff.mprby_cases he : ∃ j, ∀ z ∈ S, col z = j → x z = k · obtain ⟨j,hj⟩ := he have hRest : ∑ j' ∈ (Finset.univ : Finset ι).erase j, (B j').card ≤ p-1 := by calc _ ≤ ∑ _j' ∈ (Finset.univ : Finset ι).erase j, 1 := by apply Finset.sum_le_sum intro j' hj' have hjne : j' ≠ j := (Finset.mem_erase.mp hj').1 apply hsmall intro hj' exact hjne (hUnique hj' hj) _ = p-1 := by simp [hp] have hs : (B j).card + ∑ j' ∈ (Finset.univ : Finset ι).erase j, (B j').card = A.card := by calc _ = ∑ j' : ι, (B j').card := Finset.add_sum_erase Finset.univ (fun j' => (B j').card) (Finset.mem_univ j) _ = A.card := hAsum.symm have hp0 : 0 < p := by have : 0 < Fintype.card ι := Fintype.card_pos_iff.mpr ⟨j⟩ omega have hb := hBbound j omega
A contradiction is reached if no column has x identically equal to k.
If no column has x ≡ k, then |B(j)| ≤ 1 for every column j ∈ ι. Summing over all p columns yields q = |A| = ∑_{j ∈ ι} |B(j)| ≤ ∑_{j ∈ ι} 1 = p. Combined with p + r ≤ q and r > 0, this implies p < p + r ≤ q ≤ p, a contradiction.
uses
Finset.sum_le_sum· have hs : A.card ≤ p := by rw [hAsum] calc _ ≤ ∑ _j : ι, 1 := by apply Finset.sum_le_sum intro j _ apply hsmall intro hj exact he ⟨j,hj⟩ _ = p := by simp [hp] omega
Finset.add_sum_erase- A sum over a finite set s can be decomposed into the term at a ∈ s plus the sum over s with a removed.
Finset.card_le_one_iff.mpr- A finite set has cardinality at most 1 if and only if any two of its elements are equal.
Finset.card_le_card- If a finite set s is a subset of t, then the cardinality of s is at most that of t.
Finset.card_eq_sum_card_fiberwise- The cardinality of a finite set equals the sum of the cardinalities of its fibers under a function into another finite set.
Finset.card_union_of_disjoint- The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
Finset.disjoint_left.mpr- Two finite sets are disjoint if no element of the first belongs to the second.
Finset.eq_empty_iff_forall_notMem.mpr- A finite set with no elements is equal to the empty set.
Finset.mem_erase.mp- An element in s with x removed is distinct from x and belongs to s.
Finset.mem_filter.mp- An element is in a filtered finset only if it is in the original set and satisfies the filter predicate.
Finset.mem_filter.mpr- An element is in a filtered finset if it belongs to the original set and satisfies the filter predicate.
Finset.mem_union.mp- If an element is in the union of two finite sets, it belongs to at least one of them.
Finset.mem_univ- Every element of a finite type belongs to the universal finset Finset.univ.
Finset.sum_le_sum- If f(i) ≤ g(i) for all elements i of a finite set s, then the sum of f over s is at most the sum of g over s.
Fintype.card_pos_iff.mpr- A finite type has strictly positive cardinality if and only if it is nonempty.
le_trans- The less-than-or-equal relation is transitive: if a ≤ b and b ≤ c, then a ≤ c.
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 maxRecDepth 10000set_option maxHeartbeats 5000000theorem good_slopes_finite_rows_no_vertical {α ι κ : Type*} [DecidableEq α] [DecidableEq ι] [Fintype ι] [DecidableEq κ] (S : Finset α) (row col : α → ι) (x : α → κ) (p q r : ℕ) (hp : Fintype.card ι = p) (hsize : r*p < 2*q) (hgap : p+r ≤ q) (hrows : ∀ i, (S.filter fun z => row z = i).card = q) (hcols : ∀ j, (S.filter fun z => col z = j).card = q) (hbound : ∀ k, (S.filter fun z => x z = k).card ≤ r*p) (hcross : ∀ i j k, (S.filter fun z => row z = i ∧ col z = j ∧ x z = k).card ≤ r) (hclass : ∀ j, (∃ k, ∀ z ∈ S, col z = j → x z = k) ∨ Set.InjOn x {z | z ∈ S ∧ col z = j}) : ∀ i k, ¬ ∀ z ∈ S, row z = i → x z = k := by classical intro i k hrow let A := S.filter fun z => row z = i let B (j : ι) := A.filter fun z => col z = j have hA : A.card = q := hrows i have hAk : ∀ z ∈ A, x z = k := by intro z hz exact hrow z (Finset.mem_filter.mp hz).1 (Finset.mem_filter.mp hz).2 have hBbound (j : ι) : (B j).card ≤ r := by apply le_trans (Finset.card_le_card ?_) (hcross i j k) intro z hz have hzB := Finset.mem_filter.mp hz have hzA := Finset.mem_filter.mp hzB.1 exact Finset.mem_filter.mpr ⟨hzA.1, hzA.2, hzB.2, hAk z hzB.1⟩ have hAsum : A.card = ∑ j : ι, (B j).card := by exact Finset.card_eq_sum_card_fiberwise (fun _ _ => Finset.mem_univ _) have hq : 0 < q := by omega by_cases hr : r = 0 · have hz : ∀ j, (B j).card = 0 := by intro j; have := hBbound j; omega rw [hAsum] at hA simp [hz] at hA omega have hUnique {j j' : ι} (hj : ∀ z ∈ S, col z = j → x z = k) (hj' : ∀ z ∈ S, col z = j' → x z = k) : j = j' := by by_contra hne let C := S.filter fun z => col z = j let D := S.filter fun z => col z = j' have hdisj : Disjoint C D := by apply Finset.disjoint_left.mpr intro z hzC hzD have hc := (Finset.mem_filter.mp hzC).2 have hd := (Finset.mem_filter.mp hzD).2 exact hne (hc.symm.trans hd) have hsub : C ∪ D ⊆ S.filter fun z => x z = k := by intro z hz rcases Finset.mem_union.mp hz with hz | hz · have hh := Finset.mem_filter.mp hz exact Finset.mem_filter.mpr ⟨hh.1, hj z hh.1 hh.2⟩ · have hh := Finset.mem_filter.mp hz exact Finset.mem_filter.mpr ⟨hh.1, hj' z hh.1 hh.2⟩ have h := (Finset.card_le_card hsub).trans (hbound k) rw [Finset.card_union_of_disjoint hdisj] at h have hC : C.card = q := hcols j have hD : D.card = q := hcols j' omega have hsmall (j : ι) (hn : ¬ ∀ z ∈ S, col z = j → x z = k) : (B j).card ≤ 1 := by rcases hclass j with ⟨v,hv⟩ | hv · have hvne : v ≠ k := by intro h apply hn intro z hz hcol rw [← h] exact hv z hz hcol have hempty : B j = ∅ := by apply Finset.eq_empty_iff_forall_notMem.mpr intro z hz have hzB := Finset.mem_filter.mp hz have hzA := Finset.mem_filter.mp hzB.1 exact hvne ((hv z hzA.1 hzB.2).symm.trans (hAk z hzB.1)) simp [hempty] · apply Finset.card_le_one_iff.mpr intro z z' hz hz' have hzB := Finset.mem_filter.mp hz have hz'B := Finset.mem_filter.mp hz' have hzA := Finset.mem_filter.mp hzB.1 have hz'A := Finset.mem_filter.mp hz'B.1 exact hv ⟨hzA.1,hzB.2⟩ ⟨hz'A.1,hz'B.2⟩ ((hAk z hzB.1).trans (hAk z' hz'B.1).symm) by_cases he : ∃ j, ∀ z ∈ S, col z = j → x z = k · obtain ⟨j,hj⟩ := he have hRest : ∑ j' ∈ (Finset.univ : Finset ι).erase j, (B j').card ≤ p-1 := by calc _ ≤ ∑ _j' ∈ (Finset.univ : Finset ι).erase j, 1 := by apply Finset.sum_le_sum intro j' hj' have hjne : j' ≠ j := (Finset.mem_erase.mp hj').1 apply hsmall intro hj' exact hjne (hUnique hj' hj) _ = p-1 := by simp [hp] have hs : (B j).card + ∑ j' ∈ (Finset.univ : Finset ι).erase j, (B j').card = A.card := by calc _ = ∑ j' : ι, (B j').card := Finset.add_sum_erase Finset.univ (fun j' => (B j').card) (Finset.mem_univ j) _ = A.card := hAsum.symm have hp0 : 0 < p := by have : 0 < Fintype.card ι := Fintype.card_pos_iff.mpr ⟨j⟩ omega have hb := hBbound j omega · have hs : A.card ≤ p := by rw [hAsum] calc _ ≤ ∑ _j : ι, 1 := by apply Finset.sum_le_sum intro j _ apply hsmall intro hj exact he ⟨j,hj⟩ _ = p := by simp [hp] omega