categorical models of dependent type...

22
Master 1 Internship ENS Lyon Master d’Informatique Fondamentale Categorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter Dybjer Chalmers Tekniska H¨ ogskola oteborg, Sverige June - August 2006

Upload: others

Post on 15-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Master 1 Internship

ENS LyonMaster d’Informatique Fondamentale

Categorical Models of DependentType Theory

Alexandre Buisse

Under the direction of Peter Dybjer

Chalmers Tekniska Hogskola

Goteborg, Sverige

June - August 2006

Page 2: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Contents

Contents 2

1 Introduction 3

2 Categorical Definitions 42.1 Basic Categorical Notions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2 (Locally) Cartesian Closed Categories . . . . . . . . . . . . . . . . . . . . . . . . . 72.3 Indexed Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.4 Categories with Families . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3 Equivalences of Categorical Models 123.1 Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.2 From Categories with Families to Indexed Categories. . . . . . . . . . . . . . . . . . 123.3 . . . And Back . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3.3.1 Functor C → Fam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3.2 Obtaining a full Category with Families . . . . . . . . . . . . . . . . . . . . 14

3.4 From Categories with Families to Locally Cartesian Closed Categories. . . . . . . . 153.5 . . . And Almost Back . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4 From Finite Limits to Families 164.1 Statement of the problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.2 Hofmann’s Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.2.1 Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.2.2 Functor Cop → Fam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.2.3 Context Comprehension and Projections . . . . . . . . . . . . . . . . . . . . 174.2.4 Substitutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.2.5 Checking of the definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

5 Conclusion 21

References 22

Abstract

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

2

Page 3: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

1. Introduction

Category theory was first introduced in the 40s as a way to abstract mathematical structure andmodel transformations between such structures. Lambek[LS86] later showed that some categoricalstructure, namely the cartesian closed categories which had been introduced a few years earlier byLawvere, could be proved equivalent to the simply typed λ-calculus, which was known since the40s. 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 studieda lot and has thus many results that are useful for defining models. It also helps to define whatexactly it means to be a model of dependent type theory. Another reason is that some flavoursof type theory don’t have yet a definite formulation. By providing some models linked with agiven syntax, one could help “legitimate” it. Paradoxically, those models allow to abstract fromthe syntax and all the issues it usually generates, like alpha-conversion, and focus instead on thestructural notions.

While many categorical models have been studied over the years, we are here interested in aspecific notion: categories with families, introduced by Peter Dybjer[Dyb95], which are a variantof Cartmell’s categories with attributes. As many categorical models, they make substitutionsand context morphisms part of the structure rather than define them afterwards. Their maininterest is that they can be defined equationally as a generalized algebraic theory (GAT), whichis an algebraic theory where the sorts may depend on elements of other sorts. The rules ofthe generalized algebraic theory of categories with families are closely related to the substitutioncalculus formulation of Martin-Lof type theory, see [Tas93]. Dybjer used categories with families inhis approach to “internal type theory”, the goal of which is to formalize the metatheory (includingmodels of fragments of Martin-Lof type theory) inside the language of Martin-Lof type theoryitself.

Samuel Mimram recently proved[Mim04] that categories with families with extra structurewere equivalent to LF, Martin-Lof’s logical framework, a λ-calculus with dependent types. ThenPierre Clairambault[Cla05] proved that categories with families with some carefully chosen extrastructure could be transformed in locally cartesian closed categories or hyperdoctrines, whoseexact 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, andHofmann[Hof97] who proved many results on categories with families. Our contribution is toprove links between all those models, in particular indexed categories and the converse of Pierre’sresult. A last part of the work presented here is to prove that Hofmann’s solution[Hof94] to theproblem of substitution up to isomorphism still works with categories with families.

3

Page 4: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

2. Categorical Definitions

In this first section, we will present the categorical notions which we will use in the rest of thereport. For space reasons, definitions will have to stay as short as possible, a much more completeintroduction 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 ofgeneral 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

to B. If f ∈ Hom(A,B), we usually note f : A → B or Af→ 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 arrowg ◦ 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 .

• Associativity: For all Af→ B

g→ Ch→ D, h ◦ (g ◦ h) = (h ◦ g) ◦ f .

An elementary and intuitive example of category is Set, the category where objects are setsand arrows are total functions between those sets. Identity and composition have their usualmeaning.

Another important notion is the one of functor, which is a mapping between two categoriesthat 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 asarrows.

The next step is to define what a natural transformation is. It is an important notion, of whichit has been said that the whole category theory was invented just for its definition.

