Categorical Models of Dependent Type Theory - CiteSeerX

mation η from F to G associates to each element X of C a D-morphism ηX ... GG G(Y ). While the definition of a category is very general, we often need to add ...
262KB taille 77 téléchargements 348 vues
Master 1 Internship

ENS Lyon Master d’Informatique Fondamentale

Categorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter Dybjer

¨ gskola Chalmers Tekniska Ho ¨ teborg, Sverige Go June - August 2006

Contents Contents

2

1 Introduction

3

2 Categorical Definitions 2.1 Basic Categorical Notions 2.2 (Locally) Cartesian Closed 2.3 Indexed Categories . . . . 2.4 Categories with Families .

. . . .

. . . .

. . . .

. . . .

. . . .

4 4 7 9 9

3 Equivalences of Categorical Models 3.1 Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 From Categories with Families to Indexed Categories. . . . . . . . . . . . 3.3 . . . And Back . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Functor C → Fam . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.2 Obtaining a full Category with Families . . . . . . . . . . . . . . 3.4 From Categories with Families to Locally Cartesian Closed Categories. . . 3.5 . . . And Almost Back . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

12 12 12 13 13 14 15 15

4 From Finite Limits to Families 4.1 Statement of the problem . . . . . . . . . . . . 4.2 Hofmann’s Solution . . . . . . . . . . . . . . . . 4.2.1 Goal . . . . . . . . . . . . . . . . . . . . 4.2.2 Functor C op → Fam . . . . . . . . . . . 4.2.3 Context Comprehension and Projections 4.2.4 Substitutions . . . . . . . . . . . . . . . 4.2.5 Checking of the definitions . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

16 16 16 16 16 17 18 18

. . . . . . . Categories . . . . . . . . . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . . . .

. . . .

. . . . .

. . . . . . .

5 Conclusion

21

References

22

Abstract Category theory is known to provide “good” models of type theory, such as indexed categories, locally cartesian closed categories or the more recent categories with families. Extending the work of Pierre Clairambault, who proved that categories with families with some extra structure were locally cartesian closed, we are interested in finding equivalences between all those models. In the last part of this report, we will adapt Hofmann’s solution to a problem in interpreting dependent type theory in locally cartesian closed categories to categories with families.

2

1. Introduction Category theory was first introduced in the 40s as a way to abstract mathematical structure and model transformations between such structures. Lambek[LS86] later showed that some categorical structure, namely the cartesian closed categories which had been introduced a few years earlier by Lawvere, could be proved equivalent to the simply typed λ-calculus, which was known since the 40s. This was an early example of the strong links between category theory and type theory. There are many reasons to study such links, especially as category theory has been studied a lot and has thus many results that are useful for defining models. It also helps to define what exactly it means to be a model of dependent type theory. Another reason is that some flavours of type theory don’t have yet a definite formulation. By providing some models linked with a given syntax, one could help “legitimate” it. Paradoxically, those models allow to abstract from the syntax and all the issues it usually generates, like alpha-conversion, and focus instead on the structural notions. While many categorical models have been studied over the years, we are here interested in a specific notion: categories with families, introduced by Peter Dybjer[Dyb95], which are a variant of Cartmell’s categories with attributes. As many categorical models, they make substitutions and context morphisms part of the structure rather than define them afterwards. Their main interest is that they can be defined equationally as a generalized algebraic theory (GAT), which is an algebraic theory where the sorts may depend on elements of other sorts. The rules of the generalized algebraic theory of categories with families are closely related to the substitution calculus formulation of Martin-L¨ of type theory, see [Tas93]. Dybjer used categories with families in his approach to “internal type theory”, the goal of which is to formalize the metatheory (including models of fragments of Martin-L¨ of type theory) inside the language of Martin-L¨of type theory itself. Samuel Mimram recently proved[Mim04] that categories with families with extra structure were equivalent to LF, Martin-L¨ of’s logical framework, a λ-calculus with dependent types. Then Pierre Clairambault[Cla05] proved that categories with families with some carefully chosen extra structure could be transformed in locally cartesian closed categories or hyperdoctrines, whose exact power is well-known. We are also relying on the work of Jacobs with fibrations, Seely[See84] who exposed links between locally cartesian closed categories and dependent type theory, and Hofmann[Hof97] who proved many results on categories with families. Our contribution is to prove links between all those models, in particular indexed categories and the converse of Pierre’s result. A last part of the work presented here is to prove that Hofmann’s solution[Hof94] to the problem of substitution up to isomorphism still works with categories with families.

3

2. Categorical Definitions In this first section, we will present the categorical notions which we will use in the rest of the report. For space reasons, definitions will have to stay as short as possible, a much more complete introduction to category theory can be found in, for instance, [BW90].

2.1

Basic Categorical Notions

