AFTD Auto-Formalizing Theoretical Domains

op_2130_coin_blocks_avoid_count

theoremverified

For N blocks of L Boolean coins and any fixed L-coin tape, the number of block assignments in which every block differs from that tape is exactly (2^L − 1)^N.

Statement

theorem op_2130_coin_blocks_avoid_count (N L : ℕ) (coin : Fin L → Bool) :
    (Finset.univ.filter (fun f : Fin N → (Fin L → Bool) => ∀ i, f i ≠ coin)).card =
      (2 ^ L - 1) ^ N
Source
Independent-block counterexample to op_2130_path_greedy_fixed_time_tail
Verified
22 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

The proof reformulates the condition that every block differs from the target tape by identifying the set of valid sequences as the Cartesian product of N identical sets, each consisting of all 2^L possible L-coin blocks except the forbidden one. Using standard product and set-difference cardinality lemmas, the size of this product is computed as the N-th power of the size of each factor, (2^L − 1)^N.

  1. The set of sequences of N blocks that avoid the fixed block at every index equals the Cartesian product of N copies of the set of all blocks excluding that fixed block.

    We enable classical reasoning so that all finset operations are available. We then claim that the filtered set of functions equals the product set Fintype.piFinset of N copies of the universe minus the target block. By functional extensionality (ext f), two sets are equal if they have the same elements; an element f satisfies the filter condition (f i ≠ coin for all i) if and only if each f i lies in the universal set with coin removed, which matches the definition of membership in a product set via Fintype.mem_piFinset.

    lines 4–8

    uses Fintype.mem_piFinset

      classical
      have h : (Finset.univ.filter (fun f : Fin N → (Fin L → Bool) => ∀ i, f i ≠ coin)) =
          Fintype.piFinset (fun _ : Fin N => Finset.univ.erase coin) := by
        ext f
        simp [Fintype.mem_piFinset]
  2. The cardinality of the set of valid sequences is (|univ| − 1)^N, where univ is the set of all L-coin blocks.

    We rewrite the goal using the set equivalence established in the previous step. By Fintype.card_piFinset_const, the cardinality of an N-fold product of a set S is |S|^N. Because coin belongs to the universal set of blocks by Finset.mem_univ, removing it reduces the cardinality by 1 via Finset.card_erase_of_mem.

    line 9

    uses Fintype.card_piFinset_const, Finset.card_erase_of_mem, Finset.mem_univ

      rw [h, Fintype.card_piFinset_const, Finset.card_erase_of_mem (Finset.mem_univ coin)]
  3. The total number of valid block assignments is (2^L − 1)^N.

    Simplification evaluates the cardinality of the universe of functions Fin L → Bool to 2^L (since each of the L coin positions independently has 2 Boolean possibilities). Substituting this into (|univ| − 1)^N closes the goal with (2^L − 1)^N.

    line 10

      simp
Fintype.mem_piFinset
An element f belongs to the Cartesian product ∏_{a} t(a) if and only if f(a) ∈ t(a) for all indices a.
Fintype.card_piFinset_const
The cardinality of the Cartesian product of n copies of a finite set s is |s|^n.
Finset.card_erase_of_mem
Removing an element a from a finite set s that contains it yields a set of cardinality |s| − 1.
Finset.mem_univ
Every element of a finite type belongs to the universal finite set of that type.

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 op_2130_coin_blocks_avoid_count (N L : ℕ) (coin : Fin L → Bool) :    (Finset.univ.filter (fun f : Fin N → (Fin L → Bool) => ∀ i, f i ≠ coin)).card =      (2 ^ L - 1) ^ N := by  classical  have h : (Finset.univ.filter (fun f : Fin N → (Fin L → Bool) => ∀ i, f i ≠ coin)) =      Fintype.piFinset (fun _ : Fin N => Finset.univ.erase coin) := by    ext f    simp [Fintype.mem_piFinset]  rw [h, Fintype.card_piFinset_const, Finset.card_erase_of_mem (Finset.mem_univ coin)]  simp
See it in the graphDiscuss this resultChallenge it