# ¶ Normalization

One way of deciding an equational theory is through normalizing its terms.

Take any equational theory with judgments of the form

$\mathrm{\Gamma }⊢M=N:\tau \Gamma \vdash M = N : \tau$

This judgment states that the terms $MM$ and $NN$, which are both of type $\tau \tau$, are equal. The context $\mathrm{\Gamma }\Gamma$ may contain typing assumptions, e.g. of the form $x:\sigma x : \sigma$, which are needed to infer that $MM$ and $NN$ have type $\tau \tau$. Thus, the terms $MM$ and $NN$ can be open, i.e. have free variables. This kind of judgment subsumes most type theories, e.g.

Given terms $\mathrm{\Gamma }⊢M:\tau \Gamma \vdash M : \tau$ and $\mathrm{\Gamma }⊢N:\tau \Gamma \vdash N : \tau$, we would like an algorithm that decides whether the judgment $\mathrm{\Gamma }⊢M=N:\tau \Gamma \vdash M = N : \tau$ is derivable in this equational theory. One way to do so is to normalize the terms of the calculus: we do so by mapping every term to some mathematical object that canonically represents its equivalence class under equality. Deciding whether $MM$ is equal to $NN$ then amounts to computing whether $MM$ and $NN$ are mapped to the same representative.

We can capture this axiomatically. Let

${\mathsf{T}\mathsf{m}}_{\tau }\left(\mathrm{\Gamma }\right)=\left\{M\mid \mathrm{\Gamma }⊢M:\tau \right\}\mathsf\left\{Tm\right\}_\tau\left(\Gamma\right) = \\left\{ M \mid \Gamma \vdash M : \tau \\right\}$

be the set of terms of type $\tau \tau$ in context $\mathrm{\Gamma }\Gamma$. Moreover, let ${\mathsf{N}\mathsf{f}}_{\tau }\left(\mathrm{\Gamma }\right)\mathsf\left\{Nf\right\}_\tau\left(\Gamma\right)$ be an abstract set of "normal forms" in context $\mathrm{\Gamma }\Gamma$. A normalizer is then a collection of functions

$\left\{{\mathsf{\text{nf}}}_{\mathrm{\Gamma },\tau }:{\mathsf{T}\mathsf{m}}_{\tau }\left(\mathrm{\Gamma }\right)\to {\mathsf{N}\mathsf{f}}_{\tau }\left(\mathrm{\Gamma }\right){\right\}}_{\mathrm{\Gamma },\tau }\\left\{\textsf\left\{nf\right\}_\left\{\Gamma, \tau\right\} : \mathsf\left\{Tm\right\}_\tau\left(\Gamma\right) \to \mathsf\left\{Nf\right\}_\tau\left(\Gamma\right)\\right\}_\left\{\Gamma, \tau\right\}$

which map each term $\mathrm{\Gamma }⊢M:\tau \Gamma \vdash M : \tau$ to a normal form, such that

where $\equiv \equiv$ refers to syntactic identity (possibly up to $\alpha \alpha$-equivalence).

That is: to decide whether two terms are equal, it suffices to compute their normal forms, and check if they are syntactically identical. This is computable precisely when (a) computing the normal forms, and (b) deciding their equality is.

If the normal forms are a subset of terms, i.e. if ${\mathfrak{N}}_{\tau }\left(\mathrm{\Gamma }\right)\subseteq {\mathfrak{L}}_{\tau }\left(\mathrm{\Gamma }\right)\mathfrak\left\{N\right\}_\tau\left(\Gamma\right) \subseteq \mathfrak\left\{L\right\}_\tau\left(\Gamma\right)$, the following axioms suffice:

1. Preservation of equational theory.
2. Equality with normal form. If $\mathrm{\Gamma }⊢M:\tau \Gamma \vdash M : \tau$ then $\mathrm{\Gamma }⊢M={\mathsf{\text{nf}}}_{\mathrm{\Gamma },\tau }\left(M\right):A\Gamma \vdash M = \textsf\left\{nf\right\}_\left\{\Gamma, \tau\right\}\left(M\right) : A$.
3. Idempotence. If $M\in {\mathfrak{N}}_{\tau }\left(\mathrm{\Gamma }\right)M \in \mathfrak\left\{N\right\}_\tau\left(\Gamma\right)$ then $M\equiv {\mathsf{\text{nf}}}_{\mathrm{\Gamma },\tau }\left(M\right)M \equiv\textsf\left\{nf\right\}_\left\{\Gamma, \tau\right\}\left(M\right)$.