A category can be seen as a way to abstract mathematical structures and provide some sort of general framework. Definition 2.1.1 (Category ) A category C is made of: • A collection |C| of objects. • For all elements A, B of |C|, a collection Hom(A, B) of arrows, or morphisms from A f

to B. If f ∈ Hom(A, B), we usually note f : A → B or A → B. A is called domain and B codomain of f . • For all objects A, there is an identity arrow idA : A → A. • For all objects A, B, C, for all arrows f : A → B, g : B → C, there is a composite arrow g ◦ f : A → C. We also require the following two conditions to hold: • Neutrality: For all objects A, B, for all arrows f : A → B, f ◦ idA = f = idB ◦ f . f

g

h

• Associativity: For all A → B → C → D, h ◦ (g ◦ h) = (h ◦ g) ◦ f . An elementary and intuitive example of category is Set, the category where objects are sets and arrows are total functions between those sets. Identity and composition have their usual meaning. Another important notion is the one of functor, which is a mapping between two categories that preserves their structure: Definition 2.1.2 (Functor ) If A and B are two categories, we say that F is a functor from A to B if: • For all X ∈ |A|, there is an object F (X) of |B|. • For all g : X → Y in A, there is an arrow F (g) : F (X) → F (Y ) in B. For F to be well defined, we also require that: • F (idA ) = idF (A) • F (g ◦ h) = F (g) ◦ F (h).

A direct consequence is that we can define Cat, the category of categories, with functors as arrows. The next step is to define what a natural transformation is. It is an important notion, of which it has been said that the whole category theory was invented just for its definition. 4

Definition 2.1.3 (Natural Transformation) Let C and D be two categories, and F and G two functors from C to D. A natural transformation η from F to G associates to each element X of C a D-morphism ηX : F (X) → G(X) such that for every C-morphism f : X → Y , the following diagram commutes: F (X)

F (f )

/ F (Y )

ηX

ηY

 G(X)

G(f )

 / G(Y )

While the definition of a category is very general, we often need to add some extra structural conditions to be able to prove interesting properties. Here come some such conditions which we will use in this report. N.B. 1 In category theory, properties are often stated via commuting diagrams, which is a visual and elegant way of expressing complex algebraic equalities involving compositions. To say that the following diagram commutes is equivalent to saying that g 0 ◦ f = f 0 ◦ g: A

f

g0

g  C

/B

f0

 /D

Definition 2.1.4 (Binary Product) Let C be a category and A and B be two objects of C. A binary product of A and B is an object A×B and two morphisms π1 : A×B → A and π2 : A×B → B such that for any object Z and morphisms f1 : Z → A and f2 : Z → B, there is a unique morphism h : Z → A × B such that the following diagram commutes: Z z  DD zz  DDD z DD f2 zz  DD zz h DD  z z f1 DD z  z D" z | z π 2 /B A × B Ao π1

More important to us is the notion of pullback, as it is very closely related to the interpretation of substitution in some models of type theory.

5

Definition 2.1.5 (Pullback ) In the following diagram, A0/ @OOO // @ OOO // @ OOOO // @ h OOOO h2 OOO // @ @ OOO // OOO @ OOO // @ OOO @ // O' f // /B A h1 / // // // g0 // g // //   f0 /D C the inner square is said to be a pullback if it commutes and for any object A0 and arrows h1 : A0 → C, h2 : A0 → B such that g 0 ◦ h2 = f 0 ◦ h1 , there is a unique arrow h : A0 → A such that the two upper triangles commute (that is h1 = g ◦ h and h2 = f ◦ h). In other words, A is unique up to isomorphism. Definition 2.1.6 (Category with pullbacks) We say that a category has all pullbacks if for all diagrams B

 /D

C

There is an object A and two arrows A → B and A → C such that the square created with those four objects is a pullback. Definition 2.1.7 (Finite Limits) A category C is said to have finite limits if: • C has a terminal object. • C has all pullbacks.

6

Definition 2.1.8 (Adjoint functors) Let C and D be two categories, F a functor C → D and G a functor D → C. We say that F is a left adjoint of G (or equivalently that G is a right adjoint of F ) if, for every objects A of C and B of D, there is a bijection φA,B : Hom(F (A), B) → Hom(A, G(B)). Moreover, this bijection has to be natural, which means that for any objects A, A0 in C, for any objects B, B 0 in D, for any morphisms f : A → A0 , g : B → B 0 , we get from the following commuting diagram: h /B F (A) g

F (f )  F (A0 )

k

 / B0

we get the following diagram: A

φA,B (h)

/ G(B)

f  A0

2.2

G(g) φA0 ,B 0 (k)

 / G(B 0 )

(Locally) Cartesian Closed Categories

