🤖 AI Summary
This work addresses the reliance on strong decidability assumptions in the elaboration process from surface syntax to core syntax in proof assistants. It proposes a shallow embedding approach based on dependent types and a monadic domain-specific language (DSL), which reformulates elaboration as elementary equality computation through a bidirectional type system. The elaboration algorithm is algebraically derived from presheaf models and the dual initial natural models of Martin-Löf type theory, with its correctness guaranteed constructively—without committing to specific normal forms or conversion-checking mechanisms. The resulting elaboration procedure automatically preserves well-typedness, judgmental equality, and substitution stability, and introduces a novel denotational interpretation of elaboration suspension.
📝 Abstract
Surface syntax in proof assistants like Rocq, Lean, Agda, and Idris is highly implicit, lacking many details that are needed for user-written code to denote precisely defined mathematical objects. Elaboration is an algorithm that accounts for these details by translating surface syntax to an explicit enough core syntax. The reliability and predictability of elaboration relies on several critical properties of the core type system, including decidability of judgemental equality and the injectivity of type constructors; these dependencies are witnessed in a concrete system by explicit calls to conversion checking and weak-head reduction subroutines.
We introduce a dependently typed monadic domain specific language for the executable specification of correct-by-construction elaboration algorithms that is abstracted from any particular representation of normal forms or algorithm for conversion checking. In particular, we represent a bidirectionally typed surface language for Martin-Löf type theory by shallow embedding in this DSL so that the translation of surface terms into core terms amounts to elementary equational calculation. This translation is correct by construction in the sense that it cannot produce ill-typed terms, and is automatically stable under judgemental equality of core terms and even under substitution; from the latter property, we obtain a new denotational interpretation of the suspension of elaboration problems. Finally, a concrete elaboration algorithm is extracted by algebraic means from a presheaf model of the DSL built out of the bi-initial natural model of Martin-Löf type theory.