AFTD Auto-Formalizing Theoretical Domains

op861_boolean_weight_interval_count

theoremverified

For natural numbers n, a, and b with a at most b, the number of subsets of an n-element set whose cardinalities lie between a and b inclusive is at most (b−a+1) times the largest binomial coefficient n choose floor(n/2).

Statement

theorem op861_boolean_weight_interval_count (n a b : ℕ) (hab : a ≤ b) :
    ((Finset.univ : Finset (Finset (Fin n))).filter (fun S => a ≤ S.card ∧ S.card ≤ b)).card ≤
      (b-a+1) * n.choose (n/2)
Source
Finite binomial interval estimate for op861_dense_triangle_orientation_sqrt_cover.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 3

The proof, explained

The proof partitions the collection of subsets of an n-element set into sub-collections of fixed size s for each s in the interval [a, b]. Applying the union bound reduces the problem to bounding the sum of the binomial coefficients n choose s over s ∈ [a, b]. Since the binomial coefficient n choose s is maximized at s = floor(n / 2), each of the b - a + 1 terms in the sum is at most n choose floor(n / 2), completing the estimate.

  1. The family of subsets of an n-element set whose sizes lie between a and b is contained in the union over s ∈ [a, b] of the collections of subsets of size s.

    Assuming classical logic, consider any subset S ⊆ Fin n whose size satisfies a ≤ |S| ≤ b. Setting s = |S|, we have s ∈ [a, b] and S is an s-element subset of Finset.univ. Thus S belongs to the indexed union.

    lines 4–10

    uses Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_biUnion, Finset.mem_Icc, Finset.mem_powersetCard, Finset.subset_univ

      classical
      have hsub : ((Finset.univ : Finset (Finset (Fin n))).filter (fun S => a ≤ S.card ∧ S.card ≤ b))
          ⊆ (Finset.Icc a b).biUnion (fun s => (Finset.univ : Finset (Fin n)).powersetCard s) := by
        intro S hS
        simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hS
        simp only [Finset.mem_biUnion, Finset.mem_Icc, Finset.mem_powersetCard, Finset.subset_univ, true_and]
        exact ⟨S.card, hS, rfl⟩
  2. The number of subsets with sizes between a and b is at most the sum over s ∈ [a, b] of the number of subsets of size s.

    By subset monotonicity of cardinality (Finset.card_le_card), the number of such subsets is at most the size of the union. By the union bound (Finset.card_biUnion_le), the size of the union is at most the sum of the sizes of the individual families of size-s subsets.

    lines 11–13

    uses Finset.card_le_card, Finset.card_biUnion_le

      calc _ ≤ ((Finset.Icc a b).biUnion (fun s => (Finset.univ : Finset (Fin n)).powersetCard s)).card :=
            Finset.card_le_card hsub
        _ ≤ ∑ s ∈ Finset.Icc a b, ((Finset.univ : Finset (Fin n)).powersetCard s).card := Finset.card_biUnion_le
  3. The sum of the sizes of the size-s families is at most the sum of the central binomial coefficient n choose floor(n / 2) over s ∈ [a, b].

    For each s ∈ [a, b], the number of s-element subsets of Fin n is n choose s (by Finset.card_powersetCard, Finset.card_univ, and Fintype.card_fin). Because binomial coefficients peak at the middle (Nat.choose_le_middle), each term is bounded above by n choose floor(n / 2). Summing term-by-term (Finset.sum_le_sum) yields the inequality.

    lines 14–18

    uses Finset.sum_le_sum, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin, Nat.choose_le_middle

        _ ≤ ∑ s ∈ Finset.Icc a b, n.choose (n / 2) := by
            apply Finset.sum_le_sum
            intro s _
            rw [Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin]
            exact Nat.choose_le_middle s n
  4. The sum of n choose floor(n / 2) over s ∈ [a, b] equals (b - a + 1) * (n choose floor(n / 2)).

    Summing a constant over [a, b] multiplies the constant by the number of elements in the interval (Finset.sum_const, smul_eq_mul), which is b + 1 - a (Nat.card_Icc). Since a ≤ b, linear arithmetic over ℕ (omega) simplifies b + 1 - a to b - a + 1.

    lines 19–22

    uses Finset.sum_const, Nat.card_Icc, smul_eq_mul

        _ = (b - a + 1) * n.choose (n / 2) := by
            rw [Finset.sum_const, Nat.card_Icc, smul_eq_mul]
            congr 1
            omega