Definition 2.2.1 (Slice Category ) Let C be a category and A ∈ |C|. The slice category C/A is defined by: • Its objects are morphisms f : B → A where B is an object of C. • Its arrows from f : B → A to f 0 : B 0 → A are C-arrows h : B → B 0 such that f 0 ◦ h = f . • Composition of h : f → f 0 and h0 : f 0 → f 00 is usual C-composition, h0 ◦ h. • Likewise, identity arrow of f : B → A is idB : B → B.

This particular construction will be of big importance to us as it provides a “free” functor from an arbitrary category C to the category of categories Cat, which we will use in section 2.3. If we add the condition that C has all pullbacks, then we can even obtain functors between its slice categories:

7

Definition 2.2.2 (Pullback Functor ) Let C be a category with pullbacks. Then for any C-arrow f : A → B, there is a functor f ∗ : C/B → C/A defined as follows: • For any C-arrow g : C → B, the pullback property applied to C g f

A

 /B

ensures us that there is an object D and an arrow h : D → A. Then we set f ∗ (g) = h. • For any g : C → B, g 0 : C 0 → B and h : C → C 0 such that g 0 ◦ h = g, we obtain the following diagram, where both the inner and outer squares are pullbacks: i0 D00 @ 00 @ 00 @ 00 @ j 00 @ @ 00 @ 00 @ 00 @ i 0 ∗ 0 00 D f (g ) 0 00 00 00 ∗ 00 f (g) 00 00  f A

/D      h              0 /C   g    g       /B

Since h ◦ i0 : D0 → C, we can apply the definition of a pullback to the inner square and D0 and obtain a unique j : D0 → D, which allows us to set f ∗ (h) = j. The two conditions for f ∗ to be a functor are easily verified and left as an exercise to the reader. Certainly one of the most important notions in category theory is the one of cartesian closed category, as it provides an elegant model of simply typed λ-calculus. For a complete description of what we can call an ancestor of the work presented here, one can refer to [BW90]. Definition 2.2.3 (Cartesian Closed Category ) Let C be a category. We say that it is cartesian closed if: • It has a terminal object, noted 1. • It has all binary products (that is, for every objects A and B, there is an object A × B). • For every object A, the functor B 7→ A × B has a right adjoint, noted B 7→ B A .

Another way of expressing the right-adjoint condition is to say that C possesses exponent objects and evaluation morphisms, which makes the link to λ-calculus much more obvious.

8

A stronger condition, of more direct interest to us, is the locally cartesian closed category property: Definition 2.2.4 (Locally Cartesian Closed Category ) Let C be a category. We say that C is a locally cartesian closed category if any of the two following properties is satisfied: • C has all pullbacks and for every C-morphism f : A → B, the pullback functor f ∗ : C/B → C/A has a right adjoint. • For every object A, the slice category C/A is cartesian closed.

We can here get an idea of the power of locally cartesian closed categories with the second definition. As every slice category C/A is cartesian closed, it is a model of simply typed lambda calculus, but its objects have some kind of “special relationship” to A, which we could see as a dependence. Indeed, Seely proved in [See84] that locally cartesian closed categories are a model of extensional Martin-L¨ of type theory without inductive types.

2.3

Indexed Categories

Definition 2.3.1 (Indexed Category ) A C-indexed category is a couple (C, T ) where C is a category and T is a functor from C to Cat, the category of categories. Indexed categories are also important because the notion of indexing things is very common in type theory: types are indexed by contexts and terms are indexed by types. If we add some structure to indexed categories, we obtain hyperdoctrines: Definition 2.3.2 (Hyperdoctrine) We say that an indexed category (C, T ) is a hyperdoctrine if: • For every object A, T (A) is cartesian closed. • For every morphism f , T (f ) preserves exponents (the right adjoints of product functors). • For every morphism f , T (f ) has a right adjoint Πf and left adjoint Σf . • The Beck condition is verified: if the following diagram is a pullback in C, h

D

/C g

k  A

f

 /B

then for any object φ of T (C), Σk h∗ φ → f ∗ Σg φ is an isomorphism in T (A).

2.4

Categories with Families

Categories with Families (hereafter shortened to CwF) are a categorical model of dependent type theory closely related to Cartmell’s categories with attributes but taken even “closer” to the syntax.

9

Definition 2.4.1 (Fam) Fam is the category of families, which has as objects pairs B = (B 0 , B 1 ) where B 0 is a set and (Bb1 )b∈B 0 is a family of sets indexed over B 0 . A morphism from B to C = (C 0 , C 1 ) is a pair (f 0 , f 1 ) where f 0 : B 0 → C 0 and f 1 = (fb1 )b∈B 0 is a family of functions fb1 : Bb1 → Cf10 (b) . We can now define CwF themselves: Definition 2.4.2 (Category with Families) A Category with Families is made of the four following parts: • A base category C. Its objects are called contexts and its morphisms substitutions. • A terminal object  of C, called the empty context. • A functor T : C op → Fam. If Γ is an object of C, we write T (Γ) = T ype(Γ), T erms(Γ, A)A∈T ype(Γ)



