(Ventures into) Dependent with Reductions

Sam Speight [email protected]

Spring 2019 Last updated July 7, 2020

In this note we introduce theory with reductions and categories with ordered families, the former being an internal language for the latter. This is motivated by the desire to extend to dependent type theory Gallier’s [Gal95] semantic method for proving metatheoretic properties of type theories involving reduction, which requires se- mantics that distinguishes judgementally equal objects and instead models reductions between them.

1 Introduction and motivation

In [Gal95], Gallier presents a method for proving properties that involve reduction of terms of simply typed λ-calculus and system F; instantiating his method, he proves confluence and strong normalisation for each of these type theories. Gallier’s motivation is to render the (Tait-Girard) “reducibility" method in more semantic terms. Much of the work is carried out at the level of pre-applicative β-structures, novel structures that serve to interpret well-typed terms and reductions between them (and so distinguish between terms that are judgemen- tally equal/convertible). Gallier mentions that he attempted to lift his method to dependent type theory, though ran into a problem that ‘has to do with type-conversion rules: a term no longer has a unique type, and we run into a coherence problem in attempting to define the meaning of term by induction on typing-derivations’; getting round this problem is described as ‘the most pressing open problem’ [Gal95, p. 364]. As far as we understand, the issue is to get a good notion of pre-applicative β-structures for the dependent setting. In this note, we introduce categories with ordered families (CwOFs), a natural higher- dimensional generalisation of Dybjer’s categories with families (CwFs) [Dyb95]. We believe that CwOFs could play the role of pre-applicative β-structures in a lifting of Gallier’s method to dependent type theory. To interpret type theory in CwOFs, as in CwFs, a partial interpre- tation function is given taking untyped syntax to the relevant part of a CwOF; after this it is proved that the interpretation function is defined on well-typed syntax, as is usual when in- terpreting dependent type theory (see [Hof97]. In this way, Gallier’s problem is circumvented. The internal language of CwOFs is a type theory that we call dependent type theory with reductions (DTTwR). As the aim is to give a model of dependent type theory that models reductions between terms and types (reductions can occur between types when types may depend on terms), and so distinguishes between terms and types that are convertible in de- pendent type theory as usually formulated (DTT, which we take to be something like that presented in [Hof97]), this must of course be reflected in DTTwR. Thus we have a notion of judgemental reduction, and we replace computation rules (the β-rule for Π-types, for in- stance) as judgemental equalities with computation rules as judgemental reductions (we do

1 retain a notion of judgemental equality, but this has rather a different role than it usually does). However, due to the dependency of types on terms, modifying judgemental equality has an effect on the typing of terms. Thus, DTTwR bears a non-trivial relationship to DTT. We are yet to relate DTTwR to DTT and untyped reduction, as well as carry out the development of Gallier’s method for dependent type theory using CwOFs. We give some thoughts on the first of these tasks in 4.2 Future work.

2 Dependent type theory with reductions

