AFTD Auto-Formalizing Theoretical Domains

op309_clean_component_charge_count

theoremverified

If every path component is charged to a bad path or bad star, each bad path has at most nine charges, each bad star at most ten, there are at most 2b bad components, and at most s of them are stars, then there are at most 18b+s paths.

Statement

theorem op309_clean_component_charge_count
    {C : Type*} [DecidableEq C]
    (P Bp Bs : Finset C) (T : C → Finset C) (b s : ℕ)
    (hcover : P ⊆ (Bp ∪ Bs).biUnion T)
    (hp : ∀ x ∈ Bp, (T x).card ≤ 9)
    (hs : ∀ x ∈ Bs, (T x).card ≤ 10)
    (hbad : Bp.card + Bs.card ≤ 2*b) (hstar : Bs.card ≤ s) :
    P.card ≤ 18*b + s
Source
OP-309 clean-component charging argument.
Verified
27 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

The proof bounds the total number of paths |P| by charging them to bad paths Bp and bad stars Bs. Subadditivity of set unions bounds |P| by 9 * |Bp| + 10 * |Bs| = 9 * (|Bp| + |Bs|) + |Bs|. Substituting the bounds on the total number of bad components (|Bp| + |Bs| ≤ 2b) and bad stars (|Bs| ≤ s) immediately yields |P| ≤ 18b + s.

  1. The number of paths is bounded by the size of the union of charges over all bad components, |P| ≤ |⋃_{x ∈ Bp ∪ Bs} T(x)|.

    Because P is covered by the charges of bad paths and bad stars (hypothesis `hcover`), monotonicity of finite set cardinality (`Finset.card_le_card`) bounds |P| by the size of this union.

    line 9

    uses Finset.card_le_card

      have h1 : P.card ≤ ((Bp ∪ Bs).biUnion T).card := Finset.card_le_card hcover
  2. The union over all bad components has size at most |⋃_{x ∈ Bp} T(x)| + |⋃_{x ∈ Bs} T(x)|.

    Decomposing the indexing set Bp ∪ Bs into Bp and Bs splits the union into the union of charges on bad paths and charges on bad stars (`Finset.union_biUnion`). The size of this union is at most the sum of their sizes by subadditivity (`Finset.card_union_le`).

    lines 10–11

    uses Finset.union_biUnion, Finset.card_union_le

      have h2 : ((Bp ∪ Bs).biUnion T).card ≤ (Bp.biUnion T).card + (Bs.biUnion T).card := by
        rw [Finset.union_biUnion]; exact Finset.card_union_le _ _
  3. The charges to bad paths cover at most 9 * |Bp| paths, |⋃_{x ∈ Bp} T(x)| ≤ 9 * |Bp|.

    By subadditivity (`Finset.card_biUnion_le`), the union of charges over Bp is bounded by the sum ∑_{x ∈ Bp} |T(x)|. Since each bad path has at most 9 charges (hypothesis `hp`), comparing term-by-term (`Finset.sum_le_sum`) bounds the sum by ∑_{x ∈ Bp} 9, which evaluates to 9 * |Bp| (`Finset.sum_const`, `smul_eq_mul`).

    lines 12–15

    uses Finset.card_biUnion_le, Finset.sum_le_sum, Finset.sum_const, smul_eq_mul

      have h3 : (Bp.biUnion T).card ≤ Bp.card * 9 := by
        calc _ ≤ ∑ x ∈ Bp, (T x).card := Finset.card_biUnion_le
          _ ≤ ∑ _x ∈ Bp, 9 := Finset.sum_le_sum hp
          _ = Bp.card * 9 := by rw [Finset.sum_const, smul_eq_mul]
  4. The charges to bad stars cover at most 10 * |Bs| paths, |⋃_{x ∈ Bs} T(x)| ≤ 10 * |Bs|.

    Similarly, subadditivity (`Finset.card_biUnion_le`) bounds the union over Bs by ∑_{x ∈ Bs} |T(x)|. Since each bad star receives at most 10 charges (hypothesis `hs`), the sum is bounded by ∑_{x ∈ Bs} 10 = 10 * |Bs| via `Finset.sum_le_sum`, `Finset.sum_const`, and `smul_eq_mul`.

    lines 16–19

    uses Finset.card_biUnion_le, Finset.sum_le_sum, Finset.sum_const, smul_eq_mul

      have h4 : (Bs.biUnion T).card ≤ Bs.card * 10 := by
        calc _ ≤ ∑ x ∈ Bs, (T x).card := Finset.card_biUnion_le
          _ ≤ ∑ _x ∈ Bs, 10 := Finset.sum_le_sum hs
          _ = Bs.card * 10 := by rw [Finset.sum_const, smul_eq_mul]
  5. |P| ≤ 18 * b + s automation

    Combining the previous inequalities gives |P| ≤ 9 * |Bp| + 10 * |Bs| = 9 * (|Bp| + |Bs|) + |Bs|. Since total bad components satisfy |Bp| + |Bs| ≤ 2 * b (`hbad`) and bad stars satisfy |Bs| ≤ s (`hstar`), linear integer arithmetic deduces |P| ≤ 9 * (2 * b) + s = 18 * b + s.

    line 20

      omega
Finset.card_le_card
A subset has cardinality at most that of its superset.
Finset.union_biUnion
A union of indexed sets over the union of two index sets is the union of the two respective indexed unions.
Finset.card_union_le
The cardinality of a union of two finite sets is at most the sum of their cardinalities.
Finset.card_biUnion_le
The cardinality of an indexed union of finite sets is at most the sum of the cardinalities of the individual sets.
Finset.sum_le_sum
If each term of one sum is bounded by the corresponding term of another, the first sum is bounded by the second.
Finset.sum_const
Summing a constant value over a finite set equals the cardinality of the set scalar-multiplied by the constant.
smul_eq_mul
Scalar multiplication of natural numbers coincides with ordinary 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 op309_clean_component_charge_count    {C : Type*} [DecidableEq C]    (P Bp Bs : Finset C) (T : C → Finset C) (b s : ℕ)    (hcover : P ⊆ (Bp ∪ Bs).biUnion T)    (hp : ∀ x ∈ Bp, (T x).card ≤ 9)    (hs : ∀ x ∈ Bs, (T x).card ≤ 10)    (hbad : Bp.card + Bs.card ≤ 2*b) (hstar : Bs.card ≤ s) :    P.card ≤ 18*b + s := by  have h1 : P.card ≤ ((Bp ∪ Bs).biUnion T).card := Finset.card_le_card hcover  have h2 : ((Bp ∪ Bs).biUnion T).card ≤ (Bp.biUnion T).card + (Bs.biUnion T).card := by    rw [Finset.union_biUnion]; exact Finset.card_union_le _ _  have h3 : (Bp.biUnion T).card ≤ Bp.card * 9 := by    calc _ ≤ ∑ x ∈ Bp, (T x).card := Finset.card_biUnion_le      _ ≤ ∑ _x ∈ Bp, 9 := Finset.sum_le_sum hp      _ = Bp.card * 9 := by rw [Finset.sum_const, smul_eq_mul]  have h4 : (Bs.biUnion T).card ≤ Bs.card * 10 := by    calc _ ≤ ∑ x ∈ Bs, (T x).card := Finset.card_biUnion_le      _ ≤ ∑ _x ∈ Bs, 10 := Finset.sum_le_sum hs      _ = Bs.card * 10 := by rw [Finset.sum_const, smul_eq_mul]  omega
See it in the graphDiscuss this resultChallenge it