---
abstract: |
    The univalence axiom expresses the principle of extensionality for dependent type theory. However, if we simply add the univalence axiom to type theory, then we lose the property of *canonicity* — that every closed term computes to a canonical form. A computation becomes ‘stuck’ when it reaches the point that it needs to evaluate a proof term that is an application of the univalence axiom. So we wish to find a way to compute with the univalence axiom. While this problem has been solved with the formulation of cubical type theory, where the computations are expressed using a nominal extension of lambda-calculus, it may be interesting to explore alternative solutions, which do not require such an extension.

    As a first step, we present here a system of propositional higher-order minimal logic (PHOML). There are three kinds of typing judgement in PHOML. There are *terms* which inhabit *types*, which are the simple types over $\Omega$. There are *proofs* which inhabit *propositions*, which are the terms of type $\Omega$. The canonical propositions are those constructed from $\bot$ by implication $\supset$. Thirdly, there are *paths* which inhabit *equations* $M =_A N$, where $M$ and $N$ are terms of type $A$. There are two ways to prove an equality: reflexivity, and *propositional extensionality* — logically equivalent propositions are equal. This system allows for some definitional equalities that are not present in cubical type theory, namely that transport along the trivial path is identity.

    We present a call-by-name reduction relation for this system, and prove that the system satisfies canonicity: every closed typable term head-reduces to a canonical form. This work has been formalised in Agda.
author:
- Robin Adams
- Marc Bezem
- Thierry Coquand
bibliography:
- '../../../../type.bib'
title: 'A Normalizing Computation Rule for Propositional Extensionality in Higher-Order Minimal Logic '
---

Introduction
============

The *univalence axiom* of Homotopy Type theory (HoTT) [@hottbook] postulates a constant $${\ensuremath{\mathsf{isotoid}}}: A \simeq B \rightarrow A = B$$ that is an inverse to the obvious function $A = B \rightarrow A \simeq B$. However, if we simply add this constant to Martin-Löf type theory, then we lose the important property of *canonicity* — that every closed term of type $A$ computes to a unique canonical object of type $A$. When a computation reaches a point where we eliminate a path (proof of equality) formed by ${\ensuremath{\mathsf{isotoid}}}$, it gets ’stuck’.

As possible solutions to this problem, we may try to do with a weaker property than canonicity, such as *propositional canonicity*: that every closed term of type $\mathbb{N}$ is *propositionally* equal to a numeral, as conjectured by Voevodsky. Or we may attempt to change the definition of equality to make ${\ensuremath{\mathsf{isotoid}}}$ definable [@Polonsky14a], or add a nominal extension to the syntax of the type theory (e.g. Cubical Type Theory [@cchm:cubical]).

We could also try a more conservative approach, and simply attempt to find a reduction relation for a type theory involving ${\ensuremath{\mathsf{isotoid}}}$ that satisfies all three of the properties above. There seems to be no reason *a priori* to believe this is not possible, but it is difficult to do because the full Homotopy Type Theory is a complex and interdependent system. We can tackle the problem by adding univalence to a much simpler system, finding a well-behaved reduction relation, then doing the same for more and more complex systems, gradually approaching the full strength of HoTT.

In this paper, we present a system we call PHOML, or predicative higher-order minimal logic. It is a type theory with three kinds of typing judgement. There are *terms* which inhabit *types*, which are the simple types over $\Omega$. There are *proofs* which inhabit *propositions*, which are the terms of type $\Omega$. The canonical propositions are those constructed from $\bot$ by implication $\supset$. Thirdly, there are *paths* which inhabit *equations* $M =_A N$, where $M$ and $N$ are terms of type $A$.

There are two canonical forms for proofs of $M =_\Omega N$. For any term $\varphi : \Omega$, we have ${\ensuremath{\mathrm{ref} \left( {\varphi} \right)}} : \varphi =_\Omega \varphi$. We also add univalence for this system, in this form: if $\delta : \varphi \supset \psi$ and $\epsilon : \psi \supset\varphi$, then ${\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}} : \varphi =_\Omega \psi$.

This entails that in PHOML, two propositions that are logically equivalent are equal. Every function of type $\Omega \rightarrow \Omega$ that can be constructed in PHOML must therefore respect logical equivalence. That is, for any $F$ and logically equivalent $x$, $y$ we must have that $Fx$ and $Fy$ are logically equivalent. Moreover, if for $x:\Omega$ we have that $Fx$ is logically equivalent to $Gx$, then $F =_{\Omega\to\Omega} G$. Every function of type $(\Omega \rightarrow \Omega) \rightarrow \Omega$ must respect this equality; and so on. This is the manifestation in PHOML of the principle that only homotopy invariant constructions can be performed in homotopy type theory. (See Section \[section:exampletwo\].)

We present a call-by-name reduction relation for this system, and prove that every typable term reduces to a canonical form. From this, it follows that the system is consistent.

For the future, we wish to include the equations in $\Omega$, allowing for propositions such as $M =_A N \supset N =_A M$. We wish to expand the system with universal quantification, and expand it to a 2-dimensional system (with equations between proofs). We then wish to add more inductive types and more dimensions, getting ever closer to full homotopy type theory.

Another system with many of the same aims is cubical type theory [@cchm:cubical]. The system PHOML is almost a subsystem of cubical type theory. We can attempt to embed PHOML into cubical type theory, mapping $\Omega$ to the universe $U$, and an equation $M =_A N$ to either the type ${\ensuremath{\mathsf{Path} \, {A} \, {M} \, {N}}}$ or to $\mathrm{Id}\ A\ M\ N$. However, PHOML has more definitional equalities than the relevant fragment of cubical type theory; that is, there are definitionally equal terms in PHOML that are mapped to terms that are not definitionally equal in cubical type theory. In particular, ${\ensuremath{\mathrm{ref} \left( {x} \right)}}^+ p$ and $p$ are definitionally equal, whereas the terms $\mathrm{comp}^i x [] p$ and $p$ are not definitionally equal in cubical type theory (but they are propositionally equal). See Section \[section:cubical\] for more information.

The proofs in this paper have been formalized in Agda. The formalization is available at `https://github.com/radams78/TYPES2016`.

Predicative Higher-Order Minimal Logic with Extensional Equality
================================================================

We call the following type theory PHOML, or *predicative higher-order minimal logic with extensional equality*.

Syntax
------

Fix three disjoint, infinite sets of variables, which we shall call *term variables*, *proof variables* and *path variables*. We shall use $x$ and $y$ as term variables, $p$ and $q$ as proof variables, $e$ as a path variable, and $z$ for a variable that may come from any of these three sets.

The syntax of PHOML is given by the grammar:

$$\begin{array}{lrcl}
\text{Type} & A,B,C & ::= & \Omega \mid A \rightarrow B \\
\text{Term} & L,M,N, \varphi,\psi,\chi & ::= & x \mid \bot \mid \varphi \supset \psi \mid \lambda x:A.M \mid MN \\
\text{Proof} & \delta, \epsilon & ::= & p \mid \lambda p:\varphi.\delta \mid \delta \epsilon \mid P^+ \mid P^- \\
\text{Path} & P, Q & ::= & e \mid {\ensuremath{\mathrm{ref} \left( {M} \right)}} \mid P \supset^* Q \mid {\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({P} , {Q} \right)}} \mid \\
& & & {\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y. P \mid P_{MN} Q \\
\text{Context} & \Gamma, \Delta, \Theta & ::= & \langle \rangle \mid \Gamma, x : A \mid \Gamma, p : \varphi \mid \Gamma, e : M =_A N \\
\text{Judgement} & \mathbf{J} & ::= & \Gamma {\ensuremath{\vdash \mathrm{valid}}}\mid \Gamma \vdash M : A \mid \Gamma \vdash \delta : \varphi \mid \\
& & & \Gamma \vdash P : M =_A N
\end{array}$$

In the path ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y . P$, the term variables $x$ and $y$ must be distinct. (We also have $x \not\equiv e \not\equiv y$, thanks to our stipulation that term variables and path variables are disjoint.) The term variable $x$ is bound within $M$ in the term $\lambda x:A.M$, and the proof variable $p$ is bound within $\delta$ in $\lambda p:\varphi.\delta$. The three variables $e$, $x$ and $y$ are bound within $P$ in the path ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e:x =_A y.P$. We identify terms, proofs and paths up to $\alpha$-conversion. We write $E[z:=F]$ for the result of substituting $F$ for $z$ within $E$, using $\alpha$-conversion to avoid variable capture.

We shall use the word ’expression’ to mean either a type, term, proof, path, or equation (an equation having the form $M =_A N$). We shall use $E$, $F$, $S$ and $T$ as metavariables that range over expressions.

Note that we use both Roman letters $M$, $N$ and Greek letters $\varphi$, $\psi$, $\chi$ to range over terms. Intuitively, a term is understood as either a proposition or a function, and we shall use Greek letters for terms that are intended to be propositions. Formally, there is no significance to which letter we choose.

Note also that the types of PHOML are just the simple types over $\Omega$; therefore, no variable can occur in a type.

The intuition behind the new expressions is as follows (see also the rules of deduction in Figure \[fig:lambdaoe\]). For any object $M : A$, there is the trivial path ${\ensuremath{\mathrm{ref} \left( {M} \right)}} : M =_A M$. The constructor $\supset^*$ ensures congruence for $\supset$ — if $P : \varphi =_\Omega \varphi'$ and $Q : \psi =_\Omega \psi'$ then $P \supset^* Q : \varphi \supset \psi =_\Omega \varphi' \supset \psi'$. The constructor $\mathsf{univ}$ gives ’univalence’ (propositional extensionality) for our propositions: if $\delta : \varphi \supset \psi$ and $\epsilon : \psi \supset \varphi$, then ${\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}}$ is a path $\varphi =_\Omega \psi$. The constructors $^+$ and $^-$ are the converses, which denote the action of transport along a path: if $P$ is a path of type $\varphi =_\Omega \psi$, then $P^+$ is a proof of $\varphi \supset \psi$, and $P^-$ is a proof of $\psi \supset \varphi$.

