HackerPapers

arXiv:2001.10490cs.PL

Beyond Notations: Hygienic Macro Expansion for Theorem Proving Languages

Sebastian Ullrich, Leonardo de Moura

Early discovery. Linked by one identifiable commenter. This paper is outside the main ranking; a mention is not an endorsement.

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.

arXiv comments
Journal reference
Logical Methods in Computer Science, Volume 18, Issue 2 (April 13, 2022) lmcs:7421
DOI
doi:10.46298/lmcs-18(2:1)2022
Subjects
cs.PLProgramming Languages

On Hacker News

Linked by 1 identifiable commenter in 1 comment across 1 thread, from Jul 2025 to Jul 2025. Found in 1 HN submission from Aug 2024 to Aug 2024. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments1 thread

  1. Binding Application in Idris 1 comment
    • The system used in Lean 4 is explained in https://arxiv.org/abs/2001.10490v7 (Ullrich and Moura, "Beyond Notations: Hygienic Macro Expansion for Theorem Proving Languages"). There's still a set-of-scopes system, but it seems to be pretty different from…

      kmillView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.