We have used $\equiv \equiv$ for syntactic equality. These axioms imply (*). The left-to-right implication is simply Axiom 1. From right-to-left: we have the chain of equalities $\mathrm{\Gamma }⊢M={\mathsf{\text{nf}}}_{\mathrm{\Gamma },\tau }\left(M\right)\equiv {\mathsf{\text{nf}}}_{\mathrm{\Gamma },\tau }\left(N\right)=N:A\Gamma \vdash M = \textsf\left\{nf\right\}_\left\{\Gamma, \tau\right\}\left(M\right) \equiv \textsf\left\{nf\right\}_\left\{\Gamma, \tau\right\}\left(N\right) = N: A$ by using Axiom 2 twice. Axiom 3 is superfluous, but usually satsfied by well-behaved notions of normal form.

Note, however, that normal forms need not be a subset of terms: complicated type theories may require mathematically complicated notions of normal form.

## ¶ Canonicity

A type theory satisfies the canonicity property exactly when there are normalization functions at closed terms of ground type.

In terms of the previous definition, we only need a collection of functions

$\left\{{\mathsf{\text{nf}}}_{b}:{\mathsf{T}\mathsf{m}}_{b}\to {\mathsf{N}\mathsf{f}}_{b}{\right\}}_{b}\\left\{\textsf\left\{nf\right\}_b : \mathsf\left\{Tm\right\}_b \to \mathsf\left\{Nf\right\}_b\\right\}_\left\{b\right\}$

satisfying (*), where

• $bb$ ranges over the ground types of the system, e.g. $\mathsf{\text{Nat}}\textsf\left\{Nat\right\}$, $\mathsf{\text{Bool}}\textsf\left\{Bool\right\}$, etc.
• ${\mathsf{T}\mathsf{m}}_{b}=\left\{M\mid \cdot ⊢M:b\right\}\mathsf\left\{Tm\right\}_b = \\left\{ M \mid \cdot\vdash M : b \\right\}$ is the set of closed terms of ground type $bb$
• ${\mathsf{N}\mathsf{f}}_{b}\mathsf\left\{Nf\right\}_b$ usually consists of the normal forms of ground type $bb$

${\mathsf{N}\mathsf{f}}_{b}\mathsf\left\{Nf\right\}_b$ consists of the closed introduction forms of ground type. For example, ${\mathsf{N}\mathsf{f}}_{\mathsf{\text{Nat}}}\mathsf\left\{Nf\right\}_\textsf\left\{Nat\right\}$ consist of all terms of the form ${\mathsf{\text{succ}}}^{n}\left(\mathsf{\text{zero}}\right)\textsf\left\{succ\right\}^n\left(\textsf\left\{zero\right\}\right)$.

## ¶ Normalization by Rewriting

Normalization is a property of an abstract rewriting system that every term will eventually be rewritten as an irreducible term, called a normal form.
Strong normalization, or termination requires for all sequences of rewriting will leads to a normal form, and weak normalization only requires one such sequence to exist.

## ¶ Normalization by Evaluation

Normalization by evaluation refers to a 'semantic' technique for normalizing terms. In short, terms are interpreted in some sort of semantic structure. This structure is chosen cleverly so as to enable the extraction of normal forms from its elements. See the main article for more.

## ¶ References

• The normalization axioms given above come from
• Chicago
• BibTeX
• Fiore, Marcelo. 2002. ‘Semantic Analysis of Normalisation by Evaluation for Typed Lambda Calculus’. In Proceedings of the 4th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming - PPDP ’02, 26–37. Pittsburgh, PA, USA: ACM Press. https://doi.org/10.1145/571157.571161. pdf

@inproceedings{fiore_semantic_2002,
address = {Pittsburgh, PA, USA},
title = {Semantic analysis of normalisation by evaluation for typed lambda calculus},
isbn = {978-1-58113-528-2},
doi = {10.1145/571157.571161},
language = {en},
booktitle = {Proceedings of the 4th {ACM} {SIGPLAN} international conference on {Principles} and {Practice} of {Declarative} {Programming} - {PPDP} '02},
publisher = {ACM Press},
author = {Fiore, Marcelo},
year = {2002},
pages = {26--37}