The constructor ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}$ gives functional extensionality. Let $F$ and $G$ be functions of type $A \rightarrow B$. If $F x =_B G y$ whenever $x =_A y$, then $F =_{A \rightarrow B} G$. More formally, if $P$ is a path of type $Fx =_B Gy$ that depends on $x : A$, $y : A$ and $e : x =_A y$, then ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y . P$ is a path of type $F =_{A \rightarrow B} G$. The proofs $P^+$ and $P^-$ represent transport along the path $P$.

Finally, if $P$ is a path $M =_{A \rightarrow B} M'$, and $Q$ is a path $N =_A N'$, then $P_{MN} Q$ is a path $MN =_B M'N'$.

### Substitution and Path Substitution

Intuitively, if $N$ and $N'$ are equal then $M[x:=N]$ and $M[x:=N']$ should be equal. To handle this syntactically, we introduce a notion of *path substitution*. If $N$, $M$ and $M'$ are terms, $x$ a term variable, and $P$ a path, then we shall define a path $N \{ x := P : M = M' \}$. The intention is that, if $\Gamma \vdash P : M =_A M'$ and $\Gamma, x : A \vdash N : B$ then $\Gamma \vdash N \{ x := P : M = M' \} : N [ x:= M ] =_B N [ x := M' ]$ (see Lemma \[lm:pathsub\]).

Given terms $M_1$, …, $M_n$ and $N_1$, …, $N_n$; paths $P_1$, …, $P_n$; term variables $x_1$, …, $x_n$; and a term $L$, define the path $$L \{ x_1 := P_1 : M_1 = N_1 , \ldots, x_n := P_n : M_n = N_n \}$$ as follows. $$\begin{aligned}
x_i \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \} & {\mathrel{\smash{\stackrel{\text{def}}{=}}}}P_i \\
y \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \} & {\mathrel{\smash{\stackrel{\text{def}}{=}}}}{\ensuremath{\mathrm{ref} \left( {y} \right)}} \qquad (y \not\equiv x_1, \ldots, x_n) \\
\bot \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \} & {\mathrel{\smash{\stackrel{\text{def}}{=}}}}{\ensuremath{\mathrm{ref} \left( {\bot} \right)}} \\
(LL') \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \} \\
\omit\rlap{\qquad \qquad ${\mathrel{\smash{\stackrel{\text{def}}{=}}}}L \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \}_{L' [\vec{x} := \vec{M}] L' [\vec{x} := \vec{N}]} L' \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \}$} \\
(\lambda y:A.L) \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \} & \\
\omit\rlap{\qquad\qquad ${\mathrel{\smash{\stackrel{\text{def}}{=}}}}{\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : a =_A a' . L \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} , y := e : a = a' \}$} \\
(\varphi \supset \psi) \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \} & {\mathrel{\smash{\stackrel{\text{def}}{=}}}}\varphi \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \} \supset^* \psi \{ \vec{x} := \vec{P} : \vec{M} = \vec{N} \}\end{aligned}$$

We shall often omit the endpoints $\vec{M}$ and $\vec{N}$.

