It is well-known that checking whether a given string $w$ matches a given regular expression $r$ can be done in quadratic time $O(|w|\cdot |r|)$ and that this cannot be improved to a truly subquadratic running time of $O((|w|\cdot |r|)^{1-ε})$ assuming the strong exponential time hypothesis (SETH). We study the related problem that asks whether $w$ has a \emph{subsequence} that matches $r$, and we show that surprisingly this task admits an algorithm that runs in linear time, i.e., in $O(|w| + |r|)$. We further show that the same holds if we ask for a supersequence instead of a subsequence. Moreover, we show that the \emph{quantitative} problems of computing a longest subsequence or shortest supersequence of $w$ that matches $r$ can be solved with the same complexity as the classical longest common subsequence or shortest common supersequence problems, i.e., in $O(|w|\cdot |r|)$, and conditionally not in $O((|w|\cdot|r|)^{1 - ε})$. By contrast, if instead of subsequences or supersequences we consider other string relations like the infix, prefix, left-extension, or extension relations, then all the corresponding problems (both quantitative and non-quantitative) have the same complexity as classical regex matching, i.e., they can also be solved in $O(|w|\cdot |r|)$, but not in $O((|w|\cdot|r|)^{1 - ε})$ assuming SETH. We last study the complexity of the \emph{universal} problem that asks if \emph{all} subsequences (or supersequences, infixes, prefixes, left-extensions or extensions) of an input string satisfy a given regular expression. For these problems, we show polynomial upper bounds (along with matching conditional lower bounds) for the infix and prefix relations, but PSPACE-completeness for the extension, left-extension and supersequence relations, and coNP-completeness for the subsequence relation.


翻译:众所周知,检查给定字符串 $w$ 是否匹配给定正则表达式 $r$ 可在二次时间 $O(|w|\cdot |r|)$ 内完成,并且假设强指数时间假说(SETH)成立,此时间无法改进至真正次二次运行时间 $O((|w|\cdot |r|)^{1-ε})$。我们研究询问 $w$ 是否存在匹配 $r$ 的\emph{子序列}的相关问题,并出人意料地表明该任务存在线性时间算法,即运行时间为 $O(|w| + |r|)$。我们进一步证明,若将子序列替换为超序列,同样成立。此外,我们表明计算 $w$ 中匹配 $r$ 的最长子序列或最短超序列的\emph{定量}问题,其求解复杂度与经典最长公共子序列或最短公共超序列问题相同,即 $O(|w|\cdot |r|)$,且条件性地不可能在 $O((|w|\cdot|r|)^{1 - ε})$ 内完成。相比之下,若将子序列或超序列替换为其他字符串关系(如中缀、前缀、左扩展或扩展关系),则所有对应问题(包括定量与非定量)均具有与经典正则匹配相同的复杂度,即可在 $O(|w|\cdot |r|)$ 内求解,但假设SETH成立,无法在 $O((|w|\cdot|r|)^{1 - ε})$ 内完成。最后,我们研究询问输入字符串的\emph{所有}子序列(或超序列、中缀、前缀、左扩展或扩展)是否满足给定正则表达式的\emph{全域}问题的复杂度。对于这些问题,我们给出了中缀和前缀关系的多项式上界(以及匹配的条件性下界),而扩展、左扩展和超序列关系为PSPACE完全性,子序列关系为coNP完全性。

0
下载
关闭预览

相关内容

数学上,序列是被排成一列的对象(或事件);这样每个元素不是在其他元素之前,就是在其他元素之后。这里,元素之间的顺序非常重要。
南大《时间序列分析 (Time Series Analysis)》课程,推荐!
专知会员服务
156+阅读 · 2022年3月31日
专知会员服务
237+阅读 · 2020年12月15日
专知会员服务
63+阅读 · 2020年3月4日
你真的懂时间序列预测吗?
腾讯大讲堂
104+阅读 · 2019年1月7日
R语言时间序列分析
R语言中文社区
12+阅读 · 2018年11月19日
利用动态深度学习预测金融时间序列基于Python
量化投资与机器学习
18+阅读 · 2018年10月30日
基于 Keras 用 LSTM 网络做时间序列预测
R语言中文社区
21+阅读 · 2018年8月6日
基于 Keras 用深度学习预测时间序列
R语言中文社区
23+阅读 · 2018年7月27日
R语言之数据分析高级方法「时间序列」
R语言中文社区
17+阅读 · 2018年4月24日
回归预测&时间序列预测
GBASE数据工程部数据团队
44+阅读 · 2017年5月17日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
23+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 6月14日
Arxiv
0+阅读 · 6月4日
Arxiv
0+阅读 · 5月6日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
6+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
5+阅读 · 6月17日
相关VIP内容
南大《时间序列分析 (Time Series Analysis)》课程,推荐!
专知会员服务
156+阅读 · 2022年3月31日
专知会员服务
237+阅读 · 2020年12月15日
专知会员服务
63+阅读 · 2020年3月4日
相关资讯
你真的懂时间序列预测吗?
腾讯大讲堂
104+阅读 · 2019年1月7日
R语言时间序列分析
R语言中文社区
12+阅读 · 2018年11月19日
利用动态深度学习预测金融时间序列基于Python
量化投资与机器学习
18+阅读 · 2018年10月30日
基于 Keras 用 LSTM 网络做时间序列预测
R语言中文社区
21+阅读 · 2018年8月6日
基于 Keras 用深度学习预测时间序列
R语言中文社区
23+阅读 · 2018年7月27日
R语言之数据分析高级方法「时间序列」
R语言中文社区
17+阅读 · 2018年4月24日
回归预测&时间序列预测
GBASE数据工程部数据团队
44+阅读 · 2017年5月17日
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
23+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员