arXiv:1610.00026v3 [cs.LO] 13 Mar 2017

1 downloads 46 Views 200KB Size Report
Mar 13, 2017 - Abstract. The univalence axiom expresses the principle of extensionality for dependent type theory. How- ever, if we simply add the univalence ...
arXiv:1610.00026v1 [cs.LO] 30 Sep 2016

A Strongly Normalizing Computation Rule for Univalence in Higher-Order Minimal Logic Robin Adams

Marc Bezem

Thierry Coquand

October 4, 2016

1

Introduction

The rules of deduction of a type theory are traditionally justified by a meaning explanation [3], in which to know that a given term has a given type is to know that it computes to a canonical object of that type. For such a meaning explanation to be possible, the type theory should have the following properties: • Confluence — The reduction relation should be confluent. • Normalization — Every well-typed term should reduce to a normal form. • Every closed normal form of type A is a canonical object of type A. From these three properties, we have: • Canonicity — Every term of type A reduces to a unique canonical object of type A. It is desirable to have, in addition, strong normalization, so that we know that we are free to choose whatever reduction strategy we please. The univalence axiom of Homotopy Type theory (HoTT) [5] breaks the property of canonicity. It postulates a constant isotoid : A ≃ B → A = B that is an inverse to the canonical function A = B → A ≃ B. When a computation reaches a point where we eliminate a path (proof of equality) formed by 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. We may attempt to prove that every closed term of type N is propositionally equal to a numeral, as conjectured by Voevodsky. Or we may attempt to change the definition of equality to make isotoid definable[4], or shift to an entirely different type theory such as Cubical Type Theory[1]. We could also try a more conservative approach, and simply attempt to find a reduction relation for a type theory involving isotoid that satisfies all three 1

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 λoe, or predicative higher-order minimal logic. It is a type theory with two universes: the universe Ω of propositions, and the universe of types. The propositions are closed under ⊃ (implication) and include ⊥ (falsehood), and an equality proposition M =A N for any type A and terms M : A and N : A. The types include Ω itself and are closed under → (non-dependent function type). There are two canonical forms for proofs of M =Ω N . For any term M : Ω, we have ref (M ) : M =Ω M . We also add univalence for this system, in this form: if δ : φ ⊃ ψ and ǫ : ψ ⊃ φ, then univφ,ψ (δ, ǫ) : φ =Ω ψ. We present a reduction relation for this system, and prove it satisfies confluence (Corollary 2.8.1), strong normalization (Corollary 3.5) and canonicity (Corollary 3.6). For the future, we wish to expand the system with universal quantification, and expand it to a 2-dimensional system (with equations between proofs).

2

Predicative Higher-Order Minimal Logic with Extensional Equality

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

2.1

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 λoe is given by the grammar: Type Term Proof Path Context Judgement

A, B, C L, M, N, φ, ψ, χ δ, ǫ P, Q

::= ::= ::= ::=

Γ, ∆, Θ J

::= ::=

Ω|A→B x | ⊥ | φ ⊃ ψ | λx : A.M | M N p | λp : φ.δ | δǫ | P + | P − e | ref (M ) | P ⊃∗ Q | univφ,ψ (P, Q) | λλλe : x =A y.P | PMN Q hi | Γ, x : A | Γ, p : φ | Γ, e : M =A N Γ ⊢ valid | Γ ⊢ M : A | Γ ⊢ δ : φ | Γ ⊢ P : M =A N

2

In the path λλλe : x =A y.P , the term variables x and y must be distinct. (We also have x 6≡ e 6≡ y, thanks to our stipulation that term variables and path variables are disjoint.) The term variable x is bound within M in the term λx : A.M , and the proof variable p is bound within δ in λp : φ.δ. The three variables e, x and y are bound within P in the path λλλe : x =A y.P . We identify terms, proofs and paths up to α-conversion. 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 r, s, t, S and T as metavariables that range over expressions. Note that we use both Roman letters M , N and Greek letters φ, ψ, χ 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 λoe are just the simple types over Ω; 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 2). For any object M : A, there is the trivial path ref (M ) : M =A M . The constructor ⊃∗ ensures congruence for ⊃ — if P : φ =Ω φ′ and Q : ψ =Ω ψ ′ then P ⊃∗ Q : φ ⊃ ψ =Ω φ′ ⊃ ψ ′ . The constructor univ gives univalence for our propositions: if δ : φ ⊃ ψ and ǫ : ψ ⊃ φ, then univφ,ψ (δ, ǫ) is a path of type φ =Ω ψ. The constructors + and − are the converses: if P is a path of type φ =Ω ψ, then P + is a proof of φ ⊃ ψ, and P − is a proof of ψ ⊃ φ. The constructor λλλ gives functional extensionality. Let F and G be functions of type A → B. If F x =B Gy whenever x =A y, then F =A→B G. More formally, if P is a path of type F x =B Gy that depends on x : A, y : A and e : x =A y, then λλλe : x =A y.P is a path of type F =A→B G. Finally, if P is a path of type F =A→B G, and Q is a path M =A N , then PMN Q is a path F M =B GN . Substitution We write t[z := s] for the result of substituting s for z in t, renaming bound variables to avoid capture. We write s[z1 := t1 , . . . , zn := tn ] or s[~z := ~t] for the result of simultaneously substituting each ti for zi in s. A substitution σ is a function whose domain is a finite set of variables, and which maps term variables to terms, proof variables to proofs, and path variables to paths. Given a substitution σ and an expression t, we write t[σ] for the result of simultaneously substituting σ(z) for z within t, for each variable z in the domain of σ. Given two substitutions σ and ρ, we define their composition σ ◦ ρ to be the substitution with the same domain an ρ, such that def

(σ ◦ ρ)(x) = ρ(x)[σ] . An easy induction on t shows that we have t[σ ◦ ρ] ≡ t[ρ][σ].

3

