一句话:提出正则表达式消歧鲁棒性概念,证明判定问题为 PSPACE 完全,并给出实用静态分析算法与优化。
正则表达式常用于序列数据的匹配与提取,但其固有歧义使匹配结果依赖消歧策略,主流有 POSIX 最长左匹配与贪婪(PCRE)策略,跨引擎复用正则时可能产生不同输出。论文提出“消歧鲁棒性”:若正则的提取语义在 POSIX 与贪婪策略下相同,则该正则鲁棒。作者将该性质判定问题形式化,证明其为 PSPACE 完全,并设计静态分析算法检查非鲁棒性,附带两项性能优化。实现后在大规模、多领域正则数据集上实验,表明方法实用。
Regular expressions are commonly used for finding and extracting matches from sequence data. Due to the inherent ambiguity of regular expressions, a disambiguation policy must be considered for the match extraction problem, in order to uniquely determine the desired match out of the possibly many matches. The most common disambiguation policies are the POSIX policy and the greedy (PCRE) policy. The POSIX policy chooses the longest match out of the leftmost ones. The greedy policy chooses a leftmost match and further disambiguates using a greedy interpretation of Kleene iteration to match as many times as possible. The choice of disambiguation policy can affect the output of match extraction, which can be an issue for reusing regular expressions across regex engines. In this paper, we introduce and study the notion of disambiguation robustness for regular expressions. A regular expression is robust if its extraction semantics is indifferent to whether the POSIX or greedy disambiguation policy is chosen. This gives rise to a decision problem for regular expressions, which we prove to be PSPACE-complete. We propose a static analysis algorithm for checking the (non-)robustness of regular expressions and two performance optimizations. We have implemented the proposed algorithms and we have shown experimentally that they are practical for analyzing large datasets of regular expressions derived from various application domains.
@article{paperbot2506,
title = {Static Analysis for Checking the Disambiguation Robustness of Regular Expressions},
author = {Konstantinos Mamouras and Alexis Le Glaunec and Wu Angela Li and Agnishom Chattopadhyay},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {PLDI},
year = {2024},
doi = {10.1145/3656461}
}