AFTD Auto-Formalizing Theoretical Domains

op874_finset_progress_card_le

theoremverified

A process that starts with an empty finite set and adds at most one element at each step has at most n elements after n steps.

Statement

theorem op874_finset_progress_card_le {α : Type*} [DecidableEq α]
    (S : ℕ → Finset α) (n : ℕ) (h0 : S 0 = ∅)
    (hstep : ∀ i < n, ((S (i+1)) \ (S i)).card ≤ 1) :
    (S n).card ≤ n
Source
OP-874: dense gadget obstruction to bounded component-switch repair, experiment 38459.
Verified
24 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

The proof, explained

The proof proceeds by mathematical induction on n. In the base case, the initial set S(0) is empty and therefore has size 0 ≤ 0. In the inductive step, the size of S(n + 1) is bounded by the size of S(n) plus the at most 1 element added in the difference S(n + 1) \ S(n); applying the induction hypothesis |S(n)| ≤ n gives |S(n + 1)| ≤ n + 1.

  1. Base case: |S(0)| ≤ 0

    We proceed by induction on n. In the base case n = 0, the assumption h0 gives S(0) = ∅. Since the empty set has cardinality 0, the inequality 0 ≤ 0 holds immediately.

    lines 5–6

      induction n with
      | zero => simp [h0]
  2. By induction hypothesis, |S(n)| ≤ n

    For the inductive step from n to n + 1, any index i < n also satisfies i < n + 1 (verified by linear arithmetic). Applying the induction hypothesis to the restriction of the step condition yields |S(n)| ≤ n.

    lines 7–8

      | succ n ih =>
        have hi : (S n).card ≤ n := ih (fun i hi => hstep i (by omega))
  3. |S(n + 1) \ S(n)| ≤ 1

    Specializing the step hypothesis to i = n (which is strictly less than n + 1) shows that the number of new elements added at step n is at most 1.

    line 9

        have hs := hstep n (by omega)
  4. |S(n + 1)| ≤ |S(n + 1) \ S(n)| + |S(n)|

    By the general set-theoretic lemma Finset.card_le_card_sdiff_add_card, any finite set's cardinality is bounded by the cardinality of its difference with another set plus the cardinality of that set.

    line 10

    uses Finset.card_le_card_sdiff_add_card

        have hc := Finset.card_le_card_sdiff_add_card (s := S (n+1)) (t := S n)
  5. |S(n + 1)| ≤ n + 1

    Combining |S(n + 1)| ≤ |S(n + 1) \ S(n)| + |S(n)| with |S(n + 1) \ S(n)| ≤ 1 and |S(n)| ≤ n yields |S(n + 1)| ≤ 1 + n = n + 1 by linear arithmetic.

    line 11

        omega
Finset.card_le_card_sdiff_add_card
For any two finite sets s and t, the cardinality of s is at most the cardinality of the difference s \ t plus the cardinality of t.

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 op874_finset_progress_card_le {α : Type*} [DecidableEq α]    (S : ℕ → Finset α) (n : ℕ) (h0 : S 0 = ∅)    (hstep : ∀ i < n, ((S (i+1)) \ (S i)).card ≤ 1) :    (S n).card ≤ n := by  induction n with  | zero => simp [h0]  | succ n ih =>    have hi : (S n).card ≤ n := ih (fun i hi => hstep i (by omega))    have hs := hstep n (by omega)    have hc := Finset.card_le_card_sdiff_add_card (s := S (n+1)) (t := S n)    omega
See it in the graphDiscuss this resultChallenge it