betaFeedback

WorksComputer Science

Normalization by Evaluation with Substitutions as Operations

Abstract

In previous works on normalization by evaluation (NbE) with an untyped domain model, explicit substitutions are a major decision choice, which, in retrospect, is taken to simplify subsequent semantic proofs. This choice hence is taken for a purely technical reason. In addition, there is no obvious lemma to test the completeness of the definition or the laws for explicit substitutions. In this technical report, we investigate NbE in a typical setting, i.e. defining substitutions as operations. We show that this setting brings simplifications in proving syntactic properties and soundness of NbE, though complications are introduced in the completeness proof of NbE.

Introduction

Normalization by evaluation (NbE) is a technique for deciding definitional equality in type theories by computing normal forms via an interpretation into a semantic domain, followed by a reification (readback) procedure that extracts syntactic normal forms from semantic values [2, 5]. In the dependently typed setting, NbE has been studied extensively [1, 3, 4, 6, 7, 8, 9], and serves as the algorithmic backbone of type checkers for proof assistants.

A recurring design decision in formalizations of NbE for dependent type theories is whether substitutions should be treated as explicit syntactic constructs or as meta-level operations on terms. In the explicit substitution approach, substitutions appear as term formers in the syntax, and the theory includes definitional equalities governing their interaction with other term formers (e.g. the congruence rule for λ\lambda abstraction (λx.t)[σ]=λx.t[q(σ)](\lambda x.t)[\sigma] = \lambda x.t[q(\sigma)]). This approach is prevalent in recent formalized accounts of NbE [3, 4, 7, 8, 9], partly because it simplifies the semantic proofs: the compositionality of the evaluation function follows directly from the syntax, and many substitution lemmas become trivial consequences of the equational theory rather than requiring separate inductive proofs. Nevertheless, explicit substitutions have two downsides:

  • The exact formulation of explicit substitutions and its completeness are in question. For instance, we have seen explicit substitutions with and without terminal object (i.e. ϵ:Γ⇒⋅\epsilon: \Gamma\Rightarrow\cdot the substitution that puts a closed term in any context) and its companion laws. The associativity law of substitutions is technically not required given the presence of composition law (t[σ∘σ′]=t[σ][σ′])(t[\sigma\circ\sigma'] = t[\sigma][\sigma']). Thus, explicit substitutions are difficult to standardize and its formulation is entirely on the author(s)’ discretion.

  • That equations of substitutions become part of definition equality have made proving, especially in the soundness proof, more technically involved. When reasoning about a chain of equalities of applying substitutions, explicit substitutions requires us also maintain the well-formedness of well-typedness of ambient contexts and types. This adds undesired complexity to the proof, whereas the operational approach allows unconditional equational reasoning as usual.

Author’s Contact Information: Jason Z. S. Hu, [email protected], Amazon, Seattle, WA, USA.

  1. ACM XXXX-XXXX/2026/10-ART https://doi.org/10.1145/nnnnnnn.nnnnnnn

, Vol. 1, No. 1, Article . Publication date: October 2026.

The operational approach, in contrast, defines substitution as a recursive function on raw terms. This is the “classical” treatment found in standard presentations of Martin-Löf type theory (MLTT) [10, 11]. While conceptually simpler and closer to implementations, this approach also requires us to establish a substantial body of tedious substitution lemmas — associativity of composition, interaction with weakening, and compatibility with the equational theory — as separate meta-theoretic results. Nevertheless, we argue that, to date, we should welcome more tedious prerequisites as they can easily be discharged by established tools like autosubst [12, 13] and even LLM agents. The complication, however, lies in the completeness proof. In this approach, the semantic interpretation must explicitly witness that evaluation commutes with substitution, which requires careful reasoning about environments and their relationship to syntactic substitutions. This problem is shortcircuited with explicit substitutions.