We work with a relatively straightforward type theory, which has one closed ground type G0, one other ground type G1 depending on terms of type G0 and Π-types. Neither of the ground types are taken to have any term constructors, thus the only term constructors we have are SUB for λ-abstraction, application and coercion A,A0 (t) (see the rule in Figure1). (In this way we have types genuinely depending on terms.) As well as the usual judgements for well-typed contexts, types and terms, and judgemen- tal equality for contexts, types and terms, we have judgemental reduction for types Γ A ` ⇒ A0 type and terms Γ t t 0 : A, with the intuitive meaning that, in the first case, say: in ` ⇒ context Γ the term t of type A reduces to the term t 0 of type A. Judgemental reduction is meant to capture the reflexive transitive closure of β-reduction acting in all contexts (we are not concerned with η here). The typing rules are given in Figure1 (p. 11), with the omission of the usual strucutral rules, the ususal rules saying that judgemental equality is a congruence on type and term for- mers and the usual rules for Π-formation, λ-abstraction and application (see [Hof97, §2]. Im- portantly, judgemental reduction is not symmetric, and we do not make the β-rule a judge- mental equality, but a judgemental reduction. The SUB rule (for “subsumption”, due to its likeness to the eponymous rule in disciplines) coerces a type to a “lower", more reduced, type. Note that whenever we have Γ t t 0 : A we are careful in making sure that t and t 0 should be well-typed with type A in ` ⇒ context Γ (and similarly for types)—it is not as simple as repeating the rues for judgemental equality but without symmetry. For example, in the -Π rule, when giving conditions under ⇒ which Q B reduces t Q B , B and B are compared in context ,x : A; but B expects (x:A) (x:A0) 0 0 Γ 0 the variable x to have type A0, and so in B 0 we replace x by its coercion down to the type A0. The last two rules allow coercions to be pushed inside λ and App. Note that we use fully annotated syntax. However, we take the view that annotations are annotations: they are for the purpose of rigorously interpreting the syntax into the semantics and therefore do not contribute to reductions.

3 Categories with ordered families

Recall that a CwF [Dyb95] (again, see also [Hof97], which we rely on for results and notation, often without explicit mention) involves a functor

Cop Fam, → where C is a category (with a terminal object) and Fam is the category of indexed families of sets. In moving from CwFs to CwOFs, we “bump-up” the dimension of each of the above components—and add to the comprehension axiom that is also required of a CwF. As we have a proof-irrelevant notion of judgemental reduction, we need only add extra layers of preordered structure. First we describe the bumped-up version of Fam.

Definition 3.1. The category OFam (for “ordered families”) is given by the following.

2 • Objects are triples ¡ ¢ I,(Pi )i I ,(ci i )(i i ) Mor(I) , ∈ ⇒ 0 ⇒ 0 ∈ where I and each of the Pi are preorders (with a morphism from a to b in some pre- order denoted by a b), and the ci i : Pi Pi are monotone functions such that: ⇒ ⇒ 0 → 0 ci i idP , ⇒ = i ci i ci i ci i . 0⇒ 00 ◦ ⇒ 0 = ⇒ 00 The ci i are the semantic coercion functions. ⇒ 0 • A morphism (I,(Pi ),ci i ) (J,Q j ,c j j )) is a pair: ⇒ 0 → ⇒ 0 ¡ ¢ f : I J,(fi : Pi Q f (i))i I , → → ∈ where f and each fi are monotone , such that the following square commutes.

ci i ⇒ 0 Pi Pi 0

fi f i0

Q f (i) c Q f (i) f (i)(i0)

Composition and identities are as in Fam: the composition of (f ,(fi )) : (I,(Pi ),(ci i )) ⇒ 0 → (J,(Q j ),(c j j )) and (g,(gi )) : (J,(Q j ),(c j j )) (K ,(Rk ),(ck k )) is given by: ⇒ 0 0 ⇒ 0 → ⇒ 0 (g,(g )) (f ,(f )) : (g f : I K ,g f : P R ). j ◦ i = → f (i) i i → g(f (i))

• A 2-cell (f ,(fi )) (g,(gi )) : (I,(Pi ),ci i ) (J,(Q j ),(c j j ))) is determined pointwise ⇒ ⇒ 0 → ⇒ 0 in the codomain; that is, there is a 2-cell (f ,(f )) (g,(g )) whenever: i ⇒ i (i) i i 0 I. f (i) g(i 0) J, and ∀ ⇒ ∈ ⇒ ∈ (ii) i i 0 I and p Pi ,p0 Pi such that ci i (p) p0 Pi we have that: ∀ ⇒ ∈ ∀ ∈ ∈ 0 ⇒ 0 ⇒ ∈ 0 c f (i) g(i )(fi (p)) gi (p0) Qg(i ). ⇒ 0 ⇒ 0 ∈ 0 y We use this category in the definition of CwOFs as follows. Definition 3.2. A category with ordered families is given by a preordered 2-category C (in which a 2-cell between f and g is denoted f g) with a (1-)terminal object and a preordered ⇒ 2-functor F : Cop OFam, → ¡ ¢ (where, like with CwFs, we write F Γ as Ty(Γ),(Tm(Γ, A))A Ty(Γ),(cA A )A A Ty(Γ) and we ∈ ⇒ 0 ⇒ 0∈ write both components of the morphism (Ty,Tm)(f : Γ ∆) as ( ){f }; 2-cells—as well as → − preorder relations—are aslways written with ), such that the following comprehension ax- ⇒ iom is satisfied. For any Γ C and A Ty(Γ) there is an object Γ.A C and a morphism p(A): Γ.A A and ∈ ∈ ∈ → semantic term v Tm(Γ.A, A{p(A)}) such that for any f : ∆ Γ and t Tm(∆, A{f }) there is A ∈ → ∈ a unique morphism f ,t : ∆ Γ.A such that the following commutes. 〈 〉A →

v A Γ.A

( ){ f ,t A } − 〈 〉 p(A) f ,t A 〈 〉 t ∆ Γ f