The case $n = 0$ is permitted, and we shall have that, if $\Gamma \vdash M : A$ then $\Gamma \vdash M \{\} : M =_A M$. There are thus two paths from a term $M$ to itself: ${\ensuremath{\mathrm{ref} \left( {M} \right)}}$ and $M \{\}$. There are not always equal; for example, $(\lambda x:A.x) \{\} \equiv {\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y. e$, which (after we define the reduction relation) will not be convertible with ${\ensuremath{\mathrm{ref} \left( {\lambda x:A.x} \right)}}$.

The following lemma shows how substitution and path substitution interact.

\[lm:subpathsub\] Let $\vec{y}$ be a sequences of variables and $x$ a distinct variable. Then

1.  \[lm:subpathsubi\] $ \begin{aligned}[t]
    & M [ x:= N ] \{ \vec{y} := \vec{P} : \vec{L} = \vec{L'} \} \\
    & \equiv M \{ x := N \{ \vec{y} := \vec{P} : \vec{L} = \vec{L'} \} : N [ \vec{y}:= \vec{L} ] = N [ \vec{y} := \vec{L'} ], \vec{y} := \vec{P} : \vec{L} = \vec{L'} \}
    \end{aligned} $

2.  \[lm:subpathsubii\] $ \begin{aligned}[t]
    & M \{ \vec{y} := \vec{P} : \vec{L} = \vec{L'} \} [ x := N ] \\
    & \equiv M \{ \vec{y} := \vec{P} [x := N] : \vec{L} [x := N] = \vec{L'} [x := N], x := {\ensuremath{\mathrm{ref} \left( {N} \right)}} : N = N \}
    \end{aligned} $

An easy induction on $M$ in all cases.

The familiar substitution lemma also holds as usual: $t [\vec{z_1} := \vec{s_1}] [\vec{z_2} := \vec{s_2}] \equiv t [\vec{z_1} := \vec{s_1}[\vec{z_2} := \vec{s_2}], 
\vec{z_2} := \vec{s_2}]$. We cannot form a lemma about the fourth case, simplifying $M \{ \vec{x} := \vec{P} \} \{ \vec{y} := \vec{Q} \}$, because $M \{ \vec{x} := \vec{P} \}$ is a path, and path substitution can only be applied to a term.

We introduce a notation for simultaneous substitution and path substitution of several variables:

A *substitution* is a function that maps term variables to terms, proof variables to proofs, and path variables to paths. We write $E[\sigma]$ for the result of substituting the expression $\sigma(z)$ for $z$ in $E$, for each variable $z$ in the domain of $\sigma$.

A *path substitution* $\tau$ is a function whose domain is a finite set of term variables, and which maps each term variable to a path. Given a path substitution $\tau$ and substitutions $\rho$, $\sigma$ with the same domain $\{ x_1, \ldots, x_n \}$, we write $$M \{ \tau : \rho = \sigma \} \text{ for } M \{ x_1 := \tau(x_1) : \rho(x_1) = \sigma(x_1), \ldots, \tau(x_n) : \rho(x_n) = \sigma(x_n) \} \enspace .$$

### Call-By-Name Reduction

Define the relation of *call-by-name reduction* $\rightarrow$ on the expressions. The inductive definition is given by the rules in Figure \[fig:reduction\]

#### Reduction on Terms {#reduction-on-terms .unnumbered}

$$\infer{(\lambda x:A.M)N \rightarrow M[x:=N]}{} \quad
\infer{MN \rightarrow M'N}{M \rightarrow M'}$$ $$\infer{\varphi \supset \psi \rightarrow \varphi' \supset \psi}{\varphi \rightarrow \varphi'} \quad
\infer{\varphi \supset \psi \rightarrow \varphi \supset \psi'}{\psi \rightarrow \psi'}$$

#### Reduction on Proofs {#reduction-on-proofs .unnumbered}

$$\infer{(\lambda p : \varphi . \delta)\epsilon \rightarrow \delta [ p := \epsilon ]}{} \quad
\infer{{\ensuremath{\mathrm{ref} \left( {\varphi} \right)}}^+ \rightarrow \lambda p : \varphi . p}{} \quad
\infer{{\ensuremath{\mathrm{ref} \left( {\varphi} \right)}}^- \rightarrow \lambda p : \varphi . p}{}$$ $$\infer{\delta \epsilon \rightarrow \delta' \epsilon}{\delta \rightarrow \delta'} \quad
\infer{{\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}}^+ \rightarrow \delta}{} \quad
\infer{{\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}}^- \rightarrow \epsilon}{}$$ $$\infer{P^+ \rightarrow Q^+}{P \rightarrow Q} \quad
\infer{P^- \rightarrow Q^-}{P \rightarrow Q}$$

#### Reduction on Paths {#reduction-on-paths .unnumbered}

$$\infer{({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e:x =_A y.P)_{MN} Q \rightarrow P [x := M, y := N, e := Q]}{}$$ $$\infer{{\ensuremath{\mathrm{ref} \left( {\lambda x:A.M} \right)}}_{N N'} P \rightarrow M \{ x:=P : N = N' \}}{}$$ $$\infer{{\ensuremath{\mathrm{ref} \left( {\varphi} \right)}} \supset^* {\ensuremath{\mathrm{ref} \left( {\psi} \right)}} \rightarrow {\ensuremath{\mathrm{ref} \left( {\varphi \supset \psi} \right)}}}{}$$ $$\infer{{\ensuremath{\mathrm{ref} \left( {\varphi} \right)}} \supset^* {\ensuremath{\mathrm{univ}_{{\psi}, {\chi}} \left({\delta} , {\epsilon} \right)}} \rightarrow 
{\ensuremath{\mathrm{univ}_{{\varphi \supset \psi}, {\varphi \supset \chi}} \left({\lambda p:\varphi \supset \psi. \lambda q : \varphi. \delta (pq)} , {\lambda p : \varphi \supset \chi. \lambda q : \varphi. \epsilon (pq)} \right)}}}{}$$ $$\infer{{\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}} \supset^* {\ensuremath{\mathrm{ref} \left( {\chi} \right)}} \rightarrow
{\ensuremath{\mathrm{univ}_{{\varphi \supset \chi}, {\psi \supset \chi}} \left({\lambda p : \varphi \supset \chi. \lambda q : \psi. p (\epsilon q)} , {\lambda p:\psi \supset \chi. \lambda q : \varphi. p(\delta q)} \right)}}}{}$$ $$\infer{\begin{array}{l}
{\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}} \supset^* {\ensuremath{\mathrm{univ}_{{\varphi'}, {\psi'}} \left({\delta'} , {\epsilon'} \right)}} \\
 \rightarrow
{\ensuremath{\mathrm{univ}_{{\varphi \supset \varphi'}, {\psi \supset \psi'}} \left({\lambda p : \varphi \supset \varphi'. \lambda q : \psi. \delta' (p(\epsilon q))} , {\lambda p : \psi \supset \psi'. \lambda q : \varphi. \epsilon' (p (\delta q))} \right)}}
\end{array}}{}$$ $$\infer{P_{MN} Q \rightarrow P'_{MN} Q}{P \rightarrow P'} \quad
\infer{{\ensuremath{\mathrm{ref} \left( {M} \right)}}_{NN'}P \rightarrow {\ensuremath{\mathrm{ref} \left( {M'} \right)}}_{NN'}P}{M \rightarrow M'}$$ $$\infer{P \supset^* Q \rightarrow P' \supset^* Q}{P \rightarrow P'} \quad
\infer{P \supset^* Q \rightarrow P \supset^* Q'}{Q \rightarrow Q'}$$

\[lm:diamond\] If $E \twoheadrightarrow F$ and $E \twoheadrightarrow G$, then there exists $H$ such that $F \twoheadrightarrow H$ and $G \twoheadrightarrow H$.

The proof is given in Appendix \[section:confluence\].

\[lm:resp-sub\] If $M \rightarrow N$ then $M \{ \tau : \rho = \sigma \} \rightarrow N \{ \tau : \rho = \sigma \}$.

Induction on $M \rightarrow N$. The only difficult case is $\beta$-contraction. We have $$\begin{aligned}
& ((\lambda x:A.M)N)\{ \tau : \rho = \sigma \} \\
\equiv & ({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A x' . M \{ \tau : \rho = \sigma , x := e : x = x' \})_{N [ \rho ] N [ \sigma ]} N \{ \tau : \rho = \sigma \} \\
\rightarrow & M \{ \tau : \rho = \sigma, x := N \{ \tau \} : N [ \rho ] = N [ \sigma ] \} \\
\equiv & M [ x := N ] \{ \tau : \rho = \sigma \} & (\text{Lemma \ref{lm:pathsubsub}})\end{aligned}$$

We write $\rightarrow^?$ for the reflexive closure of $\rightarrow$, we write $\twoheadrightarrow$ for the reflexive transitive closure of $\rightarrow$, and we write $\simeq$ for the reflexive symmetric transitive closure of $\rightarrow$. We say an expression $E$ is in *normal form* iff there is no expression $F$ such that $E \rightarrow F$.

$ $

1.  Reduction on proofs and paths does *not* respect substitution. For example, let $M \equiv \lambda x:\Omega.x$. Then we have $$\begin{aligned}
    {\ensuremath{\mathrm{ref} \left( {\lambda y : \Omega. y'} \right)}}_{\bot \bot} {\ensuremath{\mathrm{ref} \left( {\bot} \right)}} & \rightarrow y' \{ y:= {\ensuremath{\mathrm{ref} \left( {\bot} \right)}} : \bot = \bot \} \equiv {\ensuremath{\mathrm{ref} \left( {y'} \right)}} \nonumber \\
    ({\ensuremath{\mathrm{ref} \left( {\lambda y : \Omega.y'} \right)}}_{\bot \bot} {\ensuremath{\mathrm{ref} \left( {\bot} \right)}}) [y' := M] & \equiv {\ensuremath{\mathrm{ref} \left( {\lambda x : \Omega.M} \right)}}_{\bot \bot} {\ensuremath{\mathrm{ref} \left( {\bot} \right)}}
    \label{eq:exp1} \\
    \label{eq:exp2}
    {\ensuremath{\mathrm{ref} \left( {y'} \right)}}[y':=M] & \equiv {\ensuremath{\mathrm{ref} \left( {M} \right)}} \equiv {\ensuremath{\mathrm{ref} \left( {\lambda x : \Omega.x} \right)}}\end{aligned}$$ Expression (\[eq:exp1\]) does not reduce to (\[eq:exp2\]). Instead, (\[eq:exp1\]) reduces to $$M \{ y := {\ensuremath{\mathrm{ref} \left( {\bot} \right)}} : \bot = \bot \} \equiv {\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_\Omega x'. e \enspace .$$

2.  Reduction on terms does respect substitution: if $M \rightarrow N$ then $M[x:=P] \rightarrow N[x:=P]$, as is easily shown by induction on $M \rightarrow N$.

Rules of Deduction
------------------

The rules of deduction of PHOML are given in Figure \[fig:lambdaoe\].

#### Contexts {#contexts .unnumbered}

$$(\langle \rangle) \quad \vcenter{\infer{\langle \rangle {\ensuremath{\vdash \mathrm{valid}}}}{}} \qquad
(\mathrm{ctx}_T) \quad \vcenter{\infer{\Gamma, x : A {\ensuremath{\vdash \mathrm{valid}}}}{\Gamma {\ensuremath{\vdash \mathrm{valid}}}}} \qquad 
(\mathrm{ctx}_P) \quad \vcenter{\infer{\Gamma, p : \varphi {\ensuremath{\vdash \mathrm{valid}}}}{\Gamma \vdash \varphi : \Omega}}$$ $$(\mathrm{ctx}_E) \quad \vcenter{\infer{\Gamma, e : M =_A N {\ensuremath{\vdash \mathrm{valid}}}}{\Gamma \vdash M : A \quad \Gamma \vdash N : A}}$$ $$(\mathrm{var}_T) \quad \vcenter{\infer[(x : A \in \Gamma)]{\Gamma \vdash x : A}{\Gamma {\ensuremath{\vdash \mathrm{valid}}}}} \qquad
(\mathrm{var}_P) \quad \vcenter{\infer[(p : \varphi \in \Gamma)]{\Gamma \vdash p : \varphi}{\Gamma {\ensuremath{\vdash \mathrm{valid}}}}}$$ $$(\mathrm{var}_E) \quad \vcenter{\infer[(e : M =_A N \in \Gamma)]{\Gamma \vdash e : M =_A N}{\Gamma {\ensuremath{\vdash \mathrm{valid}}}}}$$

#### Terms {#terms .unnumbered}

$$(\bot) \quad \vcenter{\infer{\Gamma \vdash \bot : \Omega}{\Gamma {\ensuremath{\vdash \mathrm{valid}}}}} \qquad
(\supset) \quad \vcenter{\infer{\Gamma \vdash \varphi \supset \psi : \Omega}{\Gamma \vdash \varphi : \Omega \quad \Gamma \vdash \psi : \Omega}}$$ $$(\mathrm{app}_T) \quad \vcenter{\infer{\Gamma \vdash M N : B} {\Gamma \vdash M : A \rightarrow B \quad \Gamma \vdash N : A}} \qquad
(\lambda_T) \quad \vcenter{\infer{\Gamma \vdash \lambda x:A.M : A \rightarrow B}{\Gamma, x : A \vdash M : B}}$$

#### Proofs {#proofs .unnumbered}

$$(\mathrm{app}_P) \quad \vcenter{\infer{\Gamma \vdash \delta \epsilon : \psi} {\Gamma \vdash \delta : \varphi \supset \psi \quad \Gamma \vdash \epsilon : \varphi}} \qquad
(\lambda_P) \quad \vcenter{\infer{\Gamma \vdash \lambda p : \varphi . \delta : \varphi \supset \psi}{\Gamma, p : \varphi \vdash \delta : \psi}}$$ $$(\mathrm{conv}_P) \quad \vcenter{\infer[(\varphi \simeq \psi)]{\Gamma \vdash \delta : \psi}{\Gamma \vdash \delta : \varphi \quad \Gamma \vdash \psi : \Omega}}$$

#### Paths {#paths .unnumbered}

$$(\mathrm{ref}) \quad \vcenter{\infer{\Gamma \vdash {\ensuremath{\mathrm{ref} \left( {M} \right)}} : M =_A M}{\Gamma \vdash M : A}}
\qquad
(\supset^*) \quad \vcenter{\infer{\Gamma \vdash P \supset^* Q : \varphi \supset \psi =_\Omega \varphi' \supset \psi'}{\Gamma \vdash P : \varphi =_\Omega \varphi' \quad \Gamma \vdash Q : \psi =_\Omega \psi'}}$$ $$(\mathrm{univ}) \quad \vcenter{\infer{\Gamma \vdash {\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}} : \varphi =_\Omega \psi}{\Gamma \vdash \delta : \varphi \supset \psi \quad \Gamma \vdash \epsilon : \psi \supset \varphi}}$$ $$(\mathrm{plus}) \quad \vcenter{\infer{\Gamma \vdash P^+ : \varphi \supset \psi}{\Gamma \vdash P : \varphi =_\Omega \psi}}
\qquad
(\mathrm{minus}) \quad \vcenter{\infer{\Gamma \vdash P^- : \psi \supset \varphi}{\Gamma \vdash P : \psi =_\Omega \psi}}$$ $$({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}) \quad \vcenter{\infer{\Gamma \vdash {\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y . P : M =_{A \rightarrow B} N}
  {\begin{array}{c}
     \Gamma, x : A, y : A, e : x =_A y \vdash P : M x =_B N y \\
     \Gamma \vdash M : A \rightarrow B \quad
\Gamma \vdash N : A \rightarrow B
     \end{array}}}$$ $$(\mathrm{app}_E) \quad \vcenter{\infer{\Gamma \vdash P_{NN'}Q : MN =_B M' N'}{\Gamma \vdash P : M =_{A \rightarrow B} M' \quad \Gamma \vdash Q : N =_A N' \quad \Gamma \vdash N : A \quad \Gamma \vdash N' : A}}$$ $$(\mathrm{conv}_E) \quad \vcenter{\infer[(M \simeq M', N \simeq N')]{\Gamma \vdash P : M' =_A N'}{\Gamma \vdash P : M =_A N \quad \Gamma \vdash M' : A \quad \Gamma \vdash N' : A}}$$

### Metatheorems {#section:meta}

In the lemmas that follow, the letter $\mathcal{J}$ stands for any of the expressions that may occur to the right of the turnstile in a judgement, i.e. $\mathrm{valid}$, $M : A$, $\delta : \varphi$, or $P : M =_A N$.

Every derivation of $\Gamma, \Delta \vdash \mathcal{J}$ has a subderivation of $\Gamma {\ensuremath{\vdash \mathrm{valid}}}$.

Induction on derivations.

If $\Gamma \vdash \mathcal{J}$, $\Gamma \subseteq \Delta$ and $\Delta {\ensuremath{\vdash \mathrm{valid}}}$ then $\Delta \vdash \mathcal{J}$.

Induction on derivations.

$ $

1.  If $\Gamma \vdash \delta : \varphi$ then $\Gamma \vdash \varphi : \Omega$.

2.  If $\Gamma \vdash P : M =_A N$ then $\Gamma \vdash M : A$ and $\Gamma \vdash N : A$.

Induction on derivations. The cases where $\delta$ or $P$ is a variable use Context Validity.

$ $

1.  If $\Gamma \vdash x : A$ then $x : A \in \Gamma$.

2.  If $\Gamma \vdash \bot : A$ then $A \equiv \Omega$.

3.  If $\Gamma \vdash \varphi \supset \psi : A$ then $\Gamma \vdash \varphi : \Omega$, $\Gamma \vdash \psi : \Omega$ and $A \equiv \Omega$.

4.  If $\Gamma \vdash \lambda x:A.M : B$ then there exists $C$ such that $\Gamma, x : A \vdash M : C$ and $B \equiv A \rightarrow C$.

5.  If $\Gamma \vdash MN : A$ then there exists $B$ such that $\Gamma \vdash M : B \rightarrow A$ and $\Gamma \vdash N : B$.

6.  If $\Gamma \vdash p : \varphi$, then there exists $\psi$ such that $p : \psi \in \Gamma$ and $\varphi \simeq \psi$.

7.  If $\Gamma \vdash \lambda p:\varphi.\delta : \psi$, then there exists $\chi$ such that $\Gamma, p : \varphi \vdash \delta : \chi$ and $\psi \simeq (\varphi \supset \chi)$.

8.  If $\Gamma \vdash \delta \epsilon : \varphi$ then there exists $\psi$ such that $\Gamma \vdash \delta : \psi \supset \varphi$ and $\Gamma \vdash \epsilon : \psi$.

9.  If $\Gamma \vdash e : M =_A N$, then there exist $M'$, $N'$ such that $e : M' =_A N' \in \Gamma$ and $M \simeq M'$, $N \simeq N'$.

10. If $\Gamma \vdash {\ensuremath{\mathrm{ref} \left( {M} \right)}} : N =_A P$, then we have $\Gamma \vdash M : A$ and $M \simeq N \simeq P$.

11. If $\Gamma \vdash P \supset^* Q : \varphi =_A \psi$, then there exist $\varphi_1$, $\varphi_2$, $\psi_1$, $\psi_2$ such that $\Gamma \vdash P : \varphi_1 =_\Omega \psi_1$, $\Gamma \vdash Q : \varphi_2 =_\Omega \psi_2$, $\varphi \simeq (\varphi_1 \supset \psi_1)$, $\psi \simeq (\varphi_2 \supset \psi_2)$, and $A \equiv \Omega$.

12. If $\Gamma \vdash {\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}} : \chi =_A \theta$, then we have $\Gamma \vdash \delta : \varphi \supset \psi$, $\Gamma \vdash \epsilon : \psi \supset \varphi$, $\chi \simeq \varphi$, $\theta \simeq \psi$ and $A \equiv \Omega$.

13. If $\Gamma \vdash {\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y. P : M =_B N$ then there exists $C$ such that $\Gamma, x : A, y : A, e : x =_A y \vdash P : M x =_C N y$ and $B \equiv A \rightarrow C$.

14. If $\Gamma \vdash P_{M M'} Q : N =_A N'$, then there exist $B$, $F$ and $G$ such that $\Gamma \vdash P : F =_{B \rightarrow A} G$, $\Gamma \vdash Q : M =_B M'$, $N \simeq F M$ and $N' \simeq G M'$.

15. If $\Gamma \vdash P^+ : \varphi$, then there exist $\psi$, $\chi$ such that $\Gamma \vdash P : \psi =_\Omega \chi$ and $\varphi \simeq (\psi \supset \chi)$.

16. If $\Gamma \vdash P^- : \varphi$, there exist $\psi$, $\chi$ such that $\Gamma \vdash P : \psi =_\Omega \chi$ and $\varphi \simeq (\chi \supset \psi)$.

Induction on derivations.

### Substitutions

Let $\Gamma$ and $\Delta$ be contexts. A *substitution from $\Delta$ to $\Gamma$*[^1], $\sigma : \Delta \Rightarrow \Gamma$, is a substitution whose domain is ${\ensuremath{\operatorname{dom}}}\Gamma$ such that:

-   for every term variable $x : A \in \Gamma$, we have $\Delta \vdash \sigma(x) : A$;

-   for every proof variable $p : \varphi \in \Gamma$, we have $\Delta \vdash \sigma(p) : \varphi [ \sigma ]$;

-   for every path variable $e : M =_A N \in \Gamma$, we have $\Delta \vdash \sigma(e) : M [ \sigma ] =_A N [ \sigma ]$.

If $\Gamma \vdash \mathcal{J}$, $\sigma : \Delta \Rightarrow \Gamma$ and $\Delta {\ensuremath{\vdash \mathrm{valid}}}$, then $\Delta \vdash \mathcal{J} [\sigma]$.

Induction on derivations.

If $\rho, \sigma : \Delta \Rightarrow \Gamma$ and $\tau$ is a path substitution whose domain is the term variables in ${\ensuremath{\operatorname{dom}}}\Gamma$, then we write $\tau : \sigma = \rho : \Delta \Rightarrow \Gamma$ iff, for each variable $x : A \in \Gamma$, we have $\Delta \vdash \tau(x) : \sigma(x) =_A \rho(x)$.

\[lm:pathsub\] If $\tau : \sigma = \rho : \Delta \Rightarrow \Gamma$ and $\Gamma \vdash M : A$ and $\Delta {\ensuremath{\vdash \mathrm{valid}}}$, then $\Delta \vdash M \{ \tau : \sigma = \rho \} : M [ \sigma ] =_A M [ \rho ]$.

Induction on derivations.

If $\Gamma \vdash s : T$ and $s \twoheadrightarrow t$ then $\Gamma \vdash t : T$.

It is sufficient to prove the case $s \rightarrow t$. The proof is by a case analysis on $s \rightarrow t$, using the Generation, Well-Typed Substitution and Path Substitution Lemmas.

### Canonicity

$ $

-   The *canonical propositions*, are given by the grammar $$\theta ::= \bot \mid \theta \supset \theta$$

-   A *canonical proof* is one of the form $\lambda p : \varphi . \delta$.

-   A *canonical path* is one of the form ${\ensuremath{\mathrm{ref} \left( {M} \right)}}$, ${\ensuremath{\mathrm{univ}_{{\phi}, {\psi}} \left({\delta} , {\epsilon} \right)}}$ or ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y.P$.

\[lm:compat-beta\] Suppose $\varphi$ reduces to a canonical proposition $\theta$, and $\varphi \simeq \psi$. Then $\psi$ reduces to $\theta$.

This follows from the fact that $\rightarrow$ satisfies the diamond property, and every canonical proposition $\theta$ is a normal form.

### Neutral Expressions

$ $ The *neutral* terms, paths and proofs are given by the grammar $$\begin{array}{lrcl}
\text{Neutral term} & M_n & ::= & x \mid M_n N \\
\text{Neutral proof} & \delta_n & ::= & p \mid P_n^+ \mid P_n^- \mid \delta_n \epsilon \\
\text{Neutral path} & P_n & ::= & e \mid P_n \supset^* Q \mid Q \supset^* P_n \mid (P_n)_{MN} Q
\end{array}$$

Examples
========

We present two examples illustrating the way that proofs and paths behave in PHOML. In each case, we compare the example with the same construction performed in cubical type theory.

Functions Respect Logical Equivalence {#section:exampletwo}
-------------------------------------

As discussed in the introduction, every function of type $\Omega \rightarrow \Omega$ that can be constructed in PHOML must respect logical equivalence. This fact can actually be proved in PHOML, in the following sense: there exists a proof $\delta$ of $$f : \Omega \rightarrow \Omega, x : \Omega, y : \Omega, p : x \supset y, q : y \supset x \vdash \delta : f x \supset f y$$ and a proof of $f y \supset f x$ in the same context. Together, these can be read as a proof of ’if $f : \Omega \rightarrow \Omega$ and $x$ and $y$ are logically equivalent, then $fx$ and $fy$ are logically equivalent’.

Specifically, take $$\delta {\mathrel{\smash{\stackrel{\text{def}}{=}}}}({\ensuremath{\mathrm{ref} \left( {f} \right)}}_{xy} {\ensuremath{\mathrm{univ}_{{x}, {y}} \left({p} , {q} \right)}})^+ \enspace .$$

Note that this is not possible in Martin-Löf Type Theory.

In cubical type theory, we can construct a term $\delta$ such that $$f : {\mathsf{Prop}}\rightarrow {\mathsf{Prop}}, x : {\mathsf{Prop}}, y : {\mathsf{Prop}}, p : x.1 \rightarrow y.1, q : y.1 \rightarrow x.1 \vdash \delta : (f x).1 \rightarrow (f y).1$$ In fact, we can go further and prove that equality of propositions is equal to logical equivalence. That is, we can prove $${\ensuremath{\mathsf{Path} \, {U} \, {({\ensuremath{\mathsf{Path} \, {{\mathsf{Prop}}} \, {x} \, {y}}})} \, {((x.1 \rightarrow y.1) \times (y.1 \rightarrow x.1))}}} \enspace .$$

Computation with Paths
----------------------

Let $\top {\mathrel{\smash{\stackrel{\text{def}}{=}}}}\bot \supset \bot$. Using propositional extensionality, we can construct a path of type $\top = \top \supset \top$, and hence a proof of $\top \supset (\top \supset \top)$. But which of the canonical proofs of $\top \supset (\top \supset \top)$ have we constructed?

We define $$\top := \bot \supset \bot, \quad \iota := \lambda p:\bot.p, \quad I := \lambda x:\Omega.x, \quad F := \lambda x:\Omega.\top \supset x, \quad H := \lambda h.h \top \enspace .$$

Let $\Gamma$ be the context $$\Gamma {\mathrel{\smash{\stackrel{\text{def}}{=}}}}x : \Omega, y : \Omega, e : x =_\Omega y \enspace .$$

Then we have $$\begin{aligned}
\Gamma & \vdash \lambda p:\top \supset x. e^+ (p \iota) & : & (\top \supset x) \supset y \\
\Gamma & \vdash \lambda m : y. \lambda n : \top. e^- m & : & y \supset (\top \supset x) \\
\Gamma & \vdash {\ensuremath{\mathrm{univ}_{{*}, {\lambda p:\top \supset x. e^- m}} \left({\lambda m:y. \lambda n:\top. e^- m} , {&} \right)}} : & (\top \supset x) =_\Omega y\end{aligned}$$

Let $P \equiv \univ*{\lambda p:\top \supset x. e^+ (p \iota)}{\lambda m:y. \lambda n:\top. e^- m}$. Then

$$\begin{aligned}
\therefore & \vdash {\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e:x =_\Omega y. P & : & F =_{\Omega \rightarrow \Omega} I \label{eq:llleP} \\
\therefore & \vdash ({\ensuremath{\mathrm{ref} \left( {H} \right)}})_{FI}({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e:x =_\Omega y. P) & : & (\top \supset \top) =_\Omega \top \label{eq:llleP2} \\
\therefore & \vdash (({\ensuremath{\mathrm{ref} \left( {H} \right)}})_{FI}({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e:x =_\Omega y.P))^- & : & \top \supset (\top \supset \top) \label{eq:llleP3}\end{aligned}$$

And now we compute:

$$\begin{aligned}
& (({\ensuremath{\mathrm{ref} \left( {H} \right)}})_{FI}({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e:x =_\Omega y.P))^- \\
\twoheadrightarrow & ((h \top) \{ h := {\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_\Omega y.P : F = I \})^- \\
\equiv & (({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_\Omega y.P)_{\top \top} ({\ensuremath{\mathrm{ref} \left( {\top} \right)}}))^- \\
\rightarrow & (P [ x := \top, y := \top, e := {\ensuremath{\mathrm{ref} \left( {\top} \right)}} ])^- \\
\equiv & {\ensuremath{\mathrm{univ}_{{*}, {\lambda p : \top \supset \top. {\ensuremath{\mathrm{ref} \left( {\top} \right)}}^+ (p \iota)}} \left({\lambda m:\top. \lambda n:\top. {\ensuremath{\mathrm{ref} \left( {\top} \right)}}^- m} , {^} \right)}}- \\
\rightarrow & \lambda m : \top. \lambda n : \top. {\ensuremath{\mathrm{ref} \left( {\top} \right)}}^- m\end{aligned}$$

Therefore, given proofs $\delta, \epsilon : \top$, we have $$(({\ensuremath{\mathrm{ref} \left( {H} \right)}})_{FI}({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e:x =_\Omega y.P))^- \delta \epsilon \twoheadrightarrow \delta \enspace .$$

Thus, the construction gives a proof of $\top \supset (\top \supset \top)$ which, given two proofs of $\top$, selects the first. We could have anticipated this: consider the context $\Delta {\mathrel{\smash{\stackrel{\text{def}}{=}}}}X : \Omega, Y : \Omega, p : X$. By replacing in our example some occurrences of $\top$ with $X$ and others with $Y$, and replacing $\iota$ with $p$, we can obtain a path $$Y =_\Omega X \supset Y$$ and hence a proof of $Y \supset (X \supset Y)$. By parametricity, any proof that we can construct in the context $\Delta$ of this proposition must return the left input.

### Comparison with Cubical Type Theory {#section:cubical}

In cubical type theory, we say that a type $A$ is a *proposition* iff any two terms of type $A$ are propositionally equal; that is, there exists a path between any two terms of type $A$. Let $${\mathsf{isProp} \left( {A} \right)} {\mathrel{\smash{\stackrel{\text{def}}{=}}}}\Pi x,y:A. {\ensuremath{\mathsf{Path} \, {A} \, {x} \, {y}}}$$ and let ${\mathsf{Prop}}$ be the type of all types in $U$ that are propositions: $${\mathsf{Prop}}{\mathrel{\smash{\stackrel{\text{def}}{=}}}}\Sigma X : U. {\mathsf{isProp} \left( {X} \right)} \enspace .$$ Let $\bot$ be any type in the universe $U$ that is a proposition; that is, there exists a term of type ${\mathsf{isProp} \left( {\bot} \right)}$. ($\bot$ may be the empty type, but we do not require this in what follows.)

Define $$\top := \bot \rightarrow \bot$$ Then there exists a term $\top_{\mathsf{Prop}}$ of type ${\mathsf{isProp} \left( {\top} \right)}$ (we omit the details). Define $$I := \lambda X:{\mathsf{Prop}}.X.1, \quad F := \lambda X : {\mathsf{Prop}}.\top \rightarrow X.1, \quad H := \lambda h.h (\top , \top_{\mathsf{Prop}})$$ Then we have $$\vdash \top : U \quad
\vdash I  : {\mathsf{Prop}}\rightarrow U \quad
\vdash F  : {\mathsf{Prop}}\rightarrow U \quad
\vdash H  : ({\mathsf{Prop}}\rightarrow U) \rightarrow U$$

From the fact that univalence is provable in cubical type theory [@cchm:cubical], we can construct a term $Q$ such that $$\vdash Q : {\ensuremath{\mathsf{Path} \, {({\mathsf{Prop}}\rightarrow U)} \, {I} \, {F}}} \enspace .$$ Hence we have $$\vdash \langle i \rangle H (Q i) : {\ensuremath{\mathsf{Path} \, {U} \, {HI} \, {HF}}}$$ which is definitionally equal to $$\vdash \langle i \rangle H (Q i) : {\ensuremath{\mathsf{Path} \, {U} \, {\top \rightarrow \top} \, {\top}}}$$ From this, we can apply transport to create a term $Q' : \top \rightarrow \top \rightarrow \top$. Applying this to any terms $\delta, \epsilon : \top$ gives a term that is definitionally equal to $$Q' \delta \epsilon = {\mathsf{mapid}_{\top} \, {{\mathsf{mapid}_{\top} \, {\delta}}}}$$ where ${\mathsf{mapid}_{} \, {}}$ represents transport across the trivial path: $${\mathsf{mapid}_{A} \, {t}} {\mathrel{\smash{\stackrel{\text{def}}{=}}}}{\mathsf{comp}}^i \, A \, [] \, t \qquad (i \text{ does not occur in } A) \enspace .$$ (For the details of the calculation, see Appendix \[appendix:cubical\].)

In the version of cubical type theory given in [@bch:cubical], we have ${\mathsf{mapid}_{X} \, {x}}$ is definitionally equal to $x$, and therefore $Q' \delta \epsilon = \delta$, just as in PHOML. This is no longer true in the version of cubical type theory given in [@cchm:cubical].

Computable Expressions {#section:computable}
======================

We now proceed with the proof of canonicity for PHOML. Our proof follows the lines of the Girard-Tait reducibility method [@tait1967]: we define what it means to be a *computable* term (proof, path) of a given type (proposition, equation), and prove: (1) every typable expression is computable (2) every computable expression reduces to either a neutral or a canonical expression. In particular, every closed computable expression reduces to a canonical expression.

In this section, we use $E$, $F$, $S$ and $T$ as metavariables that range over expressions. In each case, either $E$ and $F$ are terms and $S$ and $T$ are types; or $E$ and $F$ are proofs and $S$ and $T$ are propositions; or $E$ and $F$ are paths and $S$ and $T$ are equations.

We define the relation $\models E : T$, read ‘$E$ is a computable expression of type $T$’, as follows.

-   $\models \delta : \bot$ iff $\delta$ reduces to a neutral proof.

-   For $\theta$ and $\theta'$ canonical propositions, $\models \delta : \theta \supset \theta'$ iff, for all $\epsilon$ such that $\models \epsilon : \theta$, we have $\models \delta \epsilon : \theta'$.

-   If $\varphi$ reduces to the canonical proposition $\theta$, then $\models \delta : \varphi$ iff $\models \delta : \theta$.

-   $\models P : \varphi =_\Omega \psi$ iff $\models P^+ : \varphi \supset \psi$ and $\models P^- : \psi \supset \varphi$.

-   $\models P : M =_{A \rightarrow B} M'$ iff, for all $Q$, $N$, $N'$ such that $\models N : A$ and $\models N' : A$ and $\models Q : N =_A N'$, then we have $\models P_{NN'}Q : MN =_B M'N'$.

-   $\models M : A$ iff $\models M \{\} : M =_A M$.

Note that the last three clauses define $\models M : A$ and $\models P : M =_A N$ simultaneously by recursion on $A$.

Let $\sigma$ be a substitution with domain ${\ensuremath{\operatorname{dom}}}\Gamma$. We write $\models \sigma : \Gamma$ and say that $\sigma$ is a *computable* substitution on $\Gamma$ iff, for every entry $z : T$ in $\Gamma$, we have $\models \sigma(z) : T [ \sigma ]$.

We write $\models \tau : \rho = \sigma : \Gamma $, and say $\tau$ is a *computable* path substitution between $\rho$ and $\sigma$, iff, for every term variable entry $x : A$ in $\Gamma$, we have $\models \tau(x) : \rho(x) =_A \sigma(x)$.

\[lm:conv-compute\] If $\models E : S$ and $S \simeq T$ then $\models E : T$.

This follows easily from the definition and Lemma \[lm:compat-beta\].

\[lm:expansion\] If $\models F : T$ and $E \rightarrow F$ then $\models E : T$.

An easy induction, using the fact that call-by-name reduction respects path substitution (Lemma \[lm:resp-sub\]).

\[lm:reduction\] If $\models E : T$ and $E \rightarrow F$ then $\models F : T$.

An easy induction, using the fact that call-by-name reduction is confluent (Lemma \[lm:diamond\]).

We introduce a closed term $c_A$ for every type $A$ such that $\models c_A : A$. $$\begin{aligned}
c_\Omega & {\mathrel{\smash{\stackrel{\text{def}}{=}}}}\bot \\
c_{A \rightarrow B} & {\mathrel{\smash{\stackrel{\text{def}}{=}}}}\lambda x:A.c_B\end{aligned}$$

$\models c_A : A$

An easy induction on $A$.

\[lm:neutral-canon\] $ $

1.  If $\models \delta : \phi$ then $\delta$ reduces to either a neutral proof or canonical proof.

2.  If $\models P : M =_A N$ then $P$ reduces either to a neutral path or canonical path.

3.  If $\models M : A$ then $M$ reduces either to a canonical proposition or a $\lambda$-term.

We prove by induction on the canonical proposition $\theta$ that, if $\models \delta : \theta$, then $\delta$ reduces to a neutral proof or a canonical proof of $\theta$.

If $\models \delta : \bot$ then $\delta$ reduces to a neutral proof. Now, suppose $\models \delta : \theta \supset \theta'$. Then $\models \delta p :
\theta'$, so $\delta p$ reduces to either a neutral proof or canonical proof by the induction hypothesis. This reduction must proceed either by reducing $\delta$ to a neutral proof, or reducing $\delta$ to a $\lambda$-proof then $\beta$-reducing.

We then prove by induction on the type $A$ that, if $\models P : M =_A N$, then $P$ reduces to a neutral path or a canonical path. The two cases are straightforward.

Now, suppose $\models M : A$, i.e. $\models M \{\} : M =_A M$. Let $A \equiv A_1 \rightarrow \cdots \rightarrow A_n \rightarrow \Omega$. Then $$\models M \{\}_{c_{A_1} c_{A_1}} c_{A_1} \{\}_{c_{A_2} c_{A_2}} \cdots c_{A_n} \{\}
: M c_{A_1} \cdots c_{A_n} =_\Omega M c_{A_1} \cdots c_{A_n} \enspace .$$ Therefore, $M c_{A_1} \cdots c_{A_n}$ reduces to a canonical proposition. The reduction must consist either in reducing $M$ to a canonical proposition (if $n = 0$), or reducing $M$ to a $\lambda$-expression then performing a $\beta$-reduction.

\[lm:pre-ref-compute\] If $\models M : A \rightarrow B$ then $M$ reduces to a $\lambda$-expression.

Similar to the last paragraph of the previous proof.

\[lm:ref-compute-Omega\] For any term $\varphi$ that reduces to a canonical proposition, we have $\models {\ensuremath{\mathrm{ref} \left( {\varphi} \right)}} : \varphi =_\Omega \varphi$.

In fact we prove that, for any terms $M$ and $\varphi$ such that $\varphi$ reduces to a canonical proposition, we have $\models {\ensuremath{\mathrm{ref} \left( {M} \right)}} : \varphi =_\Omega \varphi$.

It is sufficient to prove the case where $\varphi$ is a canonical proposition. We must show that $\models {\ensuremath{\mathrm{ref} \left( {M} \right)}}^+ : \varphi \supset \varphi$ and $\models {\ensuremath{\mathrm{ref} \left( {M} \right)}}^- : \varphi \supset \varphi$. So let $\models \delta : \varphi$. Then $\models {\ensuremath{\mathrm{ref} \left( {M} \right)}}^+ \delta : \varphi$ and $\models {\ensuremath{\mathrm{ref} \left( {M} \right)}}^- \delta : \varphi$ by Expansion (Lemma \[lm:expansion\]), as required.

\[lm:models-canon\] $\models \varphi : \Omega$ if and only if $\varphi$ reduces to a canonical proposition.

If $\models \varphi : \Omega$ then $\models \varphi \{\}^+ : \varphi \supset \varphi$. Therefore $\varphi \supset \varphi$ reduces to a canonical proposition, and so $\varphi$ must reduce to a canonical proposition.

Conversely, suppose $\varphi$ reduces to a canonical proposition $\theta$. We have $\varphi \{\} \twoheadrightarrow \theta \{\}$, and $\theta \{\} \twoheadrightarrow {\ensuremath{\mathrm{ref} \left( {\theta} \right)}}$ for every canonical proposition $\theta$. Therefore, $\models \varphi \{\} : \varphi =_\Omega \varphi$ by Expansion (Lemma \[lm:expansion\]). Hence $\models \varphi : \Omega$.

\[lm:neutral-proof\] If $\delta$ is a neutral proof and $\varphi$ reduces to a canonical proposition, then $\models \delta : \varphi$.

It is sufficient to prove the case where $\varphi$ is a canonical proposition. The proof is by induction on $\varphi$.

If $\varphi \equiv \bot$, then $\models \delta : \bot$ immediately from the definition.

If $\varphi \equiv \psi \supset \chi$, then let $\models \epsilon : \psi$. We have that $\delta \epsilon$ is neutral, hence $\models \delta \epsilon : \chi$ by the induction hypothesis.

\[lm:neutral-path\] Let $\models M : A$ and $\models N : A$. If $P$ is a neutral path, then $\models P : M =_A N$.

The proof is by induction on $A$.

For $A \equiv \Omega$: we have that $P^+$ and $P^-$ are neutral proofs, and $M$ and $N$ reduce to canonical propositions (by Lemma \[lm:models-canon\]), so $\models P^+ : M \supset N$ and $\models P^- : N \supset M$ by Lemma \[lm:neutral-proof\], as required.

For $A \equiv B \rightarrow C$: let $\models L : B$, $\models L' : B$ and $\models Q : L =_B L'$. Then we have $\models ML : C$, $\models NL' : C$ and $P_{LL'} Q$ is a neutral path, hence $\models P_{L L'} Q : ML =_C NL'$ by the induction hypothesis, as required.

\[lm:ref-compute\] If $\models M : A$ then $\models {\ensuremath{\mathrm{ref} \left( {M} \right)}} : M =_A M$.

If $A \equiv \Omega$, this is just Lemma \[lm:ref-compute-Omega\].

So suppose $A \equiv B \rightarrow C$. Using Lemma \[lm:pre-ref-compute\], Reduction (Lemma \[lm:reduction\]) and Expansion (Lemma \[lm:expansion\]), we may assume that $M$ is a $\lambda$-term. Let $M \equiv \lambda y:D.N$.

Let $\models L : B$ and $\models L' : B$ and $\models P : L =_B L'$. We must show that $$\models {\ensuremath{\mathrm{ref} \left( {\lambda y:D.N} \right)}}_{L L'} P : (\lambda y:D.N)L =_C (\lambda y:D.N)L' \enspace .$$ By Expansion and Conversion, it is sufficient to prove $$\models N \{ y := P : L = L' \} : N [ y:= L ] =_C N [y := L'] \enspace .$$ We have that $\models (\lambda y:D.N)\{\} : \lambda y:D.N =_{B \rightarrow C} \lambda y:D.N$, and so $$\models ({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : y =_D y' . N \{ y := e : y = y' \})_{L L'} P : (\lambda y:D.N)L =_C (\lambda y:D.N)L' \enspace ,$$ and the result follows by Reduction and Conversion.

\[lm:compute-supset\*\] If $\models P : \varphi =_\Omega \varphi'$ and $\models Q : \psi =_\Omega \psi'$ then $\models P \supset^* Q : \varphi \supset \psi =_\Omega \varphi' \supset \psi'$.

By Reduction (Lemma \[lm:reduction\]) and Expansion (Lemma \[lm:expansion\]), we may assume that $P$ and $Q$ are either neutral, or have the form ${\ensuremath{\mathrm{ref} \left( {-} \right)}}$ or ${\ensuremath{\mathrm{univ}_{{-}, {-}} \left({-} , {-} \right)}}$ or ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y.-$.

We cannot have that $P$ reduces to a ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}$-path; for let $\varphi'$ reduce to the canonical proposition $\theta_1 \supset \cdots \supset \theta_n \supset \bot$. Then we have $$\models P^+ p q_1 \cdots q_n : \bot$$ and so $P^+ p q_1 \cdots q_n$ must reduce to a neutral path. Similarly, $Q$ cannot reduce to a ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}$-path.

If either $P$ or $Q$ is neutral then $P \supset^* Q$ is neutral, and the result follows from Lemma \[lm:neutral-path\].

Otherwise, let $\models \delta : \varphi \supset \psi$ and $\epsilon \models \varphi'$. We must show that $\models (P \supset^* Q)^+ \delta \epsilon : \psi'$.

If $P \equiv {\ensuremath{\mathrm{ref} \left( {M} \right)}}$ and $Q \equiv {\ensuremath{\mathrm{ref} \left( {N} \right)}}$, then we have $$(P \supset^* Q)^+ \delta \epsilon \rightarrow {\ensuremath{\mathrm{ref} \left( {M \supset N} \right)}}^+ \delta \epsilon \rightarrow \delta \epsilon \enspace .$$ Now, $\models P^- \epsilon : \varphi$, hence $\models \epsilon : \varphi$ by Reduction, and so $\models \delta \epsilon : \psi$. Therefore, $\models Q^+ (\delta \epsilon) : \psi'$, and hence by Reduction $\models \delta \epsilon : \psi'$ as required.

If $P \equiv {\ensuremath{\mathrm{ref} \left( {M} \right)}}$ and $Q \equiv {\ensuremath{\mathrm{univ}_{{N}, {N'}} \left({\chi} , {\chi'} \right)}}$, then we have $$\begin{aligned}
(P \supset^* Q)^+ \delta \epsilon & \rightarrow {\ensuremath{\mathrm{univ}_{{M \supset N}, {M \supset N'}} \left({\lambda pq.\chi(pq)} , {\lambda pq.\chi'(pq)} \right)}}^+ \delta \epsilon \\
& \rightarrow (\lambda pq.\chi(pq)) \delta \epsilon \\
& \twoheadrightarrow \chi (\delta \epsilon)\end{aligned}$$ We have $\models P^- \epsilon : \varphi$, hence $\models \epsilon : \varphi$ by Reduction, and so $\models \delta \epsilon : \psi$. Therefore, $\models Q^+ (\delta \epsilon) : \psi'$, and hence by Reduction $\models \chi (\delta \epsilon) : \psi'$ as required.

The other two cases are similar.

\[lm:univ-compute\] If $\models \delta : \phi \supset \psi$ and $\models \epsilon : \psi \supset \phi$ then $\models {\ensuremath{\mathrm{univ}_{{\phi}, {\psi}} \left({\delta} , {\epsilon} \right)}} : \phi =_\Omega \psi$.

We must show that $\models {\ensuremath{\mathrm{univ}_{{\phi}, {\psi}} \left({\delta} , {\epsilon} \right)}}^+ : \phi \supset \psi$ and $\models {\ensuremath{\mathrm{univ}_{{\phi}, {\psi}} \left({\delta} , {\epsilon} \right)}}^- : \psi \supset \phi$. These follow from the hypotheses, using Expansion (Lemma \[lm:expansion\]).

Proof of Canonicity
===================

$ $

1.  If $\Gamma \vdash \mathcal{J}$ and $\models \sigma : \Gamma$, then $\models \mathcal{J} [ \sigma ]$.

2.  If $\Gamma \vdash M : A$ and $\models \tau : \rho = \sigma : \Gamma$, then $\models M \{ \tau : \rho = \sigma \} : M [ \rho ] =_A M [ \sigma ]$.

The proof is by induction on derivations. Most cases are straightforward, using the lemmas from Section \[section:computable\]. We deal with one case here, the rule ($\lambda_T$).

$$\infer{\Gamma \vdash \lambda x:A.M : A \rightarrow B}{\Gamma, x : A \vdash M : B}$$

1.  We must show that $$\models \lambda x:A.M[\sigma] : A \rightarrow B \enspace .$$ So let $\models Q : N =_A N'$. Define the path substitution $\tau$ by $$\tau(x) \equiv Q, \qquad \tau(y) \equiv {\ensuremath{\mathrm{ref} \left( {\sigma(y)} \right)}} \ (y \in {\ensuremath{\operatorname{dom}}}\Gamma)$$ Then we have $\models \tau : (\sigma, x:=N) = (\sigma, x:=N') : \Gamma , x : A$, and so the induction hypothesis gives $$\models M \{ \tau \} : M[\sigma, x:=N] =_B M [ \sigma, x:= N' ]$$ We observe that $M \{ \tau \} \equiv M [ \sigma ] \{ x:=Q:N=N' \}$ (Lemma \[lm:pathsubsub\]), and so by Expansion (Lemma \[lm:expansion\]) and Conversion (Lemma \[lm:conv-compute\]) we have $$\models (\lambda x:A.M[\sigma])\{\}_{N N'} Q : (\lambda x:A.M[\sigma])N =_B (\lambda x:A.M[\sigma])N'$$ as required.

2.  We must show that $$\models {\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y. M \{ \tau : \rho = \sigma, x := e : x = y \} : \lambda x:A.M [ \rho ] =_{A \rightarrow B} \lambda x:A.M [ \sigma ] \enspace .$$ So let $ \models P : N =_A N'$. The induction hypothesis gives $$\models M \{ \tau : \rho = \sigma, x := P : N = N' \} : M [\rho, x := N] =_B M [\sigma, x := N'] \enspace ,$$ and so we have $$\begin{aligned}
    \models & ({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y. M \{ \tau : \rho = \sigma, x := e : x = y \})_{N N'} P \\
    : & (\lambda x:A.M [ \rho ])N =_B (\lambda x:A.M [ \sigma ])N'\end{aligned}$$ by Expansion and Conversion, as required.

Let $\Gamma$ be a context in which no term variables occur.

1.  If $\Gamma \vdash \delta : \phi$ then $\delta$ reduces to a neutral proof or canonical proof.

2.  If $\Gamma \vdash P : M =_A N$ then $P$ reduces to a neutral path or canonical path.

Let ${\mathsf{id}}$ be the substitution $\Gamma \Rightarrow \Gamma$ such that ${\mathsf{id}}(x) {\mathrel{\smash{\stackrel{\text{def}}{=}}}}x$. If $\Gamma {\ensuremath{\vdash \mathrm{valid}}}$ then $\models {\mathsf{id}}: \Gamma$ using Lemmas \[lm:neutral-proof\] and \[lm:neutral-path\].

Therefore, if $\Gamma \vdash E : T$ then $\models E [ {\mathsf{id}}] : T [ {\mathsf{id}}]$, that is, $\models E : T$. Hence $E$ reduces to a neutral expression or canonical expression.

Let $\Gamma$ be a context with no term variables.

1.  If $\Gamma \vdash \delta : \bot$ then $\delta$ reduces to a neutral proof.

2.  If $\Gamma \vdash \delta : \phi \supset \psi$ then $\delta$ reduces either to a neutral proof, or a proof $\lambda p : \phi' . \epsilon$ where $\phi \simeq \phi'$ and $\Gamma, p : \phi \vdash \epsilon : \psi$.

3.  If $\Gamma \vdash P : \phi =_\Omega \psi$ then $P$ reduces either to a neutral path; or to ${\ensuremath{\mathrm{ref} \left( {\chi} \right)}}$ where $\phi \simeq \psi \simeq \chi$; or to ${\ensuremath{\mathrm{univ}_{{\phi'}, {\psi'}} \left({\delta} , {\epsilon} \right)}}$ where $\phi \simeq \phi'$, $\psi \simeq \psi'$, $\Gamma \vdash \delta : \phi \supset \psi$ and $\Gamma \vdash \epsilon : \psi \supset \phi$.

4.  If $\Gamma \vdash P : M =_{A \rightarrow B} M'$ then $P$ reduces either to a neutral path; or to ${\ensuremath{\mathrm{ref} \left( {N} \right)}}$ where $M \simeq M' \simeq N$; or to ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_A y. Q$ where $\Gamma, x : A, y : A, e : x =_A y \vdash Q : Mx =_B M'y$.

A closed expression cannot be neutral, so from the previous corollary every typed closed expression must reduce to a canonical expression. We now apply case analysis to the possible forms of canonical expression, and use the Generation Lemma.

There is no $\delta$ such that $\vdash \delta : \bot$.

We have not proved canonicity for terms. However, we can observe that PHOML restricted to terms and types is just the simply-typed lambda calculus with one atomic type $\Omega$ and two constants $\bot$ and $\supset$; and our reduction relation restricted to this fragment is head reduction. Canonicity for this system is already a well-known result (see e.g. [@Girard1989 Ch. 4]).

Conclusion and Future Work
==========================

We have presented a system with propositional extensionality, and shown that it satisfies the property of canonicity. This gives hope that it will be possible to find a computation rule for homotopy type theory that satisfies canonicity, and that does not involve extending the type theory, either with a nominal extension of the syntax as in cubical type theory or otherwise.

We now intend to do the same for stronger and stronger systems, getting ever closer to full homotopy type theory. The next steps will be:

-   a system where the equations $M =_A N$ are objects of $\Omega$, allowing us to form propositions such as $M =_A N \supset N =_A M$.

-   a system with universal quantification over the types $A$, allowing us to form propositions such as $\forall x:A. x =_A x$ and $\forall x,y : A. x =_A y \supset y =_A x$

Ultimately, we hope to approach full homotopy type theory. The study of how the reduction relation and its properties change as we move up and down this hierarchy of systems should reveal facts about computing with univalence that might be lost when working in a more complex system such as homotopy type theory or cubical type theory.

Calculation in Cubical Type Theory {#appendix:cubical}
==================================

We can prove that, if $X$ is a proposition, then the type $\Sigma f:\top \rightarrow X. Path \, X \, x \, (f I)$ is contractible (we omit the details). Let $e[X, x, p]$ be the term such that $$\begin{aligned}
 & X : {\mathsf{Prop}}, x : X.1, p : \Sigma f:\top \rightarrow X.1. {\ensuremath{\mathsf{Path} \, {X.1} \, {x} \, {(fI)}}} \\
\vdash & e[X, x, p] : {\ensuremath{\mathsf{Path} \, {(\Sigma f:\top \rightarrow X.1. {\ensuremath{\mathsf{Path} \, {X.1} \, {x} \, {(f I)}}})} \, {\langle \lambda t : \top . x, 1_{X.1} \rangle} \, {p}}}\end{aligned}$$

Let ${\mathsf{step}_2}[X,x] {\mathrel{\smash{\stackrel{\text{def}}{=}}}}\langle \langle \lambda t : T.x, 1_{X.1} \rangle,
\lambda p : \Sigma f : T \rightarrow X.1. {\ensuremath{\mathsf{Path} \, {X.1} \, {x} \, {(fI)}}}. e[X, x, p] \rangle$. Then $$X : {\mathsf{Prop}}, x : X.1 \vdash {\mathsf{step}_2}[X, x] : \mathsf{isContr}(\Sigma f:T \rightarrow X.1. {\ensuremath{\mathsf{Path} \, {X.1} \, {x} \, {(fI)}}}) \enspace .$$ Let ${\mathsf{step}_3}[X] \equiv \lambda x : X.1. {\mathsf{step}_2}[X, x]$. Then $$X : {\mathsf{Prop}}\vdash {\mathsf{step}_3}[X] : \mathsf{isEquiv} \, (T \rightarrow X.1) \, X.1 \, (\lambda f : T \rightarrow X.1. f I) \enspace .$$ Let $E[X] \equiv \langle \lambda f : \top \rightarrow X.1. f I, step3[X] \rangle$. Then $$X : {\mathsf{Prop}}\vdash E[X] : \mathsf{Equiv} \, (\top \rightarrow X.1) \, X.1$$

From this equivalence, we want to get a path from $\top \rightarrow X.1$ to $X.1$ in $U$. We apply the proof of univalence in [@cchm:cubical]

Let $P[X] \equiv \langle i \rangle \mathsf{Glue} [(i = 0) \mapsto (\top \rightarrow X.1, E[X]), (i = 1) \mapsto (X.1, equiv^k X.1)] X.1$. Then $$X : {\mathsf{Prop}}\vdash P[X] : {\ensuremath{\mathsf{Path} \, {U} \, {(\top \rightarrow X.1)} \, {X.1}}}$$ Let $Q \equiv \langle i \rangle \lambda x : {\mathsf{Prop}}. P[X] i$. Then $$\vdash Q : {\ensuremath{\mathsf{Path} \, {({\mathsf{Prop}}\rightarrow U)} \, {F} \, {I}}}$$

This is the term in cubical type theory that corresponds to ${\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e : x =_\Omega y.P$ in PHOML (formula \[eq:llleP\]). We now construct terms corresponding to formulas (\[eq:llleP2\]) and (\[eq:llleP3\]): $$\vdash \langle i \rangle H (Q i) : {\ensuremath{\mathsf{Path} \, {U} \, {(\top \rightarrow \top)} \, {\top}}}$$ $$\vdash \lambda x : \top. {\mathsf{comp}}^i (H (Q (1 - i))) [] x : \top \rightarrow \top \rightarrow \top$$

Let us write ${\mathsf{output}}$ for this term: $${\mathsf{output}}{\mathrel{\smash{\stackrel{\text{def}}{=}}}}\lambda x : \top. {\mathsf{comp}}^i (H (Q (1 - i))) [] x \enspace .$$ And we calculate (using the notation from [@cchm:cubical] section 6.2): $$\begin{aligned}
& \quad {\mathsf{output}}\\
& = \lambda x : \top. {\mathsf{comp}}^i (Q (1 - i) \top) [] x \\
& = \lambda x : \top. {\mathsf{comp}}^i (P[\top] (1 - i)) [] x \\
& = \lambda x : \top. {\mathsf{comp}}^i (\mathsf{Glue}[(i = 1) \mapsto (\top \rightarrow \top, E[\top]), (i = 0) \mapsto (\top, \mathsf{equiv}^k \top)] \top) [] x \\
& = \lambda x : \top. \mathsf{glue} [ 1_\mathbb{F} \mapsto t_1 ] a_1 \\
& = \lambda x : \top. t_1 \\
& = \lambda x : \top. (\mathsf{equiv} \, E[\top] \, [] \, {\mathsf{mapid}_{\top} \, {x}}).1 \\
& = \lambda x : \top. (\mathsf{contr} (step2[\top, {\mathsf{mapid}_{\top} \, {x}}]) []).1 \\
& = \lambda x : \top. ({\mathsf{comp}}^i \\
& \qquad (\Sigma f : \top \rightarrow \top. {\ensuremath{\mathsf{Path} \, {\top} \, {({\mathsf{mapid}_{\top} \, {x}})} \, {(fI)}}}) \\
& \qquad [] \\
& \qquad \langle \lambda t : \top. {\mathsf{mapid}_{\top} \, {x}}, 1_{mapid_\top(x)} \rangle).1 \\
& = \lambda x : \top. {\mathsf{mapid}_{\top \rightarrow \top} \, {(\lambda y : \top. {\mathsf{mapid}_{\top} \, {x}})}}\end{aligned}$$ Therefore, $$\begin{aligned}
& {\mathsf{output}}\, m \, n \\
& = {\mathsf{mapid}_{\top \rightarrow \top} \, {(\lambda y : \top. {\mathsf{mapid}_{\top} \, {m}})}} n \\
& \equiv ({\mathsf{comp}}^i (\top \rightarrow \top) [] (\lambda _ : \top. {\mathsf{mapid}_{\top} \, {m}})) n \\
& = {\mathsf{mapid}_{\top} \, {{\mathsf{mapid}_{\top} \, {m}}}}\end{aligned}$$

Proof of Confluence {#section:confluence}
===================

The proof follows the same lines as the proof given in [@luo:car].

#### Reflexivity {#reflexivity .unnumbered}

$$\infer{E \rhd E}{}$$

#### Reduction on Terms {#reduction-on-terms-1 .unnumbered}

$$\infer{(\lambda x:A.M)N \rhd M[x:=N]}{} \quad
\infer{MN \rhd M'N}{M \rhd M'} \quad
\infer{\varphi \supset \psi \rhd \varphi' \supset \psi'}{\varphi \rhd \varphi' \quad \psi \rhd \psi'}$$

#### Reduction on Proofs {#reduction-on-proofs-1 .unnumbered}

$$\infer{(\lambda p : \varphi . \delta)\epsilon \rhd \delta [ p := \epsilon ]}{} \quad
\infer{{\ensuremath{\mathrm{ref} \left( {\varphi} \right)}}^+ \rhd \lambda p : \varphi . p}{} \quad
\infer{{\ensuremath{\mathrm{ref} \left( {\varphi} \right)}}^- \rhd \lambda p : \varphi . p}{}$$ $$\infer{{\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}}^+ \rhd \delta}{} \quad
\infer{{\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}}^- \rhd \epsilon}{}$$ $$\infer{\delta \epsilon \rhd \delta' \epsilon}{\delta \rhd \delta'} \quad \infer{P^+ \rhd Q^+}{P \rhd Q} \quad
\infer{P^- \rhd Q^-}{P \rhd Q}$$

#### Reduction on Paths {#reduction-on-paths-1 .unnumbered}

$$\infer{({\ensuremath{\lambda \!\! \lambda \!\! \lambda}}e:x =_A y.P)_{MN} Q \rhd P [x := M, y := N, e := Q]}{}$$ $$\infer{{\ensuremath{\mathrm{ref} \left( {\lambda x:A.M} \right)}}_{N N'} P \rhd M \{ x:=P : N = N' \}}{}$$ $$\infer{{\ensuremath{\mathrm{ref} \left( {\varphi} \right)}} \supset^* {\ensuremath{\mathrm{ref} \left( {\psi} \right)}} \rhd {\ensuremath{\mathrm{ref} \left( {\varphi \supset \psi} \right)}}}{}$$ $$\infer{{\ensuremath{\mathrm{ref} \left( {\varphi} \right)}} \supset^* {\ensuremath{\mathrm{univ}_{{\psi}, {\chi}} \left({\delta} , {\epsilon} \right)}} \rhd
{\ensuremath{\mathrm{univ}_{{\varphi \supset \psi}, {\varphi \supset \chi}} \left({\lambda p:\varphi \supset \psi. \lambda q : \varphi. \delta (pq)} , {\lambda p : \varphi \supset \chi. \lambda q : \varphi. \epsilon (pq)} \right)}}}{}$$ $$\infer{{\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}} \supset^* {\ensuremath{\mathrm{ref} \left( {\chi} \right)}} \rhd
{\ensuremath{\mathrm{univ}_{{\varphi \supset \chi}, {\psi \supset \chi}} \left({\lambda p : \varphi \supset \chi. \lambda q : \psi. p (\epsilon q)} , {\lambda p:\psi \supset \chi. \lambda q : \varphi. p(\delta q)} \right)}}}{}$$ $$\infer{\begin{array}{l}
{\ensuremath{\mathrm{univ}_{{\varphi}, {\psi}} \left({\delta} , {\epsilon} \right)}} \supset^* {\ensuremath{\mathrm{univ}_{{\varphi'}, {\psi'}} \left({\delta'} , {\epsilon'} \right)}} \\
 \rhd
{\ensuremath{\mathrm{univ}_{{\varphi \supset \varphi'}, {\psi \supset \psi'}} \left({\lambda p : \varphi \supset \varphi'. \lambda q : \psi. \delta' (p(\epsilon q))} , {\lambda p : \psi \supset \psi'. \lambda q : \varphi. \epsilon' (p (\delta q))} \right)}}
\end{array}}{}$$ $$\infer{P_{MN} Q \rhd P'_{MN} Q}{P \rhd P'} \quad
\infer{{\ensuremath{\mathrm{ref} \left( {M} \right)}}_{NN'}P \rhd {\ensuremath{\mathrm{ref} \left( {M'} \right)}}_{NN'}P}{M \rhd N} \quad
\infer{P \supset^* Q \rhd P' \supset^* Q}{P \rhd P' \quad Q \rhd Q'}$$

Define the notion of *parallel one-step reduction* $\rhd$ by the rules given in Figure \[fig:POSR\]. Let $\rhd^*$ be the transitive closure of $\rhd$.

\[lm:rhdiff\]

1.  If $E \rightarrow F$ then $E \rhd F$.

2.  If $E \twoheadrightarrow F$ then $E \rhd^* F$.

3.  If $E \rhd^* F$ then $E \twoheadrightarrow F$.

These are easily proved by induction.

Our reason for defining $\rhd$ is that it satisfies the diamond property:

If $E \rhd F$ and $E \rhd G$ then there exists an expression $H$ such that $F \rhd H$ and $G \rhd H$.

The proof is by case analysis on $E \rhd F$ and $E \rhd G$. We give the details for one case here: $${\ensuremath{\mathrm{ref} \left( {\phi} \right)}} \supset^* {\ensuremath{\mathrm{ref} \left( {\psi} \right)}} \rhd {\ensuremath{\mathrm{ref} \left( {\phi \supset \psi} \right)}} \mbox{ and } {\ensuremath{\mathrm{ref} \left( {\phi} \right)}} \supset^* {\ensuremath{\mathrm{ref} \left( {\psi} \right)}} \rhd {\ensuremath{\mathrm{ref} \left( {\phi'} \right)}} \supset^* {\ensuremath{\mathrm{ref} \left( {\psi'} \right)}}$$ where $\phi \rhd \phi'$ and $\psi \rhd \psi'$. In this case, we have ${\ensuremath{\mathrm{ref} \left( {\phi \supset \psi} \right)}} \rhd {\ensuremath{\mathrm{ref} \left( {\phi' \supset \psi'} \right)}}$ and ${\ensuremath{\mathrm{ref} \left( {\phi'} \right)}} \supset^* {\ensuremath{\mathrm{ref} \left( {\psi'} \right)}}
\rhd {\ensuremath{\mathrm{ref} \left( {\phi' \supset \psi'} \right)}}$.

If $E \rhd^* F$ and $E \rhd^* G$ then there exists $H$ such that $F \rhd^* H$ and $G \rhd^* H$.

If $E \twoheadrightarrow F$ and $E \twoheadrightarrow G$ then $F \twoheadrightarrow H$ and $G \twoheadrightarrow H$.

Immediate from the previous corollary and Lemma \[lm:rhdiff\].

[^1]: These have also been called *context morphisms*, for example in Hoffman [@Hofmann97syntaxand].