If γ : Γ → ∆ is a substitution in C, T (γ) will interpret substitution in types and terms. We will note the application of its first component to a type A as A[γ] and the application of its second component to a term a as a[γ]. • A context comprehension operation, which to a context Γ of C and a type A of T ype(Γ) associates a context Γ; A of C together with a substitution p Γ,A : Γ; A → Γ, called the first projection or sometimes display maps and a term q Γ,A of T erms(Γ; A, A [p Γ,A ]) such that for every context ∆, substitution γ : ∆ → Γ and term a : ∆ ` A[γ], there is a unique morphism hγ, ai : ∆ → Γ; A with the property that p Γ;A,A[p Γ,A ] ◦ hγ, ai = γ and q Γ,A [hγ, ai] = a.

N.B. 2 It can seem awkward at first that T is from C op (the dual of C, i.e. C with all arrows reversed) rather than directly from C. This can be explained by looking at the “real” context substitutions in type theory, which we want to model here: let’s consider a context as a sequence x1 : A1 , . . . , xn : An where the xi are variables and the Ai types. A term in this context is a term with its free variables amongst x1 , . . . xn . A substitution γ : Γ → ∆ is then a tuple of terms (M1 , . . . , Mn ) such that the following properties hold: Γ

`

M 1 : A1

Γ

`

M2 : A2 [M1 /x1 ]

Γ

... `

Mn : An [M1 /x1 ][M2 /x2 ] . . . [Mn−1 /xn−1 ]

Then, if a : ∆ ` A, a[γ] will be a where every occurence of xi is replaced by Mi , thus a[γ] : Γ ` A[γ], which explains why T (γ) is best interpreted by a morphism from T (∆) to T (Γ). Categories with Families are very close to Cartmell’s categories with attributes. The main difference comes from the fact that many notions such as terms or substitutions are not natively present in categories with attributes but rather defined afterwards and shown equivalent to some constructions. As we will use those equivalences, especially in section 4, let’s present them quickly:

10

Proposition 2.4.1 (Types are display maps) It is straightforward to get a type A from the projection p Γ,A : Γ; A → Γ. Conversely, if A ∈ T ype(Γ), p Γ,A is given by the definition of the category with families. Proposition 2.4.2 (Terms are sections of the display maps) A section of a display map p Γ,A is a C-morphism t : Γ → Γ; A such that p◦t = idΓ . From such a section, we can get the term a = q Gamma,A[p] [t] : Γ ` A. Conversely, hidΓ , ai : Γ → Γ; A which satisfies the wanted property p ◦ hidΓ , ai = idΓ . Eventually, as q Γ,A[p] [hidΓ , ai] = a, there is a one-to-one correspondance between terms and sections of display maps.

In the models of Categories with Families or Categories with Attributes, substitution and pullbacks are closely tied together. Indeed, the following diagram is a pullback in a CwF (the proof can be found in [Hof97], and CwA use the same diagram to define substitution in types, as the top left context is unique “up to isomorphism”. This will be particularly important in section 4.

∆; A[γ]

q(γ, A)

p ∆,A[γ]  ∆

/ Γ; A

p Γ;A γ

Where q(γ, A) = hγ ◦ p, qi.

11

 /Γ

3. Equivalences of Categorical Models 3.1

Presentation

Our goal will now be to try and find equivalences between all the categorical models that we presented, so as to get a better idea of their respective “power”. To the exception of section 3.4, all the remaining results in this report are original. CwF

Section 4

Section 3.2 Section 3.3

Clairambault

Finite limits

LCCC

IC ?

Figure 1: Equivalences of categorical models

3.2

From Categories with Families to Indexed Categories. . .

Let (C, T ) be the base category and functor of a category with family. We will construct an indexed category (C op , U ) with the dual base C op and U : C op → Cat. • If Γ is an object of C, then U (Γ) is a category: – its objects are the semantic types in context Γ, that is T ype(Γ), the first component of T (Γ). – if A and B are objects of U (Γ), the arrows f : A → B are the terms f : Γ; A ` B[p Γ,A ] – we take qA as idA , as idA : Γ; A ` A[p Γ,A ] – if f : A → B and g : B → C, then g ◦ f = g [hp Γ,A , f i] • If γ : Γ → ∆ is a morphism of C, then U (γ) is a functor U (∆) → U (Γ): – if A is an object of U (∆), U (γ)(A) = A[γ] which is an object of U (Γ). – if f : A → B in U (∆), U (γ)(f ) = f [q(γ, A[γ])] which is a term in Γ; A[γ] ` B[γ][p Γ,A[γ] ], so an arrow of A[γ] → B[γ] in U (Γ). Let us prove that U (γ) is really a functor :

