稀疏正则表达式匹配
Sparse Regular Expression Matching
AI总结:
本文针对正则表达式匹配的复杂度瓶颈,引入密度参数Δ刻画NFA模拟的非确定性,提出时间复杂度为O(Δloglog(nm/Δ)+n+m)的新算法,并给出匹配的SETH条件下界,本质上以Δ替换了原复杂度中的nm。
摘要:
正则表达式指定了由单个字符经连接、并集和Kleene星算子组合而成的字符串集合。给定正则表达式$R$和字符串$Q$,正则表达式匹配问题是判断$Q$是否匹配$R$所指定的任意字符串。正则表达式是形式语言中的基础概念,正则表达式匹配是数据搜索与处理的基本原语。标准教科书解法[Thompson, CACM 1968]会构造并模拟一个非确定有限自动机,由此得到一个时间复杂度为$O(nm)$的算法,其中$n$是$Q$的长度,$m$是$R$的长度。尽管已有大量研究工作,但目前已知该复杂度界仅能得到多对数级别的改进。近期,条件下界为这一进展停滞提供了依据:Backurs和Indyk[FOCS 2016]证明,在强指数时间假设(SETH)成立的前提下,对于任意常数$ε>0$,正则表达式匹配都无法在$O((nm)^{1-ε})$时间内求解。因此,正则表达式匹配的复杂度在$n$和$m$的维度上已基本确定。\n本文采用一种新方法,引入了“密度”参数$Δ$,用于刻画在$Q$上进行NFA模拟时的非确定性程度。该密度至多为$nm+1$,但可能远小于该值。我们的主要结果是一种新算法,能以$$O\left(Δ\log \log \frac{nm}Δ +n + m\right)$$的时间复杂度求解正则表达式匹配问题。这本质上是将正则表达式匹配复杂度中的$nm$替换为了$Δ$。我们还给出了与之匹配的条件下界,补充了上界结果:在SETH成立的前提下,对于任意常数$ε>0$,我们无法在$O(Δ^{1-ε})$时间内求解正则表达式匹配问题。
英文摘要:
A regular expression specifies a set of strings formed by single characters combined with concatenation, union, and Kleene star operators. Given a regular expression $R$ and a string $Q$, the regular expression matching problem is to decide if $Q$ matches any of the strings specified by $R$. Regular expressions are a fundamental concept in formal languages and regular expression matching is a basic primitive for searching and processing data. A standard textbook solution [Thompson, CACM 1968] constructs and simulates a nondeterministic finite automaton, leading to an $O(nm)$ time algorithm, where $n$ is the length of $Q$ and $m$ is the length of $R$. Despite considerable research efforts only polylogarithmic improvements of this bound are known. Recently, conditional lower bounds provided evidence for this lack of progress when Backurs and Indyk [FOCS 2016] proved that, assuming the strong exponential time hypothesis (SETH), regular expression matching cannot be solved in $O((nm)^{1-ε})$, for any constant $ε> 0$. Hence, the complexity of regular expression matching is essentially settled in terms of $n$ and $m$. In this paper, we take a new approach and introduce a \emph{density} parameter, $Δ$, that captures the amount of nondeterminism in the NFA simulation on $Q$. The density is at most $nm+1$ but can be significantly smaller. Our main result is a new algorithm that solves regular expression matching in $$O\left(Δ\log \log \frac{nm}Δ +n + m\right)$$ time. This essentially replaces $nm$ with $Δ$ in the complexity of regular expression matching. We complement our upper bound by a matching conditional lower bound that proves that we cannot solve regular expression matching in time $O(Δ^{1-ε})$ for any constant $ε> 0$ assuming SETH.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。