4

Page 5: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

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 transfor-mation η 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)

//

ηX

��

F (Y )

ηY

��G(X)

G(f)// G(Y )

While the definition of a category is very general, we often need to add some extra structuralconditions to be able to prove interesting properties. Here come some such conditions which wewill use in this report.

N.B. 1

In category theory, properties are often stated via commuting diagrams, which is a visual andelegant way of expressing complex algebraic equalities involving compositions.To say that the following diagram commutes is equivalent to saying that g′ ◦ f = f ′ ◦ g:

Af //

g

��

B

g′

��C

f ′ // 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 anobject A×B and two morphisms π1 : A×B → A and π2 : A×B → B such that for any objectZ and morphisms f1 : Z → A and f2 : Z → B, there is a unique morphism h : Z → A × Bsuch that the following diagram commutes:

Z

f1

||zzzz

zzzz

zzzz

zz

h

�������

f2

""DDD

DDDD

DDDD

DDD

A A×Bπ1

oo π2 // B

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

5

Page 6: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Definition 2.1.5 (Pullback)

In the following diagram,

A′

h1

��///

////

////

////

////

////

////

///

h

��@@

@@

@@

@@

@

h2

''OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

Af //

g

��

B

g′

��C

f ′ // D

the inner square is said to be a pullback if it commutes and for any object A′ and arrowsh1 : A′ → C, h2 : A′ → B such that g′ ◦ h2 = f ′ ◦ h1, there is a unique arrow h : A′ → A suchthat 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

��C // D

There is an object A and two arrows A → B and A → C such that the square createdwith 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

Page 7: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

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 thatF is a left adjoint of G (or equivalently that G is a right adjoint of F ) if, for every objectsA 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,A′ in C, for any objectsB,B′ in D, for any morphisms f : A → A′, g : B → B′, we get from the following commutingdiagram:

F (A) h //

F (f)

��

B

g

��F (A′) k // B′

we get the following diagram:

AφA,B(h)

//

f

��

G(B)

G(g)

��A′

φA′,B′(k)// G(B′)