Previously, we have investigated the simply typed λ\lambda-calculus (SLTC), and demonstrated that with substitutions as operations, the overall proof structure remains manageable and brings certain simplifications to the soundness proof, in spite of increasing complexity in the completeness proof. In this technical report, we extend the investigation to MLTT. In particular, we focus on extending the semantic judgment for completeness in SLTC to dependent types. With substitutions as operations, we also observe significant simplifications in the soundness proof.

Contributions. We present a complete account of NbE for a core MLTT with a universe à la Tarski, Π\Pi-types, and natural numbers, where substitutions are defined as operations rather than explicit syntax. Our main contributions are:

  1. A careful presentation of the syntax, typing rules, and equational theory for MLTT with operational substitutions (Sec. 2 to 4).

  2. A domain model and evaluation/readback functions suitable for the operational setting (Sec. 5).

  3. A PER model establishing completeness: any two terms that are judgmentally equal evaluate to related semantic values, which in turn read back to the same normal form (Sec. 6).

  4. A Kripke logical predicate establishing soundness: any well-typed term evaluates to a semantic value from which a normal form can be extracted, and this normal form is judgmentally equal to the original term (Sec. 7).

Notation. We use N\mathbb{N} for the type of natural numbers at the meta-level. Contexts are snoc-lists written Γ,x:T\Gamma, x : T. Application of a substitution σ\sigma to a term tt is written t[σ]t[\sigma], and composition of substitutions is written σ∘τ\sigma\circ\tau (meaning first σ\sigma, then τ\tau).

Syntax and Substitution

In this section, we define the raw syntax of our core Martin-Löf Type Theory (MLTT) and introduce weakenings and substitutions as meta-level operations (recursive functions on expressions). We establish the key algebraic properties of these operations, which form the backbone of the subsequent development.

The crucial design decision—and the one that distinguishes this work from Abel—is that substitutions are not part of the term syntax. Instead, the application of a substitution to a term is defined by recursion on the structure of the term, and the basic laws governing the interaction of substitutions with term formers are proved as meta-theoretic lemmas rather than being postulated as definitional equalities of the type theory.

Throughout this presentation, we use named variables, ranging over xx, yy, zz. However, since we are handling weakenings and substitutions, we find it more rigorous to use de Bruijn indices under the hood. Therefore, we might use xx to also refer to its underlying de Bruijn index as well, whenever the ambient context requires precision. We might use subscript, e.g. x0x_0, to emphasize the de Bruijn index of a particular variable.

Raw Syntax

We work with a single syntactic category Exp\mathrm{Exp} of expressions, which encompasses both types and terms.

Definition 2.1 (Raw Expressions). The set Exp\mathrm{Exp} of raw expressions is generated by the following grammar:

t,s,S,T∈Exp::=x(variable)∣Tyi(universe at level i)∣Nat(natural number type)∣Π(x:S).T(dependent function type, x bound in T)∣zero(zero)∣succ t(successor)∣elimNat (x.T) z (x,y.s) t(natural number eliminator)∣λx.t(lambda abstraction, x bound in t)∣r s(application)\begin{aligned} t,s,S,T \in\mathrm{Exp} &::= x &&\text{(variable)}\\ &\mid\mathrm{Ty}_{i} &&\text{(universe at level }i\text{)}\\ &\mid\mathrm{Nat} &&\text{(natural number type)}\\ &\mid\Pi(x:S).T &&\text{(dependent function type, }x\text{ bound in }T\text{)}\\ &\mid\mathrm{zero} &&\text{(zero)}\\ &\mid\mathrm{succ}\ t &&\text{(successor)}\\ &\mid\mathrm{elim}_{\mathrm{Nat}}\ (x.T)\ z\ (x,y.s)\ t &&\text{(natural number eliminator)}\\ &\mid\lambda x.t &&\text{(lambda abstraction, }x\text{ bound in }t\text{)}\\ &\mid r\ s &&\text{(application)} \end{aligned}

