paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Solving string constraints with Regex-dependent functions through transducers with priorities and variables

借助带优先级与变量的转换器求解含 RegEx 相关函数的字符串约束
POPL 6(POPL)2022匹配度 3/10 · 论文属于程序验证/自动机理论中的字符串约束求解,虽与静态分析/形式化验证的大方向相关,但未涉及用户重点关注的大模型/Agent、浮点程序分析或贝叶斯程序分析,也不是用 LLM/Agent 改进静态分析,匹配点主要在形式化与工程实现偏好。引用 38 inbox
Taolue Chen, Alejandro Flores-Lamas, Matthew Hague, Zhilei Han, Denghang Hu, Shuanglong Kan, Anthony W. Lin, Philipp Rümmer, Zhilin Wu
crossref: 2026-09-10

AI 速览

一句话:提出首个原生支持 RegEx(贪婪/懒惰、捕获组)的字符串理论与求解器,核心为带优先级的流式字符串转换器 PSST。

编程语言中的正则表达式(RegEx)具有贪婪/懒惰 Kleene 星、捕获组与引用等非标准语义,现有字符串求解器难以原生支持,阻碍了含 RegEx 程序的符号执行。本文提出首个原生支持这些特性的字符串理论与求解器,核心是新的自动机模型 PSST——在流式字符串转换器中引入优先级(刻画贪婪/懒惰)与字符串变量(刻画捕获组)。作者证明 PSST 保持正则性(正则约束的原像仍正则),并给出可靠矢列演算,通过前像/后像传播正则约束;该方法在 straight-line 片段上完备,实验表明其语义与 JavaScript 实际语义一致,并在 195000 余条约束上于精度与效率两方面显著优于现有符号执行方法。

问题
JavaScript 等语言中的 RegEx 具有贪婪/懒惰匹配、捕获组与引用等非标准语义,而现有字符串求解器缺乏原生支持,导致含 RegEx 的程序难以进行符号执行。
方法
提出自动机模型 PSST(带优先级与字符串变量的流式字符串转换器)以形式化 RegEx 相关字符串函数的语义,证明其保持正则性,并设计可靠矢列演算通过前像/后像传播正则约束来求解约束。
评估
通过大量实验验证形式语义与实际 JavaScript 语义的一致性,并在来自开源 RegEx 库的逾 195000 条字符串约束上与既有符号执行方法对比,精度与效率均大幅提升。
原文摘要(Abstract)

Regular expressions are a classical concept in formal language theory. Regular expressions in programming languages (RegEx) such as JavaScript, feature non-standard semantics of operators (e.g. greedy/lazy Kleene star), as well as additional features such as capturing groups and references. While symbolic execution of programs containing RegExes appeals to string solvers natively supporting important features of RegEx, such a string solver is hitherto missing. In this paper, we propose the first string theory and string solver that natively provides such support. The key idea of our string solver is to introduce a new automata model, called prioritized streaming string transducers (PSST), to formalize the semantics of RegEx-dependent string functions. PSSTs combine priorities, which have previously been introduced in prioritized finite-state automata to capture greedy/lazy semantics, with string variables as in streaming string transducers to model capturing groups. We validate the consistency of the formal semantics with the actual JavaScript semantics by extensive experiments. Furthermore, to solve the string constraints, we show that PSSTs enjoy nice closure and algorithmic properties, in particular, the regularity-preserving property (i.e., pre-images of regular constraints under PSSTs are regular), and introduce a sound sequent calculus that exploits these properties and performs propagation of regular constraints by means of taking post-images or pre-images. Although the satisfiability of the string constraint language is generally undecidable, we show that our approach is complete for the so-called straight-line fragment. We evaluate the performance of our string solver on over 195000 string constraints generated from an open-source RegEx library. The experimental results show the efficacy of our approach, drastically improving the existing methods (via symbolic execution) in both precision and efficiency.

链接与引用

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

BibTeX
@article{paperbot1566,
  title = {Solving string constraints with Regex-dependent functions through transducers with priorities and variables},
  author = {Taolue Chen and Alejandro Flores-Lamas and Matthew Hague and Zhilei Han and Denghang Hu and Shuanglong Kan and Anthony W. Lin and Philipp Rümmer and Zhilin Wu},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {POPL},
  year = {2022},
  doi = {10.1145/3498707}
}