AFTD Auto-Formalizing Theoretical Domains

op869_repeated_color_incidence

theoremverified

Suppose there are KqD copies and fewer than K colors, and every copy contains at least q colors. If 1 ≤ q ≤ K and D ≥ 1, at least q colors occur in at least qD copies each.

Statement

theorem op869_repeated_color_incidence {α β : Type} [DecidableEq α] [DecidableEq β] (A : Finset α) (B : Finset β)
    (R : α → β → Prop) [DecidableRel R] (K q D : ℕ) :
    1 ≤ q → q ≤ K → 1 ≤ D → A.card = K * q * D → B.card < K →
    (∀ a ∈ A, q ≤ (B.filter (R a)).card) →
    q ≤ (B.filter (fun b => q * D ≤ (A.filter (fun a => R a b)).card)).card
Source
arXiv:2610.41516, Lemma 2.5, the incidence-counting step for the reserved copies.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 4
  • op869_incidence_degree_countFor a finite incidence relation in which each element of A is incident with at least d elements of B, and 1 ≤ r ≤ |A|, the incidence count…
  • op869_double_countDouble counting in a bipartite incidence: if every element x of A meets at least d elements of B, then for i ≤ |A|, |A|·d ≤ |B|·(i-1) +…
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
Used by 1

The proof, explained

