paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A Coq Mechanization of JavaScript Regular Expression Semantics

JavaScript 正则表达式语义的 Coq 机器化
ICFP 8(ICFP)2024匹配度 3/10 · 该论文是 JavaScript 正则表达式的 Coq 形式语义与验证,属于形式化验证/形式语义方向,虽与用户“AI→PL 改进形式化验证”有弱关联,但未涉及 LLM/Agent,也未涉及静态分析 ML/Agent 程序、浮点程序分析或贝叶斯程序分析,与核心研究画像匹配度低。引用 8 inbox
Noé De Santo, Aurèle Barrière, Clément Pit-Claudel
dblp: 2026-09-10crossref: 2026-09-10arxiv: 2026-09-10

AI 速览

一句话:首次在 Coq 中忠实机器化 ECMA-262 的 JavaScript 正则语义,证明匹配必然终止且安全,并可提取为通过 Test262 的引擎。

本文首次在交互式定理证明器中忠实机器化工业级正则语言:ECMA-262 第 22.2 节所定义的 JavaScript 正则匹配。作者在 Coq 中给出可执行、可证明安全且便于随规范演进的语义实现,并讨论编码、边界情形与可执行性等挑战。基于该机器化,他们证明 JS 正则匹配必然终止且不触发断言失败,指出既有文献中的细微边界错误,验证了取自先进正则引擎的优化,并表明自动机教科书中的若干经典性质及基于导数的匹配器假设在 JS 正则下并不成立。该实现可提取为 OCaml 与 JavaScript,链接 Unicode 库后通过官方 Test262 一致性测试的相关部分。

问题
工业级正则语言(如 ECMA-262 定义的 JavaScript 正则)规范庞大而微妙,却缺乏忠实的、可供机器检查的形式化,导致引擎实现与既有研究常在边界情形上出错。
方法
将 ECMA-262 §22.2 的 JavaScript 正则语义机器化为可执行的 Coq 定义,证明匹配的终止性与安全性(无断言失败),并通过与现有实现对照来校准对规范的理解。
评估
开展一系列分析、案例研究与实验:终止与安全证明、边界情形勘误、对先进正则引擎中一项优化的验证、自动机经典性质的反例,以及规范更新维护成本的评估;并将提取出的 OCaml/JavaScript 引擎通过官方 Test262 一致性测试的相关部分。
原文摘要(Abstract)

We present an executable, proven-safe, faithful, and future-proof Coq mechanization of JavaScript regular expression (regex) matching, as specified by the latest published edition of ECMA-262 section 22.2. This is, to our knowledge, the first time that an industrial-strength regex language has been faithfully mechanized in an interactive theorem prover. We highlight interesting challenges that arose in the process (including issues of encoding, corner cases, and executability), and we document the steps that we took to ensure that the result is straightforwardly auditable and that our understanding of the specification aligns with existing implementations. We demonstrate the usability and versatility of the mechanization through a broad collection of analyses, case studies, and experiments: we prove that JavaScript regex matching always terminates and is safe (no assertion failures); we identify subtle corner cases that led to mistakes in previous publications; we verify an optimization extracted from a state-of-the-art regex engine; we show that some classic properties described in automata textbooks and used in derivatives-based matchers do not hold in JavaScript regexes; and we demonstrate that the cost of updating the mechanization to account for changes in the original specification is reasonably low. Our mechanization can be extracted to OCaml and JavaScript and linked with Unicode libraries to produce an executable regex engine that passes the relevant parts of the official Test262 conformance test suite.

链接与引用

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

BibTeX
@article{abs-2403-11919,
  title = {A Coq Mechanization of JavaScript Regular Expression Semantics},
  author = {Noé De Santo and Aurèle Barrière and Clément Pit-Claudel},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {ICFP},
  year = {2024},
  doi = {10.1145/3674666}
}