A Case for First-Class Environments
Jinhao Tan, Bruno C. d. S. Oliveira
Abstract
Formalizations of programming languages typically adopt the substitution model from the lambda calculus. However, substitution creates notorious complications for reasoning and implementation. Furthermore, it is disconnected from practical implementations, which normally adopt environments and closures.
In this paper we advocate for formalizing programming languages using a novel style of small-step environment-based semantics, which avoids substitution and is closer to implementations. We present a call-by-value statically typed calculus, called λ E , using our small-step environment semantics. With our alternative environment semantics programming language constructs for first-class environments arise naturally, without creating significant additional complexity. Therefore, λ E also adopts first-class environments, adding expressive power that is not available in conventional lambda calculi. λ E is a conservative extension of the call-by-value Simply Typed Lambda Calculus (STLC), and employs de Bruijn indices for its formalization, which fit naturally with the environment-based semantics. Reasoning about λ E is simple, and in many cases simpler than reasoning about the traditional STLC. We show an abstract machine that implements the semantics of λ E , and has an easy correctness proof. We also extend λ E with references. We show that λ E can model a simple form of first-class modules, and suggest using first-class environments as an alternative to objects for modelling capabilities. All technical results are formalized in the Coq proof assistant. In summary, our work shows that the small-step environment semantics that we adopt has three main and orthogonal benefits: 1) it simplifies the notorious binding problem in formalizations and proof assistants; 2) it is closer to implementations; and 3) additional expressive power is obtained from first-class environments almost for free.
CCS Concepts: • Software and its engineering → Formal language definitions.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 402268ce-26fa-40fd-9ee3-714899d01f52Builds on1
Related papers
- Destination Calculus: A Linear 𝜆-Calculus for Purely Functional Memory WritesThomas Bagrel, Arnaud SpiwackOOPSLA 2025 · 1 citation
- Full Iso-Recursive TypesLitao Zhou, Qianyong Wan, Bruno C. d. S. OliveiraOOPSLA 2024 · 4 citations
- Contextual MetaML: Syntax and Full AbstractionHaoxuan Yin, Andrzej S. Murawski, C.-H. Luke OngLICS 2026 · 1 citation
- Resolution as intersection subtyping via Modus PonensKoar Marntirosian, Tom Schrijvers, Bruno C. d. S. Oliveira, Georgios KarachaliasOOPSLA 2020 · 5 citations
- Asynchronous effectsDanel Ahman, Matija PretnarPOPL 2021 · 6 citations