2.2 (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 ′ : B′ → A are C-arrows h : B → B′ such that f ′ ◦h = f .

• Composition of h : f → f ′ and h′ : f ′ → f ′′ is usual C-composition, h′ ◦ 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 froman 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 itsslice categories:

7

Page 8: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Definition 2.2.2 (Pullback Functor)

Let C be a category with pullbacks. Then for any C-arrow f : A → B, there is a functorf∗ : C/B → C/A defined as follows:

• For any C-arrow g : C → B, the pullback property applied to

C

g

��A

f // 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′ : C ′ → B and h : C → C ′ such that g′ ◦ h = g, we obtain thefollowing diagram, where both the inner and outer squares are pullbacks:

D′ i′ //

f∗(g′)

��000

0000

0000

0000

0000

0000

0000

0000

j

@@

@@

@@

@@

@ D

h

������

����

����

����

��

g′

��������������������������������

D

f∗(g)

��

i // C

g

��A

f // B

Since h ◦ i′ : D′ → C, we can apply the definition of a pullback to the inner square andD′ and obtain a unique j : D′ → 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 thereader.

Certainly one of the most important notions in category theory is the one of cartesian closedcategory, as it provides an elegant model of simply typed λ-calculus. For a complete descriptionof 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→ BA.

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

8

Page 9: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

A stronger condition, of more direct interest to us, is the locally cartesian closed categoryproperty: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 twofollowing 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 seconddefinition. As every slice category C/A is cartesian closed, it is a model of simply typed lambdacalculus, but its objects have some kind of “special relationship” to A, which we could see as adependence. Indeed, Seely proved in [See84] that locally cartesian closed categories are a modelof extensional Martin-Lof 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 toCat, the category of categories.

Indexed categories are also important because the notion of indexing things is very commonin 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,

Dh //

k

��

C

g

��A

f // B

then for any object φ of T (C), Σkh∗φ → 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 typetheory closely related to Cartmell’s categories with attributes but taken even “closer” to the syntax.

9

Page 10: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Definition 2.4.1 (Fam)

Fam is the category of families, which has as objects pairs B = (B0, B1) where B0 is a setand (B1

b )b∈B0 is a family of sets indexed over B0. A morphism from B to C = (C0, C1) is apair (f0, f1) where f0 : B0 → C0 and f1 = (f1

b )b∈B0 is a family of functions f1b : B1

b → C1f0(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 : Cop → Fam. If Γ is an object of C, we write

T (Γ) =(Type(Γ), T erms(Γ, A)A∈Type(Γ)

)If γ : Γ → ∆ is a substitution in C, T (γ) will interpret substitution in types andterms. We will note the application of its first component to a type A as A[γ] and theapplication 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 Type(Γ)associates a context Γ;A of C together with a substitution p Γ,A : Γ;A → Γ, called thefirst projection or sometimes display maps and a term q Γ,A of Terms(Γ;A,A [p Γ,A])such that for every context ∆, substitution γ : ∆ → Γ and term a : ∆ ` A[γ], there is aunique morphism 〈γ, a〉 : ∆ → Γ;A with the property that p Γ;A,A[p Γ,A] ◦ 〈γ, a〉 = γ andq Γ,A[〈γ, a〉] = a.

N.B. 2

It can seem awkward at first that T is from Cop (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, whichwe want to model here: let’s consider a context as a sequence x1 : A1, . . . , xn : An where thexi are variables and the Ai types. A term in this context is a term with its free variablesamongst x1, . . . xn. A substitution γ : Γ → ∆ is then a tuple of terms (M1, . . . ,Mn) such thatthe following properties hold:

Γ ` M1 : 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, thusa[γ] : Γ ` A[γ], which explains why T (γ) is best interpreted by a morphism from T (∆) toT (Γ).

Categories with Families are very close to Cartmell’s categories with attributes. The maindifference comes from the fact that many notions such as terms or substitutions are not nativelypresent in categories with attributes but rather defined afterwards and shown equivalent to someconstructions. As we will use those equivalences, especially in section 4, let’s present them quickly:

10

Page 11: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Proposition 2.4.1 (Types are display maps)

It is straightforward to get a type A from the projection p Γ,A : Γ;A → Γ. Conversely, ifA ∈ Type(Γ), 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 sucha section, we can get the term a = q Gamma,A[p][t] : Γ ` A. Conversely, 〈idΓ, a〉 : Γ → Γ;Awhich satisfies the wanted property p ◦ 〈idΓ, a〉 = idΓ. Eventually, as q Γ,A[p][〈idΓ, a〉] = 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 andpullbacks are closely tied together. Indeed, the following diagram is a pullback in a CwF (theproof can be found in [Hof97], and CwA use the same diagram to define substitution in types, asthe top left context is unique “up to isomorphism”. This will be particularly important in section4.

∆; A[γ]q(γ, A)

//

p ∆,A[γ]

��

Γ;A

p Γ;A

��∆

γ // Γ

Where q(γ, A) = 〈γ ◦ p, q〉.

11

Page 12: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

3. Equivalences of Categorical Models

3.1 Presentation

Our goal will now be to try and find equivalences between all the categorical models that wepresented, 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.

LCCC IC

CwF

Finite limits

?

Section 4

Clairambault

Section 3.2

Section 3.3

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 indexedcategory (Cop, U) with the dual base Cop and U : Cop → Cat.

• If Γ is an object of C, then U(Γ) is a category:

– its objects are the semantic types in context Γ, that is Type(Γ), the first component ofT (Γ).

– 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 [〈pΓ,A, f〉]

• 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

Page 13: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

• 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 [〈p, f〉] [〈γ ◦ p, q〉]= g [〈γ ◦ p, q〉] [〈p, f [〈γ ◦ p, q〉]〉]= U(γ)(g) ◦ U(γ)(f)

Two conditions are left to prove that U is really a functor of Cop → 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 [〈idΓ ◦ p, qA〉]= f [〈p, qA〉]= f

Thus U(idΓ) = idU(Γ).

• If γ : Γ → ∆ and δ : ∆ → Ξ in Cop:

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 (Cop, U) is an indexedcategory.

3.3 . . . And Back

We will now make the reverse transformation and try to go from an Indexed Category to a Categorywith Families.

3.3.1 Functor C → FamProposition 3.3.1

If (C, T ) is an indexed category and

• for each Γ object of C, T (Γ) has a terminal object 1Γ

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

13

Page 14: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

• 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, Type(Γ)) is the set of objects ofT (Γ).

• the second component of U(Γ) is the set of arrows f : 1Γ → A in T (Γ), for all A in U(Γ) (ina CwF, Terms(Γ, 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 forsome 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 inobtaining a category with families. However, we can’t directly model context comprehension andwe need another hypothesis for that.

Proposition 3.3.2

Indexed Categories with the condition of definition 3.3.1 are not enough to define contextcomprehension.

Proof. Let C be a category with one element (noted Γ) and one arrow, idΓ. C′ is a category withtwo elements, A and 1, and one arrow f : A → 1 plus the identities. Let T : C → Cat be thefunctor that sends Γ to C′ and idΓ to idC′ .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 1′ and an arrow g : 1′ → U(p)(A)

As there is only one object in C, Γ;A = Γ. So p = idΓ, T (Γ;A) = C′, 1′ = 1 and U(p)(A) = A.But there is no arrow from 1 to A in C′, so context comprehension is not defined correctly.

14

Page 15: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Proposition 3.3.3

If (C, T ) is an indexed category with the condition of definition 3.3.1 and for all Γ in C, forall A in T (Γ), there is an object Γ;A of C and a morphism p Γ;A : Γ → Γ;A such that thereis an arrow q : 1Γ;A → T (p)(A) in T (Γ;A), then (Cop, 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 Cate-gories. . .

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 andtransform it in a category with families with some extra structure. To begin with, we will onlyconsider a simpler category C with finite limits and try to show that it can be transformed in acategory with families.

There is a “naive” transformation that we will quickly present, but it eventually raises a knownproblem related to the interpretation of substitution in locally cartesian closed categories. Thesolution to this problem, along with a working transformation from finite limits to categories withfamilies, will be presented in section 4.

The basic idea of the naive transformation is to keep the same base category C, then set Type(Γ)to be the objects of C/Γ, that is the morphisms f : A → Γ. We then write A = B; f which makessense as we can identify types with display maps. Terms are again defined as sections of thedisplay maps. To define the second projection, one needs to consider the following pullback:

Γ;σ

idΓ;σ

��333

3333

3333

3333

3333

3333

3333

3333

33

qΓ,σ

""EE

EE

EE

EE

EE

idΓ;σ

**UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU

Γ;σ;σ[p]σ[p]

//

σ[p]

��

Γ;σ

σ

��Γ;σ σ

// Γ

As q Γ,σ is defined uniquely and satisfies the required equations, we take it as the secondprojection.

15

Page 16: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

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 firstdescribed 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 morphismchosen in the pullback will always coincide with the syntactical definition. This is an impor-tant flaw in Seely’s construction, which has led to two different solutions, by Curien[Cur93] andHofmann[Hof94].

We will here adapt Hofmann’s solution to categories with families, which makes sense, as trhissolution 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 attributesfrom a locally cartesian closed category, with the exact behaviour under substitution fixed in thestructure 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 familyof morphism, which allows to “fix” the interpretation of substitution.

We will here present the construction in categories with families, but it remains essentially thesame 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 categoryC and functor T : Cop → Fam.

4.2.2 Functor Cop → Fam

The main difficulty is to define Type(Γ), 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 (Type(Γ))

For Γ in C, we set Type(Γ) to be the set of functors σ from the slice category C/Γ to thearrow category C→ that satisfy the following conditions:

• To any C-morphism s : B → Γ, σ(s) : dom(σ(s)) → B is a C-morphism with codomainB.

• To α : B′ → B, C/Γ-morphism, σ(s, α) is a C-morphism such that the upper square ofthe diagram in figure 2 is a pullback.

• σ(s, idB) = iddom(σ(s))

• If β : B′′ → B′ then σ(s, α ◦ β) = σ(s, α) ◦ σ(s ◦ α, β)

16

Page 17: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

dom(σ(s ◦ α))σ(s, α)

//

σ(s ◦ α)

��

dom(σ(s))

σ(s)

��B′

α//

s ◦ α

$$JJJJJJJJJJJJJJJJ B

s

{{wwwwwwwwwwwwwww

Γ

Figure 2: Definition of Type(Γ)

On the other hand, defining the terms is quite easy, we just use the correspondance withsections of the first projection (which we’ll define a bit later):Definition 4.2.2 (Terms(Γ, σ))

If Γ is an object of C and σ ∈ Type(Γ), then Terms(Γ, σ) is the set of sections of σ(idΓ), thatis 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 ∆ ` σ[γ], 〈γ, a〉 = σ(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Γ)

��Γ;σ

σ(idΓ)//

σ(idΓ)

""EEE

EEEE

EEEE

EEEE

EEΓ

idΓ

~~}}}}

}}}}

}}}}

}}}}

Γ

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 thusa term of Γ;σ ` σ[p]. qΓ,σ being unique, we choose it as the second projection of Γ; σ.

17

Page 18: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Γ;σ

idΓ;σ

��333

3333

3333

3333

3333

3333

3333

3

qΓ,σ

""FF

FF

FF

FF

F

idΓ;σ

**VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV

Γ;σ;σ[p]σ (idΓ, σ(idΓ))

//

σ[p](idΓ;σ)

��

Γ;σ

σ(idΓ)

��Γ;σ

σ(idΓ)//

σ(idΓ)

""EEE

EEEE

EEEE

EEEE

EEΓ

idΓ

~~}}}}

}}}}

}}}}

}}}}