3 (This much is the comprehension axiom for CwFs.) Moreover, whenever A A0 Ty(Γ) ⇒ ∈ we have a unique morphism r (A, A0): Γ.A Γ.A0 in C such that p(A0) r (A, A0) p(A) and → ◦ = v A {r (A, A0)} cA A (v A) and whenever t t 0 Tm(∆, A{f }) then f ,t A f ,t 0 A. y 0 = ⇒ 0 ⇒ ∈ 〈 〉 ⇒ 〈 〉

In terms of type theory, the morphism r (A, A0) allows us to put something in context Γ,x : A0 in context Γ,x : A, such as we do in the -Π rule in Figure1. ⇒ Forgetting all the preordered structure (in the base category C and in the preorders in OFam) in a CwOF gives a CwF. CwOFs, as defined above, model the structural core of DTTwR. If we want G0, G1 and Π-types in our type theory, we must equip our CwFs with extra structure. This is similar to adding the relevant extra structure to CwFs, though we require different equations and some “inequations”. We use Π-types as a representative example.

Definition 3.3. A CwOF supports Π-types iff for every Γ C and every A Ty(Γ) and B ∈ ∈ ∈ Ty(Γ.A) there is a semantic type Π(A,B) Ty(Γ) ∈ such that whenever A A0 Ty(Γ) and B 0 Ty(Γ.A0) with B B 0{r (A, A0)} Ty(Γ.A) we have ⇒ ∈ ∈ ⇒ ∈ that Π(A,B) Π(A0,B 0) Ty(Γ); ⇒ ∈ and there is a monotone function

λ ( ) : Tm(Γ.A,B) Tm(Γ,Π(A,B)); A,B − → and for every t Tm(Γ,Π(A,B)) and u Tm(Γ, A) there is a semantic term ∈ ∈ App (t,u) Tm(Γ,B{ id ,u }) A,B ∈ 〈 Γ.A 〉B such that if t t 0 Tm(Γ,Π(A,B)) and u u0 Tm(Γ, A) then ⇒ ∈ ⇒ ∈

App (t,u) App (t 0,u0) Tm(Γ,B{ id ,u }); A,B ⇒ A,B ∈ 〈 Γ.A 〉B subject to the appropriately typed universal closure of the following (in)equations: first, say- ing how substitution interacts with the semantic type and term formers:

Π(A,B){f } Π(A{f },B{q(f , A)}) = λA,B (t){f } λ q (t{q(f , A)}) = A{f },B{ (f ,A)} App (t,u){f } App (t{f },u{f }); A,B = A{f },B{q(f ,A)} next, the β-reduction inequality:

M{ id ,u } App (λ (t),u); 〈 Γ 〉B ⇒ A,B A,B and, finally, two equations specifying how semantic coercions interact with the semantic term formers: if A A0 Ty(Γ), B Ty(Γ.A) and B 0 Ty(Γ.A0) with B B 0{r (A, A0)} Ty(Γ.A) ⇒ ∈ ∈ ∈ ⇒ ∈ then

¡ ¢ ¡ ¢ cB{id ,u} B {r (A,A )} App (t,u) AppA ,B cΠ(A,B) Π(A0,B0)(t),cA A0 (u) Γ ⇒ 0 0 A,B = 0 0 ⇒ ⇒ ¡ ¢ cΠ(A,B) Π(A ,B ) λA,B (t) λA ,B (cB B (t)). ⇒ 0 0 = 0 0 ⇒ 0 Equations corresponding to congruence rules for or are not needed, for everything pre- ≡ ⇒ serves equality and the relevant functions are monotone. y