In the grammar above, Π(x:S).T\Pi(x:S).T represents the dependent function type where TT may refer to the bound variable xx. The constructor λx.t\lambda x.t is the introduction form for Π\Pi-types: the body tt may refer to the variable xx of type SS. The eliminator elimNat (x.T) z (x,y.s) t\mathrm{elim}_{\mathrm{Nat}}\ (x.T)\ z\ (x,y.s)\ t eliminates a natural number tt with motive TT, where xx refers to the natural number being eliminated, zero case zz, and successor case ss. In the successor case, xx names the predecessor and yy names the inductive hypothesis; both are bound in ss.

Definition 2.2 (Contexts). Contexts Γ,Δ∈Ctx\Gamma,\Delta\in\mathrm{Ctx} are ordered lists of variable-type pairs:

Γ∈Ctx::=⋅∣Γ,x:S\Gamma\in\mathrm{Ctx} ::= \mathord{\cdot}\mid\Gamma,x:S

where ⋅\mathord{\cdot} is the empty context and Γ,x:S\Gamma,x:S extends Γ\Gamma with a fresh variable xx of type S∈ExpS \in\mathrm{Exp}. We write ∣Γ∣|\Gamma| for the length of Γ\Gamma.

Weakenings

To define the substitution operation, we must define weakenings first, ranging over ϕ,ψ\phi,\psi. Weakenings adjust de Bruijn indices. In our presentation, we define weakenings are functions between natural numbers: N→N\mathbb{N}\to\mathbb{N}.

Definition 2.3 (Weakenings). A weakening is a function ϕ:N→N\phi:\mathbb{N}\to\mathbb{N}. The key operations on weakenings are:

id:N→Nid(x)=x↑:N→N↑(x)=x+1q(ϕ):N→Nq(ϕ)(0)=0q(ϕ)(x+1)=ϕ(x)+1\begin{aligned} \mathrm{id}:\mathbb{N}\to\mathbb{N} && \mathrm{id}(x)&=x\\ \uparrow:\mathbb{N}\to\mathbb{N} && \uparrow(x)&=x+1\\ q(\phi):\mathbb{N}\to\mathbb{N} && q(\phi)(0)&=0\\ && q(\phi)(x+1)&=\phi(x)+1 \end{aligned}

The shift ↑\uparrow increments all indices by one (corresponding to introducing one new binding). The operation q(ϕ)q(\phi) extends a weakening under a binder: it fixes index 00 (the newly bound variable) and applies ϕ\phi followed by a successor to all other indices.

Definition 2.4 (Weakening Application). The application of a weakening ϕ\phi to a term tt, written t[ϕ]t[\phi], is defined by recursion on the structure of tt:

x[ϕ]=ϕ(x)x[\phi]=\phi(x)
Tyi[ϕ]=Tyi\mathrm{Ty}_{i}[\phi]=\mathrm{Ty}_{i}
Nat[ϕ]=Nat\mathrm{Nat}[\phi]=\mathrm{Nat}
(Π(x:S).T)[ϕ]=Π(x:S[ϕ]).(T[q(ϕ)])(\Pi(x:S).T)[\phi]=\Pi(x:S[\phi]).(T[q(\phi)])
zero⁡[ϕ]=zero⁡\operatorname{zero}[\phi] = \operatorname{zero}
(succ⁡ t)[ϕ]=succ⁡ (t[ϕ])(\operatorname{succ}\ t)[\phi] = \operatorname{succ}\ (t[\phi])
(elimNat⁡ (x.T) z (x,y.s) t)[ϕ]=elimNat⁡ (x.T[q(ϕ)]) z[ϕ] (x,y.s[q2(ϕ)]) t[ϕ](\operatorname{elimNat}\ (x.T)\ z\ (x,y.s)\ t)[\phi] = \operatorname{elimNat}\ (x.T[q(\phi)])\ z[\phi]\ (x,y.s[q^{2}(\phi)])\ t[\phi]
(λx.t)[ϕ]=λx.t[q(ϕ)](\lambda x.t)[\phi] = \lambda x.t[q(\phi)]
(r s)[ϕ]=(r[ϕ]) (s[ϕ])(r\ s)[\phi] = (r[\phi])\ (s[\phi])