12

• U (γ)(idA ) = idU (γ)(A) : U (γ)(idA )

= U (γ)(qA ) = qA [q(γ, A[γ])] 

 = qA γ ◦ p Γ,A , qA[γ] = qA[γ] = idU (γ)(A)

• If f : A → B and g : B → C, U (γ)(g ◦ f ) = U (γ)(g) ◦ U (γ)(f )1 : U (γ)(g ◦ f )

=

(g ◦ f ) [q(γ, A)]

= g [hp, f i] [hγ ◦ p, qi] = g [hγ ◦ p, qi] [hp, f [hγ ◦ p, qi]i] = U (γ)(g) ◦ U (γ)(f ) Two conditions are left to prove that U is really a functor of C op → Cat: • If Γ is an object of C, A, B are objects of U (A) and f : A → B is an arrow of U (A), then U (idΓ )(A)

= A [idΓ ] = A

U (idΓ )(f )

= f [q(idΓ , A)] = f [hidΓ ◦ p, qA i] = f [hp, qA i] = f

Thus U (idΓ ) = idU (Γ) . • If γ : Γ → ∆ and δ : ∆ → Ξ in C op : U (δ ◦ γ)(A)

= A[δ ◦ γ] = A[δ][γ]

= (U (δ) ◦ U (γ)) (A) U (δ ◦ γ)(f ) = f [q(δ ◦ γ, A[δ ◦ γ])] 

 = f δ ◦ γ ◦ p Γ,A , qA[δ◦γ] 

 

 = f δ ◦ p ∆,A[γ] , qA[δ] γ ◦ p Γ,A , qA[γ] =

(U (δ) ◦ U (γ)) (f )

This proves that U (γ ◦ δ) = U (γ) ◦ U (δ), which ends the proof that (C op , U ) is an indexed category.

3.3

. . . And Back

We will now make the reverse transformation and try to go from an Indexed Category to a Category with Families. 3.3.1 Functor C → Fam Proposition 3.3.1 If (C, T ) is an indexed category and • for each Γ object of C, T (Γ) has a terminal object 1Γ 1 We

omit the subscript as they can be deduced from the context and make the terms difficult to read

13

• for each γ : Γ → ∆ of C, T (γ)(1Γ ) = 1∆ then we can construct a functor U : C → Fam. Proof. We define U as: • for each Γ of C, the first component of U (Γ) (in a CwF, T ype(Γ)) is the set of objects of T (Γ). • the second component of U (Γ) is the set of arrows f : 1Γ → A in T (Γ), for all A in U (Γ) (in a CwF, T erms(Γ, A) = {f ∈ T (Γ)|f : 1Γ → A}). • if γ : Γ → ∆ in C then the first component of U (γ) is T (γ) restricted to the objects of T (Γ) and the second component is T (γ) restricted to the arrows of T (Γ) of the form 1Γ → A for some A of T (Γ). We just have to prove that U is really a functor: • with γ : Γ → ∆ and f : 1Γ → A, U (γ)(f ) = T (γ)(f )

: T (γ)(1Γ → A) : T (γ)(1Γ ) → T (γ)(A) :

1∆ → U (γ)(A)

so U (γ) is really a morphism of Fam. • U (idΓ ) = idU (Γ) because T (idΓ ) = idT (Γ) . • likewise, U (g ◦ f ) = U (g) ◦ U (f ).

3.3.2

Obtaining a full Category with Families

So we can get a functor C → Fam from such an indexed category, which is an important step in obtaining a category with families. However, we can’t directly model context comprehension and we need another hypothesis for that. Proposition 3.3.2 Indexed Categories with the condition of definition 3.3.1 are not enough to define context comprehension. Proof. Let C be a category with one element (noted Γ) and one arrow, idΓ . C 0 is a category with two elements, A and 1, and one arrow f : A → 1 plus the identities. Let T : C → Cat be the functor that sends Γ to C 0 and idΓ to idC 0 . If context comprehension was defined, we would have some object Γ; A of C such that: • there is an arrow p : Γ → Γ; A in C • in T (Γ; A), there is a terminal object 10 and an arrow g : 10 → U (p)(A) As there is only one object in C, Γ; A = Γ. So p = idΓ , T (Γ; A) = C 0 , 10 = 1 and U (p)(A) = A. But there is no arrow from 1 to A in C 0 , so context comprehension is not defined correctly.

14

Proposition 3.3.3 If (C, T ) is an indexed category with the condition of definition 3.3.1 and for all Γ in C, for all A in T (Γ), there is an object Γ; A of C and a morphism p Γ;A : Γ → Γ; A such that there is an arrow q : 1Γ;A → T (p)(A) in T (Γ; A), then (C op , U ) is a category with families. The proof is quite easy and won’t be detailed here.