4 3.1 Soundness properties The interpretation of DTTwR in CwOFs is the same as for DTT in CwFs (see [Hof97, §3], with the added clause that Γ;c (t) : c ¡ Γ;t ¢. A,A0 Γ;A Γ;A0 J K = J K⇒J K J K Theorem 3.4 (Soundness). The interpretation function enjoys the following soundness prop- erties.

(i) If Γ ctxt then Γ is an object in C. J K (ii) If Γ A type then Γ; A Ty¡ Γ ¢. ` J K ∈ J K (iii) If Γ t : A then Γ;t Tm¡ Γ , Γ; A ¢. ` J K ∈ J K J K (iv) If Γ ∆ ctxt then Γ ∆ C. ≡ J K = J K ∈ ¡ ¢ (v) If Γ A A0 type then Γ; A Γ; A0 Ty Γ . ` ≡ J K = J K ∈ J K ¡ ¢ (vi) If Γ t t 0 : A then Γ;t Γ;t 0 Tm Γ , Γ; A . ` ≡ J K = J K ∈ J K J K ¡ ¢ (vii) If Γ A A0 type then Γ; A Γ; A0 Ty Γ . ` ⇒ J K ⇒ J K ∈ J K ¡ ¢ (viii) If Γ t t 0 : A then Γ;t Γ;t 0 Tm Γ , Γ; A . ` ⇒ J K ⇒ J K ∈ J K J K This will be proved by induction over derivations. We use, as expected, a weakening lemma and a substitution lemma, relating weakening and substitution in the semantics to the respective notions in the type theory. These lemmas are as for CwFs [Hof97, Lemma 3.36 & Lemma 3.37]. We moreover need a lemma, in much the same spirit, which relates, on the one hand, the syntactic act of taking a type or term in context Γ,x : A0 and putting it in context Γ,x : A supposing that Γ A A0 type with, on the other hand, the semantic act of ` ⇒ substitution by the morphism r (A, A0) or a weakening thereof.

Definition-lemma 3.5 (R-lemma). Let Γ and ∆ be pre-contexts, A and A0 be pre-types and x be a fresh variable. We define the expression R(Γ; A; A0,∆) by induction on the length of ∆ as follows.

R(Γ; A; A0; ): r (A, A0) ¦ = ¡ ¢ R(Γ; A; A0,∆, y : B): q R(Γ; A; A0,∆), Γ,x : A0,∆;B = J K where q(f , A): f p(A{f }),v : Γ.A{f } Γ.A is the “weakening of the context morphism = 〈 ◦ A{f }〉A → f : Γ ∆ by the semantic type A Ty(∆)." → ∈ Moreover, let X {t,B} where t is a pre-term and B is a pre-type. Then the expression ∈ R(Γ; A; A0,∆) is a morphism Γ,x : A,∆ Γ,x : A0,∆ if these interpretations are defined, and → if Γ; A Γ; A0 Ty(Γ) thenJ K J K J K ⇒ J K ∈ © ª Γ,x : A,∆[cA,A (x)/x]; X [cA,A (x)/x] Γ,x : A0,∆; X R(Γ; A; A0;∆) , J 0 0 K ' J K where φ ψ means that if either φ or ψ are defined then so is the other and both agree (Kleene ' equality).

Proof. The proof of the Kleene equality is by nested induction, first on the structure of X and then on the length of ∆. We only need to apply the R-lemma in the case that ∆ , but being able to induct on the = ¦ length of ∆ makes the proof go through.

5 We give the case where X t is a variable z, for this is where most of the action happens. = First let ∆ be empty. If it’s not the case that either z x or z Γ,∆ then both sides are = ¦ = ∈ undefined. If z x then = © ª © ¡ ¢ª Γ,x : A0;x R(Γ; A; A0; ) v r Γ; A , Γ; A0 Γ;A0 J K ¦ ' J K J K J K c (v ) (by the comprehension axiom of CwOFs) Γ;A , Γ;A0 Γ;A = J K J K J K Γ,x : A;cA A (x) = J ⇒ 0 K Γ,x : A;x[cA A (x)/x] = J ⇒ 0 K as required. If z Γ, so let Γ (Γ ,z : D,Γ ), then ∈ = 1 2 © ª Γ,x : A0;z R(Γ; A; A0; ) J © ¡ K ¢ ¡ ¦ ¢ª Γ;z p Γ; A0 r Γ; A , Γ; A0 'J K© ¡J K¢ª◦ K K J K Γ;z p Γ; A (by the comprehension axiom, given Γ; A Γ; A0 ) =J K J K J K ⇒ J K Γ,x : A;z =J K Γ,x : A;z[cA A (x)/x] . =J ⇒ 0 K Now let ∆ ∆, y : C. Again, if it’s not the case that either z x or z Γ,∆ then both sides = = ∈ are undefined. So let z x. Then = © ª Γ,x : A0,∆, y : C;x R(Γ; A; A0;∆, y : C) J © ¡ K ¢ ª Γ,x : A0,∆;x p Γ,x : A0,∆;C R(Γ; A; A0;∆, y : C) 'J K J K ◦ © ¡ c c ¢ª Γ,x : A0,∆;x R(Γ; A; A0;∆) p Γ,x : A,∆[ A A0 (x)/x];C[ A A0 (x)/x] (?) =J K ◦ J © ¡ ⇒ ⇒ K ¢ª Γ,x : A,∆[cA A (x)/x];x[cA A (x)/x] p Γ,x : A,∆[cA A (x)/x];C[cA A (x)/x] (IH) =J ⇒ 0 ⇒ 0 K J ⇒ 0 ⇒ 0 K Γ,x : A,∆[cA A (x)/x], y : C[cA A (x)/x];x[cA A (x)/x] =J ⇒ 0 ⇒ 0 ⇒ 0 K as required, where the equality (?) holds because the following square commutes

R(Γ;A;A0;∆,y:C) Γ,x : A,∆[cA A (x)/x], y : C[cA A (x)/x] Γ,x : A0,∆, y : C J ⇒ 0 ⇒ 0 K J K

p( Γ,x:A,∆[cA A (x)/x];C[cA A (x)/x] ) p( Γ,x:A0,∆;C ) J ⇒ 0 ⇒ 0 K J K c Γ,x : A,∆[ A A0 (x)/x] Γ,x : A0,∆ , J ⇒ K R(Γ;A;A0;∆) J K as we have: ¡ ¢ p Γ,x : A0,∆;C R(Γ; A; A0;∆, y : C) ¡J K¢ ◦ ¡ ¢ p Γ,x : A0,∆;C q R(Γ; A; A0,∆), Γ,x : A0,∆;C = ¡J K¢ ◦ ­ J¡ K © ª¢ p Γ,x : A0,∆;C R(Γ; A; A0,∆) p Γ,x : A0,∆;C R(Γ; A; A0,∆) , = J K ◦ ◦ J K v ® Γ,x:A0,∆;C {R(Γ;A;A0,∆)} Γ,x:A0,∆;C ¡ J K© J ª¢ K R(Γ; A; A0,∆) p Γ,x : A0,∆;C R(Γ; A; A0,∆) (by comprehension) = ◦ ¡J K ¢ R(Γ; A; A0;∆) p Γ,x : A,∆[cA A (x)/x];C[cA A (x)/x] (IH). = ◦ J ⇒ 0 ⇒ 0 K Finally we have the case where z Γ, which is proved using the commutativity of the above ∈ square as well as the induction hypothesis.

Proof of Soundness. As mentioned, the proof proceeds by induction on derivations. We show the -Π case of clause (vii) for it uses the R-lemma. One can see that the (in)equations in ⇒

6 Definition 3.3 have been designed precisely to validate the rules in Figure1; similarly, the semantic coercions are designed to model coercions in the syntax. ¡ ¢ ¡ ¢ ¡ ¢ We want to show that Π Γ; A , Γ,x : A;B Π Γ; A0 , Γ,x : A0;B 0 Ty Γ . By the ⇒ ¡ ¢ ∈ ¡ ¢ induction hypothesis, we haveJ thatK JΓ; A ΓK; A0 TyJ Γ K ,J Γ,x : A;B K Ty ΓJ,xK: A and ¡ ¢ ⇒ ∈ ∈ ¡ ¢ Γ,x : A0;B 0 Ty Γ,x : A0 with ΓJ,x : KA;BJ ΓK,x : AJ;BK0[cJ (x)/x] K Ty JΓ,x : A K . We ∈ ⇒ A,A0 ∈ have:J K J K J K J K J K

Γ,x : A;B J K c Γ,x : A;B 0[ A,A0 (x)/x] ⇒J © K ª Γ,x : A0;B 0 R(Γ; A; A0; ) (by the R-lemma, given Γ,x : A0;B 0 is defined by IH) =J K© ¡ ¦ ¢ª J K Γ,x : A0;B 0 r Γ; A , Γ; A0 . =J K J K J K Looking at Definition 3.3, we have the desired result.

3.2 The term model The term model is constructed in much the same way as for CwFs. The base category is the category of contexts and context morphisms, each up to judgemental equality (though we shall denote an equivalence class by a representative), where we always assume the variables in a context obey a canonical order, eg. (x1 : A1,x2 : A2,x3 : A3); the terminal object is the empty context. There is a 2-cell between context morphisms

f (f ,..., f ) g (g ,...,g ): Γ ∆ (x : A ,...,x : A ) = 1 n ⇒ = 1 n → = 1 1 n n whenever the following n judgements hold.

Γ f g : A ` 1 ⇒ 1 1 Γ c (f ) g : A [g /x ] ` A2[f1/x1],A2[g1/x1] 2 ⇒ 2 2 1 1 ...

Γ cAn [f1/x1,...,fn 1/xn 1],An [g1/x1,...,gn 1/xn 1](fn) gn : An[g1/x1,...,gn 1/xn 1] ` − − − − ⇒ − − The sets Ty(Γ) and Tm(Γ, A) are the set of types up to in context Γ and terms up to ≡ of type in context Γ, respectively, where the ordering is given by judgemental reduction, ≡ eg. A A0 Ty(Γ) iff Γ A A0 type. Semantic substitution is given by (simultaneous) ⇒ ∈ ` ⇒ substitution in the syntax. Everything appearing in the CwFs part of the comprehension axiom is as usual. We are only left to define: ¡ ¢ r (A, A0): Γ,xn : A Γ,xn : A0 : x1,...,xn 1,cA,A (xn) , → = − 0 where Γ (x1 : A1,...,xn 1 : An 1) and A A0 Ty(Γ). = − − ⇒ ∈ The above constructions are well-defined and do indeed have the relevant categorical or monotonicity properties due to the following lemma.

Lemma 3.6. If f g : Γ ∆, for context morphisms f ,g of the given type, and ∆,Θ t t 0 : ⇒ → ` ⇒ A, where Θ (x : B ,...,x : B ) is a pre-context, then = 1 1 n n Γ,Θ[f ] c (t[f ]) t 0[g][c (x )/x ,...,c (x )/x ]: A[g]. ` A[f ],A[g] ⇒ B1[f ],B1[g] 1 1 Bn [f ],Bn [g] n n A similar result holds for jdugemental reduction of types.

This lemma relies on the usual admissibility of the rule

Γ,x : A,∆ t t 0 : C Γ u u0 : A ` ⇒ ` ⇒ Subst, Γ,∆[u/x] c (t[u/x]) ⇒ − ` A[u/x],A[u0/x] t 0[u0/x][c (y )/y ,...,c (y )/y ]: C[u0/x] ⇒ B1[u/y1],B1[u0/y1] 1 1 Bn [u/yn ],Bn [u0/yn ] n n

7 where ∆ (y : B ,..., y : B ), as well as a similar rule for judgemental reduction of types. = 1 1 n n Morally (squinting so that the coercions dissappear), this above rule says that: “if t t 0, both ⇒ t and t 0 having a free variable x, and u u0 then the substitution t[u/x] t 0[u0/x] preserves ⇒ ⇒ ." (As with the R-lemma, we really only need the case of ∆ , but the case of non-empty ⇒ = ¦ ∆ lets an inductive proof go through.)

4 Conclusions

4.1 Related work The idea of using higher categories to model reductions in type theory goes back, as far as we know, to Seely [See87], who treated simply typed λ-calculus with cartesian closed 2- categories. As well as Gallier, there has been other work using semantic tools to prove metatheoretic properties of type theories involving reduction. In particular, Plotkin gives a semantics for Curry’s system of F-deducibility and uses it to prove the admissibility of subject reduction and the non-admissibility of subject expansion. Inspired by Seely, Hilken [Hil96] formulates the simply tpyed 2λ-calculus (2λ), which is simply typed λ-calculus extended with a proof-relevant reduction judgement. 2λ has seman- tics in 2-categories with finite products and lax exponentials. The main result of the paper is the solution to the word problem for 2λ. van Doorn, Geuvers and Wiedijk [vDGW13] formulate pure type systems with explicit conversions. This has the consequence that the tpying derivation of a term has exactly the same shape as the term itself. It should be possible to modify our work to handle a notion of proof-relevant judgemental equality like this, turning preordered structure into fully-fledged categories. Hirschowitz [Hir13] shows that cartesian closed 2-categories provide a sound and com- plete semantics for permutation equivalence in higher-order rewriting (for instance, the usual notion of reduction in simply typed λ-calculus). Jay [Jay92] models confluent higher-order rewrite systems in confluent categories; in par- ticular, simply typed λ-calculus is modelled in confluent cartesian closed categories. These models bear a functorial relationship to the usual (1-categorical) semantics of the equational theories.

4.2 Future work We have presented the syntax of dependent type theory with reductions and its semantics in categories with ordered families. It would be interesting to consider other variants of categor- ical semantics for dependent type theory (eg. comprehension categories[Jac99]), modified for reductions, in order to better situate the current structures in the mathematical land- scape. We believe that our work is the first attempt to model reduction in dependent type the- ory. As mentioned above, things get more complicated here, for the equational theory is in- tertwined with typing. Perhaps semantic methods can give new insight into open problems, such as the conjecture of Barendregt–Geuvers–Klop that every weakly normalising pure is strongly normalising (see eg. [SU06, §14]). We have yet to relate DTTwR to DTT and untyped reduction, as well as carry out the de- velopment of Gallier’s method for dependent type theory using CwOFs. Conjecture. On the first of these tasks, we believe that every well-typed term of DTT up to judgemental equality should arise as the “erasure” of some well-typed term of DTTwR, where the erasure function recursively strips the coercions from a term of DTTwR (giving a term

8 in the grammar of DTT), and similarly for types and contexts of DTT. It would seem that a stronger hypothesis is needed to put through an inductive proof (as is not unusual, though we have not managed to find one yet), and we may need to use some properties of reduction (either typed judgements or untyped) such as confluence or subject reduction. On the other hand, for any well-typed judgement in DTTwR, if that of judgement is present in DTT (so everything bar judgemental reduction) then the erasure of that judgement is well-typed in DTT; and the erasure of the types/terms occurring either side of in any judgemental ⇒ reduction are related (covariantly) by the usual untyped notion of reduction ∗. →β With the advent of homotopy type theory (HoTT) [Uni13], there has been much work relating type theories and higher categories. We wonder whether some principles in this work could be used in relation to HoTT, with “paths” (terms of an identity type) in the place of reductions—of course, the structure of paths is symmetric—where computation rules may be given only up to a path. One might wonder what would happen if we were to bump things up and go from judgemental reduction to a reduction type. This may relate to recent attempts to formulate a “directed type theory" [LH12, Nuy15, Nor18]. Finally, it may also be possible to use this work in order to study (the semantics of) depen- dent type theories with subtyping [LS99, AC01, YO17]. The latter two of the previously cited papers discuss the difficulties with having subtyping entangled with typing—like reduction and typing in DTTwR. Consider the -Π rule from Figure1. This has in common with the ⇒ corresponding rule from subtyping that B and B 0 are compared in the “stronger" context in- volving A rather than A0. However, here Π is covariant in both its second and first argument, whereas in subtyping Π is contravariant in its first arguement.

5 Acknowledgements

I thank Samson Abramsky for many discussions about this work and Sam Staton for encour- aging me to think harder about implicit vs. explicit coercions. The author was supported by an EPSRC Doctoral Training Partnership.

References

[AC01] David Aspinall and Adriana Compagnoni. Subtyping dependent types. Theoreti- cal , 266(1):273 – 309, 2001.

[Dyb95] Peter Dybjer. Internal type theory. In International Workshop on Types for Proofs and Programs, pages 120–134. Springer, 1995.

[Gal95] Jean Gallier. Proving properties of typed lambda terms: Realizability, covers, and sheaves. Theoretical Computer Science, 142(2):299–368, 1995.

[Hil96] Barnaby P Hilken. Towards a proof theory of rewriting: the simply typed 2λ- calculus. Theoretical Computer Science, 170(1-2):407–444, 1996.

[Hir13] Tom Hirschowitz. Cartesian closed 2-categories and permutation equivalence in higher-order rewriting. Logical Methods in Computer Science, 9(3):10, 2013.

[Hof97] Martin Hofmann. Syntax and semantics of dependent types. In Semantics and logics of computation, volume 14 of Publictions of the Newton Institute, pages 79– 130. Cambridge University Press, Cambridge, 1997.

[Jac99] Bart Jacobs. Categorical logic and type theory, volume 141 of Studies in Logic and the Foundations of Mathematics. Elsevier, 1999.

9 [Jay92] C Barry Jay. Modelling reduction in confluent categories. In Applications of Cate- gories in Computer Science: Proceedings of the London Mathematical Society Sym- posium, Durham 1991, volume 177, page 143. Cambridge University Press, 1992.

[LH12] Daniel R Licata and Robert Harper. Canonicity for 2-dimensional type theory. ACM SIGPLAN Notices, 47(1):337–348, 2012.

[LS99] Zhaohui Luo and Sergei Soloviev. Dependent coercions11this work is partly sup- ported by the uk epsrc grant on “subtyping, inheritance and reuse” (gr/k79130). Electronic Notes in Theoretical Computer Science, 29:152 – 168, 1999. CTCS ’99, Conference on Category Theory and Computer Science.

[Nor18] Paige Randall North. Towards a directed homotopy type theory. CoRR, abs/1807.10566, 2018.

[Nuy15] Andreas Nuyts. Towards a directed homotopy type theory based on 4 kinds of vari- ance. MA thesis, KU Leuven, 2015.

[See87] R. A. G. Seely. Modelling computations: A 2-categorical framework. In Proceed- ings of the Symposium on Logic in Computer Science (LICS ’87), Ithaca, New York, USA, June 22-25, 1987, pages 65–71, 1987.

[SU06] M.H. Sørensen and P. Urzyczyn. Lectures on the Curry-Howard Isomorphism. Number v. 10 in Lectures on the Curry-Howard isomorphism. Elsevier, 2006.

[Uni13] The Univalent Foundations Program. Homotopy Type Theory: Univalent Foun- dations of Mathematics. https://homotopytypetheory.org/book, In- stitute for Advanced Study, 2013.

[vDGW13] Floris van Doorn, Herman Geuvers, and Freek Wiedijk. Explicit convertibility proofs in pure type systems. In Proceedings of the Eighth ACM SIGPLAN inter- national workshop on Logical frameworks & meta-languages: theory & practice, pages 25–36. ACM, 2013.

[YO17] Yanpeng Yang and Bruno C. d. S. Oliveira. Unifying typing and subtyping. Proc. ACM Program. Lang., 1(OOPSLA):47:1–47:26, October 2017.

10 Γ t t 0 : A Γ t t 0 : A Γ t 0 t 00 : A ` ≡ -REFL-TM ` ⇒ ` ⇒ -TRANS-TM Γ t t 0 : A ⇒ Γ t t 00 : A ⇒ ` ⇒ ` ⇒

Γ A A0 type Γ A A0 type Γ A0 A00 type ` ≡ -REFL-TY ` ⇒ ` ⇒ -TRANS-TY Γ A A0 type ⇒ Γ A A00 type ⇒ ` ⇒ ` ⇒

Γ t : A Γ A A0 type Γ t t 0 : A Γ A A0 type ` ` ⇒ SUB ` ⇒ ` ⇒ -SUB Γ c (t): A0 Γ c (t) c (t 0): A0 ⇒ ` A,A0 ` A,A0 ⇒ A,A0 B Q Γ λ(x : A).t : (x:A)B Γ u : A ` ` Π-β Γ App (λ(x : A).t B ,u) t[u/x]: B[u/x] ` (x:A)B ⇒ Q Γ t t 0 : (x:A)B Γ u u0 : A ` ⇒ ` ⇒ -App Γ c (App (t,u)) App (t 0,u0): B[u0/x] ⇒ ` B[u/x],B[u0/x] (x:A)B ⇒ (x:A)B

Γ,x : A t t 0 : B ` ⇒ -λ B B Q Γ λ(x : A).t λ(x : A).t 0 : B ⇒ ` ⇒ (x:A)

Γ A A0 type ` ⇒ Γ,x : A B type Γ,x : A0 B 0 type Γ,x : A B B 0[c (x)/x] type ` ` ` ⇒ A,A0 Q Q -Π Γ B B 0 type ⇒ ` (x:A) ⇒ (y:A0)

Γ t t 0 : G0 ` ⇒ -G1 Γ G (t) G (t 0) type ⇒ ` 1 ⇒ 1

Γ t : A Γ A A0 type Γ A A0 Γ A0 A00 Γ t : A ` ` ≡ c-REFL ` ⇒ ` ⇒ ` c-TRANS Γ c (t) t : A Γ c (c (t)) c (t): A00 ` A,A0 ≡ ` A0,A00 A,A0 ≡ A,A00

Γ A A0 type ` ⇒ Q Γ,x : A0 B 0 type Γ,x : A B B 0[cA,A (x)/x] type Γ t : (x:A)B Γ u : A ` ` ⇒ 0 ` ` c-App Γ cB[u/x],B [c (u)/x](App(x:A)B (t,u) ` 0 A,A0 Q Q App(x:A )B (c (x:A) B, B (t),cA,A (u)) : B 0[cA,A (u)/x] ≡ 0 0 (x:A0) 0 0 0

Γ A A0 type ` ⇒ Γ,x : A0 B 0 type Γ,x : A B B 0[cA,A (x)/x] type Γ,x : A t : B ` ` ⇒ 0 ` c-λ Q Q B B0 Q Γ c (x:A) B, B (λ(x : A).t ) λ(x : A0).(cB,B (t)) : (x:A )B 0 ` (x:A0) 0 ≡ 0 0

Figure 1: some typing rules for DTTwR.

11