Finset.mem_filter
An element belongs to Finset.filter p s if and only if it belongs to s and satisfies the predicate p.
Finset.mem_univ
Every element of a finite type belongs to Finset.univ.
true_and
The conjunction True ∧ p is equivalent to p.
Finset.mem_biUnion
An element belongs to a finite union s.biUnion t if and only if it belongs to t a for some a ∈ s.
Finset.mem_Icc
An element x belongs to the closed interval Finset.Icc a b if and only if a ≤ x and x ≤ b.
Finset.mem_powersetCard
A subset belongs to Finset.powersetCard n t if and only if it is a subset of t and has cardinality n.
Finset.subset_univ
Every finset of elements from a finite type is a subset of Finset.univ.
Finset.card_le_card
If s ⊆ t, then the cardinality of s is at most the cardinality of t.
Finset.card_biUnion_le
The cardinality of a finite union is at most the sum of the cardinalities of the individual sets.
Finset.sum_le_sum
If f(i) ≤ g(i) for all elements i in a finset s, then the sum of f over s is at most the sum of g over s.
Finset.card_powersetCard
The number of k-element subsets of a finite set s is given by the binomial coefficient |s| choose k.
Finset.card_univ
The cardinality of Finset.univ for a finite type α equals the cardinality of α.
Fintype.card_fin
The cardinality of Fin n is n.
Nat.choose_le_middle
For any natural numbers r and n, the binomial coefficient n choose r is at most the central binomial coefficient n choose floor(n / 2).
Finset.sum_const
Summing a constant value over a finite set equals the cardinality of the set multiplied by the constant.
Nat.card_Icc
For natural numbers a and b, the number of elements in the discrete closed interval [a, b] is b + 1 - a.
smul_eq_mul
Scalar multiplication in ℕ is standard multiplication.

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 op861_boolean_weight_interval_count (n a b : ℕ) (hab : a ≤ b) :    ((Finset.univ : Finset (Finset (Fin n))).filter (fun S => a ≤ S.card ∧ S.card ≤ b)).card ≤      (b-a+1) * n.choose (n/2) := by  classical  have hsub : ((Finset.univ : Finset (Finset (Fin n))).filter (fun S => a ≤ S.card ∧ S.card ≤ b))      ⊆ (Finset.Icc a b).biUnion (fun s => (Finset.univ : Finset (Fin n)).powersetCard s) := by    intro S hS    simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hS    simp only [Finset.mem_biUnion, Finset.mem_Icc, Finset.mem_powersetCard, Finset.subset_univ, true_and]    exact ⟨S.card, hS, rfl⟩  calc _ ≤ ((Finset.Icc a b).biUnion (fun s => (Finset.univ : Finset (Fin n)).powersetCard s)).card :=        Finset.card_le_card hsub    _ ≤ ∑ s ∈ Finset.Icc a b, ((Finset.univ : Finset (Fin n)).powersetCard s).card := Finset.card_biUnion_le    _ ≤ ∑ s ∈ Finset.Icc a b, n.choose (n / 2) := by        apply Finset.sum_le_sum        intro s _        rw [Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin]        exact Nat.choose_le_middle s n    _ = (b - a + 1) * n.choose (n / 2) := by        rw [Finset.sum_const, Nat.card_Icc, smul_eq_mul]        congr 1        omega
See it in the graphDiscuss this resultChallenge it