paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Repairing Regular Expressions for Extraction

修复用于提取的正则表达式
PLDI 7(PLDI)2023匹配度 3/10 · 该论文属于程序合成与形式语义方向,虽与 PL 相关,但不涉及用户核心关注的静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析,也未讨论 AI 与 PL 的双向结合或工业落地。引用 9 inbox
Nariyoshi Chida, Tachio Terauchi
crossref: 2026-09-10

AI 速览

一句话:提出首个基于编程示例的提取型正则合成与修复方法,支持反向引用与环视等扩展。

现有基于编程示例(PBE)的正则合成与修复仅面向成员测试,提取场景仍是开放问题。本文提出首个面向提取的 PBE 合成与修复方法,支持反向引用、环视等现实扩展。作者指出,扩展显著改变可解性:不允许扩展时存在不可解实例,而允许扩展时每个实例可解,这与成员测试不同。方法沿用枚举搜索与 SMT 约束求解,但为提取定义实际正则引擎的确定性大步骤操作语义,据此生成尊重确定性行为的约束,并以匹配续延消歧;同时提出两种基于示例提取信息的剪枝。作者实现 R3,在 50 个含扩展的正则上评估,验证了算法有效性与剪枝效果。

问题
现有 PBE 正则合成与修复仅支持成员测试,无法处理提取任务;且反向引用、环视等扩展使提取场景的可解性问题与成员测试截然不同。
方法
在枚举搜索加 SMT 约束求解的框架上,定义实际正则引擎的确定性大步骤操作语义,并据此生成考虑匹配续延与消歧的 SMT 约束,同时使用两种基于示例提取信息的搜索空间剪枝。
评估
实现为工具 R3,并在 50 个包含真实世界扩展的正则表达式上评估,结果表明算法有效且新剪枝技术显著缩减搜索空间。
原文摘要(Abstract)

While synthesizing and repairing regular expressions (regexes) based on Programming-by-Examples (PBE) methods have seen rapid progress in recent years, all existing works only support synthesizing or repairing regexes for membership testing, and the support for extraction is still an open problem. This paper fills the void by proposing the first PBE-based method for synthesizing and repairing regexes for extraction. Our work supports regexes that have real-world extensions such as backreferences and lookarounds. The extensions significantly affect the PBE-based synthesis and repair problem. In fact, we show that there are unsolvable instances of the problem if the synthesized regexes are not allowed to use the extensions, i.e., there is no regex without the extensions that correctly classify the given set of examples, whereas every problem instance is solvable if the extensions are allowed. This is in stark contrast to the case for the membership where every instance is guaranteed to have a solution expressible by a pure regex without the extensions. The main contribution of the paper is an algorithm to solve the PBE-based synthesis and repair problem for extraction. Our algorithm builds on existing methods for synthesizing and repairing regexes for membership testing, i.e., the enumerative search algorithms with SMT constraint solving. However, significant extensions are needed because the SMT constraints in the previous works are based on a non-deterministic semantics of regexes. Non-deterministic semantics is sound for membership but not for extraction, because which substrings are extracted depends on the deterministic behavior of actual regex engines. To address the issue, we propose a new SMT constraint generation method that respects the deterministic behavior of regex engines. For this, we first define a novel formal semantics of an actual regex engine as a deterministic big-step operational semantics, and use it as a basis to design the new SMT constraint generation method. The key idea to simulate the determinism in the formal semantics and the constraints is to consider continuations of regex matching and use them for disambiguation. We also propose two new search space pruning techniques called approximation-by-pure-regex and approximation-by-backreferences that make use of the extraction information in the examples. We have implemented the synthesis and repair algorithm in a tool called R3 (Repairing Regex for extRaction) and evaluated it on 50 regexes that contain real-world extensions. Our evaluation shows the effectiveness of the algorithm and that our new pruning techniques substantially prune the search space.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot2000,
  title = {Repairing Regular Expressions for Extraction},
  author = {Nariyoshi Chida and Tachio Terauchi},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {PLDI},
  year = {2023},
  doi = {10.1145/3591287}
}