AFTD Auto-Formalizing Theoretical Domains

op861_boolean_matching_set_injective

theoremverified

A Boolean assignment is uniquely determined by the set of positions where it matches a fixed Boolean pattern.

Statement

theorem op861_boolean_matching_set_injective (β : Type*) [Fintype β] [DecidableEq β]
    (pattern : β → Bool) : Function.Injective
      (fun v : β → Bool => Finset.univ.filter (fun t => v t = pattern t))
Source
Per-block estimate for op861_disjoint_boolean_windows_count.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1
  • op861_boolean_matching_window_countFor a finite Boolean coordinate set, a fixed bit pattern, an integer offset, and an integer interval with ordered endpoints, the number of…

The proof, explained

To show that the set of matching positions uniquely identifies a Boolean assignment, we assume two assignments v and w have identical matching sets with a fixed pattern. Since the sets are equal, an index t matches the pattern under v if and only if it matches under w. A case analysis on the Boolean values of v(t), w(t), and pattern(t) shows that v(t) and w(t) cannot disagree without causing a contradiction, establishing v = w by functional extensionality.

  1. To show injectivity, it suffices to prove that v(t) = w(t) for an arbitrary element t : β, assuming assignments v and w produce the same matching set.

    By definition of injectivity, we assume two Boolean assignments v and w produce the same matching set with pattern (hypothesis h). By functional extensionality (funext), v = w follows if v(t) = w(t) holds for every coordinate t.

    lines 4–6

      classical
      intro v w h
      funext t
  2. For any coordinate t, v(t) = pattern(t) if and only if w(t) = pattern(t).

    Applying the predicate (t ∈ ·) to both sides of the set equality h via congrArg shows that t is in the matching set of v if and only if it is in the matching set of w. Simplifying with Finset.mem_filter, Finset.mem_univ, and true_and simplifies membership in {t ∈ Finset.univ | v(t) = pattern(t)} directly to the equality of truth values (v(t) = pattern(t)) = (w(t) = pattern(t)).

    lines 7–8

    uses congrArg, Finset.mem_filter, Finset.mem_univ, true_and

      have hm := congrArg (fun X : Finset β => t ∈ X) h
      simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hm
  3. v(t) = w(t) holds for all t, completing the proof.

    There are eight possible Boolean truth-value combinations for the triple (v(t), w(t), pattern(t)). In the cases where v(t) ≠ w(t), one matches pattern(t) and the other does not, contradicting the fact that (v(t) = pattern(t)) is equivalent to (w(t) = pattern(t)). In the remaining cases where v(t) = w(t), the goal holds trivially. The simp_all tactic evaluates the Boolean expressions and discharges all branches.

    line 9

      cases hv : v t <;> cases hw : w t <;> cases hp : pattern t <;> simp_all
congrArg
Applying a function to equal arguments yields equal results: if a₁ = a₂, then f(a₁) = f(a₂).
Finset.mem_filter
An element a belongs to {x ∈ s | p x} if and only if a ∈ s and p a holds.
Finset.mem_univ
Every element of a finite type belongs to the universal set Finset.univ.
true_and
The proposition (True ∧ p) is equivalent to p.

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_matching_set_injective (β : Type*) [Fintype β] [DecidableEq β]    (pattern : β → Bool) : Function.Injective      (fun v : β → Bool => Finset.univ.filter (fun t => v t = pattern t)) := by  classical  intro v w h  funext t  have hm := congrArg (fun X : Finset β => t ∈ X) h  simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hm  cases hv : v t <;> cases hw : w t <;> cases hp : pattern t <;> simp_all
See it in the graphDiscuss this resultChallenge it