3.4

From Categories with Families to Locally Cartesian Closed Categories. . .

This corresponds to the work of Pierre Clairambault in [Cla05]. His main result is: Proposition 3.4.1 Categories with Families with intensional and extensional identity types, context products, Π and Σ types, are locally cartesian closed. For the missing definitions (e.g. of identity types) and the proof of the proposition, see [Cla05].

3.5

. . . And Almost Back

The converse of Pierre Clairambault’s theorem would take a locally cartesian closed category and transform it in a category with families with some extra structure. To begin with, we will only consider a simpler category C with finite limits and try to show that it can be transformed in a category with families. There is a “naive” transformation that we will quickly present, but it eventually raises a known problem related to the interpretation of substitution in locally cartesian closed categories. The solution to this problem, along with a working transformation from finite limits to categories with families, will be presented in section 4. The basic idea of the naive transformation is to keep the same base category C, then set T ype(Γ) to be the objects of C/Γ, that is the morphisms f : A → Γ. We then write A = B; f which makes sense as we can identify types with display maps. Terms are again defined as sections of the display maps. To define the second projection, one needs to consider the following pullback: Γ; σ3 EUUU 33 E UUUUUUU UUUU 33 E UUUU 33 E E q UUUU idΓ;σ Γ,σ UUUU 33 E UUUU 33 E UUUU UUUU E 33 UUUU E 33 UUUU E " UUU* 33 σ[p] / Γ; σ 3 Γ; σ; σ[p] idΓ;σ 33 33 33 33 33 σ σ[p] 33 33 3   /Γ Γ; σ σ As q Γ,σ is defined uniquely and satisfies the required equations, we take it as the second projection.

15

However, this transformation is not good enough, as will be explained in the next section.

4. From Finite Limits to Families 4.1

Statement of the problem

When trying to interpret dependent type theory in locally cartesian closed categories, as first described in [See84], one encounters a deep problem: the interpretation is based on the syntax, which means that substitution must be defined directly, as it is defined inductively on the syntax. But at the same time, substitution is given by pullbacks, defined only up to isomorphism. While there is no proof of the contrary, nothing allows us to certify that the morphism chosen in the pullback will always coincide with the syntactical definition. This is an important flaw in Seely’s construction, which has led to two different solutions, by Curien[Cur93] and Hofmann[Hof94]. We will here adapt Hofmann’s solution to categories with families, which makes sense, as trhis solution is already dealing with the very close categories with attributes.

4.2

Hofmann’s Solution

The basic idea of the construction presented in [Hof94] is to construct a category with attributes from a locally cartesian closed category, with the exact behaviour under substitution fixed in the structure itself — and of course still compatible with the “pullback” definition. To this end, one replaces the interpretation of types as a single morphism by a whole family of morphism, which allows to “fix” the interpretation of substitution. We will here present the construction in categories with families, but it remains essentially the same than with categories with attributes.

4.2.1

Goal

Let C be a locally cartesian closed category. We will construct a CwF with the same base category C and functor T : C op → Fam. 4.2.2

Functor C op → Fam

The main difficulty is to define T ype(Γ), the first component of T (Γ), for Γ in C. As stated before, we take it to be equal to a set of C-morphisms: Definition 4.2.1 (T ype(Γ)) For Γ in C, we set T ype(Γ) to be the set of functors σ from the slice category C/Γ to the arrow category C → that satisfy the following conditions: • To any C-morphism s : B → Γ, σ(s) : dom(σ(s)) → B is a C-morphism with codomain B. • To α : B 0 → B, C/Γ-morphism, σ(s, α) is a C-morphism such that the upper square of the diagram in figure 2 is a pullback. • σ(s, idB ) = iddom(σ(s)) • If β : B 00 → B 0 then σ(s, α ◦ β) = σ(s, α) ◦ σ(s ◦ α, β) 16

dom(σ(s ◦ α))

σ(s, α)

/ dom(σ(s))

σ(s ◦ α)