Whenever we pass under a binder, we extend the weakening with qq. The successor case of the eliminator binds two variables (xx for the predecessor, yy for the inductive hypothesis), hence qq is applied twice.

Weakenings compose as: (ϕ∘ψ)(x)=ψ(ϕ(x))(\phi\circ\psi)(x) = \psi(\phi(x)). We now establish the key algebraic properties of weakenings.

Lemma 2.5 (qq-Identity). q(id)=idq(id) = id.

Proof. By case analysis on the argument:

q(id)(0)=0=id(0)q(id)(0) = 0 = id(0)
q(id)(x+1)=id(x)+1=x+1=id(x+1)q(id)(x+1) = id(x)+1 = x+1 = id(x+1)

Lemma 2.6 (Identity Weakening). For all t∈Expt \in Exp, t[id]=tt[id] = t.

Proof. By induction on tt. We show a few representative cases.

Case t=xt = x (variable).

x[id]=id(x)=xx[id] = id(x) = x

Case t=λx.t′t = \lambda x.t'.

(λx.t′)[id]=λx.(t′[q(id)])(\lambda x.t')[id] = \lambda x.(t'[q(id)])
=λx.(t′[id])(by Theorem 2.5)= \lambda x.(t'[id]) \qquad\text{(by Theorem 2.5)}
=λx.t′(by IH)= \lambda x.t' \qquad\text{(by IH)}

Case t=Π(x:S).Tt = \Pi(x:S).T.

(Π(x:S).T)[id]=Π(x:S[id]).(T[q(id)])(\Pi(x:S).T)[id] = \Pi(x:S[id]).(T[q(id)])
=Π(x:S).(T[id])(by IH and Theorem 2.5)= \Pi(x:S).(T[id]) \qquad\text{(by IH and Theorem 2.5)}
=Π(x:S).T(by IH)= \Pi(x:S).T \qquad\text{(by IH)}

All other cases follow the same pattern.

Lemma 2.7 (qq Distributes over Composition). For all weakenings ϕ,ψ\phi,\psi: q(ϕ)∘q(ψ)=q(ϕ∘ψ)q(\phi) \circ q(\psi) = q(\phi\circ\psi).

Proof. By case analysis on the argument:

(q(ϕ)∘q(ψ))(0)=q(ψ)(q(ϕ)(0))=q(ψ)(0)=0=q(ϕ∘ψ)(0)(q(\phi) \circ q(\psi))(0) = q(\psi)(q(\phi)(0)) = q(\psi)(0) = 0 = q(\phi\circ\psi)(0)
(q(ϕ)∘q(ψ))(x+1)=q(ψ)(ϕ(x)+1)=ψ(ϕ(x))+1(q(\phi) \circ q(\psi))(x+1) = q(\psi)(\phi(x)+1) = \psi(\phi(x))+1
=(ϕ∘ψ)(x)+1=q(ϕ∘ψ)(x+1)= (\phi\circ\psi)(x)+1 = q(\phi\circ\psi)(x+1)

The previous lemma generalizes to arbitrary applications of qq:

Lemma 2.8 (qnq^{n} Distributes over Composition). For all weakenings ϕ,ψ\phi,\psi: qn(ϕ)∘qn(ψ)=qn(ϕ∘ψ)q^{n}(\phi) \circ q^{n}(\psi) = q^{n}(\phi\circ\psi).

References

  1. [1]Andreas Abel. 2013. Normalization by evaluation: dependent types and impredicativity. Habilitation thesis. Ludwig-Maximilians-Universität München.
  2. [2]Thorsten Altenkirch, Martin Hofmann, and Thomas Streicher. 1995. Categorical reconstruction of a reduction free normalization proof. In Category Theory and Computer Science, David Pitt, David E. Rydeheard, and Peter Johnstone (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 182–199.DOI
  3. [3]Thorsten Altenkirch and Ambrus Kaposi. 2016. Normalisation by Evaluation for Dependent Types. In 1st International Conference on Formal Structures for Computation and Deduction, FSCD 2016, Porto, Portugal, June 22-26, 2016 (LIPIcs), Delia Kesner and Brigitte Pientka (Eds.). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 6:1–6:16. doi:10.4230/LIPIcs.FSCD.2016.6DOI
  4. [4]Thorsten Altenkirch and Ambrus Kaposi. 2017. Normalisation by Evaluation for Type Theory, in Type Theory. Log. Methods Comput. Sci. 13, 4 (2017). doi:10.23638/LMCS-13(4:1)2017DOI
  5. [5]Ulrich Berger and Helmut Schwichtenberg. 1991. An Inverse of the Evaluation Functional for Typed lambda-calculus. In Proceedings of the Sixth Annual Symposium on Logic in Computer Science (LICS ’91), Amsterdam, The Netherlands, July 15-18, 1991. IEEE Computer Society, 203–211. doi:10.1109/LICS.1991.151645
  6. [6]Daniel Gratzer, Jonathan Sterling, and Lars Birkedal. 2019. Implementing a modal dependent type theory. Proc. ACM Program. Lang. 3, ICFP (2019), 107:1–107:29. doi:10.1145/3341711DOI
  7. [7]Jason Z. S. Hu, Junyoung Jang, and Brigitte Pientka. 2023. Normalization by evaluation for modal dependent type theory. J. Funct. Program. 33 (2023). doi:10.1017/S0956796823000060DOI
  8. [8]Junyoung Jang, Antoine Gaulin, Jason Z. S. Hu, and Brigitte Pientka. 2025. McTT: A Verified Kernel for a Proof Assistant. Proc. ACM Program. Lang. 9, ICFP (2025), 190–221. doi:10.1145/3747511
  9. [9]Shengyi Jiang, Jason Z. S. Hu, and Bruno C. d. I. S. Oliveira. 2025. Normalization by Evaluation for Non-cumulativity. Proc. ACM Program. Lang. 9, ICFP (2025), 93–127. doi:10.1145/3747508DOI
  10. [10]Per Martin-Löf. 1975. An Intuitionistic Theory of Types: Predicative Part. In Studies in Logic and the Foundations of Mathematics, H. E. Rose and J. C. Shepherdson (Eds.). Logic Colloquium ’73, Vol. 80. Elsevier, 73–118. doi:10.1016/S0049-237X(08)71945-1
  11. [11]Per Martin-Löf. 1984. Intuitionistic type theory. Studies in proof theory, Vol. 1. Bibliopolis.
  12. [12]Steffen Schӓfer, Tobias Tebbi, and Gert Smolka. 2015. Autosubst: Reasoning with Terms and Parallel Substitutions. In Interactive Theorem Proving - 6th International Conference, ITP 2015, Nanjing, China, August 24-27, 2015, Proceedings (Lecture Notes in Computer Science), Christian Urban and Xingyuan Zhang (Eds.). Springer, 359–374. doi:10.1007/978-3-319-22102-1_24
  13. [13]Kathrin Stark, Steven Schäfer, and Jonas Kaiser. 2019. Autosubst 2: reasoning with multi-sorted de Bruijn terms and vector substitutions. In Proceedings of the 8th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2019, Cascais, Portugal, January 14-15, 2019, Assia Mahboubi and Magnus O. Myreen (Eds.). ACM, 166–180. doi:10.1145/3293880.3294101

Paper details

vlnc:W_4ta9kfw6
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents