<figure><img src="image_1.png" /></figure>

HAL
open science

# On the Definition of the Eta-long Normal Form in Type Systems of the Cube

Gilles Dowek, Gérard Huet, Benjamin Werner

<figure><img src="image_2.png" /></figure>

## To cite this version:

Gilles Dowek, Gérard Huet, Benjamin Werner. On the Definition of the Eta-long Normal Form in Type Systems of the Cube. 1993. hal-04148082

HAL Id: hal-04148082

https://inria.hal.science/hal-04148082

Preprint submitted on 2 Jul 2023

HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

<figure><img src="image_3.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# On the Definition of the Eta-long Normal Form in Type Systems of the Cube

Gilles Dowek Gérard Huet Benjamin Werner *

## Abstract

The smallest transitive relation $<$ on well-typed normal terms such that if $t$ is a strict subterm of $u$ then $t < u$ and if $T$ is the normal form of the type of $t$ and the term $t$ is not a sort then $T < t$ is well-founded in the type systems of the cube. Thus every term admits a $\eta$-long normal form.

## Introduction

In this paper we prove that the smallest transitive relation $<$ on well-typed normal terms such that

* if $t$ is a strict subterm of $u$ then $t < u$,

* if $T$ is the normal form of the type of $t$ and the term $t$ is not a sort then $T < t$

is well-founded in the type systems of the cube [1]. This result is proved using the notion of *marked terms* introduced by de Vrijer [6]. A motivation for this theorem is to define the $\eta$-long form of a normal term in these type systems.

In simply typed $\lambda$-calculus, to define the $\eta$-long form of a normal term we first define the $\eta$-long form of a variable $x$ of type $P_1 \rightarrow \dots \rightarrow P_n \rightarrow P$ ($P$ atomic) as the term $[y_1 : P_1]\dots[y_n : P_n](x y_1' \dots y_n')$ where $y_i'$ is the $\eta$-long form of the variable $y_i$ of type $P_i$. Then we define the $\eta$-long form of a normal term $t$ well-typed of type $P_1 \rightarrow \dots \rightarrow P_n \rightarrow P$ ($P$ atomic) as

* if $t = [x:U]u$ then its $\eta$-long form is the term $[x:U]u'$ where $u'$ is the $\eta$-long form of $u$,

<footnote>*INRIA-Rocquencourt, B.P. 105, 78153 Le Chesnay Cedex, France.
Gilles.Dowek@inria.fr, Gerard.Huet@inria.fr, Benjamin.Werner@inria.fr</footnote>
* if $t = (x c_1 ... c_p)$ then its $\eta$-long form is the term $[y_1 : P_1]...[y_n : P_n](x c'_1 ... c'_p y'_1 ... y'_n)$ where $c'_i$ is the $\eta$-long form of the term $c_i$, and $y'_i$ the $\eta$-long form of the variable $y_i$.

The definition of the $\eta$-long form of a variable is by induction over the structure of its type, and the definition of the $\eta$-long form of a normal term is by induction over the structure of the term itself. The $\eta$-long form appeared in [17] under the name of *long reduced form* and in [15] under the name of *$\eta$-normal form*, and was further investigated in [16], under the name of *extensional form*.

In systems with dependent types the corresponding definition is more complicated. First when $t = [x : U]u$ we have to take also the $\eta$-long form of the term $U$ and when $t = (x c_1 ... c_p)$ we have to take also the $\eta$-long form of the terms $P_1, ..., P_n$. So the well-foundedness of this definition is not so obvious, indeed $P_i$ is not a subterm of $t$, but a subterm of its type. We prove the well-foundedness of this definition using the well-foundedness of the relation $<$.

Besides the definition of $\eta$-long form, this well-foundedness result has been used in [8] to prove the completeness of the resolution method in the systems of the cube and in [7] to prove the decidability of second order matching in these systems.

# 1 The Cube of Typed $\lambda$-calculi

**Definition 1 (Term) The set of terms is inductively defined as**

$$T ::= \mathit{Prop} \mid \mathit{Type} \mid x \mid (T T) \mid [x : T] T \mid (x : T) T$$

