AFTD Auto-Formalizing Theoretical Domains

op861_boolean_block_product_bound

theoremverified

For Boolean assignments on a finite coordinate set and any family of block predicates depending on the assignment outside all blocks, the number of assignments satisfying every predicate is at most the sum over outside assignments of the product of the numbers of allowed assignments on the individual blocks. Blocks may overlap.

Statement

theorem op861_boolean_block_product_bound (β ι : Type) [Fintype β] [DecidableEq β]
    [DecidableEq ι] (J : Finset ι) (B : ι → Finset β)
    (P : ({t : β // t ∉ J.biUnion B} → Bool) →
      ∀ i : {i : ι // i ∈ J}, ({t : β // t ∈ B i.1} → Bool) → Prop)
    [∀ a i v, Decidable (P a i v)] :
    ((Finset.univ : Finset (β → Bool)).filter (fun ω =>
      ∀ i : {i : ι // i ∈ J},
        P (fun t => ω t.1) i (fun t => ω t.1))).card ≤
      ∑ a : ({t : β // t ∉ J.biUnion B} → Bool),
        ∏ i : {i : ι // i ∈ J},
          ((Finset.univ : Finset ({t : β // t ∈ B i.1} → Bool)).filter (P a i)).card
Source
Finite product bound used for op861_disjoint_boolean_windows_count.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
Used by 2
  • op861_boolean_block_uniform_boundA uniform bound on each block fiber yields a bound on the total number of good Boolean assignments by the outside-assignment count times…
  • op861_disjoint_boolean_windows_countFor a finite Boolean coordinate set, pairwise disjoint coordinate blocks, and integer offsets depending only on coordinates outside all…

The proof, explained

The proof constructs an injection from the set of valid Boolean assignments into a target type consisting of an outside assignment together with valid local assignments for each block. Because a Boolean assignment is uniquely determined by its outside restriction and its restrictions to each individual block (even if the blocks overlap), this restriction map is injective. The claim follows by bounding the cardinality of the domain by that of the target, which decomposes as a sum of products of block counts.

  1. Define the set of satisfying assignments, the target space of candidate block assignments, and the restriction map between them.

    We enable classical reasoning (`classical`) and introduce convenient shorthand: $O$ for coordinates outside all blocks, $I = J$ for the index set, and $\text{Block}(i)$ for the $i$-th block. We then define $\text{Good}$ as the subtype of global assignments $\omega : \beta \to \text{Bool}$ satisfying $P$ on every block, and $\text{Target}$ as the dependent sum over outside assignments $a : O \to \text{Bool}$ of families of block assignments satisfying $P(a, i, -)$. The mapping $\text{embed}$ restricts a global assignment $\omega$ to $O$ and to each block $B(i)$, carrying along the proofs that each block predicate is satisfied, while $\text{forget}$ strips off the predicate proofs.

    lines 14–23

      classical
      let O := {t : β // t ∉ J.biUnion B}
      let I := {i : ι // i ∈ J}
      let Block : I → Type := fun i => {t : β // t ∈ B i.1}
      let Good := {ω : β → Bool // ∀ i : I, P (fun t => ω t.1) i (fun t => ω t.1)}
      let Target := Σ a : O → Bool, ∀ i : I, {v : Block i → Bool // P a i v}
      let embed : Good → Target := fun ω =>
        ⟨fun t => ω.1 t.1, fun i => ⟨fun t => ω.1 t.1, ω.2 i⟩⟩
      let forget : Target → (O → Bool) × (∀ i : I, Block i → Bool) := fun z =>
        (z.1, fun i => (z.2 i).1)
  2. The restriction map embed is injective.

    Suppose two assignments $a, b \in \text{Good}$ have the same image under $\text{embed}$ (`intro a b h`). To show $a = b$, it suffices to show their underlying functions are equal (`Subtype.ext`). Applying `forget` to the equality $\text{embed}(a) = \text{embed}(b)$ via `congrArg` shows that $a$ and $b$ agree outside the blocks and on every block. By `op861_boolean_restrictions_injective`, an assignment is completely determined by these restrictions, so the underlying functions are equal.

    lines 24–28

    uses Subtype.ext, op861_boolean_restrictions_injective, congrArg

      have hinj : Function.Injective embed := by
        intro a b h
        apply Subtype.ext
        apply op861_boolean_restrictions_injective β ι J B
        exact congrArg forget h
  3. The cardinality of Good is at most the cardinality of Target.

    Because $\text{embed} : \text{Good} \to \text{Target}$ is an injection between finite types, the cardinality of the domain is at most the cardinality of the target (`Fintype.card_le_of_injective`).

    line 29

    uses Fintype.card_le_of_injective

      have hcard := Fintype.card_le_of_injective embed hinj
  4. The number of valid global assignments is bounded by the sum over outside assignments of the product of allowed block assignments.

    We rewrite the inequality $|\text{Good}| \le |\text{Target}|$ using the definitions of $\text{Good}$, $\text{Target}$, $O$, $I$, and $\text{Block}$. By `Fintype.card_sigma`, the cardinality of the sigma type becomes the sum over outside assignments $a$. By `Fintype.card_pi`, the cardinality of the product type becomes the product over blocks $i \in J$. Finally, by `Fintype.card_subtype`, each subtype cardinality translates to the cardinality of the corresponding filtered finite set, concluding the proof.

    line 30

    uses Fintype.card_sigma, Fintype.card_pi, Fintype.card_subtype

      simpa [Good, Target, O, I, Block, Fintype.card_sigma, Fintype.card_pi, Fintype.card_subtype] using hcard
Subtype.ext
Two elements of a subtype are equal if their underlying values are equal.
op861_boolean_restrictions_injective
A Boolean assignment is uniquely determined by its restriction to the coordinates outside all blocks together with its restrictions to each individual block.
congrArg
Applying a function to equal inputs produces equal outputs.
Fintype.card_le_of_injective
If there is an injective function from a finite type to another, the cardinality of the domain is at most the cardinality of the codomain.
Fintype.card_sigma
The cardinality of a dependent sum (sigma type) of finite types is the sum of the cardinalities of the individual fibers.
Fintype.card_pi
The cardinality of a dependent function type (product) of finite types is the product of the cardinalities of the individual factor types.
Fintype.card_subtype
The cardinality of a subtype equals the number of elements in the corresponding filtered finite set.

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

open scoped BigOperatorstheorem op861_boolean_block_product_bound (β ι : Type) [Fintype β] [DecidableEq β]    [DecidableEq ι] (J : Finset ι) (B : ι → Finset β)    (P : ({t : β // t ∉ J.biUnion B} → Bool) →      ∀ i : {i : ι // i ∈ J}, ({t : β // t ∈ B i.1} → Bool) → Prop)    [∀ a i v, Decidable (P a i v)] :    ((Finset.univ : Finset (β → Bool)).filter (fun ω =>      ∀ i : {i : ι // i ∈ J},        P (fun t => ω t.1) i (fun t => ω t.1))).card ≤      ∑ a : ({t : β // t ∉ J.biUnion B} → Bool),        ∏ i : {i : ι // i ∈ J},          ((Finset.univ : Finset ({t : β // t ∈ B i.1} → Bool)).filter (P a i)).card := by  classical  let O := {t : β // t ∉ J.biUnion B}  let I := {i : ι // i ∈ J}  let Block : I → Type := fun i => {t : β // t ∈ B i.1}  let Good := {ω : β → Bool // ∀ i : I, P (fun t => ω t.1) i (fun t => ω t.1)}  let Target := Σ a : O → Bool, ∀ i : I, {v : Block i → Bool // P a i v}  let embed : Good → Target := fun ω =>    ⟨fun t => ω.1 t.1, fun i => ⟨fun t => ω.1 t.1, ω.2 i⟩⟩  let forget : Target → (O → Bool) × (∀ i : I, Block i → Bool) := fun z =>    (z.1, fun i => (z.2 i).1)  have hinj : Function.Injective embed := by    intro a b h    apply Subtype.ext    apply op861_boolean_restrictions_injective β ι J B    exact congrArg forget h  have hcard := Fintype.card_le_of_injective embed hinj  simpa [Good, Target, O, I, Block, Fintype.card_sigma, Fintype.card_pi, Fintype.card_subtype] using hcard
See it in the graphDiscuss this resultChallenge it