paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A practical mode system for recursive definitions

一种实用的递归定义模式系统
POPL 5(POPL)2021匹配度 4/10 · 该论文提出一种用于 call-by-value 递归定义的静态分析(模式系统),属于类型系统与程序分析领域,但与用户核心关注的 PL→AI(静态分析应用于 ML/Agentic 程序)、AI→PL(LLM 改进静态分析)、浮点程序分析及贝叶斯程序分析均无直接交叉。不过,论文兼具理论形式化与工业落地(OCaml 实现),符合用户对工程实现和问题驱动研究的偏好。引用 2 inbox
Alban Reynaud, Gabriel Scherer, Jeremy Yallop
crossref: 2026-09-10

AI 速览

一句话:提出一种实用的模式系统,静态检测 call-by-value 递归定义中的恶性循环,并成功替换 OCaml 的不健全语法检查。

在 call-by-value 语言中,递归定义可用来构造递归函数或循环数据结构,但如 let rec x = x + 1 这类定义含恶性循环,求值时会运行时失败。本文提出一种新的静态分析来排除此类失败:给出一组声明式推理规则,证明其相对于 Nordlander、Carlsson 和 Gill 的源级语义是可靠的,并说明可按一种异常简单的方式将其导向算法的后向分析检查。该实现已替换 OCaml 原有的脆弱语法检查,后者随语言演化漏掉了若干微妙错误。论文还记录了异常、一等模块、GADT 等真实函数式语言高级特性与递归定义安全检查交互时出现的问题。

问题
call-by-value 语言中,某些递归定义在运行时因恶性循环而失败,而 OCaml 原有的语法检查不够健全且随语言演化容易漏掉错误。
方法
提出一组声明式模式推理规则,证明其相对于源级语义的可靠性,并给出一种简单的后向算法检查,用于替换 OCaml 的现有检查。
评估
在 OCaml 中实现并部署该检查,取代原有语法检查;作者还文档化了异常、一等模块、GADT 等高级特性与安全检查交互时出现的问题。
原文摘要(Abstract)

In call-by-value languages, some mutually-recursive definitions can be safely evaluated to build recursive functions or cyclic data structures, but some definitions (let rec x = x + 1) contain vicious circles and their evaluation fails at runtime. We propose a new static analysis to check the absence of such runtime failures. We present a set of declarative inference rules, prove its soundness with respect to the reference source-level semantics of Nordlander, Carlsson, and Gill [2008], and show that it can be directed into an algorithmic backwards analysis check in a surprisingly simple way. Our implementation of this new check replaced the existing check used by the OCaml programming language, a fragile syntactic criterion which let several subtle bugs slip through as the language kept evolving. We document some issues that arise when advanced features of a real-world functional language (exceptions in first-class modules, GADTs, etc.) interact with safety checking for recursive definitions.

链接与引用

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

BibTeX
@article{paperbot1146,
  title = {A practical mode system for recursive definitions},
  author = {Alban Reynaud and Gabriel Scherer and Jeremy Yallop},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {5},
  number = {POPL},
  year = {2021},
  doi = {10.1145/3434326}
}