Skip to main content
QUICK REVIEW

[论文解读] Sorting Finite Automata via Partition Refinement

Ruben Becker, Manuel Cáceres|arXiv (Cornell University)|Jan 1, 2023
semigroups and automata theory被引用 1
一句话总结

该论文提出了一种高效的 O(|δ| log |Q|)-time 算法,用于在 Wheeler NFA 中计算共字典序总预序,以及在 DFA 中计算最小宽度共字典序偏序,采用扩展的划分细化技术。通过将 Paige-Tarjan 算法适配至有序划分并引入剪枝启发式方法,该方法实现了最优时间复杂度,并在实践中优于先前方法,其实现表明在大规模自动机上性能提升最高可达 10,000×。

ABSTRACT

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.

研究动机与目标

  • 解决在有限自动机中进行模式匹配时共字典序预序计算的性能瓶颈,尤其针对大规模应用如泛基因组图谱。
  • 通过聚焦于保留 Wheeler 顺序实用性的预序计算,克服决定 Wheeler 自动机的 NP-完全性问题。
  • 为 DFA 上的最小宽度共字典序偏序和 WNFA 上的总预序,开发一种时间与空间高效的算法。
  • 提供可扩展至超过 5000 万个状态和边的自动机的实用实现,展示其在真实场景中的高效性。

提出的方法

  • 将经典的 Paige-Tarjan 划分细化算法扩展至有序划分,以支持状态的共字典序排序。
  • 引入一种剪枝机制,在细化后移除冗余转移,确保在剪枝后的自动机中每个非源状态恰好有一条进入边。
  • 通过在剪枝自动机 Ainf 和 Asup 上进行反向遍历,分别计算每个状态所接受字符串的下确界与上确界。
  • 应用类似后缀加倍的算法,利用基于指针的 2k-跳导航,在 O(|Q| log |Q|) 时间内计算逆后缀数组(ISA)的共字典序。
  • 利用摊还分析证明剪枝仅增加 O(|δ|) 总工作量,从而保持 O(|δ| log |Q|) 的时间复杂度。
  • 使用 C++ 实现该算法,并在合成数据与真实世界中的泛基因组 DFA 上进行评估,与 WGT 重命名启发式方法进行对比。

实验结果

研究问题

  • RQ1是否可以在 O(|δ| log |Q|) 时间内计算 Wheeler NFA 中状态的共字典序顺序,达到划分细化的理论下界?
  • RQ2是否能够以 O(|δ| log |Q|) 时间复杂度计算任意 DFA 的最小宽度共字典序偏序,优于先前的 O(|δ|² + |Q|⁵ᐟ²) 上界?
  • RQ3在大规模自动机上,所提出的带剪枝的划分细化方法与现有工具(如 WGT 的重命名启发式方法)相比,实际表现如何?
  • RQ4剪枝步骤在多大程度上保持了正确性,同时减少了细化过程中的内存与时间开销?
  • RQ5该算法是否能够在包含超过 5000 万个状态和边的真实世界泛基因组图谱上保持低内存与时间复杂度的同时实现可扩展性?

主要发现

  • 所提算法在 O(|δ| log |Q|) 时间内为任意 Wheeler NFA 计算共字典序总预序,达到 Paige-Tarjan 算法的最优复杂度。
  • 对于 DFA,该算法在 O(|δ| log |Q|) 时间内计算出最小宽度共字典序偏序,优于先前的 O(|δ|² + |Q|⁵ᐟ²) 上界。
  • 在 100 万个状态的 NFA 上,实现可在约 7 秒内完成 Wheeler 预序计算,表现出接近线性的可扩展性。
  • 在运行时间上,该实现相比 WGT 重命名启发式方法最高提升 10,000×,并在大输入数据上展现出 3 倍的内存优势。
  • 该算法在 355 秒内成功剪枝了一个包含 5100 万个状态和 5300 万个边的泛基因组 DFA,峰值内存仅使用 33.2 GB。
  • 剪枝步骤仅增加 O(|δ|) 的摊还时间,证实尽管增加了额外处理,整体复杂度仍保持在 O(|δ| log |Q|)。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。