The theorem is proved by contradiction using a double-counting inequality on incidences between copies and colors. Applying the lemma op869_double_count establishes that the total incidence count K * q^2 * D is bounded above by |B| * (qD - 1) + ((K - 1) * qD + 1) * H, where H is the number of colors appearing in at least qD copies. Assuming for contradiction that H ≤ q - 1, and combining this with |B| ≤ K - 1, the right-hand side is at most (K - 1)(qD - 1) + ((K - 1)qD + 1)(q - 1). Expanding both sides shows that this upper bound is strictly less than K * qD * q, producing a contradiction via nonlinear arithmetic.

  1. We introduce the hypotheses and define E(a) for each copy a ∈ A as the subset of colors in B incident to a, verifying that E(a) ⊆ B.

    We introduce the assumptions 1 ≤ q ≤ K, 1 ≤ D, |A| = K q D, |B| < K, and the degree condition that every copy contains at least q colors. We set E(a) = {b ∈ B | R a b} to be the set of colors present in copy a; by definition of filtering, any b ∈ E(a) belongs to B, so E(a) ⊆ B.

    lines 6–10

    uses Finset.mem_filter.mp

      intro hq hqK hD hA hB hd
      let E : α → Finset β := fun a => B.filter (R a)
      have hE : ∀ a ∈ A, E a ⊆ B := by
        intro a ha b hb
        exact (Finset.mem_filter.mp hb).1
  2. The bounds 1 ≤ K, 1 ≤ qD, and qD ≤ |A| hold.

    From 1 ≤ q ≤ K we get 1 ≤ K by transitivity (le_trans). Since 1 ≤ q and 1 ≤ D, their product satisfies 1 ≤ qD (Nat.mul_pos). Multiplying 1 ≤ K on the right by qD gives qD ≤ K * (qD) = |A| (Nat.mul_le_mul_right, Nat.mul_assoc).

    lines 11–16

    uses le_trans, Nat.mul_pos, Nat.mul_le_mul_right, Nat.mul_assoc

      have hK : 1 ≤ K := le_trans hq hqK
      have hs : 1 ≤ q * D := Nat.mul_pos hq hD
      have hQA : q * D ≤ A.card := by
        rw [hA]
        have := Nat.mul_le_mul_right (q * D) hK
        simpa [Nat.mul_assoc] using this
  3. The set of colors occurring in at least qD sets E(a) coincides with the set of colors occurring in at least qD copies under R.

    For any color b ∈ B, the membership condition b ∈ E(a) is definitionally b ∈ B ∧ R a b, which is equivalent to R a b since b ∈ B. Thus, for each b ∈ B, the copies containing b are the same under both formulations, and Finset.filter_congr equates the sets of colors with copy-count at least qD.

    lines 17–24

    uses Finset.filter_congr

      have hcard : (B.filter (fun b => q * D ≤ (A.filter (fun a => b ∈ E a)).card)) =
          B.filter (fun b => q * D ≤ (A.filter (fun a => R a b)).card) := by
        apply Finset.filter_congr
        intro b hb
        have heq : (A.filter (fun a => b ∈ E a)) = A.filter (fun a => R a b) := by
          ext a
          simp [E, hb]
        rw [heq]
  4. The double-counting inequality gives K * q * D * q ≤ |B| * (qD - 1) + (K * q * D - qD + 1) * H, where H is the count of colors occurring in at least qD copies.

    We apply the double-counting lemma op869_double_count with degree lower bound q and threshold i = qD, which is valid since E(a) ⊆ B, q ≤ |E(a)|, and qD ≤ |A|. Rewriting with |A| = K * q * D and the set equivalence established in the previous step gives the desired incidence bound.

    lines 25–28

    uses op869_double_count

      have hdc := op869_double_count A B E q (q * D) hE hd hQA
      rw [hcard, hA] at hdc
      let H := (B.filter (fun b => q * D ≤ (A.filter (fun a => R a b)).card)).card
      change K * q * D * q ≤ B.card * (q * D - 1) + (K * q * D - q * D + 1) * H at hdc
  5. Assuming for contradiction that H ≤ q - 1, the two terms on the right-hand side are bounded by (K - 1) * (qD - 1) and (K * q * D - qD + 1) * (q - 1).

    We assume for contradiction that H < q, which over ℕ means H ≤ q - 1. Similarly, |B| < K implies |B| ≤ K - 1. Multiplying |B| ≤ K - 1 by qD - 1 on the right (Nat.mul_le_mul_right) bounds the first term, and multiplying H ≤ q - 1 by (K * q * D - qD + 1) on the left (Nat.mul_le_mul_left) bounds the second term.

    lines 29–33

    uses Nat.mul_le_mul_right, Nat.mul_le_mul_left

      by_contra hnot
      have hH : H ≤ q - 1 := by dsimp [H]; omega
      have hB' : B.card ≤ K - 1 := by omega
      have h1 := Nat.mul_le_mul_right (q * D - 1) hB'
      have h2 := Nat.mul_le_mul_left (K * q * D - q * D + 1) hH
  6. We have K * q * D - qD = (K - 1) * (qD), which simplifies the coefficient of H in the double-counting inequality and its upper bound.

    Writing K as (K - 1) + 1 and distributing multiplication over addition shows that ((K - 1) + 1) * (qD) - qD = (K - 1) * (qD). We substitute this into the double-counting inequality and the bound on the second term.

    lines 34–38

    uses Nat.add_mul, one_mul, Nat.add_sub_cancel_right, Nat.mul_assoc

      have hsub : K * q * D - q * D = (K - 1) * (q * D) := by
        have heq : K = (K - 1) + 1 := by omega
        conv_lhs => rw [heq]
        simp only [Nat.add_mul, one_mul, Nat.add_sub_cancel_right, Nat.mul_assoc]
      rw [hsub] at hdc h2
  7. We express K = k + 1, q = p + 1, and qD = s + 1 for non-negative integers k, p, s, rewriting the inequalities in terms of s.

    Because 1 ≤ K, 1 ≤ q, and 1 ≤ qD, there exist non-negative integers k = K - 1, p = q - 1, and s = qD - 1. Rewriting K * q * D as K * (qD) and substituting qD = s + 1 simplifies all occurrences of qD - 1 to s in the inequalities.

    lines 39–44

      obtain ⟨k, hk⟩ : ∃ k, K = k + 1 := ⟨K - 1, by omega⟩
      obtain ⟨p, hp⟩ : ∃ p, q = p + 1 := ⟨q - 1, by omega⟩
      obtain ⟨s, hs'⟩ : ∃ s, q * D = s + 1 := ⟨q * D - 1, by omega⟩
      have hh : K * q * D = K * (q * D) := by ring
      rw [hh, hs'] at hdc
      rw [hs'] at h1 h2
  8. The resulting inequalities produce a contradiction, completing the proof that q ≤ H. automation

    Substituting K = k + 1 and q = p + 1 simplifies the double-counting lower bound to (k + 1) * (s + 1) * (p + 1) ≤ |B| * s + (k * (s + 1) + 1) * H. Adding the bounds |B| * s ≤ k * s and (k * (s + 1) + 1) * H ≤ (k * (s + 1) + 1) * p yields an upper bound of k * s + (k * (s + 1) + 1) * p. Expanding both sides reveals that the lower bound strictly exceeds this upper bound by s * p + k + s + 1 > 0, and nlinarith detects this contradiction.

    lines 45–46

    uses Nat.add_sub_cancel

      simp only [hk, hp, Nat.add_sub_cancel] at hdc h1 h2
      nlinarith
Finset.mem_filter.mp
If an element belongs to a filtered set {y ∈ s | p(y)}, then it belongs to s and satisfies p.
le_trans
If a ≤ b and b ≤ c, then a ≤ c (transitivity of inequality).
Nat.mul_pos
The product of two positive natural numbers is positive.
Nat.mul_le_mul_right
Multiplying both sides of an inequality of natural numbers by a number on the right preserves the inequality (n ≤ m implies n * k ≤ m * k).
Nat.mul_assoc
Multiplication of natural numbers is associative: (n * m) * k = n * (m * k).
Finset.filter_congr
Two filtered finsets are equal if their defining predicates are equivalent on every element of the set.
op869_double_count
A double-counting inequality bounding total incidences: for families E(x) ⊆ B of size at least d over x ∈ A with i ≤ |A|, |A| * d ≤ |B| * (i - 1) + (|A| - i + 1) * |{u ∈ B | i ≤ |{x ∈ A | u ∈ E(x)}|}|.
Nat.mul_le_mul_left
Multiplying both sides of an inequality of natural numbers by a number on the left preserves the inequality (n ≤ m implies k * n ≤ k * m).
Nat.add_mul
Multiplication of natural numbers distributes over addition on the right: (n + m) * k = n * k + m * k.
one_mul
Multiplying any element by 1 on the left leaves it unchanged (1 * a = a).
Nat.add_sub_cancel_right
Subtracting an added term on the right from a sum of natural numbers restores the original number: (n + m) - m = n.
Nat.add_sub_cancel
Subtracting an added term from a sum of natural numbers restores the original number: (n + m) - m = n.

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

theorem op869_repeated_color_incidence {α β : Type} [DecidableEq α] [DecidableEq β] (A : Finset α) (B : Finset β)    (R : α → β → Prop) [DecidableRel R] (K q D : ℕ) :    1 ≤ q → q ≤ K → 1 ≤ D → A.card = K * q * D → B.card < K →    (∀ a ∈ A, q ≤ (B.filter (R a)).card) →    q ≤ (B.filter (fun b => q * D ≤ (A.filter (fun a => R a b)).card)).card := by  intro hq hqK hD hA hB hd  let E : α → Finset β := fun a => B.filter (R a)  have hE : ∀ a ∈ A, E a ⊆ B := by    intro a ha b hb    exact (Finset.mem_filter.mp hb).1  have hK : 1 ≤ K := le_trans hq hqK  have hs : 1 ≤ q * D := Nat.mul_pos hq hD  have hQA : q * D ≤ A.card := by    rw [hA]    have := Nat.mul_le_mul_right (q * D) hK    simpa [Nat.mul_assoc] using this  have hcard : (B.filter (fun b => q * D ≤ (A.filter (fun a => b ∈ E a)).card)) =      B.filter (fun b => q * D ≤ (A.filter (fun a => R a b)).card) := by    apply Finset.filter_congr    intro b hb    have heq : (A.filter (fun a => b ∈ E a)) = A.filter (fun a => R a b) := by      ext a      simp [E, hb]    rw [heq]  have hdc := op869_double_count A B E q (q * D) hE hd hQA  rw [hcard, hA] at hdc  let H := (B.filter (fun b => q * D ≤ (A.filter (fun a => R a b)).card)).card  change K * q * D * q ≤ B.card * (q * D - 1) + (K * q * D - q * D + 1) * H at hdc  by_contra hnot  have hH : H ≤ q - 1 := by dsimp [H]; omega  have hB' : B.card ≤ K - 1 := by omega  have h1 := Nat.mul_le_mul_right (q * D - 1) hB'  have h2 := Nat.mul_le_mul_left (K * q * D - q * D + 1) hH  have hsub : K * q * D - q * D = (K - 1) * (q * D) := by    have heq : K = (K - 1) + 1 := by omega    conv_lhs => rw [heq]    simp only [Nat.add_mul, one_mul, Nat.add_sub_cancel_right, Nat.mul_assoc]  rw [hsub] at hdc h2  obtain ⟨k, hk⟩ : ∃ k, K = k + 1 := ⟨K - 1, by omega⟩  obtain ⟨p, hp⟩ : ∃ p, q = p + 1 := ⟨q - 1, by omega⟩  obtain ⟨s, hs'⟩ : ∃ s, q * D = s + 1 := ⟨q * D - 1, by omega⟩  have hh : K * q * D = K * (q * D) := by ring  rw [hh, hs'] at hdc  rw [hs'] at h1 h2  simp only [hk, hp, Nat.add_sub_cancel] at hdc h1 h2  nlinarith
See it in the graphDiscuss this resultChallenge it