Repository navigation
Conversation
equivalent, subset, cardinality and difference no longer determinize or complement their operands: they walk the sets of states a word can reach (bisimulation up to congruence for equivalent, antichains for subset). Two deterministic automata are compared with Hopcroft & Karp. has_intersection no longer builds the intersection, Term::is_finite looks for a cycle instead of counting, Term::is_total uses subset, and remove_state(s) no longer scan every state's transitions.
alexvbrdn
force-pushed
the
avoid-determinization
branch
from
November 19, 2026 18:21
2c16da9 to
ea0e939
Compare
Since #11, `union_mut_nondegenerate` checks the state limit with `union_state_count_nondegenerate`, and only `test_heuristic` used `union_state_count_heuristic`, which added the degenerate cases and was kept in the `impl` behind `#[cfg(test)]`. It is now a helper of the tests module, and the remaining count is `union_state_count`.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
equivalent,subset,cardinalityanddifferenceno longer determinize or complement their operands. Instead they work on the sets of states a word can reach in each automaton, and only build the sets that are actually reached. Determinizing first can produce exponentially many states, so these operations are now much faster on non-deterministic automata.equivalent: bisimulation up to congruence (HKC, Bonchi & Pous, POPL 2013). Two deterministic automata are compared state by state with Hopcroft & Karp (1971), in close to linear time.subset: antichains (De Wulf, Doyen, Henzinger & Raskin, CAV 2006), in the forward form.cardinality: on a non-deterministic automaton with a finite language, strings are counted per set of states, so a string with several paths is counted once. It returnsBigIntegeras soon as one set's count overflows.difference: each state of the result pairs a state of the minuend with the set of subtrahend states the same word reaches. Only the pairs the minuend reaches are built.Also:
has_intersectionno longer builds the intersection.Term::is_finitelooks for a cycle on an accepting path instead of counting strings.Term::is_totalusessubsetinstead of determinizing.remove_state/remove_statesno longer scan every state's transitions.SharedSpanningSetreplaces the spanning-set merge code that was duplicated acrossintersection,has_intersectionand the new algorithms.FastAutomaton::transitions_fromnow returns an iterator that can be cloned (+ Clone).Behaviour change: when the execution profile disables implicit determinization,
FastAutomaton::equivalent,subset,cardinalityanddifferencenow accept non-deterministic automata instead of returningEngineError::DeterministicAutomatonRequired.max_number_of_statescaps the pairs or sets they visit. Onlyminimizeandcomplementstill determinize implicitly.On the new benches in
benches/operations.rs:equivalent/subset: 2 to 20 times faster, and about 100 times faster where most pairs are skipped.difference: up to 3 times faster, and about 170 times faster when the minuend reaches few of the subtrahend's sets.has_intersection: about 3 times faster.minimize: 17% faster on the large pattern.Checklist
cargo fmt --all --checkandcargo clippy --all-targets -- -D warningspasscargo testandcargo test --no-default-featurespassCHANGELOG.mdis updated under## [Unreleased]