Quantification Operations for DFAs #
This file implements existential (∃) and universal (∀) quantification over automata, which is fundamental for building first-order formulas in automata-based decision procedures.
Main Components #
- Quantification Operator Type: Custom type implementing operators ∃ and ∀
- Reachability Analysis: Finding states reachable with leading zeros
- Determinization: Converting NFA to DFA
- Quantification Operations: ∃ and ∀ operators over an automaton
Theory #
Given a DFA M over variables [x₁, x₂, ..., xₙ] and a variable xᵢ:
- ∃xᵢ. M: Creates a DFA over [x₁, ..., xᵢ₋₁, xᵢ₊₁, ..., xₙ] that accepts when there exists some value for xᵢ that makes M accept
- ∀xᵢ. M: Creates a DFA that accepts when M accepts for all values of xᵢ
Implementation Strategy #
- Remove Quantified Variable: Remove xᵢ's track from the alphabet
- Non-Determinization: For each input on remaining variables, consider all possible values for xᵢ, this creates an NFA
- Find All Initial States: Find all states reachable with leading zeros from the initial state
- Determinization: Convert the NFA back to DFA
- For ∀: Use De Morgan's law: ∀x.φ ≡ ¬∃x.¬φ
Quantification Operator Type #
Reachability Analysis #
These functions find all states reachable from starting states by reading zero prefixes.
Finds all states reachable from the initial state with one or more consecutive zeros.
Parameters #
transition_function: Transition function returning a list of all reachable states for a state and a symbolzero: The zero symbolcurrent_states: List of current initial states to visitnum_possible_states: Maximum number of possible initial statesstates: Already visited states
Equations
- One or more equations did not get rendered due to their size.
Instances For
NFA Determinization #
After removing a variable, we get an NFA (non-deterministic finite automaton). We use powerset construction to convert it to a DFA, with memoization for efficiency.
Determinization using depth-first search with memoization.
Algorithm (Powerset Construction) #
- Start with a set of NFA states (represented as List Nat)
- For each input symbol, compute all possible next states
- Each set of NFA states becomes a single DFA state
- Recursively process newly discovered state sets
- Use memoization to avoid recomputing transitions
Parameters #
transition_function: NFA transition function (state → input → list of states)alphabet: Input alphabetcurrent_state: Current set of NFA states (forms one DFA state)num_possible_states: Bound on recursion depth (prevents infinite loops)state: Memoization state (visited sets and cached transitions)
Returns #
Pair of (all transitions discovered, updated memoization state)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Public interface for determinization with memoization.
Parameters #
transition_function: NFA transition functionalphabet: Input alphabetinitial_state: Starting set of NFA statesmax_states: Upper bound on number of states (usually 2^n for powerset)
Returns #
List of all transitions in the determinized DFA, where each transition is ((source_state_set, input_symbol), target_state_set)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Quantification Implementation #
Existential quantification over a variable.
Parameters #
M: Original DFAzero: Zero symbol for handling leading zerosvar: Variable to quantify overalphabet_vars: All possible values for the quantified variable
Algorithm #
Remove variable from input
Create NFA
Handle leading zeros
Determinize
Accepting states
Equations
- One or more equations did not get rendered due to their size.
Instances For
Quantification operation (public interface).
Implements both existential (∃) and universal (∀) quantification.
- ∃x. M: Accepts input if there exists a value for x making M accept
- ∀x. M: Accepts input if M accepts for all values of x
Parameters #
M1: DFA to quantify overzero: Zero symbol for leading zerosvar: Variable to quantifyop_type: Quantifier type (exists or for_all)alphabet_vars: Possible values for quantified variable
Returns #
DFA_extended with Nat states representing the quantified formula
Equations
- One or more equations did not get rendered due to their size.