[Paper Review] Sorting Finite Automata via Partition Refinement
This paper presents an efficient O(|δ| log |Q|)-time algorithm for computing co-lex total preorders in Wheeler NFAs and the smallest-width co-lex partial order in DFAs using an extended partition refinement technique. By adapting the Paige-Tarjan algorithm to ordered partitions and incorporating pruning heuristics, the method achieves optimal time complexity and outperforms prior approaches in practice, with implementations showing up to 10,000× speedup on large automata.
Wheeler nondeterministic finite automata (WNFAs) were introduced as a generalization of prefix sorting from strings to labeled graphs. WNFAs admit optimal solutions to classic hard problems on labeled graphs and languages. The problem of deciding whether a given NFA is Wheeler is known to be NP-complete. Recently, however, Alanko et al. showed how to side-step this complexity by switching to preorders: letting $Q$ be the set of states, $E$ the set of transitions, $|Q|=n$, and $|E|=m$, they provided a $O(mn^2)$-time algorithm computing a totally-ordered partition of the WNFA's states such that (1) equivalent states recognize the same regular language, and (2) the order of non-equivalent states is consistent with any Wheeler order, when one exists. Then, the output is a preorder of the states as useful for pattern matching as standard Wheeler orders. Further research generalized these concepts to arbitrary NFAs by introducing co-lex partial preorders: any NFA admits a partial preorder of its states reflecting the co-lex order of their accepted strings; the smaller the width of such preorder is, the faster regular expression matching queries can be performed. To date, the fastest algorithm for computing the smallest-width partial preorder on NFAs runs in $O(m^2+n^{5/2})$ time, while on DFAs the same can be done in $O(\min(n^2\log n,mn))$ time. In this paper, we provide much more efficient solutions to the problem above. Our results are achieved by extending a classic algorithm for the relational coarsest partition refinement problem to work with ordered partitions. Specifically, we provide a $O(m\log n)$-time algorithm computing a co-lex total preorder when the input is a WNFA, and an algorithm with the same time complexity computing the smallest-width co-lex partial order of any DFA. Also, we present implementations of our algorithms and show that they are very efficient in practice.
Motivation & Objective
- Address the computational bottleneck in computing co-lex preorders for pattern matching in finite automata, especially for large-scale applications like pangenome graphs.
- Overcome the NP-completeness of deciding Wheeler automata by focusing on preorder computation that preserves the utility of Wheeler orders.
- Develop a time- and space-efficient algorithm for computing the smallest-width co-lex partial order on DFAs and total preorder on WNFAs.
- Provide practical implementations that scale to automata with over 50 million states and edges, demonstrating real-world efficiency.
Proposed method
- Extend the classic Paige-Tarjan algorithm for coarsest partition refinement to operate on ordered partitions, enabling co-lexicographic ordering of states.
- Introduce a pruning mechanism that removes redundant transitions after refinement, ensuring each non-source state has exactly one incoming transition in the pruned automaton.
- Compute the infimum and supremum of accepted strings for each state using backward walks on pruned automata Ainf and Asup, respectively.
- Apply a suffix-doubling style algorithm to compute the co-lex order of the inverse suffix array (ISA) in O(|Q| log |Q|) time using pointer-based 2k-hop navigation.
- Leverage amortized analysis to show that pruning adds only O(|δ|) total work, preserving the O(|δ| log |Q|) time complexity.
- Implement the algorithm in C++ and evaluate it on synthetic and real-world pangenome DFAs, comparing against the WGT renaming heuristic.
Experimental results
Research questions
- RQ1Can the co-lex order of states in a Wheeler NFA be computed in O(|δ| log |Q|) time, matching the theoretical lower bound of partition refinement?
- RQ2Is it possible to compute the smallest-width co-lex partial order for any DFA in O(|δ| log |Q|) time, improving over the prior O(|δ|² + |Q|⁵ᐟ²) bound?
- RQ3How does the proposed partition refinement with pruning compare in practice to existing tools like WGT’s renaming heuristic for large-scale automata?
- RQ4To what extent does the pruning step preserve correctness while reducing memory and time overhead in the refinement process?
- RQ5Can the algorithm scale to real-world pangenome graphs with over 50 million states and edges while maintaining low memory and time complexity?
Key findings
- The proposed algorithm computes a co-lex total preorder for any Wheeler NFA in O(|δ| log |Q|) time, matching the optimal complexity of the Paige-Tarjan algorithm.
- For DFAs, the algorithm computes the smallest-width co-lex partial order in O(|δ| log |Q|) time, improving upon the previous O(|δ|² + |Q|⁵ᐟ²) bound.
- On a 1-million-state NFA, the implementation computes the Wheeler preorder in approximately 7 seconds, demonstrating near-linear scalability.
- The implementation outperforms the WGT renaming heuristic by up to 10,000× in running time and shows a 3× memory advantage on large inputs.
- The algorithm successfully pruned a pangenomic DFA with 51 million states and 53 million edges in 355 seconds, using only 33.2 GB of peak memory.
- The pruning step adds only O(|δ|) amortized time, confirming that the overall complexity remains O(|δ| log |Q|) despite additional processing.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.