Γ

Figure 4: Pullback and definion of the second projection

4.2.4 Substitutions

If γ : ∆ → Γ, we define σ[γ] by:

• If s : B → Γ, σ[γ](s) = σ(γ ◦ s).

• If α : B′ → 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.

id∆

��222

2222

2222

2222

2222

2222

2222

a[γ]

!!DD

DD

DD

DD

γ ◦ a

**UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU

∆; σ[γ]σ (idΓ, γ)

//

σ(γ)

��

Γ;σ

σ(idΓ)

��∆ γ

// Γ

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∆,σ ◦ 〈γ, a〉 = γ.

18

Page 19: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Proof. With our definitions:

p∆,σ ◦ 〈γ, a〉 = σ(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:

Γ;σ[γ]σ (id∆, γ)

// ∆; σ

σ(id∆)

��Γ

a

OO

γ// ∆

Proposition 4.2.2 (The second projection is well defined)

For γ : Γ → ∆, a : Γ ` σ[γ], we have q∆,σ [〈γ, a〉] = a.

Proof. We need to prove that a satisfies the two conditions for being q∆,σ [〈γ, a〉] and we’ll thenbe able to conclude with unicity.

As q∆,σ : ∆;σ ` σ[p∆,σ],

σ[p∆,σ](〈γ, a〉) ◦ a = σ (σ(id∆) ◦ σ(id∆, γ) ◦ a) ◦ a

As the following diagram commutes:

Γ;σ[γ]σ (id∆, γ)

// ∆; σ

σ(id∆)

��Γ γ

//

a

OO

We have σ(id∆) ◦ σ(id∆, γ) ◦ a = γ, so σ[p∆,σ](〈γ, a〉) ◦ a = σ(γ) ◦ a = id∆, which is the firstequation we need.

The other one is:

σ[p∆,σ] (id∆, 〈γ, a〉) ◦ a = σ(σ(id∆) ◦ id∆, σ(id∆, γ) ◦ a) ◦ a

Let us consider the following diagram:

19

Page 20: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

Γ;σ[γ]σ (σ(id∆), σ(id∆, γ) ◦ a)

//

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

��

∆; σ;σ[p]

σ(σ(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∆,σ [〈γ, a〉] = a.

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

20

Page 21: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

5. Conclusion

While we have managed to prove several equivalence results between known categorical modelsof type theory, much remains to do. In particular, finishing the transformation of locally cartesianclosed categories to categories with families with some extra structures. We can even hope thatthis transformation would be reverse to Pierre’s, which would effectively prove that categories withfamilies with intensional and extensional identity types, context products and Π and Σ-types areequivalent 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 wesuspect 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 mapbetween categorical structures and dependent type theory properties.

This subject, while extremely interesting, was a lot more difficult than I first thought, requiringmanipulation of complex abstract structures with the uttermost care. At least a third of theinternship was spent doing bibliographical work. The real research work began only in the lastweeks, when I had finally grasped most of the notions that we were dealing with. This is why Iregret not having had more time, for example to finish the transformation from locally cartesianclosed categories to categories with families. However, I intend to go back to Chalmers andcontinue working on this topic for my Master 2 internship.

The results presented here, in conjunction with Pierre’s, and certainly some more, are plannedto form the basis of a joint article with Pierre and Peter. Unfortunately, the initial plan of redactingit during the summer failed for logistic reasons, but we hope to be able to work on it sometimesoon.

21

Page 22: Categorical Models of Dependent Type Theoryenslyon.free.fr/rapports/info/Alexandre_Buisse_2.pdfCategorical Models of Dependent Type Theory Alexandre Buisse Under the direction of Peter

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 Hogskola 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 cate-gories. 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. CambridgeUniversity 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 Hogskola and ENS Lyon, 2004.

[See84] R.A.G. Seely. Locally cartesian closed categories and type theory. Math. Proc. CambridgePhil. Soc., 95:33–48, 1984.

[Tas93] A. Tasistro. Formulation of Martin-Lof’s theory of types with explicit substitutions.Master’s thesis, Chalmers Tekniska Hogskola and Goteborgs Universitet, May 1993.

22