<<

Extensional concepts in intensional

Martin Hofmann

Do ctor of Philosophy

University of Edinburgh

Abstract

Theories of dep endent types have b een prop osed as a foundation of constructive

mathematics and as a framework in which to construct certied programs In

these applications an imp ortant role is played by identity types which internalise

equality and therefore are essential for accommo dating pro ofs and programs in the

same formal system

This thesis attempts to reconcile the two dierent ways that type theories deal

with identity types In extensional type theory the prop ositional equality induced

by the identity types is identied with denitional equality ie conversion This

renders typechecking and wellformedness of prop ositions undecidable and leads

to nontermination in the presence of universes In intensional type theory prop os

itional equality is coarser than denitional equality the latter b eing conned to

denitional expansion and normalisation Then typechecking and wellformedness

are decidable and this variant is therefore adopted by most implementations

However the identity type in intensional type theory is not p owerful enough

for formalisation of mathematics and program development Notably it do es

not identify p ointwise equal functions functional extensionality and provides no

means of redening equality on a type as a given relation ie quotient types We

call such capabilities extensional concepts Other extensional concepts of interest

are uniqueness of pro ofs and more sp ecically of equality pro ofs subset types and

prop ositional extensionalitythe identication of equivalent prop ositions In this

work we investigate to what extent these extensional concepts may b e added to

intensional type theory without sacricing decidability and existence of canonical

forms The metho d we use is the translation of identity types into equivalence

relations dened by induction on the type structure In this way type theory with i

Abstract ii

extensional concepts can b e understo o d as a highlevel language for working with

equivalence relations instead of equality Such translations of type theory into

itself turn out to b e b est describ ed using categorical mo dels of type theory

We thus b egin with a thorough treatment of categorical mo dels with particular

emphasis on the interpretation of typetheoretic in such mo dels We then

show how pairs of types and predicates can b e organised into a mo del of type theory

in which subset types are available and in which any two pro ofs of a prop osition

are equal This mo del has applications in the areas of program extraction from

pro ofs and mo dules for functional programs For us its main purp ose is to clarify

the idea of syntactic translations via categorical mo del constructions

The main result of the thesis consists of the construction of two mo dels in

which functional extensionality and quotient types are available In the rst one

types are mo delled by types together with prop ositionvalued partial equivalence

relations This mo del is rather simple and in addition provides subset types and

prop ositional extensionality However it do es not furnish prop er dep endent types

such as vectors or matrices We try to overcome this disadvantage by using another

mo del based on families of typevalued equivalence relations which is however much

more complicated and validates certain conversion rules only up to prop ositional

equality

We illustrate the use of these mo dels by several small examples taken from

b oth formalised mathematics and program development

We also establish various syntactic prop erties of prop ositional equality includ

ing a pro of of the undecidability of typing in extensional type theory and a corres

p ondence b etween derivations in extensional type theory and terms in intensional

type theory with extensional concepts added Furthermore we settle armatively

the hitherto op en question of the indep endence of unicity of equality pro ofs in

intensional type theory which implies that the addition of pattern matching to

intensional type theory do es not yield a conservative

Acknowledgements

This thesis would not have app eared without the generous help and supp ort of

many p eople to whom I wish to express my deep thanks here

The rst p erson to thank here is my sup ervisor Don Sannella He has taught

me a lot on research in general and in particular on writing in our weekly meetings

He created a wonderful environment which allowed me to fo cus on my research

only without b eing o ccupied by nancial or administrative problems His detailed

comments on an earlier draft of this thesis resulted in imp ortant improvements My

second sup ervisor Gordon Plotkin has provided valuable guidance in discussions

and in particular has suggested and made p ossible a visit to Gothenburg during

which the idea for this thesis work arose Terry Stroup my former sup ervisor

from Erlangen brought me to Edinburgh and lo oked after me during my rst

year of studies I am grateful to Ro d Burstall and Andy Pitts for agreeing to b e

examiners of this thesis Ro d Burstall was a step sup ervisor as he once put it

during the whole p erio d of this research and help ed me a lot b oth p ersonally and

scientically

My friend and colleague Thorsten Altenkirch provided invaluable input to my

research and moral supp ort in many sometimes lively discussions He carefully

pro ofread an earlier draft and suggested ma jor improvements I also owe him

thanks for introducing me to Bath Street Housing Co op the place where I sp ent

my rst two years in Edinburgh My thanks go to the Co op members to o for

making me feel at home in Scotland

Thomas Streicher help ed me in many conversations made imp ortant sugges

tions and was a wonderful host during several visits of mine to Munich iii

Acknowledgements iv

The LFCS provided an excellent environment for scientic work The courses

the visitors the computing facilities and the administration to ok away most of

the diculties other young researchers have to cop e with

Thanks for stimulating conversations and suggestions on the sub ject of this

thesis go to David Aspinall Adriana Compagnoni Thierry Co quand Wolfgang

Degen Peter Dyb jer Bart Jacobs Per MartinLof Zhaohui Luo James Mc

Kinna Uwe Nestmann Benjamin Pierce Alex Simpson Martin Steen Makoto

Takeyama and the members of the Edinburgh Lego Club

Prof Ulrich Herzog and his colleagues have provided a desk and a computer

and b efore all a very friendly atmosphere during two p erio ds which I sp ent in

Erlangen

I wish to acknowledge nancial supp ort by Edinburgh University the DAAD

and the Europ ean Union HCM programme contract number ERBCHBICT

My very sp ecial thanks go to my wife Annette for her love and patience during

our geographical separation

Declaration

This thesis was comp osed by myself and the work rep orted herein is my own

unless explicitly declared otherwise Large parts of the material in Chapter have

already b een published in Sect Sect together with Th Strei

cher Sect v

Table of Contents

Introduction

Denitional and prop ositional equality

Extensional concepts

Metho d

The use of categorical mo dels

Syntactic mo dels

Applications

Application to machineassisted theorem proving

Overview

Syntax and semantics of dep endent types

Syntax for a core calculus

Raw syntax

Judgements

Notation

Derived rules and metatheoretic prop erties

Highlevel syntax

Telescopes

Elements of telescop es and context morphisms vi

Table of Contents vii

Denitions and substitution

Further type formers

Unit type

types

Function and cartesian pro duct types

The Calculus of Constructions

Universes

Quotient types

Abstract semantics of type theory

Syntactic categories with attributes

Type constructors

Interpreting the syntax

Partial interpretation

Soundness of the interpretation

Discussion and related work

Syntactic prop erties of prop ositional equality

Intensional type theory

Substitution

Uniqueness of identity

Functional extensionality

Extensional type theory

Comparison with Troelstras presentation

Undecidability of extensional type theory

Interpreting extensional type theory in intensional type theory

Table of Contents viii

An extension of TT for which the interpretation in TT is

I E

surjective

Conservativity of TT over TT

E I

Discussion and extensions

Conservativity of quotient types and functional extensionality

Related work

Pro of irrelevance and subset types

The renement approach

The deliverables approach

The deliverables mo del

Contexts

Families of sp ecications

Sections of sp ecications deliverables

Mo del checking with Lego

Records in Lego

Deliverables in Lego

Type formers in the mo del D

Dep endent pro ducts

Dep endent sums

Natural numbers

The type of prop ositions

Pro of irrelevance

Universes

Subset types

Table of Contents ix

Subset types without impredicativity

A nonstandard rule for subset types

Reinterpretation of the equality judgement

Related work

Extensionality and quotient types

The setoid mo del

Contexts of setoids

Implementing the setoid mo del S in Lego

Type formers in the setoid mo del

Prop ositions

Quotient types

Interpretation of quotient types in S

A choice op erator for quotient types

Type dep endency and universes

The group oid mo del

Group oids

Interpretation of type formers

Uniqueness of identity

Prop ositional equality as isomorphism

A dep endent setoid mo del

Families of setoids

Dep endent pro duct

The identity type

Inductive types

Table of Contents x

Quotient types

Discussion and related work

Applications

Tarskis xp oint theorem

Discussion

Streams in type theory

Category theory in type theory

Categories in S

Categories in S

Discussion

Enco ding of the copro duct type

Development in the setoid mo dels

Some basic constructions with quotient types

Canonical factorisation of a function

Some categorical prop erties of S

Subsets and quotients

Saturated subsets

Iterated quotients

Quotients and pro ducts

Quotients and function spaces

is cocontinuousintensionally

Parametrised limits of chains

Development in TT

E

Development in TT I

Table of Contents xi

Conclusions and further work

A Lego context approximating S

A Extensionality axioms

A Quotient types

A Further axioms

B Syntax

C A glossary of type theories

D Index of symbols

Chapter

Introduction

Theories of dep endent types have b een prop osed as a foundation of construct

ive mathematics and as a framework in which to construct certied pro

grams and to extract programs from pro ofs Using implement

ations of such type theories substantial pieces of constructive mathematics have

b een formalised and medium scale program developments and verications have

b een carried out

One key feature of dep endent type theories making them so apt for these

applications is that to a certain extent they allow the internalisation of meta

theorems they can sp eak ab out themselves For instance it is p ossible to

use such a type theory as a programming language and at the same time for

reasoning ab out these programs Then the pro of that eg a program meets its

sp ecication is an element of a certain type and the fact that this is so can b e

checked automatically

To a great extent this is made p ossible through the internalisation of equal

ity by propositional equality and more generally through the interplay b etween

prop ositional equality and intensional denitional equality

The main sub ject of this thesis is to study this interplay and in particular

extensions to prop ositional equality which maintain the desirable prop erties of the

denitional equality

Chapter Introduction

Denitional and prop ositional equality

In extensional type theory and axiomatic set theory the constant zero function

and the function dened by

if there is no counterexample to Fer

mats conjecture of size less than n

f n

otherwise

are probably equal whereas intensionally they are quite distinct b ecause their

denitions are entirely dierent On the other hand even in an intensional setting

there may b e a pro of that the extensions of the two functions agree In the presence

of such a pro of it should b e the case that whenever some denable prop erty holds

for the constant zero function then it also holds for f

However certain equalities do not require a pro of For instance in the ab ove

example the function f equals the function which searches for a counterexample

to Fermats conjecture Similarly we have

if true then e else e e

just by app ealing to the denition of the ifthenelse construct One therefore

sp eaks in the former case of a propositional equality whereas in the latter we have

an example of a denitional equality The precise b orderline b etween prop ositional

and denitional equality is uid but it app ears to b e commonly agreed that two

A simpler example of prop ositionally equal yet intensionally dierent functions is

x

given by the identity on the natural numbers and the function x NSuc sending

x to the xfold iteration of the successor function on zero The example with Fermats

conjecture is however more convincing since one could imagine an intensional theory in

which the former two functions b ecome identied by some rule for natural num

b ers whereas in no reasonable intensional or algorithmic setting would one identify two

functions the prop ositional equality of which is equivalent to Fermats conjecture

Chapter Introduction

ob jects are denitionally equal if after certain computation steps they evaluate

to identical results Traditionally denitional equality is therefore meant to b e

induced by a strongly normalising conuent rewriting system in an extended sense

we might simply require denitional equality to b e decidable and furthermore that

the decision pro cedure b e induced by some notion of terminating computation on

terms Indeed we shall consider notions of denitional equality dened indirectly

via interpretation in some syntactically constructed mo del

It is imp ortant that denitional equality is pervasive so if M and N are den

itionally equal then P M is denitionally equal to P N whatever P is In

particular the stating that M is prop ositionally equal to N is deni

tionally equal to the prop osition that M is prop ositionally equal to itself Since the

latter prop osition is always true denitional equality always entails prop ositional

equality but certainly not vice versa

This distinction b etween obvious identities which do not require a pro of and

meaningful identities which need to b e veried is the key dierence b etween

intensional and extensional theories In an extensional theory every identity needs

a pro of whereas in an intensional theory a notion of computation or denitional

expansion is built in

An illustrative example of denitional equality arises in category theory For

conceptual reasons one often do es not want to have an equality on ob jects Non

etheless such an equality is needed to state when a comp osition f g is dened

namely when the domain of f and the co domain of g agree A careful analysis of

common practice shows that the word agree here refers in most cases to den

itional equality of ob jects For example if GX A X one would b e allowed

Luo connes denitional equality to actual denitional expansion and considers

as an instance of computational equality However since computational and den

itional equality b ehave identically syntactically this distinction is merely a philosophical

one On the other hand MartinLof explains the use of the term denitional for

equalities like on the grounds that the noncanonical term former ifthenelse is

dened by and a corresp onding clause for false

Chapter Introduction

to comp ose a morphism with co domain GX with a pro jection but no category

theorist would write lets prove that the domain and co domain of the following

two morphisms are equal

A formal framework in which b oth prop ositional and denitional equality are

present is MartinLofs intensional type theory Denitional equality is ex

pressed by the equality judgement M N meaning that M and N are

denitionally equal terms of type in context type assignment There is also

a notion of denitional equality on types Prop ositional equality of

terms M and N is expressed by the judgement P Id M N meaning that

P is a pro of that M and N are prop ositionally equal terms of type in context

Here Id is MartinLofs identity type which is dened as an inductive family

with the single constructor ReM Id M M

In the presence of a type of prop ositions Prop one can also dene prop osi

tional equality by Leibnizs principle According to this principle a pro of that M

is prop ositionally equal to N is a pro of that whenever a prop erty P Prop

holds for M then it holds for N

These formulations demonstrate an imp ortant asp ect of prop ositional equality

in intensional type theorythe fact that it internalises pro ofs of equality Prop os

itional equality is identied with the type of its pro ofs and it is decidable whether

a term b elongs to this type or not In contrast in set theory one may dene an

identity type by

fg if M N

set

Id M N

otherwise

set set

Then Id M N is nonempty i M and N are equal but membership in Id M N

is not in general decidable so cannot b e considered a pro of that M equals N

A similar situation o ccurs in extensional MartinLoftype theory where

prop ositional and denitional equality are forcefully identied by the equality re

ection rule

P Id M N

IdDefEq

M N

Chapter Introduction

This rule makes denitional equality extensional and thus undecidable Sect

Moreover type checking b ecomes undecidable b ecause ReM Id M N holds

i M and N are denitionally equal Also the term ReM can no longer b e

considered a pro of that M and N are equal as is the case in of the ab ove identity

type in set theory For these and other reasons see Sect interest in ex

tensional type theory seems to have recently decreased We shall however explain

in Chapter that the equality reection rule can b e seen as a shortcut for longer

derivations in intensional type theory

Unfortunately the ab ovementioned formalisations of prop ositional equality

identity type and Leibniz equality suer from serious limitations when they are

used at types which are not inductive For example if P x Id f x g x is a

pro of that f and g are p ointwise prop ositionally equal then there is in general no

way of constructing an element of Id f g although in the presence of P the

functions f and g are clearly prop ositionally equal in the abstract sense This has

led to the common misunderstanding that the identity type was intensional This

is not so b ecause if M x and N x are expressions containing a free variable of

type then in certain cases an element of Id M x N x may b e constructed

by induction on x even if M x and N x are not denitionally ie intensionally

equal

Summing up we can say that denitional equality is intensionalit identies

ob jects which b ecome identical up on denitional expansion andor computation

and that idealised prop ositional equality is extensional but that it is not ad

Strictly sp eaking denitional equality do es not b ecome extensional here but the

equality judgement no longer expresses denitional equality To avoid the introduction

of a third notion of equality judgemental equality we shall by a slight abuse of language

identify denitional equality with the relation expressed by the equality judgement

Luo therefore calls the identity type weakly intensional A way of justifying

the predicate intensional for the identity type consists of decreeing that intensional

equality on op en terms refers to denitional equality of all closed instances

Chapter Introduction

equately captured by the identity type or Leibniz equality This thesis is an

attempt at overcoming this mismatch

Extensional concepts

We use the term extensional concept to refer to a desirable feature of prop os

itional equality which is not present in its traditional formulation In this thesis

several such extensional concepts are of interest notably the following

i Functional extensionality Two functions which are p ointwise prop osition

ally equal are prop ositionally equal

ii Uniqueness of identity Any two pro ofs of a prop ositional equality are pro

p ositionally equal

iii Pro ofirrelevance Any two pro ofs of a prop osition are prop ositionally equal

iv Subset types The presence of a type former which p ermits the formation of

a type of elements of a given type that satisfy a certain predicate

v Prop ositional extensionality Two prop ositions which imply each other are

prop ositionally equal

vi Quotient types The presence of a type former which p ermits arbitrary den

ition of prop ositional equality on some underlying type

These extensional concepts are not indep endent of each other In particular

iii implies iv and vi implies i see Sect Also v implies iii if one assumes

a distinguished prop osition with exactly one pro of The concepts iii v iv only

make sense if there is a dierence b etween prop ositions and arbitrary types In

this thesis this dierence is expressed by the assumption of a type of prop ositions

Prop and a type Prf P for each P Prop The prop ositions are then the types

of the form Prf P and the elements of these types are pro ofs If for conceptual

Chapter Introduction

reasons one do es not want to have a type of all prop ositions one can also introduce

a new judgement Prop to mean that the type P is a prop osition We only

hint at this alternative in Remarks

The concept of uniqueness of identity is of course a sp ecial case of pro of

irrelevance so it only makes sense in the absence of the latter for example in a

theory with prop ositions and types identied

In extensional type theory these extensional concepts are either present or can

b e added easily see eg Here we take on the more dicult task of adding

them to intensional type theory Apart from the advantages of intensional type

theory in general this has the desirable eect that we can add a choice principle

for quotient types which would b e unsound in any extensional theory

Extensional concepts could simply b e added axiomatically and justied se

mantically say by a settheoretic interpretation For example in order to achieve

functional extensionality we could simply assume a family of constants

Ext f g x Id f x g x Id f g

However in this case an imp ortant prop erty called Ncanonicity Def of

denitional equality will b e violated namely that every closed term of the natural

numbers is denitionally equal to a numeral The reason is that a term containing

an instance of Ext cannot b e denitionally equal to a numeral b ecause there are

no rules governing the b ehaviour of Ext wrt denitional equality This work

canto some extentbe seen as a quest for extensions of denitional equality so

as to include rules for these constants

An exception to this is uniqueness of identity As noticed by Streicher it

can indeed by added axiomatically and the axiom can b e endowed with a reduction

rule so that no noncanonical elements arise For us the concept is of relevance

b ecause it is needed to establish equivalence of extensional and intensional type

theory with extensional concepts added

The use of the natural numbers is arbitrary here One can easily show that a non

canonical element in some other type induces one in the type of natural numbers

Chapter Introduction

Metho d

The main to ol we use in order to achieve the goals set out ab ove consists of den

ing interpretations of the type theory with extensional concepts inside pure type

theory For example in order to achieve functional extensionality and quotient

types one interprets every type as a type together with an internal equivalence

relation and prop ositional equality at a particular type as this equivalence rela

tion Since this approach is inspired by Bishops denition of a set by its members

and its equality we call this translation the setoid interpretation Similarly

for subset types and pro ofirrelevance we use a translation of types into types

with unary predicates and of terms into terms plus pro ofs that these predicates

are resp ected Following Burstall and McKinna we call this translation the

deliverables interpretation

Given such an interpretation we can consider two ob jects denitional ly equal if

they receive denitionally equal interpretations and in this way ensure Ncanonicity

The use of categorical mo dels

It turns out that due to type dep endency the verication that a certain translation

indeed validates all the rules of type theory is quite dicult It has therefore

proven useful to insert the intermediate step of abstract categorical mo dels One

then denes a sound interpretation function from the syntax to the abstract mo del

once and for all and the task of proving that a certain translation is sound can

then b e reduced to the task of verifying that one has an instance of the abstract

mo del

This may b e compared to the situation in the simply typed

Instead of directly giving an interpretation of typed lambda terms in some math

ematical structure one can alternatively show that this structure forms a cartesian

closed category and then app eal to the general interpretation function mapping

Chapter Introduction

lambda terms to morphisms in an arbitrary cartesian closed category In

our situation the role of cartesian closed categories is played by syntactic categor

ies with attributes an equational presentation of Cartmells notion of categories

with attributes Such an equational presentation has the advantage that

the prop erty of b eing a mo del can b e checked using term rewriting normalisa

tion In this way we have enco ded all the syntactic mo dels within the Lego pro of

checker and advantageously used its normalisation features to verify them

Syntactic mo dels

So the task of interpreting type theory with extensional concepts can b e rephrased

as that of exhibiting a categorical mo del in which the desired extensional concepts

are valid The aims set out in Sect ab ove place certain restrictions on such

mo dels

Firstly in order that semantically dened denitional equality b e decidable

equality in the mo del must b e decidable which presupp oses that the semantic

ob jects come with some eective description

Second the mo del must have the prop erty that the type of natural numbers

consists of numerals only so that we obtain the desired prop erty that even in the

presence of an extensional concept every closed term of the natural numbers is

denitionally equal to a numeral Ncanonicity

Now any mo del satisfying these two requirements would meet the sp ecication

set out so far However in addition to this we want that the mo del explains the

extensional concepts in terms of more basic ideas More basic in this context

means in terms of type theory without extensional concepts added We thus seek

a syntactic model the ob jects of which are syntactical and the equality of which is

induced by the denitional equality of the underlying type theory

The interpretation in the mo del then not only induces a coarser notion of

denitional equality but actually computes syntactic expressions which no longer

contain the extensional concepts Extensional concepts may therefore b e seen as

abbreviations or macros for longer derivations in the theory without them

Chapter Introduction

In particular working in the syntactic mo del for functional extensionality and

quotients can b e viewed as using a highlevel language for working with equivalence

relations instead of equality and functions together with pro ofs that they resp ect

these relations instead of mere functions Similarly the syntactic mo del for subset

types and pro of irrelevance can b e understo o d as a highlevel language for working

with deliverables in the sense of ie functions together with pro ofs that they

resp ect certain predicates

We also encounter a mo del which cannot b e called syntacticthe groupoid

model It is similar in spirit to the syntactic mo dels we give and serves similar

purp oses The group oid mo del can b e seen as a renement of the setoid interpret

ation in which pro ofs are constrained by equations For example the pro of that

a function resp ects equality must resp ect symmetry This allows for a more ne

grained denition of semantic prop ositional equality on the identity type itself

which b oth shows the underivability of uniqueness of equality pro ofs and p ermits

a view of prop ositional equality of types as isomorphism

It turns out that the syntactic mo dels for the various extensional concepts

discriminate b etween the features present in the type theory under consideration

For instance the simplest mo del for quotient types do es not supp ort universes

and other more involved forms of type dep endency like the denition of a family

of types indexed over Bo oleans by case distinction It is p ossible to extend this

mo del to cover universes but then the extensional concepts are only available for

types in the universe and not for the universe itself Denition of types by cases is

still not p ossible On the other hand in a more complicated mo del in which these

type dep endencies are available certain exp ected denitional equalities only hold

prop ositionally for example certain instances of the computation rules asso ciated

to elimination of natural numbers Some of these limitations have a natural ex

planation in terms of the intended meaning of the particular extensional concept in

question others like the lack of certain denitional equalities are rather arbitrary

but nevertheless seem unavoidable

Of course here the question arises whether the metho d of syntactic mo dels is

not to o restrictive Certainly any approach to extensional concepts would mo dulo

Chapter Introduction

some co ding b e induced by a mo del which meets the rst two requirements on

a syntactic mo del viz semantic equality would have to b e decidable and the

interpretation of the natural numbers would have to consist of numerals only

Given that from the mo del one also exp ects some insight ab out the nature of the

extensional concepts not much choice is left We cannot exclude the existence

of such nonsyntactic mo dels but have not encountered any in the course of the

research rep orted here

Applications

The applications of extensional concepts are numerous Functional extensionality

is required when one wants to reason ab out higherorder functions and also when

co ding coinductive types and greatest xp oints using function types Quotient

types are of pivotal use in formalisations of pro ofs in constructive algebra since

the most elementary algebraic constructions involve quotients Quotient types also

provide bisimulation principles to reason ab out innite types This may facilitate

semanticsbased verication of concurrent programs Subset types can b e used

for mo dular sp ecication Here the additional computational principle that a

function on a subset type should embo dy an algorithm dened on the whole type

is imp ortant Sect Pro of irrelevance and prop ositional extensionality are

of more theoretical interest For example prop ositional extensionality implies

that quotient types are eective ie that if two equivalence classes are equal in a

quotient type then their representatives are related Sect We work out

several of these applications in some detail in Chapter

Most of the applications also go through if the extensional concepts are merely

assumed axiomatically without supp orting them by a syntactic mo del Indeed we

establish a conservativity prop erty Thm of which this fact is a general con

sequence The b enet of the syntactic mo dels in applications is threefold First

they show that using partial equivalence relations called b o okequalities in the Automath tradition is essentially equivalent to using prop ositional equal

Chapter Introduction

ity with extensional concepts added Even if one do es insist on b o okequalities

the syntactic mo dels may guide their use which is particularly imp ortant in the

presence of type dep endency Second they allow to gauge the dierences in ex

pressiveness b etween various approaches to b o okequalities eg equivalence re

lations vs partial equivalence relations Propvalued vs typevalued relations et

cetera Finally two of the syntactic mo dels we lo ok at give rise to a complete

separation b etween pro ofs and computations Denitional equality in the mo del

only compares the computational parts so that the decision pro cedure for equality

and type checking b ecomes more ecient

Application to machineassisted theorem proving

Theorem proving in type theories with or without extensional concepts is in prin

ciple p ossible by writing down derivations according to the rules For realistic

applications these rules are however unmanagable and one either has to move

to informal notation or use machine supp ort For ordinary type theory without

extensional concepts such machine supp ort exists in the form of pro of assistants

like Lego There are in principle two p ossibilities as to how a pro of assistant

can b e extended so as to provide extensional concepts

As said ab ove most of the applications go through with axiomatically added

extensional concepts The Lego system allows for the addition of axioms or con

stants and even for the addition of certain denitional equalities as rewrite rules

In App endix A we give Lego co de which approximates in this sense one of the syn

tactic mo dels for extensionality and quotient types a setoid interpretation The

main disadvantage of this simpleminded approach is that terms of the natural

numbers may contain instances of these axioms and thus not reduce to a canon

ical form We also encounter certain nonstandard op erations on subset types and

quotient types which cannot b e cast into the form of Lego constants

A deep er application of the work describ ed here consists of a changing the im

plementation of the pro of assistant itself so that it would compute interpretations

in a syntactic mo del of all types and terms o ccurring during a pro of session and

Chapter Introduction

use these interpretations to decide denitional equality and thus type checking

This would restore the ability of internal computation on terms and would also

supp ort the nonstandard op erations Additionally the interpretations could b e

made accessible to the user for subsequent pro cessing For instance in the case of

the syntactic mo del for pro ofirrelevance the computational part of the interpret

ation can b e seen as a program corresp onding to the computational content of a

pro of

Unfortunately such a change to a pro of assistant involves substantial practical

eort and thus falls b eyond the scop e of this thesis

Overview

Chapter recapitulates the syntax of dep endent type theory including universes

and impredicative quantication We use a judgementoriented presentation without

a logical framework In order to comp ensate for the lack of a logical framework

we develop a highlevel syntax for substitutions and free variables In the second

part of Chapter we introduce our notion of categorical mo del for dep endent type

theory socalled syntactic categories with attributes and we describ e the inter

pretation of syntax therein The denition of the interpretation function and the

soundness pro of closely follows

The third chapter is mainly devoted to a comparison b etween intensional type

theory with extensional concepts added and extensional type theory The main

result is that the latter is conservative over the former Together with the unde

cidability of extensional type theory we consider this result the main theoretical

justication for the use of intensional type theory with extensional concepts added

We also describ e some basic constructions with the identity type that are required

later such as the denition of MartinLofs elimination rule in terms of a Leibniz

principle

Chapter contains the rst syntactic mo del construction a deliverables inter pretation of the Calculus of Constructions which mo dels types as types together

Chapter Introduction

with a predicate The mo del supp orts subset types and pro ofirrelevance and

it interprets a nonstandard rule for subset types which under certain conditions

allows one to lift a function dened on a subset to a function on the whole set

The interpretation establishes a corresp ondence b etween two metho dologies for

program development in type theory the deliverables approach and the rene

ment approach We also sketch an application of the interpretation to typing of

higherorder mo dules

Our main purp ose in presenting the deliverables interpretation is however

to introduce the metho dology of describing translations of type theory into itself

using categorical mo dels and to indicate how the verication of such a categorical

mo del can b e mechanised using Lego

Chapter forms the kernel of this thesis It contains three mo del constructions

centred around extensionality and quotient types Section describ es an inter

pretation under which types are mo delled as types together with a Prop valued

partial equivalence relation setoids The interpretation is rather simple b e

cause type dep endency is only allowed at the level of the relations not for the

types themselves In this mo del functional and prop ositional extensionality sub

set types and quotient types can b e interpreted For the quotient types a choice

op erator may b e dened which under certain conditions allows a representative

to b e recovered from an equivalence class The mo del do es not contain any prop

erly dep endent types such as matrices and universes To alleviate this we lo ok at

an extension with universes obtained by amalgamating the setoid mo del with the

deliverables interpretation In this way a universe is supp orted but extensional

concepts b ecome restricted to types inside the universe

Sect describ es an attempt to overcome the lack of type dep endency in the

previous mo del We try to answer the question of what the right denition of a

family of setoids indexed over a setoid might b e under the hypothesis that the

underlying types of such a family should dep end on the underlying type of the

indexing setoid The criterion for the value of such a denition is of course that

the families must form a syntactic category with attributes and supp ort as many

type formers as p ossible as well as functional extensionality The answer turns out

Chapter Introduction

to b e rather unsatisfactory the mo del is quite complicated and the verication

even of the type of natural numbers is extremely complicated

In Sect thein our opinionmost natural solution to the ab ove question

of dep endent setoids is describ ed the group oid interpretation of type theory It is

however not a syntactic mo del but can only b e dened in extensional type theory

or set theory We show how the group oid interpretation answers the question

of indep endence of uniqueness of identity and how it p ermits one to interpret

prop ositional equality on a universe as isomorphism It also motivates the setup

of the dep endent setoid mo del in Sect which is why we describ e it rst

Chapter is devoted to applications of the extensional concepts and of the

conservativity of extensional type theory over intensional type theory with exten

sional concepts added Many of these applications have b een actually formally

developed within the Lego pro of checker

Sect studies a formalisation of Tarskis generalised xp oint theorem using

subset types The main lemmaa prop erty of p osetsis instantiated in the course

of the pro of with various subp osets of a given one whence the need for subset

types Our development is based on an earlier formalisation by Pollack which can

b e viewed as the result of translating our development to intensional type theory

using the interpretation in the deliverables mo del

Sect studies an imp ortant application of functional extensionalityan en

co ding of innite lists streams as functions We derive a coinduction principle

for these streams and dene a xp oint combinator the verication of which makes

heavy use of coinduction

In Sect we describ e a simpleminded enco ding of category theory in type

theory with extensional concepts prop ositional equality is used to compare b oth

ob jects and morphisms We investigate how this enco ding gets translated un

der the various interpretations in terms of setoids The resulting enco dings in

pure intensional type theory resemble enco dings prop osed indep endently by other authors

Chapter Introduction

Sect serves a similar purp ose We show how an enco ding of disjointunion

types in extensional type theory due to Troelstra gets translated under the setoid

interpretations In particular we show in some detail how functional extensionality

gets eliminated

Sect is devoted to an examination of our syntax for quotient types by

redoing certain constructions with quotient sets collected by Bourbaki in order

to b ecome indep endent of their enco ding as sets of equivalence classes All but one

construction go through we explain why this one isomorphism b etween the two

denitions of the image of a function as a subset and as a quotient must fail under

a constructive understanding of quotienting as a redenition of prop ositional

equality

Finally Sect gives an application of the conservativity of extensional type

theory over intensional type theory We give an extensional typetheoretic vari

ant of a theorem due to Mendler which involves indexed families of sets Our

formalisation is such that the conservativity theorem implies the existence of a

pro of of this theorem in intensional type theory with functional extensionality and

uniqueness of identity However we were not able to come up explicitly with such

a pro of This application suggests that in certain situations extensional type

theory might b e useful as a highlevel language for type theory with extensional

concepts

Each of the four theoretical chapters ends with a section discussing p ossible

extensions and related work General conclusions and some directions for future

research are summarised in Chapter

The app endix contains a summary of the typetheoretic rules used throughout

the thesis a glossary of type theories app earing in the thesis and an index of

symbols We also include a translation into Lego syntax of some of the rules for extensional concepts

Chapter

Syntax and semantics of dep endent types

In this chapter we x a particular syntax for a dep endently typed calculus and

dene an abstract notion of mo del as well as a general interpretation function

mapping syntactical ob jects to entities in a mo del This interpretation function is

shown to b e sound with resp ect to the syntax

Syntax for a core calculus

We start by giving a syntactic description of intensional MartinLof type theory

with types natural numbers and the identity type On top of this we can

add further inductive types types universes impredicative quantication and

so forth in order to accommo date richer systems like the Calculus of Constructions

or LegoECC The syntax we give do es not make use of a logical

framework as eg in or We could however view the core calculus as

a framework and make all further denitions of types inside some universe So we

do not really commit ourselves to a particular style of presentation

Raw syntax

The raw syntax is formed out of three categories precontexts pretypes and

preterms These are dened by the grammar in Fig

Chapter Syntax and semantics of dep endent types

empty context

j x context extension

N natural numbers

j x dep endent pro duct

j Id M N identity type

M N O P x variable

j N introduction zero

j SucM N introduction successor

N

j R M N O N elimination induction

j x M typed abstraction

j App M N typed application

j Re M identity introduction

j J M N O P identity elimination

Figure Syntax of preconstructions

A few remarks concerning this presentation are in order First note that we

include type information in application and abstraction This makes the denition

of the interpretation function for mo dels easier and it app ears somewhat arbitrary

to leave the type information out in this particular place Indeed much more type

information could b e inferred automatically and for an actual implementation one

would set up some sort of front end which would generate as much type information

as p ossible so that the syntax we give here would only app ear as an intermediate

language Cf also Streicher where situations are indicated in which the

typing information in an application can not b e inferred To increase readability

we shall however often suppress type information informally and in particular we

abbreviate App M N by MN and x M by x M or even xM where

appropriate See Co quands survey article Sect for a deep er discussion

of such abus de langage

Chapter Syntax and semantics of dep endent types

Second we are a bit sloppy ab out variable in our presentation For

N

example as will emerge from the typing rules the type in of R contains a free

N

variable of type N which b ecomes b ound in R To b e consistent with the usual

notation we make this binding explicit in the case of types but otherwise not

since it would lead to overly clumsy terms

We identify all constructions up to renaming of b oth free and b ound variables

and ensure by a suitable renaming p olicy that no unwanted variable captures

o ccur This could b e made more precise by using de Bruijn indices instead of

named variables but the price to pay is that syntactic weakening would no longer

b e the identity and thus notation would b ecome less readable

The union of preterms types and contexts is called the set of preconstruc

tions The prex pre indicates that these need not typecheck in any sense

The actual terms types and contexts constructions are those which o ccur inside

the typing judgements to b e dened in the next section To avoid rep etition we

use the synonyms element function op eration for terms where the latter

two are mostly used for terms with distinguished free variables We also sometimes

say set instead of type

Judgements

There are six kinds of judgements

is a wellformed context of variable declarations

is a type in context

M M is a term of type in context

The contexts and are equal

The types and b oth in context are equal

M N The terms M and N of type are equal

The last three kinds of judgements state denitional equality of contexts types

and terms The valid judgements are dened inductively by the following clauses

Chapter Syntax and semantics of dep endent types

Context rules

Valid contexts are generated from the empty context by successive extensions

Empty Compr

x

It follows from our conventions on variable names that in rule Compr the variable

x do es not o ccur in

Type formation rules

For each of the type formers N Id there is a formation rule stating the con

ditions under which a pretype having that type former as outermost constructor

is wellformed In particular the type formation rule for sp ecies its binding

b ehaviour

M

x N

Form IdForm NForm

x Id M N N

Term formation rules

First there are two structural rules which dene the typing of variables and

type conversion along type equalities

M x

Var Conv

x x M

The following rules each corresp ond to a constructor on preterms and dene its

wellformedness and typing In particular they dene the binding b ehaviour of

N

and J The rules can b e group ed in pairs according to the term formers R

whether a certain type app ears in the conclusion introduction or in a premise

elimination of the rule The rules corresp onding to the type are

x M M x N

Intro Elim

x M x App M N x N

Chapter Syntax and semantics of dep endent types

The introduction rules for the natural numbers dene the constructors and Suc

whereas the elimination rule denes mathematical induction

M N

NIntro NIntroSuc

N SucM N

x N

M x

z

x N p M x Sucx

s

N N

NElim

N

R M M N x N

z s

Notice here that the free variables x in as well as x and p in M are b ound by

s

N

R We could have chosen a notation like

N

M x Np M N R

z s

xN

to emphasise this Instead we dene later in Sect a highlevel syntax for terms

and types with free variables

Finally for the identity type Id M N the introduction rule corresp onds to

reexivity whereas the elimination rule is a generalised Leibniz principle which

we study in more detail in Chapter

M

IdIntro

Re M Id M M

x y p Id x y

x M x xy xp Re x

N

N

P Id N N

IdElimJ

J M N N P x N y N p P

Chapter Syntax and semantics of dep endent types

Denitional equality

Denitional equality of types terms M N and contexts

is dened as the least congruence with resp ect to all type and term formers

closed under denitional expansion This means that denitional equality is

reexive symmetric and transitive

TRefl TSym TTrans

with analogous rules for denitional equality on contexts and terms Further

more there are congruence rules for every type and term former for example the

congruence rule for the successor and for the type are

M M N x

C CSuc

SucM SucM N x x

Notice also the congruence rule for context extension

CCompr

x y

Sp ecial attention is drawn to the congruence rule for abstraction rule b ecause

it is left out in some presentations of type theory See and Sect

x x x M M

CAbstr

x M x M x

Finally closure under denitional expansion is formalised by the following rules

which are all understo o d under the premise that the resp ective left and right hand

sides b oth have the indicated types

Beta

App x M N M x N x N

NatCompZero

N

R M M M x

z s z

NatCompSuc

N

R M M SucN

z s

N

M x N p R M M N x SucN

s z s

Chapter Syntax and semantics of dep endent types

IdComp

J M N N Re N

M x N x N y N p Re N

Notice that unlike prop ositional equality given by Id the denitional equality is not

annotated by any justication or pro of whatso ever Thus M M states

that M and M are denitionally equal terms of type whereas P Id M M

states that P is a pro of that M and M are prop ositionally equal terms of type

in context Also a denitional equality can never app ear as an assumption in

a context whereas prop ositional equality obviously can This stands in contrast

to the system presented in in the framework of socalled labelled deductive

systems

Notation

The empty context is usually left out in judgements so we write N instead of

N We sometimes write J for an indeterminate judgement where J may

b e of the form M M N In the running text the

ambient context and the derivation symbol are often left out and informal

equality reasoning may b e used to justify equality judgements thereby implicitly

using reexivity symmetry transitivity and the congruence rules

We shall in the sequel sometimes use an abbreviated notation for inference

J

is rules whereby we omit the context carried along previously So a rule

J

J

understo o d as This abbreviated notation app ears also in and We

J

also use this abbreviated notation in the running text so phrases like let M

b e are understo o d in arbitrary context If then we sometimes write

true to mean that there exists M with M

The implicit typing premises to equality rules mentioned ab ove Sect

are also required in all subsequent equality rules So an equality rule of the form

P

M N

Chapter Syntax and semantics of dep endent types

is understo o d as

P M N

M N

We use the symbol for syntactic identity including conversion So x Nx

y Ny but x Nx

The set of settheoretic natural numbers is denoted If n we sometimes

write n also for the corresp onding numeral in N for example we write abbreviate

SucSucSuc by

Derived rules and metatheoretic prop erties

The metatheory of systems like the ab ove has b een the sub ject of extensive study

For our development we need the following metatheoretic

prop erties whose pro ofs are standard and may b e found eg in

Prop osition Weakening Let and If the judgement

J is derivable then so is x J

Prop osition Substitution Let x and M If the judge

ment x J is derivable then so is x M J x M

Prop osition If then If then If M

N then M

Prop osition Strong normalisation The rewrite system obtained by dir

ecting the nonlogical equality rules Beta IdComp NatCompZero Nat

CompSuc from left to right is strongly normalising This induces a decision

procedure for denitional equality

Prop osition Decidability It is decidable whether a judgement J is derivable

Chapter Syntax and semantics of dep endent types

Remark The strong normalisation property implies in particular that every

term in the empty context is denitional ly equal to a canonical one ie a term

having Re Suc or as outermost term former

Prop osition Unicity of typing If M and M then

Prop osition Unicity of type formation If x x

then and x If Id M N Id M N then

and M M and N N

These metaprop erties continue to hold mutatis mutandis for the various exten

sions to the core type theory we are going to make

Ncanonicity

We are now in the p osition to make precise what we mean by the prop erty that

in the empty context terms of the natural numbers are canonical which we hinted

at in the Introduction

Denition Ncanonicity A type theory with natural numbers is Nca

nonical if whenever M N then M Suc Suc for some n

z

n times

It follows from Prop and Remark ab ove that the core type theory

describ ed so far is Ncanonical We remark that if M N is a noncanonical

element of the natural numbers and L is any term of type then

N

R L x N y L M is a noncanonical element of type so that the role of

N in the denition of Ncanonicity is arbitrary

Chapter Syntax and semantics of dep endent types

Highlevel syntax

In the syntactic mo del constructions we are interested in we need to dene various

op erations on contexts and will require the notion of relative contexts or tele

scop es We thus introduce some highlevel syntax and derived rules and

judgements in order to deal with these We also introduce some abbreviational

machinery to deal with denitions and substitutions

Telescopes

If and x x are precontexts then we write as an abbrevi

n n

ation for the n judgements x up to x x

n n n

In this case we say that is a context relative to or a telescope wrt It can b e

shown by induction that i where according to our convention the

variables in have b een suitably renamed The type equality judgements are

extended accordingly to telescop es Ie we write if and have

the same length and denitionally equal comp onents

Elements of telescop es and context morphisms

Assume with x x If f M M is an ntuple

n n n

of preterms then we write f as an abbreviation for the n judgements

M M x M up to M x M x

n n n

M We then call f an element of the telescope In the sp ecial case where

n

is indep endent of ie we have and we call f a substitution or a context

morphism from to In this situation we write f Denitional equality

is extended canonically to elements of telescop es that is we write f f

if f and f have the same length and denitionally equal comp onents

Syntactic substitution generalises to elements of telescop es If f and

then we write x x f for the parallel substitution of all

n

variables x through x in by their companions in the ntuple f We then have

n

Chapter Syntax and semantics of dep endent types

x x f If the variables are clear from the linguistic context we

n

also write f An analogous notation applies to substitution inside terms and

telescop es

The context morphisms include the identity from to which consists of the

tuple of variables in and they are closed under comp osition ie if f is a context

morphism from to and g is a context morphism from to then the parallel

substitution of f into g gives a context morphism from to denoted g f In this

way the contexts form a category ie comp osition is asso ciative and the identity

is neutral

We remark that the prop erty of unicity of typing Prop which holds for

terms do es not extend to elements of telescop es For example the pair Re

N

can b e viewed as a substitution from to x N p Id x x or to x N p

N

Id Therefore elements of telescop es ought to b e annotated with typing

N

information which we shall however usually omit

Since we are going to describ e constructions involving abstractly given contexts

and telescop es we need a means of introducing variables for them If is a pre

context of length n and if is an ntuple of variables then

n

denotes with its variables renamed to This allows us for example to

n

write

Denitions and substitution

Assume for some type expression By the declaration

the metavariable b ecomes an abbreviation for the expression This notation

emphasises that the variables from are free in For example we may dene

eqzeron N Id n

N

and in ambient context maxint N

eqmaxn N Id n maxint N

Chapter Syntax and semantics of dep endent types

Explicit variable names in a substitution may now b e omitted for example the

expression eqzero denotes Id and eqmax denotes Id maxint We

N N

also use square brackets as a form of rstorder abstraction Ie we may write

to emphasise the variables in The ab ove declaration can thus equivalently

b e written as

Whenever or app ears inside some term then by suitable renaming it is

ensured that none of the variables are captured

Analogous conventions apply to terms telescop es and elements The main

application of rstorder abstraction is the instantiation of binding op erators like

N

R For example the following is a somewhat contrived pro of that every natural

number is equal to itself

n N

N

by ind on n R

nNId nn

N

Re base case

N

n N p Id n nRe Sucn ind case

N N

n Id n n conclusion

N

N

Observe the scoping of variable names here The n in the subscript to R is

dierent from the one declared in the global context

It is the hop e of the author that with these conventions a reasonable comprom

ise b etween readability and formal correctness has b een found

Chapter Syntax and semantics of dep endent types

Further type formers

In this section we introduce the syntax of a few further type formers such as

types and universes We also describ e how Co quandHuets Calculus of Con

structions ts into our syntactic framework It is understo o d that whenever a rule

introduces new type or term formers then the raw syntax is suitably extended to

account for these and denitional equality is extended accordingly

Unit type

We start with a unit type which is sometimes handy for technical reasons It

introduces a type with single canonical element The unit type comes with an

induction principle stating that is the only inhabitant of up to prop ositional

equality We shall later Sect consider an extensional unit types which

contains a single element up to denitional equality

UnitForm UnitIntro

x x M N

UnitElim

R M N N

UnitComp

M M R

types

types serve to internalise telescop es They are given by the following rules

M N M x x

Form Intro

x x pair M N x x

p x x p

x y x M x y pair x y P x x

Elim

R M P P

Comp

R M pair N O M N O pair N O

Chapter Syntax and semantics of dep endent types

In case type information can b e inferred from the context we abbreviate the pairing

op erator pair M N by M N By suitable instantiation of R we can dene

pro jections and which provide a left inverse to the pairing op erator viewed

as the context morphism x y pair x y x

M R x y x M

M R x y y M M

px p

Now from Comp we get pairM N M and pairM N N But pairing

is not surjective which is why types only approximate the summation obtained

from telescop es However using R we can nd a term of the type

p x Id p hp pi

x

namely R p x y Re pairx y Thus surjective pairing holds pro

x

p ositionally

Function and cartesian pro duct types

Function spaces and cartesian pro ducts are sp ecial cases of dep endent pro duct and

sum Writing x and x we have and

provided and and we obtain corresp onding introduction and elimination

rules

Although types and unit type are not absolutely crucial we consider them

from now on as part of the core type theory which we henceforth refer to by TT

The type theory TT is a subsystem of MartinLofs intensional type theory

The Calculus of Constructions

Co quandHuets Calculus of Constructions is a dep endently typed calculus

with pro ducts types only and a universe Prop that is closed under impredic

Chapter Syntax and semantics of dep endent types

ative quantication The latter is describ ed by the following rules

S Prop

PropForm ProofForm

Prop Prf S

x S x Prop

PropIntro

x S x Prop

PropEq

Prf x S x x Prf S x

The terms of Prop are called prop ositions If M Prop is a prop osition then

Prf M is the type of its pro ofs A type of the form Prf M for some M Prop

is also called a prop osition The term prop ositions for these terms and types

can b e misleading b ecause in some applications of the Calculus of Constructions

the universe Prop is used to represent b oth datatypes and prop ositions In

the present work this will not b e done

The op erator together with the equation PropEq gives that the pro duct

over a family of prop ositions indexed over is a prop osition again In Co quand

and Huets original presentation terms of type Prop and their corresp onding

Prf types were syntactically identied The presentation used here is due to

Streicher The Calculus of Constructions has types in the empty context for

example the type of falseho o d s PropPrf s

We use logical connectives tt ff for their enco dings in the Calcu

lus of Constructions If P Q Prop then their implication P Q is dened

as the prop osition x Prf P Q their conjunction is dened as the prop osition

c PropP Q c c and their disjunction P Q is given by c PropP

c Q c c The true prop osition tt is dened as c Propc c The false

prop osition ff is dened as c PropPrf c The P of prop osition P is

dened as P ff If x P Prop then we dene the existential quantication

of P as x P c Prop x P c c For M N we dene Leibniz

L

equality M N as

P PropP M P N

Chapter Syntax and semantics of dep endent types

It is wellknown that the pro of rules for these connectives in higherorder intu

itionistic logic are derivable Extending the notation from Sect we write

P true for P Prop to mean that there exists P with P Prf P

The syntactic prop erties stated in Sect including decidability of equality

continue to hold for the Calculus of Constructions see eg

Universes

A universe is a type U containing names or co des for types This is achieved by

an op erator El which for each term M U gives a type ElM A universe can b e

closed under various type formers in which case there are functions similar to

which p erform the type formation on the level of co des As an example we give

the rules for a universe closed under and containing the natural numbers

M U

UForm ElForm

U ElM

S U x ElS T U

UIntro

S T U

UEq

ElS T x ElS ElT

UIntroN UEqN

N U ElN N

We do not consider universeinduction p Universes can b e used

to represent mo dules and also increase the strength of the type theory For

example in the presence of a universe containing an empty type which we

havent dened it b ecomes p ossible to nd an inhabitant of the type p

Id Suc which corresp onds to Peanos fourth axiom For a type

N

theory without universes it may therefore b e appropriate to introduce this as an

axiom by the following rule

M Id Suc

N

Peano

Peano M

Chapter Syntax and semantics of dep endent types

This rule do es not introduce noncanonical elements in the empty context b ecause

with the premises to Peano cannot b e met In it is shown how a

term Peano M can b e dened by induction on the form of in the core type

theory without empty types and universes Cf also Sect

Quotient types

Quotient types p ermit the redenition of the prop ositional equality on a type

According to the particular notion of prop ositional equality chosen we obtain dif

ferent formulations of quotient types In this thesis we study quotient types with

resp ect to Leibniz equality Sect the identity type Sects and

marginally also wrt extensional denitional equality Sect We de

fer the syntactic rules to these sections Here we only remark that intensional

formulations of quotient types must invariably introduce noncanonical elements

of identity types which establish prop ositional equality of equivalence classes of

related elements and therefore the statement made in Remark is no longer

true in the presence of quotient types unless denitional equality is redened using

a syntactic mo del like the ones presented in Chapter

Abstract semantics of type theory

As describ ed in the Introduction we require a precise denition of what a mo del for

a dep endently typed calculus should b e and also a generic interpretation function

mapping syntactic ob jects to ob jects in the mo del Many notions of mo del have

b een prop osed in the literature for a comprehensive treatment see eg We

use a derivative of categories with attributes as introduced by Cartmell and

later used by Pitts dubb ed type categories there and Moggi This notion

seems to oer the right level of generality for our purp oses and nevertheless do es

not introduce any unnecessary formal padding

As opp osed to the displaymap approach or contextual categories in categories with attributes a distinction is made b etween families the

Chapter Syntax and semantics of dep endent types

of types and their corresp onding context extensions In particular

the map which assigns the corresp onding context extension to a family need not

b e injective This extra generality will b e required in almost all the mo del con

structions we shall study

The original denition of categories with attributes involves conditional equa

tions since certain diagrams are required to b e pullbacks This is a disadvantage if

one wants to construct mo dels internally in some type theory and check the mo del

equations using normalisation We thus describ e a notion of mo del without con

ditional equations inspired by Curiens categorical combinators This

means that in addition to abstract contexts and families we introduce a third sort

of abstract sections which are in oneone corresp ondence to sections right inverses

to pro jections Their separate introduction allows to quantify over them without

using conditional equations Ehrhard and Ritter achieves the same goal

by introducing arbitrary morphisms b etween families as a new sort For our pur

p oses this app ears overly general and the price to pay is that a formal unit type

must b e introduced and that the equational theory b ecomes more complicated

Since a guideline in our description of the semantics of dep endent types is to

stay as close to the syntax as p ossible without losing the advantages which abstract

semantics oers we have chosen the name syntactic categories with attributes for

the notion of mo del to b e describ ed here

Syntactic categories with attributes

Denition A syntactic category with attributes is given by the fol lowing

data

i A category C with terminal object The objects of C are called contexts A

B the morphisms f g h are called context morphisms

The unique morphism from the terminal object to is denoted

Read Alpha Beta

Chapter Syntax and semantics of dep endent types

op

ii A functor Fam C Sets If f C is a context morphism

and Fam then Famf Fam is abbreviated by ff g The

elements of Fam are called types or families in context

iii If is a family in context then there is a context called the compre

hension of and a context morphism p C called the display

map or the pro jection of Moreover if in addition f CB then

qf CB ff g and

qf

B ff g

p ff g p

B

f

commutes The assignment q is functorial in the sense that qid

id and for g CA B also qf g qf qg ff g Note that

these equations typecheck by virtue of the functoriality of Fam

iv For each Fam there is a set Sect of sections or terms M N

v If M Sect for Fam then M C and

p M id SectChar

or diagrammatically

M

p id

R

Henceforth all diagrams are supp osed to commute unless stated otherwise The diagrams have b een typeset using Paul Taylors versatile macro package

Chapter Syntax and semantics of dep endent types

vi If Fam and f C then Hdf Sect fp f g and

qp f Hdf f MorInv

or diagrammatically

qp f

fp f g

f

Hdf p

p f

Moreover if f and M Sect ff g then

M SectInv M Hdqf

which at the level of contexts becomes

qf

ff g

M Hdqf M p

M qf

f

This denition is rather condensed and may need some explanation C b eing a

category means that there is an asso ciative comp osition for context morphisms

which has a left and rightneutral element the identity id Fam b eing a functor

op

from C to the category Sets of sets and functions means that for each context

there is a set Fam of p ossible interpretations of types over and if f B

then Famf is a function from Fam to FamB written ff g and satisfying

fid g and ff g g ff gfg g for Fam and g A B

The pro jection p asso ciates to each family Fam a forgetful context

morphism Its co domain corresp onds to the extension of context

by type Substitution along the morphism p corresp onds to weakening

The morphism qf ff g can b e seen as a weakening of f

On the part of ff g it b ehaves like f this expressed by the commutative

Chapter Syntax and semantics of dep endent types

square for q and on the ff gpart it do es nothing this is indirectly expressed by

the equation MorInv

The mapping M M asso ciates a context morphism to a section M from

to which is the identity everywhere but on the last comp onent This

is expressed by the equation SectChar The equation MorInv is a kind of

surjective pairing prop erty for context morphisms It expresses that and how

f can b e recovered from its two comp onents Hdf and p f

The at rst sight strange typing of Hd may b e explained as follows A

context morphism f should b e thought of as containing two com

p onents A context morphism from to obtainable as p f and a section

of submitted to substitution along this rst comp onent of f ie an element of

Sect fp f g This is Hdf

We continue by giving a few examples of syntactic categories with attributes

which should clarify the denition further In particular the term mo del provides

some more intuition and should b e carefully gone through by the reader unfamiliar

with categorical mo dels of type theory

Example Term mo del Consider a calculus of dep endent types T like

the core calculus TT describ ed in Section We construct a syntactic category

with attributes which will later turn out to b e the initial one The underly

ing category of contexts C has as ob jects the wellformed contexts of T and

as morphisms context morphisms as dened in Sect mo dulo denitional

equality This is easily seen to b e a category in which the empty context is a

terminal ob ject For a context the set Fam is the set of wellformed types

in this context ie the set of valid judgements Context extension is in

herited from the syntax so x and the display map p

is the context morphism consisting of the variables in Substitution is syn

tactic substitution ie if M M B x x then

n n n

fM M g B x M x M The weakened con

n n n

text morphism qM M B x x M x M x

n n n

b etween the resp ective comprehensions then b ecomes M M x where x

n

Chapter Syntax and semantics of dep endent types

x M x M is the last variable of the comprehension of the substi

n n

tuted type If is a family then Sect is the set of terms M again

mo dulo denitional equality To such a section we asso ciate the context morph

ism x x M x x M Finally if f M M is

n n n n

a context morphism we put Hdf M The verication that this forms a syn

n

tactic category with attributes is straightforward The term mo del of the Calculus

of Constructions has b een thoroughly studied by Streicher in particular a

completeness result for abstract categorical semantics wrt syntax is proved there

The next example is taken from with minor adjustments

Example Families over sets Let F b e a small category with terminal

ob ject We form a syntactic category with attributes over the category Sets of

sets and functions as follows If is a set then Fam is the set of all functions

from to ObF If Fam then is the disjoint union f s j

and s F g The map p is the rst pro jection If furthermore

f B then ff g is the comp osition f and qf sends b s where

b B and s F f b to f b s Finally Sect is the cartesian pro duct

Q

F We leave the remaining denitions and the verications to the

reader

In this example families carry an intensional structure namely the morphisms in

F which are not global sections and thus are not reected into the underlying

category

Example Settheoretic mo del An imp ortant sp ecial case of the previ

ous example arises when F is chosen to b e the full sub category of Sets consisting

of small sets ie with cardinality smaller than some inaccessible cardinal see

Sect We then obtain the familiar settheoretic mo del of type

theory which may eg b e used to demonstrate equational consistency ie the fact

that the type Id Suc is not inhabited

N

Example Families of sets An set is a pair X jX j where

X

jX j is a set and is a surjective relation b etween jX j and the set of natural X

Chapter Syntax and semantics of dep endent types

numbers If n x for some n and x jX j then we say that n realises x

X

or that n is a realiser for x Surjectivity means that every element of jX j has a

realiser A morphism b etween two sets X and Y is a function f from jX j to jY j

for which there exists a natural number n viewed as a co de for a partial recursive

function such that for all x jX j and realisers m x the computation fngm

X

terminates and is a realiser for f x We write fngm for the application of the

partial recursive function co ded by n to input m We say that f is tracked by

n The sets with these morphisms form a category with terminal ob ject given

by the singleton set fg equipp ed with the trivial realisability relation ie every

natural number realises and the unique morphism is realised by any co de for a

total recursive function

We construct a syntactic category with attributes over the category of sets

as follows A family over an set is an assignment of a small set to each

element of jj If is such a family then its comprehension is

jj

dened by j j f s j jj and s j jg and n s i fp gn

and fp gn s where p and p are co des for the comp onents of some recursive

bijection b etween and The display map p is the rst pro jection tracked

by p If is such a family ab ove and f is a morphism from B to tracked

by n then we dene the substitution ff g simply by comp osition viz as the

family The morphism qf sends s to f s and is tracked

f jBj

by the pairing of n and a co de for the identity If is as b efore then a section

Q

is an element M of the cartesian pro duct j j together with a realiser ie

jj

some natural number n such that whenever m then fngm M We

leave the denition of the remaining comp onents to the reader

Remark One might try to dene a syntactic category with attributes over

Sets say by dening Fam as the set of al l functions with codomain and

is such a function and furthermore f B then to dene if

Chapter Syntax and semantics of dep endent types

substitution as the pul lback

fb s B j f b sg

B

f

This does not work because then for example fid g is only isomorphic but not

equal to Also the composition law is not strictly satised In we describe

a canonical construction which turns a structure like the above into a syntactic

category with attributes

Some remarks on notation We usually refer to a syntactic category with

attributes by the name of its category of contexts If C is any category then a

syntactic category with attributes having C as underlying category of contexts

will b e called a syntactic category with attributes over C Whenever we use one

of the op erator symbols which were part of the denition of a syntactic category

with attributes it should b e clear from the context to which syntactic category

with attributes we are referring

Although the formulation of the ab ove denition might suggest something dif

ferent a syntactic category with attributes is meant to b e a structure ie the

various comp onents referred to by the op erator symbols are explicitly given and

not merely required to exist The same applies to further denitions in this style

We b egin our investigation of syntactic categories with attributes with a char

acterisation of the sections as sp ecial context morphisms

M is a bijection Prop osition Let Fam The assignment M

between Sect and ff j p f id g

Pro of One direction is part of the denition of a mo del Conversely if f

has the sp ecied prop erty then Hdf is a section of fid g It is

immediate from the denition that these two maps are inverse to each other 2

Chapter Syntax and semantics of dep endent types

So up to bijective corresp ondence the set Sect is the set of sections of the

corresp onding display map By making these sections part of the structure we can

quantify over sections without having to introduce conditional equations

Our next step consists of establishing a corresp ondence to the usual notions of

mo del which make use of pullbacks

Prop osition Every diagram of the form

qf S

B ff g

p ff g p

B

f

is a pul lback

Pro of Let u A B and v A b e context morphisms such that

f u p v The unique mediating morphism from A to B ff g is given by

Hdv Indeed qu ff g

p ff g qu ff g Hdv

u p fu f g Hdv since Hdv Sect fu f g

u

qu ff g qf

A ff ug B ff g

Hdv p ff ug p ff g

A B

u f

Similarly we have

qf qu ff g Hdv

Hdv qf u

v by MorInv

Chapter Syntax and semantics of dep endent types

For uniqueness let w A B ff g b e such that qf w v and p ff g w

u Then

Hdw

Hdqf u Hdw by SectInv

Hdqf qu ff g Hdw

Hdqf w by MorInv

Hdv by assumption

and thus

w

qu ff g Hdw

qu ff g Hdv

as required 2

This prop erty has the consequence that if f B then Hdf is the unique

section M Sect ff g with qp f M f This implies the following

identities

Lemma Let A B be contexts and Fam

i Hdqf g Hdg for f B and g A B ff g

Hdf g Hdf g for f B and g A B ii Hd

We can furthermore use the pullback prop erty in order to characterise syntactic

categories with attributes

Prop osition Let C be a category with terminal object and equipped with

the fol lowing data

op

A functor Fam C Sets with morphism part written fg as in

Def

p

For each Fam a Cmorphism with codomain denoted

Chapter Syntax and semantics of dep endent types

For f CB and Fam a pullback square

qf

B ff g

p ff g p

B

f

For each Fam a set Sect and a bijection

Sect ff C j p f id g

Then there is a unique way of completing this structure to a syntactic category

with attributes

Pro of It only remains to dene the Hd op eration and to check the equations

and uniqueness of the particular choice made Let f B The unique

mediating morphism in

B

X

X

X

X

X

X

S

X

X

X

f

X

S

X

X

X

X

S

X

X

X

X S

Xz

S

qp f

S

B ff g

S

id

S B

S

S

p p ff g

S

S

S w

B

p f

is a section of fp f g We let Hdf b e the corresp onding section of fp f g

Uniqueness of this choice follows from the universality of the pullback and the

equations are routine calculation 2

is an Remark A special case of Prop arises when the bijection

identity ie if Sect equals the set of right inverses to p Such a structure

Chapter Syntax and semantics of dep endent types

is called category with attributes by Cartmel l and Moggi and a type

category by Pitts This notion in turn is equivalent to Jacobs notion of full

split comprehension category a notion of model based on brations

Substitution on sections

Assume f B Fam and M Sect We construct a section

M ff g Sect ff g as

M ff g Hd M f

This reects the intuition that substitution in terms is comp osition rather than

induced by abstract universal prop erties If in particular the morphism f hap

p ens to b e a display map ie of the form p for some Fam then the

substitution M fp g is the weakening of M Alternatively we can identify the

M ff g as the unique mediating morphism in the diagram morphism

B

X

X

X

X

X

X

S

X

X

M f X

X

S

X

X

X

X

S

X

X

X

S X

z X

S

qf

S

B ff g

S

id

S B

S

S

p ff g p

S

S

w S

B

f

whereby we get that if qf N M f for some N Sect ff g then N

M ff g

Notation for weakening

If Fam M Sect and f B we introduce the following

abbreviated notations for weakening

fp g

M p M M fp g Hd

f qf

Chapter Syntax and semantics of dep endent types

This notation b eing ambiguous eg f can mean b oth qf and qf we

use it only if the meaning is clear from the context In the term mo del we have

x and M x M

Handling of variables

If Fam then Hdid is a section of fp g In the term mo del it

corresp onds to the term x x where the second instance of is actually

weakened We abbreviate this section by v The thus dened semantic variables

are stable under substitution in the following sense

Lemma If f B and Fam then

v fqf g v

ff g

We can also establish that the substitution of a section into a variable results

in that section this corresp onds to the syntactic triviality xx M M

Lemma If Fam and M Sect then

v f M g M

Pro of Routine calculation 2

We could have introduced v as a primitive together with an op erator Cons which

turns a context morphism f B and a section M Sect ff g into a context

morphism Cons M f B The morphism qf then b ecomes denable

as Consv f p ff g We leave it as an exercise to work out the details of

ff g

this alternative description

In the meantime this exercise has b een indep endently worked out by P Dyb jer

and it turns out that the resulting notion of mo del without conditional equations is much

more natural and intuitive than ours If this thesis would b e written again certainly this notion would b e used instead

Chapter Syntax and semantics of dep endent types

The variables other than the last one are obtained as successive weakenings

of v For example if Fam and Fam then v Sect and

v Sect

Type constructors

We now turn to the description of the semantic companions to the type formers

describ ed in Sect These semantic op erators will b e dened in such a way

that the term mo del always provides an instance This precludes their denition

by universal prop erties as is usually done in the literature eg Instead

we must ask for stability under substitution of all type and term formers not only

the constructors This sometimes leads to more complicated formulations but it

is the only way to identify as mo dels the various syntactic constructions to b e

dened later

Dep endent Pro ducts

Denition Assume a syntactic category with attributes C We say that

C is equipp ed with dep endent pro ducts if the fol lowing hold

For every context and families Fam Fam there is a

distinguished family Fam

If M Sect then there is a distinguished section M Sect

If M Sect and N Sect then there is a distinguished section

N g App M N Sect f

If f B then

ff g ff g fqf g

and for M Sect N Sect

App M N ff g App M ff g N ff g

ff g fqf g

Chapter Syntax and semantics of dep endent types

and for M Sect

M ff g M fqf g

ff g fqf g

If M Sect and N Sect then App M N M f N g

This denition of dep endent pro ducts almost verbally follows the syntactic deni

tion of types The requirements on compatibility of reindexing with the dep end

ent pro duct constructor corresp onds to the syntactic denition of substitution as

distributive over type and term constructors

Remark We could require an rule too ie for M Sect

App M v M

fp g fqp g

Then the compatibility condition on could be dropped and in fact would

enjoy a universal property However then the term model would not have dependent

products unless an rule were present in the syntax

Prop osition The term model from Example is equipped with de

pendent products if the underlying syntax has types

Pro of If Fam and Fam then is a valid context and

and x by denition of the term mo del We then put x

Fam If f B is a syntactic context morphism then clearly

x f x f f x

by denition of syntactic substitution Next if M Sect then x M

so we put M x M Sect Conversely if M Sect

and N Sect then M x and N so we put App M N

M N Again by denition of syntactic substitution these choices meet the co

herence requirements and moreover by PiBeta the dening equation is also sat

ised We also see that the rule mentioned in the ab ove remark corresp onds

to x M x M which do es not necessarily hold 2

Chapter Syntax and semantics of dep endent types

We now give another characterisation of dep endent pro ducts which is sometimes

easier to check

Prop osition A syntactic category with attributes has dependent products

i for each family Fam and Fam there is a distinguished family

Fam and a morphism

ev fp g

with p ev p fp g in such a way that for every section M

Sect there exists a distinguished section M Sect such that

ev M fp g M and moreover the fol lowing three coherence conditions

are satised for any morphism f B

ff g ff g fqf g

qqf fp g

ev ev

ff g fqf g

qqf

M ff g M fqf g

ff g fqf g

Pro of We give the pro of for the term mo del The general case is an exercise in

categorical notation In the situation and x we dene the

context morphism ev as

s f x s f s s t

Conversely if we are given a context morphism ev with the ab ove source and

target and satisfying the commutativity requirement then we must have

ev s f x s As f

for some term

s f x As f

Chapter Syntax and semantics of dep endent types

We then dene for M x and N

M N AN M

The verications are straightforward 2

From the example of the dep endent pro duct it should have b ecome clear how in

principle every syntactic type or term former can b e translated into its semantic

equivalent For every type forming rule one introduces an op erator on families and

for every term forming rule an op erator on sections where in each case suitable

instances of weakening have to b e inserted Then for every equation one intro

duces an equation b etween the corresp onding semantic entities and nally one

imp oses equations which ensure the compatibility of all semantic op erators with

substitution

In most cases however this approach leads to very clumsy formulations of the

semantic type formers Indeed it is often p ossible to replace a term op erator by

a single context morphism or sometimes by a single section and a type op erator

by a single family An example for the former is provided by the alternative

characterisation of dep endent pro ducts in Prop where we have replaced

the application op erator by the evaluation morphisms An example for the latter

arises from the identity type we dene in Sect b elow

We often follow this strategy in the denition of further semantic type formers

without explicitly stating and proving corresp ondences like Prop ab ove

In most cases we relate our denition to stronger ones which make use of

universal prop erties and thus are more elegant but are usually not met by syntactic

mo dels like the term mo del

Unit types

The semantic denition corresp onding to the unit type dened in Sect is as follows

Chapter Syntax and semantics of dep endent types

Denition A syntactic category with attributes is equipp ed with unit

types if for every context there is a distinguished family Fam and

a distinguished section Sect such that for every Fam and

M Sect f M Sect with g there is a distinguished section R

g M M f R

in such a way that the fol lowing coherence equations are satised for every morph

ism f B and M Sect f g

ff g

B

ff g

B

B

R M ff g R M ff g

ff g

In view of the rst coherence condition one might require only and obtain the

other units by substitution along the unique morphism into the terminal ob ject

The op erator R would however still have to b e required for arbitrary contexts

The corresp ondence to the syntax is as follows If Fam and M

Sect f M f g and N Sect then R M N R N g Sect fN g

In many mo dels unit types exist by virtue of the following prop osition

Prop osition A syntactic category with attributes C can be equipped with

unit types if there exists a family Fam such that p is an isomorphism

Pro of We put f g Since

p p

is a pullback p is an isomorphism to o Let b e its inverse We put

Hd and for Fam and M Sect fg we put R M

Chapter Syntax and semantics of dep endent types

M fp g Sect fp g Sect Stability under substitution follows

since all the op erators are given by substitutions themselves 2

Natural numbers

Denition A syntactic category with attributes C is equipp ed with nat

ural numbers if for every context there are the fol lowing data

a distinguished family N Fam

a distinguished section SectN and a distinguished morphism Suc

N N with pN Suc pN

g and M Sect fSuc p g for every Fam N M Sect f

s z

N N

M M f M M Sect with R a distinguished section R g M

z s z s z

N

N

M M g R and R M M fSuc g M f

z s z s s

in such a way that al l these data are stable under substitution ie for f B

Fam N M Sect f g M Sect fSuc p g we have

z s

N ff g N

B

ff g

B

f Suc Suc f

B

N N

B

R M M ff g R M ff g M ff g

z s z s

By straightforward calculation we obtain

Chapter Syntax and semantics of dep endent types

Prop osition The term model described in is equipped with natural

numbers given by

N N

N

Suc n N Sucn n N

N N

R M M x N R M M x

z s z s

Again we relate our notion of natural numbers to a stronger one often oered

in the literature eg

Denition Let B be a cartesian category with terminal object and products

Suc

A parametrised natural numbers ob ject in B is a diagram N N

z s

such that for any diagram G S S there exists a unique morphism

Rz s G N S such that

z s

G S S

Rz s Rz s

hid i

G

R

G N G N

id Suc

G

Prop osition Let C be a syntactic category with attributes If there exists

a family N Fam such that N is the object part of a parametrised natural

numbers object in C then C can be equipped with natural numbers in the sense of

Def

Pro of We dene

N Nf g

Hdf g

Next we notice that N is isomorphic to the cartesian pro duct N by

virtue of Prop Without loss of generality we can identify N with this

pro duct We then put Suc id Suc We also have that pN is a pro duct

hid i pro jection and

Chapter Syntax and semantics of dep endent types

Next we note that for Fam N sections of fSuc gfp g this is the

type of M are in bijective corresp ondence to the set of endomorphisms h of

s

N with p h Suc p On the other hand elements of Sect f g

the type of M are in bijective corresp ondence to morphisms g N

z

with p g hid i

Now given such g and h arising from appropriate sections M and M then

z s

Rg h N N and p Rg h id by the uniqueness prop erty

N

of the natural numbers ob ject So Rg h induces a section of which is the

N

desired R M M The commutativity of the diagram dening Rg h gives

z s

N

the required equation for R The coherence laws for N and Suc follow

N

is again from their denition by substitution pullback and the coherence of R

a consequence of the uniqueness prop erty 2

One may compare this to the pro of of mathematical induction for natural numbers

ob jects in a top os see eg

Identity types

For the denition of the identity type we rst observe that for Fam the

morphism

v

is the diagonal which in the term mo del is given by

x x x x y

It has the prop erty

p v p v id

where p and p are the two pro jections

Denition A syntactic category with attributes C is equipp ed with iden

tity types if for every context and Fam there is

a distinguished family Id Fam

Chapter Syntax and semantics of dep endent types

a distinguished morphism Re Id with pId Re

v

for every family Fam Id and M SectfRe g a distin

guished section J M Sect with J M fRe g M

in such a way that al l these data are stable under substitution ie for f B

as above and M SectfRe g we have

Id ff g Id ff g

Re f f Re

ff g

J M ff g J M ff g

ff gff g

Again in many semantic mo dels we can give a simpler denition as follows

Prop osition A syntactic category with attributes can be equipped with

identity types if for every Fam there is a distinguished family Id

Fam stable under substitution such that

pId

Id

pId p

p

commutes and is a pul lback

v

Pro of The universal prop erty of the pullback applied to

v

gives the morphism Re Id with

v as required Now Re is actually an isomorphism b ecause pId Re

v v

is also the pullback of the two pro jections

p p For the inverse of Re we may for example take

p pId So substituting along this inverse denes the desired function

J SectfRe g Sect All the data except Id are dened by universal

prop erties and thus are stable under substitution 2

Chapter Syntax and semantics of dep endent types

types

Denition A syntactic category with attributes C is equipp ed with

types if for every context and families Fam Fam there is

a distinguished family Fam

a distinguished morphism pair with

p pair p p

for each family Fam and M Sectfpair g a distinguished

section R M Sect with R M fpair g M

in such a way that al l these data are stable under substitution ie for every

situation f B Fam Fam Fam

M Famfpair g we have

ff g ff g ff g

f pair pair f

ff g ff g

M ff g R M ff g R

ff g ff g

The term mo del is equipp ed with types with the obvious choice A more sp e

cialised but simpler denition of types is the following

Prop osition A syntactic category with attributes can be equipped with

types if for every Fam and Fam there is a distinguished

family Fam and an isomorphism pair

with p pair p p both stable under substitution in the sense of

Def

Chapter Syntax and semantics of dep endent types

is dened by substitution along the in Pro of The elimination op eration R

verse of pair 2

The types obtained by virtue of the ab ove prop osition are called extensional for

they have the prop erty that any P Sect is of the form Hdpair P

P for uniquely determined sections P Fam and P Fam fP g

Universes

In this section we dene a general semantic framework which allows us to in

terpret various kinds of universes including the universe Prop in the Calculus of

Constructions We rst present a very concise denition of semantic universes

which however turns out to b e to o restrictive for many applications Therefore

we dene a lo oser notion and give a canonical construction which allows to pass

from one to the other The Calculus of Constructions will play the role of a run

ning example We give the explicit constructions for this particular case and

app eal to the mathematical understanding of the reader for the generalisation to

other instances of universes

Throughout this section we assume a xed syntactic category with attributes

C equipp ed with dep endent pro ducts

Denition A full submo del of C consists of a subset Fam of Fam

for each context such that whenever f B and Fam then ff g

op

Fam B In other words a ful l submodel is a subfunctor of Fam C Sets

Denition A ful l submodel Fam is closed under some type former if

whenever al l family arguments to the type former are in Fam then so is the new ly

formed family

For example Fam is closed under dep endent pro ducts if for Fam and

Fam the pro duct is in Fam instead of just in Fam In

case the type former takes no arguments ie it is a constant like N then closure

means that this constant is in Fam

Chapter Syntax and semantics of dep endent types

Denition A ful l submodel Fam is closed under impredicative quantic

ation if whenever Fam and Fam then Fam

So impredicative quantication means that the pro duct of a family in Fam over

an arbitrary family is in Fam again

Denition A pair U El is a generic family for a ful l submodel Fam if

U Fam and El Fam U and for every family Fam there exists

a unique morphism s U such that Elfsg

Example If U Fam and El Fam U are any two families with

the property that whenever Elfsg Elfs g for some s s U then the

assignment Fam f Fam j s U Elfsgg denes a ful l

submodel of C with generic family U El

In fact by denition every full submo del with generic family is of the form given

in Ex The reason for introducing the notion of full submo del is that it

allows to state closure prop erties in a shorter way as b ecomes clear in the next

denition

Denition The syntactic category with attributes C is a mo del of the Cal

culus of Constructions if it has a ful l submodel closed under impredicative quanti

cation with a distinguished generic family denoted Prop Prf

Prop osition Let C be a model of the Calculus of Constructions Then for

any context family Fam and s Prop there is a distinguished

morphism s Prop with

Prf f sg Prf fsg

Moreover these morphisms are stable under substitution that is for every f B

and s as above we have

s f s f

ff g

Chapter Syntax and semantics of dep endent types

Pro of If s Prop then Prf fsg lies in the full submo del Since

the latter is closed under impredicative quantication the pro duct do es

to o We thus dene s as the unique morphism with Prf f sg

For stability under substitution we observe that substituting either side into Prf

gives rise to the same family So the equation follows by the denition of generic

family 2

Prop osition The term model of the Calculus of Constructions is a model

for same

Pro of The generic family is given by the pair Prop x Prop Prf x We

must show that this is indeed a generic family ie that Prf M Prf N

implies M N We prove this by induction along derivations together with

the statement that Prf M x Prf N implies M x N So

assume Prf M Prf N If this is an instance of reexivity then M N

by reexivity to o If it is an instance of the congruence rule for Prf we must

have M N as a premise In all other cases we can nd such that

Prf M and Prf N such that b oth these judgements have

shorter derivations than Prf M Prf N and moreover the last instance

in the pro of of Prf M is neither reexivity nor transitivity and if it

is symmetry then the derivation of its premise do es not end with either of these

three In the rst case either is Prf M and M M or M is x M and

is x Prf M in either case the result follows from the inductive hypothesis

All the other cases are similar

We thus have shown that the types of the form Prf M form a full submo del

with generic family They are closed under impredicative quantication by virtue

of the op erator 2

Chapter Syntax and semantics of dep endent types

Other universes

In order to dene semantic counterparts to other sorts of universes we pro ceed in

a similar way We ask for a full submo del with a generic family closed under the

desired typeforming op erations For example in order to interpret the particular

universe used in Sect we ask for closure under dep endent pro ducts and

natural numbers We can now dene op erators similar to s witnessing the

closure on the level of morphisms Again using uniqueness we can show that

these op erators are stable under substitution Finally by suitably extending the

argument in the pro of of Prop we can show that the term mo del provides

an instance

The settheoretic mo del admits a cumulative hierarchy of universes all closed

under all the standard type formers using inaccessible cardinals This is worked

out eg in The set mo del admits such a chain of universes all inside the

impredicative universe of partial equivalence relations hinted at in Example

b elow even without using inaccessible cardinals This is worked out in and

Lo ose mo dels for universes

Unfortunately the denitions ab ove are to o restrictive to account for many natural

mo dels like the settheoretic mo del and the set mo del For example if in the

settheoretic mo del we put Prop ftt g and Prf tt fg and Prf

then the induced full submo del ie those families f g with ffg g are

not closed under impredicative quantication b ecause if fg for all

then the pro duct over the family is a singleton but not the chosen singleton fg

We present a laxer notion of mo del for the Calculus of Constructions of which

the settheoretic mo del forms an instance see Example together with a

canonical construction which turns such a mo del into an actual mo del in the sense

of the denitions given ab ove The notion as well as the construction generalise

to other universes in a straightforward way

Chapter Syntax and semantics of dep endent types

Denition A syntactic category with attributes C equipped with dependent

products is a lo ose mo del for the Calculus of Constructions if the fol lowing are

given

distinguished families Prop Fam and Prf Fam Prop

for each Fam and s Prop a distinguished morph

ism s Prop and a distinguished morphism ev

s

Prf f s p g Prf fsg with pPrf fsg ev pPrf f s

s

p g

for each section M SectPrf fsg a distinguished section M

s

SectPrf f sg with

M fp g M ev

s s

in such a way that al l these data are stable under substitution that is for f B

Fam s Prop M SectPrf fsg we have

s f s f

ff g

ev f f ev

s

ff gs f

M ff g M ff g

s

ff gs f

Notation To simplify notation we shall in the sequel denote by Prop the

family in Fam its substitutions Propf g Fam and its comprehension

Prop

Example The settheoretic model can be turned into a loose model of the

Calculus of Constructions as fol lows We dene Prop and Prf as in the erroneous

attempt above ie Prop ftt ff g and Prf tt fg and Prf ff and for

s Prop we dene s tt if s x tt for al l x and

ff otherwise Then we can dene ev as the function sending x to x in s

Chapter Syntax and semantics of dep endent types

the former case and as the empty function otherwise The other components are

dened accordingly and the verications are straightforward

This loose model is trivial in the sense that for any two M N SectPrf fsg

for some s Prop we must have M N It is known that the set model

can be turned into a nontrivial loose model by letting Prop be the set of partial

equivalence relations on endowed with the trivial realisability structure

Prop osition There exists a canonical construction which for a given loose

model C for the Calculus of Constructions produces a model in the sense of

Def over the same category of contexts Moreover the new model supports

whatever type former the original one did

Pro of The families of the new mo del are dened as the disjoint union

Fam Fam C Prop

new

If f B then substitution on families in the left summand is inherited from

the original mo del whereas on the right summand it is given by comp osition

For Fam let b e if is already in Fam and Prf f g if is a

new

morphism from to Prop All the other comp onents of the new mo del except

are inherited from the original mo del by precomp osition with

If Fam and Fam then we dene the pro duct in

new

the new mo del as On the other hand if is a morphism from

to Prop then the pro duct in the new mo del is dened as the morphism

Prop For evaluation and abstraction we use either the op erations

from the original mo del or the ones which are part of the denition of a lo ose

mo del Both satisfy the required equations and are stable under substitution

The families in the right summand viz the morphisms into Prop thus form a

full submo del closed under impredicative quantication It has the generic family

Prop id Indeed if s Prop Fam then there is a unique

Prop new

Chapter Syntax and semantics of dep endent types

morphism namely s itself such that s arises by substitution from the generic

family 2

The ab ove prop osition is a bit vague as stated b ecause for example the prom

ised construction might pro duce the same trivial result for every lo ose mo del

Had we dened a notion of morphism b etween mo dels we could identify the con

struction as an equivalence

In case the lo ose mo del we start with has the prop erty that the families of the

form Prf ff g form a full submo del with generic ob ject ie the functions Prf fg

are injective then we can choose Fam to b e Fam and dene by case

new

distinction according to whether Prf ftg for some then unique t or not A

sp ecial case of this pro cedure app ears in for the particular case of the set

mo del and in for a particular class of mo dels

Interpreting the syntax

In this section we dene a semantic function which maps wellformed terms types

and contexts of the dep endently typed calculus dened in Sect to entities in

a syntactic category with attributes which supp orts the type formers and other

features present in the syntax We pro ceed by rst dening a partial interpretation

function on preconstructions which is then proven total on wellformed construc

tions by induction on derivations This metho d which circumvents the necessity

to prove indep endence of the interpretation of a particular derivation is due to

Streicher Our treatment here diers from lo ccit in that our notion of mo del

is more general in particular we do not require extensional types and that in lo ccit only the particular example of the Calculus of Constructions is considered

Chapter Syntax and semantics of dep endent types

Partial interpretation

Assume a syntactic category with attributes C equipp ed with dep endent pro ducts

natural numbers and identity types An a priori partial interpretation function

is dened which maps

precontexts to ob jects of C

pairs j where is a precontext and is a pretype to families in

Fam

pairs j M where is a precontext and M is a preterm to sections in

Sect for some Fam

We show b elow in Thm that this semantic function is dened on all contexts

types and terms

The semantic clauses are the following where in order to reduce the number of

cases we adopt the convention that an expression containing an undened sub ex

pression is itself undened We also adopt the convention that expressions which

do not typecheck like if Fam are undened

x j

j x j x j

j N N

j Id M N Id f j M gf j N g

j

if x where has length n and x do es j x v

j

z

n times

not o ccur in Undened otherwise

j App M N App j M j N

x j x j

Chapter Syntax and semantics of dep endent types

j x M x j M

j x j

j

j SucM HdSuc j M

N N

j R M M N R j M x N p j M f j N g

z s z s

j Re M Re f j M g

j

j J M N N P

xy pId xy

J x j M f j N gf j N gf j P g

j xy pId xy j

The nfold weakening in the clause for variables is understo o d along the semantics

of the n types in in their resp ective contexts Notice that the semantic com

N

binators like R and J take sections as arguments whereas substitution fg

takes morphisms as arguments so that when arguments are supplied via substitu

to transform sections into tion like the three last arguments to J we must use

morphisms

Soundness of the interpretation

Before we state and prove a soundness theorem for this interpretation we establish

corresp ondences b etween syntactic and semantic substitution and weakening In

order to state these we need to dene a semantic equivalent of telescop es

Denition Let C be a model and ObC A semantic telescop e

over is a list of families with Fam Fam

n

Fam The set of semantic telescopes is denoted by Tel

n n

The empty telescope over is written The operations of comprehension and

substitution are extended to telescopes by the fol lowing recursive denition

p id

Chapter Syntax and semantics of dep endent types

ff g for f B

B

qf f

where is the telescope extended by family

p p p

ff g ff g fqf g

qf qqf

By a straightforward induction on the length of telescop es we now obtain

Prop osition The telescopes together with the operations dened above sat

isfy the premises of Prop and thus dene a syntactic category with attributes

where Sect the set of sections of p

The partial interpretation function can b e extended to telescop es by dening

for precontexts and x x

n n

j j x j x x j

n n n

Clearly if j is dened then so is and the former is a semantic telescop e

over the latter Moreover the following two prop erties of the extension are obvious

from the denitions of p and q on telescop es

p j p j p j

qf j qqf j j

Lemma Weakening Let be precontexts pretypes M a pre

term and x a fresh variable The fol lowing equations hold if either side is dened

x x j fp j g

x j j fqp j j g

x j M j M fqp j j g

Chapter Syntax and semantics of dep endent types

Pro of An instance of this lemma is one of the left hand sides of the ab ove

equations The weight of such an instance is the number of symbols required to

write it down including variables and punctuation symbols Thus for example the

weight of x y is greater than the weight of x j b ecause y is

not contained in the latter We also need the notion of length of a precontext

denoted jj which is the number of variable declarations it contains We pro ceed

by induction on the weight and give a representative selection of the many cases

required

First consider the case where If either side of the instance is dened

then p j must b e dened to o Now x x x

j fp j g b ecause j by denition

If y then

x

x x j by denition

x j fp j g j fqp j j g by IH

x j fp j g j fqp j j g

x j fp j g

The last two steps follow from the denition of substitution and comprehension on

semantic telescop es We have used the inductive hypothesis IH on the instances

x j and x which b oth have smaller weight

Next we consider the instance x j N We have

x j N

N

x

N by IH

x jfpj g

N fqp j j g

j Nfqp j j g

For the p enultimate step we have used that qp j j is a morphism

from x j fp j g to j and the fact that

N ff g N for any morphism f B

B

Chapter Syntax and semantics of dep endent types

Now we consider the instance x j y We have

x j y

x j x y j

j fqp j j g

y j fqp j j y g

j fqp j j g

y j fqqp j j j y g

j y j fqp j j g

j y fqp j j g

In the second step we have used the IH on the instances j and y

j b oth of which have smaller weight than the original instance We see here

the need for the rather involved structure of the inductive argument The third

step uses the denition of the q op eration on semantic telescop es and the

fourth step is a consequence of the stability of under substitution

The instance x j Id M N is similar We expand the denition and

use the IH on the instances x j x j M and x j N

all of which have smaller weight

Let us now consider the instance x j y where y is a variable We

observe that using our notation for telescop es and functoriality of substitution we

can rewrite the iterated weakening in the semantic clause for variables as follows

y j y v fp y j g

j

where y do es not o ccur in Supp ose now that x j y is dened

Then either y for some type and y do es not o ccur in or

y and y do es not not o ccur in In the former case we

calculate as follows

y x j y

v fp y j x g

j

v fp y j p j p x j g

j

Chapter Syntax and semantics of dep endent types

Now we notice that

x j j fp j g

by induction on jj and the IH This in turn implies that

p j p x j p j qp j j

b ecause semantic telescop es form a syntactic category with attributes We can

thus continue the calculation as follows

v fp y j p j qp j j g

j

v fp y j qp j j g

j

y j y fqp j j g

On the other hand if y and y do es not o ccur in then

x y j y

v fp x y j g

x j

v fp x y j g by IH

j fqpj j g

v fqp j j y gfp x y j g

j

by Lemma and the denition of q on telescop es Now again by

induction on j j and the IH we conclude that

x y j y j fqp j j y g

and thus

qp j j y p x y j

p y j qp j j y

using the commutativity of the square corresp onding to the substitution y j

fqp j j y g and the observation on nested q morphisms

on telescop es made ab ove Now we can nish the calculation as follows

v fp y j gfqp j j g

j

j y fqp j j g

Chapter Syntax and semantics of dep endent types

If the right hand side of the equation for variables is dened then we p erform the

same case distinction as to whether y o ccurs in or Since all the steps in the

ab ove calculation are valid if either side is dened this implies that the left hand

side is dened to o

The instances of the form x j M are similar to the instances of the

form x j If M is a constant then we follow the pro of for N and if the

outermost constructor of M is a binder then we argue as in the case of 2

Lemma Substitution Let be precontexts pretypes M N pre

terms and x a fresh variable We denote the substitution of M for x in some pre

construction C by C M The expression j M is abbreviated by m If j

and j M are both dened and the latter is a section of the former then the

fol lowing equations hold if either side is dened

j M g M x j f

j M x j g M j M x j fq

M j N M x j N fq j M x j g

Pro of Again we pro ceed by simultaneous induction on the weights of the three

j M by m It now plays the role of instances We abbreviate the morphism

the weakening morphism p j in Lemma There are only two cases

the pro of of which diers from the one of their companion in Lemma The

rst one is the instance M This equals x j fmg i j M is

dened and is a section of j b ecause otherwise the substitution would not

typecheck and would thus b e undened This is actually the only place where this

assumption is needed it is propagated to the other cases through the inductive

pro cess

The second case is the instance where N is the variable x ie

M j M x j xfqm x j g

Chapter Syntax and semantics of dep endent types

Notice here that xM M By the inductive hypothesis and by induction on jj

we may assume that

j M x j fmg

and thus

m p j M p x j qm x j

by the commutativity of the square corresp onding to the substitution x j

fmg Now we calculate as follows

M j M

j M fp j M g by jjfold application of Lemma

v fm p j M g by Lemma

j

v fp x j qm x j g as argued ab ove

j

x j xfqm x j g by the clause for variables

The pro ofs of all the other cases almost literally follow the pro of of Lemma

and are thus left out 2

Substitution for arbitrary context morphisms We can extend the inter

pretation function to syntactic context morphisms together with their domain

and co domain as follows If are precontexts f a tuple of preterms and M

a preterm then

j j

j f M j x q j j f j M

where as b efore we adopt the convention that expressions which do not typecheck

are undened We now have the following general substitution prop erty

Lemma General substitution Let B be precontexts and f a jj

tuple of preterms M a preterm and a pretype We denote the simultaneous

Chapter Syntax and semantics of dep endent types

substitution of the variables by f in some preconstruction C by C f If B j

f j is a morphism from B to then the fol lowing equations hold if either

side is dened

B f B j fB j f j g

B f j f j fqB j f j j g

B f j M f j M fqB j f j j g

Pro of The pro of is by induction on the length of f If f and thus

then the rst equation is satised by denition of substitution on semantic

telescop es The second equation b ecomes

B j j fqB j j j g

From a jBjfold application of Lemma we get

B j j fqp j B j g

where we have used comp ositionality of q and the denition of p on

telescop es But now p j B as a morphism from B to must equal by the

unicity prop erty of the terminal ob ject The third equation is analogous

Now consider the case where f f N and y If B j f j is

dened and is a morphism from B to then B j N must b e dened and b e a

section of j fB j f j g which by the IH is equal to B j f Now for

the rst equation we calculate as follows

B f N

B f y N by denition of parallel substitution

B B y f j f f B j N g by Lemma

B y j fqB j f j j gf B j N g by ind on jj and IH

B j fB j f N j y g

by comp ositionality of fg and the denition of the interpretation of nonempty

context morphisms

The other cases are similar 2

Chapter Syntax and semantics of dep endent types

We remark that the inductive argument ab ove do es not go through if we restrict

ourselves to and thus qB j f j j B j f j

We have tried to prove the general substitution lemma directly by induction on

the weight of the instances Then all the inductive cases are very much the same

as if not easier than in the weakening case Lemma but the case where M

is a variable b ecomes extremely complicated and seems to require weakening and

substitution for terms in the rst place

We can now establish a corresp ondence b etween syntax and semantics

Theorem The interpretation function enjoys the fol lowing soundness prop

erties

If then is an object of C

If then j is an element of Fam

If M then j M is an element of Sect j

If and and f then j f j C

If then

If then j j

If M N then j M j N

Pro of The pro of is by induction on derivations Again we only treat selected

cases to give the general idea The cases for context and type formation rules

are fairly simple applications of the IH Assume for example that x x

has b een derived from and x x using Form Then we may

assume that S j Fam and T x j Fam x

Now x S by the semantic clause for context extension So S T

is dened and equals j x by the clause for types

Chapter Syntax and semantics of dep endent types

More interesting are rules involving syntactic substitution Assume for example

that App M N N has b een derived from M x x and

x

N using Elim Then by induction we may assume that j M

Fam j x x and j N Fam j By expanding some denitions

and using the IH we get from this that j App M N is dened and is

x

a section of the family x j xf j N g We now use Lemma to

conclude that this family equals j N as required 2

We nish our presentation of categorical semantics of dep endent type theory with

a trivial completeness theorem for syntactic categories with attributes

Theorem Let be precontexts be pretypes and M N be pre

terms

If is dened in al l interpretations then

If j is dened in al l interpretations then

If j M is dened in al l interpretations then M for some unique

If in al l interpretations then

If j j in al l interpretations then

If j M j N in al l interpretations then M N for some

unique

Pro of Using the term mo del from Ex and induction on the denition of

the interpretation function 2

Chapter Syntax and semantics of dep endent types

Remark One can dene morphisms between syntactic categories with at

tributes in the obvious way as functions on contexts morphisms families and

sections preserving al l the structure up to equality In this way syntactic categor

ies with attributes supporting a given set of type formers form a category in which

the respective term model is initial

Discussion and related work

Our formulation of the syntax diers from the more mo dern one in in that it

is not based on a logical framework In the latter approach one rst denes a type

theory with types written x and one universe called Set the way we have

done and then one introduces all further constructs as constants of the appropriate

type eg for types one would have a constant S SetT s ElS SetSet

In this way many of the rules can b e simplied and less metanotation like sub

stitution is needed The reason why we have not used this notation was that

the categorical semantics then b ecomes more complicated In retrosp ect we think

that it might have b een b etter to pay this price in exchange for a neater and more

uptodate syntax

Another basic characteristic of our presentation of the syntax is the handling

of substitution as a dened op eration on the raw syntax Recently there has b een

an interest in treating substitution as part of the syntax and giving reduction or

equality rules for it and unpublished notes by Per MartinLof We have

not used this presentation simply b ecause it do es not yet seem to b e suciently

settled see for instance

The categorical semantics of dep endent type theory has attracted quite some

interest see for instance but mostly from an abstract categorical

p oint of view If we can claim any originality for the material in this chapter then

it is for having tried to demystify the categorical semantics and to relate it as

closely to the syntax as p ossible Let us summarise the most imp ortant approaches

to categorical semantics in the literature The sub ject started with Cartmells pi

Chapter Syntax and semantics of dep endent types

oneering work who invented the notions of contextual categories and categories

with attributes Categories with attributes have b een describ ed in Remark

in contextual categories the families are replaced by an additional tree structure

on the category of contexts This latter notion underlies Streichers work

on categorical semantics of the Calculus of Constructions where the interpret

ation of the syntax is dened formally and the metho d of partially interpreting

preconstructions app ears for the rst time

In these two notions of mo del equality of families and compatibility of the

type formers with substitution up to equality is crucial this in known as the split

case In other approaches to categorical semantics this has b een weakened to ca

nonical isomorphism the nonsplit case eg in lo cally cartesian closed categories

mo dels based on brations and display map categories The

interpretation of the syntax in such structures is not obvious at all however a fact

which has astonishingly b een neglected by many authors An exception is Ehrhard

who restricts to the split case and then uses Streichers metho d to interpret

the syntax of the Calculus of Constructions in his brational mo dels The problem

of interpreting the syntax in nonsplit categorical structures has only recently b een

taken up by Curien using an intermediate syntax with explicit substitutions

and by the author using a categorical construction that turns a nonsplit structure

into a split one In b oth approaches problems in particular the treatment

of universes remain so that one can conclude that at the current stateoftheart

the nonsplit mo dels do not prop erly corresp ond to the syntax

Another generalisation oered by mo dels based on brations is that morphisms

b etween families are primitive rather than dened through context comprehension

as sp ecial context morphisms This has the advantage that context comprehen

sion satises a universal prop erty wrt these morphisms and thereforeif it

existsit is unique up to isomorphism Morphisms b etween families also p ermit

a more natural characterisation of and types as certain adjoint functors

Again this characterises them up to isomorphism so that the presence of these

type formers b ecomes a prop erty rather than additional structure However this

only works for mo dels of extensional type theory

Chapter Syntax and semantics of dep endent types

It has already b een said that most of the material in this chapter is not original

However since no homogeneous treatment covering b oth syntax and semantics of

dep endent type theory exists in the literature let alone a textb o ok this may b e

remedied by the forthcoming we considered it necessary to give a rather

detailed account As novelties alb eit implicit in existing literature we consider

the equational presentation of categories with attributes the emphasis on stabil

ity under substitution rather than universal prop erties in the formulation of the

semantic type formers eg the identity type the construction achieving equality

b etween the semantics of Prf x S and x Prf S in Prop and the

explicit use of telescop es in the correctness pro of for the interpretation function

Chapter

Syntactic prop erties of prop ositional

equality

The main fo cus of this Chapter are the pro ofs of two imp ortant prop erties of ex

tensional type theory ie type theory with prop ositional and denitional equality

identied The rst prop erty is undecidability of this theory in view of the inform

ation loss in the equality reection rule an obvious thing which is nevertheless not

completely trivial to prove Sect The second prop erty is the conservativity

of extensional type theory over intensional type theory with extensional concepts

Sect These two prop erties constitute the ma jor justication for the use

of intensional type theory with extensional concepts

On the way we develop some notions and concepts which will b e required later

such as the formulation of prop ositional equality using uniqueness of identity and

a Leibniz prop erty Sect and the syntactic formulation of extensional

concepts relevant in MartinLof type theory without a universe of prop ositions

Sects An impatient reader may skip the other parts of this

chapter without aecting the understandability of the rest of the thesis

Chapter Syntactic prop erties of prop ositional equality

Intensional type theory

Intensional type theory is the one describ ed in Sect Here we present some

derived combinators and op erations for the inductive identity type Id dened

there Sect Next we lo ok at the extensional concepts of uniqueness of

identity Sect and functional extensionality Sect and establish some

syntactic prop erties of these

Substitution

From the elimination op erator J we can dene an op erator which allows to replace

prop ositionally equal ob jects in a dep endent type Let x x and M M

and P Id M M and N M We then dene

Subst M M P N

J x h xh M M P N M

xy pId xy x y

By the equality rule IdComp we have

Subst M M Re M N N M

Intuitively Subst allows to replace M by the prop ositionally equal M in the

type M of N As opp osed to extensional type theory every application of

prop ositional equality must b e recorded in the terms we cannot simply write

N M but Subst M M P N M as indicated

Since the rst two arguments to Subst can b e inferred from the third one we

often suppress these and write Subst P N Also as usual type annotations

may b e left out The same convention applies to other combinators and denitional

extensions which we introduce later on

It is slightly unpleasant that the function type has to b e used in order to derive

a principle as basic as substitution This may b e avoided by replacing J by another

Chapter Syntactic prop erties of prop ositional equality

elimination op erator J governed by the typing rule

x y p Id x y x y p

N N

M N N Re N

P Id N N

IdElimJ

J M N N P N N P

and an equality rule analogous to IdComp So instead of having to prove

x x Re x for all x the second premise to IdElimJ we only need it for

x N This elimination op erator is denable from J using function types and

gives Subst directly without using them However since J is more established we

shall stick to it

It is worth p ointing out that identity elimination J allows us to reason

ab out terms involving instances of Subst an example for such a term o ccurs in

Ex Intuitively using J one can replace the pro of P in an instance of

Subst by an instance of reexivity and then use the denitional equality Eqn

ab ove to get rid of Subst A more systematic approach to this is provided by the

conservativity result in Sect and is exemplied again in Ex

Symmetry and transitivity

Let M N and P Id M N We dene

Sym M N P Subst M N P Re M Id N M

x Id xM

If in addition we have Q Id N O we dene

Trans M N O P Q Subst N O Q P Id M O

x IdM x

The typing annotations and the inferable arguments may again b e elided

Compatibility with function application

Assume U and M N and P Id M N An element of type

Id U M U N is constructed as follows

Resp U P Subst P Re U M

x Id U M x

Chapter Syntactic prop erties of prop ositional equality

More generally if x x and M N P are as b efore then we can nd an

element of Id Subst P U M U N

N

Uniqueness of identity

The conversion functions from M to M if P IdM M obtained from

Subst dep end on the pro of supplied That is if P Q Id M N and L

M then in general the type

Id Subst P L Subst Q L

N

is not inhabited We shall prove this later in Section It is however certainly

desirable that the ab ove type is inhabited or that equivalently the type

Id P Q

Id M N

is inhabited We use the term uniqueness of identity to refer to either type b eing

inhabited for every such P Q M N

Various authors have prop osed the addition of axioms to type theory so as

to achieve uniqueness of identity Now as p ointed out in it is

sucient to have uniqueness of identity in the case where one of the two pro ofs is

a canonical one by reexivity The general case follows using J see b elow So we

introduce a family of constants

M P Id M M

IdUniI

IdUni M P Id P ReM

Id M M

and in addition to the obvious congruence rules an equality rule

M

IdUniComp

IdUni M ReM ReReM Id M M

Inhabited at any rate if the identity typed is to approximate extensional equality

For an application of a type theory without uniqueness of identity see Sect

Chapter Syntactic prop erties of prop ositional equality

In this way an instance of IdUni can b e eliminated if its arguments are canonical

so that provided IdUniComp do es not destroy strong normalisation a type

theory extended by IdUniI and IdUniComp is Ncanonical in the sense of

Def We have not found a formal pro of in the literature that IdUniComp

is indeed strongly normalising but it seems probable that any of the usual pro ofs

of normalisation should carry over

Where appropriate we omit the type annotation and the rst argument to

IdUni

For the sake of completeness we give now a pro of of the general case of unique

ness of identity using IdUni If then consider the type

x y p Id x y q Id x y Id p q

Id xy

Now if M N and P Q Id M N then we have

J x q Id x xIdUni x p M N P Q Id P Q

Id M N

Uniqueness of identity for denable types

In the presence of a universe one can show that various instances of IdUni are

denable In addition to the unit type we need an empty type containing no

M if where R canonical elements and an elimination op erator R

M Moreover we need a universe U El in the sense of containing

co des and for the unit type and the empty type We say that uniqueness

of identity is denable at type if for each M and P Id M M the type

Id P Re M is inhabited without using IdUni

Id M M

Prop osition In TT extended with an empty type and a universe U El

containing and uniqueness of identity is denable at N If uniqueness

of identity is denable at then it is denable at Id M N for M N If

x and uniqueness of identity is denable at and at then it is denable

at x

Chapter Syntactic prop erties of prop ositional equality

Pro of For the empty type the result is trivial since in the presence of a term

M any type is inhabited by R For we rst construct a general pro of

x y P x y Id x y using R satisfying P x x Rex and then show

using J and R that whenever P Id M N then Id P P M N

Id M N

Uniqueness of identity at is a trivial consequence from this We argue similarly

for the case of identity types themselves If uniqueness of identity is denable at

and M N then as shown ab ove we have a general pro of

p q Id M N P p q Id p q

Id M N

We deduce uniqueness of identity at Id M N as in the case of using J

N

For N we dene a term x y N EqNatx y U by induction R in such a

way that EqNat U x N EqNat Sucx EqNatSucx

U and x y N EqNatSucx Sucy EqNatx y Now we construct

terms

x y N p Id x y p ElEqNatx y

N

and

x y N p ElEqNatx y p Id x y

N

The function is dened using identity elimination whereas involves induction

N

R Now using identity elimination J we can show that

x y N p Id x y Id p p

N Id xy

N

is inhabited So uniqueness of identity at N follows from unicity of pro ofs of

ElEqNatx x which can b e established by induction

For types consider the type

EqSigmau v x x p Id u v Id Subst p u v

y

As in the case of N we can construct an isomorphism b etween Id M N

x

and EqSigmaM N and deduce uniqueness of identity from uniqueness of pro ofs

of EqSigma which in turn follows from uniqueness of identity at and 2

Chapter Syntactic prop erties of prop ositional equality

The metho ds of the ab ove pro of app ear to carry over to other inductive types

and type formers and under a certain assumption also to types see b elow

Uniqueness of identity is however not denable at universes as emerges from the

pro of of its indep endence in Sect

The relationship with patternmatching

It is worth highlighting the trivial observation that uniqueness of identity is den

able at all types using the device of patternmatching for dep endent types in

tro duced by Co quand in We do not here give the full denition of this

mechanism but only remark that it allows to dene a function on an inductive

type such as the identity type by sp ecifying its value at the canonical elements

In this way we may dene a term

p Id M M IdUni M P Id M Re M

Id M M

by the single pattern

IdUni M Re M Re Re M

Id M M

since Re M is the only canonical element of Id M M Of course this reduc

N

tion to canonical elements is also the intention b ehind the elimination rules R J

but there the patterns are given in a parametrised way This subtle dierence

is made more explicit in the pro of of indep endence of uniqueness of identity in

Functional extensionality

Supp ose that U V x and x P Id U x V x It is in general

not p ossible to derive from these hypotheses that Id U V is inhabited

x

that isin the terminology of the Introductionintensional type theory do es not

supp ort functional extensionality In a formal semantic pro of of this is given

Intuitively one may argue that if functional extensionality were available then

in the case we could deduce Id U V true from the existence of P

x

Chapter Syntactic prop erties of prop ositional equality

ab ove but by strong normalisation see Remark an identity type in the

empty context can only b e inhabited by a canonical element Re so U and V

must b e denitionally equal ie intensionally equal which do es not follow from

the existence of the pro of P which may have b een obtained using induction This

is an unfortunate problem with the identity type which makes its instances at

higher types essentially unusable To achieve functional extensionality we may

add a family of constants Ext U V P ob eying the rule

U V x

x P Id U x V x

ExtForm

Ext U V P Id U V

x

The type annotations and the rst two arguments to Ext may b e omitted

The introduction of these constants is essentially the solution prop osed by

Turner in Clearly the addition of these constants Ext is consistent as may

b e seen from the settheoretic or the set mo del Examples and

Its serious drawback immediately p ointed out by MartinLof in a subsequent

discussion also in is that this introduces noncanonical elements in each type

since we have not sp ecied how the eliminator J should b ehave when applied to a

pro of having Ext as outermost constructor For example consider the constant

family f N N N Now if x N P x Id U x V x for two functions

U V N N then Subst ExtP is an element of N in the empty

NNxNNN

context which do es not reduce to canonical form We address this problem later in

Chapter where we give syntactic mo dels in which functional extensionality holds

and which induce a decidable denitional equality on the syntax under which terms

like the ab ove are indeed denitionally equal to an element in canonical form One

may try to achieve the same thing by adding reduction rules for Ext under which

the ab ove term would for example reduce to Yet no satisfactory set of such

rules has b een found to date Notice however that we can show that the term in

question is propositionally equal to b ecause using J we can replace ExtP by

an instance of Re

In lo ccit Turner prop oses to add the denitional equation

Ext x Re U Re x U Id x U x U

x x

Chapter Syntactic prop erties of prop ositional equality

ie if we use Ext only to establish equality of denitionally equal terms then we

may use Re straightaway The equation is incomplete ie do es not solve the

problem with noncanonical elements b ecause for example even in its presence the

ab ove term is not equal to or any other canonical natural number We remark

that the prop ositional version of Turners equation is an instance of IdUni but

do es not seem to follow from J alone Interestingly using Turners equation we

can dene uniqueness of identity at types as well

Prop osition Consider an extension of TT containing a family of term

formers Ext satisfying Turners equation above If uniqueness of iden

tity is denable at x then it is denable at x

Pro of Consider the type EqPiu v x x Id u x v x We dene

u v x p Id u v x Resp u x u x p EqPiu v

x

and

u v x p EqPiu v Ext x p x Id u v

x

From uniqueness of identity at and Ext it follows that any two elements of

EqPi are prop ositionally equal On the other hand an element p Id u v is

x

prop ositionally equal to u v u v p using rst J and then Turners equation

Notice that Resp f Rex f x by IdComp We conclude using Resp for

2

Note that this pro of still go es through if Eqn only holds prop ositionally eg

by IdUni

In the remainder of this chapter we shall leave aside the issue of noncanonical

elements and study the logical implications of functional extensionality together

with uniqueness of identity We shall see that in a certain sense these two allow

to recover the strength of extensional type theory in an intensional setting

Chapter Syntactic prop erties of prop ositional equality

Extensional type theory

As describ ed in the Introduction in extensional type theory the denitional equal

ity is identied with prop ositional equality and thereby b ecomes extensional This

is achieved by adding the following two rules p

M N

P Id M N

IdDefeq

M N

M N

P Id M N

IdUni

P Re M Id M N

The rst rule IdDefEq is the equality reection rule discussed in the Introduc

tion Notice that this rule is needed to make the other one IdUni typecheck

For technical reasons we also assume an rule for types

M x

Eta

M x M x x

In it is p ointed out that in the presence of rules IdDefEq and IdUni

identity elimination b ecomes denable by putting

J M N N P M x N

The op erators IdUni and Ext are also denable see Prop in fact they are

just instances of reexivity Therefore extensional type theory do es not need ex

plicit elimination op erators for identity For these reasons extensional type theory

is intuitively quite app ealing It also is very close to set theory and extensional con

cepts like quotient types are easily added see and Sect Moreover it

avoids the unusual co existence of two dierent notions of equality The rest of this

Chapter is devoted to refute these apparent advantages of extensional type theory

and to argue in favour of intensional type theory with extensional concepts The

Chapter Syntactic prop erties of prop ositional equality

two main arguments we put forward are the undecidability of extensional type the

ory Sect and the conservativity of extensional type theory over intensional

type theory Sect which shows that nothing is lost by using intensional type

theory

Comparison with Troelstras presentation

In order to prevent p ossible confusion let us remark that in Troelstra and van

Dalens b o ok Sect the predicates intensional and extensional are

i

used in a dierent way Their intensional theory ML is a version of our extensional

type theory that is it has rule IdDefEq but with type equality conned to

basically syntactic identity So no denitional conversion is p ermitted inside a type

and thus the introduction rule for the identity type must b e extended to p ermit

one to conclude ReM Id M M from M M Moreover

i

ML neither contains a congruence rule for abstraction rule nor an rule

for types On the other hand their extensional type theory ML agrees mostly

with extensional type theory in our sense and in the sense of Intensional

type theory in our sense and in the sense of is only mentioned briey as a

note lo ccit p

Undecidabili ty of extensional type theory

The equality reection principle IdDefEq is problematic since up on its applica

tion the pro of P for the prop ositional equality is lost Therefore a syntaxdirected

decision pro cedure for denitional equality in extensional type theory would have

to guess this pro of P Our aim in this section is to prove that this is not p ossible

by showing that denitional equality in extensional type theory is undecidable

Before doing this we describ e how this entails undecidability of all other kinds of

judgements Assume M and N Now Re M Id M N

i M N so typechecking is equivalent to deciding denitional equality

Furthermore we have Id M M i M so typeho o d is equivalent to

Chapter Syntactic prop erties of prop ositional equality

typechecking The same go es for the remaining three kinds of judgements type

equality context equality and wellformedness of contexts

Let us now turn to the undecidability of denitional equality Although the rule

IdDefEq represents an information loss undecidability is not entirely obvious

b ecause it is not clear how many prop ositional equalities are actually provable In

particular there do es not seem to b e an obvious reduction to the halting problem

but one must use the to ol of recursively inseparable sets In order to avoid

the introduction of to o much machinery we shall however avoid explicit mention

of this notion We also avoid explicit formalisation of pro ofs and algorithms in

MartinLof type theory and app eal to a variant of Churchs thesis and the math

ematical intuition of the reader

n

If n is a natural number letn stand for the numeral Suc in type theory

We have n N A k ary function f on the natural numbers is called numeralwise

representable if there exists a term f N N N such that for every

\

k tuple of natural numbers x x we have f x x f x x N

k k k

N

It is wellknown and actually obvious from the form of the recursor R that every

primitive recursive function is numeralwise representable Compare this to the

interpretation of Heyting arithmetic in type theory Theorem

Fix some Godel numbering of Turing machines TMs in order to allow for

selfapplication of Turing machines and consider the following function

if TM e applied to itself halts after less than t steps with result

f e t

otherwise

Since the number of steps required to evaluate f e t is linear in e and t this

function is primitive recursive Let f N N N b e its numeralwise

representation

Now supp ose e is such that e applied to itself halts after some number of steps

with a result other than Then f e is constantly and this fact is actually

provable in type theory ie in this case the following type is inhabited by induction

N N

R and nite case distinction also R

t N Id f e t N

Chapter Syntactic prop erties of prop ositional equality

Using IdDefEq this implies that

t N f e t N

holds

On the other hand if TM e applied to itself halts with result then

t N f e t N

do es not hold b ecause this would contradict the denition of f

Notice that in case e applied to itself do es not halt the ab ove equation may

or may not hold according to whether nontermination is provable in type theory

Now if denitional equality in extensional type theory were decidable we could

construct a Turing machine which when applied to some number e returns if

t N f e t N

and returns otherwise Let e b e the Godelnumber of this machine and consider

the application of e to itself By denition of e this computation terminates We

arrive at a contradiction whatever the result is

Summing up we obtain

Theorem In extensional type theory denitional equality typechecking and

typehood are equivalent and undecidable

The same argument shows that inhabitation of identity types in nonempty contexts

is undecidable in intensional type theory

We remark that the undecidability of extensional type theory is part of the

folklore in the eld but to the b est of our knowledge has never b een explicitly

proved in the literature

Interpreting extensional type theory in intensional

type theory

In view of the ab ove undecidability results implementations of extensional type

theory like eg Nuprl deal with derivations rather than terms and judge

Chapter Syntactic prop erties of prop ositional equality

ments The question arises whether derivations in extensional type theory can

b e translated into terms in intensional type theory with functional extensional

ity and uniqueness of identity For example we may want to know whether if

x N U V N in intensional type theory and x N U V N in extensional

type theory then the type x N Id U V is inhabited in intensional type the

N

ory This is indeed the case and follows from a much more general corresp ondence

b etween intensional and extensional type theory which we prove b elow

The type theories TT and TT

I E

Streicher has observed in that in the presence of uniqueness of identity the

elimination op erator J can b e dened in terms of its particular instance Subst

dened ab ove Sect Indeed if x H x x Rex and P

Id M N then we form the type

x p Id M x M x p

Now we observe that M is inhabited by

L p IdM M Subst Sym IdUni P H M

Therefore Subst P L P is an inhabitant of M N P as required

This suggests to take Subst instead of J as a primitive if one has uniqueness of

identity For the remainder of this Chapter by intensional type theory or TT

I

we mean the theory TT from ab ove together with the constants IdUni and Ext

and with the elimination op erator J with its asso ciated rules replaced by a newly

introduced term former Subst governed by the following two rules

x x

M M

P Id M M

N M

Leibniz

Subst M M P N M

LeibnizComp

Subst M M Re M N N M

Chapter Syntactic prop erties of prop ositional equality

The type annotations and the rst two arguments to Subst may b e omitted If

so stated in the running text TT may b e augmented by further type formers

I

and rules Thus the term formers asso ciated to prop ositional equality in TT are

I

Re Subst IdUni and Ext

By extensional type theory or TT we mean the core type theory TT with

E

the identity elimination rules the rules IdElimJ and IdComp J replaced

by IdDefEq and IdUni and with Eta added In order to distinguish the

intensional from the extensional type theory we write and for the two

I E

resp ective judgement relations Recall from Sect that for f g we

I E

write true if there exists M with M and that denotes syntactic

identity mo dulo renaming of variables

It was mentioned b efore that the op erators of TT are denable in TT More

I E

formally we can dene a stripping map j j by

jSubst M M P N j jN j

jIdUni M P j Re Re jM j

Id jM jjM j j j

j j

jExt U V P j Re jU j

xj jj j

homomorphically extended to all other terms types contexts and judge

ments

This mapping enjoys the following trivial soundness prop erty

Prop osition If J then jj jJ j for al l contexts and judgements J

I E

Pro of By induction on derivations in TT or equivalently by showing that the

I

term mo del of TT forms a mo del of TT with the settings prescrib ed by the

E I

denition of j j The only interesting case is the interpretation of Ext If x

E

P Id U x V x then by IdDefEq we have x U x V x x So

E

by the congruence rule for abstraction we get x U x x V x

E

x and hence using Eta and transitivity U V x and nally E

Chapter Syntactic prop erties of prop ositional equality

ReU IdU V as required Without Eta we could obtain functional

E

extensionality only for abstractions but not for arbitrary terms of type 2

In order to compare the strengths of extensional and intensional type theory we

are now interested in p ossible converses of this prop osition In particular

Inv J implies J for

E I

some J with j j and jJ j J

ConsTy jj j j true implies true

E I

ConsId jj jM j jN j j j implies Id M N true

E I

Clearly ConsTy implies ConsId The rst prop erty Inv which in contrast to

the other two sp eaks ab out arbitrary judgements in TT is not true A counter

E

example is the judgement

x

x N x Suc N

E

x

N

x y NSucy x is the xth iteration of the successor where Suc R

N

function on start value If we decorate b oth sides of this equation with instances

of Subst we get more complicated terms but certainly no true equation in TT

I

The reason is that apart from congruence the only way that a Subst expression

can b e denitionally equal to something else is by use of LeibnizComp but then

the outermost Subst disapp ears and no equation has b een added which wasnt

there b efore However we certainly have

x

x N Id x Suc true

I N

since the required inhabitant of the identity type may b e constructed by induction

Together with IdDefEq this gives a pro of of the ab ove judgement in TT and

E

corrob orates ConsId

Our aim is to prove ConsTy and thus ConsId and to dene a mild exten

sion of TT under which Inv b ecomes true I

Chapter Syntactic prop erties of prop ositional equality

An extension of TT for which the interpretation in

I

TT is surjective

E

The ab ove counterexample would no longer go through if there were a term whose

x

stripping equals x and which nevertheless is denitionally equal to Suc in TT

I

To cure the problem with Inv we may simply add such a construct More precisely

we introduce a new term former M N P describ ed by the following two rules

M N P Id M N

I I

Form

M N P

I

M N P

I

Eq

M N P N

I

Let us write TT for TT extended with and for the corresp onding judgement

I

relation In view of Eq is a simple denitional extension comparable with the

addition of an explicit function symbol for multiplication which is denitionally

N

equal to its primitive recursive co ding using R The p ower of stems from its

interpretation in TT Namely we decree that

E

j M N P j jM j

Now Prop continues to hold

Prop osition If J then jj jJ j for al l contexts and judgements

E

J

Pro of As b efore by induction on derivations the only interesting case is the

rule Eq If M N P then we must have M N and

P Id M N So we may inductively assume that jj jP j Id jM j jN j

E

j j

and thus jj jM j jN j j j by IdDefEq But this is the stripping of the

E

conclusion of rule Eq 2

The interesting asp ect of TT is that the interpretation j j of it in TT is actually

E

surjective which means that Inv holds

Chapter Syntactic prop erties of prop ositional equality

Theorem Whenever J then there exist and J in the language of

E

TT such that J and j j and jJ j J

Pro of By induction on derivations in TT The interesting cases are Id

E

DefEq IdUni and Eta In the other cases we just follow the deriva

tion in TT For IdDefEq assume P Id M N and inductively

E E

M N where jC j C for C f P M N g Now the conclu P Id

M N P we have sion of IdDefEq is M N Putting M

E

M N but on the other hand jM j jM j M

The rule IdUni has the same premises so we keep the variables introduced so

far The conclusion of the rule is P Re M Id M N Therefore we

E

must nd a term P with stripping equal to P and which itself is denitionally

equal in TT to ReM Using we can relax this to prop ositional equality

I

This suggests to dene

P Subst N M Sym P P

x IdM x

We have P Id M M and IdUni P IdP ReM Moreover

jP j jP j P Therefore with

P P ReM IdUni P

Id M M

M M and the stripping of this judgement we have P Re M Id

is the conclusion of rule IdUni

Finally for Eta we use a particular instance of Ext 2

The particular instance of IdUni used in this pro of can b e dened using J as well

So if we had used J instead of Subst we could have avoided the use of uniqueness

of identity Then however jP j would not b e identical to P but only reduce to

P One could circumvent this using J dened ab ove in Sect as primitive

The only use of functional extensionality was in order to mimic the rule Eta

If one were not interested in this rule one could get surjectivity of j j with

alone and no extensional concepts at all In particular in TT we can derive a

Chapter Syntactic prop erties of prop ositional equality

prop ositional counterpart of the congruence rule rule as follows Supp ose

that x U V and x P Id U V Then we have

Re x V Id x U V P x V

x x

This shows quite well how works In a certain sense the ab ove judgement is a

triviality b ecause it is an instance of reexivity But if one do es not identify den

itionally equal terms and instead reads an expression M N P as something

like means M but is written N for reasons of intensionality and this is justied

by virtue of P then the ab ove judgement really corresp onds to the conclusion

of a prop ositional rule One can do even more andusing extensional concepts

and instances of Resp move all the instances of to the ro ot of a term with the

stripping unchanged which may b e used to obtain a variant of prop erty ConsId

as follows If M N we can nd and free terms M M N

E

N and pro ofs P P such that

N N P M M P

where j j j j jM j M and jN j N From the denition of we

then get

M M Trans P Sym P Id

which we can see as the conclusion of ConsId in case and are suciently

simple so that they equal their stripping Also the type annotations of M M

must not contain any instances of or Subst which may b e dicult to guarantee

We will not pursue this line of thought any further and prove ConsTy and

ConsId by other metho ds b elow However we want to advocate the use of as

a p ossible addition to intensional type theory even in the absence of extensional

concepts This requires a slightly unusual approach to theorem proving in type

theory b ecause in the course of trying to prove a goal it may b ecome necessary

to alter it by interspersing instances of Eg we cant prove that x U and

x V from ab ove are denitionally equal or without functional extensionality

that they are prop ositionally equal but by altering the goal using this b ecomes

p ossible as we have just seen in the derivation of Judgement

Chapter Syntactic prop erties of prop ositional equality

Conservativity of TT over TT

E I

Our aim is now to prove prop erty ConsTy of which ConsId is a consequence

In fact we shall establish the following mild generalisation of ConsTy

Theorem If and jj P j j for some P then there exists P such

I E

that P Moreover jj jP j P j j

I E

Before embarking on the pro of of this Theorem we remark that it do es not follow

from Inv ie in the presence of b ecause if and jj j j true then we

E

have true for some and with j j jj and j j j j but there is

no reason why true should hold to o It would however b e true if types

and contexts with identical stripping could b e shown to b e isomorphic On the

other hand this fact at least for types is a consequence of ConsTy b ecause if

j j j j then the stripping of

f f

Idx f f x x x Idx f f x x x

is inhabited in TT by taking the identity on for f and f and ConsTy then

E

gives an isomorphism b etween and in TT

I

These isomorphisms are indeed the key to proving the conservativity theorem

but it turns out that the use of can b e avoided

The idea for the pro of is to show that the term mo del of TT quotiented by

I

prop ositional equality forms a mo del of TT Quotienting a mo del of type theory

E

is however not an easy thing to do b ecause as so on as one identies two morphisms

f g one also has to identify families over which come from the same

family over through substitution along f and g This identication of families

also forces identication of certain contexts and therefore of new morphisms which

were incomparable b efore We do not know whether there exists a general theory

of quotients of syntactic categories with attributes and more generally of brations

and generalised algebraic theories but we b elieve that such a theory would have

to b e fairly complicated Fortunately in the particular case at hand we have a

Chapter Syntactic prop erties of prop ositional equality

go o d denition for when two types or contexts are to b e identied so that we can

get away without lo oking at the most general case

Our strategy consists of rst extending prop ositional equality to contexts so

that we can say when two context morphisms are to b e identied Next by struc

tural induction we construct p ossibly undened isomorphisms up to prop ositional

equality b etween types and b etween contexts in such a way that the isomorphism

b etween two types and b etween two contexts is dened i their strippings are

equal in TT The key idea of the pro of is that this semantic prop erty of types

E

and contexts can b e dened by structural induction

We identify two types or contexts if the corresp onding isomorphism is dened

and show that this gives a mo del of TT We then show that stripping lifts to

E

an op eration on the induced equivalence classes and denes a structurepreserving

map b etween this mo del and the term mo del of TT Its comp osition with the

E

interpretation of TT in the quotient mo del must therefore b e the identity This

E

together with the fact that equality in the quotient mo del is isomorphism gives

the desired result

Prop ositional equality of context morphisms

Let b e a context in TT By induction on the length of we dene a type

I I

out and in x as in the empty context and substitutions x

I I

follows

in

out

x g out g

in x in x pair

x

out

out z x out z z

x

From the equation Comp we get the denitional equality

out in

I

Chapter Syntactic prop erties of prop ositional equality

This equation is needed for the denitions ab ove to typecheck so strictly sp eaking

we have to establish it along with the inductive denition ab ove

The converse only holds prop ositionally If M then by induction on the

I

length of and using R we can construct a term srj M such that

in out M M srj M Id

I

This reection of contexts into types allows us to compare substitutions up to

prop ositional equality If f g then we can form

I

Id in f in g

I

and if P Id in f in g and M f then since

I I I I

f out in f we have

in f in g P M g Subst

I

out

So the ab ove type b ehaves like an identity type at contexts We thus introduce

the abbreviations

in f in g Id f g Id

and

Subst f g P M Subst in f in g P M

out

for these types and terms We also write

Re f Re in f

and

IdUni f P IdUni in f P

As usual we allow the omission of arguments which can b e inferred or are clear

from the context

From LeibnizComp and IdUniComp we obtain the denitional equalities

Subst Ref M M f

I

IdUni f Ref ReRef Id f f

I

Chapter Syntactic prop erties of prop ositional equality

Remark This denition of propositional equality of context morphisms can

stil l be carried out when Comp is a replaced by a propositional equality as is

the case in the type theory S to be introduced in Sect but then one must

construct a witness for the propositional counterpart of Eqn along with the

denition of in and out This is possible but messy to write down

Prop ositional isomorphisms

A pair of syntactic context morphisms f and f is called a

I I

propositional isomorphism b etween and if Id f f true and

I

Id f f true In this situation we write f f If

I

and then a pair of terms x f x and x f x

I I I I

is called a propositional isomorphism b etween and if x Id f f x

I

x true and y Id f f y y true We write f f to

I I

indicate this

We shall now partially dene symbols co and ty by structural induc

tion on preterms and precontexts in such a way that if these symbols are dened

they constitute prop ositional isomorphisms in the following way

co co

and

co ty ty

I

The inductive clauses for these symbols are as follows

co co

co x co ty x

x y

co y co ty co Subst P y

x y

where P Id co co is obtained from the assumption that co

I

The context morphisms co and co are undened in all other co

cases In particular co is undened if and have dierent length

Chapter Syntactic prop erties of prop ositional equality

The prop ositional isomorphisms ty can only b e dened if and share

the same outermost type former We have a clause for each of these

x if co is dened

ty x

NN

undened otherwise

ty ty

NN NN

For the denition of ty assume f x and y co

x y

We put U ty y and V f v U Now

W ty U V co ty U

x y

by expanding the denition of co Finally

x y

Subst P W co y

where

y co P Id

I

y co

y co ty ty

co y

ty is obtained from reexivity and the assumption ty

I

co and thus

ty f y co Subst P W y co

x y

is dened in the same way interchanging the roles The inverse ty

x y

of ty and ty The pro ofs that a prop ositional isomorphism has b een constructed

are obtained using Ext

we assume and f x Now For ty

x y

f co U ty

and

V ty f f co U

x y

We thus dene

ty f U V y co

x y

Chapter Syntactic prop erties of prop ositional equality

The inverse is again obtained by interchanging ty and ty For the pro of of the

isomorphism prop erty one uses that surjective pairing holds prop ositionally see

Sect

For ty we check whether there exist P Q with

Id M M Id N N

P Id ty M N co

I co

P Id ty M N co

I co

If not then ty is undened If yes then for p Id M M

Id M M Id N N

we dene

ty p Id M M

Id M M Id N N

Trans Sym P Trans Resp x ty x p P

Id N N co

The inverse is dened analogously the pro of of the isomorphism prop erty is an

instance of IdUni

Notice that this denition dep ends in various places on choices of particular

pro ofs of prop ositional equalities Some of the choices eg in the denition of

could b e avoided by carrying through explicit witnesses for the various co

x y

isomorphism prop erties Others like the one in the clause for the identity type

are more dicult to eliminate

These prop ositional isomorphisms enjoy various prop erties all of which follow

by straightforward structural induction First for convenience we restate the

isomorphism prop erties

Lemma Let and

I I

i If co is dened so is co and the two constitute a propositional iso

morphism between and

ii If ty is dened so are co and ty and ty ty

I

co

Chapter Syntactic prop erties of prop ositional equality

Next we state that denedness of the prop ositional isomorphisms induces an equi

valence relation on contexts and on types

Lemma i If then co is dened and Id co true

I I

ii If then ty is dened and x Id x ty x true

I I

iii If co is dened then so is co

iv If ty is dened then so is ty

v If co and co are both dened then so is co and

Id co co co true

I

vi If ty and ty are both dened then so is

ty and

x Id

I

co

Subst P ty co ty x

ty x true

for every

P Id co co co true

I

We also need that the prop ositional isomorphisms are stable under denitional

equality and under syntactic substitution

Lemma i If and then if co is dened so is

I I

and co

true Id co co

I

ii If and and and then if ty

I I I I

is dened so is ty and

x Id Subst P ty x ty x true

I

for every P Id co co

I

Chapter Syntactic prop erties of prop ositional equality

Lemma Suppose that ty is dened and that f and

I I

g are syntactic context morphisms satisfying

true Id co f g co

I

dened then ty is dened and so in particular co

f g

ty x ty f x true x f Id

I

g co

f g

The relationship to extensional type theory is describ ed by the following lemma

Lemma i If co is dened then jj jj and jj

E E

jco j jj

ii If ty is dened then jj j j j j and

E

jj x j j x jty j x j j

E

A mo del for TT

E

We come to the construction of a mo del for TT by quotienting the term mo del

E

of TT We write for an equivalence relation determined by the linguistic

I

context and for equivalence classes

Denition The category C has as objects equivalence classes of contexts

where and are considered equivalent if co is dened this forms an

I

equivalence relation by Lemma A morphism between and is an

equivalence class of triples A B f where A B and A f B

I

are and co Two such triples A B f and A B f are equivalent if co

BB AA

dened and

true f f co co A Id

AA BB I B

Again it fol lows from Lemma together with properties of Id that this denes

an equivalence relation The identity morphism on is given by

I

The composition of B g and A B f

is dened by f Observe that co is given by A A g co

BB I BB

Lemma

Chapter Syntactic prop erties of prop ositional equality

Prop osition C is a category with terminal object

Pro of First we check that homsets identities and comp osition are welldened

ie indep endent of the choice of representatives For the homsets this is obvious

the case of identities is an instance of reexivity For comp osition we consider the

diagram

f co g

A B B

co co co co

f co g

A B B

If the two outer squares commute up to prop ositional equality ie if A B f

A B f and B g B g then the whole rectangle commutes up to

prop ositional equality b ecause the inner square do es by Lemma It is obvious

that identities are neutral For asso ciativity of comp osition assume A f B

I

B g h A common representative for b oth ways of comp osing

I I

the triple is given by

f g co A hco

BB I

Finally the obviously unique morphism from to is given by 2

Denition The mo del Q A syntactic category with attributes Q over

the category C is dened as fol lows Let ObC A family over is an

equivalence class of pairs with where two such pairs and

I

is dened The set of families is are considered equivalent if ty

denoted Fam

If Fam then the morphism p is

represented by

x x co

I

Chapter Syntactic prop erties of prop ositional equality

If A B f then the substitution fA B f g is represented by

A A co f The morphism qA B f is represented

I B

by

A x co f x

B

A x co f co f x x

B I B

A section of is an equivalence class of triples M with

and M where two such triples M and M are equivalent if

I

true M M co ty Id

I

If M is a section of Sect then a morphism M

is represented by

x

M x

I

Conversely if A B f then we must have B B x since

equivalent contexts have equal lengths Thus f f M for B M f We

I

put HdA B f B f M

Prop osition Q is a syntactic category with attributes

Pro of Routine verication As an example we check that substitution in famil

ies is welldened and commutes with comp osition Supp ose that g B g

and  Fam We have

 fg g B co g

Now let b e another representative for  We must show that

g B co g B co

b eing dened By By denition this is equivalent to ty

f B B co f co

Lemma this holds if ty is dened and

true co g co g co co B Id

B B I

Chapter Syntactic prop erties of prop ositional equality

The former follows from the assumption the latter follows by

equality reasoning from Lemma

Now supp ose that B g B g is another representative for g We

must show that ty is dened Using Lemmas and

B B co g co g

this b oils down to

B Id co co g co g coB B true

I

Using the fact that Id resp ects comp osition and using Lemma this follows

from

g g coB B true co B Id

I

which is the denition of B g B g

For compatibility with comp osition assume in addition that f A B f

f and and  Fam We have g f A g co

BB

thus

f  fg f g A co g co

BB

which equals  fg gff g as required 2

Prop osition The stripping map j j from TT to TT lifts to a struc

I E

ture preserving map from Q to the term model of TT constructed according to

E

Ex dened by jj jj j j j j and j M j jM j

Pro of Immediate from Lemma for contexts and types and rule DefEq

and the denition of stripping for context morphisms and terms 2

Prop osition The model Q supports types types natural numbers

and extensional identity types and these are preserved by j j

Chapter Syntactic prop erties of prop ositional equality

Pro of Let  Fam and  x Fam  We

represent   Fam by

x ty x co

I

It follows from the denition of ty for types that this is welldened

If M x M Sect we represent its abstraction M

 

Sect  by

x M x

I

is This is indeed a section of   b ecause ty

x ty x co

dened by assumption and the denition of ty for types For welldenedness

we use again the denition of ty for types

Now let M x M Sect  observe that the type of M

must b e a dep endent pro duct and N N Sect The application

App M N Sect f Ng is represented by

 

N N ty M ty

I

Now the required equations are readily checked and since the type and its

asso ciated term formers are mo delled by their syntactic companions interspersed

with canonical isomorphisms it follows that stripping preserves the dep endent

pro duct structure b ecause the canonical isomorphisms are mapp ed to identities

by Lemma

For the identity type assume  Fam and M M

Sect and N M Sect We represent the identity type Id M



N Fam by

M N co ty Id

I

Now if this family has a section then M N by denition of equality on sections

and any two sections of this family are equal by IdUni and the denition of equality

on sections

We follow the same pattern for types and natural numbers 2

Chapter Syntactic prop erties of prop ositional equality

Pro of of Theorem Consider the following informal diagram of inter

pretations

Q

I

j j

R

TT TT

I E

j j

Here TT and TT denote the term mo dels asso ciated to the type theories TT

I E I

and TT The informal map TT Q denotes the interpretation of TT

E I I

in Q which b eing a mo del for TT also is a mo del for TT The mapping j j

E I

Q TT is the lifting of j j TT TT given by Prop Finally

E I E

TT Q is the canonical mapping asso ciating equivalence classes which is

I

structure preserving by denition of Q

These maps preserve all the type and term formers up to semantic equality

thus by induction on derivations or more elegantly by an initiality argument

we nd that any two paths in this diagram with common source and target and

starting from either TT or TT are equal In more elementary terms this gives

I E

in particular the following identities

i If then jj in Q

I

ii If then jj j j j in Q

I

iii If M then M jj j jM j in Q

I

iv If then jj

E E

v If then j j j

E E

We cannot prop erly formulate initiality of TT and TT since we have not dened

I E

morphisms of mo dels See however Remark

Chapter Syntactic prop erties of prop ositional equality

vi If M then j j M j M

E E

Now supp ose that and jj M j j The interpretation yields

I E

jj j M Sectjj j j j

Thus Sect by Eqn ii By denition of Q this means that there exist

and ty M with P and co are dened Therefore we

I

have

M co ty

I

and therefore true Call this term M ie M By denition of Q

I

we have M jj j M and thus jj jM j M j j by Eqn vi 2

E

Discussion and extensions

The relative complexity and clumsiness of the present pro of is regrettable and it

is our hop e that in the near future a shorter and more elegant pro of will b e found

Notice however that the describ ed metho d is fairly robust wrt extensions of the

type theory For it to b e extensible to a new type former it is enough that this

type former admits an action on prop ositional isomorphisms To demonstrate this

we consider the addition of quotient types and of a universe closed under types

and natural numbers b elow

A p ossible p oint of criticism is the nonconstructive nature of the pro of Not

only has the axiom of choice b een used in the denition of the canonical iso

morphisms co and ty more seriously the interpretation of TT in Q asso ciates

E

equivalence classes to contexts types and terms In order to get an inhabitant of

type in the pro of ab ove we must arbitrarily choose a representative of the cor

resp onding class So the present pro of do es not directly give rise to an algorithm

which eectively computes an inhabitant of in TT from a derivation of j j true

I

in TT Such algorithm trivially exists by Markovs principle we simply try out

E

all p ossible terms and derivations and from the nonconstructive pro of of existence

we know that this search always succeeds But of course one would like a more

Chapter Syntactic prop erties of prop ositional equality

ecient algorithm which makes use of the derivation in TT It is however not

E

clear whether the describ ed argument gives rise to such an algorithm An idea

would b e to carry out the construction of Q in a setoid mo del similar to the ones

describ ed in Chapter where quotients come with a canonical choice of repres

entatives In the present framework of a settheoretic presentation of syntactic

categories with attributes this is however not p ossible

Denitional equality has played a minor role in the present pro of and it app ears

that the whole development go es through if TT was replaced by a type theory

I

without denitional equality at all and rules like replaced by corresp onding

constants of identity types in the style of IdUni The construction of the mo del

Q would remain unchanged since prop ositionally equal ob jects are identied in Q

Quotient types

The Nuprl version of TT contains a quotient type former governed by the

E

following rules

x x x x M

QEForm QEIntro

M

M N H M N

QEEq

M N

x x x M x x

x x p x x M x M x x

N

QEElim

plug N in M N

QEComp

plug N in M M N N

Here is viewed as a binary relation on and the idea is that is the type

of equivalence classes of the least equivalence relation on containing The

op erator asso ciates an equivalence class to an element of The rule QEEq

states that equivalence classes of related elements are equal in Notice that

Chapter Syntactic prop erties of prop ositional equality

this rule introduces an information loss in a way similar to IdDefEqup on its

application the pro of H is lost The lifting op erator plug in p ermits one to

dene functions on the quotient type as usual in mathematical practice by dening

it on representatives and proving indep endence of the particular representative

chosen Notice that QEEq is required for QEElim to make sense Finally

the rule QEComp states intuitively that the underlying algorithm of a lifted

function is the function itself

A version of quotient types for TT has to replace the conclusion of QEEq by

I

a prop ositional equality and include instances of Subst in order to make rule Q

EElim typecheck Formally we extend TT by the following rules for intensional

I

quotient types

x x x x M

QIForm QIIntro

M

M N H M N

QIAx

Qax H Id M N

x x x M x x

x x p x x

H Id Subst Qax p M x M x

x

N

QIElim

plug N in M using H N

QIComp

plug N in M using H M N N

Let TT TT refer to the resp ective extensions of TT and TT with quotient

EQ IQ E I

types and let denote the corresp onding judgement relations

EQ IQ

We notice that like Ext the term former Qax introduces noncanonical ele

ments in the identity type and thus in all types In Chapter we study mo dels

In the rst of these mo dels Sect QIForm is restricted to relations of the

form Prf R for some x x R Prop and QIElim is split into a nondep endent

elimination rule and an induction axiom

Chapter Syntactic prop erties of prop ositional equality

which induce further equations for Qax so that these noncanonical elements disap

p ear but for now TT is any extension of TT supp orting the rules for quotient

IQ I

types So in particular this may b e one of the type theories to b e studied in

Chapter or it may b e a simple addition of the rules for quotient types to TT

I

where we ignore the problem with noncanonical elements

Let us now study the relationship b etween TT and TT The interpret

IQ EQ

ation j j of TT in TT extends to quotient types by setting jQax H j

I E

Re jM j where H M N and homomorphically extending to the

I

j jjj

R

other type and term formers Eg j j j jjj Now again Prop contin

ues to hold ie if J then jj jJ j Moreover if TT and denote

IQ EQ Q Q

the extension of TT by as in Sect we obtain an analogue of Thm

IQ

ie if J then J for some J with j j and jJ j J Here

EQ Q

the only new nontrivial case arises from rule QEEq In order to mimic this in

TT we have to use QIAx and an instance of

Q

More interestingly TT is again conservative over TT with resp ect to type

EQ IQ

inhabitation

Theorem If and jj P j j for some P then there exists P

IQ EQ

such that P

IQ

Pro of The pro of follows the same pattern as the pro of of Thm First we

extend the denition of the tyisomorphisms as follows Assume and

IQ

In this context we put U x ty x co Now in

IQ

the context x x p x x we put

V ty x x p co ty x ty x

xx y y

and therefore we have

x x p x x V co U x U x

IQ

and hence

x x p x x Qax V co IdU x U x

IQ

Chapter Syntactic prop erties of prop ositional equality

Therefore we may use rule QIElim and conclude

q plug q in U using V co

IQ

If all the participating isomorphisms were dened we make this term the value of

ty The inverse is dened analogously

Next we must show that Lemmas carry over to this extension

The pro ofs are dicult to write down but are essentially straightforward As an

example we show Part ii of Lemma In the situation we must

IQ

establish

q Idq ty q true

IQ

After expanding the denitions and simplifying by using the Lemma inductively

for and this b oils down to the following prop erty which may b e compared to

the rule for quotients in simple type theory

Lemma If then

IQ

q

IQ

Id plug q in x x using x x p x x Qax p q true

holds In other words the lifting of the projection equals the identity

Pro of of Lemma Let

q

Id plug q in x x using x x p x x Qax p q

By rule QIComp we have

x Re x x

IQ

Moreover since is an identity type we have

x x p x x

IQ

H Id Subst Qax p Re x Re x

x

for H IdUni Subst Qax p Re x In fact this identity may

x

also b e proved using J alone Therefore we may conclude

q plug q in x Re x using H q

IQ

Chapter Syntactic prop erties of prop ositional equality

as required 2

Having dened the canonical isomorphisms co and ty for TT we construct

IQ

a mo del Q from TT in exactly the same way as in the pro of of Thm

IQ

In order to get an interpretation of TT in this mo del we must show that it

EQ

supp orts the rules for quotient types from TT Supp ose that  Fam and

EQ

 x x Fam   Recall that this means x x

IQ

and that ty is dened and that b oth and are representatives

for  We dene the interpretation of the quotient type as the following family

over

 

where

x x x ty x

If M M Sect then we put

M co M ty



which is a section of   If M N Sect and H SectfM gfNg then by

suitably comp osing with the tyisomorphisms and using QIAx and the denition

of equality for sections we obtain that M N ie rule QEEq is validated

 

We continue similarly for the remaining term formers and rules and then pro ceed

as in the pro of of Thm 2

Universes

We consider an extension of b oth TT and TT by the rules for a universe closed

I E

under types and natural numbers from Sect It is known that extending

TT by universes allows nonnormalising terms to b e typed For example in the

E

context d U p Id d d x dd we can derive the type equality

U

D D D E

Chapter Syntactic prop erties of prop ositional equality

for D Eld using rules IdDefEq and UEq and therefore we have the

judgement

x D x x x D x x D

E

In TT we can only construct a prop ositional isomorphism b etween D and D D

I

using instances of Subst This allows one to construct a term M such

UxUElx

that jM j is nonnormalising but where M itself do es not contain any redexes at

all b ecause the instances of Subst contain the variable p which prevents reduction

Our aim is to show that the development in the previous sections go es through

for this extension Certainly Thm characterising the extension of TT by

I

the op erator continues to hold b ecause we make the same extension to TT and

I

TT More imp ortantly Thm establishing the conservativity of TT over

E E

TT as far as inhabitation of types is concerned carries over as well

I

Theorem The extension of TT by a universe closed under and nat

E

ural numbers is conservative over TT with the same extension in the sense of

I

Thm

Pro of As in the case of quotient types we have to extend the denition of the

tyisomorphisms so as to account for the newly introduced types U and ElM

A certain complication arises from the fact that it is no longer the case that

if then and share the same outermost type former b ecause of

I

the nonlogical type equalities UEq and UEqN We may introduce an

additional clause for ty to account for this equality but then in order to retain

transitivity Lemma we must close up under comp osition of ty from the left

and from the right Then however ty is no longer uniquely dened and one would

have to establish coherence up to prop ositional equality To account for arbitrary

nonlogical type equalities this seems indeed to b e the only p ossible way in the

particular case of a universe we can get away by treating types of the form ElM

separately

We say that is a smal l type if ElM for some

I I I

M U Notice that in this case we must have either N or I

Chapter Syntactic prop erties of prop ositional equality

x x ElN for some k and x x N U and small

k k k k I

Now we introduce the following two clauses to deal with U and small

k

types

x if co is dened

ty x U

UU

undened otherwise

and

ty x Subst P x

xUElx

if there exist M N P with ElM and ElN ie and

I I

are small and P Id M N co and undened otherwise In the former

I U

case M N P are chosen arbitrarily The inverses are dened analogously

The clause for N in Sect is removed and the clause for types in

Sect is restricted to those cases which are not yet dealt with by the ab ove

is dened by the clause given there clause for small types ie ty

x y

only if x and x are not small

Now it is easy to show that the auxiliary prop erties of these canonical iso

morphisms continue to hold Notice that if ty is dened and is small so is

It remains to show that the mo del Q constructed from the extended syntax as

in Def still supp orts types natural numbers and a universe

The type of natural numbers is given by N N We have N

SectN If M M SectN then we must have ElS and

I

P IdS N for some P Now we dene

I

SucM N SucSubst P M

N

In a similar way we dene R using precomp osition with instances of Subst

UEl

where necessary

For the type we only need to consider the case   where b oth  and

 are small since in all other cases we may pro ceed as in the pro of of Prop

ab ove So assume  ElS and wlog  x ElS ElT x We

Chapter Syntactic prop erties of prop ositional equality

dene   as ElS T That this is welldened and also the deni

tion of the asso ciated combinators follow from the following Lemma which states

that the tyisomorphisms for types remain essentially unchanged by the altera

tion for small types

Lemma Suppose that S U and T U and x ElS M U

I I I

and x ElT N U and P IdS T co and x ElS Q

I I I

IdM N Subst P x ie ty is dened Then

xElS xElT ElM ElN

u x ElS ElM Id

I

ty x

xElS ElM xElT ElN

x co Subst Q u ty x true

UEl

ElS ElT

where ty is the propositional isomorphism given by the now overridden clause

of Sect

Pro of of Lemma Using Ext and elementary equality reasoning 2

We may now replace instances of ty at small types by ty and pro ceed as in

the pro of of Prop

The universe and its externalisation are dened as the equivalence classes of

U and El resp ectively The co de N in context is given by U N Similarly

we dene the co de of as the lifting to equivalence classes of the syntactic term

former That this is welldened is readily checked using Resp and Ext

We conclude as in the Pro of of Thm 2

Remark We believe that this result extends to an impredicative universe

as dened in Sect but we have not been able to prove this because it is not

clear how the operator lifts to equivalence classes That is if ty is dened

and x M Prop then it is not obvious why one should have

I

Id x M ty x M true

I Prop

Chapter Syntactic prop erties of prop ositional equality

although this can probably be shown by induction on the structure of

We also remark that the existence of a term M in TT such that jM j is non

I

normalising is now an immediate consequence of the conservativity theorem

extended to universes

In Chapters and we also consider Prop valued Leibniz equality as an imple

mentation of prop ositional equality In general Leibniz equality is much weaker

than the identity type in TT b ecause substitution Subst is p ossible only for

I

prop ositional families of the form x Prf P Thus the results rep orted in

this chapter do not apply to Leibniz equality However the type theory S we

consider in Chapter has the unusual prop erty that its Leibniz equality behaves

like the identity type so that the results do carry over In the deliverables mo del

of Chapter we could dene an identity type which would co exist with Leibniz

equality but it would not b e Propvalued

Conservativity of quotient types and functional ex

tensionality

We have now studied in much detail the question of conservativity of TT over TT

E I

Another imp ortant question is the conservativity of TT over pure type theory

I

without extensional concepts added Let TT denote the type theory without

p

Ext but with IdUni and let denote the corresp onding judgement relation

p

Certainly we cannot in general have that and true implies true

p I

b ecause the type of Ext is valid in TT However we b elieve that the following

p

holds

Conjecture If and neither nor contains instances of the

p

type then true implies true

I p

A p ossible pro of of this would use one of the mo dels to b e presented in Chapter

and show that a free type is prop ositionally isomorphic to its in

the mo del We shall try to answer this question in future work In Sect

Chapter Syntactic prop erties of prop ositional equality

such a conservativity result is proved for rstorder predicate logic over simple type

theory using a similar metho d but the situation is much simpler there b ecause

one only has to consider biimplication instead of isomorphism

As shown in uniqueness of identity is not conservative over type theory

without it in any reasonable sense b ecause for example we have

x u v x Id pairx u pairx v Id u v true

I

x x x

but this do es not hold in the pure type theory with J alone Probably one has

conservativity for types not containing the identity type but this is logically un

interesting

Surprisingly quotient types are not conservative over TT b ecause in their

p

presence a weak form of functional extensionality is derivable Supp ose that

p

F G x and H x Id F x G x We claim that

p

Id x F x x G x true

IQ x

using quotient types but of course without using functional extensionality To get

the conclusion of functional extensionality from this in the sense of Sect

an rule for types would b e required

Dene

ExtEqu v x x Id u x v x

and consider the quotient type x ExtEq Now we have

x u x u x x

and

x u v x p ExtEqu v p x Id u x v x

x

Thus we can lift application to the quotient type and get

x q x ExtEq

IQ

plug q in u x u x using u v x p ExtEqu v p x x ExtEq

Chapter Syntactic prop erties of prop ositional equality

and by abstracting from x we obtain

q x ExtEq

IQ

x plug q in u x u x

ExtEq

using u v x p ExtEqu v p x

x

Call this function Extract ie

q x ExtEq Extractq x

IQ

Notice that by rule QIComp we have

f x Extractf x f x x

IQ

ExtEq

We have

Qax H Id F G

x ExtEq

ExtEq

ExtEq ExtEq

and therefore Id x F x x G x true by Resp

x

We do not know whether quotient types are conservative over extensional type

theory TT

E

Related work

Astonishingly the metatheory of prop ositional equality in particular in the con

text of intensional type theory has attracted very little attention in the literature

In the standard the intensional TT and the extensional TT

I E

versions of type theory are introduced and compared by way of example

Streicher was the rst to see the need for uniqueness of identity as an

additional principle for prop ositional equality in intensional type theory He also

realised that the complicated elimination rule J may b e replaced by the Leibniz

principle Subst and uniqueness of identity if one is interested in the latter In

lo ccit an rule for the identity type is introduced and it is shown that it entails

Chapter Syntactic prop erties of prop ositional equality

equality reection ie the rule IdDefEq The rule is as follows If x y

p Id x y M x y p x y p then

x y p Id x y Jx M x x Rex x y p M x y p

Streichers work has b een taken up in and syntactic consequences of uniqueness

of identity in the context of Pure Type Systems are studied

Luo studies a few metaprop erties of prop ositional equality in the con

text of the Extended Calculus of Constructions He discusses the socalled equality

reection principle which states that prop ositional and denitional equality agree

in the empty context This principle not to b e confused with the equality reec

tion rule IdDefEq is in the absence of extensional concepts an immediate

consequence of normalisation Luo also considers formulations of the Calculus

of Constructions which have an identity type inside Prop and nevertheless allow

elimination Subst J over arbitrary families not only prop ositional ones He

observes that these identity types and the denable Leibniz equality imply each

other However as shown by Streicher in this biimplication only forms a

retraction and not a prop ositional isomorphism b etween the two incarnations of

prop ositional equality and so in particular it is not p ossible to dene a Jlike elim

ination rule or equivalently uniqueness of identity for Leibniz equality in this

case

Recently Gabbay and de Queiroz have lo oked at prop ositional equality

in the context of labelled deductive systems In their setting not only prop osi

tional equality but also denitional equality is witnessed by a pro of term la

b el written as a subscript to which in this case records instances of reexiv

ity symmetry transitivity and of the congruence rules They have the following

introduction rule for identity types given here in our notation

M N

s

Re M N s Id M N

and the elimination rule

M N L P Id M N

t

TEST P L

Chapter Syntactic prop erties of prop ositional equality

where t is a variable that b ecomes b ound in the TEST expression They claim that

this elimination rule for prop ositional equality is simpler than IdElimJ but they

do not compare to the formulation with Subst and IdUni It is dicult to give a

satisfactory comparison b etween their system and TT say b ecause the framework

I

is very dierent for example the hypothetical use of denitional equalities in the

elimination rule is not p ossible in TT and in fact we consider it the raison detre

I

of prop ositional equality that it may b e assumed hypothetically We conjecture

that one may give a translation b etween Gabbay and de Queiroz calculus and

TT by mapping b oth annotated denitional equality and prop ositional equality

I

to the identity type but since their calculus is not given in a fully formal way it

is hard to give more detail As an application they give a pro of of a constructive

variant of Leisenrings formula xy P x P y that is they show that the

type in our notation

x y Id x y x y

is inhabited Obviously an inhabitant may b e constructed using Subst as well

Extensional quotient types like the ones considered in Sect have b een

theoretically investigated by Mendler who nds that they corresp ond to cat

egorical co equalisers See also the section on related work in Chapter

The problem with the failure of strong normalisation in the presence of ex

tensional identity types and universes Sect has also b een noticed in

where it is concluded that for this reason identity types cannot b e used to describ e

sharing constraints in SML functors and that sharing by parametrisation

ought to b e used instead We b elieve that was written in ignorance of the

intensional identity type and that the latter provides a reasonable alternative to

sharing by parametrisation We leave this to further research

Chapter

Pro of irrelevance and subset types

Our aim in this chapter is to present a syntactic mo del for the extensional concepts

of pro ofirrelevance and subset types The mo del we give not only provides these

concepts but also relates two approaches to program development in MartinLof

type theory or the Extended Calculus of Constructions ECC Under the

rst one sp ecications and types are freely mixed using types This metho dology

underlies a pro ject for development of correct software at the University of Ulm

It is also the most natural approach and is probably employed by most users

of type systems like the ones under consideration

In the second approach types and sp ecications are kept completely distinct

This way of using type theory has b een studied systematically in McKinnas

thesis We consider b oth approaches in detail For deniteness we work in

the Calculus of Constructions extended with types and natural numbers which

L

enables us to use the dened logical connectives and Leibniz equality Much of

the development to follow can also b e carried out in MartinLoftype theory repla

cing Leibniz equality by the identity type and the logical connectives by pro duct

sum etc

Chapter Pro of irrelevance and subset types

The renement approach

Let us start with an example A type of even numbers can b e formed as

L

Even n Nm Nn m

An element of type Even is thus a natural number together with a pro of that it

is even More generally a function with result type Even can b e viewed as an

Nvalued function together with a pro of that it only takes on even values Such a

function can thus b e viewed as a veried program For lack of a b etter name we

call this metho dology the renement approach There are basically two problems

with this approach First the pro jection from a rened type such as Even to its

underlying type of elements here N is in general not injective for two elements

of type Even may have the same underlying number but two dierent pro ofs of

evenness More seriously a function out of a rened type even into a base type

like N may dep end on the pro of comp onent For example if f Even Even

then f decomp oses into

L

f n NPrf m Nn m N

and

L L

f Prf n Np m Nn mm Nf n p m

So even in order to compute the underlying natural number of f x for some

x Even b oth comp onents of x are required Even if by strong normalisation we

know that f x eventually converts to a natural number this computation may

In the terminology of Hayashi Even is a renement of N

If we formulate this example using the identity type instead of Leibniz equality and

instead of then we could prove using Prop and R that the pro jection is

L

injective However for a predicate like n Nm m Nn m m stating that n is comp osite this is not p ossible

Chapter Pro of irrelevance and subset types

in principle require evaluation of the pro of part of the argument x Hence one

cannot honestly claim that f is a veried program it is at most a computation

which b ears some extensional resemblance to an intended algorithm

The situation is not quite as serious as it might app ear since one can show that

computations of type N and other basic inductive types cannot really dep end

on pro ofs

Prop osition Let P Prop be a proposition in the empty context and

p Prf P M N be a term of type N containing a variable of type Prf P

n

Then M is denitional ly equal to a numeral ie p Prf P M Suc for

some n

Pro of We give the pro of for the Calculus of Constructions with natural num

b ers but without types ie the only type formers are N Prop Prf The

extension with types and other inductive types is similar We reason by induc

tion on the length of the normal form of M If M or M SucM the result

N

M M N then by induction follows directly or from the IH If M R

z s

xNN

N is a numeral thus M was not in normal form for it admits a reduction using

NatCompZero or NatCompSuc Now assume that the normal form of M

is of the form M M M where M is not an application If M is a variable

n

then by assumption it would have to b e p Prf P But then for M to typecheck

we would have to have

Prf P x x N

n n

for suitable types But this is p ossible only if N Prf N for some

n

N Prop which is not the case

On the other hand if

N

M R M M N

z s

xNx x N

n n

then again by induction we can assume that N is a numeral whereby M was not

in normal form This exhausts all p ossible cases for a normal form of M 2

Chapter Pro of irrelevance and subset types

We observe that the pro of dep ended up on the fact that N is not a prop osition

and that M do es not contain any free variables other than than p Prf P In

deed it is not necessarily the case that an open term of type N containing p is

denitionally equal to a term not containing p For example

M p Prf P x N

N

R f Prf P y Nf Prf P Nf x p

y NPrf P N

is in normal form Now clearly every instance M p N for some numeral N converts

to but M itself do es not convert to The reason is that the application to p

cannot b e moved inside the recursion op erator

N

Of course using induction R we nd p Prf P x N Id M p x true

N

The deliverables approach

In and another approach to program development is advocated under

which a specication is a type together with a predicate P Prop and a

function b etween two sp ecications P and P is a function f

together with a pro of f a P a P f a Such a pair f f is called

a deliverable for it corresp onds to a program together with its verication Thus

a deliverable contains an actual algorithm f which do es not dep end on pro of

comp onents by forgetting the second comp onent of a deliverable one gets rid of

all computationally irrelevant information In various examples of program

development in this framework have successfully b een carried out

What we consider a serious disadvantage of the deliverables approach is that

the user has to do a lot of b o okkeeping He or she has to keep track of which

pro of corresp onds to which program probably by means of a suitable choice of

identiers Also a lot of work has to b e done twice For example if two deliver

ables are comp osed one has to comp ose the function and pro of parts separately

This problem was realised in lo ccit to o and as a remedy it is shown there that

Chapter Pro of irrelevance and subset types

sp ecications and deliverables form a semicartesian closed category whereby one

may use categorical combinators like comp osition abstraction and application to

obtain new deliverables from already constructed ones

Our aim in this chapter is to extend this result substantially by showing how

deliverables can b e organised into a fullblown mo del of the Calculus of Con

structions where sp ecications interpret types and deliverables interpret terms

Moreover we shall see that in this mo del the underlying type of the sp ecication

interpreting a type x P x for some Prop valued predicate P is the same

as the underlying type of the sp ecication interpreting Thus type renement

using types over Prop valued predicates only changes the predicate comp onent

but leaves the underlying type unchanged This means that we can basically use

the renement approach as an internal language for deliverables thereby unifying

the advantages of the two approaches describ ed ab ove Furthermore we shall see

that in the deliverables mo del the following type is inhabited

L

p q Prf P p q

for any prop osition P Prop Thus in the mo del the pro jection from a rened

type to its underlying algorithmic type is provably injective

The deliverables mo del

In this section we construct a syntactic category with attributes whose contexts

and families are mo dulo some syntactic clutter pairs of types and Propvalued

predicates whereas morphisms and thus terms are pairs consisting of an ordinary

term of the underlying type and a pro of that the predicates are resp ected In this

mo del we shall identify a family Prop which has as underlying type the type Prop

and the trivial predicate x Prop tt recall that tt stands for the true prop osition

P PropPrf P Prf P If P Prop and P is some pro of that this trivial pre

dicate is satised for P ie P Prf tt then we dene a sp ecication Prf P P

with underlying type extensional unit type and predicate x P We shall

E E

Chapter Pro of irrelevance and subset types

see that with this choice we obtain a lo ose mo del of the Calculus of Construc

tions which meets the requirements set out in the previous section Let us now

describ e the mo del in detail We use the generic notations C Fam etc to denote

the entities in the deliverables mo del

Contexts

Let b e a syntactic context A propositional telescope over is a telescop e

wrt ie such that all the types in are of the form Prf M for some

term M In particular the empty telescop e is prop ositional

A context of specications is a pair such that is a valid syntactic

context and is a prop ositional telescop e over For example the pair forms

a context of sp ecications which is denoted Another example is x N y N p

L L

Prf x y q Prf x y

If and are contexts of sp ecications then a morphism a deliver

able from the former to the latter is a pair f g where f is a syntactic context

morphism from to ie f and g is an element of the telescop e

f over ie

g f

For example the pair forms the rst comp onent of a morphism from the

empty context of sp ecications to the example with natural numbers considered

ab ove The second comp onent would contain two instances of reexivity

It is obvious that the morphisms of contexts of sp ecications contain identities

and are closed under comp onentwise comp osition so that they form a category

It is also clear that this category C has a terminal ob ject viz

Notation If C is a context of sp ecications we denote by its underlying

set

type and by its second comp onent the prop ositional telescop e over If

pred set

f is a morphism of contexts of sp ecications we denote by f its rst

fun

comp onent the syntactic context morphism from to we denote by f

set set resp

the second comp onent the element f f

set pred resp pred fun

Chapter Pro of irrelevance and subset types

Equality of contexts of sp ecications and their morphisms is comp onentwise

denitional equality

Families of sp ecications

Let b e a context of sp ecications A family of specications over is a pair

where

set pred

set set

and

x Prop

set set pred

for instance if N and n N Evenn then m N and

set pred set set

L

m n N m n is a family of sp ecications

pred set

The set of these families is denoted Fam Equality of families of sp ecica

tions is again p ointwise denitional equality If Fam then we dene the

comprehension by

x

set set set

x p Prf x

pred set set resp pred

The pro jection p is given by

p x

fun set set

p x p q Prf x p

resp set set pred pred

If f B and Fam we dene the substitution of f in by

ff g B f

set set set fun

ff g B x f f x

pred set set fun pred fun

We also dene the morphism qf by

qf B x f f x

fun set set fun

qf B x f p B q Prf f x f p q

resp set set fun pred pred fun resp

Chapter Pro of irrelevance and subset types

So the rst comp onents of all the denitions made follow exactly the term mo del

Ex whereas in the second comp onent we carry through the pro ofs that

the predicates are resp ected

Sections of sp ecications deliverables

Let Fam A section of is a pair M M where

fun resp

M

set fun set

p M p Prf M

set pred resp pred fun

A section M gives rise to a context morphism M from to by decreeing

M M

fun set fun

M p p M p

resp set pred resp

As in the term mo del comp osition with the pro jection p yields the identity

If f M p Q is a morphism of contexts of sp ecications then

from the denition of such morphisms we obtain that

f p M f

set set

r Q Prf f M

set pred pred

and thus Hdf M p Q M Q is a section of ff pg By straightfor

ward equality reasoning we now obtain

Prop osition Contexts of specications together with families of specica

tions and their sections form a syntactic category with attributes

We call this mo del the deliverables model or D for short Proving prop erties ab out

syntactic mo dels like the ab ove prop osition is often elementary but requires some

b o okkeeping eort due to the relatively complex syntax It is therefore ideally

suited for machinesupported reasoning In the following we describ e how the

Lego system can b e used for mechanised pro of of such prop erties

Chapter Pro of irrelevance and subset types

Mo del checking with Lego

Our denition of syntactic categories with attributes contains no conditional equa

tions This makes it particularly easy to verify the correctness of an instance of

this denition by means of an implementation of type theory eg Lego The

idea is to co de the structure using higher universes as a metalanguage One prob

lem is that Lego or any other implementation of type theory do es not supp ort

contexts and telescop es which means that we have to enco de these using types

These enco dings however are slightly weaker than actual telescop es for they do

not have surjective pairing up to conversion Therefore in order to check certain

equations we have to p erform certain expansions ie replace x by x x

Since surjective pairing holds on the level of contexts any equation which holds

in Lego mo dulo such expansions do es hold in the actual mo del Also in Lego we

enco de metalevel pairs like the ones o ccurring in the denition of contexts of sp e

cications as internal types Again expansions may b ecome necessary These

issues will b ecome clear by way of example In order to reduce redundancy we

adopt a record notation for Lego which unfortunately is not yet implemented

For the syntax and the of Lego we refer the reader to

Records in Lego

The declaration

R l S l S

n n

expands to the following sequence of declarations

R l S l S l S S type

n n n

In the meantime this situation has changed and records alb eit with a dierent

syntax are available in Lego

Chapter Pro of irrelevance and subset types

rR l r S st pro jection

l r S

l r

n

z

n times

l r nth pro jection

n

z

n times

Discharge r

MkRl S l S l l R tupling

n n n

So if rR we can access its comp onents by applying the dened pro jection

functions eg l r is the second comp onent Using Legos p ostx notation

for function application this expression may also b e written as rl which is more

suggestive of the intended record semantics The function MkR allows one to collect

n items of the appropriate types to form an ob ject of type R The rule for the

type Comp gives the equations

MkR x x l x

n i i

We now come to the actual implementation of the deliverables mo del in Lego

Deliverables in Lego

The contexts of sp ecications are dened as elements of the following record type

CON setType predsetProp

So in Lego a context of sp ecications is just a type and a Propvalued predicate on

it As we see b elow we then use the internal type instead of context extension

for comprehension The morphisms are dened analogously

MORGDCON funGsetDset

respfgGsetgGpred gDpred fun g

The empty context must b e dened using a unit type and a true prop osition ie we have

Chapter Pro of irrelevance and subset types

Emp MkCON unit xunittt

where unitType is an inductive type with sole constructor starunit and tt

is the prop osition XPropXX the higherorder enco ding of truth We have

a not necessarily unique morphism into Emp from any other context

bangGCON MkMOR G Emp Gsetstar

Gpred gXPropxXx gGset

Thus in order to prove that the category of contexts of sp ecications has a terminal

ob ject the Lego enco ding is of no use we must lo ok at its denition in terms of

contexts and telescop es We can however prove in Lego that morphisms admit

an asso ciative comp osition and identities

IdGCON MkMOR gGsetg gGsetpGpred gp

CompGDTCONfMOR D TgMOR G D

MkMOR xGsetffungfun x

xGsetpGpred xfresp gresp p

Goal fGDTXCONgffMOR G DgfgMOR D TgfhMOR T Xg

Q Comp Comp h g f Comp h Comp g f

Intros G D T X f g h

Refine Q refl

QED

We have formulated asso ciativity in terms of prop ositional equality Q However

since we were able to prove it using reexivity alone we know that the two terms in

question have identical normal forms and thus are denitionally equal as required

Alternatively we can use Lego to calculate these normal forms and compare them

by hand but the use of prop ositional equality app ears more economical We see

that Lego is used here only as a pro of assistant The full pro of that deliverables

form a syntactic category with attributes is done by hand

The remaining denitions are as follows

Chapter Pro of irrelevance and subset types

FAMGCON setGsetType predfgGsetgset gProp

SECTGCONSFAM G

funfgGsetgSset g

respfgGsetgGpred g Spred fun g

For simplicity we use the same name for the rst comp onents of contexts and of

families In the actual Lego implementation we have to choose a dierent name

each time

Context comprehension is dened using types and conjunction

DotGCONSFAM G

MkCON gGsetSset g

xgGsetSset gGpred x Spred x

pGCONSFAM G MkMOR Dot G S G

xDot G Ssetx

xDot G SsetpDot G Spred xfst p

SubstGDCONSFAM DfMOR G D

MkFAM G gGsetSset

ffun g

gGsetsSset ffun gSpred s

qGDCONfMOR G DSFAM D

MkMOR Dot G Subst S f Dot D S

xDot G Subst S fsetffun xx

xDot G Subst S fset

pDot G Subst fpred x

pair fresp fst p snd p

We use conjunction in Lego to concatenate parts of a prop ositional telescop e

Now we can use Lego to check for example coherence of substitution where in the

case of the identity law we must make an expansion

Goal fGCONgfSFAM GgQ Subst S Id G MkFAM Sset Spred

Intros G SRefine Q refl

QED

Chapter Pro of irrelevance and subset types

Goal fBGDCONgffMOR B GgfgMOR G DgfSFAM Dg

Q Subst S Comp g f Subst Subst S g f

introsRefine Q refl

QED

Since the expansion we made is an identity in the true deliverables mo del we

can conclude that the equations we are able to prove in Lego do indeed hold in

the actual mo del But for example due to the deciencies of the unit type as a

surrogate for the empty context we cannot exp ect completeness

Type formers in the mo del D

We have now set out the structure of the mo del it remains to dene various type

constructors In fact it seems that the deliverables mo del can b e endowed with

whatever features the original type theory has we shall however limit ourselves to

and types the natural numbers a universe and of course the pro ofirrelevant

type of prop ositions

Dep endent pro ducts

Let b e a context of sp ecications and Fam and Fam Their

dep endent pro duct Fam is dened by

s s

set set set set

f s s s f s

pred set set set pred pred

So the setcomp onent of the dep endent pro duct is just the syntactic pro duct over

the setcomp onents of and and the asso ciated predicate expresses that a

function in this type sends arguments meeting to values meeting

pred pred

The asso ciated combinators are almost forced If M Sect then M

Sect is dened by

M s M s

fun set set fun

Chapter Pro of irrelevance and subset types

M p s q Prf sM s p q

resp set pred set pred resp

Similarly we dene application for M Sect and N Sect

App M N M N

fun set fun fun

App M N p M p N N p

resp set pred resp fun resp

Prop osition The above assignments determine dependent products in the

deliverables model

Pro of All the equations follow by simply rewriting the denitions For compat

ibility with substitution one uses the fact that syntactic substitution commutes

by denition with all type and term formers The equations can also b e checked

automatically using Lego 2

Dep endent sums

Let b e a context of sp ecications and Fam and Fam Their

dep endent sum Fam is dened by

s s

set set set set

f

pred set set

R

f x Prop

set set set set

x y x x x y f

set set pred pred

That is holds for a canonical element x y if holds for x and

pred pred

holds for y and it is extended to arbitrary elements of using the

pred set

elimination op erator R Alternatively one could dene using a

pred

higherorder enco ding or the dened pro jections

Next we dene the pairing morphism pair Its rst

comp onent is dened by

pair s t hs ti fun

Chapter Pro of irrelevance and subset types

The second comp onent is a bit more dicult We start from the context

s t p Prf q Prf s r Prf s t

set set set pred pred pred

In this context we must nd an element M of S Prf hs ti We

pred

then put

pair s t p q r p M

For the construction of M we observe that by virtue of the computation rule

Comp S equals Prf s s t We thus put M Intros t where

pred pred

Intro is the pairing combinator asso ciated to

For elimination assume Fam and M Sectfpairg We

must construct a section R M of The rst comp onent is just as in the term

mo del

M x R M x R

fun fun set set

set set set

For the second comp onent we use elimination as well We must nd an inhab

itant of the type

Prf R M x

pred fun

set set set

in the context

x p q Prf x

set set pred pred

Using cut this may b e reduced to nding an inhabitant of

x Prf x R M x

pred pred fun

set set set

in context x p Using R we can reduce this task to nd

set set pred

ing an inhabitant of hs ti in context x p s t

set set pred set

s But using Comp hs ti is equal to

set

Prf s t M s t

pred pred pred fun

This latter type is inhabited by K h Prf s tM s t fsth

pred pred resp

sndh where fst and snd are the pro jections asso ciated with So putting things

together we get

K x p R M x p q R

resp

set set

Prop osition The above data endow D with types

Chapter Pro of irrelevance and subset types

Pro of The pairing morphism satises

p p p pair

since the comp onents are simply copied in b oth parts of pair Stability of all

comp onents under substitutions follows again directly from the split prop erty of

syntactic substitution It remains to check equation Comp In the comp on

fun

ent it is identical to its syntactic companion for the comp onent we calculate

resp

as follows If s t p q Prf s r Prf t then

set set set pred pred pred

R M fpair g s t p q r

resp

K Introq r by Comp

M s t fstIntroq r sndIntroq r by Beta

resp

M s t q r

resp

2

Using this technique we can show that the deliverables mo del admits other in

ductive type constructors We content ourselves by describing natural numbers in

D

Natural numbers

If C we dene N N and N n tt The morphisms

set pred

and Suc are readily constructed from their syntactic companions We have

and Suc n Sucn The comp onents are constants

fun fun resp

returning the canonical pro of of tt For Nelimination let Fam N and

g and M Sect fSuc p g We must construct a sec M Sect f

s z

N

tion R M M of The comp onent is again the same as in the term

z s fun

N N

mo del R M M n R M M n For the part we

z s fun z fun s fun resp

must show that holds for this term By analogy to the case of types

pred

N

we use R This time there is no need for strengthening the inductive hypothesis

since the predicate on N is trivial

Chapter Pro of irrelevance and subset types

Prop osition Ncanonicity If M SectN then M is canonical ie

n

M Suc for some settheoretic natural number n

n

Pro of We have M N so by Remark we have M Suc N

fun fun

for some n Moreover we have M Prf tt but by strong normalisation

resp

for the Calculus of Constructions there is only one element of Prf tt in the empty

n

context so M Suc as required 2

The type of prop ositions

Now we come to the main feature of the deliverables mo del the pro ofirrelevant

type of prop ositions We show that the mo del is a lo ose mo del of the Calculus

of Constructions in the sense of Def For the moment we assume that the

underlying type theory supp orts an extensional unit type ob eying the rules

UnitForm UnitIntro

E E

M

E

UnitEq

M

E

We shall see b elow how this assumption can b e eliminated

Now we dene the family Prop Fam by

Prop Prop

set

Prop P Prop tt

pred

The generic family of pro of types Prf Fam Prop is dened by

Prf P Prop

set E

Prf P Prop x P

pred E

So the pro of type asso ciated to a prop osition P is always the unit type but the

predicate asso ciated to P is P itself

Chapter Pro of irrelevance and subset types

Therefore a section of Prop is already determined by its comp onent a

fun

section of Prf fsg is already determined by its comp onent

resp

We come to the denition of universal quantication Let Fam and

s Prop Recall that Prop here denotes Prop We dene the

morphism s Prop by

s x x s x

fun set set pred

For the part we take some constant function returning a pro of of tt

resp

If M SectPrf fsg ie

x M

set set fun E

x p q Prf x M p q Prf s x

set set pred pred resp

then we dene M SectPrf f sg by

s

M

s fun set E

M p x q xM p q

s resp set pred set pred resp

Prf x x s x

set pred

The evaluation morphism ev Prf f s p g Prf fsg is dened

s

by

ev x p

s fun

ev

s resp

x f

set set E

p r Prf x q Prf y y s y

pred pred set pred

p q x r

Prop osition The above data endow D with the structure of a loose model

for the Calculus of Constructions

Pro of For the equation let M SectPrf fsg We want to show that

ev M fp g M

s s

The part is an equation of type and therefore holds by UnitEq The

fun E

part follows immediately from the denitions and Beta and PropEq

resp

The other laws including the substitutivity laws are also immediate consequences

of the denitions 2

Chapter Pro of irrelevance and subset types

We can now establish logical consistency of the deliverables mo del in the sense

that there exists a morphism ff Prop such that Prf fff g has no sections

Prop osition Consistency The family Prf fff g with

ff id Prop

Prop Prop

has no sections

Pro of We have Prf fff g and Prf fff g x p Prop tt p A section

set E pred

of Prf fff g thus consists of an element of necessarily and a term of type

E

Prf p Proptt p

but no such term exists by consistency of the syntax 2

Eliminating extensional unit types

One may ob ject against the use of extensional unit types as they are not part

of the original syntax and b ecause their b ehaviour in terms of rewriting and in

particular normalisation is dubious For instance they lead to nonconuence in

the presence of reductions for functions and require a typed notion of reduction

for otherwise every term could b e reduced to Although we b elieve that their

addition do es not cause any substantial problems and indeed this has b een done

in the formulation of the Calculus of Constructions used in we prefer to show

two ways in which their use can b e eliminated

First we observe that the only use of the extensional unit type was to ascrib e a

comp onent to the families of the form Prf fsg So a p ossible solution consists

set

of not giving these families a comp onent at all We then have to rene the

set

notion of families so as to allow for that More precisely we dene

Fam Fam Fam

type prop

Chapter Pro of irrelevance and subset types

where Fam is the set of families of sp ecications over as dened in

type

Sect and Fam is dened as the set of prop ositions in context

prop set

ie the set of terms P with P Prop These are called prop ositional fam

set

ilies over Now we must show that even with this extended notion of families

we still have a syntactic category with attributes supp orting all the structure we

are interested in The pro of of this is absolutely straightforward and tedious An

element of Fam b ehaves like an ordinary family of sp ecications having the

prop

extensional unit type as comp onent All reference to it is omitted So for

set

example if P Fam ie P Prop then the comprehension P is

prop set

dened by P and P q Prf P Also if is a

set set pred pred

prop ositional family over then the pro duct is a prop ositional family

over

A more systematic way of eliminating extensional unit types consists of exhib

iting an interpretation of type theory with them in type theory without them This

can b e done by constructing a syntactic category with attributes whose base cat

egory is the same as that of the term mo delthe category of contexts and context

morphismsand where a family over is either a type in context or a formal

constant The relevant op erations may then b e extended to this constant in

E

the obvious way for instance we dene and p id

E E

Pro of irrelevance

In the deliverables mo del any two pro ofs of a prop osition are indistinguishable

b ecause pro of types have as comp onent and observations only take the

E set

comp onent into account To make this statement precise we rst need to

set

dene a semantic analogue to Leibniz equality

Denition Fix a loose model of the Calculus of Constructions and let

EqM N Fam and M N Sect Leibniz equality of M and N written L

is the proposition over dened by

PN Prop

Prop

PMg Prf f

Chapter Pro of irrelevance and subset types

where we have used the fol lowing abbreviations

Prop Propf g Fam

v M SectProp f g PM App

Prop Prop

Prop

v N SectProp f g PN App

Prop Prop

Prop

Syntactically the thus dened Leibniz equality corresp onds to the usual

P PropP M P N Prop

To b e precise this gets interpreted as HdL EqM N By mimicking the

EqM M g usual syntactic manipulations in the semantics we can show that Prf fL

is always inhabited and that if Prf fL EqM N g is inhabited then whenever

Prf fApp P M g is inhabited for some P Sect Prop then so is

Prop

App P N g Prf f

Prop

Let us now examine what Leibniz equality means in the deliverables mo del If

Fam and M N Sect in this mo del then we have

L EqM N P PropP M P N

fun set fun fun

EqM N is some uninteresting pro of of ttthe comp onent whereas L

resp pred

of Prop So L EqM N simply states actual Leibniz equality of the

fun

comp onents of M and N Given the denition of Prf in the mo del we see

that SectPrf fL EqM N g is nonempty i M and N are Leibniz equal

fun fun

in context We thus obtain the following prop osition expressing pro of

set pred

irrelevance in the deliverables mo del

Prop osition Let C be a context of specications and A Prop

L EqM N g is nonempty and M N SectPrf fAg Then the set SectPrf f

Pro of Since the comp onent of the family Prf fAg is b oth M and

set E fun

N must equal So by the ab ove considerations the section Pr Ir with Pr Ir

fun fun

Ir p P Propx Prf P x denes the de and Pr

resp set pred E

sired section 2

Chapter Pro of irrelevance and subset types

However we do not have M N b ecause the second comp onents which are not

observed by prop ositional equality may dier We can also obtain a mo del if we

identify morphisms and sections with equal rst comp onent In the more general

setting of partial equivalence relations instead of predicates this will b e done in the

next chapter Here we prefer not to identify prop ositionally equal terms b ecause

this would thwart the application to mo dules describ ed in Sect b elow

There is no fundamental reason for this choice though

Corollary The deliverables model permits the interpretation of a type the

ory extending the Calculus of Constructions by the rule

A Prop M N Prf A

PrIr

L

Pr IrA M N Prf M N

Pro of We interpret Pr Ir by the section dened in the pro of ab ove It remains

to show that the choice of this section is stable under substitution but this follows

immediately from its uniform syntactic denition 2

Universes

If the underlying type theory has universes so has the deliverables mo del In

particular since the underlying type theory has an impredicative universe Prop

we can dene such a universe in D which astonishingly is dierent from Prop

We therefore call it Set and write El instead of Prf We dene

Set X Prop X Prop

set

Set x Set tt

pred set

El X Set X

set set

El X Set x X X x

pred set

It is now p ossible to dene a op erator for this universe Moreover the universe

Set will b e closed under the subset types dened b elow Since we do not make

Chapter Pro of irrelevance and subset types

further use of Set we do not give the details here Notice that since the

set

comp onent of an Eltype is not pro ofirrelevance do es not hold for Set In

E

this sense D allows us to use the impredicative universe Prop b oth for pro of

irrelevant logic and for impredicative quantication One may compare this to the

two impredicative universes Spec and Prop in PaulinMohrings thesis work

Subset types

Given PrIr we can enco de subset comprehension using types more precisely

if and P Prop then the type x Prf P x can b e seen as

the subset of containing those elements for which P holds The rst pro jection

x Prf P x where u x Prf P xu is now provably

injective in the sense that the prop osition

L L

u v x Prf P x u v u v

is provable using elimination R and PrIr Let us now lo ok at how this

particular type gets interpreted in the deliverables mo del If Fam and

P Prop then we have

Prf fP g x

set set set E

Prf fP g u Prf fP g

pred set set

x y x P x u R

set E pred

That is the comp onent of the type is almost the comp onent of and

set set

the comp onent is the conjunction of and P It makes sense to replace

pred pred

is almost by is and to dene the following subset type former inside D

Denition Let Fam and P Prop The subset type

f j P g Fam is dened by

f j P g

set set set

f j P g x x P x

pred set set pred fun

Chapter Pro of irrelevance and subset types

Now if M Sect and H Prf fP M g then we dene a section M of f j P g

H

by

M M

H fun fun

M pairM P

H resp resp resp

where here pair is the dened introduction op erator corresp onding to Con

versely if M Sectf j P g then we have a section witM of witness given

by witM M and witM fst M Every section of the form

fun fun resp resp

witM satises P in the sense that there is a section corM of Prf fP M g

correctness given by corM and corM sndM where fst

fun resp resp

and snd are the pro jections corresp onding to

Prop osition The deliverables model permits the interpretation of a type

theory extending the Calculus of Constructions by a subset type governed by the

fol lowing rules

x P Prop

fgForm

fx j P g

M H Prf P M

fgIntro

M fx j P g

H

M fx j P g

fgWit

witM

M fx j P g

fgCor

corM Prf P witM

fgBeta

witM M corM H Prf P M

H H

Pro of The subset type and its asso ciated combinators are interpreted by the

semantic op erations dened ab ove fgBeta and stability under substitution are

immediate from the denition 2

The ab ove prop osition could also b e proved in a purely syntactical way by

interpreting fx j P g as x Prf P The p oint is that the more economical

enco ding ab ove also interprets them

Chapter Pro of irrelevance and subset types

An extended example for the use of subset types will b e given in Sect

Subset types without impredicativity

The ab ove development of subset types and pro of irrelevance do es not hinge on

impredicative prop ositions one could carry out the same development in the core

type theory TT and would then obtain a mo del for a type theory with two dierent

sorts types and prop ositions So instead of we would have to write

type and we would also have a judgement prop These prop ositions

would supp ort the same type formers as the types and moreover we would have

an inclusion rule

prop

type

Semantically the prop ositions would b e interpreted as families with extensional

unit type in the comp onent In the absence of Leibniz equality we would

set

then dene a prop ositional equality using the identity type from the syntax The

prop ositions then would b e at most singlevalued wrt this equality The resulting

mo del is then quite close to the subset interpretation of MartinLof type theory

A nonstandard rule for subset types

In Section we sketched a renement of the deliverables mo del in which fam

ilies could have no comp onent which then was meant to b e We will now

set E

consider a renement under which there are families without comp onent

pred

which is understo o d to b e tt This will allow us to derive a nonstandard rule

for subset types in Prop b elow which shows that every function on a subset

type is in fact dened on the whole of the underlying comp onent So we dene

set

a new mo del with

Fam Fam Fam

type nprop

where Fam is the set of families of sp ecications as dened b efore whereas

type

Fam is the set of syntactic types in context The elements of this set

nprop set

Chapter Pro of irrelevance and subset types

are called nonpropositional families of specications over If Fam

nprop

then we dene as x and Substitution in non

set set pred pred

prop ositional families is simply syntactic substitution A section of is a term

M The corresp onding morphism M is given by M M and

set fun

M p p which makes sense since the comprehension of do es not add

resp

anything to the comp onent We call the resulting structure the deliverables

pred

model with nonpropositional families

Prop osition The deliverables model with nonpropositional families is a

loose model of the Calculus of Constructions and supports natural numbers and

types Moreover Prop and N are nonpropositional and is nonpropo

sitional i is and is nonpropositional i both and are

Pro of The mo del equations for nonprop ositional families are readily checked

by straightforward expansion of the denitions N and Prop are dened as their

syntactic companions viewed as nonprop ositional families If Fam

nprop

then Fam is dened as x x If

nprop set set set

Fam and Fam we dene the dep endent pro duct by

nprop

x x

set set set set

f x x f x

pred set set set pred

The dep endent sum of two nonprop ositional families is dened as in the syntax

the dep endent sum of an ordinary family and a nonprop ositional one is dened

as in Sect where all to the nonexisting part of the non

pred

prop ositional family are dropp ed The other comp onents and the verications are

straightforward 2

Next we dene a syntactical counterpart to nonprop ositional families which

will serve to dene the desired rule for subset types

Chapter Pro of irrelevance and subset types

Denition Consider the Calculus of Constructions with natural numbers

types and subset types The set of nonprop ositional pretypes is dened by the

fol lowing clauses

N and Prop are nonpropositional

If and are nonpropositional then so are and for any

pretype

We write Nprop if and is a nonpropositional pretype In this

situation is called a nonpropositional type

Prop osition The notion of nonpropositional types is stable under equality

and substitution more precisely if and Nprop then also

Nprop and B f Nprop for every syntactic substitution B f

Pro of The only type equality rule which is not a congruence rule is PropEq

Therefore if then either b oth and have the same outermost type

former or b oth types contain an instance of Prf in which case Nprop do es

not hold We then use induction The same argument applies to substitution

2

Prop osition The fol lowing rules can be interpreted in the deliverables model

with nonpropositional families

x x Nprop

x P x Prop

p fx j P xg M p witp

N

fgElimNonprop

extend M N M

P

H Prf P M

fgElimNonpropComp

extend M N M N N

P H

Chapter Pro of irrelevance and subset types

Pro of By induction along the denition of the interpretation function we show

that if Nprop then j Fam It remains to interpret the two

nprop

rules on the semantic level Thus let Fam Fam and P

nprop

Prop Let w f j P g b e the morphism qpf j P g witv

f j P g

We have w s s and w p q p fstq Now let M Sect fw g

fun resp

M g We and N Sect We must construct a section extend M N of f

P

dene it by

extend M N M N

P set fun fun

Notice that no comp onent is required b ecause is nonprop ositional The

resp

equation fgElimNonpropComp now holds by denition 2

The nonstandard rule allows one to extend a function p fx j P xg M p

witp dened on a subset type to the whole of hence the name of the op erator

symbol

In the ordinary deliverables mo del we could still interpret fgElimNonprop

by showing that nonprop ositional types get interpreted as families with a

pred

comp onent which is universally valid equivalent to tt One would then use this

pro of to interpret the comp onent of extend But rst some care would have

resp

to b e taken in order to retain stability under substitution and second the equation

fgElimNonpropComp would only hold up to Leibniz equality b ecause the

comp onents of the two sections might disagree

resp

The computation rule fgElimNonpropComp is suspicious from a rewrit

ing p oint of view for if we direct it from left to right we would have to guess

a pro of H Prf P M If on the other hand we choose to direct it from right

to left there is no way of eliminating instances of extend Such rules do however

make sense as a clarication of the semantically determined denitional equality

induced by a syntactic mo del here D discussed in the Introduction Below in

Sect we make that more precise

Chapter Pro of irrelevance and subset types

Internal program extraction

The rule fgElimNonprop may b e used to p erform an internal version of pro

gram extraction For example if we have dened a function f Even Even

L

where Even is fx N j m Nn mg then we obtain a function f from N to N

by

f n Nextendx Evenwitf x n

which is valid since N is nonprop ositional Now using fgElimNonpropComp

we obtain

x Even f witx witf x N

which states that f is the underlying algorithm of f

In a similar vein the nonstandard rule for subset types admits the following

generalisation of Prop ab ove

Prop osition Consider a type theory with subset types and the extend

operator Let P Prop and p Prf P M for some nonpropositional

type eg N Then there exists a term N with p Prf P M N

Pro of Consider the type fn N j P g where n do es not o ccur in P We have

x fn N j P g M p corx

Therefore by fgElimNonprop

extend x fn N j P gM p corx

P

Let N b e this term By rule fgElimNonpropComp we get

p Prf P M N

as required 2

Chapter Pro of irrelevance and subset types

We remark that the nonprop ositional families and the families of the form Prf fsg

are independent in the sense of In our terminology this means that for

s Prop the nonprop ositional families over are in corresp ondence

to the nonprop ositional families over Prf fsg and that for nonprop ositional

Fam the weakening map

nprop

fpPrf fsgg Sect Sect fpPrf fsgg

is a bijection The nonstandard op erator extend can b e seen as an internalisa

tion or a syntactic version of Moggis concept of indep endence From equation

fgElimNonpropComp we can only deduce that the ab ove mapping is surject

ive To deduce bijectivity in a purely syntactic way we could introduce an like

equation extendu fx j P gM witu N M N if x M x This is

a case in p oint for the type theory with semantically dened denitional equality

describ ed in Sect

In the settheoretic mo del Ex where subset types can b e interpreted

as ordinary subsets one can interpret extend as extend M N M N if

P

P N holds and c otherwise where c is a default element dened by

induction on the denition of nonprop ositional However this understanding

is not constructive whereas the interpretation in D is

Application to mo dules

We can also use subset types and the deliverables mo del for mo dules and higher

order functors where it is imp ortant that the typing comp onent of a functor do es

not dep end up on its implementation comp onent Although the account of mo dules

we end up with is essentially the same as the one given by Moggi and others in

we found it interesting to exhibit the relationship with subset types and

deliverables and to rephrase their constructions in terms of syntactic mo dels

For what follows we need a type theory in which Prop the name Set would b e

more appropriate contains the natural numbers and other datatypes of interest

This means that there is a constant N Prop with Prf N N In the

Chapter Pro of irrelevance and subset types

deliverables mo del we can then also dene such a constant by putting N N

fun

and N returns a pro of of tt Now in the mo del Prf N is not N b ecause any

resp

family of the form Prf fsg has part but we can interpret the following

set E

rules where we abbreviate Prf fNg by N

M N

NIntro NIntroSuc

N SucM N

x N S Prop

M Prf S x

z

x N p Prf S M Prf S x Sucx

s

N N

NElim

N

R M M N Prf S x N

z s

S

Now we may view Prop as the universe of datatypes and types like Prop Prop

as kinds We may then use the subset type to give signatures For example a

signature for sets with a binary op eration would b e

BIN fX Prop j X X X g

The signature for monads as used in functional programming would b e

MON fT Prop Prop j

X Prop X T X

X Y Prop X T Y T X T Y g

If S BIN then witS Prop and corS Prf S Prf S Prf S so

an element of type BIN consists of a datatype and a binary op eration on it For

example we have N BIN We may therefore call elements of a signature

xy xy

structures matching the signature If S is a structure then we call witS its

type component and corS its implementation comp onent

Recall that for X Y Prop we have Prf X Y Prf X Prf Y and that

Prf X Y together with pair fst and snd is a binary pro duct without surjective pairing

Chapter Pro of irrelevance and subset types

Now we still have that any two pro ofs elements of a prop osition data

type are Leibnizequal for example the type

Prf P Prf N PropPrf P Prf P Suc

is inhabited in the mo del by PrIr But the reason for this is that in the mo del

a datatype a prop osition can never dep end up on values of a datatype and so

every P the quantication ranges over must b e constant Thus by working in D it

is p ossible to typecheck signatures at compile time without p erforming any compu

tations on datatypes Using the deliverables mo del with nonprop ositional families

this can b e internalised in the following sense If F BIN BIN is a functor

mapping structures matching BIN to themselves then just as in Sect we

can dene f Prop Prop where f X is the type comp onent of f applied to

a structure matching BIN with type comp onent X

It should b e p ointed out that now that we have used up the two comp onents

of a sp ecication for types and implementation resp ectively there is no p ossibility

of including logical information anymore This could b e done in a similar mo del

where a family has three comp onents type implementation and pro of This

might form the basis of a typetheoretic semantics for a mo dular sp ecication

languages like Extended ML in which programs and sp ecications can co exist

The internal language of such a mo del ie the type theory interpretable by it

should resemble one of the higherorder type theories considered in

Reinterpretation of the equality judgement

We have now describ ed a syntactic mo del of type theory in which subset types and

pro ofirrelevance can b e interpreted We have argued that type theory extended

with these additional constructs can b e understo o d as a macro language for work

ing under the deliverables approach describ ed in Sect ab ove Up on application

of the semantic interpretation function to derivations in the extended type the

ory one obtains a corresp onding derivation under the deliverables approach as

explained by the semantic interpretation of the various type and term formers

Chapter Pro of irrelevance and subset types

Rather than actually computing the deliverables interpretation of some derivation

one may also lo ok at the new equality judgements induced by this interpretation

We therefore prop ose a new type theory in which all the equality rules are replaced

by rules making reference to semantic equality

Denition Let denote the semantic function associated to D and take

x y X to mean that x y and X are dened and x y are equal elements of

the set X The type theory D is dened by the fol lowing clauses

The preconstructions of D are the same as those of ordinary type theory

extended with Pr Ir and the operators associated to subset types

The typing rules are the same as those of ordinary type theory

There are only the fol lowing three equality rules

j M j N Sect j

EqTerm

M N

j j Fam

EqType

ObC

EqCont

Since the interpretation function is recursive and equality in the deliverables mo del

is decidable by decidability of equality in the Calculus of Constructions we nd

that the new type theory dened ab ove also has decidable typing and equality

judgements In this way we can make sense out of equality rules like fgElim

NonpropComp which now app ear as sp ecial cases of EqTerm

This semantic denition of equality also applies to the two syntactic mo dels

for extensionality and quotient types we study in the next chapter

Chapter Pro of irrelevance and subset types

Related work

A subset type former very similar to ours has also b een introduced by MartinLof

and justied by a very similar mo del constructionthe subset interpretation of

type theory describ ed in The main dierence is that our mo del accounts

for the full Calculus of Construction ie higherorder logic and more subtly that

MartinLof identies morphisms with equal rst comp onents and families with

equal rst and equivalent second comp onents This last identication makes se

mantic equality undecidable A dierence in presentation is that MartinLofs

subset interpretation is not describ ed in terms of categorical semantics In this

simple case this is only a matter of taste however for the more involved setoid

mo dels we lo ok at in the next chapter we found the use of the abstract semantics

unavoidable

Subset types in an extensional context without unicity of typing in the sense of

Prop have b een studied by Salvesen and Smith They consider a subset

introduction rule which allows one to conclude M fx j P xg provided M

and P M true They do not have a rule which gives P M from M fx j P xg

but only allow to conclude C true if x p Prf P x C true and x do es not

o ccur in C They ask the question under what conditions on P this do es allow

P M to b e derived and nd that this is the case for stable formulae ie those

for which P ff ff P true This work do es not really compare to ours

b ecause in an intensional setting the questions answered in lo ccit either make no

sense or have a trivial answer

The idea that types endowed with predicates can b e organised into a mo del

of type theory also app ears in There however only semicartesian closure is

shown thus it follows that deliverables form a mo del of the simply typed lambda

calculus In lo ccit also relativised sp ecications and second order deliverables

are considered A relativised specication relative to a sp ecication and x

P x Prop consists of a type and a relation x y Rx y Prop If

R and R are two relativised sp ecications over P then a second

Chapter Pro of irrelevance and subset types

order deliverable from R to R consists of a function x f x

and a pro of x p Prf P x F Prf y Rx y R x f x y In our mo del

a relativised sp ecication is a sp ecial case of a family in Fam P where

in general may dep end up on A second order deliverable then app ears as

a morphism from p R to p R in the slice category over P It

is easily seen that the relativised sp ecications form a full submo del of D The

setoid mo del S presented in the next chapter has indeed the prop erty that the

type comp onent of families do es not dep end on the context

Many of the ideas underlying the mo del D are also present in the thesis work

of C PaulinMohring She describ es a type theory with two impredicative

universes Spec and Prop which is then interpreted in an amalgamation of pure

Calculus of Constructions and system F It is explained in great detail how

the F comp onent of the interpretation it corresp onds to our and

fun set

comp onents can b e seen as a program extracted from a constructive pro of An

analogy is drawn to the notion of realisability in pro of theory and various exten

sions are prop osed such as an interpretation of wellfounded recursion using a x

p oint combinator on the F level Also a subset type is introduced alb eit without

the nonstandard rule from Sect The main dierences to our construction

are that categorical mo dels are not used and that the comp onents

set fun

in PaulinMohrings mo del do not contain type dep endency very much like our

mo del S to b e introduced in the next chapter

Summing up we can say that the constructions leading to the deliverables

mo del were all known but that some new facets have b een presented such as the

organisation using categorical mo dels and the nonstandard rule for subset types

As was said b efore our main purp ose in presenting the deliverables mo del is to

exemplify the use of categorical mo dels for syntactic translations

Chapter

Extensionality and quotient types

In this chapter we study mo dels for quotient types and the related concepts of

functional and prop ositional extensionality The general metho d is to construct

mo dels in which types are interpreted as types together with partial equivalence

relations Prop ositional equality at some type is then the asso ciated partial equi

valence relation

As we discuss b elow in Sect this idea has b een considered by several authors

with various aims What is new here is that the concept of types with partial

equivalence relations setoids is studied in the context of intensional dep endent

type theory which makes it necessary to dene setoids dep ending on setoids In the

sequel we shall essentially give three dierent answers to this question The rst

and simplest one Sect only provides a restricted notion of type dep endency

b ecause in the mo del dep endency arises only at the level of the relations not at the

level of the types themselves The second one Sect the group oid mo del

supp orts all the type and termformers we know of and should b e considered the

correct answer but unfortunately it is not denable in intensional type theory

However it answers the question of indep endence of the uniqueness of identity

and provides valuable insights into the nature of prop ositional equality The third

one Sect nally is an attempt to overcome the syntactic problems with the

group oid mo del and the limitations of the rst setoid mo del It provides slightly

more type dep endency butas we shall seehas other disadvantages so that the

denitive answer to the question of dep endent setoids remains op en

Chapter Extensionality and quotient types

We encounter two op erations the soundness of which relies on the dierence

b etween extensional prop ositional equality and intensional denitional equality a

choice op erator for quotient types Sect and an axiom identifying prop osi

tional equality on a universe with the type of isomorphisms Sect

The setoid mo del

We consider an extension of the Calculus of Constructions by dep endent sums

natural numbers and p ossibly some datatypes No further universes are required

Our aim is to construct a mo del in which quotient types wrt Leibniz equality

can b e interpreted and in which the extensional concepts of pro of irrelevance

functional extensionality and prop ositional extensionality are available In view

of the analysis in Sect we then also have pro ofirrelevance which we shall

however derive directly The mo del we construct has the remarkable prop erty

that Leibniz equality b ehaves like the identity type in the sense that a substitution

op erator for dep endent types in the sense of Sect may b e dened for it If

one lo oks closer at the mo del this is not so astonishing b ecause the only source for

type dep endency in this mo del is the dep endency of pro of types on prop ositions

wrt which Leibniz equality is substitutive by denition

In the mo del types will b e interpreted as types together with Prop valued

partial equivalence relations Type dep endency is mo delled only at the level of

the relations ie a family indexed over some type is a type not dep ending

on and for each x a partial equivalence relation on compatible with the

relation on By analogy to Bishops denition of sets as assemblies together with

an equality relation we call the pairs of types and partial equivalence relations

setoids

We use the name target type theory to refer to the version of the Calculus

of Constructions the mo del is built up on and source type theory to refer to the

internal language of the mo del which contains all the type and term formers from

the target type theory together with the desired extensional concepts and the

Chapter Extensionality and quotient types

strong Leibniz equality Denitional equality in the source type theory is dened

semantically via interpretation in the mo del according to Sect The mo del

we construct is called the setoid model S Its comp onents are called contexts

families morphisms etc of setoids The source type theory itself will also b e

called S

Large parts of this section have b een published as The extension to

universes Sect and the discussion of choice principles and Churchs thesis

Sect and app ear here for the rst time

Contexts of setoids

A context of setoids is a pair where is a syntactic context

set rel set

ie and is a prop osition in context ie

set rel set set set set

Prop in such a way that

rel

Prf true Sym

set rel rel

Prf Prf true Trans

set rel rel rel

Here we just write Prf in a context instead of p Prf for some

rel rel

variable p since this variable do es not app ear in the conclusion of the judgement

We shall adopt this abbreviation in the sequel as well The axioms Sym and

Trans thus express that is a partial equivalence relation on Two contexts

rel set

of setoids are equal if their comp onents are denitionally equal ie if

set

and Prop The implicit witnesses for Sym

set set rel rel

and Trans are not compared It is imp ortant that the relation is not assumed

reexive for otherwise we could not interpret prop ositions see Sect

Examples The empty context of setoids is given by tt where Sym and

Trans are validated by the canonical pro of of tt Another example is the context

Int given by Int p N N and

set

L

Int p p Int p p p p

rel set

where in order to establish symmetry and transitivity we use some elementary

lemmas ab out addition on natural numbers

Chapter Extensionality and quotient types

Morphisms

Let b e contexts of setoids A morphism from to is a syntactic context

morphism f from to with

set set

Prf f f true Resp

set rel rel

In this situation we write f as usual Equality of morphisms is denitional

equality in the target type theory Clearly the comp osition of two morphisms is

a morphism again and the identity is a morphism Moreover the unique context

morphism into trivially satises Resp so that we have

Prop osition The contexts of setoids and their morphisms form a category

C with terminal object

Notice that we do not identify provably equal morphisms ie f and g with

Prf f g true Doing so would render the semantic

set rel rel

equality undecidable and therefore the source type theory would b e undecidable

The dierence b etween actual semantic equality and provable equality is also im

p ortant for the choice op erator we consider in Sect which would b e unsound

if the two were identied

Families of setoids

Let b e a context of setoids A family of setoids indexed over is a pair

where is a type in the empty context and

set rel set set

s s s s Prop

set set rel

is a family of relations on indexed by such that

set set

s s Sym

set set

Prf Prf s s s s true

rel rel rel

s s s Trans

set set

Prf Prf s s Prf s s s s true

rel rel rel rel

s s Comp

set set

Prf Prf s s s s true

rel rel rel

Chapter Extensionality and quotient types

Two families are equal if their two comp onents and are denitionally

set rel

equal

Thus a family of setoids consists of a indexed family of partial equival

set

ence relations on one and the same type with the prop erty expressed by Comp

set

compatibility that the relations over related elements in are equivalent by

set

virtue of symmetry of It is imp ortant that symmetry and transitivity are

rel

relativised to existing ie those with since otherwise most of

set rel

the type formers including quotient types would not go through Also intuitively

this restriction makes sense since and are meant to b e undened or uncon

set rel

strained outside the existing part of An example of a family is again given by

L

Int N N and Int p p p p p p Here the family do es

set rel rel

not actually dep end on Examples where there is such a dep endency will arise

set

later in Section when we interpret an impredicative universe of prop ositions

The set of families of setoids over is denoted by Fam

Substitution and comprehension

Let B b e contexts of setoids f B and Fam A family ff g

FamB is dened by ff g and

set set

ff g B s s ff g f s s

rel set set rel

The comprehension of is dened by s and

set set set

s s s s

rel rel rel

The morphism p is dened by p s the relation is preserved

by virtue of elimination Finally the morphism qf B ff g is

given by qf s f s This preserves the relation since f do es It is

also readily checked that the relevant square formed out of f p and q commutes

and in fact is a pullback

Chapter Extensionality and quotient types

Sections

Let b e a context of setoids and Fam A section of is a term

set

M which resp ects the relations that is

set

Prf M M true Resp

set rel rel

Equality of these sections is again denitional equality in the target type theory If

M is a section then its asso ciated context morphism is dened by M M

which is a morphism by virtue of Resp Conversely if f M B is a

morphism then Hdf M M is a section of ff g To see Resp let B

set

and p B We must show that in this context f M M true

rel rel

But this is merely the last comp onent of condition Resp for f M B

by denition of Summing up we have the following

rel

Prop osition Contexts families and sections of setoids form a syntactic

category with attributesthe setoid model S

The dep endent type theory with extensional concepts mo delled by this syntactic

category with attributes in the sense of Sect will also b e called S

Implementing the setoid mo del S in Lego

If we want to use Lego to check the equations of S we must deal with of the

extensional nature of the judgements of the form P true We have used an

approach whereby semantic ob jects are rendered as pairs consisting of the actual

part which gures in the mo del and a pro of that the required judgements hold

For example we dene

Con setType relsetsetProp

CONGCon

fggGsetgGrel g gGrel g g

fgggGsetgGrel g gGrel g gGrel g g

Chapter Extensionality and quotient types

Now a context is an element G of Con and a pro of of CON G but these pro ofs

are ignored when two contexts are compared For each semantic op eration we

have a part which works on the rst comp onents and a part which establishes

preservation of these prop erties For instance comp osition has two comp onents

CompfABGCongMor B GMor A BMor A G

COMPfABGCongfgMor B GgffMor A Bg

CON ACON BCON G

MOR gMOR fMOR Comp g f

Thus in a sense we work in the deliverables mo del We cannot use the internal lan

guage of the deliverables mo del directly since it only oers prop ositional equality

of pro ofs but we must compare the semantic ob jects using denitional equality

Type formers in the setoid mo del

Let Fam and Fam The dep endent pro duct is dened by

set set set

u v

rel set set

s s s s s u s v s

set rel rel

If M Sect then we dene

M s M s

set set

and conversely if M Sect and N Sect we dene

App M N M N

set

Now by straightforward calculation we obtain

Prop osition These data endow the model S with dependent products in

the sense of Def

In very much the same way we can interpret types natural numbers and various

inductive types present in the target type theory Since the interpretation of these

Chapter Extensionality and quotient types

is almost forced we leave it out here In particular we have N N and

set

L

N x x x x This allows us to establish in exactly the same way as

rel

in the pro of of Prop that in the empty context the natural numbers contain

canonical elements only in spite of the extensional concepts Ncanonicity

Prop ositions

Our next goal is to identify a type of prop ositions and pro ofs which allows us to

externalise the relations asso ciated to each type and to interpret quotient types

and extensionality We use the semantic framework of Def lo ose mo del of

Constructions Again we denote by Prop b oth the family in Fam and its

comprehension Prop

To simplify the exp osition we assume as in Chapter that the target type

theory supp orts an extensional unit type ie there is a type in every

E

context and a term together with the equation M for

E E

every M We shall use the extensional unit type as the underlying type

E

of prop ositional types It is p ossible to get rid of the extensional unit type in

the same way as in Section by dening families of setoids as b eing either

of the form dened in Section or to consist simply of a prop osition in

context compatible with in which case it is silently understo o d that the

set rel

comp onent is the extensional unit type Comprehension substitution and

set

the type formers have then to b e dened by case distinction

Now we are ready to dene the required ingredients to interpret prop ositions

The underlying type of Prop Fam in S is just the syntactic type of pro

p ositions

Prop Prop

set

In order to identify equivalent prop ositions we dene the relation as biimplication

Prop p q Prop p q

rel

This is clearly symmetric and transitive and so a family over has b een dened

Note that Comp degenerates to a tautology in the case of families over

Chapter Extensionality and quotient types

The family Prf Fam Prop is given by

Prf p Prop

set E

Prf p Prop x x p

rel E

where is the extensional unit type The relation on Prf is trivially symmet

E

ric and transitive for Comp we use the relation on Prop More precisely if

Prop p q and Prf p x y ie p then also q thus Prf q x y

rel rel rel

Next we dene universal quantication If Fam and S Prop

then we put

S x x x S x

set set rel

For prop erty Resp assume and We must show that S

set rel

S So assume S and x with x x Using Sym and Comp

set rel

we get x x hence S x by assumption Prop erty Resp for S using

rel

and x x gives S x S x and thus S x as required

rel rel

The other direction is symmetric We see that the relativisation to existing

x is necessary to prove Resp

set

For the abstraction let M SectPrf fS g We dene

M

S set

To see that this is indeed a section of Prf f S g assume and

set rel

We must show that

Prf f S g M M

rel S S

which equals x x x S x by denition of Prf and Now

set rel rel

assuming x and x x we have that x x hence S x

set rel rel

by Resp for M

Finally the evaluation morphism is given by

ev x u x

S set set E

We must show that this denes a morphism from Prf f S p g to

Prf fS g Assume x x with and x x furthermore

set set rel rel

Chapter Extensionality and quotient types

assume x x x S x meaning that the two variables of unit type

set rel

corresp onding to Prf f S p g are related according to the denition of

Prf We must show that S x But this follows since by Sym and Trans

rel

for we have and thus x x by Sym and Trans for

rel rel

The equations relating evaluation and abstraction follow straightforwardly

from the prop erties of the extensional unit type Also the stability under sub

stitution of all comp onents follows readily by expanding the denitions

Prop osition The model S is a loose model of the Calculus of Construc

tions

Pro of irrelevance and extensionality

Next we explore which additional prop ositions are provable in S First we have

a nonprovability result

Prop osition Consistency The family

ff Prf f id g Fam

Prop Prop

has no sections

Pro of We have ff and ff x y p Prop Prop p p p A

set E rel E rel

section of ff consists of an element of necessarily such that p Prop p

E

p p expanding Prop But this is not p ossible by consistency of the syntax

rel

2

Next we lo ok at Leibniz equality in the mo del If Fam and M N Sect

then let L EqM N Prop b e the denotation of Leibniz equality as given

in Def By unfolding its denition we nd that in S

EqM N L

set

P Prop

set

x x x x P x P x

rel

y P M P N E

Chapter Extensionality and quotient types

So mo dulo the trivial quantication over M and N are Leibniz equal in the

E

mo del if they are indistinguishable by observations which resp ect the relation on

Lemma Let Fam and M N Sect The family Prf fL EqM N g

over has a section i

Prf M N true

set rel rel

EqM N g By denition this means that if Pro of Assume a section of Prf fL

for some then M and N not N are indistinguishable

rel set

by observations resp ecting Now

rel

x M x

set rel

is such an observation as can b e seen using Sym and Trans for and by

rel

virtue of and Sym Trans for Therefore we can deduce M

rel rel

N provided we can show M M but this follows from Resp for

rel

M Conversely if M N and P Prop resp ects then obviously

rel

P M P N by denition of resp ects 2

Thus Leibniz equality externalises the relation asso ciated to each family

Prop osition The fol lowing rules providing proof irrelevance as wel l as func

tional and propositional extensionality can be interpreted in S

A Prop M N Prf A

PrIr

M N Prf A

P Prop Q Prop H Prf P Q

BiImp

L

Bi ImpP Q H Prf P Q

U V x

L

x H Prf U x V x

Ext

L

ExtH Prf U V

Chapter Extensionality and quotient types

Pro of We identify syntactic ob jects with their denotations in S Rule PrIr

is immediate b ecause b oth M and N equal For rule BiImp assume P Q

SectProp f g The assumption H gives rise to a pro of of P Q for every

with But by Lemma this implies that there exists a section

set rel

of Prf fL EqP Qg The pro of for Ext is similar 2

Now we present a somewhat unexp ected feature of Leibniz equality namely that

it b ehaves like MartinLofs identity type in the sense that a Leibniz principle for

dep endent types can b e interpreted from which the denability of MartinLofs

elimination rule follows using PrIr and the enco ding of J in terms of Subst

and IdUni given in Sect

Prop osition For each Fam and Fam and M N Sect

EqM N and U Sect fM g there exists a wel ldet ermined section and P L

Subst P U Sect fN g in such a way that Subst ReM U U where

EqM M g corresponding to reexivity ReM is the canonical section of Prf fL

Moreover this operator Subst is stable under substitution in al l its arguments

Pro of We dene Subst P U simply as U That this is a section of f N g

follows from Lemma applied to P and rule Comp for the family The other

prop erties are trivially satised 2

Obviously this means that we can interpret rules Leibniz and LeibnizComp

L

from Sect with Id M N replaced by Prf M N As long as we do not

use induction over denable families the semantic formulation of closure prop erties

as in Prop ab ove and the more syntactic one in Prop are equivalent

and it is a mainly a matter of presentation which one is b eing used

Prop is imp ortant b ecause it states that S has the same strength as TT

I

and thus is conservative over extensional type theory TT by Thm E

Chapter Extensionality and quotient types

Axiom of choice

We may start with a target type theory in which the internal axiom of choice

ie the following schema of prop ositions

IAC

x y Rx y f x Rx f x true

holds Then in the source type theory this axiom is nevertheless not in general

valid b ecause in its translation the witness f is required to resp ect the equivalence

relations present on and which cannot b e guaranteed for the witness pro duced

by IAC in the target type theory In fact one can show by mimicking Diaconescus

argument see I I that IAC together with Ext and BiImp implies the

principle of the excluded middle p Propp p ff if this holds in the source

type theory then it must hold in the target type theory This in turn is not

necessarily the case even if IAC is present in the target type theory The fact that

the axiom of choice may fail b ecause a choice function fails to preserve extensional

equality is wellknown and is eg discussed in See also the example with

real numbers in Sect b elow

We conjecture however that in the particular case where the type in IAC

is N countable choice or any other type with Leibniz equality as the relation

we can actually interpret IAC in the source type theory provided we have it for

the target type theory The reason is that this relation is always preserved See

also Remark b elow The same go es for the principle of dependent choice

see eg Sect

L

x y Rx y x f N f x n NRf n f Sucn

where again the choice function has domain N The internal axiom of choice must

not b e confused with the following pro ofrelevant version of the axiom of choice

IAC is not valid in the Calculus of Constructions but it do es hold in its settheoretic interpretation of it

Chapter Extensionality and quotient types

which is obviously inhabited

x y Prf P x y f x Prf P x y

The dierence is that elements of a type are distinct if they have dierent

witnesses whereas all pro ofs of an existential statement are identied

Churchs thesis

Another principle which gets lost when passing from the target type theory to the

source type theory is Churchs thesis in the following formulation

CT F N N Nf N NcomputesF f f

where

L

computese N f N N n Nz Nf n Uz Te n z

and T is Kleenes Tpredicate and U is the output extraction function Informally

computese f expresses that e is co de for a program which computes f and CT

states that there exists a functional which to every function f N N asso ciates

a program for it

If CT holds in the target type theory then it need not hold in the source type

theory b ecause there is no reason why the witness F should preserve p ointwise

equality of functions Even worse in the source type theory one can actually prove

CT by mimicking the pro of in that CT together with the axiom of choice

and functional extensionality is inconsistent in HA Intuitively the reason is

that in the presence of functional extensionality F must yield equal results when

We do not know whether there exists a mo del of the Calculus of Constructions in

which CT is valid but this seems rather likely since CT is consistent in higherorder

intuitionistic arithmetic HA using a realisability mo del which interprets types as

subsets of rather than partial equivalence relations

Chapter Extensionality and quotient types

applied to extensionally equal functions so one can check whether a function is

eg constantly zero by examining whether F applied to it equals F x N

Let us p oint out that the following weaker formulation of CT

CT f N Ne Ncomputese f

do es hold in the source type theory if it holds in the target type theory b ecause

it gets translated into basically the same formula In the presence of IAC this

weaker version implies CT so that S together with CT provides a type theory

in which the internal axiom of choice is inconsistent provided CT is consistent in

the target type theory

We also b elieve that CT can b e consistently added to TT or TT if we trans

I E

late the existential quantication using the squash type former to b e introduced

in Sect rather than into a type

Quotient types

We now turn to the interpretation of quotient types in the mo del Their syntax is

given by the following rules

s s Rs s Prop M

QForm QIntro

R M R

R

s M s N R

L

s s p Prf Rs s H Prf M s M s

QElim

plug N in M using H

R

QComp

plug N in M using H M N

R

R

Per MartinLof has told the author that this phenomenon was one of the reasons

for him to reject equality reection IdDefEq which gives functional extensionality

and thus makes a TT version of CT inconsistent E

Chapter Extensionality and quotient types

M N H Prf RM N

QAx

L

Qax H Prf M N

R

R R

x R P x Prop

s H Prf P s

R

M R

QInd

Qind H M Prf P M

R

This syntax is a formalisation of usual mathematical practice Rule QForm al

lows the formation of a type R from a type and a relation R We do not

require R to b e an equivalence relation Using QIntro one constructs elements

classes of R from representatives The rule QElim allows one to con

struct functions on the quotient type by denition on representatives The axiom

QAx states that classes of related elements are equal the axiom QInd states

that R consists of classes only

For example we may dene a type of integers as Int N NR where

Int

L

R u v N N u v u v The elimination rule now allows us to

Int

dene functions like addition on the integers and the induction principle together

with the equations p ermits us to derive prop erties of these functions from their

implementations In examples we assume that various such functions such as

j j and negation have b een dened

Comparison to quotient types in TT

I

Notice that QInd resembles a sp ecial case of the dep endent elimination rule Q

IElim from Section the additional proviso in QIElim stating that H

preserves R is trivially satised in this sp ecial situation b ecause of pro of irrelev

ance

Using Prop and the fact that the quotienting relation never app ears in

the conclusion of a rule we can simulate the rules for quotients given in Sect

in the following way If s s s s we put Rs s p s s tt and

R We also put Obviously we have Rs s true if s s true

R

Chapter Extensionality and quotient types

and conversely if Rs s true and p s s P s s true for some s s

P s s Prop then P s s true by elimination Therefore the rules QIForm

QIIntro QIAx are validated For QIElim assume x R x and

x M x x such that

R

L

x x p x x H Prf Subst Qax p M x M x

We put x R x and

M s pairs M s

R

L

Now if Rs s then we can nd H M s M s using R elimination and

equality reasoning Therefore the premises to rule QElim are satised Let N

R and put U plug N in M using H The second pro jection U has type

R

U rather than N as we would need it in order to simulate QIElim But

L

using QInd over N we can construct P Prf plug N in M using H N

R

and thus have Subst P U N as required The computation rule Q

R

IComp follows from QComp and the semantic interpretation of Subst as the

identity

Interpretation of quotient types in S

Let Fam and R Prop b e a relation over Viewed

internally R is a term of type x x Prop such that

set set

x y x y

set set set set

Prf x x y y

rel rel rel

Rx y Rx y true

We say that R resp ects Our aim is to dene a new family R on which the

rel

relation is given by R The underlying type remains unchanged by quotienting

R

set set

Now since R is not guaranteed to b e symmetric and transitive we have to take

the symmetric and transitive closure of R moreover we must ensure compatibility

Chapter Extensionality and quotient types

with the relation already present on It turns out that the right choice for

rel

R is the following higherorder enco ding of symmetric transitive closure

rel

R s s

rel set set

R Prop

set set

x x R x x R x x 

set

x x x R x x R x x R x x 

set

x x x x R x x 

set rel

x x R x x x x x x R x x 

set rel rel

R s s

In other words R is the least partial equivalence relation on

rel set

which contains and R restricted to the domain of

rel rel

We shall call such a relation suitable so R is the least suitable relation

rel

Equivalence classes

Assume M Sect We want to construct a section M of R We put

R

M M

R

so M b ehaves just like M We must prove Resp for M Let and

set

R R

Moreover let R Prop b e a suitable relation We must

rel set set

show that R M M But since M is a section we have M M

rel

so we are done since suitable relations contain

rel

For QAx assume M N Sect and H SectPrf fR N M g ie

Prf R M N true

set rel

We want to show that SectPrf fL EqM N g is nonempty By Lemma

R R

and the denition of it suces to show that

R

Prf R M N true

set rel rel

In this context we can show M M and N N using Resp

rel rel

Thus for every suitable relation R Prop we have R M N

set set

by  which gives the desired result

Chapter Extensionality and quotient types

Lifting

Now we want to dene functions on the quotient family R from functions

on which resp ect R More precisely supp ose we are given Fam and

M Sect fp g and

H SectPrf fL Eq

M fp pPrf fRgg

M fqp pPrf fRgg

g

Eq are instances of M applied to one of the variables The two sections inside L

in Prf fRg Thus informally H states that M maps Rrelated elements

to Leibnizequal elements Finally assume N Sect R We want to construct

a section plug N in M using H of from this We dene

R

plug N in M using H M N

set

R

Let and Since N Sect R we have R N N

set rel rel

Now consider the particular relation

R x x

set

x x

rel

x x

rel

M x M x

rel

Now the result follows provided we can show that R is suitable This requires a

somewhat lengthy calculation in which H is used to establish that R extends R

Induction

Finally we interpret the induction principle Qind Assume P R Prop

and let an element of SectPrf fP qp R v g b e given In other words

R

assume

Prf s s Prf s s P s true

set rel set rel

Chapter Extensionality and quotient types

Now if M Sect R then we want to nd a section of Prf fP M g ie we must

show

Prf P M true

set rel

In this context we nd R M M using Sym and Trans and Resp

rel

Now putting s s M the result follows if we can show the stronger condi

tion M M But this follows by using the suitable relation

rel

R x x x x x x

set rel rel

Prop osition The setoid model S al lows the interpretation of quotient types

Eectiveness of quotient types

Here we want to address the question as to whether the converse to QAx is

L

also true ie whether we can conclude RM N from M N In general

R R

this cannot b e the case b ecause together with QAx this implies that R is an

equivalence relation Quotient types are called eective if this condition

is already sucient It turns out that in S all quotient types are eective and

that this is a purely syntactic consequence of the rules for quotient types and rule

BiImp

Prop osition Fix a type theory with quotient types and BiImp Let

and x y Rx y Prop be an equivalence relation ie in context we have

x Rx x true reexivity

x y Rx y Ry x true symmetry

x y z Rx y Ry z Rx z true transitivity

L

Then for each U V with U V we have RU V

R R

Pro of Consider the term M y RU y Prop We have

L

y y Ry y M y M y true

Chapter Extensionality and quotient types

by symmetry and transitivity and BiImp Let H denote the pro of of this Now

put

M z R plug z in M using H Prop

R

By QComp M U equals RU U and M V equals RU V The former is

R R

true by reexivity of R and b oth are Leibniz equal by assumption on U and V

Therefore RU V is true as well 2

Remark Quotient types without impredicativity Remark on

the role of impredicativity for subset types applies mutatis mutandis also to S

We have used the impredicative Calculus of Constructions as a target type the

ory and as the basis of the source type theory mainly for convenience b ecause

it oers enco dings of the logical connectives and equality so that their existence

do es not have to b e veried in the mo del Also eectiveness of quotients can then

b e derived in the source type theory However if for certain reasons one wants to

stay within a predicative framework such as MartinLof type theory one can still

interpret a type theory with a sort rather than a type of prop ositions One reason

why one might want to do this is that MartinLof type theory as a target type

theory satises the internal axiom of choice so that one could hop e to interpret

the principles of countable choice and dep endent choice in the source type theory

as indicated in Sect ab ove The details are left to future research

A choice op erator for quotient types

Our next goal consists of nding a way of getting hold of a representative for a

given element of a quotient type The idea is that since in the mo del an element

M of a quotient type is nothing but an element of the underlying type alb eit with

a weaker Resp requirement it should under certain circumstances b e p ossible to

view M as an element of this underlying type In other words we seek to interpret

Chapter Extensionality and quotient types

a rule of the form

M R certain proviso

QChoice

choiceM

and the following two equality rules

choiceM M

R

QChoiceComp

choiceM M

R

M R choiceM

QChoiceAx

choiceM M R

R

There is no error in rule QChoiceComp we explain in Sect how it can

b e consistent with QAx Semantically we want to interpret the choice op erator as

the identity ie if M Sect R then we want to put choiceM M

set

Now from M Sect R we can deduce that if for some

rel set

then R M M But in order to conclude choiceM M Sect

rel

we need to have the stronger M M One situation in which we

rel

can deduce the latter from the former o ccurs when from we can conclude

rel

that M and M are actually Leibniz equal b ecause then we can reason like in

Sect ab ove Now this situation in turn o ccurs for example when

rel

entails that and are Leibniz equal themselves This motivates the following

denition

Denition The set of nonquotiented types is dened by the fol lowing

clauses

N and other inductive types and x x Prf M for n are

n n

nonquotiented

If and are nonquotiented so is x

A syntactic context is nonquotiented if it is made up out of nonquotiented

types only

Notice that if and is nonquotiented then so is

Chapter Extensionality and quotient types

Prop osition Let be a nonquotiented syntactic context and let

set rel

be its interpretation in the setoid model We have

L

i i true

set rel

Pro of Easy induction on the denition of nonquotiented 2

Now we could semantically justify the application of choice in nonquotiented

contexts ie the ab ove certain proviso would b e that is nonquotiented With

such a rule we would however lose the syntactic weakening and substitution prop

erties which are implicit in eg the typing rule for application For example if

M R we can infer choiceM b ecause the empty context is non

quotiented but we would not have x R choiceM although x do es not

o ccur in M Therefore we close the rule up under arbitrary substitution and

weakening and thus arrive at the following denitive rule for choice

There exists a nonquotiented context

and a type and a term N with

N and a syntactic context

morphism f such that M

M R N f and R f

QChoice

choiceM

Recall that means syntactic identity and not just denitional equality so that

the side condition is decidable since the p ossible substitutions f are b ounded by

the size of M The condition is eg satised for z Int jz j Int with n N

and f z Int jz j but it do es not hold for z Int z z Int

Prop osition The above rules QChoice QChoiceComp QChoi

ceAx can be sound ly interpreted in the setoid model

Pro of We interpret choiceM like M Supp ose that choiceM by

QChoice then M N f for some syntactic substitution f We

Chapter Extensionality and quotient types

identify these syntactic ob jects with their interpretations If then f

rel

and f are actually Leibniz equal by Prop using the assumption that

is nonquotiented So M and M are Leibniz equal and thus related in

by the same argument as the one used in Sect Thus we can assert

rel

M Sect Since b oth choice and are interpreted as the identity the rules

R

QChoiceComp and QChoiceAx are validated 2

Discussion

The choice op erator is quite unusual and seems paradoxical at rst so that a few ex

amples explaining its use are in order Let and

R R

Int Int

where are abbreviations for the corresp onding numerals of type N and R

Int

L

is as dened in Sect Now since we have R and

Int

L

thus On the other hand choice and choice

L

It seems as if we could conclude which would b e a contradiction

L

Now means

P Int Prop P P

In order to get a contradiction from this we would have to instantiate with P

L

z Intchoice choicez But this expression is not welltyped since z Int

choicez the context z Int contains a quotient type is not Thus in some sense

the choice op erator do es not resp ect Leibniz equality As with any term former it

do es of course resp ect denitional equality so in an extensional setting where the

two equalities are identied choice would b e unsound

The main usage of the choice op erator is that it p ermits to recover the underly

ing implementation of a function b etween quotients internally For example if we

have dened some function F Int Int in nonquotiented context so in partic

ular F may not just b e a variable then we may form u N N F u Int

R

Int

apply choice and abstract from u to obtain F u N NchoiceF u

R

Int

N N N N Now using QChoiceAx we obtain u N N

Chapter Extensionality and quotient types

F u F u Int and moreoversince R is an equivalence relation

Int

R R

Int Int

u v N NR u v R F u F v using the ab ove and Prop

Int Int

Yet another application of choice arises from the use of quotient types to mo del

nonconstructive types like the real numbers Assume that we have dened a

type of real numbers Real as a quotient of a suitable subset type RealRep of N

N thought of as of decimal or continued fraction expansions the quotienting

relation b eing that the dierence is a fundamental sequence dened in the usual

style Now since dierent real numbers can b e arbitrarily close together there

can b e no nonconstant function from the quotient type Real to a ground type like

N and more generally all functions from Real to Real must b e continuous This

has b een brought forward as a serious argument against the use of quotienting in

a constructive setting since if one has dened a real number one cannot even put

ones hands on its rst digit Using the choice op erator one can at least solve this

last problem Assume that we have dened a real number R in the empty context

say e or We may then form choiceR N N and from this extract desired

intensional information like the rst digit or other things However it is still not

p ossible to write a nonconstant function from the reals to N Notice that this

lack is not particular to the setoid mo del but directly inherited from the target

type theory which do es not provide functions from N N to N which resp ect

the b o okequality for real numbers Similarly in the setoid mo del we have no

nonconstant function from Prop to N b ecause this is so in the target type theory

The constructive real numbers furnish another illustrative example due to

Troelstra for the failure of the axiom of choice b ecause choice functions

need not preserve equality Consider the function f x x x Although

f is surjective it has no continuous right inverse In S surjectivity that is

L L

a Realx Realf x a follows using Qind from a RealRepx Realf x

a where Real RepRealR This in turn is readily established by case

Real

R

Real

distinction on a But since this case distinction do es not preserve equality of real numbers we cannot lift this op eration to a function on the real numbers themselves

Chapter Extensionality and quotient types

Type dep endency and universes

As announced earlier the mo del S do es not provide any type dep endency other

than the one induced by prop ositions In particular we have neither universes

nor large eliminations Formally this can b e seen as follows Assume that

the target type theory contains an empty type and an op erator such that

M if M Then in the setoid mo del S we also have this empty

type Now if we had a universe containing the natural numbers and the empty

type then we could dene a family of types n N n such that and

Sucn N Now remember that the comp onent is left unchanged up on

set

substitution So in view of the rst equation there would have to b e a

function for every type which contradicts the second equation if

set

A ma jor application of such families of types is that they allow to derive Peanos

fourth axiom On the level of prop ositions we are still able to interpret this

L

axiom that is we have Suc ff provided this holds in the target type

theory The dierence is that Prf ff is weaker than the empty type b ecause in

the presence of an element of Prf ff every prop osition is true but not every type

is inhabited

Universes are also used for mo dularisation and structuring Eg using a uni

verse it is p ossible to dene a type of monoids or groups and to identify the

construction of the free group over a monoid as a function If we want to use

universes in this way then we are not interested in quotienting the universe itself

or types derived from it like U U So it should b e enough to allow quotienting

for smal l types ie those of the form ElM for some M U Moreover there do es

not seem to b e a need to dene a function from a quotient type into a universe

unless this function arises by weakening or substitution

We have investigated an extension to the setoid mo del which admits a universe

restricted in the sense that quotient types and inductive types and elimination of

them is only allowed within the universe This will concern us now

Chapter Extensionality and quotient types

In this mo del types in the empty context for now are triples

type set

where is a type is a family of types indexed by and nally

rel type set type

is a partial equivalence relation on each s for s It is not p ossible

rel set type

to compare x s and x s unless s s are denitional ly equal Now

set set type

the universe has comp onent U whereas types of the form ElM have trivial

type

comp onent Quotienting will then only b e p ossible for such small types

type

Similarly the families in elimination rules like the one for the natural numbers

or the one for quotient types will only range over small types So in particular

we cannot dene the ab ove family over N b ecause this would require primitive

recursion with result type U Let us now study the mo del in more detail

Contexts are dened as triples where is a syntactic

type set rel type

context is a syntactic telescop e over The third comp onent is a

set type rel

prop osition

g g g Prop

type set rel

such that denes a partial equivalence relation ie we have

rel

g g

type set

Prf g g true Sym

rel rel

g g

type set

Prf g Prf g g true Trans

rel rel rel

As usual equality b etween such contexts is given by denitional equality of all

three comp onents So a context can b e seen as a context of deliverables equipp ed

with a partial equivalence relation on each bre

A morphism b etween two contexts is a pair f f f such that

type set

g f g

type type type

g g f g f g

type set set set type

and moreover

g g

type set

Prf g f g f g f g true Resp

rel rel type set set

Chapter Extensionality and quotient types

A family over context is now given by a triple where

type set rel

g g

type type

g s g g s

type type set

g s g g x x g s g s x x Prop

type type set set rel

in such a way that is symmetric and transitive and compatible with ie

rel rel

g s g g x x g s Sym

type type set set

Prf g Prf g s x x g s x x true

rel rel rel

g s g g x x x g s Trans

type type set set

Prf g Prf g s x x Prf g s x x

rel rel rel

g s x x true

rel

g s g g x x g s Comp

type type set set

Prf g Prf g s x x g s x x true

rel rel rel

We notice that since do es not dep end on the last axiom Comp can b e

set set

formulated in the same simple way as b efore for ordinary setoids Indeed in this

setup dep endency and quotienting are entirely separated Again we have the

relativisation of symmetry and transitivity to existing elements of

set

The remaining structure is forced by the construction so we leave it to the

reader

More interesting is the denition of the universe in the empty context We

shall require the target type theory to supp ort a universe U El In particular

this universe may b e Prop Prf in which case we obtain an impredicative universe

in the mo del dierent from the semantic universe of prop ositions which exists to o

The universe is dened by

U U

type

U X U ElX ElX Prop

set

U X U R R ElX ElX Prop

rel

x x ElX R x x R x x

x x x ElX R x x R x x R x x

x x ElX R x x R x x

Chapter Extensionality and quotient types

This means that a morphism f from to U assigns to g an element

type

f g U and to g a relation Elf g Elf g Prop in such a

type set type type

way that if g then this relation is symmetric and transitive and moreover

rel

if g then the relations asso ciated to and are equivalent In other

rel

words such a morphism induces a family over This family is formally obtained

by substituting f into the generic family El Fam U dened by

El X U

type

El X U u ElX

set

El X U u R X X Prop x x ElX R x x

rel

It is easy to check that this indeed denes a family b ecause symmetry and trans

itivity are relativised to those R X X Prop for which U X R R holds

rel

The universe thus obtained is closed under all type formers the original universe

from the underlying type theory is closed under and in addition it is closed under

quotient types We leave the details to future work

The group oid mo del

We have seen in the last section that the setoid mo del S is of rather limited use

when one wants to interpret genuine type dep endency other than the one arising

from pro ofs dep ending on prop ositions For instance we were unable to dene a

family of types over the natural numbers by primitive recursion The reason was

that the setpart of a family did not dep end on the setpart of its context only

the relations were made dep endent In order to overcome these limitations an

obvious change is to make the parts dep endent to o So a setoid dep ending

set

on a context of setoids would consist of a type in context ie

set set set

and an equivalence relation on each of the ie x x together

set set rel

with terms re sym trans having the appropriate types Now in order to dene

context extension one needs a relation on the context x This means that

set

there must b e a way of comparing elements in and if and are

set set

related A natural way of achieving this consists of assuming functions mediating

Chapter Extensionality and quotient types

b etween the two ie a term

p x p x

set rel set reindex set

One would then exp ect that sends related elements to related elements and

reindex

so forth It is b ecause the pro of p of is used computationally in

rel reindex

that all the relations have to b e prop er dep endent types and not just families of

prop ositions Another way which we pursue in Section consists of dening

the relations b etween elements in dierent bres and The

rel set set

comp onent is however still needed

reindex

Now it turns out that in order to obtain a mo del of type theory along these

lines one needs to imp ose certain equational constraints on these pro ofs of re

latedness and also on the witnesses re sym trans which cannot b e guaranteed in

a purely syntactic mo del The construction can however b e carried through in

an extensional settheoretic framework and is of interest for the following three

reasons

First the mo del shows that from the identity elimination rule J alone it is not

p ossible to prove that any two elements of an identity type are prop ositionally

equal that is it provides the pro of promised in Sect that the additional

elimination rule IdUni introduced there is indeed necessary

Second the mo del gives a semantic view on the dichotomy b etween denitional

and prop ositional equality Denitional equality is the ambient settheoretic equal

ity in the mo del whereas prop ositional equality gets interpreted as generalised

isomorphism This establishes in particular the soundness of a rule which denes

prop ositional equality b etween elements of a universe as isomorphism

Thirdly we consider the mo del as the correct denition of dep endent setoids

as opp osed to the somewhat ad hoc formulation in Sect b elow This latter

construction is motivated and claried by the interpretation we shall give now

Since in the mo del types are interpreted as groupoids that is small categories

with isomorphisms only we call the mo del the groupoid interpretation of type the

ory Much of the material presented here has b een published in a joint pap er with

Chapter Extensionality and quotient types

Streicher A similar mo del has indep endently b een studied by Lamarche

without however noticing the implications on prop ositional equality In

the mo del was describ ed in rather abstract terms using the notion of bration

of group oids Here we give an elementary description avoiding categorical lan

guage as much as p ossible We use informal MartinLof type theory to denote

sets and families of sets as well as elements In particular we write x X S x

for the cartesian pro duct of a family of sets S indexed over a set X and we use

x X S x for the disjoint union of all sets in an X indexed family S We denote

pairing by x y and pro jections by x and x Also we use x A and M N

for settheoretic functional abstraction and application resp ectively

In the following we dene group oids and families of group oids and show how

they give rise to a syntactic category with attributes which interprets the stand

ard type formers including universes and the intensional identity type but which

nevertheless violates uniqueness of identity Functional extensionality will b e avail

able though

Group oids

Denition A group oid is a smal l category in which al l morphisms are iso

morphisms

In elementary terms a group oid X consists of a set X and a pro ofrelevant

set

relation on it ie for each x y X a set X x y which is provably an equi

set rel

valence relation This means that there are functions

re x X X x x

set rel

sym x y X X x y X y x

set rel rel

trans x y z X X y z X x y X x z

set rel rel rel

Notice the order of arguments to trans which diers from the one used for trans

itivity of Id or of setoids in Sect We have adopted the applicative order here

to b e in line with usual practice in category theory

Chapter Extensionality and quotient types

Moreover these functions must satisfy the following equations

trans p trans q r trans transp q r

trans p re p transre p

trans p symp re

trans symp p re

where we have omitted the X arguments If X is a group oid we refer to its

comp onents by X X X X X If the group oid we are referring to

set rel re sym trans

is clear from the context we use the following abbreviations

X x

re

pq X p q

trans

p X p

sym

We also sometimes leave out the and subscripts

set rel

Examples For each set X we have the discrete group oid rX dened by

rX X and rX x y fg if x y and otherwise

set rel

If X is a set and G is a group we dene a group oid G X by G X X

set

and G X x y G if x y and otherwise Here re sym and trans are

rel

dened in the obvious way using the group structure

Every top ological space X gives rise to a group oid with underlying set b eing

the set of p oints jX j of X and with the set of morphisms b etween p oints x and

y b eing the set of paths from x to y quotiented by homotopy ie two paths are

identied if there exists a continuous mapping sending one to the other For

example the group oid thus asso ciated to the surface of a ball is the discrete one

element group oid rjX j and the group oid asso ciated to the surface of a torus is

the group oid Z jX j

Every type in intensional type theory TT without extensional concepts

gives rise to a group oid G in the following way The underlying set G is

set

the set of terms M and the set of morphisms G M N b etween terms

rel

M N is the set of pro ofs P Id M N quotiented by prop ositional

equality ie P IdM N and Q IdM N are identied if IdP Q

Chapter Extensionality and quotient types

is inhabited Identity comp osition and inverses are given by Re Trans and

Sym which are readily seen to lift to the quotient using Resp The pro of of the

group oid equations is a nice application of the elimination rule Id Elim J

Remark The denition of groupoids also makes perfect sense in intensional

type theory replacing set by type or context The problem is that not many

groupoids exist if we ask the dening equations to hold in terms of denitional

equality Indeed we see below why this denition would not be closed under most

type formers notably function space and type

Denition Let X and Y be groupoids A morphism of group oids from X

to Y is a functor from X to Y when viewed as categories

In elementary terms such a morphism f consists of a function f X Y

fun set set

and a pro of that f resp ects the relations ie a function

fun

f x y X X x y Y f x f y

resp set rel rel fun fun

Moreover this pro of must resp ect re and trans ie

f

resp

resppq respprespq

From this it follows that sym is also preserved We omit the and

fun resp

subscripts if no confusion can arise

Example If are types in intensional type theory and x F x

is a function from to then F induces a morphism of group oids G F from

G to G by G F M F M and G F P Resp F P Again

fun resp

the required equations are readily veried using IdElimJ

Prop osition Groupoids with morphisms of groupoids form a cartesian closed category

Chapter Extensionality and quotient types

Pro of Comp osition and identities are their settheoretic companions taken for

the element and resppart separately The terminal ob ject is the discrete one

element group oid denoted rfg the cartesian pro duct is the pro duct category

We give the explicit construction of the exp onential X Y of two group oids X

and Y

X Y the set of morphisms from X to Y

set

X Y f g the set of natural transformations from f to g

rel

Thus an element of X Y f g is a function

rel

x X Y f x g x

set rel

such that for each p X x y the equation

rel

xg p f py

holds The group oid structure is given by

x

pq x pxq x

p x px

If f is a group oid morphism from Z X to Y its abstraction f is a group oid

morphism from Z to X Y If z Z then f z is the functor which

set

sends x X to f z x and p X x x to f p Now if q Z z z then

set rel rel

f q is a natural transformation from f z to f z Its comp onent at x

X is f q The naturality condition amounts to checking that f q f p

set

f pf q which follows since f preserves transitivity comp osition in X Y

It remains to verify the functor laws for f We have

f x f

f pq x f pq f p q f p f q

We leave it to the reader to dene the evaluation morphism and to check the

and equations 2

Chapter Extensionality and quotient types

The exp onential of group oids cannot b e dened syntactically in intensional type

theory b ecause there is no way to restrict the typetheoretic function space in

such a way that only those functions are included which preserve reexivity and

transitivity up to denitional equality An enco ding in extensional type theory

should however b e p ossible

The assignment r of group oids to sets extends to a functor b etween these

categories and as such has a left adjoint which sends a group oid G to the

quotient set G where g g G g g

set rel

Denition Let be a groupoid A family of group oids indexed over is

a functor from viewed as a category to the category of groupoids The set of

families over a groupoid is denoted Fam

In elementary terms a family of group oids over consists of a group oid for

each element Moreover these group oids must b e compatible with each

set

other ie there is a reindexing function

reindex set rel set set

and a pro of that this op eration resp ects the relations ie a function

p u v

resp set rel set

u v p u p v

rel rel reindex reindex

So far we have the notion of dep endent setoid sketched in the introduction to this

section But now again we imp ose further equational constraints Both

reindex

and must resp ect the group oid structure ie

resp

u u

reindex

pq u p q u

reindex reindex reindex

p p

resp

This is meant to b e a naive set In order to avoid size problems one might require the group oids taken on by the functor to b e small wrt some universe

Chapter Extensionality and quotient types

pq r p q r

resp resp resp

p

resp

p q r p q p r

resp resp resp

If is a family of group oids indexed over we refer to its comp onents by

set

We thus allow b oth s s and s s to denote

rel re sym trans rel rel

relatedness of s and s in the bre over If the family under consideration

set

is clear from the context we abbreviate p u by p u and also p q

reindex resp

by p q in accordance with the convention to use the same name for ob ject and

morphism part of a functor For p the pair p p

rel reindex resp

is a functor from to

Examples Every family of sets fS g induces a family of discrete group oids

x xX

indexed over rX in the obvious way Moreover if X and Y are group oids we

dene the constant family Const X Y over X by

Const X Y x Y indep endent of x X

set set set

Const X Y x y y Y y y

rel rel

Const X Y p y y

reindex

Const X Y p q q

resp

We also note that families of group oids over the terminal group oid are in

corresp ondence to nondep endent group oids

A family of types x x in TT almost gives rise to a family of group oids

over G Indeed if M is an element of G then we obtain a group oid

set

G M G M Moreover if P Id M M then Subst P

induces a morphism of group oids from G M to G N However we do

not have Subst Trans P Q M Subst Q Subst P M as required by the

second law for but only the corresp onding prop ositional equality Also the

resp

Subst functions do not lift to functions dened on G Nevertheless it is an

rel

instructive exercise to verify the equations for families of group oids in this case up

to prop ositional equality

Chapter Extensionality and quotient types

More examples arise from the interpretation of the type constructors which we

are going to describ e

Comprehension and Substitution

Let b e a group oid and Fam We dene the comprehension of denoted

as the following group oid

set set set

u v p p u v

rel rel rel

u u

re re re

p q p q

p q p q pp q p q

Notice that in order for these denitions to typecheck the equations imp osed on

families are required For example for u u

re re rel

u it is required that u u u and this follows from

re rel re

u u

re

It remains to check that is indeed a group oid We only verify asso ciativity

of transitivity

p q p q p q pp q p q p q

pp p q p q pp q pp p q p q p q

p q p p q p q p q p q p q

The canonical pro jection p is the rst pro jection from to which

set set

is obviously a morphism of group oids The reader familiar with category theory

will have noticed that this deninition of comprehension is a sp ecial case of the

socalled Grothendieck construction

Now let b e group oids Fam and f The comp osition

f is a family of group oids over which denes the substitution ff g In more

explicit terms we have

ff g f

set set set fun

Chapter Extensionality and quotient types

ff g u v ff g

rel set set

f u v

rel fun

ff g p u ff g

reindex set rel set

f p u ff g y

set

The other comp onents are dened accordingly It is immediate from the denition

that this substitution op eration satises the split prop erty ff g g ff gfg g

and fid g

Finally we have the morphism qf from ff g to whose function

part sends u to f u and it is readily seen that the following diagram

fun

is a pullback in the category of group oids

qf

ff g

p p ff g

f

This shows that group oids and families of group oids form a category with attrib

utes in the sense of Remark For technical reasons it is however appropriate

to separate sections from their asso ciated context morphisms as follows

Sections Let Fam A section of is a pair M M M where

el resp

M and M p p M

el set set resp set rel rel el

M in such a way that the following two equations hold for

el set

and q and q

rel rel

M M M M

resp re re el rel el el

M pq M pp M q pq M M

resp resp resp rel el el

If M Sect we dene the asso ciated context morphism M by

M M and M p p M p This obviously denes a

fun el resp resp

corresp ondence b etween the set of sections and the set of right inverses to p

We can now conclude

Chapter Extensionality and quotient types

Prop osition Groupoids and families of groupoids form a syntactic category

with attributes

Interpretation of type formers

We now investigate the closure prop erties of this mo del wrt various type formers

It turns out that the group oid mo del supp orts almost all the settheoretic type

formers so in particular those studied in the monograph Here we restrict

ourselves to the interpretation of sum and pro duct types the identity type natural

numbers and a universe

Interpretation of the dep endent sum

Let b e a family over and a family over We want to construct a family

over which interprets the type s s It is a dep endent version of the

comprehension group oid from Section It is dened by

s s

set set set set

u v

rel set set

p u v v p u v

rel rel

u

re set set

p q p q

p q p q pp q p q

p s t p s p t Reindexing on elements

p q r p q p r Reindexing on morphisms

The verications are essentially the same as in Sect and are left to the reader

Chapter Extensionality and quotient types

Pro jections and pairing If M is a section of then taking the rstsecond

pro jection in the el and the resppart separately yields two sections one of de

noted M and one of f M g denoted M On the other hand comp onentwise

N g into a section N N of pairing turns sections N of and N of f

These op erations are inverse to each other ie N N N N N N

and M M M Compatibility with substitution is straightforward

The group oid mo del thus admits extensional types in the sense of Prop

Dep endent pro duct of group oids

Let b e as b efore For each let denote the family of group oids

set

over the group oid dened by

set rel

s s

set set set

s s

rel set rel

In fact is just a sp ecial instance of substitution along the morphism from the

one p oint group oid to determined by Using this notation we dene the

set

dep endent pro duct of along as a family over by

The set of sections of

set

M N

rel set

The set of natural transformations from M to N

Natural transformations are dened in the same way as for the exp onential of

nondep endent group oids Also the brewise group oid structure is like in this

example A bit trickier is the denition of reindexing For p and

rel

M we put

set

p M s p M p s

el set

Here M p s is an element of p s Now since p p s s the

set

pair p lies in p s s So the denition makes sense The

rel

morphism part is similar

p M q s s p M p q

resp rel

Chapter Extensionality and quotient types

Finally we must dene the resp part of reindexing So let b e a natural trans

formation from M to M in We must dene a natural transformation

set

from p M to p M Its comp onent at s is

set

p p s

which is an element of s p M s p M s The verications are

rel

tedious but straightforward

Abstraction and application We want to show that the group oid mo del ad

mits pro ducts in the sense of Prop so we have to dene abstraction and

the evaluation morphism In the ab ove situation let M b e a section of Its

abstraction M is a section of Its element part at is the

set

section of sending s to M s and q s s to M q

set el rel resp

Its resppart sends p to a natural transformation from p M

rel

to M Its comp onent at s is M p which is an element of

set

s p M s M s

rel

The evaluation morphism

ev fp g

sends s M fp g to M s and acts similarly on morph

set el

isms The verications are left to the reader

The identity group oid

Now we come to the most imp ortant part of the mo del construction Due to the

particular prop erties of group oids and families of group oids it b ecomes p ossible to

dene an identity type which is dierent from the categorical equaliser and hence

is truly intensional We use the semantic framework of Def

Let b e a family of group oids over We form the group oid which

corresp onds to the context s s Over this group oid we dene the

family Id by

Id s s r s s rel

Chapter Extensionality and quotient types

Thus a pro of that s s are prop ositionally equal is an element of s

set rel

s Two such pro ofs are related only if they are actually equal Thus prop osi

tional and denitional equality on identity types coincide in the group oid mo del

Coming back to the example of top ological spaces and homotopy we would thus

consider two p oints of a top ological space as prop ositionally equal if there exists

a path linking the two and two such paths are prop ositionally equal if they can

b e continuously transformed into one another

It remains to dene the reindexing functions for Id If p q r

s s s s and h Id x s s s s then

rel set rel

p q r h r p hq s s Id s s

rel set

Notice that by the denition of we have p q p s s

rel rel

and r p s s Moreover since h s s by denition of families we

rel rel

have p h p s p s So the ab ove denition of reindexing in Id is well

rel

typed

We check the transitivity law

p q r p q r h pp q p q r p r h

r p r pp hq p q r p r pp hp q q

r p r p hq q p q r p q r h

Now if Id s s h h in other words if h and h are equalthen

rel

clearly p q r h p q r h so we put

p q r

For this denition to work all the coherence equations imp osed on families of

group oids are indeed required

v is the diagonal Identity introduction Recall that

morphism from to dened on elements by v s s s We

fun

v must construct a morphism Re Id with pId Re

It is dened by

Re s s s s

fun re

Re p q p q q

resp

Chapter Extensionality and quotient types

This denition implicitly uses the equation

p q q re s q p q q q

deduced from the laws for families of group oids

Identity elimination Let b e a family over the family Id and

let M b e a section of fRe g We construct a section J M of by

J M s s q Id q M s

el set

This works since s s s and s s q are related in Id by

re

q b ecause q q q

It remains to dene J M Let

resp

p r r Id s s q s s q

rel

or equivalently p r p s s r p s s and

rel rel rel

q r p q r We must exhibit an element of

q p r r q M s q M s s s

rel

Now

M p r relates p r r M s and M s

since M is a section So we have

r p q r M p r relates p r r p q M s

and r p q r M s

by multiplying by r p q r which is the desired pro of since

p r r q p r r p q

by denition of transitivity in and q r p q r by assumption

Prop osition The groupoid model supports intensional identity types

Chapter Extensionality and quotient types

Functional extensionality

It is immediate from the denitions of the dep endent pro duct and the identity type

that the latter supp orts functional extensionality ie that Ext constants as dened

in Sect can b e dened and that Turners equation Eqn in Sect

holds This is imp ortant b ecause we do not have uniqueness of identity in the

group oid mo del as shown b elow in Thm

The base types

The types N may b e interpreted by the discrete group oids r rfg

rN These are initial terminal and natural numbers ob jects resp in the cat

egory of group oids from which it follows that the introduction and elimination rules

can b e interpreted One may of course construct them explicitly as well It is also

p ossible to dene a group oid of lists even over a nondiscrete group oid but we have

not checked whether arbitrary parametrised inductive denitions can b e carried

out in the group oid mo del Certainly arbitrary inductive denitions as provided

by Co quands pattern matching cannot b e interpreted for then uniqueness of

identity would hold in the group oid mo del contradicting Theorem b elow We

leave it as an op en problem to determine whether the group oid mo del supp orts

all ortho dox inductive denitions ie those which only provide MartinLofs

canonical elimination rules as formalised by Dyb jer

Interpretation of universes

To interpret the universe we mimic the construction describ ed in of a mo del for

the Extended Calculus of Constructions Let b e some inaccessible cardinal This

means that is regular closed under union and whenever a cardinal is strictly

smaller than then so is Let U b e the set of all group oids lying inside

the level V of the cumulative hierarchy We interpret the universe by the discrete

group oid rU Since U is a mo del of ZFC it is closed under all constructions on

group oids we describ ed so all the universe rules can b e interpreted Using a chain

of inaccessible cardinals we can also interpret universes containing each other If

Chapter Extensionality and quotient types

we are interested in a universe closed under impredicative quantication containing

only and we may use the discrete group oid rf fgg with ElX X

Inside the settheoretic group oid mo del we considered so far there do es not

exist a nontrivial impredicative universe However group oids can b e dened in

any lo cally cartesian closed category for example the category of Sets

Here we can take U to b e the set of those Set group oids for which b oth the

set of ob jects and each homset are mo dest sets see lo ccit We conjecture that

in this way we get a nondegenerate ie without pro ofirrelevance mo del of the

Calculus of Constructions

We have not lo oked in detail at universes admitting universe induction However

since the category of sets is a full sub category of the category of group oids via

r every settheoretic construction of such a universe should carry over to the

group oid case see for example

Quotient types

The group oid mo del admits the interpretation of intensional quotient types as

dened in Sect at least in the case where the quotienting relation is

internally an equivalence relation If Fam and Fam is

such that there exist sections of the appropriate families witnessing reexivity

symmetry and transitivity then we can dene a group oid by

set set

and s s s s where is the left adjoint to r dened after

rel

the pro of of Prop The rules for quotient types can b e interpreted in this way

but due to the absence of uniqueness of identity we would like to have further rules

which constrain the equality pro of obtained by Qax see rule QIAx A sp ecial

case of this problem will b e considered b elow in Sect The formulation of a

general quotient type former in the group oid mo del of which this example would

b e an instance is left for future research

Chapter Extensionality and quotient types

Uniqueness of identity

We are now ready to give the promised pro of that uniqueness of identity is not in

general denable

Theorem Uniqueness of identity is not uniformly denable at al l types in

particular it is not denable at the type x UElx

Pro of If uniqueness of identity is denable at some type then by the

soundness theorem and the fact that all group oids Id s s are discrete

every group oid j for must b e a preorder ie every set j

x x has at most one element But the interpretation of x UElx

rel

do es not have this prop erty since in particular it has the element Z fg

which has two dierent endomorphisms 2

We remark that in view of Prop ositions and the interpretations of all

types denable from N using Id must b e preorders in fact they are discrete

which may also b e seen directly from the denition of these type formers in the

group oid mo del

Since uniqueness of identity can b e dened using patternmatching Sect

we obtain the following imp ortant corollary

Corollary Patternmatching is a nonconservative extension of MartinLof

type theory

Prop ositional equality as isomorphism

The lack of uniqueness of identity in the syntax has b een considered as a drawback

which can b e cured by the introduction of the IdUni constants There may

however b e circumstances under which the existence of more than one pro of of

identity is actually useful One such is provided by the following extension to

TT with one universe U El which may b e soundly interpreted in the group oid

Chapter Extensionality and quotient types

mo del For reasons of exp osition we assume functional extensionality and an

explicit constant Subst as in TT although it is denable from J Let

I

Isox y U f Elx Ely f Ely Elx

Id f f id Id f f id

ElxElx Ely Ely

b e the type of prop ositional isomorphisms b etween Elx and Ely If F

IsoX Y let F also stand for the rst comp onent F ElX ElY and

let F stand for the second comp onent F ElY ElX Now consider the

following new introduction rule for prop ositional equality on the universe

X Y U F Iso X Y

UnivId

UnivIdX Y F Id X Y

U

Moreover we introduce a denitional equality describing the reaction of Subst to

UnivId

F IsoX Y M ElX

UnivIdEq

Subst X Y UnivIdF M F M ElY

UEl

So if we use Subst to rewrite an element M of ElX as an element of ElY

then this equals the result of applying the isomorphism F to M Clearly this

violates uniqueness of identity this rule makes the op erator UnivId injective so

that if any two pro ofs of a prop ositional equality were identied then also any

two isomorphisms b etween types in the universe would b e identied which is a

contradiction as so on as the universe contains a co de for a nontrivial type such as

N Astonishingly however the ab ove extension is sound in pure TT

Theorem The above extension of TT can be sound ly interpreted in the

groupoid model

Pro of Let U b e the group oid with underlying set U the set of all small sets

set

ie with cardinality smaller than some inaccessible cardinal and with U x y

rel

the set of bijections b etween x and y The identity bijection provides reexivity

symmetry and transitivity are given by taking inverses and comp osition resp ect

ively We dene a family of group oids El FamU by Elx rx and if

Chapter Extensionality and quotient types

y is a bijection b etween x and y ie p U x y and e El x x p x

rel set

then we put p x px The El comp onent is trivial since b oth Elx and

resp

Ely are discrete It is readily veried that this denes a family of group oids

Now we claim that this provides a mo del for the ab ove extension to TT Clearly

we interpret the universe as U and the Elop erator as El Now if X Y U then

set

the interpretation of Iso is the set of bijections from x to y b ecause ElX and

ElY are discrete and thus prop ositional equality and semantic identity coincide

By denition any such bijection is an element of U X Y and thus we interpret

rel

UnivId as the identity Finally it may b e seen from the interpretation of J and

the denition of Subst that the latter is interpreted exactly by so that the

reindex

equation UnivIdEq is validated 2

The rule UnivIdEq may b e replaced by the simpler denitional equality

UnivIdEq

UnivIdX X idX Re X Id X X

U U

where idX IsoX X is the identity function viewed as an isomorphism b etween

X and X From UnivIdEq one obtains the prop ositional version of UnivId

Eq using J in the obvious way

We do not know whether this extension has many applications as such but one

might imagine more general extensions which allow to dene quotient types with

pro ofrelevant equality relation of which the ab ove universe would just b e a sp ecial

case For example one could then quotient a slice category by isomorphism and

in this way obtain a pullback op eration which is split up to Id If one succeeds

in formulating the interpretation theory for dep endent types inside type theory

and with prop ositional equality rather than settheoretic extensional equality one

could in this way address the problem of interpreting type theory in nonsplit

structures This ties in with the ab ovementioned work of Lamarche

which attempts to base mathematics on isomorphism rather than equality using a

group oid interpretation without however noticing the relationship with prop osi tional equality

Chapter Extensionality and quotient types

A dep endent setoid mo del

Our aim in this section is to give a version of truly dep endent setoids which can

b e presented as a syntactic mo del within TT As we shall see the mo del we end

up with has other drawbacks so that it cannot really b e considered sup erior to

S The mo del which we call S is similar in spirit to the group oid mo del but

certain compromises have to b e made since as we have seen the group oid mo del is

not denable in intensional type theory

We have argued that the reason for this is that the preservation of symmetry

and transitivity by context morphisms cannot b e guaranteed as so on as one has

dep endent pro ducts or function spaces A natural attempt would b e to drop

these requirements and to see how far one gets Then however symmetry and

transitivity for contexts may not b e used in the denition of any type former for

then stability under substitution would fail To see why consider a contrived

type former in the group oid mo del which sends Fam to B Fam

for all given by

B for fset rel re sym trans g

B p s p s

reindex reindex sym sym

Now if f B and Fam then we have B ff g B ff g ie

stability under substitution of B if and only if f preserves B

resp sym

Now if no type and term former may use symmetry and transitivity for

contexts we can just as well omit them from the denition of contexts It turns

out that the use of reexivity in certain term formers is unavoidable notably

in the interpretation of Subst the elimination op erator for the identity type

Fortunately using a trick we can ensure the preservation of reexivity by all

context morphisms as we see b elow in Sect

However we cannot ensure that reexivity is preserved by reindexing ie that

for all families Fam and s we have

set

s s

reindex re

Chapter Extensionality and quotient types

The lack of this preservation prop erty entails that certain denitional equalities

notably Comp and NatCompSuc only hold up to semantical prop ositional

equality in the mo del S so that we can only interpret a weakened type theory

where these equations are replaced by prop ositional axioms in the style of IdUni

I or ExtForm This is not a principal problem b ecause the mo del S supp orts

uniqueness of identity and functional extensionality so that by Thm and the

remark at the end of Sect it has the same expressive p ower as TT namely

I

the one of extensional type theory TT

E

Let us now describ e the details The target type theory ie the type theory

in which the syntactic mo del is formulated is TT the core type theory with

dep endent sums and pro ducts identity types and natural numbers

Parts of the material have b een previously published as The denition of

squash types in Sect is new and the material on universes Sect has

b een thoroughly revised and rewritten

Denition A context of setoids is a triple where

set rel re set

is a syntactic context and is a syntactic context relative to ie

rel set set

set set rel

and is a tuple of terms establishing reexivity of ie

re rel

set re rel

Two contexts of setoids are equal if their three components are denitional ly equal

So a context of setoids is a reexive graph if we view as the set of no des and

set

as the set of edges from to

rel

Denition Let and be contexts of setoids A morphism from to

is a pair f f f where

fun resp

f

set fun set

and

p f p f f

set rel resp rel fun fun

Chapter Extensionality and quotient types

such that reexivity is preserved up to denitional equality ie

f f f f

resp re re fun rel fun fun

holds Two morphisms between contexts of setoids are equal if their two compon

ents are denitional ly equal

Prop osition The contexts of setoids together with their morphisms form a

category C with terminal object

Pro of Clearly morphisms are closed under comp onentwise comp osition and

contain the identity A terminal ob ject is given by and

set rel re

2

Families of setoids

Now we come to the most imp ortant ingredientthe denition of dep endency in

the mo del We rst introduce a useful abbreviation If is a context of setoids

and then

n set

conn n

denotes the context consisting of all types for i j n i j ie

rel i j

the are connected by So for example if then

i rel set

conn rel rel

Denition Let be a context of setoids A family of setoids ab ove is a

tuple where

set rel reindex sym trans ax

is a type depending on

set set

set set

Chapter Extensionality and quotient types

is a dependent relation on

rel set

s s s s

set set set rel

is the reindexing function which al lows to substitute connected ele

reindex

ments of in

set set

p s s s s

set conn set rel

p s s

reindex set

such that is symmetric and transitive and such that p s s is always

rel reindex

related to s More precisely we require terms

rel

set

p

conn

s s

set

q s s p q s s

rel sym rel

set

p

conn

s s s

set set set

q s s q s s p q q s s

rel rel trans rel

set

p

conn

s s s s p s s s p s s

set rel ax rel reindex

Two families are equal if al l their six components are denitional ly equal We

denote the set of families of setoids over context by Fam

Since is not assumed to b e symmetric we must make a premise

rel conn

to rather than merely Otherwise we could not dene type

reindex rel

formers like the dep endent pro duct The reexivity assumption s s s in

rel

is needed for otherwise from one could conclude that any two elements

ax ax

of are related The function could also b e dened without this

set rel reindex assumption

Chapter Extensionality and quotient types

Comprehension and substitution

Let b e a family of setoids indexed over Its comprehension is the context

of setoids dened by

s s s s

set set set rel

s p s p p q s s

rel rel rel

s s s

re re

Thus a typical context of setoids of length takes the form

s s s s

set set rel

s s s s s s s s

set rel

s s s s s s s s p s s

rel rel

p s s s s s s

rel

s s s s s s

re

The morphism p is dened by by

p s s

fun

p p q p

resp

It follows immediately from the denition of that this is indeed a morph

re

ism

Let b e a family of setoids indexed over and f b e a morphism from to

We obtain a family of setoids over denoted ff g by precomp osing with f

ie by putting

ff g f

set set set fun

ff g s f s f s s

rel set fun set fun rel

ff g p s f s s s

reindex conn set fun rel

f p s s

reindex resp

Here by a slight abuse of notation we have applied f to p This is

resp conn

understo o d comp onentwise The other comp onents of ff g are dened similarly

by precomp osition We omit the obvious denition of the qmorphisms

Chapter Extensionality and quotient types

Sections

Denition If is a family over a context of setoids then a section of

is a pair M M M where

el resp

M

set el set

and

p M p M M

set rel resp rel el el

We denote the set of sections of by Sect Two sections are equal if both

components are denitional ly equal

Every section induces a context morphism from its context to the comprehension

of its type More precisely if M Sect then we dene M by

M M M

fun el resp re

M p p M p

resp resp

We check that reexivity is preserved

M

resp re

M

re resp re

M M

re el resp re

M

fun re

So although no equational constraints are placed on sections they nevertheless

induce prop er morphisms This is the trick used to obtain preservation of re

exivity We have p M id as required

Conversely if f then we construct a section Hdf Sect fp f g

as follows The part of p f sends to f Now

el set fun set

f is an element of So we put

fun set

Hdf f

el fun

The comp onent is dened analogously We have f qf Hdf and

resp

M so sections and rightinverses to canonical pro jections are in M Hd

corresp ondence Summing up we obtain

Chapter Extensionality and quotient types

Prop osition Setoids and families of setoids form a syntactic category with

attributesthe setoid model S

A frequently asked question is whether one could not identify families as so on

as they have denitionally equal and comp onents but arbitrary

set rel sym

and comp onents As we shall see these comp onents enter

trans reindex ax

directly the denition of the Subst op erator and the derived op erators Sym and

Trans witnessing symmetry and transitivity of the identity type A fortiori we

would then have to identify equivalent morphisms and to make substitution re

sp ect this identication we would also have to identify certain families This could

only b e achieved using a construction like that in the pro of of Thm The

resulting structure would probably b e a mo del of extensional type theory but not

a syntactic mo del in the sense of Sect for functional extensionality

We now pass to the mo delling of type formers notably the identity type and

a type satisfying functional extensionality We also lo ok at natural numbers

and types where we see that certain conversion rules are only satised up to

prop ositional equality

Dep endent pro duct

Let b e a context of setoids b e a family over and b e a family over

We dene a family Fam as follows Its type comp onent is given by

s s s s s s

set set set rel set

The relation is dened by

U V

rel set set

s s s ss s s s

set rel set rel

s s U s s V s s

rel rel

From the other comp onents the denition of which is basically forced we single out transitivity b ecause it displays a p erhaps unexp ected need for the use of reindexing

Chapter Extensionality and quotient types

We assume the following variables

f f f

set set set set

p q f f q f f

conn rel rel

We must show that f f To that end assume

rel

s s s s s s s s h s s

set rel rel rel

set

We have to construct an element of f s s f s s We would like to use

rel

and q q for this but in order to do so we need an element of which is

trans set

related to b oth s and s Using it is p ossible to obtain such element from

reindex

either s or s using the hypothesis p for instance Q s s

conn reindex

where Q is a part of p The rest is obvious This shows that with

conn

a more general denition of transitivity that do es not include the restriction to

connected elements of the context it would not have b een p ossible to dene the

type

Next we dene introduction and elimination for the dep endent pro duct follow

ing Def That is if M Sect we construct M Sect and

conversely if M Sect and N Sect we construct App M N

Sect f N g The element parts are

M s s s sM s s

el set set rel el

and

App M N M N N

el set el el resp re

The relational parts are dened similarly Also the governing equations are readily

checked Stability under substitution may b e veried by careful insp ection by

hand or b etter using the Lego pro of checker The fact that morphisms preserve

reexivity is crucial for this prop erty to hold

Prop osition The setoid model S supports dependent products

Chapter Extensionality and quotient types

The identity type

We are now ready to dene the interpretation of the identity type in the mo del

S The basic idea is to interpret prop ositional equality on a type as the as

so ciated relation endowed with a trivial relation namely any two elements are

related so that we can interpret uniqueness of identity In view of Sect

this allows us to replace J by the simpler combinator Subst Moreover we can

interpret functional extensionality in the sense of Sect Ext will satisfy

certain denitional equations which in particular ensure that all elements of type

N in the empty context are equal to canonical values However the denitional

equality LeibnizComp is only validated up to prop ositional equality that is we

can interpret a constant of the corresp onding identity type In we sketch

the denition of a more complicated identity type in S with strict Leibniz

Comp but sinceas announced ab oveother computational equations only hold

prop ositionally and there is no x for those we do not give this construction here

Supp ose we are given a context of setoids and a family of setoids over

We rst form the context consisting of and two copies of In our notation this

is The identity setoid denoted Id is a family over this context We

dene it by

Id s s s s s s

set set rel

and

Id x x p Id x q Id x

rel set set set

ie any two elements of Id are related Clearly this is symmetric and trans

set

itive To dene the rewriter Id we make use of transitivity and symmetry

reindex

of We see that although the relations on contexts are not assumed to b e sym

rel

metric and transitive we do need these prop erties for the relations on families

Chapter Extensionality and quotient types

Reexivity

The distinguished morphism Re Id interpreting reexivity

is given by

Re s s s s s s s Id

fun set set

The comp onent is trivial since any two elements of the identity setoid are

resp

related by It is also clear from the denition that Re satises the required

equations ie is stable under substitution and equals the diagonal when comp osed

with pId

Identity elimination

Let Fam and M N Sect We introduce the abbreviation IdM N

for the family Id f N gfM g Fam IdM N corresp onds to the setoid of

pro ofs that M and N are equal We also write ReM for the section

HdRe M SectIdM M

Now assume Fam Fam M M Sect P SectIdM M

M g corresp onding to the premises of rule Leibniz We want and N Sect f

to dene a section Subst P N of fN g using We put

reindex

Subst P N P P

el reindex re el re sym re re el

N N

el resp re

The rst two arguments to constitute a pro of that M and

reindex el

M are connected in Notice that reexivity of is required here as

el

well as symmetry of the relation on families In particular the use of reexivity

as a pro of that the two rst comp onents of the two elements of are related

is crucial

The next two arguments to are the element N M and

reindex el set el

a pro of that it is related to itself We hence obtain an element of M

set el

as required

Chapter Extensionality and quotient types

The part of Subst is dened similarly using

resp ax

As announced ab ove this eliminator do es not satisfy the rule LeibnizComp

The reason for this is that applied to a pro of by reexivity is not necessarily

reindex

the identity function However by virtue of the prop ositional companion to

ax

LeibnizComp is inhabited in the mo del

Extensional concepts

If P SectIdM M thensince the relation on Id is trivialthere is a

canonical section of IdReM P sending to Thus we conclude

set

Prop osition The model S supports the concept of uniqueness of identity

Next assume that Fam that U V Sect and that

V v U v App P SectIdApp

ie corresp onding to the premises to rule ExtForm Sect We want to

dene a canonical section Ext U V P of IdU V from this The element part

of P is basically mo dulo some currying of types a term of type

s s s s U s s V s s

set set rel rel el el

The element part of the section we are lo oking for amounts to an inhabitant of

s s s s s s s s

set set rel set rel

U g s s V g s s

rel el el

We obtain that by using either U or V and transitivity of The

resp resp rel resp

part is again trivial

Prop osition The model S supports the concept of functional extensional

ity We discuss quotient types b elow in Sect

Chapter Extensionality and quotient types

Inductive types

Simple inductive types like the unit type the Bo oleans and the natural numbers

may b e dened by taking the identity type from the target type theory as the

relation Unfortunately in the case of the natural numbers we obtain the compu

tation rule NatCompSuc see Sect only up to prop ositional equality

b ecause of the reexivity assumptions in contexts

We show the construction of the natural numbers in S following Def

Let b e a context of setoids

N N

set set

N n n N Id n n

rel set N

where Id is the identity type from the target type theory This is obviously

N

symmetric and transitive The reindexing function N is simply the identity

reindex

The section SectN and the morphisms Suc N N are

dened using the derived combinator Resp dened in Sect For example

we have

Suc n N Sucn Resp n NSucn

fun set re

Suc n n N p q N n n

resp set rel

p Resp n NSucn q Sucn Sucn

rel

N

For the elimination rule R assume some family Fam N and sections

M Sect f g and M Sect fSuc p g We must construct a section

z s

N

R M M Sect from this Assuming n N and n Id n n we have

z s set N

N

to nd an element R M M n n of n n Notice the dep endency of

z s el set

on the pro of that n is equal to itself As we have seen this dep endency is in

set

general unavoidable b ecause may contain term formers like Subst which make

use of which is in turn dened using the reexivity assumptions liken added

re

during context comprehension N is n N n Id n n

set set N

N

We wish to dene the desired element using R but in order to do so we must

slightly strengthen the inductive hypothesis b ecause M exp ects elements of

s set

Chapter Extensionality and quotient types

which are related to themselves So we use

N

R n n

z s

nNn Id nns nn ss

set

N rel

where the question marks are readily lled using M and M In the case of ie

z s s

the inductive step we assume n N and hyp n Id n ns n n s s

N set rel

and sn Id Sucn Sucn We then have to construct an element of

N

s Sucn sn s s

set rel

There are various p ossibilities for obtaining this element The easiest is probably

to instantiate hyp with Re n and to apply M This gives an element of

N s el

Sucn Resp Suc Re Sucn Re Sucn

set N set N

sn The second comp onent from which we obtain an element of Sucn

set

ie a pro of that this element is related to itself is obtained using M and the

s resp

required rst comp onent using instances of Subst and IdUni which is denable

at N

N

We omit the nontrivial but essentially forced part for R M M

resp z s

Now the equation NatCompZero follows immediately from its syntactic

companion The other equation NatCompSuc do es not even hold for the

el

parts b ecause in the righthand side according to the denition of substitution for

N

sections the omitted part of R M M applied to reexivity app ears

resp z s

whereas the lefthand side do es not contain this term Of course using induction

the two can b e proved prop ositionally equal in the target type theory and are thus

prop ositionally equal in the source type theory so that a prop ositional counterpart

of NatCompSuc can b e interpreted It seems that in many sp ecial cases Nat

CompSuc do es indeed hold for instance if do es not dep end on N

We are now able to establish the two imp ortant metaprop erties of S N

canonicity and consistency

x

Prop osition If M SectN then M Suc for some x

Chapter Extensionality and quotient types

Pro of By denition of S and in particular the interpretation of the natural

numbers we must have in the target type theory M N and M

el resp

x

Id M M By Remark we have M Suc for some x and

N el el el

x

M Re M Id M M Hence M Suc in S 2

resp N el N el el

Prop osition The family Id Suc over has no sections

N

Pro of If M SectId Suc then in the target type theory we have

N

M Id Suc which is a contradiction 2

el N

types

Our denition of contexts and context morphisms is based on an equational con

straint preservation of reexivity So we cannot exp ect that they can easily b e

internalised in S by some sort of type The obvious guess for a type in the

setoid mo del has for as in the denition of the type as underlying set

s s s s s s

set set set rel set

and as relation

S T s s t s s t s s t t

rel rel rel

We can now dene pairing and the rst pro jection and more generally interpret the

weak elimination rule In order to dene a second pro jection or equivalently

the dep endent elimination rule we must use and thus we cannot get the

reindex

equation

M N N

but only interpret the corresp onding prop ositional identity

Chapter Extensionality and quotient types

Quotient types

We b elieve that intensional quotient types ob eying the syntax given in Sect

are denable in S but checking all the necessary pro of obligations turned out to

b e to o complicated even with machine supp ort Particular instances of quotient

typesesp ecially in the empty contextcan however easily b e seen to exist in

S Examples are types of integers and rationals We therefore prop ose to add

the required quotients as primitive when working in S until a formal verication

of the quotient type former in S can b e given

As an example of how this works we dene a squash type former which can

b e seen as a quotient by the everywhere true relation

Prop osition The setoid model S supports a squash type former dened

by the fol lowing rules

M

2Form 2Intro

2 2M 2

M N 2

2Ax

2 axM N Id M N

2

x M x N 2

x x H Id M x M x

2Elim

plug N in M using H

2

plug 2N in M using H

2

2Eq

2 eqM N H Id plug 2N in M using H M N

2

Pro of Assume Fam We dene 2 Fam by 2 and

set set

2 x x x x x x

rel set set set rel rel

Furthermore we put 2 The other comp onents are straight

reindex reindex

forward If M Sect then 2M Sect2 is given by 2M M and

el el

Chapter Extensionality and quotient types

2M is trivial Finally if M Sect fp g and N Sect2 and H

resp

SectIdM fp g M fp g ie as in the premises to rule 2Elim then we

dene plug N in M using H Sect by

2

plug N in M using H M N N

el set el el resp re

2

The part of this section is combined using out of an instance of H

resp trans el

and M applied to instances of N and an instance of applied to N One

resp reindex

cannot use H directly b ecause it only works for elements over one and the same

whereas for the required part we must compare elements over dierent

set resp

alb eit related elements of With b eing part of the denition of plug

set reindex

we cannot achieve 2Eq up to denitional equality for the same reason as in the

situation of identity types where IdComp only holds prop ositionally 2

We remark that an analogue to the dep endent quotient elimination rule QIElim

is denable and that a denitional counterpart to 2Eq would b e desirable but

cannot b e interpreted in S

An application of squash types is that they p ermit the denition of existential

quantication as

x x 2x x

For this existential quantier the usual intuitionistic introduction and elimination

rules can b e dened but with the restriction that in the elimination rule the

conclusion type must b e at most single valued ie any two elements of it must

b e prop ositionally equal In particular for this existential quantier we can prove

unique choice ie if then the following type is inhabited

x x x Idx x

We also conjecture that the schemes countable choice and dep endent choice

from Sect with replaced by are inhabited

We b elieve that one can dene a choice op erator for the squash type similar to

the one in Sect but we have not checked the details

Chapter Extensionality and quotient types

Universes

We were also unable to identify a universe in S closed under types The obvious

candidate would have as underlying set the type

S US ElS ElS U type and relation

r

s s ElS ElS s s ElS s s symmetry

r r

s s s ElS ElS s s ElS s s ElS s s transitivity

r r r

and the identity type as relation Contrary to what we stated in this universe

is apparently not closed under the type former unless one assumes functional

extensionality in the underlying target type theory This universe do es however

contain the empty type and a unit type so that it may eg b e used to derive

Peanos fourth axiom

We conjecture that it is p ossible to add a universe to S using the metho d

describ ed in Sect with the same restriction on the source type theory ie

the extensional concepts are then only available inside the universe

Discussion and related work

An interpretation of types sorts or sets as sets together with partial equivalence

relations with a corresp onding relativisation of quantiers and abstractions has

b een prop osed by several authors with various aims

The rst was probably Gandy who gives an interpretation of simple type

theory no dep endency in itself to establish relative consistency of an extensional

ity axiom corresp onding to our Prop ositions and In he extends

this result to GodelBernays formulation of axiomatic set theory There he em

phasises the semantic character of his metho d by using the term inner model for

the interpretation Gandy also recognises the value of the interpretation itself as

an explanation of the nature of extensionality The results of this pap er may b e

expressed by saying in ordinary mathematics it is not possible to prove the

existence of nonextensional quantities

Chapter Extensionality and quotient types

Feferman Sect strengthens Gandys result by proving conservativ

ity of extensionality wrt secondorder formulae His metho d do es not seem to

generalise easily to type dep endency which is why we must content ourselves with

Conjecture Luckhardt applies Gandys metho d to higherorder Heyting

arithmetic

Assemblies together with partial equivalence relations as a formalisation of

the notion of a set underlies Bishops approach to constructive analysis and has

also b een used by Benabou where these ob jects are called ensembles empiriques

empirical sets Benabous setting diers from Bishops b ecause the relation in

empirical sets is pro of relevant very much like the part in group oids however

rel

the set of pro ofs that two ob jects are related carries a structure of top ological

space there Benabous motivating example is the set of stars where a pro of

that two stars are equivalent is a p erson who sees them identied The set of

p ersons is assumed to b e endowed with a structure of a top ological space expressing

closeness The relation thus dened is symmetric and transitive and moreover

has the prop erty of observational stability namely that for any two p oints the set

of pro ofs that they are related is op en Or to stay within the example if p mixes

up stars x and x and p is close enough to p then p identies them to o Benabou

then denes functional relations b etween empirical sets and proves that with this

notion of morphism the empirical sets form a top os in fact are the top os of sheaves

over the top ological space of observers Benabous main ob jective seems to b e of

a p edagogical nature namely to nd an intuitive way of explaining sheaves and

top oses

This b ears some resemblance with the ScottFourman theory of existence and

identity and the construction of a top os out of a categorical mo del of higher

order logic trip os describ ed in Again a category is formed the ob jects of

which are ob jects of some category endowed with an abstract equivalence relation

and the morphisms are functional relations We b elieve that Benabous construc

tion can b e cast into this abstract framework The motivating example in

the eective topos is of a similar nature

With the exception of Bishops approach and ours in all these constructions

Chapter Extensionality and quotient types

the morphisms b etween setoids are functional relations rather than functions

preserving the relations The reason for this is that functional relations provide

the axiom of unique choice which is crucial to top os logic In the Calculus of

Constructions or extensions of it like S this axiom may b e phrased as follows

L

P Prf x y x y

AC

ACP

This axiom thus blurs the distinction b etween pro ofs and datatypes present in S

b ecause it allows to construct an element of type out of a pro of Obviously with

functional relations instead of functions one achieves unique choice b ecause one

identies elements of a type with premises to the unique choice axiom

We have not considered functional relations and unique choice for two reas

ons First we want the interpretation function to map functions to functions

ie algorithms rather than functional relations ie sp ecications Second with

functional relations as morphisms it do es not seem p ossible to keep prop osition

ally equal elements distinct intensionally so that we lose the decidable semantic

equality and also the choice principle Of course setoids with functional relations

as morphisms have their own merits but for this pro ject we found it interesting

to lo ok at the other alternative Some more thoughts on the issue of functions

vs functional relations and unique choice can b e found in Sect We also

remark that if we express totality of a functional relation using types instead of

existential quantication then there is no dierence b etween functions and func

tional relations This is for example the case in the type theory suggested in

Remark

Due to the settheoretic nature of Benabous setting unique choice is present even

if one takes functions instead of functional relations

We have no precise pro of of this b ecause there is more than one way of setting up a

typetheoretic setoid mo del with functional relations as morphisms but in the obvious

one one has to make this identication for example in order to dene substitution in families

Chapter Extensionality and quotient types

Benabou also considers a categorical version of empirical sets called theorie

dappartenance et egalite formel le in which a setoid is simply a span in a cat

egory along with morphisms witnessing reexivity symmetry and transitivity

These morphisms are to ob ey equational laws similar to the group oid equations

in Sect Morphisms b etween these ob jects are again suitably dened func

tional relations Closely related to this is Carb onis explicit description of the

exact completion of a left exact category This category has as ob jects spans

with structural morphisms witnessing reexivity symmetry and transitivity and

morphisms are morphisms in the underlying category resp ecting the relations

It deserves mention that in none of these categorical approaches is type de

p endency a primitive It can b e enco ded using pullbacks or subsets of cartesian

pro ducts but only in an extensional setting where denitional and prop ositional

equality are identied

Jacobs and Mendler have lo oked at categorical reformulations of the

syntax of quotient types in the context of simple type theory and extensional type

theory resp ectively Jacobs identies extensional quotient types as left adjoint

to equality whereas Mendler proves that they corresp ond to co equalisers For our

purp oses the syntax is not really imp ortant we feel free to add or remove rules as

long as this is sound wrt the setoid semantics and corresp onds to constructive mathematical practice

Chapter

Applications

In this chapter we describ e some small applications of the extended type theories

studied in this thesis Most of the applications only use the extensional concepts

qua constants the additional denitional equalities gained by the interpretation

in the various syntactic mo dels are not used This allows us to carry out the ex

amples within the existing Lego system by merely working in a context containing

assumptions for the various extensional concepts see App endix A Most of the

examples have b een carried out in Lego but we prefer to stick to the notation used

so far and not give actual Lego syntax here The main purp ose of the examples is

to explain the usefulness of extensional concepts as opp osed to a direct enco ding

in pure intensional type theory according to one of the syntactic mo dels

This b ecomes particularly clear in Sect where subset types are heavily

used and in Sect which explores an enco ding of streams using functional

extensionality The example of category theory in type theory Sect shows

how the obvious enco ding of categories in type theories with extensional concepts

gets translated in the various setoid mo dels The resulting enco dings of category

theory in pure intensional type theory are quite complex which we see as evidence

for the structuring and taxonomic asp ect of setoid mo dels

The explicit unfolding of the interpretation in the setoid mo dels is pursued

further in Sect where we show how a familiar enco ding of copro duct types in

extensional type theory gets interpreted in pure intensional type theory On the

one hand this constitutes an interesting application of functional extensionality

Chapter Applications

on the other hand it exemplies the elimination of this concept by way of the

interpretation in the setoid mo dels

Section aims at a comparison b etween quotient types and the usual set

theoretic enco ding of quotienting This also sheds some light on the dierence

b etween setoid mo dels and top oses and the role of unique choice The last ex

ample Sect provides evidence for the usefulness of the conservativity of equal

ity reection over intensional type theory with extensional concepts Thm

In order to prove the practical usefulness of intensional type theory with exten

sional concepts larger case studies taken from Computer Science and constructive

mathematics would b e required However we felt that subsequent research in this

eld would b enet more from the present short examples each of which highlights

a sp ecic topic or problem raised in this work

Tarskis xp oint theorem

Our aim is to give a formalisation of the following general form of Tarskis xp oint

theorem Our formalisation is based on a previous one by Randy Pollack

which uses the Extended Calculus of Constructions without extensional con

cepts added

Denition A poset T is a complete lattice if every subset P T has

W

a necessarily unique least upper bound lub P in T

Theorem Tarski Let T be a complete lattice and f T T be

monotone The subposet of xpoints of f is then a complete lattice too

Informal pro of We rst note that if P T then P has also a greatest lower

V W

b ound in T given by P fxjx P g This implies that the dual of a complete

lattice is a complete lattice again

Chapter Applications

W

Now we show that the lub of the set of p ostxp oints of f ie fxjx f xg

is a xp oint of f and that it is actually the greatest xp oint ie that

fxjx f xg fxjx f xg

Both prop erties follow by expanding the denition of least upp er b ound By

duality we also obtain the existence of least xp oints

Next we observe that for any x T the subp oset x fy jx y g of elements

ab ove x is a complete lattice The lub of P x in x is given by the lub of

P fxg in T The verication is by case distinction on whether or not P is empty

Now given a subset P fxjx f xg of the xp oints of f let l b e its lub in

T First we show that f restricts to l Supp ose that l x We want to show

that l f x Since l is a lub this amounts to showing that P f x but this

follows from the assumption and the fact that P contains xp oints only Now let

w b e the least xp oint of f viewed as a function on l This xp oint exists since

by the ab ove l is a complete lattice We claim that w is the desired lub of P in

fxjx f xg Obviously w is an upp er b ound of P since w l P On the

other hand if P w and w is a xp oint of f then l w by denition of l and

thussince w is the least xp oint of f ab ove l we have w w as required 2

The structure of this pro of is somewhat intriguing since the facts ab out com

pleteness and xp oints are rst proved for T and later on in the pro of instantiated

with other partial orders obtained from T by restriction If we are to formalise this

pro of in some dep endent type theory we therefore have to prove these preliminary

facts for arbitrary p osets and later on instantiate them Now if we dene a p oset

as a type together with a binary Propvalued relation for example then without

subset types there is no way of identifying the upclosure x of an element x as

a p oset again

In the formal pro of by Pollack this diculty is overcome by representing the

underlying set of a p oset not merely as a type but as a type together with a Prop

valued predicate which singles out the intended elements The p oset axioms are

Actually Pollack uses partial equivalence relations rather than just predicates but

Chapter Applications

then relativised to the intended elements and so are further notions such as lubs

and xp oints This is where the deliverables mo del from Chapter comes in

Since in this mo del ordinary types are in fact mo delled as types with Prop valued

predicates we can get away with the previous naive denition of a p oset as having

merely a type as underlying set The interpretation of the development in the

mo del should then roughly give rise to Pollacks pro of but we dont even need to

carry out the translation if we are merely interested in the existence of a pro of The

formal pro of obtained thus is substantially shorter than Pollacks original pro of

and moreover follows much closer the informal pro of given ab ove The reason is

that we do not need to verify each time we apply an op eration or a law that all

the arguments satisfy the relativising predicate A certain drawback of the use

of subset types is the need for explicit co ercion functions from subsets to their

sup ersets In Pollacks pro of co ercions arise only at the level of the predicates but

not at the level of the terms themselves

Let us now describ e the details of the pro of We work in the internal language

of the deliverables mo del ie we assume the additional term and type formers

introduced there notably subset types and pro ofirrelevance We also require a

universe U El to dene a type of p osets which makes the presentation more

compact but could in principle b e avoided by using type variables To increase

readability we do not explicitly write down the El and Prf op erators and we use

the abbreviations for logical connectives and quantiers introduced in Chapter

We also allow inx notation for the ordering

In the context T U T T Prop we dene a prop osition PO stating

that T forms a partial order and CL stating that T is actually a complete

lattice The denition of CL uses four auxiliary predicates expressing that an

element of T is a lower upp er least upp er b ound or greatest lower b ound of some

since the present pro of do es not make use of quotienting the extra generality oered by using PERs is not needed

Chapter Applications

prop erty P T Prop

lowerP T Prop x T z T P z x z

upp er P T Prop x T z T P z z x

lubP T Prop x T upp er P x lowery T upp erP y x

glb P T Prop x T lowerP x upp er y T lowerP y x

CL PO P T Propx T lubP x

Furthermore if f T T we dene a predicate monf stating that f is monotone

wrt and if in addition P T Prop we dene a predicate closedf P express

L

ing that P is preserved by f We also dene predicates xf x x f x and

prexf x x f x Notice that all the denitions made so far dep end on T

and and that these can b e instantiated using substitutions Eg the prop osition

POT x y T y x expresses that the dual of T is a p oset

We keep the variables T f and assume pro ofs of the prop ositions CLT

and monT f We may then construct the following pro ofs

fpuf u T lubx T prexf x u xptf u

lubfpsuf u T lubx T prexf x u lubx T xf x u

establishing that the lub of the set of prexp oints is a xp oint and actually the

greatest xp oint We also prove that complete lattices have glbs

Glb P T Propg T glbP g

by constructing g as the lub of the lower b ounds

Now while keeping T and f we instantiate the denitions made so far

with dierent arguments Whenever P T Prop we may form the subset type

fx T jP xg and dene an order on this type by precomp osing the relation

by the injection wit

x y fx T jP xgwitx wity

Henceforth we write instead of Now we prove the prop osition POfx T jP xg

ie that a subset of a p oset is a p oset again and use this to establish the main

Chapter Applications

lemma namely that the upclosure of some element of a complete lattice is a

complete lattice The upclosure is represented as x fy T jx y g

upsCL x T CL x

Roughly this pro of upsCL is constructed as follows Assuming x T and P

fy T jx y g Prop we construct a predicate P on T as

L

y T p x y P y x y

p

following the settheoretic denition in the informal pro of Recall that y x

p

is an instance of the introduction op erator for subset types The existential

quantication over pro ofs that y lies in the subset is required to lift the predicate

P to the whole of T Another way of doing so would b e to use the extendoperator

from Sect

We may now use pro ofirrelevance to deduce that if y T and p x y then P y

L

i P y x y Had we used the extendop erator this would b e an instance

p

of fgElimNonpropComp We then follow the informal pro of

Now we prove that f is increasing on lubs of sets of xp oints

P T Prop a T P a xptf a l T lubP l l f l

L

We then form the subset of xp oints Fix fx T jx f xg and fo cus on the main

goal

CL Fix

where again refers to the restriction of the original ordering to Fix It is trivial

to show that this is again a partial order Given P Fix Prop we use existential

elimination on l T luba T p xptf aP a l giving a variable l T and a

p

pro of that l is the lub in T of the P lifted to T using existential quantication

over pro ofs as ab ove Next we use existential elimination with

Glb l upsCL l c l f witc witc

giving w l and a pro of that it is the greatest lower b ound of the p ostxp oints in

l Here we use f still as a function on T We then need to show that l f witc

Chapter Applications

if c l in order to get that w is actually a xp oint of f Another p ossibility would

b e to explicitly construct an f l l and to take the least xp oint of this

function One concludes as in the informal pro of

Discussion

The pattern of the formal pro of follows quite closely the informal one except for

the co ercion functions b etween subsets and their sup ersets B Reus who has

b een using a similar type theory to develop synthetic domain theory in Lego has

rep orted that these co ercions are extremely cumbersome In general the co ercions

seem unavoidable unless one gives up decidability and explicit pro of ob jects one

could however imagine a system in which co ercions from a subset type to a non

propositional sup ertype in the sense of Sect may b e elided This ties in with

Hayashis ATTT where one has implicit co ercions b etween renement types

and basic types The details of this in the context of the deliverables mo del remain

to b e worked out though

Apart from its simplicity the present formalisation using subset types also has

the advantage of b eing more convincing than the pro of in the pure Calculus of Con

structions by Pollack since it is closer to the intended settheoretic understanding

of p osets and lattices

Streams in type theory

We assume a type theory with functional extensionality eg the internal language

of the mo del S or S For deniteness we assume S and thus functional ex

tensionality wrt Leibniz equality Given a type not necessarily in the empty

context we form a type of innite lists streams over as

Str N

If S Str we put

Hd S S

Chapter Applications

and

Tl S n NS Sucn

Now we dene a bisimulation as a relation s s Str R Prop with the

L

prop erty that s s Str Rs s Hds Hds and s s Str Rs s

RTls Tls In this case we can establish the coinduction principle

L

s s Str Rs s s s true

In other words bisimilar streams may b e substituted for one another in an arbit

rary context The straightforward pro of of this uses functional extensionality to

N

reduce equality on streams to equality on and induction R

Streams can b e constructed using coiteration as follows If out

and step then for init we put

n

CoIt out step init n Nout step init Str

n N

where is the nth iteration of a function dened using R Now by the rules

for denitional equality we have

HdCoIt out step init out init

TlCoIt out step init CoIt out step step init Str

For example if M we may dene a constant stream

Const M CoIt x M x x

L

It satises HdConst M M and TlConst M Const M by coinduction

More generally using coinduction we can show terminality of Str ie that

any function f Str which satises the two equations and ab ove up

to prop ositional equality must b e prop ositionally equal to x CoIt out step x

Chapter Applications

To b e indep endent of the implementation of streams as functions one also

needs a prexing op eration if M and S Str then

N

Pref M S n NR M x Ns S x n

xN

satisfying HdPref M S M and TlPref M S S Prexing is also prim

itive in Co quands approach to innite ob jects and innite lists in Martin

Lofs nonstandard type theory Using coinduction we can prove that

L

Pref HdS TlS S for S StrS

Possibly terminating streams ie solutions to domain equations of the form

have b een prop osed as a mo del of dataow networks these are networks of

agents communicating via channels with unbounded capacity playing a role in

proto col verication

If the innite streams describ ed ab ove are used instead of p ossibly terminating

ones one has the advantage that liveness ie the absence of deadlo ck mo delled by

a terminating stream is built into the typing A certain diculty arises from the

ubiquitous use of the xp oint combinator for the denition of domaintheoretic

streams For example the b ehaviour of a dataow network is dened as the least

solution to a system of xp oint equations obtained from the sp ecication of the

agents and the geometry of the network Since for the type Str obviously no

xp oint combinator can b e available for instance s StrNConstSucHds

has no xp oint and s Str Tls has no unique xp oint which could b e obtained

by an iterative pro cess we cannot immediately compute the solution of such

In fact prexing is denable in terms of coiteration using function types but it

seems more economic to dene it directly as ab ove Prexing can also b e dened in

terms of a generalised version of coiteration corecursion as is shown in

The domaintheoretic least xp oint of these functions is in b oth cases the undened stream

Chapter Applications

equations Not surprisingly this is the p oint where we have to supply a pro of of

liveness ie a pro of that the domaintheoretic least xp oint of a function on

streams is indeed innite Fortunately due to the simplicity of the ab ove domain

equation we can always compute a candidate for this least xp oint which coincides

with the least xp oint if the latter happ ens to b e innite

Supp ose that F Str Str and that is inhabited eg by M If the

least xp oint of F is total then HdF s must b e indep endent of s so a guess

for it is M HdF Const M Continuing with the iteration we obtain the

tail of the xp oint as the xp oint of the function

s Str TlF Pref M s

This suggests the following denition for the candidate for xp oints

FixF M CoIt

Str Str

F Str Str HdF Const M

F Str Str x Str TlF Pref HdF Const M x

F

We acknowledge that this is not a very ecient implementation but if so desired

one may always translate instances of Fix using general recursion and prove once

and for all that the thus extracted general recursive programs never deadlo ck

Along with this candidate we dene a totality predicate on stream trans

formers as a greatest xp oint

TotalF Str Str P Str Str Prop P F F P F

L

x s Str HdF s x

P s Str TlF Pref x s

Here the rst line is a higherorder enco ding of the greatest xp oint of the re

mainder when abstracted from P Using coinduction it is p ossible to prove the

Least xp oint is understo o d informally here via some again informal embedding

of Str into the domain of p ossibly terminating streams

Chapter Applications

following prop osition

F Str Str m

L

TotalF F FixF x FixF x

and also that every other xp oint of F equals FixF x This pro of which we

have carried out in Lego makes heavy use of the prop erty that every function and

predicate resp ects bisimilarity It would highly complicate the pro of if one did

not have coinduction and instead used a dened b o okequality on streams If

for conceptual reasons one is interested in such a development one may always

translate the present pro of using the interpretation in one of the setoid mo dels

It is p ossible to justify the choice of Total using an intuitive domaintheoretic

argument It turns out that whenever F has an innite least xp oint

in the domaintheoretic sense and the domain S of elements of the streams is

at then F must satisfy the predicate Total Indeed if the least xp oint of F is

innite then F must b e dierent from and therefore m HdF must

b e dierent from Thus since S is at sHdF must b e the constant

function sm Now recall the dinaturality principle for the least xp oint

Y f g f Y g f Consider TlY F We have

TlY F

TlY sPref HdF s TlF s since F s

TlY sPref m TlF s

Y sTlF Pref m s by dinaturality

Thus TotalF is satised for the predicate

P F Y F is innite

A simple application of Fix and Total is the recursive denition of Const M

as the xp oint of F s Str Pref M s This satises Total with the obvious

L

choice P f f F b ecause HdF s M and TlF Pref M s F

We remark that in a Lego development we have b een able to prove Total for

the central lo op of the alternating bit proto col in the setup of Dyb jer and Sander

and could thus redo their domaintheoretic pro of in the setting of total type theory

Chapter Applications

Category theory in type theory

Formulating category theory within type theory is a nice application of dep endent

types and prop ositional equality Several authors have attempted to formalise bits

of category theory in typetheoretic systems with varying results In fact

Luo rep orts that giving a sound foundation for category theory was one of

MartinLofs original motivations for introducing his type theories

Our own exp erience suggests that the simplest approach is to use prop ositional

equality for b oth ob jects and morphisms In this way we have managed to give a

formal pro of of the Yoneda Lemma in Legoa nontrivial task b ecause it neces

sitates the formalisation of presheaf categories which in turn mix up equality of

ob jects and of morphisms Our formalisation makes use of functional extension

ality in various places

Here we will not repro duce this fairly obvious formalisation but rather ex

plain how the denition of a category using prop ositional equality gets translated

into setoids using the mo dels S and S The resulting structures b ear resemb

lance with Hornungs and Huets formalisations which however lack ob ject

equality and therefore do not seem to p ermit the denition of functor categories

In this is p ossible using intensional equality for ob jects however more com

plicated constructions mixing equality of ob jects and arrows do not seem to go

through anymore This application shows how the setoids mo dels can b e used

as a guideline for formalisations if one do es insist on using partial equivalence

relations rather than prop ositional equality

Let us rst recall the denition of a category using prop ositional equality

Denition In type theory with extensional concepts a category is given by

a type Ob of objects a family of types

x y Ob Morx y

of morphisms an operation

x Ob idx Morx x

Chapter Applications

an operation

x y z Ob f Morx y g Mory z compx y z g f Morx z

and the fol lowing operations corresponding to the usual axioms where compx y z

g f is abbreviated by g f

x y Ob f Morx y idLf Id f idx f

Morxy

x y Ob f Morx y idRf Id idy f f

Morxy

x y z w Ob f Morx y g Mory z h Morz w

Assf g h Id h g f h g f

Morxw

It should b e clear that this denition is stable under constructions like functor

category arrow category slice category opp osite category etc and haswhenever

x x is a family of typesa particular instance based on Ob and

Morx y x y called Full Of sp ecial interest is the category

FullU El for a universe U El which can b e compared to the category of small

sets The use of prop ositional equality on ob jects Id is needed for instance in

Ob

the denition of slice categories

The typing of comp osition may suggest that comp osable morphisms must have

denitionally rather than prop ositionally equal domain and co domain resp ect

ively and that thus we cannot use prop ositional equality on ob jects However

using Subst we can adapt the domain and co domain of a morphism For instance

if X X Y Ob and P Id X X and F MorX Y then we have

Ob

F Subst P F MorX Y

ObxObMorxY

and using IdElimJ we can establish prop erties of F For example if F is an

isomorphism then so is F

This corresp onds to the categorytheoretic notion of full internal sub category

dened for example in Thm where it is attributed to Penon

Chapter Applications

Categories in S

In the mo del S a category according to the ab ove denition in the empty context

for simplicity expands to the following The ob jects are represented by a type

Ob and a partial equivalence relation x y Ob x y Prop We use inx

notation here to increase readability This Prop valued equivalence on ob jects is

not to b e confounded with denitional equality which is denoted x y Ob

Morphisms are represented by a single type Mor of morphisms and a relation

x y Ob f g Mor f g Prop

xy

stating that f and g are equal qua morphisms from x to y These data are sub ject

to the following axioms where we have used conjunction and implication

instead of context extensions

x y Ob f g Mor x x y y f g g f true

xy xy

and

x y Ob f g h Mor x x y y f g g h f h true

xy xy xy

and

g true x y x y Ob f g Mor x x y y f g f

xy x y

The identity op eration now takes the form

x Ob idx Mor

with

x x Ob x x idx idx true

xx

and comp osition takes the form

x y z Ob f g Mor compx y z g f Mor

with

x y z x y z Ob f g f g Mor

x x y y z z

f f g g

xy y z

compx y z g f compx y z g f true xz

Chapter Applications

In view of Lemma the laws are then expressed in terms of eg

idL b ecomes

x y Ob f Mor x x y y f f compx x y f idx f true

xy xy

The salient feature of this enco ding is the single type of morphisms indep endent

of the resp ective domains and co domains This makes it easy to replace domain

and co domain of a morphism by prop ositionally equal ones but it precludes the

particular instance of a category based on a universe FullU El since such a

universe is not available in S In the extension of S by universes describ ed in

Sect the situation is dierent Here we can of course construct a category

with U as its set of ob jects but then we do not have a substitutive equality on

ob jects at least not an equality with extensional concepts Let us sketch how

a category lo oks in this extension under the assumption that Ob has trivial

set

and comp onents and that Mor has trivial comp onent A category is

rel type

then given by a type Ob of ob jects for instance Ob U and a family of types

x y Ob Morx y such that each of the types Morx y is endowed with a partial

equivalence relation

x y Ob f g Morx y f g Prop

xy

x y Ob f g Morx y f g g f true

xy xy

x y Ob f g h Morx y f g g h f h true

xy xy xy

The comp osition op eration has the usual typing

x y z Ob f Morx y g Mory z compx y z g f Morx z

and the congruence laws and the other comp onents are as one exp ects them to b e

This enco ding of categories is quite similar to the ones oered in

Of course this notion of category is not stable under constructions such as

functor categories b ecause of the lack of ob ject equality But in the extension of

S with universes b oth notions of category co exist and even mixed forms where Ob

has nontrivial and comp onents and it makes sense to call a category

set type

Chapter Applications

small if it has a set of ob jects ie if in the source type theory Ob ElX

for some X U or if in the target type theory it has trivial comp onent

type

One would then allow the formation of a functor category C D only if C is

small The same restrictions on functor categories apply in set theory but for

size reasons not for lack of substitutive equality We remark that such a distinction

b etween categories which have ob ject equality and those which dont also is made

by Benabou in alb eit for dierent reasons

Categories in S

In S we have b oth dep endency of morphisms on ob jects and a substitutive ob ject

equality This is achieved by a reindexing function on morphisms Again we

only treat the case of a category in the empty context and use inx not to b e

confused with denitional equality for the relations on ob jects and morphisms A

category then consists of a type Ob and a partial equivalence relation x y Ob

x y Unlike in S symmetry and transitivity must now b e witnessed by terms

which are part of the category structure

x y Ob p x y Ob p y x

sym

x y z Ob p x y q y z Ob p q x z

trans

Next we have a set of morphisms indexed over existing ob jects

x y Ob x x x y y y Morx y

Notice that we do not indicate the dep endency on x and y since these can b e

inferred from x and y The equality relation is dened for arbitrary morphisms

not necessarily with common domain and co domain

x y x y Ob x x x y y y x x x y y y

f Morx y g Morx y

g f

x y x y

This equality is again symmetric and transitive with the restrictions made in

Def We do not explicitly state these More interesting is the reindexer

Chapter Applications

for morphisms over related ob jects

x y x y Ob x x x y y y x x x y y y

p x x q y y f Morx y f f f

x y x y

reindexp q f Morx y

and in addition the axiom on reindexing

reindexp q f axp q f f

x y x y

where is the context in the judgement for reindex Using symmetry and

transitivity we can construct a pro of that reindexp q f is related to itself The

identities take the form

x Ob x x x idx Morx x

x x Ob x x x x x x p x x id idx respp idx

x x x x

resp is A sp ecial case of id

x Ob x x x id respx idx idx

x x x x

We abbreviate this term by idx Comp osition is dened similarly

x y z Ob x x x y y y z z z

f Morx y g Mory z f f f g g g

compg f Morx z

x y z Ob x x x y y y z z z

f Morx y g Mory z f f f g g g

x y z Ob x x x y y y z z z

f Morx y g Mory z f f f g g g

g f v g p x x q y y r z z u f

y z y z x y x y

compg f respp q r u v compg f comp

xy x z

Again we can dene a term compg f witnessing existence of compg f As

an example of an equational law we give again the left identity law

x y Ob x x x y y y f Morx y f f f

x y x y

idx f idLf compf

x y x y

Chapter Applications

It follows from the fact that S forms a syntactic category with attributes closed

under types types and identity types that the ab ove enco ding of categories

is stable under all constructions on categories which can b e carried out with the

enco ding based on prop ositional equality using these type formers This includes

functor categories arrow categories slice categories the instances Full and

many more Of course many of these instances do not fully exhaust the generality

of the enco ding as for example the p ossible dep endency of comp osition on the

existence pro ofs f Nevertheless this generality has proven necessary in order to

obtain a syntactic category with attributes and so one can exp ect counterexamples

to every simplication of the ab ove enco ding It is however dicult to construct

such counterexamples explicitly b ecause even with machine supp ort the enco ding

b ecomes unmanageable as so on as one go es b eyond the simplest cases

Discussion

We have seen how some reasonable enco dings of category theory in type theory

arise as translations of an obvious enco ding using prop ositional equality with ex

tensional concepts added We consider such an enco ding useful for the following

two reasons

First a development of category theory in constructive type theory p ermits to

directly explore the constructive content of many categorytheoretic arguments

which gets hidden if to ols like settheoretic quotienting and choice from equivalence

classes are b eing used A case in p oint is Lafonts pro of Sect that

the addition of function types to an algebraic theory constitutes a conservative

extension Second type theory as a basis of category theory is philosophically

app ealing as the consistency of typetheoretic systems like TT S S even with

universes can b e proved within ordinary mathematics probably even in primitive

recursive arithmetic whereas the relative consistency of a settheoretic foundation

of category theory like MacLanes universes I go es b eyond ZFC

Chapter Applications

Enco ding of the copro duct type

In the literature on extensional type theory various enco dings of type formers

from simpler or more general ones have b een prop osed In particular we have

the enco ding of a sum copro duct type using natural numbers and functions

by Troelstra Ex and the enco ding of inductive types like the natural

numbers in terms of MartinLofs wellordering type By the conservativity

theorem these enco dings can also b e carried out within TT and therefore

I

give rise to counterparts in the various setoid mo dels Since we have not lo oked

at interpretations of the wellordering type in the setoid mo dels we only work out

the example with copro ducts here and leave the study of wellordering types to

future work

By coproduct type we mean a type former which to any two types and

asso ciates a type together with the following term formers if M then

inl and if M then inr M If z z and x

Lx inl x and y Ry inr y then whenever M we have

L R inlM LM L R M M and the denitional equalities R R

L R inrM RM and R

The ab ovementioned enco ding of copro ducts in TT requires a type called N

I

in with two elements called and and corresp onding elimination rule

which in the situation z N x L R and M N gives an element

N N N

R L R M in such a way that R L R L and R L R R

Moreover for each type a term Id is required The type

N

N may b e dened as

N m Nn NId m n Suc

N

N

where is the obvious enco ding of addition in terms of R the terms may b e

dened by induction on the structure of p Prop The interesting

N

case is when Id M N Here one denes a function from N to using R

which takes on the values M N on resp ectively and then obtains

Id M N

Chapter Applications

using Resp Unlike in the extensional theory studied in lo ccit the term

may thus contain a variable of type Id We remark that this denition is

N

not p ossible in the presence of an empty type but b ecomes again p ossible if the

empty type is contained in a universe Troelstra and van Dalen now oer the

following enco ding of the copro duct type for types

n N Id n Id n

N N

Indeed if M then we have

inlM p Id M p Id p

and analogously we dene the right injection using Conversely assume z

z x L inlx and y R inrx and M Using R and

N

R the task of nding an element of M may b e reduced to nding elements of

the following two types

u Id v Id u v

u Id v Id u v

These elements in turn can b e constructed using Subst and L R provided we

can show that the variables u and v are prop ositionally equal to the second and

third comp onents of some instance of inl and inr resp ectively Let us fo cus on the

rst type If u Id and v Id then using functional extension

ality and uniqueness of identity we nd that Id u p Id u Re

Id

is inhabited and using functional extensionality and an instance of we nd

that Id v p Id p is inhabited Therefore the triple u v is

Id

prop ositionally equal to inlu Re Similarly for the second type

The two equalities asso ciated with the copro duct type can only b e shown pro

p ositionally The reason is that in the ab ove construction IdUni gets applied to a

variable and thus no reduction is p ossible

Development in the setoid mo dels

The ab ove argument go es through immediately in the mo del S b ecause all the

constructions used are supp orted by this mo del It also go es through in S when we

Chapter Applications

replace the identity type by Leibniz equality which is substitutive by Prop

but due to the presence of an impredicative universe the denition of the terms

L

requires some explanation The terms Prf are again dened by

induction on the structure of If Prop we choose some arbitrary prop osition

if Prf P then we dene a function F N Prop with F tt and F P

and dene as

Prf P

L

p Prf p x N Prf F x I

where I x Prop p Prf xp is the canonical pro of of tt

Notice that this implies that each of the types j which all live in the

set

This in turn is not surprising empty context is inhabited by some element

since these types are generated from Prop N by and

For simplicity we assume that N is available in the target type theory if

we were to carry out its denition in terms of N and the identity type then

its underlying type would b e N N and the relation would b e Leibniz equality

restricted to pairs with sum equal to

Now let and b e families of setoids which arise as values of the interpretation

function so that is available The underlying type of the interpretation of

b ecomes

N

set set set

Notice here that the underlying type of a Leibniz equality is the extensional unit

type which disapp ears at the left of a function space

The injections inl and inr are dened using the default elements in the

obvious way The relation on this type singles out the elements which lie in the

image of either injection and on these elements uses the relations on and

The elimination rule applies to a family of setoids indexed over but by

denition of families its underlying type call it do es not dep end on The

input to the elimination rule thus consists of functions and and

set set

an element M of The conclusion is then obtained by case distinction on the

Chapter Applications

rst comp onent of M and application of either function to the second and third

comp onent resp ectively We omit the verications

Explicitly carrying out the construction in S is quite complicated and would

probably not clarify much The key step however where the elimination of func

tional extensionality takes place is quite instructive and relatively easy to explain

The need for functional extensionality in the denition of the eliminator R

came from the need for constructing an element of u v from an element

of u v for some u and v under the assumption that u u and v v are

p ointwise equal functions In TT one rst concludes that these functions are pro

I

p ositionally equal and then uses Subst within the mo del S the family comes

with a reindexer which allows to pass b etween bres over related elements so

that in order to pass b etween the two instances of one only needs relatedness of

u v and u v which is dened p ointwise

Some basic constructions with quotient types

In a series of b o oks a collective of French mathematicians has under the pseudonym

N Bourbaki attempted to put all of mathematics in particular geometry and

algebra on a solid axiomatic foundation based on set theory They emphasise

abstraction and mo dularisation the settheoretic enco ding of a concept is used as

little as p ossible and derived universal prop erties are employed instead Their rst

b o ok is on basic settheoretic constructions and contains a section on quotient

sets where some universal constructions with them are given As an application of

the quotient type formers we shall in this section try to redo these constructions in

a typetheoretic setting The emphasis on abstraction in the Bourbaki approach

makes it particularly apt for a development in type theory

As in various places higherorder logic is required we work in the impredicative

type theory S Parts of the development can also b e carried out using the quotient

types for rstorder MartinLof type theory given in Sect

Chapter Applications

Canonical factorisation of a function

L

A function x f x is a surjection if y x f x y holds f is an

L L

injection if x x f x f x x x holds Notice that due to the lack of the

axiom of choice it is not the case in type theory that every surjection has a right

inverse It is also not the case that if a function is b oth surjective and injective then

it has an inverse This would b e equivalent to the axiom of unique choice AC

which is not available in S We come back to this p oint later If y g y is

another function then we write g f for the function x g f x We extend

Leibniz equality to functions in the obvious way

Now let x f x b e any function and consider the equivalence relation

L

Rx x f x f x By denition of R the function f lifts to the quotient

type R that is we have

x R g x plug x in f using x x p Rx x p

R

and by QComp we get x f x g x Using Qind we readily establish that

R

g is injective and that hx x is surjective The thus obtained factorisation

R

of f into a surjection and an injection is initial among all such This means that

L

if x sx is surjective and y iy is injective and f i s then there

L L L

exists a unique up to function x R ux such that u h s and i h g

Indeed we obtain u as the lifting of s

Bourbaki now p oints out that the quotient R is in bijective corresp ondence

with the image of under f ie the subset of consisting of those elements which

have an inverse image in In fact they factor f as a threefold comp osition of

the classmap this bijection and the injection from the image into If we co de

the image of f in type theory as

L

Imf y Prf x f x y

We could also use a subset type former but since we havent explicitly describ ed it

in S we use types instead

Chapter Applications

then we obtain another factorisation of f into a surjection and an injection this

time through Imf It is easy to see that this factorisation is terminal up to

prop ositional equality Using either initiality or terminality we obtain a function

l R Imf

Since we lack unique choice we are however unable to dene an inverse to

this If we had AC in the sense of Sect we could construct an inverse as

L

follows Given u Imf we form the type z Rl x u and prove using

elimination that this type contains a unique element If P is a pro of term for this

then we can form u Imf ACP providing the desired inverse to l

Let us note that in the mo del S the ab ove mapping l is the function f itself

whereas an inverse to l would have to b e a mapping in the other direction which

need not necessarily exist for instance if is empty

set

We remark that if we had unique choice then we could dene quotient types in

the usual way as the subset of Prop consisting of equivalence classes We

also remark that if we use the type instead of to dene images then we have

of course choice but the pro jection from Imf to would not b e injective

Bourbaki also explains that any equivalence relation in the sense of Sect

R on can b e seen as b eing of the ab ove form using the function f which sends an

element x to the set of elements related to x In the impredicative type theory

S this can b e mimicked by putting f x x Rx x Prop We have

L L

x y f x f y Rx y true

by prop ositional extensionality In rstorder type theory S this is however

not p ossible

Some categorical prop erties of S

One may lo ok at the issue of factorisation from a more mo dern categorytheoretic

view as follows A regular epi is a surjection which can b e obtained as the co

equaliser of two functions Conversely a regular mono is an equaliser of a parallel

Chapter Applications

L

pair Let S b e the category obtained from S by taking closed types as ob

jects and functions up to prop ositional equality as morphisms The regular epis

L

in S are precisely those which can b e obtained from class maps by pre and

p ostcomp osing with isomorphisms notice that x x R is the co equaliser

R

of the two pro jections from x y Prf Rx x to Similarly the regular

monos are precisely those which can b e obtained in this way from pro jections out

of types with prop ositional second comp onent subset types Here prop osi

L

tional extensionality is needed In S the regular epis together with injections

and the surjections with regular monos each form a factorisation system p

The content of unique choice in the framework of S is precisely that all surjections

are regular epis and that all injections are regular monos We also remark without

L

pro of that S is regular p ie has nite limits and co equalisers given

by quotient types which are stable under pullback the verication of the latter

prop erty requires the dep endent elimination rule for quotients QIElim In ad

dition this category has the prop erty that the regular monos are classied by the

ob ject Prop It is also very easy to see that the category with the same ob jects

but with functional relations as morphisms again up to prop ositional equality is

a topos One only has to check that Prop is a p ower ob ject in the sense

of We have not pursued this categorytheoretic analysis any further in this

thesis b ecause it glosses over the distinction b etween denitional and prop ositional

equality which we consider as crucial in type theory

Subsets and quotients

Let b e a type and x x Rx x Prop an equivalence relation If x

P x Prop we may form the subset x Prf P x and denote by ix

x the rst pro jection which is injective by PrIr In rstorder type theory

In order to have a canonical choice for these nite limits it is advisable to identify

ob jects with equal comp onent and extensionally equal comp onents

set rel

Chapter Applications

eg S we must restrict to a predicate P which is singlevalued ie any two pro ofs

of which are prop ositionally equal or use the squash type former

On we have the induced equivalence relation R x x Rix ix Now

we can dene a bijective corresp ondence b etween the quotient of by R

R

and the image of under the class map from to R ie the type

L

z Rx z ix

R

In one direction from to we use the lifting of the obvious map from to

obtained by restricting the co domain of x ix The other direction is

R

more complicated In set theory ie in the development of one uses a right

inverse to the class map from to R In type theory we use the derived

dep endent elimination rule QIElim from Sections and We dene

L

z R x Prf z ix R

R

By elimination a term of type x R x gives rise to a function from to

and such term can b e dened using the dep endent elimination rule for quotients

provided we can nd a term M with

x M x x

R

together with a pro of of

L

x x p Prf Rx x Subst Qax p M x M x

R

We dene

L

M z x p Prf z ix x

R R

and the proviso is readily established using functional extensionality and the den

itions of and R The verication that the function obtained thus is the required

inverse is straightforward

In S this inverse would have b een obtained more easily by working in the

mo del directly rather than by using the internal language given by the syntax

for quotient types

Chapter Applications

Saturated subsets

The predicate P from ab ove is called saturated if for each x in P the whole equi

valence class asso ciated to x is contained in P more precisely if

x y P x Rx y P y

In it is noted that a subset is saturated i it is the inverse image under the

class map of some subset of the quotient set R This is true in type theory as

L

well Indeed if P is saturated then we dene P z R x P x x z

R

and we have that

L

x P x P x

R

using prop ositional extensionality and eectiveness of the quotient type as dened

in Sect Without eectiveness this example do es not go through even if

we would replace equality of predicates by biimplication We could also dene P

using lifting plug That b oth denitions agree requires again eectiveness

The other direction ie that an inverse image along the class map is saturated

is straightforward and only requires Qax

Bourbaki also denes the saturation of a subset P of as the inverse image of

the image of P under the class map We can show that this saturation is equal to

x x Rx x P x but again this requires eectiveness

In lo ccit saturatedness is extended to predicates with parameters ie rela

tions and then called compatibility Of particular interest is the case of functional

relations where the image along the class map denes a settheoretic analogue to

lifting plug Since due to the lack of unique choice functions and functional

relations are dierent in our type theory we cannot sensibly compare the two

denitions

In lo ccit a more general notion of lifting is also dened which takes a function

x hx with x x Rx x Qhx hx for equivalence relations R

and Q on and resp ectively into a function from R to Q In type theory

we do this by lifting the comp osition of h with the class map for Q

Chapter Applications

Iterated quotients

Let R b e as ab ove and z z R S z z Prop b e an equivalence relation on

the quotient of by R On we dene an equivalence relation T by T x x

S x x It is argued in that the quotient types RS and T are

R R

in bijective corresp ondence by relating elements which come from one and the

same element in by taking equivalence classes In type theory we can dene

the bijection by appropriately lifting the class maps In the mo del S the thus

obtained bijection is simply the identity on in accordance with the settheoretic

set

denition

Conversely if T is any equivalence relation on which has the prop erty that

Rx x entails T x x for x x then since T is saturated in b oth x and x

we can by the analysis in Sect dene an equivalence relation S on R and

nd that T is equal to the relation dened by precomp osing S with the class

map for R Bourbaki calls the thus obtained relation S the quotient of T by R

denoted T R One thus obtains a bijective corresp ondence b etween RT R

and T

That the ab ove line of reasoning go es through b oth in the settheoretic frame

work of and in type theory is a nice example for the emphasis on abstraction

and mo dularity in the Bourbaki approach

Quotients and pro ducts

Let R and S b e equivalence relations on and resp ectively An equivalence

relation R S on the pro duct is dened comp onentwise One has a bijective

corresp ondence b etween R S and R S One direction is

obtained by lifting the obvious map from to R S For the other

direction we consider the function x y x y R S and lift

RS

along y to obtain

w S x plug w in y x y using H R S

RS

RS

Chapter Applications

where H uses reexivity of R the denition of R S and Qax Now in order

to lift this function along x we must use Qind to replace w by an equivalence

class and the lifted function by its denition This metho d is of use when we

want to dene a binary function on a quotient type By giving such a function

on representatives and showing that it resp ects the relations comp onentwise one

has strictly sp eaking dened a function on R S Precomp osition

with the said bijection yields the desired binary function

This concludes the typetheoretic analysis of Bourbakis constructions with

quotients

Quotients and function spaces

Motivated by the last construction we may ask whether quotienting is compatible

with function spaces eg whether the type S is isomorphic to the quotient

of by the equivalence relation S u v x S u x v x

In the mo del S and also in set theory this is the case but apparently this is

not derivable from our syntax for quotient types The reason lies in the fact that

in top os logic where every surjection is isomorphic to a class map this prop erty

implies the internal axiom of choice IAC from Sect which is in general not

valid Recall that IAC means the prop osition x y P x y f

x P x f x for all types Parts of the following development also app ear

in a categorytheoretic guise in p

IAC is equivalent to saying that all surjections in the sense of Sect

split internally ie

L L

s y x s x y t y st y y

In order to obtain IAC from this one starts from P with x y P x y and

instantiates with s b eing the rst pro jection from x y Prf P x y to

Surjectivity of this function is precisely the assumed premise to IAC a

splitting of this surjection on the other hand gives the conclusion of IAC

Chapter Applications

That all surjections split internally is in turn equivalent to saying that if s

is surjective then so is s u s u for all types Let us

call following a surjection with this prop erty powerful To obtain an internal

splitting of p owerful s we instantiate with and apply surjectivity of s

to the identity on The other direction is easy

Now under the assumption that for every equivalence relation S on the types

S and S are isomorphic we nd that every class map

x x is p owerful This is the case in S Unlike in a top os it is however not

S

the case in S that every surjection is isomorphic to a class map For example the

surjection onto Imf describ ed ab ove Sect do es not have this prop erty

Thus we obtain that compatibility of quotienting with function spaces is not true

in a top os unless it satises IAC and thus is Bo olean and this can not b e derived

from our syntax for quotient types which except for the choice op erator can b e

interpreted in any top os The choice op erator on the other hand is of no use

here b ecause it only works for nonquotiented context and we want compatibility

of quotients with function spaces even if one of the involved types contains free

variables of quotient type

In view of this one may consider including the isomorphism b etween S

and S as a primitive in the syntax of quotient types

 is cocontinuousintensionally

In Mendler shows that in a lo cally cartesian closed category C every

functor CA CB sending u X A to f u X B preserves directed

f

limits and in particular limits of chains In view of the corresp ondence b etween

lo cally cartesian closed categories and extensional type theory this result

carries over to TT and by Thm also to TT The result has applications

E I

to enco dings of coinductive types in TT in fact the enco ding of streams as N

I

is a sp ecial case and to the intensional formulation of bisimilarity avoiding

the use of impredicativity ie the quantication over all bisimulations We

Chapter Applications

sketch the settheoretic instance of a sp ecial case of Mendlers result and give a

translation into TT The crux of this example is to demonstrate the p ower of

E

the conservativity theorem b ecause a direct pro of in TT seems to b e very

I

complicated

Parametrised limits of ! chains

As in Sect we use informal MartinLoftype theory to refer to sets and families

of sets and functions b etween them

Consider an chain of sets and functions

b b

b b b

i i

i

B B B B

i i

and let L b e its limit with pro jections L B This means that b

i i i i

for i and that for every compatible family x with x B and

i i i i i

b x x there exists a unique element hx ji i L with hx ji i x

i i i i i i i

This denes the limit up to isomorphism Recall that such limit L always exists

and that it may b e explicitly constructed as the set of compatible families by

L ff i B j i b f f ig

i i i

The pro jections are then dened by f L f i and if x is a compatible

i i i

family as ab ove then we dene the unique asso ciated element of L as

hx j i i i x

i i

The verication is routine

Now supp ose that the whole development so far dep ended up on some para

meter and that we form the disjoint union over all p ossible values of this

parameter This means that we consider the chain

b b

b

b b

i i

i

B B B B

i i

Here the notation B indicates the dep endency of B on and may b e used to

i

i

denote substitution This applies to the other metavariables L b as well i

Chapter Applications

are given by The functions b

i

b x B x b x B

i i i i

Now we have

Prop osition Mendler The set L with projections

f L f B

i

i i

is a limit of the chain of the b

i

Pro of Let x B with

i

i

b x x for i

i i

i

b e a compatible family By applying the rst pro jection to this equation and

induction on i we nd that all the rst comp onents x are equal to x

i

x x by applying and b for instance Therefore we have x B

i i i

i i

the second pro jection to Eqn This allows us to form

hx j i i L

i

It is routine to check that this satises the commutation requirement and that it

is unique among those 2

We remark that the pro ofrelevant character of is crucial here If we replace

for all and fg if B it by existential quantication ie B

i i

For otherwise then L is not a limit of the sequence of the B

i

example if and B fg i i then x is a compatible family

i

i

but L is empty This phenomenon is the gist of Hallnas denition of

bisimulation as an limit by replacing by

Development in TT

E

The ab ove pro of can b e formalised in TT the extensional type theory introduced

E

in Sect almost without changes We assume a chain dep ending on

Chapter Applications

i N B i

i N b i B Suci B i

and dene the type of compatible families by

CompFam f i NB i i NIdb i f Suci f i

For simplicity we identify the limit L with this type Now we make the following

denitions

B i N B i

b i N x B Sucix bx i x

CompFam f i NB i i NIdb i f Suci f i

If x x then x x y y Id x y

and establish in TT

E

x CompFam z CompFami NId z z i x i true

E B i

ie that CompFam is the limit of the B i Notice that if x CompFam

and i N then x i B i b ecause x is the pro of of compatibility and similarly

for elements of CompFam

Development in TT

I

Now from the conservativity theorem it follows immediately that the same

judgement holds in intensional type theory with functional extensionality and

uniqueness of identity TT provided the assumptions on B and b are valid in

I

TT However giving a direct derivation of this in TT is quite dicult b ecause

I I

the candidate z CompFam already contains instances of Subst so for

Chapter Applications

the verication we have to reason ab out terms containing instances of Subst More

precisely we rst construct a term

x CompFam i N Uniform Id x x i

I

z

N

using x the pro of that x is compatible and R Then we construct an element

of

x CompFam CompFamx

I

the rst comp onent of which of type i NB x i is given by

x CompFam i NSubst Uniformx i x i

I

B i

The verication now uses IdUni and the derived induction principle J and Ext

The author has sp end considerable time with Lego trying to formalise this com

pletely without succeeding The strategy is of course clear and is indeed dictated

by the pro of of Thm but carrying out all the necessary dep endent sub

stitutions in Lego turns out to b e extremely cumbersome The lesson is that

machinesupported reasoning in TT in order to b e ecient must b e supp orted

I

by tactics which could very well b e based on the conservativity theorem

One could eg imagine that one would conduct parts of a development in TT

E

This has the advantage that certain terms which can b e proven prop ositionally

equal are syntactically identied for instance Subst P M and Subst P M

for some M N and P P Id N N

Chapter

Conclusions and further work

We have compared extensional and intensional formulations of type theory and

argued for the need for adding extensional concepts to the latter These exten

sional concepts have b een justied using syntactic mo dels based on pure intensional

type theory

A natural next step would b e to develop an implementation of the syntactic

mo dels along the lines of Sect so as to gain more exp erience with them

We think although this may turn out to b e wrong that this implementation

task is essentially straightforward and merely requires a lot of time It is worth

mentioning that in a certain sense such an implementation already exists in the

form of the combinators for the syntactic mo dels dened in Lego Sect

but the variablefree syntax they supp ort is of very limited practical use

A more dicult and also theoretically challenging question in this direction

would b e to develop an implementation of the groupoid model This mo del as we

have presented it is based on classical extensional set theory and as such is not

amenable to a direct implementation However it seems that the fragment of the

group oid mo del which is actually taken on by the interpretation function from the

syntax do es admit an eective description which we consider worthwhile to work

out

The intended application of such an endeavourthe idea of interpreting pro

p ositional equality on types as isomorphism Sect in the absence of unique

ness of identityhas not b een pursued deeply in this thesis It app ears to b e quite

a promising sub ject For instance preliminary investigation has shown that an

extension of the typetheoretic denition of categories by additional axioms which

Chapter Conclusions and further work

allow one to conclude prop ositional equality of ob jects from isomorphism might

give rise to an elegant syntactic formulation of coherent isomorphisms Such a

notion of category is stable under the notions of functor and slice category and

contains the particular example FullU El if U El is a universe with prop osi

tional equality as isomorphism as mentioned in Sect However this universe

must app ear as a primitive in type theory In order to b e able to construct it

from more general principles some kind of pro ofrelevant quotient type former

would b e needed of which this universe would b e an instance

This leads us to another imp ortant question which has only b een marginally

addressed in this thesis the expressiveness of the source type theories with

extensional concepts wrt to the setoid mo dels in which they are interpreted It

seems that for every setoid in the mo del there exists an isomorphic one which is

taken on by the interpretation function and that every section of denable families

is denable This would work by exhibiting a given setoid as the quotient of its

comp onent by its comp onent The resulting relation on the quotient

set rel

type will however only b e equivalent not equal to the original one hence the

isomorphism Such a completeness result if it holds would not b e all to o useful

since we still do not know which types and terms are denable So what one would

really like to have is an overview over the principles and rules like countable choice

or compatibility of quotients with exp onentiation which are valid in the setoid

mo dels

More sp ecially the metatheory of quotient types should b e studied more thor

oughly We have made some attempts at that in the course of the examples in

Sect but these were far from exhaustive For instance it would b e interesting

to shed some light on the role of eectiveness of quotient types in applications

The interpretability of type formers in the setoid mo dels ought to b e studied

from a more general p ersp ective For instance one would like to know whether

the diculties with interpreting inductive types and universes in S are inherent

or stem from a awed denition of the mo del After two years of exp erience with

setoid interpretation the author tends towards the rst alternative but this is of

course only a p ersonal impression

App endix A

Lego context approximating S

Below is a sequence of Lego declarations which simulates quotient types pro of

irrelevance and functional and prop ositional extensionality as supp orted by S

cf App B This co de is slightly more general than S as Lego supp orts an innite

hierarchy of universes It should however b e p ossible to interpret the co de using

the metho d describ ed in Sect To b e absolutely safe one can of course avoid

the use of Lego universes when working with quotient types The co de do es not

contain subset types as those can b e simulated by types and it do es not supp ort

the nonstandard op erations extend and choice as the syntactic restrictions for

those cannot b e stated in Lego A version of this co de extended by pro ofs of certain

prop erties such as eectiveness of quotient types is part of the Lego distribution

Notice that Q refers to Leibniz equality

A Extensionality axioms

ImpfXYPropgXYYXQ X Y prop ositional extensionality Bi

IrfXPropgfxyXgQ x y pro of irrelevance Pr

ExtfATypegfBATypegfUVfaAgB ag

faAgQ F aG aQ F G functional extensionality

App endix A Lego context approximating S

A Quotient types

ATypeRAAProp all declarations are relative to A and R

QU Set R QForm R indicates the dep endency of QU on R

QU classAQUR QIntro

QU AxfaaAgR a a Q QU class a QU class a QAx

ElimfCSetgffACg QElim QU

faaAgR a a Q f a f a QU C

QU IndfPQUPropgfaAgPQU class a fqQUgP q QInd

CSetfACHfaaAgR a a Q f a f aaA QComp

QU it f H QU class a f a

Discharge A relativising the declarations to A and R

A Further axioms

One may add axioms approximating the substitutivity prop erty of Leibniz equality

Prop and the sp ecial case of Prop where N The corresp ond

ing denitional equalities can however only b e approximated by prop ositional

equalities which hamp ers their ecient use

SubstfATypegfBATypegfaaAgQ a aB aB a Q

Q Subst CompfATypegfBATypegfaAgfbB ag

Q Q Subst B Q refl a b b

extend fPPropgP Nat Nat

Comp fPPropgffPNatgfpPgQ f p extend f extend

App endix B

Syntax

For the convenience of the reader all of the rules app earing throughout this thesis

are summarised in this app endix Notice that some of the rules are incompatible

with each other eg IdUniI and UnivId Notice also that since the rules are

literally the same as in the text some app ear in abbreviated form and others do

not

Rules for TT

Empty Compr

x

M

x N

Form IdForm NForm

x Id M N N

M x

Var Conv

x x M

x M M x N

Intro Elim

x M x App M N x N

M N

NIntro NIntroSuc

N Suc M N

App endix B Syntax

x N

M x

z

x N p M x Suc x

s

N N

NElim

N

R M M N x N

z s

M

IdIntro

Re M Id M M

x y p Id x y

x M x xy xp Re x

N

N

P Id N N

IdElimJ

J M N N P x N y N p P

Equality rulesa selection

TRefl TSym TTrans

M M N x

CP i CSuc

SucM Suc M N x x

CCompr

x y

x x x M M

CAbstr

x x M x M

Rules for sematically dened denitional equality Sect

j M j N Sect j

EqTerm

M N

j j Fam

EqType

Ob C

EqCont

App endix B Syntax

Computation rules These are always understo o d under the premise that left and

right hand sides b oth have the indicated type

Beta

App x M N M x N x N

NatCompZero

N

R M M M x

z s z

NatCompSuc

N

R M M SucN

z s

N

M x N p R M M N x Suc N

s z s

IdComp

J M N N Re N

M x N x N y N p Re N

Rules for types and unit type

UnitForm UnitIntro

x x M N

UnitElimComp

R M N N R M M

x x M N M

Form Intro

x x pair M N x x

p x x p

x y x M x y pair x y P x x

Elim

R M P P

Comp

R M pair N O M N O pair N O

Rules for the extensional unit type

UnitForm UnitIntro

E E

M

E

UnitEq

M

E

Rules for the Calculus of Constructions

S Prop

PropForm ProofForm

Prop Prf S

x S x Prop

PropIntro

x S x Prop

PropEq

Prf x S x x Prf S x

App endix B Syntax

Universes

M U

UForm ElForm

U El M

S U x ElS T U

UIntro

S T U

UEq

El S T x ElS ElT

UIntroN UEqN

N U ElN N

Peanos fourth axiom

M Id Suc

N

Peano

Peano M

Further rules for the identity type

x y p Id x y x y p

N N

M N N Re N

P Id N N

IdElimJ

M N N P N N P J

M P Id M M

IdUniI

IdUni M P Id P ReM

Id M M

M

IdUniComp

IdUni M ReM Re ReM Id M M

U V x

x P Id U x V x

ExtForm

Ext U V P Id U V

x

x x

M M

P Id M M

N M

Leibniz

Subst M M P N M

App endix B Syntax

LeibnizComp

Subst M M Re M N N M

Rules for extensional type theory

M N

P Id M N

IdDefeq

M N

M N

P Id M N

IdUni

P Re M Id M N

M x

Eta

M x M x x

Rules for TT

M N P Id M N

I I

Form

M N P

I

M N P

I

Eq

M N P N

I

Rules for quotient types in TT

E

x x x x M

QEForm QEIntro

M

M N H M N

QEEq

M N

x x x M x x

x x p x x M x M x x

N

QEElim

plug N in M N

QEComp

plug N in M M N N

Rules for quotient types in TT

I

x x x x M

QIForm QIIntro

M

App endix B Syntax

M N H M N

QIAx

Qax H Id M N

x x x M x x

x x p x x H Id Subst Qax p M x M x

x

N

QIElim

plug N in M using H N

QIComp

plug N in M using H M N N

Pro of irrelevance

A Prop M N Prf A

PrIr

L

Pr IrA M N Prf M N

Rules for subset types

x P Prop

fgForm

fx j P g

M H Prf P M

fgIntro

M fx j P g

H

M fx j P g

fgWit

witM

M fx j P g

fgCor

corM Prf P witM

fgBeta

witM M corM H Prf P M

H H

x x Nprop

x P x Prop

p fx j P xg M p witp

N

fgElimNonprop

extend M N M

P

Same premises as fgElimNonprop and

H Prf P M

fgElimNonpropComp

extend M N M N N

P H

App endix B Syntax

Extensional concepts in S

A Prop M N Prf A

PrIr

M N Prf A

P Prop Q Prop H Prf P Q

BiImp

L

Bi ImpP Q H Prf P Q

U V x

L

x H Prf U x V x

Ext

L

ExtH Prf U V

Quotient types in S

s s Rs s Prop M

QForm QIntro

R M R

R

s M s N R

L

s s p Prf Rs s H Prf M s M s

QElim

plug N in M using H

R

QComp

plug N in M using H M N

R

R

M N H Prf RM N

QAx

L

Qax H Prf M N

R

R R

x R P x Prop

s H Prf P s

R

M R

QInd

Qind H M Prf P M

R

Rules for the choice op erator

There exists a nonquotiented context

and a type and a term N with

N and a syntactic context

morphism f such that M

N f and R f M R

QChoice

choiceM

App endix B Syntax

choiceM M

R

QChoiceComp

choiceM M

R

M R choiceM

QChoiceAx

choiceM M R

R

Rules for the identity type on universes

X Y U F Iso X Y

UnivId

UnivIdX Y F Id X Y

U

F IsoX Y M ElX

UnivIdEq

Subst X Y UnivIdF M F M ElY

UEl

UnivIdEq

UnivIdX X idX Re X Id X X

U U

Rules for squash types

M

2Form 2Intro

2 2M 2

M N 2

2Ax

2 axM N Id M N

2

x M x N 2

x x H Id M x M x

2Elim

plug N in M using H

2

plug 2N in M using H

2

2Eq

2 EqM N H plug 2N in M using H M N

2

Axioms of Choice and Unique Choice

IAC

x y Rx y f x Rx f x true

L

P Prf x y x y

AC

ACP

App endix C

A glossary of type theories

We use various type theories sometimes in parallel so that the following summary

which gives the name or symbol of each relevant type theory together with a brief

description and a reference to its rst app earance in the text may b e helpful

TT core type theory Dep endent type theory with dep endent pro ducts sums

natural numbers unit type and identity types p

Calculus of Constructions A part of TT together with an impredicative uni

verse In the CoC prop ositional equality may b e dened as Leibniz equality see

It is generally weaker than the identity type in S see b elow the two are

however equivalent p

TT The type theory TT together with the extensional concepts of functional

I

extensionality and uniqueness of identity The elimination op erator J is replaced

by the Leibniz principle Subst for convenience The extensional concepts are

merely assumed as constants p

TT The type theory TT together with the equality reection rule which identi

E

es denitional and prop ositional equality Also called extensional type theory

p

App endix C A glossary of type theories

TT Extension of TT with an intensional counterpart to equality reection

I

For every derivable judgement in TT there exists a decoration of this

E

judgement with Subst and derivable in TT p

D Type theory dened by the deliverables mo dela kind of subset interpret

ation of the Calculus of Constructions D supp orts all type and term formers of

the CoC and in addition pro ofirrelevance and subset types The symbol D is

also used for the deliverables mo del itself p

S Type theory dened by the nondep endent setoid mo del in Sect also

called S It includes the CoC and supp orts pro ofirrelevance subset types

functional and prop ositional extensionality and quotient types The extensional

concepts in S are based on Leibniz equality which in S is equivalent in strength

to the identity type S do es not supp ort universes except for the impredicative

universe of prop ositions There exists an extension of S which makes universes

available but extensional concepts are then restricted to types inside the universe

see Sect p

S Type theory dened by the dep endent setoid mo del in Sect It sup

p orts all type and term formers of TT including functional extensionality based

I

on the identity type Probably quotient types are also supp orted Unlike S the

type theory S caters for prop er type dep endency however it is not clear whether

a universe is supp orted p

Source type theory Type theory dened by a syntactic mo del eg S or D

Target type theory Type theory used to construct a syntactic mo del Usually

TT or the CoC

App endix D

Index of symbols

The following summarises the mathematical symbols used throughout the thesis

together with a brief explanation and a reference to their rst app earance in the

text

op

opp osite category

Sets category of sets and functions

Subst substitution op erator for identity types

Id identity type prop ositional equality

Re reexivity op erator for id types canon

ical element

Sym symmetry op erator for id types

Trans transitivity op erator for id types

Resp compatibility of id types with function

application

J elimination op erator for id types

IdUni uniqueness of identity pro ofs

judgement relation in type theory

true judgement expresing that is non

empty

comp osition of morphisms substitu

tions and terms

id identity morphism

App endix D Index of symbols

N type of natural numbers

Suc canonical elements of N zero and

successor

R elimination op erator for type former

syntactic identity

Int type of p ositive and negative integers

Real type of real numbers

Str type of streams over

Hd rst element of a stream

Tl tail of a stream

CoIt coiterator for streams

empty context

C a category category of contexts

terminal ob ject semantic equivalent to

the empty context

ObC ob jects of category

semantic context extension compre

hension

Fam families over interpretation of types

Sect sections of interpretation of terms

ff g semantic substitution

p display map

qf weakened substitution

M context morphism asso ciated to section

M

Hdf last comp onent of a semantic context

morphism

semantic weakening

Tel telescop es over

empty telescop e over

ev evaluation morphism

App endix D Index of symbols

App semantic application op eration

M semantic abstraction op erator

interpretation function

extensional unit type

v semantic counterpart to a variable

fegx Kleene application

Prop type of prop ositions

Prf P type of pro ofs of P

Prop semantic counterpart of Prop

Prf semantic counterpart of Prf

impredicative universal quantication

tt ff logical connectives dened in terms of

P true judgement expressing that Prf P in

nonempty

terminal pro jection

U typetheoretic universe

ElT type of elements of T U

underlying type of a

set

sp ecicationsetoidgroup oid

comp onent of a large setoid

type

comp onent of a deliverable

pred

relation comp onent of a setoidgroup oid

rel

comp onent of a family of

reindex

setoidsgroup oids

reexivity of setoidsgroup oids

re

symmetry of setoidsgroup oids

sym

transitivity of setoidsgroup oids

trans

axiom for

ax reindex

function comp onent

fun

element comp onent

el

compatibility comp onent resp

App endix D Index of symbols

f j P g subset type

M subset introduction

P

wit subset elimination

cor subset elimination

extend nonstandard op erator for subset types

M quotient introduction

R

R quotient type

plug quotient elimination lifting

Qax equality axiom for quotients

Qind induction for quotients

L

M N Leibniz equality

L EqM N semantic Leibniz equality

Ir op erator for pro of irrelevance Pr

Imp op erator for prop ositional extensionality Bi

Ext op erator for functional extensionality

intensional counterpart of equality

reection

judgement relation for TT

I I

judgement relation for TT

E E

j j interpretation of TT in TT

I E

connectedness relation

conn

f syntactic context morphism

extensional unit type

E

2 squash type and term former

least element in a domain

inhabitant of Id

W

least upp er b ound

Bibliography

Stuart Allen A nontypetheoretic account of MartinLofs types In Sym

posium on Logic in Computer Science

Thorsten Altenkirch Constructions Normalization and Inductive Types

PhD thesis University of Edinburgh

Thorsten Altenkirch Proving strong normalization of CC by mo difying

realizability semantics In Henk Barendregt and Tobias Nipkow editors

Types for Proofs and Programs Springer LNCS pages

Thorsten Altenkirch Zhaohui Luo et al Equality for categories Email

AprSep Unpublished

Michael Barr and Charles Wells Toposes Triples and Theories Springer

Michael Beeson Foundations of Constructive Mathematics Springer

J Benabou Fibred categories and the foundations of naive category theory

Journal of Symbolic Logic

J Benabou Theorie des ensembles empiriques Cahiers de p oetique com

pareeMEZURA No Institut National des Langues et Civilisations

Orientales rue de Lille Paris

Errett Bishop and Douglas Bridges Constructive Analysis Springer

Bibliography

N Bourbaki Elements de mathematique Livre I Theorie des ensembles

fascicule de resultats Hermann Paris

Ro d Burstall Programming with Mo dules as Typed Functional Program

ming In Proc Inter Conf on Fifth Generation Computer Systems Tokyo

Ro d Burstall and Butler Lampson Pebble a kernel language for mo dules

and abstract data types Information and Computation

Ro d Burstall and James McKinna Deliverables An approach to program

semantics in constructions In Symposium on Mathematical Foundations of

Computer Science also as LFCS technical rep ort ECSLFCS

A Carb oni Some free constructions in realizability and pro of theory

Journal of Pure and Applied Algebra to app ear

J Cartmell Generalized Algebraic Theories and Contextual Categories

PhD thesis Univ Oxford

Thierry Co quand Metamathematical investigations of a calculus of con

structions In Piergiorgio Odifreddi editor Logic and Computer Science

pages Academic Press Ltd

Thierry Co quand Pattern matching with dep endent types In Workshop

on Logical Frameworks Baastad Preliminary Pro ceedings

Thierry Co quand Innite ob jects in type theory In H Barendregt and

T Nipkow editors Types for Proofs and Programs Springer LNCS

Thierry Co quand and GerardHuet The Calculus of Constructions Inform

ation and Computation

R Crole Categories for Types Cambridge University Press

Bibliography

PierreLouis Curien Categorical Combinators Sequential Algorithms and

Functional Programming Pitman

PierreLouis Curien Alphaconversion conditions on variables and categor

ical logic Studia Logica

PierreLouis Curien Substitution up to isomorphism Fundamenta Inform

aticae

N J Cutland An Introduction to Recursive Function Theory Cambridge

University Press

N G de Bruijn A survey of the pro ject Automath In J P Seldin and J R

Hindley editors To H B Curry Essays on Combinatory Logic Lambda

Calculus and Formalism pages Academic Press London

N G de Bruijn Telescopic mappings in typed lambda calculus Information

and Computation April

Gilles Dowek et al The COQ pro of assistant users guide V Rapp ort

technique INRIA Ro cquencourt Dec

Peter Dyb jer Inductive sets and families in MartinLofs type theory and

their settheoretic semantics In G Huet and G Plotkin editors Logical

Frameworks pages

Peter Dyb jer and Herb ert Sander A functional programming approach to

the sp ecication and verication of concurrent systems In Specication and

Verication of Concurrent Systems pages Springer Work

shops in Computing

Thomas Ehrhard Une semantique categorique des types dependants Ap

plication au Calcul des Constructions PhD thesis Universite Paris VI I

Bibliography

Rob ert Constable et al Implementing Mathematics with the Nuprl Develop

ment System PrenticeHall

Solomon Feferman Theories of nite type In Jon Barwise editor Handbook

of Mathematical Logic chapter D NorthHolland

G Huet and A Sabi Constructive category theory Draft presented at the

Joint CLICSTYPES Workshop on Categories and Type Theory Gothen

burg Jan

DM Gabbay and RJGB de Queiroz Equality in lab elled deductive sys

tems and the functional interpretation of prop ositional equality In P Dekker

and M Stokhof editors Proceedings of the Ninth Amsterdam Col loquium

pages

Robin Gandy On the axiom of extensionality I Journal of Symbolic Logic

Robin Gandy On the axiom of extensionality I I Journal of Symbolic Logic

Herman Geuvers and Benjamin Werner On the ChurchRosser prop erty for

expressive type systems and its consequences for their metatheoretic study

In Proceedings of the th Annual IEEE Symposium on Logic in Computer

Science

Healfdene Goguen A Typed Operational Semantics for Type Theory PhD

thesis University of Edinburgh

Healfdene Goguen and Zhaohui Luo Inductive data types Wellordering

types revisited Technical Rep ort ECSLFCS LFCS April

Rob ert Goldblatt Topoi The Categorial Analysis of Logic NorthHolland revised edition

Bibliography

R Harp er and J C Mitchell On the type structure of Standard ML ACM

Trans Programming Lang and Systems Earlier ver

sion app ears as The Essence of ML in Proc th ACM Symp on Principles

of Programming Languages pp

R Harp er J C Mitchell and E Moggi Higherorder mo dules and the

phase distinction In Conference record of the th ACM Symposium on

Principles of Programming Languages POPL pages San Fran

cisco CA USA

Susumu Hayashi Singleton union and intersection types for program ex

traction Information and Computation

Martin Hofmann Elimination of extensionality for MartinLof type theory

In H Barendregt and T Nipkow editors Types for Proofs and Programs

Springer LNCS

Martin Hofmann A simple mo del for quotient types In Proceedings of

TLCA Edinburgh Springer LNCS To app ear

Martin Hofmann On the interpretation of type theory in lo cally cartesian

closed categories In Proceedings of CSL Kazimierz Poland September

To app ear as Springer LNCS

Martin Hofmann and Thomas Streicher A group oid mo del refutes unique

ness of identity pro ofs In Proceedings of the th Symposium on Logic in

Computer Science LICS Paris

Wolfgang Hornung Entwicklung eines LEGOKontexts f ur die Verikation

kategorieller Aussagen Diplomarb eit UniversitatErlangen

GerardHuet Cartesian closed categories and calculus In Guy Cousineau

et al editors Combinators and Functional Programming Languages volume

of LNCS pages Springer Berlin Heidelb erg New York

Bibliography

J M E Hyland The eective top os In A S Troelstra and D van Dalen

editors The L E J Brouwer Centenary Symposium pages North

Holland

J M E Hyland P T Johnstone and A M Pitts Tripos theory Mathem

atical Proceedings of the Cambridge Philosophical Society

Martin Hyland and Andrew Pitts The Theory of Constructions Categorical

Semantics and ToposTheoretic Mo dels In Categories in Computer Science

and Logic AMS

B Jacobs E Moggi and Th Streicher Relating Mo dels of Impredicative

Type Theories In D Pitt et al editor Proc Conf Category Theory and

Computer Science Paris France pages Springer LNCS vol

Bart Jacobs Quotients in simple type theory manuscript

Bart Jacobs Categorical Type Theory PhD thesis University of Nijmegen

Bart Jacobs Comprehension categories and the semantics of type theory

Theoretical Computer Science

Gilles Kahn The semantics of a simple language for parallel programming

Information Processing

FrancoisLamarche A Prop osal ab out Foundations I manuscript

Joachim Lambek and Philip Scott Introduction to HigherOrder Categorical

Logic Cambridge University Press

Lars Hallnas An intensional characterisation of the largest bisimulation

Theoretical Computer Science

Bibliography

FrancoisLeclerc and Christine PaulinMohring Programming with Streams

in COQ A Case Study The Sieve of Eratosthenes In H Barendregt and

T Nipkow editors Types for Proofs and Programs Springer LNCS

A Levy Basic Set Theory SpringerVerlag

Horst Luckhardt Extensional Godel Functional Interpretation A Consist

ency Proof of Classical Analysis volume of Lecture Notes in Mathemat

ics Springer Berlin

Z Luo Program sp ecication and data renement in type theory In S Ab

ramsky and T S E Maibaum editors TAPSOFT Proccedings of the

International Joint Conference on Theory and Practice of Software Develop

ment Volume Col loquium on Trees in Algebra and Programming LNCS

pages

Zhaohui Luo An Extended Calculus of Constructions PhD thesis Uni

versity of Edinburgh July

Zhaohui Luo Type Theory Logic and Computer Science Course notes for

the LFCS Postgraduate Course on type theory January

Zhaohui Luo Computation and Reasoning Oxford University Press

Zhaohui Luo and Rob ert Pollack LEGO pro of development system Users

manual Technical Rep ort ECSLFCS LFCS Computer Science

Dept University of Edinburgh

Saunders Mac Lane Categories for the Working Mathematician Springer

Per MartinLof A theory of types manuscript

Bibliography

Per MartinLof An intuitionistic theory of types Predicative part In H E

Rose and J C Shep erdson editors Logic Col loquium pages

NorthHolland

Per MartinLof Intuitionistic Type Theory Bibliop olisNap oli

Per MartinLof Mathematics of innity In P MartinLof and G Mints

editors Proc of COLOG Tallinn USSR pages Springer LNCS

vol

Per MartinLof Nondeterministic denitions in type theory Lecture notes

by Peter Dyb jer March

James McKinna Deliverables A Categorical Approach to Program Devel

opment in Type Theory PhD thesis University of Edinburgh

PaulAndre Mellies Typed calculi with explicit substitutions may not

terminate In Proceedings of TLCA Edinburgh LNCS to app ear

N P Mendler is co continuous Manuscript

N P Mendler Inductive Denition in Type Theory PhD thesis Cornell

University

Nax P Mendler Quotient types via co equalisers in MartinLofs type theory

in the informal pro ceedings of the workshop on Logical Frameworks Antibes

May

Robin Milner and Mads Tofte Commentary on Standard ML MIT Press

John C Mitchell and Gordon D Plotkin Abstract types have existen

tial type ACM Transactions on Programming Languages and Systems

July

Bibliography

Ieke Mo erdijk and Saunders Mac Lane Sheaves in Geometry and Logic A

First Introduction to Topos Theory Springer

Eugenio Moggi Computational lambda calculus and monads In th Sym

posium on Logic in Computer Science IEEE

Eugenio Moggi A categorytheoretic account of program mo dules Math

Struct in Comp Sci

B NordstromK Petersson and J M Smith Programming in MartinLofs

Type Theory An Introduction Clarendon Press Oxford

Adam Obtulowicz Categorical and algebraic asp ects of MartinLof type

theory Studia Logica

Christine PaulinMohring Extracting F s programs from pro ofs in the

calculus of constructions In Principles of Programming Languages POPL

pages ACM

Christine PaulinMohring Extraction de programmes dans le Calcul des

Constructions PhD thesis UniversiteParis VI I

Andrew Pitts Categorical logic In Handbook of Logic in Computer Science

Vol VI Oxford University Press to app ear

Gordon Plotkin Generic notes on domains Notes for lectures from several

terms at the University of Edinburgh

Randy Pollack A formalisation of Tarskis xp oint theorem in Lego Part

of the Legodistribution and p ersonal communication

Eike Ritter Categorical Abstract Machines for HigherOrder Typed Lambda

Calculi PhD thesis University of Cambridge

A Salvesen and J M Smith The strength of the subset type in MartinLofs

type theory In IEEE Symposium on Logic in Computer Science

Bibliography

D Sannella Formal program development in Extended ML for the working

programmer In Proc rd BCSFACS Workshop on Renement Hursley

Park pages Springer Workshops in Computing

D S Scott Identity and existence in intuitionistic logic In M P Fourman

C J Mulvey and D S Scott editors Applications of Sheaves pages

SpringerVerlag

Rob ert A G Seely Lo cally cartesian closed categories and type theory

Mathematical Proceedings of the Cambridge Philosophical Society

Jan Smith The indep endence of Peanos fourth axiom from MartinLofs

type theory without universes Journal of Symbolic Logic

Thomas Streicher A verication metho d for nite dataow networks with

constraints applied to the verication of the alternating bit proto col Tech

nical Rep ort MIP UniversitatPassau

Thomas Streicher Correctness and Completeness of a Categorical Semantics

of the Calculus of Constructions PhD thesis UniversitatPassau

Thomas Streicher Semantics of Type Theory Birkhauser

Thomas Streicher Semantical Investigations into Intensional Type Theory

Habilitationsschrift LMU M unchen

Alfred Tarski A latticetheoretical xp oint theorem and its applications

Pacic Journal of Mathematics

Paul Taylor Recursive Domains Indexed Category Theory and Polymorph

ism PhD thesis University of Cambridge

AS Troelstra Asp ects of constructive mathematics In Jon Barwise ed

itor Handbook of Mathematical Logic chapter D pages North Holland

Bibliography

AS Troelstra On the syntax of MartinLofs type theories Theoretical

Computer Science

AS Troelstra and D van Dalen Constructivism in Mathematics An In

troduction volume I NorthHolland

AS Troelstra and D van Dalen Constructivism in Mathematics An In

troduction volume I I NorthHolland

David Turner A new formulation of constructive type theory In P Dyb jer

editor Proceedings of the Workshop on Programming Logic pages

Programming Metho dology Group Univ of Goteborg May

FW von Henke A Dold M Grosse H Rue D Schwier and M Strecker

Construction and deduction metho ds for the formal development of software

In Arbeitsberichte des KorsoProjekts Springer LNCS to app ear

P L Wadler Comprehending monads Mathematical Structures in Com

puter Science

Gavin C Wraith A note on categorical datatypes In Proc Conf Category

Theory and Computer Science Manchester UK pages Springer

LNCS vol