The symbols *Prop* and *Type* are called *sorts*, the terms *x* are called *variables*, the terms (*T T*') applications, the terms [*x* : *T*] *T*' abstractions (they are sometimes written $\lambda x : T.T'$) and the terms (*x* : *T*) *T*' products (they are often written $\Pi x : T.T'$). Products are the type of functions and the notation $T \to T'$ is used for (*x* : *T*) *T*' when *x* does not occur free in *T*'. In this paper we ignore variable renaming problems. A rigorous presentation would use de Bruijn indices. We write (*a* $b_1$ ... $b_n$) for (*...* (*a* $b_1$) ... $b_n$).

**Notation** If $t$ and $u$ are two terms and $x$ is a variable, we write $t[x \leftarrow u]$ for the term obtained by substituting $u$ for $x$ in $t$. We write $a =_{\beta\eta} b$ (resp. $a =_{\beta} b$, $a =_{\eta} b$) when the terms $a$ and $b$ are $\beta\eta$-convertible (resp. $\beta$-convertible, $\eta$-convertible). We write $t \triangleright u$ (respectively $\triangleright_{\beta}, \triangleright_{\eta}$) when $t$ reduce in one step of $\beta$ or $\eta$-reduction (resp. $\beta$-reduction, $\eta$-reduction) to $u$,
$t \triangleright^* u$ (resp. $t \triangleright_{\beta}^* u, t \triangleright_{\eta}^* u$) when $t$ reduces in an arbitrary number of steps to $u$ and $t \triangleright^+ u$ (resp. $t \triangleright_{\beta}^+ u, t \triangleright_{\eta}^+ u$) when $t$ reduces in at least one step to $u$.

**Definition 2 (Context)** A context $\Gamma$ is a list of pairs $<x, T>$ (written $x:T$) where $x$ is a variable and $T$ a term. The term $T$ is called the type of $x$ in $\Gamma$.

We write $[x_1 : T_1; \dots; x_n : T_n]$ for the context with elements $x_1 : T_1, \dots, x_n : T_n$ and $\Gamma_1 \Gamma_2$ for the concatenation of the contexts $\Gamma_1$ and $\Gamma_2$.

**Definition 3 (Typing rules)** We define inductively two judgements: $\Gamma$ is well-formed (written $\vdash \Gamma$) and $t$ has type $T$ in $\Gamma$ (written $\Gamma \vdash t : T$) where $\Gamma$ is a context and $t$ and $T$ are terms. These judgements are indexed by the parameter $\mathcal{R}$ which is a set of pairs of sorts that contains the pair $<\text{Prop}, \text{Prop}>$.

$\vdash []$

$$ \frac{\Gamma \vdash T : s \quad x \notin \Gamma}{\vdash \Gamma[x : T]} s \in \{\text{Prop}, \text{Type}\} $$

$$ \frac{\vdash \Gamma}{\Gamma \vdash \text{Prop} : \text{Type}} $$

$$ \frac{\vdash \Gamma \quad x : T \in \Gamma}{\Gamma \vdash x : T} $$

$$ \frac{\Gamma \vdash T : s \quad \Gamma[x : T] \vdash U : s'}{\Gamma \vdash (x : T)U : s'} <s, s'> \in \mathcal{R} $$

$$ \frac{\Gamma \vdash (x : T)U : s \quad \Gamma[x : T] \vdash t : U}{\Gamma \vdash [x : T]t : (x : T)U} s \in \{\text{Prop}, \text{Type}\} $$

$$ \frac{\Gamma \vdash t : (x : T)U \quad \Gamma \vdash u : T}{\Gamma \vdash (t u) : U[x \leftarrow u]} $$

$$ \frac{\Gamma \vdash t : T \quad \Gamma \vdash U : s \quad T =_{\beta\eta} U}{\Gamma \vdash t : U} s \in \{\text{Prop}, \text{Type}\} $$
There are eight choices for the set $\mathcal{R}$ defining eight calculi. Examples of such calculi are the simply typed $\lambda$-calculus ($\mathcal{R} = \{\langle \text{Prop}, \text{Prop} > \}$), the $\lambda\Pi$-calculus [14] ($\mathcal{R} = \{\langle \text{Prop}, \text{Prop} >, \langle \text{Prop}, \text{Type} > \}\$), the system $F$ [13] ($\mathcal{R} = \{\langle \text{Prop}, \text{Prop} >, \langle \text{Type}, \text{Prop} > \}\$), the system $F\omega$ [13] ($\mathcal{R} = \{\langle \text{Prop}, \text{Prop} >, \langle \text{Type}, \text{Prop} >, \langle \text{Type}, \text{Type} > \}\$) and the Calculus of Constructions [3, 5] ($\mathcal{R} = \{\langle \text{Prop}, \text{Prop} >, \langle \text{Prop}, \text{Type} >, \langle \text{Type}, \text{Prop} >, \langle \text{Type}, \text{Type} > \}\$).

**Definition 4 (Well-typed term)** A term $t$ is said to be well-typed in a context $\Gamma$ iff there exists a term $T$ such that $\Gamma \vdash t : T$.

Notice that the term *Type* is not well-typed.

The following facts hold for every type system of the cube. The proofs are given in [10, 20].

**Proposition 1 (Substitution)** If $\Gamma[x : U]\Gamma' \vdash t : T$ and $\Gamma \vdash u : U$ then $\Gamma\Gamma'[x \leftarrow u] \vdash t[x \leftarrow u] : T[x \leftarrow u]$.

**Proposition 2** If $\Gamma \vdash t : T$ then either $T = \text{Type}$ or there exists a sort $s$ such that $\Gamma \vdash T : s$. Moreover if $t$ is a variable, an application or an abstraction (but neither a sort nor a product) then $T \neq \text{Type}$.

**Proposition 3 (Stripping Lemma)** Let $\Gamma \vdash t : T$ be a derivable judgment. The following holds:

$$t = \text{Prop} \quad \Rightarrow \quad T = \text{Type}$$

$$t = x \quad \Rightarrow \quad \exists U.(x : U \in \Gamma \land T =_{\beta\eta} U)$$

$$t = (x : A)B \quad \Rightarrow \quad \exists s_1, s_2. \Gamma \vdash A : s_1 \land \Gamma[x : A] \vdash B : s_2 \land (s_1, s_2) \in \mathcal{R} \land T = s_2$$

$$t = (u v) \quad \Rightarrow \quad \exists A, B.(\Gamma \vdash u : (x : A)B \land \Gamma \vdash v : A \land T =_{\beta\eta} B[x \leftarrow v])$$

$$t = [x : A]u \quad \Rightarrow \quad \exists B. \exists s. (\Gamma \vdash (x : A)B : s \land \Gamma[x : A] \vdash u : B \land T =_{\beta\eta} (x : A)B)$$

**Proposition 4 (Type Uniqueness)** A well-typed term has a unique type up to conversion.

**Definition 5 (Atomic Term)** A term is said to be atomic if it has the form $(h c_1 ... c_n)$ where $h$ is a variable or a sort (in this last case with $n = 0$). The symbol $h$ is called the head of this term.

**Proposition 5** Let $T$ be a well-typed $\beta$-normal term of type $s$ for some sort $s$, $T$ can be written in a unique way $T = (x_1 : P_1)...(x_n : P_n)P$ with $P$ atomic. Moreover if $s = \text{Type}$ then $P = \text{Prop}$.
**Proposition 6 (Strengthening)** If $\Gamma[x : U]\Gamma' \vdash t : T$ and $x$ does not occur free in $\Gamma'$, $t$ and $T$, then $\Gamma\Gamma' \vdash t : T$.

**Proposition 7 (Subject reduction)** If $\Gamma \vdash t : T$ and $t \triangleq^* u$ then $\Gamma \vdash u : T$.

**Proposition 8 (Normalization)** The relation $\triangleq$ is strongly normalizing.

**Proposition 9 (Confluence)** The relation $\triangleq$ is confluent.

**Proposition 10 (Church-Rosser)** If $\Gamma \vdash t_1 : T$, $\Gamma \vdash t_2 : T$ and $t_1 =_{\beta\eta} t_2$, then there exists $t$ such that $t_1 \triangleq^* t$ and $t_2 \triangleq^* t$ (and so $\Gamma \vdash t : T$).

We will also need the following technical lemma. It is implicitly present in the Church-Rosser proofs of [10, 20] but not stated in this exact form. It basically states that $\eta$-reductions do not erase free-variables on well-formed $\beta$-normal terms.

**Proposition 11** Let $\Gamma[x : U]\Gamma' \vdash t : T$ be a derivable judgement, with $t$ $\beta$-normal. Let $t'$ be its $\beta\eta$-normal form. If $\Gamma\Gamma' \vdash t' : T$ (in other words, $x$ does not occur free in $\Gamma'$, $t'$ and $T$) then $x$ does not occur free in $t$ either (and hence, by strengthening, $\Gamma\Gamma' \vdash t : T$).

*Proof.* On $\beta$-normal terms, such as $t$, $\eta$-reduction does not create $\beta$-redexes. Thus we have $t \triangleq_{\eta}^* t'$. We prove the proposition by induction over the structure of $t$; since $t$ is $\beta$-normal, the cases are:

* $t = s$; trivial.

* $t = (z : A)B$; in which case $t' = (z : A')B'$ with $A \triangleq_{\eta}^* A'$ and $B \triangleq_{\eta}^* B'$. The stripping lemma allows us to simply apply the induction hypothesis to the subterms (first to $A$, then to $B$ in the context $\Gamma[x : U]\Gamma'[z : A]$).

* $t = (y u_1 \dots u_n)$; which is similar to the case above. We simply have to reason by induction over $n$ in order to first build the respective types of $u_1 \dots u_n$ in $\Gamma\Gamma'$.

* $t = [z : A]B$; then we have two possibilities:

- $t' = [z : A']B'$ with $A \triangleq_{\eta}^* A'$ and $B \triangleq_{\eta}^* B'$. This case is similar to $t = (z : A)B$.
- $t' = B'$ with $B \triangleright_{\eta}^{*} (B'' z)$ and $B'' \triangleright_{\eta}^{*} B'$ with $x$ not free in $B'$. By the stripping lemma and Church-Rosser property, we know that $T \triangleright^{*} (z : A_0)C$ with $A = \beta_{\eta} A_0$. Since $x$ does not occur free in $A_0$, neither does it in its normal form, which is also the normal form of $A$. By induction hypothesis, $x$ does not occur free in $A$. Furthermore, the $\beta\eta$-normal form of $B$ is $(B' z)$, in which $x$ does not occur free. Since $C$ is a type of $B$ in which $x$ does not occur free either, we may again apply the induction hypothesis to the derivable judgement

$$ \Gamma[x:U]\Gamma'[z:A] \vdash B:C $$

in order to verify that $x$ does not occur free in $B$.

In order to be able to talk about the type of a subterm, we define the usual notion of subterm, but keeping track of the context in which they are well-typed: we write $t_{\Gamma}$ for a pair composed by a context $\Gamma$ and a $\beta$-normal term $t$ known to be well-typed in $\Gamma$.

**Definition 6 (Subterm)** Let $t_{\Gamma}$ be such a pair; we define by induction over the structure of $t_{\Gamma}$ the set $Sub(t_{\Gamma})$ of strict subterms of $t_{\Gamma}$:

* if $t_{\Gamma}$ is a sort or a variable then $Sub(t_{\Gamma}) = \{\}$,

* if $t_{\Gamma}$ is an application $t = (u v)$ then $Sub(t_{\Gamma}) = \{u_{\Gamma}, v_{\Gamma}\} \cup Sub(u_{\Gamma}) \cup Sub(v_{\Gamma})$,

* if $t_{\Gamma}$ is an abstraction $t = [x: P]u$ then $Sub(t_{\Gamma}) = \{P_{\Gamma}, u_{\Gamma[x:P]}\} \cup Sub(P_{\Gamma}) \cup Sub(u_{\Gamma[x:P]})$,

* if $t_{\Gamma}$ is a product $t = (x: P)u$ then $Sub(t_{\Gamma}) = \{P_{\Gamma}, u_{\Gamma[x:P]}\} \cup Sub(P_{\Gamma}) \cup Sub(u_{\Gamma[x:P]})$.

Notice that if the term $t$ is well-typed in $\Gamma$ and $u_{\Delta} \in Sub(t_{\Gamma})$ then $u$ is well-typed in $\Delta$.

**Definition 7 (The Relation <)** Let $<$ be the smallest transitive relation defined on $\beta\eta$-normal well-typed terms labeled by their contexts such that

* if neither $t$ nor $u$ is a sort and $t_{\Gamma}$ is a strict subterm of $u_{\Delta}$ then $t_{\Gamma} < u_{\Delta}$,

* if neither $t$ nor $T$ is a sort, and $T$ is the (unique) normal form of the type of $t$ in $\Gamma$ then $T_{\Gamma} < t_{\Gamma}$.
# 2 Marked Terms

## 2.1 Definition

The main idea in this proof is to consider a new syntax for type systems such that the type of a well-typed term $t$ is a subterm of $t$. So we define a syntax for type systems where each term is marked with its type. In fact, we only need to mark variables, applications and abstractions, but neither sorts nor products.

**Definition 8 (Marked Terms)**

$$T ::= \mathit{Prop} \mid \mathit{Type} \mid x^T \mid (T T)^T \mid ([x:T]T)^T \mid (x:T)T$$

**Definition 9 (Marked context)** A marked context is a list of pairs <x, T> (written $x: T$) where x a variable and T a marked term.

**Notation** Let $t$ and $u$ be marked terms and $x$ a variable. We write $t[x \leftarrow u]$ for the term obtained by substituting $u$ for $x$ in $t$, since the variable $x$ may also occur in the marks we have to substitute both in the term and in the marks. Free variables are defined as usual, here also they may occur in the marks too. $\beta$ and $\eta$-reductions are defined on marked terms in the same way as they are on unmarked terms. We write $t \triangleright u$ when $t$ reduces in one step of $\beta$ or $\eta$-reduction to $u$. The contracted redex may be either in the term or in the marks. We write $t \triangleright_{\beta} u$ if the contracted redex is a $\beta$-redex and $t \triangleright_{\eta} u$ if the contracted redex is an $\eta$-redex. A marked term $t$ is said to be normal (resp. $\beta$-normal, $\eta$-normal) if it contains no redex (resp. $\beta$-redex, $\eta$-redex).

**Definition 10 (Contents)** Let $t$ be a marked term, the contents of $t$ is the unmarked term $t^\#$ defined by induction over the structure of $t$:

* if $t$ is a sort then $t^\# = t$,

* if $t = x^T$ then $t^\# = x$,

* if $t = (u v)^T$ then $t^\# = (u^\# v^\#)$,

* if $t = ([x:P]u)^T$ then $t^\# = [x:P^\#]u^\#$,

* if $t = (x:P)U$ then $t^\# = (x:P^\#)U^\#$.
Let $\Gamma = [x_1 : P_1; \dots; x_n : P_n]$ be a marked context, the contents of $\Gamma$ is the context

$$ \Gamma^{\#} = [x_1 : P_1^{\#}; \dots; x_n : P_n^{\#}] $$

**Definition 11 (Conversion on marked terms)** Let $t_1$ and $t_2$ be two marked terms. We say that $t_1 =_{\beta\eta} t_2$ (respectively $t_1 =_{\beta} t_2$) if and only if $t_1^{\#} =_{\beta\eta} t_2^{\#}$ (respectively $t_1^{\#} =_{\beta} t_2^{\#}$)

Notice that the convertibility relation used on marked terms is defined as $\beta\eta$-conversion on the underlying unmarked terms, whatever that marks are.

**Definition 12 (Typing rules)** We define inductively two judgements: $\Gamma$ is well-formed (written $\vdash_M \Gamma$) and $t$ has type $T$ in $\Gamma$ ($\Gamma \vdash_M t : T$) where $\Gamma$ is a marked context and $t$ and $T$ are marked terms.

$\overline{\vdash_M [ ]}$

$$ \frac{\Gamma \vdash_M T : s \quad x \notin \Gamma}{\vdash_M \Gamma[x : T]} s \in \{Prop, Type\} $$

$$ \frac{\vdash_M \Gamma}{\Gamma \vdash_M Prop : Type} $$

$$ \frac{\vdash_M \Gamma \quad x : T \in \Gamma}{\Gamma \vdash_M x^T : T} $$

$$ \frac{\Gamma \vdash_M T : s \quad \Gamma[x : T] \vdash_M U : s'}{\Gamma \vdash_M (x : T)U : s'} < s, s' > \in \mathcal{R} $$

$$ \frac{\Gamma \vdash_M (x : T)U : s \quad \Gamma[x : T] \vdash_M t : U}{\Gamma \vdash_M ([x : T]t)^{(x:T)U} : (x : T)U} s \in \{Prop, Type\} $$

$$ \frac{\Gamma \vdash_M t : (x : T)U \quad \Gamma \vdash_M u : T}{\Gamma \vdash_M (t \ u)^{U[x \leftarrow u]} : U[x \leftarrow u]} $$

$$ \frac{\Gamma \vdash_M t : T \quad \Gamma \vdash_M U : s \quad T =_{\beta\eta} U}{\Gamma \vdash_M t : U} s \in \{Prop, Type\} $$
$$ \frac{\Gamma \vdash^M x^V : T \quad \Gamma \vdash^M W : s \quad V =_{\beta\eta} W}{\Gamma \vdash^M x^W : T} s \in \{Prop, Type\} $$

$$ \frac{\Gamma \vdash^M ([x:T]t)^V : U \quad \Gamma \vdash^M W : s \quad V =_{\beta\eta} W}{\Gamma \vdash^M ([x:T]t)^W : U} s \in \{Prop, Type\} $$

$$ \frac{\Gamma \vdash^M (t u)^V : U \quad \Gamma \vdash^M W : s \quad V =_{\beta\eta} W}{\Gamma \vdash^M (t u)^W : U} s \in \{Prop, Type\} $$

The three last rules permit to perform conversions in marks, in the same way as the rule above permit to perform conversion in the type of a term.

**Definition 13 (Well-typed marked term)** A marked term $t$ is said to be well-typed in a marked context $\Gamma$ if and only if there exists a marked term $T$ such that $\Gamma \vdash^M t : T$.

**Proposition 12** If $t$ and $u$ are marked terms and $t \triangleright u$ then either $t^\# = u^\#$ (if the redex occurs in the marks) or $t^\# \triangleright u^\#$.

**Proposition 13** If $t$ is a marked term such that $t^\# \triangleright \beta$ $u$ then there exists a marked term $t'$ such that $t \triangleright \beta$ $t'$ and $t'^\# = u$.

Notice that this proposition is false for $\eta$-reduction, even for well-typed terms; indeed the term $t = ([x:T^{Prop}]) (y (([z:T^{Prop}](T^{Prop} \rightarrow T^{Prop})))^{T^{Prop} \rightarrow T^{Prop}} x^{T^{Prop}})^{Prop} x^{T^{Prop}})^{T^{Prop}})^{T^{Prop}})$ is not an $\eta$-redex, but $t^\# = [x:T](y x)$ is one.

**Proposition 14** Let $\Gamma$ be a marked context and $t$ and $T$ be marked terms such that $\Gamma \vdash^M t : T$. Then $\Gamma^\# \vdash t^\# : T^\#$.

*Proof.* By induction on the length of the derivation of $\Gamma \vdash^M t : T$.

## 2.2 Basic properties

We now go to proving the basic properties of the system with marked terms. For several of the following properties, the proofs are very similar to what is done for the usual formulation using unmarked terms [10, 20]. In these cases, we do not detail the proof.

**Proposition 15 (Uniqueness of Product Formation)** If $(x : T_1)T_2 =_{\beta\eta} (x : U_1)U_2$ then $T_1 =_{\beta\eta} U_1$ and $T_2 =_{\beta\eta} U_2$. If $s_1$ and $s_2$ are two sorts such that $s_1 =_{\beta\eta} s_2$ then $s_1 = s_2$.
*Proof.* By definition $(x : T_1)T_2 =_{\beta\eta} (x : U_1)U_2$ if and only if $(x : T_1^{\#})T_2^{\#} =_{\beta\eta} (x : U_1^{\#})U_2^{\#}$ i.e. $T_1^{\#} =_{\beta\eta} U_1^{\#}$ and $T_2^{\#} =_{\beta\eta} U_2^{\#}$, i.e. $T_1 =_{\beta\eta} U_1$ and $T_2 =_{\beta\eta} U_2$.

**Proposition 16 (Substitution)** If $\Gamma[x : U]\Gamma' \vdash_M t : T$ and $\Gamma \vdash_M u : U$ then $\Gamma\Gamma'[x \leftarrow u] \vdash_M t[x \leftarrow u] : T[x \leftarrow u]$.

*Proof.* By induction on the length of the derivation of $\Gamma[x : U]\Gamma' \vdash_M t : T$.

**Proposition 17 (Weakening)** If $\Gamma\Gamma' \vdash_M t : T$, $\Gamma \vdash_M U : s$ and $x$ is a variable not declared in $\Gamma\Gamma'$ then $\Gamma[x : U]\Gamma' \vdash_M t : T$.

*Proof.* By induction on the length of the derivation of $\Gamma\Gamma' \vdash_M t : T$.

**Proposition 18** If $\Gamma \vdash_M t : T$ then either $T = \text{Type}$ or there exists a sort $s$ such that $\Gamma \vdash_M T : s$. Moreover if $t$ is a variable, an application or an abstraction (but neither a sort nor a product) then $T \neq \text{Type}$.

*Proof.* By induction on the length of the derivation of $\Gamma \vdash_M t : T$. For induction loading, we simultaneously prove that if $\Gamma = \Delta[z : V]\Delta'$, then $\Delta \vdash_M V : s$.

**Proposition 19 (Stripping)**

* If $\Gamma \vdash_M \text{Prop} : T$ then $T = \text{Type}$,

* if $\Gamma \vdash_M x^T : U$ then there exists a sort $s$ and a declaration $x : V$ in $\Gamma$ such that $\Gamma \vdash_M T : s$ and $T =_{\beta\eta} U =_{\beta\eta} V$,

* if $\Gamma \vdash_M (x : T_1)T_2 : U$ then there exists two sorts $s_1, s_2$ such that $U = s_2$, $\Gamma \vdash_M T_1 : s_1$, $\Gamma[x : T_1] \vdash_M T_2 : s_2$ and $<s_1, s_2> \in \mathcal{R}$,

* if $\Gamma \vdash_M ([x : T]t)^U : V$ then there exists a term $W$ and two sorts $s_1$ and $s_2$ such that $U =_{\beta\eta} V =_{\beta\eta} (x : T)W$, $\Gamma \vdash_M U : s_2$, $\Gamma \vdash_M T : s_1$, $\Gamma[x : T] \vdash_M t : W$, $\Gamma[x : T] \vdash_M W : s_2$ and $<s_1, s_2> \in \mathcal{R}$,

* if $\Gamma \vdash_M (t u)^T : U$ then there exists two terms $V$ and $W$ and a sort $s$ such that $T =_{\beta\eta} U =_{\beta\eta} W[x \leftarrow u]$, $\Gamma \vdash_M t : (x : V)W$, $\Gamma \vdash_M u : V$ and $\Gamma \vdash_M T : s$.

*Proof.* By induction over the length of the derivation.
**Proposition 20 (Type Uniqueness)** A well-typed term has a unique type up to conversion.

**Definition 14 (Atomic Term)** A marked term is said to be atomic if it has the form

$$ ( \dots (h c_1)^{T_1} \dots c_n)^{T_n} $$

where h is a marked variable $x^{T_0}$ or a sort s. The symbol h is called the head of this term.

**Proposition 21** Let t be a normal well-typed marked term; t is either an abstraction, a product or an atomic term.

**Proposition 22** Let T be a well-typed normal marked term of type s for some sort s; T can be written in a unique way $T = (x_1 : P_1)\dots(x_n : P_n)P$ with P atomic. Moreover if $s = Type$ then $P = Prop$.

**Proposition 23** Let $\Gamma$ be a marked context and t and T two marked terms such that $\Gamma \vdash^M t : T$. If t is a variable, an application or an abstraction, then T is convertible to the outermost mark of t. For instance if $t = (u v)^U$ then T is convertible to U.

**Proposition 24 (Convertibility of contexts)** If $\Gamma[x : T]\Gamma'$ and $\Gamma[x : U]\Gamma'$ are well-formed contexts and $\Gamma \vdash^M T : s$, $\Gamma \vdash^M U : s$, $T =_{\beta\eta} U$ and $\Gamma[x : T]\Gamma' \vdash^M t : V$ hold then $\Gamma[x : U]\Gamma' \vdash^M t : V$

*Proof.* By induction over the length of the derivation of $\Gamma[x : T]\Gamma' \vdash^M t : V$.

## 2.3 Subject reduction

**Proposition 25 (Subject $\beta$-reduction)** If $\Gamma \vdash^M t : T$ and $t \triangleright_{\beta} t'$ then $\Gamma \vdash^M t' : T$.

*Proof.* By induction over the structure of t. The key case is taken care by the substitution lemma. For induction loading, we also prove that if $\Gamma \triangleright_{\beta} \Gamma'$ then $\Gamma' \vdash^M t : T$.

We now want to prove the same property for $\eta$-reduction.

**Proposition 26 (Geuvers)** If $\Gamma \vdash^M t : u$ and $t =_{\beta\eta} (x : T)U$ then $t \triangleright_{\beta}^* (x : V)W$. If $\Gamma \vdash^M t : u$, given a sort s such that $t =_{\beta\eta} s$, one has $t \triangleright_{\beta}^* s$.
*Proof.* If $t =_{\beta\eta} (x : T)U$ then $t^{\#} =_{\beta\eta} (x : T^{\#})U^{\#}$. Thus there are terms $T'$ and $U'$ such that $t^{\#} \triangleright^* (x : T')U'$, and terms $T''$ and $U''$ such that $t^{\#} \triangleright_{\beta}^{*} (x : T'')U''$. Thus, there are terms $V$ and $W$ such that $t \triangleright^* (x : V)W$. If $t =_{\beta\eta} s$ then $t^{\#} =_{\beta\eta} s$. Thus $t^{\#} \triangleright^* s$, $t^{\#} \triangleright_{\beta}^{*} s$, and $t \triangleright_{\beta}^{*} s$.

**Proposition 27 (Strengthening)**

* If $\Gamma[x : U]\Gamma' \vdash_M t : s$ and $x$ occurs free neither in $\Gamma'$ nor in $t$ then $\Gamma\Gamma' \vdash_M t : s$.

* If $\Gamma[x : U]\Gamma' \vdash_M t : T$ and $x$ occurs free neither in $\Gamma'$ nor in $t$ then there exist a term $T'$ such that $\Gamma\Gamma' \vdash_M t : T'$.

*Proof.* By induction over the structure of $t$:

* If $t = (t_1 \ t_2)^A$, by the stripping lemma, we have $\Gamma[x : U]\Gamma' \vdash_M t_1 : (z : C)D$ and $\Gamma[x : U]\Gamma' \vdash_M t_2 : C$. The induction hypothesis ensures that $\Gamma\Gamma' \vdash_M t_1 : E$ and $\Gamma\Gamma' \vdash_M t_2 : C'$. Since $E =_{\beta\eta} (z : C)D$, Geuvers' lemma implies that $E \triangleright_{\beta}^{*} (z : C'')D'$. The conversion rule gives $\Gamma\Gamma' \vdash_M t_2 : C''$, and so $\Gamma\Gamma' \vdash_M (t_1 \ t_2)^{D'[z \leftarrow t_2]} : D'[z \leftarrow t_2]$. The induction hypothesis also implies $\Gamma\Gamma' \vdash_M A : s$, and so we finally have $\Gamma\Gamma' \vdash_M (t_1 \ t_2)^A : D'[z \leftarrow t_2]$.

* If $t = ([z : A]t_0)^B$, the stripping lemma applied to the derivable judgement

$$ \Gamma[x : U]\Gamma' \vdash_M ([z : A]t_0)^B : B $$

ensures that

$$ \Gamma[x : U]\Gamma'[z : A] \vdash_M t_0 : C, $$

$$ \Gamma[x : U]\Gamma' \vdash_M A : s_1, $$

$$ \Gamma[x : U]\Gamma' \vdash_M B : s_2, $$

$$ B =_{\beta\eta} (z : A)C, \text{ and } <s_1, s_2> \in \mathcal{R}. $$

Thus, by induction hypothesis

$$ \Gamma\Gamma'[z : A] \vdash_M t_0 : D, $$

$$ \Gamma\Gamma' \vdash_M A : s_1, $$

$$ \Gamma\Gamma'[z : A] \vdash_M B : s_2. $$
Geuvers' lemma ensures that $B \triangleright_{\beta}^{*} (z : A')C'$ with $C' =_{\beta\eta} D$ and $A =_{\beta\eta} A'$. Thus we have

$$ \Gamma\Gamma'[z : A] \vdash_M t_0 : C' $$

$$ \Gamma\Gamma'[z : A] \vdash_M C' : s $$

Hence

$$ \Gamma\Gamma' \vdash_M ([z : A]t_0)^{(z:A)C'} : (z : A)C' $$

The other cases are straightforward.

**Proposition 28 (subject $\eta$-reduction)** If $\Gamma \vdash_M t : T$ and $t \triangleright_{\eta} t'$ then $\Gamma \vdash_M t' : T$.

*Proof.* By induction over the structure of $t$. All the cases are straightforward, but the one in which $t$ is itself the reduced $\eta$-redex. In this case $t = ([x : U](u x^V)^W)^X$ and $t' = u$. Using twice the stripping lemma we get $\Gamma[x : U] \vdash_M u : (y : A)B$ with $(y : A)B =_{\beta\eta} T$. By the strengthening lemma we get $\Gamma \vdash_M u : C$ and by unicity of typing $C =_{\beta\eta} (y : A)B$. Since $T \neq \text{Type}$, we have $\Gamma \vdash_M T : s$ and $\Gamma \vdash_M u : T$ by conversion.

## 2.4 Normal forms

We have remarked above that even when $t^\#$ is an $\eta$-redex, $t$ is not necessarily an $\eta$-redex. We prove now that provided we perform enough reductions inside the marks, the term $t$ becomes an $\eta$-redex. In the example above, the term

$$ ([x : T^{Prop}](y((([z:T^{Prop}](T^{Prop} \rightarrow T^{Prop})))^{T^{Prop}} \rightarrow Prop \quad x^{T^{Prop}})^{Prop} \quad x^{T^{Prop}}))^{T^{Prop}} \rightarrow T^{Prop} $$

is not an $\eta$-redex, but it reduces to the term

$$ ([x : T^{Prop}](y^{T^{Prop}} \rightarrow T^{Prop} \quad x^{T^{Prop}})^{T^{Prop}} \rightarrow T^{Prop} $$

which is an $\eta$-redex.

More precisely, we eventually want to prove the following: if $t$ is well-typed and $\beta\eta$-normal then $t^\#$ is $\beta\eta$-normal.

**Proposition 29** If $\Gamma[x : U]\Gamma' \vdash_M t : T$ with $t$ in $\beta$-normal form and there exists $t'$ such that $t =_{\beta\eta} t'$ and

$$ \Gamma\Gamma' \vdash_M t' : T $$

then $x$ does not occur in $t^\#$.
*Proof.* It is an immediate consequence of the proposition 11 and the fact that

$$ \Gamma^{\#}[x : U^{\#}]\Gamma'^{\#} \vdash^{\#} t^{\#} : T^{\#} $$

since $t^{\#}$ is $\beta$-normal.

**Proposition 30** If $\Gamma[x : U]\Gamma' \vdash_M t : T$, $t$ is $\beta$-normal and $x$ does not occur free neither in $\Gamma'$ nor in $t^{\#}$ and in $T$, then $x$ does not occur free in $t$ either (and thus $\Gamma\Gamma' \vdash_M t : T$ holds).

*Proof.* By induction over the structure of $t$:

* If $t = (z : A)B$, we have $\Gamma[x : U]\Gamma' \vdash_M A : s$ which, by induction, implies that $x$ does not occur free in $A$. We then apply the induction hypothesis to $\Gamma[x : U]\Gamma'[z : A] \vdash_M B : s'$ which ensures that $x$ does not occur free in $B$.

* If $t = ([z : B]C)^D$, the same reasoning as above ensures that $x$ does not occur free in $B$. We know that $D =_{\beta\eta} T$, that $x$ does not occur free in $T$; since $D$ is $\beta$-normal, the previous proposition ensures that $x$ does not occur free in $D^{\#}$. By induction hypothesis, this implies that $x$ does not occur free in $D$ either.

We know that $D$ (or $T$) is convertible to a product, and thus $D \triangleright_{\beta}^{*} (z : B')E$. We may then apply the induction hypothesis to $\Gamma[x : U]\Gamma'[z : B] \vdash_M C : E$. Thus the variable $x$ does not occur in $C$.

* If $t = ( ... (z^{T_0} c_1)^{T_1} ... c_n)^{T_n}$:

1. We first prove that $x$ does not occur free in $T_0$. Let $A_0$ be the type bound to $z$ in $\Gamma\Gamma'$. We know that $T_0 =_{\beta\eta} A_0$ and hence $T_0^{\#} =_{\beta\eta} A_0^{\#}$. We also know that $x$ does not occur free in $A_0$ and thus not in $A_0^{\#}$ either. Thus $x$ does not occur in the common normal form of $A_0^{\#}$ and $T_0^{\#}$. Since $T_0$ is $\beta$-normal, so is $T_0^{\#}$. The previous proposition allows us to conclude that $x$ does not occur free in $T_0^{\#}$. By induction hypothesis, $x$ does not occur free in $T_0$ (and thus also in $z^{T_0}$).

2. Since $z^{T_0}$ is left-hand of a well-formed application, it reduces to a function type: $T_0 \triangleright_{\beta}^{*} (y : A)B$. We know that

$$ \Gamma[x : U]\Gamma' \vdash_M c_1 : A $$
is derivable, that $x$ does not occur free in $c_1^\#$ and that $x$ does not
occur free in $A$; by induction hypothesis, $x$ does not occur free in
$c_1$ either.

3. Since $x$ does not occur free in $B$ and $c_1$, it does not occur free in $B[y \leftarrow c_1]$. Furthermore $T_1 =_{\beta\eta} B[y \leftarrow c_1]$ and since $T_1$ is $\beta$-normal, the previous proposition ensures that $x$ does not occur free in $T_1^\#$. Thus, by the induction hypothesis, it does not occur in $T_1$.

4. We may then iterate the steps 2 and 3 for every $c_i$ and $T_i$.

**Proposition 31** Let $t$ be a well-typed marked term. If $t$ is $\beta\eta$-normal then $t^\#$ is $\beta\eta$-normal.

*Proof.* We already know that $t^\#$ is $\beta$-normal. Now suppose that $t^\#$ is not $\eta$-normal. So we have a subterm $u$ of $t$ such that $u^\#$ is an $\eta$-redex: $u = ([x : A](v x^B)^C)^D$ with $x$ not occurring free in $v^\#$. Let $T$ be the type of $v$. The variable $x$ does not occur in $v^\#$, thus by the unmarked strengthening lemma there is a type $U$ of $v^\#$ in which $x$ does not occur. The types $U$ and $T^\#$ have the same $\beta\eta$-normal form. Thus $x$ does not occur in the $\beta\eta$-normal form of $T^\#$. Thus $x$ does not occur in the $\beta$-normal form of $T^\#$ (proposition 11). By the proposition 13, $T$ $\beta$-reduces to a term $T'$ such that $T'^\#$ is the $\beta$-normal form of $T^\#$. We have $\Gamma[x : T] \vdash T' : s$ and $x$ does not occur in $T'^\#$, thus, by the proposition 30, $x$ does not occur in $T'$. Then $\Gamma[x : T] \vdash v : T' : s$ and $x$ does not occur in $v^\#$ nor in $T'$, thus, by proposition 30 $x$ does not occur in $v$, which is contradictory.

**2.5 Normalization**

In this section we prove that each well-typed marked term has a normal
form. We use the an adaptation of the method of [14, 11], i.e. we associate
to each marked term $t$ an unmarked term $t^\circ$ that mimics all its reductions.

**Definition 15 (Marked terms translation)** We define by simultaneous
induction two translations from marked terms to unmarked terms. We use
a fresh variable *o* (of type *Prop*).

* If P is a term of the form $(x_1 : A_1)...(x_n : A_n)Prop$, we let $\bar{P} = (x_1 : A_1^\circ)...(x_n : A_n^\circ)\mathcal{o}$.

• otherwise, we let $\bar{P} = P^\circ$.
This first auxiliary encoding is meant for types (i.e. terms such that $t : s$) and in all the cases $\bar{t} : \text{Prop}$.

* If $t$ is a sort, we let $t^\circ = t$,

* if $t = x^T$, we let $t^\circ = ([z : \text{Prop}]x \bar{T})$,

* if $t = (u v)^T$, we let $t^\circ = ([z : \text{Prop}](u^\circ v^\circ) \bar{T})$,

* if $t = ([x : P]u)^T$, we let $t^\circ = ([z : \text{Prop}][x : P^\circ]u^\circ \bar{T})$,

* if $t = (x : P)Q$, we let $t^\circ = (x : P^\circ)Q^\circ$.

**Proposition 32** $FV(t^\circ) \subseteq FV(t) \cup \{o\}$

**Proposition 33**

$$a^{\circ}[x \leftarrow b^{\circ}] \triangleright^{*} (a[x \leftarrow b])^{\circ}$$ $$\bar{a}[x \leftarrow b^{\circ}] \triangleright^{*} \overline{a[x \leftarrow b]}$$

*Proof.* By induction over the structure of $a$.

If $a = x^T$ then:

$$a^{\circ} = ([z : \text{Prop}]x \bar{T})$$

$$a^{\circ}[x \leftarrow b^{\circ}] = ([z : \text{Prop}]b^{\circ} \bar{T}[x \leftarrow b^{\circ}]) \triangleright^{*} b^{\circ} = (x^{T}[x \leftarrow b])^{\circ} = (a[x \leftarrow b])^{\circ}$$

The other cases are a simple application of the induction hypothesis. For instance, if $a$ is an application $a = (t u)^T$, we have

$$a^{\circ} = ([z : \text{Prop}](t^{\circ} u^{\circ}) \bar{T})$$

and

$$a^{\circ}[x \leftarrow b^{\circ}] = ([z : \text{Prop}](t^{\circ}[x \leftarrow b^{\circ}] u^{\circ}[x \leftarrow b^{\circ}]) \bar{T}[x \leftarrow b^{\circ}])$$

By induction hypothesis we have

$$t^{\circ}[x \leftarrow b^{\circ}] \triangleright^{*} (t[x \leftarrow b])^{\circ}$$ $$u^{\circ}[x \leftarrow b^{\circ}] \triangleright^{*} (u[x \leftarrow b])^{\circ}$$ $$\bar{T}[x \leftarrow b^{\circ}] \triangleright^{*} \overline{T[x \leftarrow b]}$$

So

$$a^{\circ}[x \leftarrow b^{\circ}] \triangleright^{*} ([z : \text{Prop}]((t[x \leftarrow b])^{\circ} (u[x \leftarrow b])^{\circ}) \overline{T[x \leftarrow b]})$$ $$= ((t[x \leftarrow b] u[x \leftarrow b])^{T[x \leftarrow b]})^{\circ} = (a[x \leftarrow b])^{\circ}$$
**Proposition 34** If $a \triangleright b$ then $a^\circ \triangleright^+ b^\circ$.

*Proof.* If $a = (([x:P]t)^Tu)^U$ and $b = t[x \leftarrow u]$,

$$a^\circ = ([z: \mathrm{Prop}]/([z': \mathrm{Prop}]/[x: P^\circ]t^\circ \bar{T} u^\circ) \bar{U}^\circ)$$

$$b^\circ = (t[x \leftarrow u])^\circ$$

By reducing first three $\beta$-redexes in $a^\circ$ we get $t^\circ[x \leftarrow u^\circ]$. Thus

$$a^\circ \triangleright^+ t^\circ[x \leftarrow u^\circ]$$

and

$$t^\circ[x \leftarrow u^\circ] \triangleright^* (t[x \leftarrow u])^\circ = b^\circ$$

thus

$$a^\circ \triangleright^+ b^\circ$$

If $a = ([x:P](t x^P)^T)^U$ and $b = t$,

$$a^\circ = ([z: \mathrm{Prop}][x: P^\circ]/([z': \mathrm{Prop}](t^\circ ([z'': \mathrm{Prop}]x \bar{P}^\circ)) \bar{T}) \bar{U}^\circ)$$

$$b^\circ = t^\circ$$

We reduce three $\beta$-redexes and one $\eta$-redex in $a^\circ$ to get $b^\circ$ (notice that, by proposition 32, the variable $x$ does not occur in the term $t^\circ$).

The same holds if we reduce a redex in a subterm.

**Proposition 35** If $a =_{\beta\eta} b$ then $a^\circ =_{\beta\eta} b^\circ$.

*Proof.* For all terms $t$ we have $t^\circ \triangleright^* t^\#$. Thus $a^\circ =_{\beta\eta} a^\# =_{\beta\eta} b^\# =_{\beta\eta} b^\circ$.

**Definition 16 (Marked context translation)** Let $\Gamma = [x_1 : P_1; \dots; x_n : P_n]$ be a marked context, we let $\Gamma^\circ = [o : \mathrm{Prop}; x_1 : P_1^\circ; \dots; x_n : P_n^\circ]$.

**Proposition 36** Let $\Gamma$ be a marked context and $t$ and $T$ two marked terms such that $\Gamma \vdash^M t : T$ in some system of the cube, then $\Gamma^\circ \vdash^M t^\circ : T^\circ$ in the Calculus of Constructions.

*Proof.* By induction over the length of the derivation of $\Gamma \vdash^M t : T$.

**Proposition 37** The reduction on marked terms is strongly normalizing.

If there was an infinite reduction issued from a marked term $t$, we could build one issued from the unmarked term $t^\circ$, in contradiction with the fact that reduction is strongly normalizing on well-typed terms in the Calculus of Constructions.
## 2.6 Confluence

**Proposition 38** Let $a$ and $b$ two $\beta\eta$-normal marked terms well-typed in the marked context $\Gamma$. If $a^\# = b^\#$ then $a = b$.

*Proof.* By induction over the structure of $a$. Since $a$ and $b$ have the same contents, they are either both sorts, both variables, both abstractions, both products or both applications.

If they are, for instance, both applications, $a = (t u)^T$, $b = (v w)^U$ then the marked terms $t$ and $v$ are well-typed and normal in $\Gamma$ and have the same contents so they are equal, and symmetrically the marked terms $u$ and $w$ are equal. The marked terms $T$ and $U$ are well-typed and normal in $\Gamma$. Thus $T^\#$ and $U^\#$ are normal, and both are types of $a^\# = b^\#$ in $\Gamma^\#$. So $T^\# = U^\#$ and thus $T = U$. We then conclude that $a = b$.

The same holds if they are both sorts, variables, abstractions or products.

**Proposition 39 (Church-Rosser)** Let $\Gamma \vdash^M t_1 : T$ and $\Gamma \vdash^M t_2 : T$ be two derivable judgements. If $t_1 =_{\beta\eta} t_2$, then there exists a term $u$ such that $t_1 \vdash^* u$ and $t_2 \vdash^* u$.

*Proof.* Let $u_1$ and $u_2$ be two normal forms of respectively $t_1$ and $t_2$ (obtained, for instance, by left reduction). By proposition 31, the term $u_1^\#$ (respectively $u_2^\#$) is the normal form of $t_1^\#$ (respectively $t_2^\#$). Since $t_1^\# =_{\beta\eta} t_2^\#$, the Church-Rosser theorem for unmarked terms ensures that $u_1^\# = u_2^\#$. The previous proposition then yields $u_1 = u_2$. We may then take $u = u_1 = u_2$.

**Proposition 40 (Confluence)** Let $\Gamma \vdash^M t : T$, $t \vdash^* t_1$ and $t \vdash^* t_2$. Then there exists a term $u$ such that $t_1 \vdash^* u$ and $t_2 \vdash^* u$.

# 3 Well-foundedness of the relation <

By induction over typing derivations, we associate to each unmarked well-typed term a marked well-typed term.

**Definition 17** A marked context $\Gamma = [x_1 : P_1; \dots; x_p : P_n]$ is said to be normal if every $P_i$ is normal.

**Proposition 41** Let $\Gamma_1$ and $\Gamma_2$ be two normal well-formed marked contexts such that $\Gamma_1^\# = \Gamma_2^\#$. Then $\Gamma_1 = \Gamma_2$.

*Proof.* By induction over the common length of $\Gamma_1$ and $\Gamma_2$ using proposition 38.
**Definition 18 (Translation of an unmarked term into a marked term)**

Let us consider an unmarked derivable judgement $\Delta \vdash a : A$ or $\vdash \Delta$. By induction over the length of this derivation, we build, in the first case, a normal marked context $\Delta^*$ and normal marked terms $a^*$ and $A^*$ such that $\Delta^* \# =_{\beta\eta} \Delta$, $a^* \# =_{\beta\eta} a$, $A^* \# =_{\beta\eta} A$ and the judgement $\Delta^* \models^M a^* : A^*$ is derivable and, in the second case, a normal marked context $\Delta^*$ such that $\Delta^* \# =_{\beta\eta} \Delta$ and the judgement $\vdash^M \Delta^*$ is derivable.

* If the last rule of the derivation is

$\vdash []$

we let $\Delta^* = []$.

* If the last rule of the derivation is

$$ \frac{\Gamma \vdash T : s}{\vdash \Gamma[x : T]} $$

then by induction hypothesis we have built $\Gamma^*$ and $T^*$. We let $\Delta^* = \Gamma^*[x : T^*]$.

* If the last rule of the derivation is

$$ \frac{\vdash \Gamma}{\Gamma \vdash \text{Prop} : \text{Type}} $$

then by induction hypothesis we have built $\Gamma^*$. We let $\Delta^* = \Gamma^*$, $a^* = \text{Prop}$ and $A^* = \text{Type}$.

* If the last rule of the derivation is

$$ \frac{\vdash \Gamma \quad x : T \in \Gamma}{\Gamma \vdash x : T} $$

then by induction hypothesis we have built $\Gamma^*$. We have $\Gamma^* \# =_{\beta\eta} \Gamma$, so $\Gamma^*$ contains a declaration $x : P$ and $P^* =_{\beta\eta} T$. We let $\Delta^* = \Gamma^*$, $a^* = x^P$ and $A^* = P$.

* If the last rule of the derivation is

$$ \frac{\Gamma \vdash T : s \quad \Gamma[x : T] \vdash U : s'}{\Gamma \vdash (x : T)U : s'} $$
then by induction hypothesis we have built $\Gamma^*$, $T^*$, $(\Gamma[x:T])^*$ and $U^*$. Since $(\Gamma[x:T])^* \# =_{\beta\eta} \Gamma[x:T]$, the context $(\Gamma[x:T])^*$ has the form $\Gamma'[x:P]$ with $\Gamma'$ and $P$ normal $\Gamma'^* =_{\beta\eta} \Gamma$ and $P^* =_{\beta\eta} T$. Then since $\Gamma^*$ and $\Gamma'$ are both normal well-formed and have the same contents we have $\Gamma^* = \Gamma'$ and since $T^*$ and $P$ are both normal, well-typed in $\Gamma^*$ and have the same contents $T^* = P$. We let $\Delta^* = \Gamma^*$, $a^* = (x:T^*)U^*$ and $A^* = s'$.

* If the last rule of the derivation is

$$ \frac{\Gamma \vdash (x : T)U : s \quad \Gamma[x : T] \vdash t : U}{\Gamma \vdash [x : T]t : (x : T)U} $$

then by induction hypothesis we have built $\Gamma^*$, $((x:T)U)^*$, $(\Gamma[x:T])^*$, $t^*$ and $U^*$. Since $((x:T)U)^*$ is normal and $((x:T)U)^* \# =_{\beta\eta} (x:T)U$ the term $((x:T)U)^*$ is a product $(x:P)Q$, $P$ and $Q$ are normal $P^* =_{\beta\eta} T$ and $Q^* =_{\beta\eta} U$. In the same way since $(\Gamma[x:T])^*$ is normal and $(\Gamma[x:T])^* \# =_{\beta\eta} \Gamma[x:T]$, the context $(\Gamma[x:T])^*$ has the form $\Gamma'[x:R]$ with $\Gamma'$ and $R$ normal $\Gamma'^* =_{\beta\eta} \Gamma$ and $R^* =_{\beta\eta} U$. Since $\Gamma^*$ and $\Gamma'$ are normal well-formed and have the same contents $\Gamma^* = \Gamma'$. Since $P$ and $R$ normal well-typed in $\Gamma^*$ and have the same contents, $P = R$. Since $Q$ and $U^*$ are normal well-typed in $\Gamma^*[x:P]$ and have the same contents, $Q = U^*$. We let $\Delta^* = \Gamma^*$, $a^* = ([x:P]t^*)^{(x:P)Q}$ and $A^* = (x:P)Q$.

* If the last rule of the derivation is

$$ \frac{\Gamma \vdash t : (x : T)U \quad \Gamma \vdash u : T}{\Gamma \vdash (t \ u) : U[x \leftarrow u]} $$

then by induction hypothesis we have built $\Gamma_1^*, t^*$, $((x:T)U)^*$, $\Gamma_2^*, u^*$ and $T^*$. Since the term $((x:T)U)^*$ is normal and $((x:T)U)^* \# =_{\beta\eta} (x:T)U$, the term $((x:T)U)^*$ has the form $(x:P)Q$, $P$ and $Q$ are normal $P^* =_{\beta\eta} T$ and $Q^* = U$. Since $\Gamma_1^*$ and $\Gamma_2^*$ are normal, well-formed and have the same contents, $\Gamma_1^* = \Gamma_2^*$. Since $P$ and $T^*$ normal, well-typed in $\Gamma_1^*$ and have the same contents, $T^* = P$. We have $\Gamma_1^* \models_M t^* : (x:T^*)U^*$ and $\Gamma_1^* \models_M u^* : T^*$, thus $\Gamma_1^* \models_M (t^* u^*)^{U^*[x \leftarrow u^*]} : U^*[x \leftarrow u^*]$. Let $v$ be the normal form of $(t^* u^*)^{U^*[x \leftarrow u^*]}$ and $V$ be the normal form of $U^*[x \leftarrow u^*]$. We have $\Gamma_1^* \models_M v : V$. We let $\Delta^* = \Gamma_1^*$, $a^* = v$ and $A^* = V$.
• If the last rule of the derivation is

$$ \frac{\Gamma \vdash t : T \quad \Gamma \vdash U : s \quad T = \beta \eta U}{\Gamma \vdash t : U} $$

then by induction hypothesis we have built $\Gamma_1^*$, $t^*$, $T^*$, $\Gamma_2^*$ and $U^*$. Since $\Gamma_1^*$ and $\Gamma_2^*$ are normal well-formed and have the same contents they are equal. Since $T^*$ and $U^*$ are normal, well-typed in $\Gamma_1^*$ and have the same contents, they are equal. We let $\Delta^* = \Gamma_1^*$, $a^* = t^*$ and $A^* = U^*$.

**Proposition 42** Let $t$ and $u$ be two unmarked normal terms well-typed in two contexts $\Gamma$ and $\Delta$. If $t_\Gamma < u_\Delta$ then $t^*$ is a strict subterm of $u^*$.

*Proof.* We have $\Gamma \vdash t : T$ and $\Delta \vdash u : U$. Thus $\Gamma^* \vdash t^* : T^*$ and $\Delta^* \vdash u^* : U^*$. If $t_\Gamma$ is a strict subterm of $u_\Delta$ then by induction over the structure of $u$, the term $t^*$ is a strict subterm of $u^*$. If $t$ is the normal form of the type $U$ of $u$ then $t^*$ and $U^*$ are $\beta\eta$-equivalent and normal, thus by Church-Rosser property, they are equal. Hence, using proposition 23, since $t$ is not a sort, $t^*$ is the outermost mark of $u^*$.

Thus, since the subterm order is well-founded on marked terms, we can deduce:

**Theorem 1** The relation $<$ is well-founded.

Notice that this theorem holds also for a calculus of the cube with $\beta$-conversion only.

# 4 The Eta-long normal form

**Definition 19 (Measure of a Term)** Let $\Gamma$ be a context and $t$ a unmarked normal term well-typed of type $T$ in $\Gamma$. We define by induction over the order $<$, the measure $\mu(t)$ of $t$

• If $t$ is a sort then $\mu(t) = 1$,

• If $t = x$ and $T$ then $\mu(t) = \mu(T) + 1$,

• If $t = (u \ v)$ then $\mu(t) = \mu(u) + \mu(v) + \mu(T)$,

• If $t = [x : U]v$ then $\mu(t) = \mu(U) + \mu(v) + \mu(T)$,
* If $t = (x : U)V$ then $\mu(t) = \mu(U) + \mu(V)$.

Now we can give the following definition by induction over $\mu(t)$.

**Definition 20 (η-long form)** Let $\Gamma$ be a context and $t$ a normal term well-typed in $\Gamma$ and $(x_1 : P_1)...(x_n : P_n)P$ (P atomic) the normal form of its type. Then

* if $t = [x : U]u$ then the η-long form of $t$ in $\Gamma$ is the term $[x : U']u'$ where $U'$ is the η-long form of $U$ in $\Gamma$ and $u'$ the η-long form of $u$ in $\Gamma[x : U]$,

* if $t = (x : U)V$ the η-long form of $t$ in $\Gamma$ is the term $(x : U')V'$ where $U'$ is the η-long form of $U$ in $\Gamma$ and $V'$ the η-long form of $V$ in $\Gamma[x : U]$,

* if $t = (w c_1 ... c_p) \text{ the } \eta\text{-long form of } t \text{ in } \Gamma \text{ is the term } [x_1 : P'_1]...[x_n : P'_n] (w c'_1 ... c'_p x'_1 ... x'_n) \text{ where } c'_i \text{ is the } \eta\text{-long form of } c_i \text{ in } \Gamma, P'_i \text{ the } \eta\text{-long form of } P_i \text{ in } \Gamma[x_1 : P_1; ...; x_{i-1} : P_{i-1}] \text{ and } x'_i \text{ the } \eta\text{-long form of } x_i \text{ in } \Gamma[x_1 : P_1; ...; x_i : P_i]$.

Notice that $\mu(x_i) = \mu(P_i) + 1 \le \mu((x_1 : P_1)...(x_n : P_n)P) < \mu(t)$.

At last we prove the following extra result.

**Definition 21 (The Relation <')** Let $<'$ be the smallest transitive relation defined on normal well-typed terms such that

* if neither $t$ nor $u$ is a sort and $t_\Gamma$ is a strict subterm of $u_\Delta$ then $t_\Gamma <' u_\Delta$,

* if neither $t$ nor $T$ is a sort and $T_\Gamma$ is the η-long form of the normal form of the type of $t_\Gamma$ in $\Gamma$ and the term $t$ is not a sort then $T_\Gamma <' t_\Gamma$.

We prove that the relation $<'$ is also well-founded.

**Definition 22 (Measure of a Marked Term)** Let $t$ be a marked term, we define by induction over the structure of $t$, the measure $\mu(t)$ of $t$

* If $t$ is a sort then $\mu(t) = 1$,

* If $t = x^T$ then $\mu(t) = \mu(T) + 1$,

* If $t = (u v)^T$ then $\mu(t) = \mu(u) + \mu(v) + \mu(T)$,
• If $t = ([x:U]v)^T$ then $\mu(t) = \mu(U) + \mu(v) + \mu(T)$,

• If $t = (x:U)V$ then $\mu(t) = \mu(U) + \mu(V)$.

**Definition 23 (η-long Form of a Marked Term)** Let $\Gamma$ be a marked context and $t$ be a normal marked term well-typed in $\Gamma$ with the type $(x_1 : P_1)...(x_n : P_n)P$ (P atomic). The η-long form of the marked term $t$ is defined by induction over $\mu(t)$.

• If $t = ([x:U]u)^T$ then the η-long form of $t$ is $([x:U']u')^{T'}$ where $U'$ is the η-long form of $U$ in $\Gamma$, $T'$ the η-long form of $T$ in $\Gamma$ and $u'$ the η-long form of $u$ in $\Gamma[x:U]$,

• if $t = (x:U)V$ then the η-long form of $t$ is $(x:U')V'$ where $U'$ is the η-long form of $U$ in $\Gamma$ and $V'$ the η-long form of $V$ in $\Gamma[x:U]$,

• if $t = (... (w^{T_0} c_1)^{T_1} ... c_p)^{T_p}$ then the η-long form of $t$ is

$$[x_1 : P'_1]...[x_n : P'_n]...((... (w^{T'_0} c'_1)^{T'_1} ... c'_p)^{T'_p} x'_1)^{V'_1} ... x'_n)^{V'_n}$$

where $c'_i$ is the η-long form of $c_i$ in $\Gamma$, $T'_i$ the η-long form of $T_i$ in $\Gamma$, $P'_i$ the η-long form of $P_i$ in $\Gamma[x_1 : P_1; ...; x_{i-1} : P_{i-1}]$, $P'$ the η-long form of $P$ in $\Gamma[x_1 : P_1; ...; x_n : P_n]$, $x'_i$ the η-long form of $x_i^{P_i}$ in $\Gamma[x_1 : P_1; ...; x_i : P_i]$ and $V'_i = (x_{i+1} : P'_1)...(x_{i+1} : P'_n)P'$.

**Definition 24 (Normal η-long translation of an unmarked term)** Let $t$ be a term well-typed in the context $\Gamma$, we define its normal η-long translation $t^+$ as the η-long form of its translation $t^*$.

**Theorem 2** *The relation <' is well-founded.*

*Proof.* As in the proof of the well-foundedness of the relation $<$ we first prove that if $t <' u$ then $t^+$ is a strict subterm of $u^+$ and then that there is no infinite decreasing sequence for the relation $<'$.

## Acknowledgements

The authors thank Christine Paulin who suggested them the idea of the normalization proof for marked terms and Cristina Cornes for a careful reading of a draft of this paper.
References

[1] H. Barendregt, Introduction to Generalized type systems, *Journal of Functional Programming*, 1, 2 (1991) pp. 125-154.

[2] H. Barendregt, Lambda calculi with types, *Handbook of Logic in Computer Science*, S. Abramsky, D.M. Gabbay, T.S.E. Maibaum (eds.) Clarendon Press, Oxford (1992).

[3] Th. Coquand, Une théorie des constructions, *Thèse de troisième cycle*, Université de Paris VII (1985).

[4] Th. Coquand, An algorithm for testing conversion in type theory, *Logi-cal Frameworks*, G. Huet and G. Plotkin (Eds.), Cambridge University Press (1991).

[5] Th. Coquand, G. Huet, The Calculus of constructions, *Information and Computation*, 76 (1988) pp. 95-120.

[6] R. de Vrijer, Big trees in a λ-calculus with λ-expressions as types, *λ-calculus and Computer Science Theory*, Lecture Notes in Computer Science 37 (1975) pp. 252-271.

[7] G. Dowek, A second order pattern matching algorithm in the cube of typed λ-Calculi, *Proceedings of Mathematical Foundation of Computer Science*, Lecture Notes in Computer Science, 520 (1991) pp. 151-160. Rapport de Recherche 1585, INRIA, (1992).

[8] G. Dowek, A complete proof synthesis method for the cube of type systems, *Journal of Logic and Computation*, 3, 3 (1993) pp. 287-315.

[9] H. Geuvers, The Church-Rosser property for βη-reduction in typed lambda calculi, *Proceedings of Logic in Computer Science* (1992) pp. 453-460.

[10] H. Geuvers, Logics and types systems, *PhD Thesis*, Catholic University of Nijmegen (1993).

[11] H. Geuvers, M.J. Nederhof, A modular proof of strong normalization for the Calculus of constructions, *Journal of Functional Programming*, I, 2 (1991) pp. 155-189.

[12] H. Geuvers, B. Werner, On the Church-Rosser property for expres-sive type systems and its consequences for their metatheoretic study, *Proceedings of Logic in Computer Science* (1994) pp. 320-329.
[13] J.Y. Girard, Interprétation fonctionnelle et élimination des coupures dans l’arithmétique d’ordre supérieur, *Thèse de Doctorat d’État*, Université de Paris VII (1972).

[14] R. Harper, F. Honsell, G. Plotkin, A framework for defining logics, *Journal of the ACM*, 40, 1 (1993) pp. 143-184.

[15] G. Huet. A unification algorithm for typed lambda calculus. *Theoretical Computer Science*, 1, 1 (1975) pp. 27-57.

[16] G. Huet. Résolution d'équations dans des langages d'ordre 1,2, ... ω. *Thèse d'Etat*, Université Paris VII (1976).

[17] D.C. Jensen and T. Pietrzykowski. Mechanizing ω-order type theory through unification. *Theoretical Computer Science*, 3 (1976) pp. 123-171.

[18] Z. Luo, An extended calculus of constructions, *PhD Thesis*, University of Edinburgh (1990).

[19] A. Salvesen, The Church-Rosser theorem for LF with β/η-reduction, Manuscript, University of Edinburgh (1989).

[20] B. Werner, Une théorie des constructions inductives, *Thèse de Doctorat*, Université Paris VII (1994).