2.2

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 Γ ⊢ P : M =A M ′ and Γ, x : A ⊢ N : B then Γ ⊢ N {x := P : M ∼ M ′ } : N [x := M ] =B N [x := M ′ ] (see Lemma 2.16). Definition 2.1 (Path Substitution). Given terms M1 , . . . , Mn and N1 , . . . , Nn ; paths P1 , . . . , Pn ; term variables x1 , . . . , xn ; and a term L, define the path L{x1 := P1 : M1 ∼ N1 , . . . , xn := Pn : Mn ∼ Nn } as follows. ~ ∼N ~ } def xi {~x := P~ : M = Pi def ~ ∼N ~ } = ref (y) y{~x := P~ : M ~ ∼N ~ } def ⊥{~x := P~ : M = ref (⊥) ~ ∼N ~} (LL′ ){~x := P~ : M def ~ ∼N ~} = L{~x := P~ : M

(y 6≡ x1 , . . . , xn )

~ ′ [~ ~ ]L L′ [~ x:=M]L x:=N



~ ∼N ~} {~x := P~ : M

~ ∼N ~} (λy : A.L){~x := P~ : M def

~ ∼N ~ , y := e : a ∼ a′ } = λλλe : a =A a′ .L{~x := P~ : M def ~ ∼N ~ } = φ{~x := P~ : M ~ ∼N ~ } ⊃∗ ψ{~x := P~ : M ~ ∼N ~} (φ ⊃ ψ){~x := P~ : M ~ and N ~. We shall often omit the endpoints M Note The case n = 0 is permitted, and we shall have that, if Γ ⊢ M : A then Γ ⊢ M {} : M =A M . There are thus two paths from a term M to itself: ref (M ) and M {}. There are not always equal; for example, (λx : A.x){} ≡ λλλe : x =A y.e, which (after we define the reduction relation) will not be convertible with ref (λx : A.x). Lemma 2.2. ~ ∼N ~ } ≡ M {~x := P~ : M ~ ∼N ~ , y := ref (y) : y ∼ y} M {~x := P~ : M Proof. An easy induction on M . The following lemma shows how substitution and path substitution interact. Lemma 2.3 (Substitution). Let ~x and ~y be a disjoint sequences of variables. Then ~ ∼L ~′ } 1. M [x := N ]{~y := P~ : L ~ ∼L ~′ } : N [~y := L] ~ ∼ N [~y := L ~′ ], ~y := P~ : L ~ ∼L ~′} ≡ M {x := N {~y := P~ : L ~ ∼L ~′ }[x := N ] 2. M {~y := P~ : L ~ := N ] ∼ L ~′ [x := N ], x := ref (N ) : N ∼ N } ≡ M {~y := P~ [x := N ] : L[x Proof. An easy induction on M in all cases. 4

Note The familiar substitution lemma also holds: t[z~1 := s~1 ][z~2 := s~2 ] ≡ t[z~1 := s~1 [z~2 := s~2 ], z~2 := s~2 ]. We cannot form a lemma about the fourth case, ~ because M {~x := P~ } is a path, and path simplifying M {~x := P~ }{~y := Q}, substitution can only be applied to a term. Definition 2.4. A path substitution τ 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 τ and substitutions ρ, σ with the same domain {x1 , . . . , xn }, we write M {τ : ρ ∼ σ} for M {x1 := τ (x1 ) : ρ(x1 ) ∼ σ(x1 ), . . . , τ (xn ) : ρ(xn ) ∼ σ(xn )} . Given substitutions σ, ρ, ρ′ and a path substitution τ , let τ •ρ,ρ′ σ be the path substitution defined by def

(τ •ρ,ρ′ σ)(x) = σ(x){τ : ρ ∼ ρ′ } Lemma 2.5. M [σ]{τ : ρ ∼ ρ′ } ≡ M {τ •ρρ′ σ : ρ ◦ σ ∼ ρ′ ◦ σ} Proof. An easy induction on M .

2.3

The Reduction Relation

Definition 2.6. We make the following definitions simultaneously: 1. Let contraction ⊲ be the relation consisting of the pairs s ⊲ t shown in Figure 1, such that s is closed, and every proper subexpression of s is in normal form. 2. One-step reduction → is the congruence generated by ⊲. That is, the expression s reduces in one step to the expression t, s → t, iff t is formed from s by replacing a subexpression s′ with a subterm t′ , where s′ ⊲ t′ . (This subexpression may be in the subscripts of a path application; thus, if M → M ′ , then PMN Q → PM ′ N Q.) 3. An expression s is in normal form iff there is no expression t such that s → t. Let →? be the reflexive closure of →; let ։+ be the transitive closure; let reduction ։ be the reflexive, transitive closure; and conversion ≃ the equivalence relation generated by →. Note Contraction is a relation between closed expressions only: if s ⊲ t then s and t are closed. This is not true for →, ։ or ≃, however. For example, we have ref (⊥)+ x → (λp : ⊥.p)x. Lemma 2.7 (Reduction respects substitution). 1. If t → t′ then t[x := s] → t′ [x := s]. 5

(λx : A.M )N ⊲ M [x := N ]

(λp : φ.δ)ǫ ⊲ δ[p := ǫ]

+

ref (φ)− ⊲ λp : φ.p

ref (φ) ⊲ λp : φ.p +



univφ,ψ (δ, ǫ) ⊲ δ

univφ,ψ (δ, ǫ) ⊲ ǫ

ref (φ) ⊃∗ univψ,χ (δ, ǫ) ⊲ univφ⊃ψ,φ⊃χ (λp : φ ⊃ ψ.λq : φ.δ(pq), λp : φ ⊃ χ.λq : φ.ǫ(pq)) univφ,ψ (δ, ǫ) ⊃∗ ref (χ) ⊲ univφ⊃χ,ψ⊃χ (λp : φ ⊃ χ.λq : ψ.p(ǫq), λp : ψ ⊃ χ.λq : φ.p(δq)) univφ,ψ (δ, ǫ) ⊃∗ univφ′ ,ψ′ (δ ′ , ǫ′ ) ⊲ univφ⊃φ′ ,ψ⊃ψ′ (λp : φ ⊃ φ′ .λq : ψ.δ ′ (p(ǫq)), λp : ψ ⊃ ψ ′ .λq : φ.ǫ′ (p(δq))) ref (φ) ⊃∗ ref (ψ) ⊲ ref (φ ⊃ ψ) ref (M )N1 N2 ref (N ) ⊲ ref (M N ) (λλλe : x =A y.P )MN Q ⊲ P [x := M, y := N, e := Q] If P does not have the form ref (−) , then ref (λx : A.M )N,N ′ P ⊲ M {x := P : N ∼ N ′ }

Figure 1: Contractions for λoe

6

2. If t → t′ then s[x := t] ։ s[x := t′ ]. 3. If P → P ′ then M {x := P : N ∼ N ′ } ։ M {x := P ′ : N ∼ N ′ }. Proof. A straightforward induction in each case. Note It is not true in general that path substitution respects reduction; that is, that if M → M ′ then M {x := P : N ∼ N ′ } ։ M ′ {x := P : N ∼ N ′ }. For example, we have (λx : Ω.x)(⊥ ⊃ ⊥) → ⊥ ⊃ ⊥, but (⊥ ⊃ ⊥){} ≡ ref (⊥) ⊃∗ ref (⊥) ((λx : Ω.x)(⊥ ⊃ ⊥)){} ≡ (λλλe : x =Ω x′ .e)(ref (⊥) ⊃∗ ref (⊥)) The second of these paths does not reduce to the first, because ref (⊥) ⊃∗ ref (⊥) is not a normal form. Proposition 2.8. If r → s and r → s′ then there exists t such that s →? t and s′ →? t. Proof. Case analysis on r → s and r → s′ . There are no critical pairs thanks to our restriction that, if s ⊲ t, then all proper subterms of s are normal forms; thus, redexes cannot overlap. Corollary 2.8.1 (Confluence). 1. The reduction relation is confluent: if r ։ s and r ։ s′ , then there exists t such that s ։ t and s′ ։ t. 2. If r ≃ s, then there exists t such that r ։ t and s ։ t.

2.4

Rules of Deduction

The rules of deduction of λoe are given in Figure 2.

2.5

Metatheorems

In the lemmas that follow, the letter J stands for any of the expressions that may occur to the right of the turnstile in a judgement, i.e. valid, M : A, δ : φ, or P : M =A N . Lemma 2.9 (Context Validity). 1. Every derivation of Γ, ∆ ⊢ J has a subderivation of Γ ⊢ valid. 2. Every derivation of Γ, p : φ, ∆ ⊢ J has a subderivation of Γ ⊢ φ : Ω. 3. Every derivation of Γ, e : M =A N, ∆ ⊢ J has subderivations of Γ ⊢ M : A and Γ ⊢ N : A. Proof. Part 1 is proven by induction on derivations. Parts 2 and 3 follow by inversion. 7

Contexts hi ⊢ valid

Γ ⊢ valid Γ, x : A ⊢ valid

Γ⊢φ:Ω Γ, p : φ ⊢ valid

Γ ⊢ valid (x : A ∈ Γ) Γ⊢x:A

Γ⊢M :A Γ⊢N :A Γ, e : M =A N ⊢ valid

Γ ⊢ valid (p : φ ∈ Γ) Γ⊢p:φ

Γ ⊢ valid (e : M =A N ∈ Γ) Γ ⊢ e : M =A N Terms Γ ⊢ valid Γ⊢⊥:Ω

Γ⊢φ:Ω Γ⊢ψ:Ω Γ⊢φ⊃ψ:Ω

Γ⊢M :A→B Γ⊢N :A Γ ⊢ MN : B Proofs

Γ⊢δ:φ⊃ψ Γ⊢ǫ:φ Γ ⊢ δǫ : ψ

Γ, x : A ⊢ M : B Γ ⊢ λx : A.M : A → B Γ, p : φ ⊢ δ : ψ Γ ⊢ λp : φ.δ : φ ⊃ ψ

Γ⊢δ:φ Γ⊢ψ:Ω (φ ≃ ψ) Γ⊢δ:ψ Paths Γ⊢M :A Γ ⊢ ref (M ) : M =A M Γ⊢δ:φ⊃ψ Γ⊢ǫ:ψ⊃φ Γ ⊢ univφ,ψ (δ, ǫ) : φ =Ω ψ

Γ ⊢ P : φ =Ω φ′ Γ ⊢ Q : ψ =Ω ψ ′ Γ ⊢ P ⊃∗ Q : φ ⊃ ψ =Ω φ′ ⊃ ψ ′ Γ ⊢ P : φ =Ω ψ Γ ⊢ P+ : φ ⊃ ψ

Γ ⊢ P : ψ =Ω ψ Γ ⊢ P− : ψ ⊃ φ

Γ, x : A, y : A, e : x =A y ⊢ P : M x =B N y Γ⊢M :A→B Γ⊢N :A→B Γ ⊢ λλλe : x =A y.P : M =A→B N Γ ⊢ P : M =A→B M ′ Γ ⊢ Q : N =A N ′ Γ ⊢ N : A Γ ⊢ N ′ : A Γ ⊢ PN N ′ Q : M N =B M ′ N ′ Γ ⊢ P : M =A N Γ ⊢ M ′ : A Γ ⊢ N ′ : A (M ≃ M ′ , N ≃ N ′ ) Γ ⊢ P : M ′ =A N ′

Figure 2: Rules of Deduction of λoe

8

Lemma 2.10 (Weakening). If Γ ⊢ J , Γ ⊆ ∆ and ∆ ⊢ valid then ∆ ⊢ J . Proof. Induction on derivations. Lemma 2.11 (Type Validity). 1. If Γ ⊢ δ : φ then Γ ⊢ φ : Ω. 2. If Γ ⊢ P : M =A N then Γ ⊢ M : A and Γ ⊢ N : A. Proof. Induction on derivations. The cases where δ or P is a variable use Context Validity. Lemma 2.12 (Generation). 1. If Γ ⊢ x : A then x : A ∈ Γ. 2. If Γ ⊢ ⊥ : A then A ≡ Ω. 3. If Γ ⊢ φ ⊃ ψ : A then Γ ⊢ φ : Ω, Γ ⊢ ψ : Ω and A ≡ Ω. 4. If Γ ⊢ λx : A.M : B then there exists C such that Γ, x : A ⊢ M : C and B ≡ A → C. 5. If Γ ⊢ M N : A then there exists B such that Γ ⊢ M : B → A and Γ ⊢ N : B. 6. If Γ ⊢ p : φ, then there exists ψ such that p : ψ ∈ Γ and φ ≃ ψ. 7. If Γ ⊢ λp : φ.δ : ψ, then there exists χ such that Γ, p : φ ⊢ δ : χ and ψ ≃ φ ⊃ χ. 8. If Γ ⊢ δǫ : φ then there exists ψ such that Γ ⊢ δ : ψ ⊃ φ and Γ ⊢ ǫ : ψ. 9. If Γ ⊢ e : M =A N , then there exist M ′ , N ′ such that e : M ′ =A N ′ ∈ Γ and M ≃ M ′ , N ≃ N ′ . 10. If Γ ⊢ ref (M ) : N =A P , then we have Γ ⊢ M : A and M ≃ N ≃ P . 11. If Γ ⊢ P ⊃∗ Q : φ =A ψ, then there exist φ1 , φ2 , ψ1 , ψ2 such that Γ ⊢ P : φ1 =Ω ψ1 , Γ ⊢ Q : φ2 =Ω ψ2 , φ ≃ φ1 ⊃ ψ1 , ψ ≃ φ2 ⊃ ψ2 , and A ≡ Ω. 12. If Γ ⊢ univφ,ψ (P, Q) : χ =A θ, then we have Γ ⊢ P : φ ⊃ ψ, Γ ⊢ Q : ψ ⊃ φ, Γ ⊢ χ ≃∆ φ : Ω, Γ ⊢ θ ≃∆ ψ : Ω and A ≡ Ω. 13. If Γ ⊢ λλλe : x =A y.P : M =B N then there exists C such that Γ, x : A, y : A, e : x =A y ⊢ P : M x =C N y and B ≡ A → C. 14. If Γ ⊢ PMM ′ Q : N =A N ′ , then there exist B, F and G such that Γ ⊢ P : F =B→A G, Γ ⊢ Q : M =B M ′ , N ≃ F M and N ′ ≃ GM ′ . 15. If Γ ⊢ P + : φ, then there exist ψ, χ such that Γ ⊢ P : ψ =Ω χ and φ ≃ (ψ ⊃ χ). 16. If Γ ⊢ P − : φ, there exist ψ, χ such that Γ ⊢ P : ψ =Ω χ and φ ≃ (χ ⊃ ψ). Proof. Induction on derivations. 9

2.5.1

Substitutions

Definition 2.13. Let Γ and ∆ be contexts. A substitution from Γ to ∆1 , σ : Γ ⇒ ∆, is a substitution whose domain is dom Γ such that: • for every term variable x : A ∈ Γ, we have ∆ ⊢ σ(x) : A; • for every proof variable p : φ ∈ Γ, we have ∆ ⊢ σ(p) : φ[σ]; • for every path variable e : M =A N ∈ Γ, we have ∆ ⊢ σ(e) : M [σ] =A N [σ]. Lemma 2.14 (Well-Typed Substitution). If Γ ⊢ J , σ : Γ ⇒ ∆ and ∆ ⊢ valid, then ∆ ⊢ J [σ]. Proof. Induction on derivations. Definition 2.15. If ρ, σ : Γ → ∆ and τ is a path substitution whose domain is the term variables in dom Γ, then we write τ : σ ∼ ρ : Γ → ∆ iff, for each variable x : A ∈ Γ, we have ∆ ⊢ τ (x) : σ(x) =A ρ(x). Lemma 2.16 (Path Substitution). If τ : σ ∼ ρ : Γ → ∆ and Γ ⊢ M : A and ∆ ⊢ valid, then ∆ ⊢ M {τ : σ ∼ ρ} : M [σ] =A M [ρ]. Proof. Induction on derivations. Lemma 2.17. If σ : Γ → ∆ and τ : ρ ∼ ρ′ : ∆ → Θ then τ •ρ,ρ′ σ : ρ ◦ σ ∼ ρ′ ◦ σ : Γ → Θ. Proof. Let x : A ∈ Γ. We have ∆ ⊢ σ(x) : A, hence Θ ⊢ σ(x){τ : ρ ∼ ρ′ } : σ(x)[ρ] =A σ(x)[ρ′ ]. Proposition 2.18 (Subject Reduction). If Γ ⊢ s : T and s ։ t then Γ ⊢ t : T . Proof. It is sufficient to prove the case s → t. The proof is by a case analysis on s → t, using the Generation Lemma. 2.5.2

Canonicity

Definition 2.19 (Canonical Object). • The canonical objects θ of Ω are given by the grammar θ ::= ⊥ | θ ⊃ θ • A canonical object of type A → B has the form λx : A.M , where x : A ⊢ M : B and M is in normal form. We define the canonical proofs of a canonical object θ of Ω as follows: 1 These have also been called context morphisms, for example in Hoffman [2]. Note however that what we call a substitution from Γ to ∆ is what Hoffman calls a context morphism from ∆ to Γ.

10

• There is no canonical proof of ⊥. • A canonical proof of φ ⊃ ψ has the form λp : φ.δ, where p : φ ⊢ δ : ψ and δ is in normal form. We define the canonical paths of an equation M =A N , where M and N are canonical objects of A, as follows: • A canonical path of φ =Ω ψ is either ref (φ) if φ ≃ ψ, or univφ,ψ (δ, ǫ), where δ is a canonical proof of φ ⊃ ψ and ǫ is a canonical proof of ψ ⊃ φ. • A canonical path of F =A→B G is either ref (F ) if F ≃ G, or λλλe : x =A y.P where x : A, y : A, e : x =A y ⊢ P : F x =B Gy and P is in normal form. Proposition 2.20 (Canonicity). If ⊢ t : T and t is in normal form, then t is a canonical object (proof, path) of T . Proof. This follows easily from the Generation Lemma. 2.5.3

Well-Typed Expansion

Let SN be the set of all strongly normalizing expressions. Proposition 2.21. 1. If M [x := N ]L1 · · · Ln ∈ SN and N ∈ SN then (λx : A.M )N L1 · · · Ln ∈ SN. 2. If δ[p := ǫ], φ, ǫ ∈ SN then (λp : φ.δ)ǫ ∈ SN. 3. If (P [x := L, y := L′ , e := Q]M1 N1 Q1 · · ·Mn Nn Qn )+ δ1 · · · δm ∈ SN and L, L′ , Q ∈ SN then ((λλλe : x =A y.P )LL′ QM1 N1 Q1 · · ·Mn Nn Qn )+ δ1 · · · δm ∈ SN. 4. If (P [x := L, y := L′ , e := Q]M1 N1 Q1 · · ·Mn Nn Qn )− δ1 · · · δm ∈ SN and L, L′ , Q ∈ SN then ((λλλe : x =A y.P )LL′ QM1 N1 Q1 · · ·Mn Nn Qn )− δ1 · · · δm ∈ SN. Proof. We prove part 1; the proofs of the other parts are similar. The proof is by a double induction on the hypotheses. Consider all possible ~ The possibilities are: one-step reductions from (λx : A.M )N L. ~ → (λx : A.M ′ )N L, ~ where M → M ′ (λx : A.M )N L ~ → M ′ [x := N ]L, ~ and the result follows In this case, we have M [x := N ]L by the induction hypothesis. Similarly for the case where we reduce N or one of the Li . ~ → M [x := N ]L ~ (λx : A.M )N L In this case, the result follows immediately from the hypothesis.

11

3

Computable Expressions

We define a model of the type theory with types as sets of terms. For every type (proposition, equation) T in context Γ, define the set of computable terms (proofs, paths) EΓ (T ). Definition 3.1 (Neutral). A term is neutral iff it has the form xM1 · · · Mn , where each Mi is in normal form. Note that (using Generation) a normal form of type Ω is either ⊥, or a neutral term, or φ ⊃ ψ where φ and ψ are normal forms of type Ω. Definition 3.2 (Computable Expressions). def

EΓ (χ) = {δ |Γ ⊢ δ : χ and δ ∈ SN} (χ is neutral or ⊥) def EΓ (φ ⊃ ψ) = {δ |Γ ⊢ δ : φ ⊃ ψ and ∀∆ ⊇ Γ . ∀ǫ ∈ E∆ (φ) . δǫ ∈ EΓ (ψ)} (φ, ψ normal forms) def

EΓ (φ) = {δ |Γ ⊢ δ : φ and δ ∈ SN} (φ neutral) def

EΓ (φ) = {δ |Γ ⊢ δ : φ and δ ∈ EΓ (nf(φ))} (φ a weakly normalizable term) def

EΓ (Ω) = {M |Γ ⊢ M : Ω and M ∈ SN and M {} ∈ EΓ (M =Ω M )} EΓ (A → B) = {M |Γ ⊢ M : A → B and def

∀∆ ⊇ Γ . ∀N ∈ E∆ (A) . M N ∈ E∆ (B) and M {} ∈ EΓ (M =A→B M )} def

EΓ (φ =Ω ψ) = {P |Γ ⊢ P : φ =Ω ψ and P + ∈ EΓ (φ ⊃ ψ) and P − ∈ EΓ (ψ ⊃ φ)} (φ, ψ weakly normalizable terms) def

EΓ (M =A→B M ′ ) = {P |Γ ⊢ P : M =A→B M ′ and ∀∆ ⊇ Γ . ∀N, N ′ ∈ E∆ (A) . ∀Q ∈ E∆ (N =A N ′ ) . PN N ′ Q ∈ E∆ (M N =B M ′ N ′ )} If φ is a term that is not weakly normalizable, then EΓ (φ) is undefined. Similarly, EΓ (φ =Ω ψ) is undefined if φ and ψ are not both weakly normalizable. Note that each EΓ (T ) is closed under reduction, and that, if Γ ⊆ ∆, then EΓ (T ) ⊆ E∆ (T ). Note also that, if M ∈ EΓ (A), then M {} ∈ EΓ (M =A M ). 12

Let us say that a substitution σ : Γ ⇒ ∆ is computable iff, for all z : T ∈ Γ, we have σ(z) ∈ E∆ (T [σ]). Let us say that a path substitution τ : σ ∼ ρ : Γ ⇒ ∆ is computable iff, for all x : A ∈ Γ, we have τ (x) ∈ E∆ (σ(x) =A ρ(x)). Our main theorem is as follows. Theorem 3.3. 1. If Γ ⊢ t : T and σ : Γ ⇒ ∆ is computable, and ∆ ⊢ valid, then t[σ] ∈ E∆ (T [σ]). 2. If Γ ⊢ M : A, τ : σ ∼ ρ : Γ ⇒ ∆, and τ , σ and ρ are all computable, and ∆ ⊢ valid, then M {τ : σ ∼ ρ} ∈ E∆ (M [σ] =A M [ρ]). Proof. The four parts are proved simultaneously by induction on derivations. •

Γ ⊢ valid (x : A ∈ Γ) Γ⊢x:A We have that σ(x) ∈ E∆ (A) and τ (x) ∈ E∆ (ρ(x) =A σ(x)) by hypothesis.



Γ ⊢ valid (p : φ ∈ Γ) Γ⊢p:φ We have that σ(p) ∈ E∆ (φ[σ]) by hypothesis.



Γ ⊢ valid Γ⊢⊥:Ω From Lemma A.7, we have ⊥ ∈ E∆ (Ω) and therefore ⊥{} ∈ E∆ (⊥ =Ω ⊥).



Γ⊢φ:Ω Γ⊢ψ:Ω Γ⊢φ⊃ψ:Ω By the induction hypothesis, φ[σ], ψ[σ] ∈ SN, hence φ[σ] ⊃ ψ[σ] ∈ SN. Also by the induction hypothesis, we have φ[σ]{} ∈ E∆ (φ[σ] =Ω φ[σ]), and ψ[σ]{} ∈ E∆ (ψ[σ] =Ω ψ[σ]). Therefore, φ[σ]{} ⊃∗ ψ[σ]{} ∈ E∆ (φ[σ] ⊃ ψ[σ] =Ω φ[σ] ⊃ ψ[σ]) by Lemma A.10.



Γ⊢M :A→B Γ⊢N :A Γ ⊢ MN : B 1 We have M [σ] ∈ E∆ (A → B) and N [σ] ∈ E∆ (A), so M [σ]N [σ] ∈ E∆ (B). 4 We have M {τ } ∈ E∆ (M [ρ] =A→B M [σ]) and N [ρ], N [σ] ∈ E∆ (A), N {τ } ∈ E∆ (N [ρ] =A N [σ]) by the induction hypothesis (1) and (4). Therefore, M {τ }N [ρ]N [σ] N {τ } ∈ E∆ (M [ρ]N [ρ] =B M [σ]N [σ]). 13



Γ⊢δ:φ⊃ψ Γ⊢ǫ:φ Γ ⊢ δǫ : ψ We have δ[σ] ∈ E∆ (φ[σ] ⊃ ψ[σ]) and ǫ[σ] ∈ E∆ (φ[σ]), hence δ[σ]ǫ[σ] ∈ E∆ (ψ[σ]).



Γ, x : A ⊢ M : B Γ ⊢ λx : A.M : A → B 1

– Let Θ ⊇ ∆ and N ∈ EΘ (A). We must show that (λx : A.M [σ])N ∈ EΘ (B). We have that (σ, x := N ) : (Γ, x : A) → Θ is computable, and so the induction hypothesis gives M [σ, x := N ] ∈ EΘ (B). The result follows by Lemma A.6.3. – We must show that λλλe : x =A y.M [σ]{x := e : x ∼ y} ≡ λλλe : x =A y.M {z1 := σ(z1 ){}, . . . , zn := σ(zn ){}, x := e} ∈ E∆ (λx : A.M [σ] =A→B λx : A.M [σ]). So let Θ ⊇ ∆ and N, N ′ ∈ EΘ (A), P ∈ EΘ (N =A N ′ ). Then (z1 := σ(z1 ){}, . . . , zn := σ(zn ){}, x := P ) : (σ, x := N ) ∼ (σ, x := N ′ ) : (Γ, x : A) → Θ is computable, and so the induction hypothesis gives M {zi := σ(zi ){}, x := P } ∈ EΘ (M [σ, x := N ] =B M [σ, x := N ′ ]) . Therefore, by Lemma A.6.1, we have that (λλλe : x =A y.M {zi := σ(zi ){}, x := e})N N ′ P ∈ EΘ (M [σ, x := N ] =B M [σ, x := N ′ ]). Hence Lemma A.1 gives (λλλe : x =A y.M {zi := σ(zi ){}, x := e})N N ′ P ∈ EΘ ((λx : A.M [σ])N =B (λx : A.M [σ])N ′ ) as required.

4 Let Θ ⊇ ∆ and N, N ′ ∈ EΘ (A), P ∈ EΘ (N =A N ′ ). Then (τ, x := P ) : (ρ, x := N ) ∼ (σ, x := N ′ ) : (Γ, x : A) → ∆ is computable, and so the induction hypothesis gives M {τ, x := P } ∈ EΘ (M [ρ, x := N ] =B M [σ, x := N ′ ]) . By Lemma A.1, M {τ, x := P } ∈ EΘ ((λx : A.M [ρ])N =B (λx : A.M [σ])N ′ ) and so Lemma A.6.1 gives (λλλe : x =A y.M {τ, x := e})N N ′ P ∈ EΘ ((λx : A.M [ρ])N =B (λx : A.M [σ])N ′ ) as required.

14



Γ, p : φ ⊢ δ : ψ Γ ⊢ λp : φ.δ : φ ⊃ ψ Let Θ ⊇ ∆ and ǫ ∈ EΘ (φ[σ]). Then (σ, p := ǫ) : (Γ, p : φ) → Θ is computable, and so the induction hypothesis gives δ[σ, p := ǫ] ∈ EΘ (ψ[σ)) . Hence by Lemma A.6.2, we have (λp : φ[σ].δ[σ])ǫ ∈ EΘ (ψ[σ]), as required.



Γ⊢δ:φ Γ⊢ψ:Ω (φ ≃ ψ) Γ⊢δ:ψ We have that δ[σ] ∈ EΓ (φ[σ]) by induction hypothesis, and so δ[σ] ∈ EΓ (ψ[σ]) by Lemma A.1.



Γ ⊢ valid (e : M =A N ∈ Γ) Γ ⊢ e : M =A N We have σ(e) ∈ EΓ (M [σ] =A N [σ]) by hypothesis.



Γ⊢M :A Γ ⊢ ref (M ) : M =A M This case holds by Lemma A.9.



Γ ⊢ P : φ =Ω φ′ Γ ⊢ Q : ψ =Ω ψ ′ Γ ⊢ P ⊃∗ Q : φ ⊃ ψ =Ω φ′ ⊃ ψ ′ This case holds by Lemma A.10.



Γ⊢δ:φ⊃ψ Γ⊢ǫ:ψ⊃φ Γ ⊢ univφ,ψ (δ, ǫ) : φ =Ω ψ This case holds by Lemma A.11.



Γ ⊢ P : φ =Ω ψ Γ ⊢ P+ : φ ⊃ ψ The induction hypothesis gives P [σ] ∈ E∆ (φ[σ] =Ω ψ[σ]), and so immediately P [σ]+ ∈ E∆ (φ[σ] ⊃ ψ[σ]).

15



Γ ⊢ P : φ =Ω ψ Γ ⊢ P− : ψ ⊃ φ The induction hypothesis gives P [σ] ∈ E∆ (φ[σ] =Ω ψ[σ]), and so immediately P [σ]− ∈ E∆ (ψ[σ] ⊃ φ[σ]).



Γ, x : A, y : A, e : x =A y ⊢ P : M x =B N y Γ⊢M :A→B Γ⊢N :A→B Γ ⊢ λλλe : x =A y.P : M =A→B N Let Θ ⊇ ∆, L, L′ ∈ EΘ (A), and Q ∈ EΘ (L =A L′ ). We must show that (λλλe : x =A y.P [σ])LL′ Q ∈ EΘ (M L =B N L′ ) . We have that (σ, x := L, y := L′ , e := Q) : (Γ, x : A, y : A, e : x =A y) → Θ is computable, and so the induction hypothesis gives P [σ, x := L, y := L′ , e := Q] ∈ EΘ (M L =B N L′ ) . The result follow by Lemma A.6.1.

• Γ ⊢ P : M =A→B M ′ Γ ⊢ Q : N =A N ′ Γ ⊢ N : A Γ ⊢ PN N ′ Q : M N =B M ′ N ′

Γ ⊢ N′ : A

The induction hypothesis gives P [σ] ∈ E∆ (M [σ] =A→B M ′ [σ]) and N [σ] ∈ E∆ (A), N ′ [σ] ∈ E∆ (A), Q[σ] ∈ E∆ (N =A N ′ ). It follows immediately that (PN N ′ Q)[σ] ∈ E∆ (M [σ]N [σ] =B M ′ [σ]N ′ [σ]). •

Γ ⊢ P : M =A N Γ ⊢ M ′ : A Γ ⊢ N ′ : A (M ≃ M ′ , N ≃ N ′ ) Γ ⊢ P : M ′ =A N ′ The induction hypothesis gives P [σ] ∈ E∆ (M [σ] =A N [σ]), hence P [σ] ∈ E∆ (M ′ [σ] =A N ′ [σ]) by Lemma A.1.

Corollary 3.4 (Soundness). If Γ ⊢ t : T then t ∈ EΓ (T ). Proof. We apply the theorem with σ the identity substitution. The identity substitution is computable by Lemmas A.3 and A.4. Corollary 3.5 (Strong Normalization). Every well-typed term, proof and path is strongly normalizing. Corollary 3.6 (Canonicity). If ⊢ s : T , then there is a unique canonical object t of T such that s ։ t. Corollary 3.7 (Consistency). There is no proof δ such that ⊢ δ : ⊥. 16

4

Future Work

We have shown that it is possible, in a system with non-dependent function types and implication, to give a strongly normalizing, confluent reduction rule for the univalence constructor. 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 Ω, allowing us to form propositions such as M =A N ⊃ N =A M . • a system with universal quantification over the types A, allowing us to form propositions such as ∀x : A.x =A x and ∀x, y : A.x =A y ⊃ y =A x

References [1] Cyril Cohen, Thierry Coquand, Simon Huber, and Anders M¨ ortberg. Cubical type theory: a constructive interpretation of the univalence axiom. Preprint http://www.math.ias.edu/∼amortberg/papers/cubicaltt.pdf, 2015. [2] Martin Hofmann. Syntax and semantics of dependent types. In Semantics and Logics of Computation, pages 79–130. Cambridge University Press, 1997. [3] Per Martin-L¨ of. Intuitionistic Type Theory. Bibliopolis, 1984. [4] Andrew Polonsky. Internalization of extensional equality. http://arxiv.org/abs/1401.1148, 2014.

Preprint

[5] The Univalent Foundations Program. Homotopy Type Theory: Univalent Foundations of Mathematics. https://homotopytypetheory.org/book, Institute for Advanced Study, 2013.

A

Results about Computable Expressions

The following are the lemmas about computable expressions needed to prove Theorem 3.3. Lemma A.1. 1. EΓ (T ) is closed under reductain. 2. If Γ ⊆ ∆ and ∆ ⊢ valid then EΓ (T ) ⊆ E∆ (T ). 3. If t ∈ EΓ (T ) then Γ ⊢ t : T . (Hence, if Γ is not a valid context, then EΓ (T ) = ∅.) 4. If δ ∈ EΓ (φ), Γ ⊢ ψ : Ω and φ ≃ ψ, then δ ∈ EΓ (ψ).

17

5. If P ∈ EΓ (M =A N ), Γ ⊢ M ′ : A, Γ ⊢ N ′ : A, M ≃ M ′ and N ≃ N ′ , then P ∈ EΓ (M ′ =A N ′ ). Proof. These follow easily from the definition of EΓ (T ). Confluence is required for the last two parts. As a consequence of Lemma A.1.4, we can relax the restriction ’φ and ψ are normal forms’ in the definition of EΓ (φ ⊃ ψ): Lemma A.2. Let φ and ψ be weakly normalizable terms, and suppose Γ ⊢ φ : Ω and Γ ⊢ ψ : Ω. Then δ ∈ EΓ (φ ⊃ ψ) if and only if Γ ⊢ δ : φ ⊃ ψ and, for all ∆ ⊇ Γ and ǫ ∈ E∆ (φ), we have δǫ ∈ E∆ (ψ). Proof. Suppose δ ∈ EΓ (φ ⊃ ψ). Let ∆ ⊇ Γ and ǫ ∈ E∆ (φ). Then δ ∈ EΓ (nf(φ) ⊃ nf(ψ)) and ǫ ∈ E∆ (nf(φ)), hence δǫ ∈ E∆ (nf(ψ)). We also have ∆ ⊢ δǫ : ψ, and so δǫ ∈ E∆ (ψ). Conversely, suppose the right-hand side holds. We must show that δ ∈ EΓ (nf(φ) ⊃ nf(ψ)). Let ∆ ⊇ Γ and ǫ ∈ E∆ (nf(φ)). Then ǫ ∈ E∆ (φ) by Lemma A.1.4, and so δǫ ∈ E∆ (ψ) by hypothesis. Therefore δǫ ∈ E∆ (nf(ψ)) as required. Lemma A.3. Let φ be a weakly normalizable term. 1. If Γ ⊢ valid and p : φ ∈ Γ then p ∈ EΓ (φ). 2. EΓ (φ) ⊆ SN. Proof. The two parts are proved simultaneously by induction on nf(φ). Let nf(φ) ≡ ψ1 ⊃ · · · ⊃ ψn ⊃ χ, where χ is either ⊥ or a neutral term. 1. Let ∆ ⊇ Γ and ǫi ∈ E∆ (ψi ) for each i. We must show that pǫ1 · · · ǫn ∈ E∆ (χ) It is easy to see that p~ǫ is well-typed, so it remains to show that p~ǫ ∈ SN. This holds because each ǫi is strongly normalizing by the induction hypothesis (2). 2. Let δ ∈ EΓ (φ). Consider the context ∆ ≡ Γ, p1 : ψ1 , . . . , pn : ψn . By the induction hypothesis (1), we have that pi ∈ E∆ (ψi ), hence δp1 · · · pn ∈ EΓ (χ), and so δp1 · · · pn ∈ SN. It follows that δ ∈ SN.

Lemma A.4. Let A be a type. 1. If Γ ⊢ valid and x : A ∈ Γ then x ∈ EΓ (A). 2. EΓ (A) ⊆ SN. 3. If Γ ⊢ valid and e : M =A N ∈ Γ and M, N ∈ EΓ (A) then e ∈ EΓ (M =A N ). 18

4. For all M , N , we have EΓ (M =A N ) ⊆ SN. Proof. The four parts are proved simultaneously by induction on A. Let A ≡ A1 → · · · → An → Ω, and suppose the lemma holds for each Ai . 1. Let ∆ ⊇ Γ. We must prove the following: (a) Given Mi ∈ E∆ (Ai ) for 1 ≤ i ≤ n, we must show that xM1 · · · Mn ∈ E∆ (Ω). We have that each Mi ∈ SN by the induction hypothesis, ~ ∈ SN. hence xM ~ ). We must show that (xM ~ ){}+ δ ∈ E∆ (xM ~ ), Now, let δ ∈ E∆ (xM + ~ i.e. (ref (x)M1 M1 M1 {}M2 M2 · · ·Mn Mn Mn {}) δ ∈ E∆ (xM ). Welltypedness is easy, and strong normalization follows from the fact that each Mi and Mi {} is strongly normalizing by the induction hypothesis (2) and (4). (Note that ref (x) cannot be part of a redex, as it is not closed.) (b) Given Mi ∈ E∆ (Ai ) for 1 ≤ i ≤ k, and Nj , Nj′ ∈ E∆ (Aj ) and Pj ∈ E∆ (Mj =Aj Nj ) for k < j ≤ n, we must show that ~N ~ =Ω ′ ′ (xM1 · · · Mk ){}Nk+1 Nk+1 (Pk+1 )Nk+2 Nk+2 · · ·Nn Nn′ Pn ∈ E∆ (xM ~N ~ ′ ), i.e. xM (ref (x)M1 M1 M1 {} · · ·Mk Mk Mk {}Mk+1 Nk+1 Pk+1 · · ·Mn Nn Pn )+ ~N ~ ⊃ xM ~N ~ ′) ∈ E∆ (xM (ref (x)M1 M1 M1 {} · · ·Mk Mk Mk {}Mk+1 Nk+1 Pk+1 · · ·Mn Nn Pn )− ~N ~ ′ ⊃ xM ~N ~) ∈ E∆ (xM The proof is similar to the previous part. 2. Let M ∈ EΓ (A). Then using the induction hypothesis M x1 · · · xn ∈ EΓ,x1 :A1 ,...,xn :An (Ω) ⊆ SN, hence M ∈ SN. 3. Let ∆ ⊇ Γ. Let Li , L′i ∈ E∆ (Ai ) and Pi ∈ E∆ (Li =Ai L′i ) for i = 1, . . . , n. We must show that eP~ ≡ eL1 L′1 P1 · · ·Ln L′n Pn ∈ E∆ (M L1 · · · Ln =Ω N L′1 · · · L′n ), i.e. that ~ ⊃ NL ~′ ) (eP~ )+ ∈ E∆ (M L ~′ ⊃ M L) ~ (eP~ )− ∈ E∆ (N L We prove the first of these; the second is similar. ~ Let nf(N L ~ ′ ) ≡ φ1 ⊃ · · · ⊃ φm ⊃ χ, where Let Θ ⊇ ∆. Let δ ∈ EΘ (M L). ~′ ) exists because N L ~ ′ ∈ E∆ (Ω).) Let χ is ⊥ or neutral. (We know nf(N L ǫj ∈ EΘ (φj ) for j = 1, . . . , m. Then we must show that (eP~ )+ δǫ1 · · · ǫm ∈ EΘ (χ) Well-typedness is easy to show, so it remains to show (eP~ )+ δ~ǫ ∈ SN. This holds as each Pi , δ and ǫj is strongly normalizing. 19

4. Let P ∈ EΓ (M =A N ). Let ∆ be the context Γ, x1 : A1 , y1 : A1 , e1 : x1 =A1 y1 , . . . , xn : An , yn : An , en : xn =An yn Then using the induction hypothesis P~e ≡ Px1 y1 e1 · · ·xn yn en ∈ EΓ (M ~x =Ω N ~y ) and so (P~e)+ ∈ EΓ (M ~x ⊃ N ~y ) ⊆ SN, hence P ∈ SN.

Lemma A.5. Let φ be a normalizable term. 1. If p : φ ∈ Γ then p ∈ EΓ (φ). 2. EΓ (φ) ⊆ SN. Proof. The proof is by induction on nf(φ). Let nf(φ) ≡ ψ1 ⊇ · · · ⊇ ψn ⊇ χ, where χ is either ⊥ or a neutral term. 1. Let ∆ ⊇ Γ and ǫi ∈ E∆ (ψi ) for each i. We must show that pǫ1 · · · ǫn ∈ E∆ (χ) It is easy to see that p~ǫ is well-typed, so it remains to show that p~ǫ ∈ SN. This holds because each ǫi is strongly normalizing by the induction hypothesis (2). 2. Let δ ∈ EΓ (φ). Consider the context ∆ ≡ Γ, p1 : ψ1 , . . . , pn : ψn . By the induction hypothesis (1), we have that pi ∈ E∆ (ψi ), hence δp1 · · · pn ∈ EΓ (χ), and so δp1 · · · pn ∈ SN. It follows that δ ∈ SN.

Lemma A.6. 1. Let Γ, x : A, y : A, e : x =A y ⊢ P : M x =B N y. If L, L′ ∈ EΓ (A); Q ∈ EΓ (L =A L′ ) and P [x := L, y := L, e := P ] ∈ EΓ (M L =B N L′ ), then (λλλe : x =A y.P )LL′ Q ∈ EΓ (M L =B N L′ ). 2. Let Γ, p : φ ⊢ δ : ψ. If ǫ ∈ EΓ (φ) and δ[p := ǫ] ∈ EΓ (ψ) then (λp : φ.δ)ǫ ∈ EΓ (ψ). 3. Let Γ, x : A ⊢ M : B and let N ∈ EΓ (A). If M [x := N ] ∈ EΓ (B) then (λx : A.M )N ∈ EΓ (B). Proof. We prove part 3 here; the proofs for the other parts is similar. We shall prove the following stronger statement: Suppose Γ, x : A ⊢ M : B1 → · · · → Bn → C. Let N ∈ EΓ (A) and Ni ∈ EΓ (Bi ) for i = 1, . . . , n. If M [x := N ]N1 · · · Nn ∈ EΓ (C) then (λx : A.M )N N1 · · · Nn ∈ EΓ (C). The proof is by induction on the type C. If C ≡ Ω: it is easy to verify that Γ ⊢ (λx : A.M )N N1 · · · Nn : Ω. Proposition 2.21.1 gives that (λx : A.M )N N1 · · · Nn ∈ SN. 20

~ ). Let nf((λx : A.M )N N ~) ≡ Now let ∆ ⊇ Γ and δ ∈ E∆ ((λx : A.M )N N φ1 ⊃ · · · ⊃ φn ⊃ χ where χ is ⊥ or neutral. Let ǫj ∈ E∆ (φj ) for each j. We must show that ~ ){}+ δǫ1 · · · ǫm ∈ E∆ (χ) ((λx : A.M )N N i.e. ((λλλe : x =A y.M {x := e : x ∼ y})N N N {}N1N1 N1 {} · · ·Nn Nn Nn {})+ δ~ǫ ∈ E∆ (χ) . It is easy to check that this proof is well-typed. We need to prove that it is strongly normalizing. By hypothesis, we have ~ ){}+ δ~ǫ ∈ E∆ (χ) ⊆ SN (M [x := N ]N i.e. (M {x := N {} : N ∼ N }N1 {} · · · Nn {})+ δ~ǫ ∈ SN and so the result follows by Proposition 2.21.3. ~ ){}− is similar. The proof for (λx : A.M )N N If C ≡ Bn+1 → D: let Nn+1 ∈ EΓ (Bn+1 ). Then ~ Nn+1 ∈ EΓ (C) M [x := N ]N ~ Nn+1 ∈ EΓ (C) ∴ (λx : A.M )N N by the induction hypothesis, as required. ′ ′ ). We Now let Nn+1 , Nn+1 ∈ EΓ (Bn+1 ) and P ∈ EΓ (Nn+1 =Bn+1 Nn+1 must show that ~ ){}N N ′ P ((λx : A.M )N N n+1 n+1 ′ ~ Nn+1 =C (λx : A.M )N N ~ Nn+1 ∈ EΓ ((λx : A.M )N N )

i.e. ′ P (λλλe : x =A y.M {x := e})N N N {}N1 N1 N1 {} · · ·Nn Nn Nn {}Nn+1Nn+1

~ Nn+1 = M [x := N ]N N ~ N′ ) ∈ EΓ (M [x := N ]N N n+1 This follows from part 1, since we have M [x := N ]{} ≡ M {x := N {} : N ∼ N } ∈ EΓ (M [x := N ] = M [x := N ])

Lemma A.7. If Γ ⊢ valid then ⊥ ∈ EΓ (Ω).

21

Proof. It is immediate that Γ ⊢ ⊥ : Ω and ⊥ ∈ SN. It remains only to show that ref (⊥) ∈ EΓ (⊥ =Ω ⊥), i.e. that +



ref (⊥) , ref (⊥) ∈ EΓ (⊥ ⊃ ⊥) . +



Let ∆ ⊇ Γ and δ ∈ E∆ (⊥). We must show that ref (⊥) δ, ref (⊥) δ ∈ SN. + Every possible reduction sequence from ref (⊥) δ reduces to (λp : ⊥.p)nf(δ). If nf(δ) is not closed, it terminates here; otherwise, it reduces to nf(δ) and then terminates. Thus, ref (⊥)+ δ ∈ SN. − Similarly for ref (⊥) δ. Our next aim is to prove that, if M ∈ EΓ (A), then ref (M ) ∈ EΓ (M =A M ). In order to prove this, we need the following technical result. Lemma A.8. Suppose: 1. M ∈ EΓ (A1 → · · · → An → Ω). 2. For 1 ≤ i ≤ n, we have Ni , Ni′ ∈ EΓ (Ai ) and Pi ∈ EΓ (Ni =Ai Ni′ ). Then (ref (M )N1 N ′ P1 · · ·Nn Nn′ Pn )+ ∈ EΓ (M N1 · · · Nn ⊃ M N1′ · · · Nn′ ) and (ref (M )N1 N ′ P1 · · ·Nn Nn′ Pn )− ∈ 1 1 EΓ (M N1′ · · · Nn′ ⊃ M N1 · · · Nn ). ~ ⊃ MN ~ ′ ). The proof for Proof. We shall prove that (ref (M ) P~ )+ ∈ EΓ (M N ~ ′ ⊃ MN ~ ). (ref (M ) P~ )− ∈ EΓ (M N It is easy to check that (ref (M ) P~ )+ is well-typed. So we have to show the following. If 1. δ ∈ EΓ (M N1 · · · Nn ); 2. nf(M N1′ · · · Nn′ ) ≡ φ1 ⊃ · · · ⊃ φm ⊃ χ where χ is either ⊥ or a neutral term; 3. for 1 ≤ j ≤ m, we have ǫj ∈ EΓ (φj ); then (ref (M )N1 N ′ P1 · · ·Nn Nn′ Pn )+ δǫ1 · · · ǫm ∈ EΓ (χ). 1 The proof is by induction on n, then on the proofs that M, Ni , Ni′ , Pi , δ, ǫj ∈ SN. 1. Case n = 0: Consider all possible one-step reductions from (ref (M ) P~ )+ δ~ǫ. There are the following possibilities: +

(a) ref (M )+ δ~ǫ → ref (M ′ ) δ~ǫ, where M → M ′ . In this case, the result follows immediately from the induction hypothesis on M . Similarly for the case where we reduce δ or one of the ǫj . +

(b) ref (M ) δ~ǫ → (λp : M.p)δ~ǫ Since δ ∈ EΓ (M ) = EΓ (nf(M )) = EΓ (φ1 ⊃ · · · ⊃ φm ⊃ χ), we have that δ~ǫ ∈ SN. Hence (λp : φ.p)δ~ǫ ∈ SN by Propositiol 2.21.2. 22

2. Induction step Suppose the result holds for n. Consider all possible one-step reductions from (ref (M ) P1 · · · Pn+1 )+ δ~ǫ. There are the following possibilities: (a) (ref (M ) P~ )+ δ~ǫ → (ref (M ′ ) P~ )+ δ~ǫ, where M → M ′ . Just as in Case 1a above, the result follows immediately from the induction hypothesis on M . Similarly for the case where we reduce one of the Pi , δ or ǫj . (b) P1 ≡ ref (L) and (ref (M ) P~ )+ δ~ǫ → (ref (M L) P2 · · · Pn )+ δ~ǫ In this case, we have that M and L are closed normal forms. By Generation, we know N1 ≃ N1′ ≃ L, hence N1 , N1′ ։ L by Confluence, and thus L ∈ EΓ (A1 ). It follows that M L ∈ EΓ (A2 → · · · → An → Ω), and the result follows by the induction hypothesis on n. (c) M ≡ λx : C.L and (ref (M ) P~ )+ δ~ǫ → (L{x := P1 : N1 ∼ N1 }P2 · · · Pn )+ δ~ǫ We have λx : C.L ∈ EΓ (A1 → · · · → An → Ω), and hence (λx : C.L){}N1 N1′ P1 ∈ EΓ (M N1 =A2 →···→An →Ω M N1′ ) , i.e. (λλλe : x =C y.L{x := e})N1 N1′ P1 ∈ EΓ (M N1 =A2 →···→An →Ω M N1′ ) . Noting that M , N1 , N1′ and P1 are closed normal forms, it follows that L{x := e : x ∼ y}[x := N1 , y = N1′ , e := P1 ] ∈ EΓ (M N1 = M N1′ ) , i.e. L{x := P1 : N1 ∼ N1′ } ∈ EΓ (M N1 = M N1′ ) and the desired result follows.

Lemma A.9. If M ∈ EΓ (A) then ref (M ) ∈ EΓ (M =A M ). Proof. We prove the following stronger statement: If M ∈ EΓ (A1 → · · · → An → B) and, for all i, we have Ni , Ni′ ∈ EΓ (Ai ) and Pi ∈ EΓ (Ni =Ai Ni′ ), then ref (M )N1 N ′ (P1 )N2 N2′ · · ·Nn Nn′ Pn ∈ 1 EΓ (M N1 · · · Nn =B M N1′ · · · Nn′ ). The proof is by induction on the type B. ~ =B M N ~ ′ , so it remains to show If B ≡ Ω: we have that Γ ⊢ ref (M ) P~ : M N + ~ ⊃ MN ~ ′ ) and (ref (M ) P~ )− ∈ EΓ (M N ~ ′ ⊃ MN ~ ). that (ref (M ) P~ ) ∈ EΓ (M N These follow from Lemma A.8. ′ If B ≡ An+1 → C, then let Nn+1 , Nn+1 ∈ EΓ (An+1 ) and ′ ′ Pn∗1 ∈ Pn+1 ∈ EΓ (Nn+1 =An+1 Nn+1 ). We must show that ref (M ) P~Nn+1 Nn+1 ′ ′ ~ ~ EΓ (M N Nn+1 =C M N N ). This follows from the induction hypothesis. n+1

23

Lemma A.10. If P ∈ EΓ (φ =Ω φ′ ) and Q ∈ EΓ (ψ =Ω ψ ′ ) then P ⊃∗ Q ∈ EΓ (φ ⊃ ψ =Ω φ′ ⊃ ψ ′ ). Proof. We must prove that (P ⊃∗ Q)+ ∈ EΓ ((φ ⊃ ψ) ⊃ φ′ ⊃ ψ ′ ) and (P ⊃∗ Q)− ∈ EΓ ((φ′ ⊃ ψ ′ ) ⊃ φ ⊃ ψ). We prove the following two stronger statements: 1. Suppose P ∈ EΓ (φ =Ω φ′ ) and Q ∈ EΓ (ψ =Ω ψ1 ⊃ · · · ⊃ ψn ⊃ χ). Let δ ∈ EΓ (φ ⊃ ψ), ǫ ∈ EΓ (φ′ ), and ǫi ∈ EΓ (ψi ) for all i. Then (P ⊃∗ Q)+ δǫǫ1 · · · ǫn ∈ EΓ (χ). 2. Suppose P ∈ EΓ (φ =Ω φ′ ) and Q ∈ EΓ (ψ1 ⊃ · · · ⊃ ψn ⊃ χ =Ω ψ ′ ). Let δ ∈ EΓ (φ′ ⊃ ψ ′ ), ǫ ∈ EΓ (φ), and ǫi ∈ EΓ (ψi ) for all i. Then (P ⊃∗ Q)− δǫǫ1 · · · ǫn ∈ EΓ (χ). We give the details for statement 1 here; the proof for 2 is similar. We prove statement 1 by induction on nf(χ). If nf(χ) is ⊥ or neutral, then we must show that (P ⊃∗ Q)+ δǫ~ǫ ∈ SN. We prove this by a secondary induction on the proofs that P, Q, δ, ǫ, ǫi ∈ SN. The following are the possible one-step reductions from (P ⊃∗ Q)+ δǫ~ǫ: • (P ⊃∗ Q)+ δǫ~ǫ → (P ′ ⊃∗ Q)δǫ~ǫ where P → P ′ . In this case, the result we require follows by the induction hypothesis on P . Similarly if we reduce Q, δ, ǫ or any of the ǫi . ∗

• P ≡ ref (φ), Q ≡ ref (ψ), and (P ⊃∗ Q)+ δǫ~ǫ → ref (φ ⊃ ψ) δǫ~ǫ. Generation gives φ ≃ φ′ and ψ ≃ ψ1 ⊃ · · · ⊃ ψn ⊃ χ. Then the only possible reduction sequence from ref (φ ⊃ ψ)∗ δǫ~ǫ is ref (φ ⊃ ψ)∗ δǫ~ǫ → (λpp)δǫ~ǫ → δǫ~ǫ which is in SN since δ ∈ EΓ (φ ⊃ ψ). • P ≡ univ (α, β), Q ≡ univ (α′ , β ′ ), and + (P ⊃∗ Q)+ δǫ~ǫ → univ (λpq.α′ (p(βq)), λpq.β ′ (p(αq))) δǫ~ǫ. Then the only possible reduction sequence from univ (λpq.α′ (p(βq)), λpq.β ′ (p(αq))) δǫ~ǫ is +

univ (λpq.α′ (p(βq)), λpq.β ′ (p(αq))) δǫ~ǫ → (λpq.α′ (p(βq)))δǫ~ǫ ։ α′ (δ(βǫ))~ǫ Now, we know P − ∈ EΓ (φ′ ⊃ φ) hence β ∈ EΓ (φ′ ⊃ φ), and so βǫ ∈ EΓ (φ). Similarly α′ ∈ EΓ (ψ ⊃ ψ1 ⊃ · · · ⊃ ψn ⊃ χ), and so α′ (δ(βǫ))~ǫ ∈ EΓ (⊥) ⊆ SN as required. • P ≡ univ (α, β), Q ≡ ref (ψ) and (P ⊃∗ Q)+ δǫ~ǫ → univ (λpq.p(βq), λpq.p(αq)) Similar to the above. 24

• P ≡ ref (φ), Q ≡ univ (α, β) and (P ⊃∗ Q)+ δǫ~ǫ → univ (λpq.α(pq), λpq.β(pq)) Similar to the above. If nf(χ) ≡ ψn+1 ⊃ χ′ , then let ∆ ⊇ Γ and ǫn+1 ∈ E∆ (ψn+1 ). The induction hypothesis gives (P ⊃∗ Q)+ δǫ~ǫǫn+1 ∈ E∆ (χ′ ) as required. Lemma A.11. If δ ∈ EΓ (φ ⊃ ψ) and ǫ ∈ EΓ (ψ ⊃ φ), then univφ,ψ (δ, ǫ) ∈ EΓ (φ =Ω ψ). Proof. Similar.

25