σ(s)

  /B B 0 JJ α w JJ ww JJ ww JJ w J ww s ◦ α JJJJ ww s w w JJ J$ {www Γ Figure 2: Definition of T ype(Γ) On the other hand, defining the terms is quite easy, we just use the correspondance with sections of the first projection (which we’ll define a bit later): Definition 4.2.2 (T erms(Γ, σ)) If Γ is an object of C and σ ∈ T ype(Γ), then T erms(Γ, σ) is the set of sections of σ(idΓ ), that is the set of C-morphisms a : Γ → dom(σ(idΓ )) such that σ(idΓ ) ◦ a = idΓ . 4.2.3

Context Comprehension and Projections

Definition 4.2.3 • Context comprehension is given by Γ; σ = dom(σ(idΓ )). • The first projection is then p Γ,σ = σ(idΓ ) : Γ; σ → Γ. • If a is a term of ∆ ` σ[γ], hγ, ai = σ(idΓ , γ) ◦ a.

In order to define the second projection, one needs to use the pullback property generated by σ in the diagram of figure 3. Γ; σ; σ[p]

σ (idΓ , σ(idΓ ))

σ[p](idΓ;σ )

/ Γ; σ σ(idΓ )

  /Γ Γ; σ E } EE σ(idΓ ) } EE }} } EE EE }} EE }} } E } idΓ σ(idΓ ) EE }} EE E" ~}}} Γ Figure 3: Defining the second projection As the upper square is a pullback, there is a unique morphism q Γ,σ in the diagram of figure 4. So we have σ[p](idΓ;σ ) ◦ q Γ,σ = idΓ;σ which means that q Γ,σ is a section of σ[p](idΓ;σ ) and thus a term of Γ; σ ` σ[p]. q Γ,σ being unique, we choose it as the second projection of Γ; σ. 17

Γ; σ3 FVVVV 33 F VVVVVV VVVV 33 F VVVV id VVVVΓ;σ 33 F Fq Γ,σ VVVV 33 F VVVV F VVVV 33 F VVVV 33 F" σ (idΓ , σ(idΓ )) VVVVV* 33 / Γ; σ idΓ;σ 33 Γ; σ; σ[p] 33 33 33 σ[p](idΓ;σ ) σ(idΓ ) 33 33 3   /Γ Γ; σ E EE σ(idΓ ) }} EE }} } EE EE }} EE }} } } idΓ σ(idΓ ) EEE }} EE } } E" ~} Γ Figure 4: Pullback and definion of the second projection 4.2.4

Substitutions

If γ : ∆ → Γ, we define σ[γ] by: • If s : B → Γ, σ[γ](s) = σ(γ ◦ s). • If α : B 0 → B, σ[γ](s, α) = σ(γ ◦ s, α). • If a : Γ ` σ, we define a[γ] as the unique morphism such that σ(γ) ◦ a[γ] = id∆ and σ(idΓ , γ) ◦ a[γ] = a ◦ γ. Its existence and unicity is given by the diagram of figure 5. ∆2 DUUUUU 22 D UUUUU UUUU 22 D UUUU 22 D a[γ] UUγUU◦ a D UUUU 22 UUUU D 22 UUUU D UUUU D! 22 UUU* σ (id Γ , γ) 22 / Γ; σ id∆ 22 ∆; σ[γ] 22 22 22 σ(γ) σ(idΓ ) 22 22   /Γ ∆ γ Figure 5: Definition of a[γ]

4.2.5

Checking of the definitions

Proposition 4.2.1 (The first projection is well defined ) For γ : Γ → ∆, a : Γ ` σ[γ], we have p ∆,σ ◦ hγ, ai = γ.

18

Proof. With our definitions: p ∆,σ ◦ hγ, ai = σ(id∆ ) ◦ σ(idΓ , γ) ◦ a Following from the definition of a[γ], we have that σ(id∆ , γ) ◦ a = a[γ] ◦ γ and σ(id∆ ) ◦ a[γ] = id∆ Thus σ(id∆ ) ◦ σ(id∆ , γ) ◦ a = σ(id∆ ) ◦ a[γ] ◦ γ = id∆ ◦ γ = γ. We could also have said that the following diagram commutes: Γ; σ[γ] O

σ (id∆ , γ)

a

/ ∆; σ σ(id∆ )

Γ

 /∆

γ

Proposition 4.2.2 (The second projection is well defined ) For γ : Γ → ∆, a : Γ ` σ[γ], we have q ∆,σ [hγ, ai] = a. Proof. We need to prove that a satisfies the two conditions for being q ∆,σ [hγ, ai] and we’ll then be able to conclude with unicity. As q ∆,σ : ∆; σ ` σ[p ∆,σ ], σ[p ∆,σ ](hγ, ai) ◦ a = σ (σ(id∆ ) ◦ σ(id∆ , γ) ◦ a) ◦ a As the following diagram commutes: Γ; σ[γ] O

σ (id∆ , γ)

a Γ

/ ∆; σ σ(id∆ )  /∆

γ

We have σ(id∆ ) ◦ σ(id∆ , γ) ◦ a = γ, so σ[p ∆,σ ](hγ, ai) ◦ a = σ(γ) ◦ a = id∆ , which is the first equation we need. The other one is: σ[p ∆,σ ] (id∆ , hγ, ai) ◦ a = σ(σ(id∆ ) ◦ id∆ , σ(id∆ , γ) ◦ a) ◦ a Let us consider the following diagram:

19

Γ; σ[γ]

σ (σ(id∆ ), σ(id∆ , γ) ◦ a)

/ ∆; σ; σ[p]

σ (σ(id∆ ) ◦ σ(id∆ , γ) ◦ a)

σ(σ(id∆ ))

 Γ

σ(id∆ , γ) ◦ a

 / ∆; σ

As it commutes, we have: σ(σ(id∆ )) ◦ σ (σ(id∆ ), σ(id∆ , γ) ◦ a) = σ(id∆ , γ) ◦ a ◦ σ (σ(id∆ ) ◦ σ(id∆ , γ) ◦ a)

Using the observation used in the first equation, σ(σ(id∆ )) ◦ σ (σ(id∆ ), σ(id∆ , γ) ◦ a) = σ(id∆ , γ) ◦ a ◦ σ(γ)

If we compose to the left with q ∆,σ , we eventually obtain q ∆,σ ◦ σ(σ(id∆ )) ◦ σ (σ(id∆ ), σ(id∆ , γ) ◦ a) = σ (σ(id∆ ), σ(id∆ , γ) ◦ a) = q ∆,σ ◦ σ(id∆ , γ) ◦ a ◦ σ(γ)

Eventually, σ (σ(id∆ ), σ(id∆ , γ) ◦ a) ◦ ◦a = q ∆,σ ◦ σ(id∆ , γ) ◦ a ◦ σ(γ) ◦ a = q ∆,σ ◦ σ(id∆ , γ) ◦ a

This ends the proof that q ∆,σ [hγ, ai] = a.

We eventually have a working transformation from a category with finite limits to a category with families. What we would need now is a proof that this transformation still works when we apply it to a locally cartesian closed category and that it gives, e.g. Π-types or Σ-types. Some clues in this direction are given in Hofmann’s paper [Hof94] but for categories with attributes.

20

5. Conclusion While we have managed to prove several equivalence results between known categorical models of type theory, much remains to do. In particular, finishing the transformation of locally cartesian closed categories to categories with families with some extra structures. We can even hope that this transformation would be reverse to Pierre’s, which would effectively prove that categories with families with intensional and extensional identity types, context products and Π and Σ-types are equivalent to locally cartesian closed categories, which wouls be a very important result. Likewise, we have mainly dealt with indexed categories and not with hyperdoctrines, which we suspect to be equivalent, once again, to categories with families with some extra structures. Another aspect that certainly looks worth researching would be to try and find a precise map between categorical structures and dependent type theory properties. This subject, while extremely interesting, was a lot more difficult than I first thought, requiring manipulation of complex abstract structures with the uttermost care. At least a third of the internship was spent doing bibliographical work. The real research work began only in the last weeks, when I had finally grasped most of the notions that we were dealing with. This is why I regret not having had more time, for example to finish the transformation from locally cartesian closed categories to categories with families. However, I intend to go back to Chalmers and continue working on this topic for my Master 2 internship. The results presented here, in conjunction with Pierre’s, and certainly some more, are planned to form the basis of a joint article with Pierre and Peter. Unfortunately, the initial plan of redacting it during the summer failed for logistic reasons, but we hope to be able to work on it sometime soon.

21

References [BW90] Barr and Wells. Category Theory for Computer Science. Prentice Hall, 1990. [Cla05]

Pierre Clairambault. From categories with families to locally cartesian closed categories. Master’s thesis, Chalmers Tekniska H¨ogskola and ENS Lyon, 2005.

[Cur93] Pierre-Louis Curien. Substitution up to isomorphism. Fundam. Inform., 19(1/2):51–85, 1993. [Dyb95] Peter Dybjer. Internal type theory. In TYPES, pages 120–134, 1995. [Hof94] Martin Hofmann. On the interpretation of type theory in locally cartesian closed categories. In CSL, pages 427–441, 1994. [Hof97] Martin Hofmann. Syntax and semantics of dependent types. In A. M. Pitts and P. Dybjer, editors, Semantics and Logics of Computation, volume 14, pages 79–130. Cambridge University Press, Cambridge, 1997. [LS86]

Joachim Lambek and Philip J. Scott. Introduction to Higher Order Categorical Logic. Cambridge University Press, 1986.

[Mim04] Samuel Mimram. Decidability of equality in categories with families. Master’s thesis, Chalmers Tekniska H¨ ogskola and ENS Lyon, 2004. [See84]

R.A.G. Seely. Locally cartesian closed categories and type theory. Math. Proc. Cambridge Phil. Soc., 95:33–48, 1984.

[Tas93] A. Tasistro. Formulation of Martin-L¨of’s theory of types with explicit substitutions. Master’s thesis, Chalmers Tekniska H¨ogskola and G¨oteborgs Universitet, May 1993.

22