Repository navigation
nfa: +refactor Compute useful states with two reachability passes - #886
Merged
Merged
Conversation
Adda0
force-pushed
the
issue-786-useful-states-pr
branch
from
October 15, 2026 11:41
5fe91e2 to
bf0abe7
Compare
Adda0
marked this pull request as ready for review
October 15, 2026 12:56
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
Adda0
force-pushed
the
issue-786-useful-states-pr
branch
2 times, most recently
from
October 16, 2026 08:57
72cc07c to
79d7e8d
Compare
Replace the Tarjan-based implementation of get_useful_states() with a simpler and faster two-pass algorithm: a forward reachability pass from initial states, followed by a backward BFS from final states over a predecessor CSR (compressed sparse row) index. The new implementation: - Adds a label-free predecessor CSR index with a source filter to only index forward-reachable transitions - Implements forward reachability from a custom initial set - Walks backward over predecessors to find all useful states - Honors custom initial and final sets for noodlification use cases LOCAL BENCHMARK (Release build, 1M-state DAG with 2M transitions): - Old Tarjan-based: 22.2 ms/iter - New two-pass: 8.8 ms/iter - Speedup: 2.52× Keeps Tarjan in place for its remaining callers (is_acyclic, is_flat, tarjan_scc_discover). Permanent test added: 'mata::nfa::get_useful_states() with brute-force oracle' validates correctness against an independent oracle on randomized graphs (50 test cases with 5-50 states and random edges) and verifies trim() state renamings. Part of #786. Not included: the benchmark against the compact templated Tarjan of #224 (b) and recording the decision in the issue (item 3), and the optional sharing of the predecessor index through #811 (item 5).
Adda0
force-pushed
the
issue-786-useful-states-pr
branch
from
October 16, 2026 10:29
79d7e8d to
efeb622
Compare
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.
Replace the Tarjan-based implementation of get_useful_states() with a simpler and faster two-pass algorithm: a forward reachability pass from initial states, followed by a backward BFS from final states over a predecessor CSR (compressed sparse row) index. The new implementation:
LOCAL BENCHMARK (Release build, 1M-state DAG with 2M transitions):
Keeps Tarjan in place for its remaining callers (is_acyclic, is_flat, tarjan_scc_discover).
Permanent test added: 'mata::nfa::get_useful_states() with brute-force oracle' validates correctness against an independent oracle on randomized graphs (50 test cases with 5-50 states and random edges) and verifies trim() state renamings.
Part of #786. Not included: the benchmark against the compact templated
Tarjan of #224 (b) and recording the decision in the issue (item 3), and the
optional sharing of the predecessor index through #811 (item 5).