arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2510.09311cs.DS
收藏

改进的扩展正则表达式匹配

Improved Extended Regular Expression Matching

DTU(丹麦技术大学)

Philip Bille, Inge Li Gørtz, Rikke Schjeldrup Jessen

AI总结:

本文提出了一种改进的扩展正则表达式匹配算法,通过新的表示法和聚类技术,将时间复杂度降低至 $O(n^ωk + \frac{n^2m}{\max(w/\log w, \log n)} + m)$,空间复杂度为 $O(n^2 + m)$。

摘要:

扩展正则表达式 $R$ 指定了由字母表中的字符结合连接、并集、交集、补集和星号运算符形成的字符串集合。给定一个扩展正则表达式 $R$ 和一个字符串 $Q$,扩展正则表达式匹配问题是在决定 $Q$ 是否匹配由 $R$ 指定的任何字符串。扩展正则表达式匹配由 Hopcroft 和 Ullman 在 1970 年代引入,他们给出了一种简单的动态规划解法,时间复杂度为 $O(n^3m)$,空间复杂度为 $O(n^2m)$,其中 $n$ 是 $Q$ 的长度,$m$ 是 $R$ 的长度。目前最先进的解法由 Yamamoto 和 Miyazaki 提出,时间复杂度为 $O(\frac{n^3k + n^2m}{w} + n + m)$,空间复杂度为 $O(\frac{n^2k + nm}{w} + n + m)$,其中 $k$ 是 $R$ 中否定和补集运算符的数量,$w$ 是机器字的位数。本文提出了一个新的解法,能够在 $O(n^ωk + \frac{n^2m}{\max(w/\log w, \log n)} + m)$ 时间和 $O(\frac{n^2 \log k}{w} + n + m) = O(n^2 +m)$ 空间内解决扩展正则表达式匹配问题,其中 $ω≈2.3716$ 是矩阵乘法的指数。本质上,这将时间复杂度中的主导项 $n^3k$ 替换为 $n^ωk$,同时将空间复杂度中的 $n^2k$ 项改进为 $O(n^2)$。为了实现这一结果,我们开发了几种新的见解和技术,包括一种新的紧凑表示法来存储和高效结合子串匹配、一种新的聚类技术用于扩展正则表达式的解析树,以及一种新的高效的有限自动机模拟与子串匹配表示结合的方法,以加速经典的动态规划解法。

英文摘要:

An extended regular expression $R$ specifies a set of strings formed by characters from an alphabet combined with concatenation, union, intersection, complement, and star operators. Given an extended regular expression $R$ and a string $Q$, the extended regular expression matching problem is to decide if $Q$ matches any of the strings specified by $R$. Extended regular expression matching was introduced by Hopcroft and Ullman in the 1970s, who gave a simple dynamic programming solution using $O(n^3m)$ time and $O(n^2m)$ space, where $n$ is the length of $Q$ and $m$ is the length of $R$. The current state-of-the art solution, by Yamamoto and Miyazaki uses $O(\frac{n^3k + n^2m}{w} + n + m)$ time and $O(\frac{n^2k + nm}{w} + n + m)$ space, where $k$ is the number of negation and complement operators in $R$ and $w$ is the number of bits in a machine word. This roughly replaces the $m$ factor with $k$ in the dominant terms of both the space and time bounds of the classical Hopcroft and Ullman algorithm. In this paper, we present a new solution that solves extended regular expression matching in \[ O\left(n^ωk + \frac{n^2m}{\max(w/\log w, \log n)} + m\right) \] time and $O(\frac{n^2 \log k}{w} + n + m) = O(n^2 +m)$ space, where $ω\approx 2.3716$ is the exponent of matrix multiplication. Essentially, this replaces the dominant $n^3k$ term with $n^ωk$ in the time bound, while simultaneously improving the $n^2k$ term in the space to $O(n^2)$. Our results are based on a surprisingly simple combination of techniques and insights, including a compact representation to store and efficiently combine substring matches, a clustering technique for parse trees of extended regular expressions, and a new efficient combination of finite automaton simulation with our substring match representation to speed up the classic dynamic programming solution.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