paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Beyond Notations: Hygienic Macro Expansion for Theorem Proving Languages

超越记号:定理证明语言的卫生宏展开
LMCS vol.Volume 18, Issue 22022匹配度 2/10 · 该论文聚焦交互式定理证明器的卫生宏系统与 Lean 4 语言集成,属于定理证明语言设计,与用户核心方向(LLM/Agent 与静态分析、浮点程序分析、贝叶斯程序分析)没有直接交叉;仅对形式化验证基础设施有间接参考价值。引用 5 inbox
Sebastian Ullrich, Leonardo de Moura
crossref: 2026-09-10

AI 速览

一句话:提出面向交互式定理证明器的卫生宏系统,同时解决意外名称捕获与语法扩展能力不足,并集成到 Lean 4。

交互式定理证明器中,可扩展语法对降低复杂数学对象操作负担和构建可复用库抽象至关重要。但多数系统仅支持受限的语法糖替换与临时机制,难以表达许多理想抽象,导致库中充斥冗余;其策略语言还常遭遇意外名称捕获,产生反直觉行为。本文借鉴 Scheme 的卫生宏思想,为 ITP 设计了一种新的卫生宏系统,同时解决上述两个问题。作者进一步将其扩展到类型导向的宏展开,从而用统一系统提供从简单语法糖到原先内建语法 elaboration 的多层次抽象。该系统已实现并集成到 Lean 4。尽管表达力强,其设计仍足够简单,便于集成到其他系统。

问题
多数交互式定理证明器的可扩展语法机制过于受限,且策略语言容易发生意外名称捕获,难以支持可复用抽象并导致库中冗余。
方法
借鉴 Scheme 的卫生宏思想,为定理证明语言设计卫生宏系统,并将其扩展为支持类型导向展开的统一多层次宏机制,最终集成到 Lean 4。
评估
通过实现新宏系统并集成到新版 Lean 定理证明器 Lean 4,展示其表达力、从语法糖到语法 elaboration 的统一能力以及易于集成的特点。
原文摘要(Abstract)

In interactive theorem provers (ITPs), extensible syntax is not only crucial to lower the cognitive burden of manipulating complex mathematical objects, but plays a critical role in developing reusable abstractions in libraries. Most ITPs support such extensions in the form of restrictive "syntax sugar" substitutions and other ad hoc mechanisms, which are too rudimentary to support many desirable abstractions. As a result, libraries are littered with unnecessary redundancy. Tactic languages in these systems are plagued by a seemingly unrelated issue: accidental name capture, which often produces unexpected and counterintuitive behavior. We take ideas from the Scheme family of programming languages and solve these two problems simultaneously by proposing a novel hygienic macro system custom-built for ITPs. We further describe how our approach can be extended to cover type-directed macro expansion resulting in a single, uniform system offering multiple abstraction levels that range from supporting simplest syntax sugars to elaboration of formerly baked-in syntax. We have implemented our new macro system and integrated it into the new version of the Lean theorem prover, Lean 4. Despite its expressivity, the macro system is simple enough that it can easily be integrated into other systems.

链接与引用

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

BibTeX
@article{paperbot1710,
  title = {Beyond Notations: Hygienic Macro Expansion for Theorem Proving Languages},
  author = {Sebastian Ullrich and Leonardo de Moura},
  journal = {Logical Methods in Computer Science},
  volume = {Volume 18, Issue 2},
  year = {2022},
  doi = {10.46298/lmcs-18(2:1)2022}
}