Download - Free Documents

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Structure (mathematical logic) wikipedia , lookup

Axiom of reducibility wikipedia , lookup

Set theory wikipedia , lookup

Truth-bearer wikipedia , lookup

Natural deduction wikipedia , lookup

Curry–Howard correspondence wikipedia , lookup

Principia Mathematica wikipedia , lookup

Type safety wikipedia , lookup

Homotopy type theory wikipedia , lookup

Intuitionistic type theory wikipedia , lookup

Transcript
Syntax and Semantics of Dependent Types
Martin Hofmann
Introduction
Dependent types are types which unlike simple types, such as products, function spaces, or
natural numbers, depend on or vary with values. An example of a dependent type is a type of
vectors or arrays Vec M of a given length M N over some type . Its objects are nil Vec and
Cons U V Vec Suc M where U and V Vec M . We can now consider a function which given x
N returns a vector over N of length x and all entries . This function then has the type x NVec
Nx a type of functions with the property that the type of the result depends on the argument.
The same algorithm could also be typed as N List N. The point of the dependent typing is
that it reveals more information about the function. Another example of this kind is the
exceptionfree head function for vectors Hd x NVec Suc x which yields the rst entry of a
vector. The typing prevents the unwanted case that Hd gets applied to the empty list. In this
way the dependent typing circumvents the need for partial functions in certain cases. Another
source for type dependency comes from type variables and type universes. For instance, the
type of monoids with carrier X
MON X def X X X
X
is a type depending on X . Type variables such as X above can be treated as ordinary
variables using universes, that is types containing names for other types as members. The
function constructing the free monoid on a type X would then be given the type
X U MON List X
where U is such a universe. The third important source for dependent types comes from the
propositionsastypes analogy under which propositions in constructive logic are seen as
types, namely the type of their proofs. For instance, a proof of consists of a proof of and a
proof of a proof of consists of a procedure which
transforms a hypothetical proof of into a proof of . Therefore, conjunction and implication can
be identi ed with cartesian product and function space, respectively. Under this
correspondence, predicates, i.e. propositional functions become dependent types. We will
describe how to view the atomic equality predicate and universal and existential quanti cation
as types and type formers. In fact universal quanti cation corresponds to the type introduced
above. If propositions are ordinary types they can be part of other types. For instance, we
can enrich the abovede ned type of monoids of monoids by a proposition stating associativity
and neutrality
MON X def X X X e X x y z X x y z x y z x X e x x x e e The type former is a generalisation of
the cartesian product to dependent types and corresponds under the propositionsastypes
analogy to existential quanti cation. An object of the above generalised signature thus
consists of an object of type X X X an object e of type X a proof that is associative and e is
neutral The main aim of this article is not so much to explain how to use dependent types to
formalise constructive mathematics or to do program development and speci cation, but
rather to introduce the reader to a tool for the metatheoretic study of dependent type theory
categorytheoretic semantics. By semantics we understand a compositional assignment of
mathematical objects to syntactic objects, for instance sets or sets to types and settheoretic
functions to open terms of the types. Such interpretation is performed with the aim of
establishing consistency or conservativity of certain typetheoretic constructs, or simply in
order to explain, motivate, and justify them. Due to type dependency the veri cation that such
an interpretation indeed validates all the rules of type theory can be quite involved which is
why it has proven useful to de ne a general abstract notion the categorytheoretic semantics,
which is proven sound and complete once and for all. Then in order to obtain an
interpretation of type theory one onlyquot needs to check that one has an instance of the
semantic notion. The semantics is not surprising like maybe the settheoretic semantics for
rstorder logic in that we have an almost trivial completeness property like in the case of
Heyting algebra semantics for intuitionistic logic. The point is that the soundness theorem is
nontrivial and therefore some work can be saved when presenting a translation of the syntax
as a model construction.
. Overview
In the next section we give the syntax for an extensible calculus of dependent types which
encompasses various namedquot type theories like MartinLofs type theory or the Calculus of
Constructions. In xx. amp . we introduce presyntax and syntactic context morphisms. Both
are auxiliary syntactic notions required later to de ne the interpretation function and to
construct a term model. x contains the material on categorytheoretic semantics. It introduces
categories with families which provide a categorytheoretic counterpart of type dependency
and form the backbone of the semantics. We compare this notion to related concepts and
identify the additional structure required to model the type and term formers. Section ends
with the interpretation of the syntax in the semantic structures. Finally, x is devoted to an
extended application of the material we give an interpretation of types as variable setsquot
presheaves and use it to establish conservativity of MartinLofs Logical Framework over
ordinary type theory. Every section or larger subsection except the last one ends with several
exercises which either contain de nitions or proofs which are similar to previously given ones
and are required later, or contain applications of the material. The last section contains
instead an overview of the literature on applications of semantic methods to dependent type
theory as a suggestion for further reading. This article is selfcontained except for the
presupposition of some very basic category theory in xx amp which have not been included
as very good introductions are readily available. The required notions are summarised in the
beginning of x.
Formal systems for dependent types
A theory of dependent types is a formal system which mainly allows one to derive
judgements of the form M the term M has type and type is a type. As types may contain
terms, typing a ects typehood and both kinds of judgements must be de ned simultaneously.
For instance, Vec M is a type if is a type and M N. Furthermore, we usually want a notion of
de nitional equality to be built into the theory, for example we wish to consider N and N as de
nitionally equal terms and hence Vec and Vec as de nitionally equal types if M Vec then also
M Vec . This leads to two more forms of judgement M N M and N are de nitionally equal
terms of type and type and are de nitionally equal types. Finally, we must keep track of the
types of the free variables occurring in a judgement we cannot assert x y N unless we know
that x N and y N. Since such declarations may depend on each other like in x N y Vec Nx it is
convenient to make all judgements
relative to a list of variable declarations including at least the free variables occurring inside
the judgement. Such lists of declarations are called contexts and sometimes also type
assignments. Intuitively, a context x xn n is wellformed if each i is a type in the context x xi i
and the xi are pairwise distinct. So typehood and thus typing a ects context validity and we
nally arrive at six kinds of judgements
c txt type M c txt type M N
is a valid context is a type in context M is a term of type in context and are de nitionally
equal contexts and are de nitionally equal types in context M and N are def. equal terms of
type in context .
Wellformedness and equality of contexts can be de ned in terms of the other judgements, but
it is technically easier to include them as primary notions. Regardless of which rules we later
introduce to describe particular type and term formers such as the natural numbers or types
we always have the following structural rules. Rules for context formation CEmp type x c txt
CExt
The variables x and y in rules CExt and CExtEq are assumed to be fresh. The variable rule x
c txt Var x x Rules expressing that de nitional equality is an equivalence relation
c txt c txt type CExtEq x y c txt
c txt CEqR c txt CEqS c txt c txt c txt CEqT c txt
c txt
type TyEqR type type TyEqS type type type TyEqT type M TmEqR M M M N TmEqS N M M
N N O TmEqT M O Rules relating typing and de nitional equality M
c txt M
type
TmConv
c txt type TyConv type
For convenience cf. E. below we also introduce the following weakening and substitution
rules where J ranges over one of the judgements M , type, M N , type. J type Weak x J x J U
Ux J Ux Subst
Here J Ux and similarly Ux denotes the capturefree substitution of U for x in J . This means
that bound variables in J are systematically renamed so as to prevent any free variables in U
from becoming bound in J Ux. We will henceforth consider all contexts, types, and terms as
equal if they agree up to names of bound variables and assume the existence of a
capturefree substitution function on these equivalence classes. One can use a de Bruijn style
presentation of the syntax to avoid this identi cation. A good reference is Huet . The de Bruijn
presentation gives rise to canonical representatives of the equivalence classes and yields an
algorithm implementing capturefree substitution.
We will henceforth refrain from writing down congruence rules. The rule Eq expresses that
de nitional equality is respected by the former. introduction. Dependent function space The
dependent function space also called dependent product or type corresponds to the
settheoretic notion of cartesian product over a family of sets iI Bi which has as elements
functions mapping an index i to an element of the corresponding set Bi. There is no de nitive
set of type formers and new ones can be invented as needed. x type x type F type . We
present several of them to give an idea of the general pattern. Elements of a type are
consumed using application like in the settheoretic situation where an element of iI Bi and a
speci c i I gives an element of Bi M x N App x M. Type formers Type and term formers are
introduced by formation. To form elements of the type we have the introduction rule with
associated congruence rule . x M x M x I .. viz. Such rules are silently understood for every
type and term former we will introduce. x type IEq x M x M x So to give an element of x one
must give an element of x in the presence of a variable x of type . and equality rules. .
elimination. The congruence rule IEq expresses that de nitional equality preserves
introduction . x type Eq x x type The rst rule expresses that a dependent function space
consists of a type possibly depending on other types recorded in and a type depending on
and . N Nx E .. In type theory this is expressed as follows type . The variable x becomes
bound in x and thus this type is subject to the convention on renaming of variables set out
above. . x M M type .
Thus when the type is used in this way then both sides of C are indeed de nitionally equal in
the proper sense of the word. The attribute de nitionalquot for en equation like C is certainly
arguable. . y H Pair x x. M type N Mx .Notice that the square brackets in the typing
annotation x are an integral part of the term former for application and indicate the binding of
x in . y in H become bound inside R as indicated by the square brackets.. M Mz Here the
variable z in and the variables x. we will use it to motivate further de nitional equalities. Now
we encounter a source for de nitional equality applying a function x M to a term N results in
M with x replaced by N x M x N C App x x M . b j i I b Bi g whose elements consist of an
index i and an element of the corresponding set Bi. not only the conversion rules as in the
case of simplytyped lambda calculus. N M Nx Nx Notice that substitution plays a more
prominent role in dependently typed calculi as it is needed to formulate even the typing rules.
However. yz M x E R z x x y H. N x The elimination rule looks a bit complicated at rst sight .
see MartinLof . z x type . x type F I x type Pair x M. In type theory the corresponding
formation and introduction rules look as follows. A more pragmatic explanation for C is that in
applications one often uses abstraction as a means for making de nitions and application to
instantiate a de nition. It is motivated by the understanding of x M as a canonical element of x
and application as a derived concept de ned by equation C. For us the distinction between
canonical and noncanonical elements is not important. The idea behind R is that in order to ..
x . If we are given a family of sets BiiI we can form the set iI Bi def fi. This view becomes
important if one wants to see type theory as a foundation of constructive mathematics which
accordingly is to be justi ed by a philosophical argument rather than via an interpretation in
some other system. Dependent sum The next type former we introduce is the type or
dependent sum corresponding to disjoint union in set theory.
A constructive proof of an existential statement x P x consists of an element M of the
witness together with a proof that P M . M Pair x U. i. N Pair x z R z x x . As an example we
show how to de ne projections for the type.give a possibly dependent function out of x . . In
this case. x . This is expressed by the following de nitional equality R z x x . Pair x M. Ny Pair
x z C which says that a function on x de ned using the eliminator R behaves on canonical
elements as speci ed by the argument H . the pairs. viz. y y.and types correspond to ordinary
nondependent function space and cartesian product.e. This is called weak elimination. A
second projection can be de ned similarly M def R z x zx x . One can then still de ne the rst
projection. x type. when type and type we write def x and def x indicating that in these cases
the . Important special cases of x and x arise when does not actually depend on . Thus under
the propositionsastypes analogy the type is the counterpart to existential quanti cation. M
Now. M M Notice that the de niens the righthand side is welltyped by virtue of rules C and
TyConv which allow us to conclude . y H. and M x . V the rule C gives M U as expected. yx
One can restrict the elimination operator R to those cases where the type does not depend
on x . Pair x M. respectively. but no longer the second one.e. We de ne M def R z x x . it is
enough to specify it on canonical elements. N H Mx. Assume type. see Luo . y x. y y Pair x x.
. that is an element of P M . y H. in the particular case where M is canonical. i.
Natural numbers An example of a basic type is provided by the type of natural numbers
given by the rules c txt NF N type c txt NI N M N NIS Suc M N The elimination rule is similar
to the one for types. n N type Hz n . x Hs. Hz n RNN Hz . we can de ne addition as follows M
N def RNNN N. For instance. n N. x Hs. x Hs. n N. n n NC N R nN Hz . in order to de ne a
possibly dependent function on N it is enough to give it on the canonical elements and Suc M
.. . In the case of Suc M the function may be called primitive recursively for M . x Hs. n N.
RNN Hz . n by mfold application of rule NCS followed by NCZ.. M N n andwriting n for the
closed term Suc z Suc we have n times nmmnN for all settheoretic natural numbers m. M Mn
n The primitiverecursive behaviour of RN is expressed by the following two rules for de
nitional equality RNN Hz . Suc M Suc M n NCS n RNN Hz . n N. Suc M n Hs Mn. x Hs Suc
nn M N NE RNN Hz . M x Suc M n n The elimination rule for natural numbers allows for both
the de nition of functions by primitive recursion and proof of properties of the natural numbers
by mathematical induction. We will see an example of the use of mathematical induction
below. n N. . n N. n N. x NSuc x. n N. x Hs. x Hs.
. not a proposition. Identity types As we have explained. We write J if we want to emphasise
that a judgement holds in the empty context.. i. like the de nition of the second projection for
types above. using RN or R . Leibniz principle are all . In order to enable equality reasoning
inside type theory one is therefore lead to introduce a type corresponding to equalitythe
identity type. transitivity. For doing proofs within the theory obviously the syntactic sugar is
unavoidable. It is always an important question whether such shorthands should be treated
formally or informally.. we have Re M Id M. N provided M N . its use is unavoidable. Its main
purpose is to facilitate the construction of inhabitants of types. that is. In implementations of
type theory many more such conventions are being used and sometimes they are even
made part of the o cial syntax. we cannot have de nitional equalities as assumptions in a
context. M We call two terms M. The further properties like symmetry. N type IdF and the
identity types have canonical inhabitants corresponding to re exivity M IdI Re M Id M. and not
a type. So far we only know that propositional equality is a re exive relation. For instance.
Also. we may write x M or even xM instead of x M . N is inhabited.e.. de nitional equality is
the congruence generated by the computational equations like NCZ and C. and therefore
cannot be established by induction. . However. For every two terms of the same type we
have a not necessarily inhabited type of proofs of their equality M N Id M. de nitional equality
is merely a judgement. Notation We will henceforth freely suppress type annotations if this
increases readability. By the implicit congruence rules and rule TyConv propositional equality
extends de nitional equality. Here we have decided to have a syntax as explicit as possible
so as to facilitate its metatheoretic study. that is. We sometimes omit a prevailing context and
thus write J instead of J . If contains among others the free variable x then we can write x to
emphasise this and use the notation M for Mx in this case. N propositionally equal if the type
Id M. in some examples.
M. zy. and congruence properties of propositional equality in the usual way. i. P Mx.y . y
type .pId x. M.pId x.y x h xh . U N We can derive a similar congruence property in the case
that depends on x. Streicher .y .pId x. Re M Mx. If H M then we can construct an element
Subst x P. N and P Id M. Re x. for this and other derived properties and combinators for
propositional equality we refer to Nordstrom. Now h xh is an inhabitant of x x. From Subst we
can derive symmetry.y z H . Petersson. My. Re U M Id U M . M.y z H . Re M x IdC H Mz Mx.
We have now collected enough material to carry out the promised example of a proof by
induction.pId x. Ny. P . x. M.y z H . We wish to construct an element of the type m N Id Nm .
We de ne x . y def x y Recall that abbreviates x . H of N as follows. m type . Re M p x RId . p
Id x. M.e. M. My. Re zp M N P Id M. if x U x and P Id M.U xP. N . and that we are given two
propositionally equal terms of type . N. z H zx. Pp x and the associated equality rule RId . H
def App RId . transitivity. N then Resp . N. y . H H M . N IdE RId .. x .y .consequences of the
following elimination rule for identity types type . We demonstrate how to derive Leibniz
principle from RId Suppose that x x type. For example. M. P def Subst x Id U M . and Smith .
so Subst x P. Re M p The eliminator RId is an induction principle like RN and R which
roughly states that every element of an indentity type behaves as if it were a canonical one of
the form Re M . H N x and from IdC and C we get the derived rule Subst x Re M . x U . y . p
Id x. Hofmann a.y .
Petersson. h Resp N. . So is now a type with a distinguished free variable m. m N. There
exists another formulation of identity types in which one may conclude M N from P Id M. h m
Resp N. The metatheory and the strength of the present and other formulations of the
identity type have been analysed in Hofmann a. Notice that we have n N Re N n Id N n. We
remark that propositional equality does not a ect the de nitional one which even in the
presence of identity types remains con ned to intensional equality. type theory with equality
re ection is called extensional type theory.where is the addition operation de ned above.N x
NSuc x . Since the proof P is discarded upon application of this rule.N x NSuc x . type theory
together with identity types as de ned here is called intensional type theory. This rule is
called equality re ection and makes it possible to derive de nitionalquot equalities by
induction and thus makes it extensional. This is expressed by the following two rules c txt UF
M U ElF U type El M type So if M U is such a codequot then we can form the type associated
to M . and Smith for more examples of this kind. So far the universe does not contain any
closed codes. h Suc m and we can nally conclude m N RN N tRe N . we refer to Nordstrom.
see MartinLof . namely El M . By NCZ we have Re N Now by NES we have m N Suc m Id N
Suc m. See also E. m m N.. n immediately by NEZ and the de nition of . Suc m type
Therefore. de nitional equality then rather called judgemental equality and thus typing
become undecidable.. m m Again. Let us de ne m N def Id N m . Therefore. N . h.. Universes
A universe is a type containing codes for types. Therefore. m.Streicher . This .
may be achieved by stipulating that the universe be closed under certain type formers.Ty is
not valid under the canonical interpretation of .E App sEl SEl T M.. This syntax. One does not
need the new application and abstraction operators and App then. Suc . closure under types
is expressed by SU . A nal important closure property for universes is impredicative quanti
cation type . s El S T U U S. Also. N El T Ns U. and RN witnessing that El N behaves like N.
N M Ns El T Ns A more economic syntax for universes closed under types is obtained if we
replace the last three above rules by a single new type equality S. s El S T is the product of
the El T rather than behaving like it. x T U U x T U . Again we could instead impose the
equality El N N type if the type theory already contains natural numbers.I s El S M El T El S.
In a similar way closure under other type formers including another universe can be
stipulated. has the disadvantage that it is no longer the case that equal types share the same
outermost type former.C App sEl SEl T s El S M El T . Closure under natural numbers is
described by c txt UN NU and further rules introducing term formers . an auxiliary property
required to establish the subject reduction property for an untyped rewrite system derived
from de nitional equality. see Streicher and the example following Def. This makes it more di
cult to show that the type formers are injective. s El S T U . in many models rule U.Ty El S.
which in fact is often used in the literature. N El T Ns App sEl SEl T s El S M El T . s El S T s
El S El T type which states that El S. . s El S T U U. s El S M El T U. s El S T M El S. For
instance. s El S T N El S U.
For instance. In particular can be U itself and we can form terms like polyone c U s El cc
where El polyone has the closed inhabitant C U x El C x El polyone the polymorphic identity
function known from polymorphic lambda calculus. For instance. N El T Nx UC App x El T x
M El T . We can now write a function F X U MON X SEM X which forgetsquot the neutral
element. An application of this pattern to semantics of modules in functional languages is
Harper and Mitchell . Universes are employed for modularisation and abstraction. z . Under
the propositionsastypes analogy we can view a universe also as a type of propositions. and a
proof that this function is associative. In this way the type of semigroups with carrier X U can
be de ned as SEM X def El X El X El X x El X y El X z El X Id El X x. We can also form X U
SEM X . z An element of type SEM X consists of a binary function on El X . y. x M El T UI x
M El T El x T M El x T N UE App x El T M. x.. N El T Nx App x El T x M El T .. the type of
semigroups. the type U can be viewed as an analogue to the powerset of . N M Nx El T Nx
The di erence to closure under types is that the domaintypequot is arbitrary and not con ned
to a small typequot of the form El S . . they permit the de nition of a type of a certain
algebraic structure. More complex examples of this kind may be found in Luo . Miscellaneous
types A counterpart to absurdity in logic is the following empty type c txt F type type M E R M
. y.
x type H x M E Rx H. nite types with n elements for each natural number n. we can consider
arbitrary theories of dependent types de ned by type symbols. An implementation of
extensional MartinLof type theory is the Nuprl system Constable et al. Finally. but elimination
rules are replaced by the more general device of patternmatching on the form of the
constructors. x C Rx H. and equations. A characteristic feature of MartinLofs type theory is
the presence of identity types either with or without equality re ection. In implementations like
Lego and Coq new type formers can be de ned on the yquot by giving the rules for their
canonical elements like Suc and in the case of N. MartinLof invented his type theories with
the aim of extending the propositions as types correspondence to predicate logic and to
provide a universal language for constructive mathematics MartinLof .There are no canonical
elements in so there is no computation rulequot like NCZ. c txt F c txt I type . A standard
reference on MartinLofs type theories is Nordstrom. but not a universe closed under
impredicative quanti cation. MartinLofs type theory This is a collective name for type theories
containing several of the abovedescribed type formers. and quotient types to name the most
important ones. This is described in Pitts . Examples of type theories In this section we brie y
describe some namedquot type theories and how they t into the formal framework described
here. M Mx Rx H. .. M H Mx . Petersson. It is sometimes useful to have a type with a single
canonical element corresponding to the true proposition There are a number of other types
considered in the literature like coproduct types corresponding to binary disjoint union. types
of wellfounded trees. . . subset types. In Alf this is also possible. and Smith . MartinLof . The
elimination rules are then generated automatically. constants.
substitution. Iterated abstractions and applications are written x . To distinguish from object
level type formers some di erent notation is used the type of the framework is written x
instead of x and instead of . . and Smith . The Alf system Magnusson and Nordstrom is
based on the Logical Framework.. and in the Alf system the type annotations in functional
abstractions are omitted. n App . is a type theory with types and a universe. Its intended use
is to de ne theories. how terms with free variables are represented as framework
abstractions in the type of and how substitution is represented as framework application in
the type of App and in the equation. as extensions of the LF by constants and equations. In
this way the burden of dealing correctly with variables. and binding is shifted from the object
language to the Logical Framework and so can be handled once and for all. n m Set. Set.
The idea is that types and type formers are declared as constants in the universe and that
termformers are declared as constants of the appropriate El types. m x x. . Abstraction is
written as x M instead of x M and application is written M N instead of App x M. . m x x . cit.
see Part IV of Nordstrom. Iterated types are written x . It allows for the de nition of types in
Set simply by giving their In loc. m . Set. L . . Nn. . SetSet App Set. n mn Notice. xn n instead
of x xn n . the LF can also cope with type formers other than the dependent function space.
m. . We include them for the sake of consistency. The lacking type information can be
inferred. Set. The Logical Framework MartinLofs Logical Framework LF. respectively. The El
operator is omitted.. in particular MartinLof type theory. xn nM and M N . . The universe is
written Set instead of U . . Petersson. N . For example the type is described by the following
constant and equality declarations understood in every valid context Set. Since we refer to it
later in x. we consider here an ad hoc type former creating a copy of its argument de ned by
the two rules type L type M lM L In LF it would have to be rendered by two constants L
SetSet and l Set. Set. Of course.
and Plotkin . Datatypes reside in U and are given by inductive rules like the ones for N. In
the CID we have two universes both closed under impredicative quanti cation. Coq. for
instance one has Nat def Prf c Prop z Prf cs Prf c Prf cc and for this type constants and Suc
can be de ned as well as an operator permitting de nition of functions by primitive recursion.
Functions on the types are then de ned by patternmatching over the constructors as needed.
This gave rise to two extensions of the pure Calculus of Constructions Luos Extended
Calculus of Constructions ECC implemented in the Lego system Luo . The higher universes
are used for modularisation as hinted at in the example above. logical connectives can be de
ned on the type Prop by their usual higherorder encodings Coquand and Huet . The
interested reader is referred to Harper.constructors. The universe is traditionally denoted by
Prop and the corresponding El operator is either written Prf or omitted. Dowek et al. The
implementation of the CID. Prop is used for propositions only. The idea is that the universe
Prop corresponds to a type of propositions and that Prf associates the type of proofs to a
proposition. comes with a program extraction facility which extracts executable ML programs
from derivations in CID essentially by removing all terms and types coming from the universe
Prop . . . . The Calculus of Constructions The Calculus of Constructions CC Coquand and
Huet is a type theory with types and a universe closed under impredicative quanti cation
UImpr. Originally. U . Also other inductive datatypes like lists or trees can be de ned in this
way. Luo and Pollack and the Calculus of Inductive De nitions CID implemented in the Coq
system Coquand and PaulinMohring . it was intended that Prop not only contains
propositions. ECC extends the Calculus of Constructions by a sequence of universes U . The
encoding of datatypes inside Prop proved insu cient as no internal induction principles like
RN are available for these. see also PaulinMohring . but also datatypes like the natural
numbers which are de nable by their impredicative encodingsquot.. The Logical Framework
can also be used to encode the syntax of other logical systems such as predicate logic and
modal logic. The datatypes reside in Set and are given by inductive rules as in ECC. The
point is that Nat itself is of the form Prf and so can serve as the argument c to an element of
Nat . Set and Prop . Similarly. Honsell. where each Ui contains a code for Ui and Prop is
contained in U .
pId x. y type the following type corresponding to the axiom of choice is inhabited x y f x f xy
type . Show that for arbitrary types type. Construct an inhabitant of the type m N. types. N.
MartinLof . y H. N j R z x x . P x j x M j App x M. For certain purposes it is convenient to have
a simpler inductive de nition of possibly non welltyped terms. type. n N. N j Pair x M.y . x Hs.
The precontexts . n N Id N m n. x .. These preterms. and natural numbers are given by the
following grammar. terms. j .yj z H . Presyntax The syntax of types. . as a term albeit not a
welltyped one. H. and contexts has been given together with the typing and equality rules. P j
x j Suc M j RNN Hz . x j x j Id M. and . Note that the variables declared in a precontext are
pairwise distinct. For instance. N j N M. and preterms M . Exercises E. M n Capturefree
substitution and identi cation of terms with di erent bound variables can then be dealt with on
the level of the presyntax. N for a type theory with . . pretypes . n m type E. we might want to
consider App xNN . we will use them as an auxiliary device in the de nition of the
interpretation of type theory in semantic structures and also in the de nition of context
morphisms below. and contexts have been used to give semantics to type theory in terms of
untyped computation Allen . out of which the actual ones are singled out by the rules. We will
use the predicates wellformed or valid for those preterms/types/contexts which actually occur
in derivable judgements. M. x provided x is not declared in . identity types. M j Re M j RId . N.
De ne a type of binary natural numbers with three constructors Zero . Suc type
corresponding to Peanos fourth axiom . and the empty type itself the following type in the
empty context is inhabited Id N . x P def c Prop x P c c where X Y abbreviates p Prf X Y .
Show that in a type theory which supports natural numbers. the identity type.E. E. E. Hint
think of lists as inductively generated from the empty list by successive additions of elements
of consquot. E. Give the rules for a universe U containing a code for the empty type and a
code for the unit type . Notice that in view of the semantic result anticipated in the previous
exercise this de nition hinges on the fact that there is no empty type in the rst place. De ne a
length function of type List N and de ne a type Vec M of lists of length M for each M N using
lists. Hint de ne using RN a function f N U such that f U and f Suc U . Show that for any type
theory containing some or all of the type formers described above the rules Weak and Subst
are admissible. N Prf x P . N M . E. The elimination operator R must then be de ned by
induction on the structure of . Show that for M and N as above one has witnessS IM. By
analogy to the type of natural numbers de ne the rules for a list type former which to any type
associates a type List consisting of nite sequences of elements of . and the type. Suc . Weak
types in the Calculus of Constructions For x T Prop de ne type and and de ne in the case
that Prf S for some S Prop a rst projection witnessS Prf x Prf S T Prf S . Troelstra and van
Dalen Show that in type theory without the empty type such an empty type can be de ned as
Id N . Suc . E. and Suc and de ne a conversion function from these binary representations to
N. this universe. Later on we will show by a semantic argument that the above type is not
inhabited in the absence of a universe Smith . De ne a pairing operation which to M and N
Prf P M associates an element IM.
Finally. Re N which forms a context morphism from to n N. . For any context we have the
empty context morphism from to and this is the only context morphism from to . M if x . Mn
then f M x M x Mn xn . p Id N. x where M x . If x . . . For any term M we can form a context
morphism M . if x . In other words when can we replace App x M. Context morphisms De
nition . If f def M . Generalised substitution We denote syntactic identity up to renaming of
variables by . See Streicher for a thorough discussion of this point. Prove that whenever M
and M then type by induction on derivations. . Mn is a sequence of n preterms we write f and
say that f is a context morphism from to if the following n judgements hold M M M x Mn n M x
M x Mn xn Examples. . we have the identity context morphism id given by id x . x to which we
denote by p. Discuss the properties a type theory must have so that the type annotation in
application can be omitted. . Find some type annotations in term formers which can safely be
omitted without violating this property. xn. N by App M. xn n be valid contexts. Let and def x
.Ty E. xn n is a context and type and x is a fresh variable. xn n and f M .E. . The same
sequence of terms also forms a context morphism from to n N. If f and is a pretype we write f
for the simultaneous replacement of the variables in by the corresponding terms in f . . N in
the o cial syntax without violating uniqueness of types. xn. . then x . . more precisely. n as N
and Re N Id N. xn n. A more concrete example is . which shows that the target contextquot is
not uniquely determined by f . .. n n. Give the rules for a universe closed under impredicative
quanti cation using the economic syntaxquot exempli ed in rule U. p Id N . xn forms a context
morphism from .
Then the following equations hold up to syntactic identity. so the generalised substitution
subsumes weakening. given by qf. x This rule together with c txt MorEmpty generates all
valid judgements of the form f . This list g f forms a context morphism from to and as
indicated is an associative operation. Although this can be seen directly with some intuition
about substitutions we prefer to state it as a proposition together with some other properties
which the reader is invited to prove by simultaneous induction on the length of g.The attribute
simultaneousquot means that the variables in should be made disjoint from those in before
performing the substitution. x J and M we have J M J Mx so ordinary substitution is
subsumed. but J J p. However. . J then . . f. from . type. x c txt M f MorCons f. Similarly. for .
Proposition . . precontexts. and judgements. . M . We de ne f analogously for preterms. The
de ned substitution operation allows us to establish the following derived typing rule for
nonempty context morphisms f . In other words g f is obtained by simultaneously
replaceming the variables in g by the corresponding terms in f . Nk we can form the list of
terms g f N f . zk k . too. g f g f g f M g f M g f g f e g f e . M N . and g . One is only interested
in the case where as this subsumes the general case with f replaced by the context
morphism qf. Assume B e . and judgements J of the form M . Notice the special case of the
context morphism p. By induction on the length of and using rules Weak and Subst we can
then establish the following property Proposition . When and when no confusion can arise we
write f for f and similarly for terms. f . f to . If f and . in order to get the inductive argument
through one needs the case of nonempty . Nk f . Furthermore let type and M . de ned above.
f J f . z . . zk for z . If f and g where g N. contexts. x J p. If J then . type.
Nn. By straightforward induction it is now possible to derive congruence rules for the de ned
operators on context morphisms. If f and g then we write f g as an abbreviation for the n
judgements M N . Show that the abovede ned context morphisms p. If M then p. . If f g we
say that f and g are de nitionally equal context morphisms from to . have the following
properties If f then id f f f id . f . If f and .t. x M f .x p. If f and M then M f qf. w. x . x f p. .
Exercises E.Hint for the proof de ne g f inductively by f def and g. c txt. . M N M x . If type and
x fresh then id . M denotes the list g extended by M . xn n . and qf. Show that if x type and f
then x f x f qf. . x. M f and x f.r. this de nitional equality and we also have that if c txt. M f def g
f. M id . Mn and g N . M M . . . M . x c txt then p . and f g then f g . M .. . If f. Categorytheoretic
semantics of type theory Now we develop an abstract notion of semantics for theories of
dependent types of which most known interpretations of type theory form an instance. Notice
that we could n M x Mn xn if equivalently replace the second judgement by M N N x in view
of the rst one and the congruence rules for de nitional equality. Hint you may assume that x
does not occur in as types are identi ed up to renaming of bound variables. . Use the fact that
f if none of the variables occurs in and that Nx f f N f x. E. f. M f where g. qf. x then p. Context
morphisms and de nitional equality Let f M . Mn Nn x .
This is achieved by essentially three properties of the abstract semantics Substitution is a
primitive operation rather than inductively de ned. and the settheoretic model Set as running
examples. Variables are replaced by combinators for substitutions. functors. and for any two
objects a collection of morphisms the context morphisms together with an associative
composition and identities. B for the collection of morphisms from A to B . B . terminal
objects. Along with the explanation of CwFs we de ne two important instances the term
model T of the calculus of dependent types described in x . A nal prerequisite if is an informal
proposition then we de ne the set by fg if is true and . Reading the relevant parts of the rst
chapter of Lambek and Scott . . . Accordingly. types. should su ce to attain the required state
of knowledge. in particular categories. natural transformations. If C is a category we write jCj
or C for its collection of objects and C A. . for each of these we have a domain of
interpretation in the model.The main purpose in de ning such an abstract semantics is that it
is easier to show that a mathematical structure forms an instance of the abstract framework
rather than de ning an interpretation function for it directly. The de nition of a CwF follows the
structure of the judgements in type theory except that context morphisms and substitution
are part of the structure rather than de ned afterwards. Furthermore. CwFs are closer to the
syntax than categories with attributes and thereforethis is the hope of the authorshould be
easier to understand. context morphisms. Categories with families We choose the semantic
framework of categories with families CwFs Dybjer a variant of Cartmells categories with
attributes which have the advantage of being equationally de ned. Categorytheoretic
semantics is based on an abstraction from the combinators like . and equations for context
morphisms identi ed in the previous section. De nitional equality is modelled by true
settheoretic equality. rather than using conditional equations. p. If we include context
morphisms the syntax contains four kinds of objects contexts. For lack of space we cannot
give an introduction to categories here and need to presuppose some very basic notions. a
CwF C contains . and the category of sets and functions. We also write f A B instead of f C A.
and terms. The key concept is the one of a category a collection of objects the contexts.
isomorphisms. More precisely. q. for instance. if is false.
The interpretation of the various type and term formers will be given afterwards as additional
structure. A morphism from to is an equivalence class with respect to de nitional equality of
syntactic context morphisms f . that substitution together with equations TyId and . If . We
also omit the subscripts if they are clear from the context. This is wellde ned in view of the
observations in x. . Moreover. An element of Tm Set . is the set of preterms M with M
factored by de nitional equality.. Tm . that is precontexts such that c txt. one for types and
one for terms if f then there is a function ff g Ty Ty and for Ty a function ff g Tm . These
operations must be compatible with composition and identities in the following sense.a
category C of semantic contexts and context morphisms for C a collection Ty C of semantic
types for C and Ty C a collection Tm C . An element of Ty Set is a family of sets indexed
over .. C . g . substitution must be axiomatised in such a way that it corresponds to the de
ned syntactic substitution. Composition and identities are given by the corresponding
operations on syntactic context morphisms. TmId M fg f g M fggff g Tm . then the following
equations are required to hold fid g Ty TyId fg f g fggff g Ty TyComp M fid g M Tm . and M
Tm . fg f g TmComp Notice that the former two equations are required for the two latter to
typecheckquot. f . Next. Two such contexts and are identi ed if c txt. Semantic substitution is
described by two operations for each context morphism. that is and are identi ed if type. .
Notice also. Finally. Tm . of semantic terms Where appropriate we leave out the attribute
semanticquot and write Tm C instead of Tm C . The de nition of CwFs only accounts for the
structural rules common to all systems of dependent types as set out in x . we need
constants and operations on these domains in order to interpret the rules of type theory. Ty T
is the set of pretypes such that type again factored by de nitional equality. The settheoretic
model Set has as category of contexts the category of sets and functions. ff g. Ty . is an
assignment of an element M of for each . In the term model T the collection of contexts is the
quotient by de nitional equality of wellformed contexts. We tend to denote equivalence
classes by their representatives.
. x x . v i id ConsId In the term model the extension of f by M is f. whereas in the settheoretic
model we have hf. According to the de nition of syntactic context morphisms we need an
operation which extends a semantic context morphism by a terms. see x. The context is
called the comprehension of and p is called the projection associated to .. i of p hf. ff g
ConsR hf. Next we want to interpret the context formation rules. M i g hf g. In the term model
this is the term x in . x x . The function p then sends . Similarly. Tm . x . . M i g . p. Note that.
if M Tm . Let us summarise that a CwF is a structure C . hi. In the term model substitution is
the generalised substitutionquot de ned in x. To model the empty context we require a
terminal object gt in the category C . x p. x and p is the context morphism given by .TyComp
makes Ty a contravariant functor from C to Set . This completes the de nition of categories
with families. whereas in the settheoretic model we de ne it by the assignment . as de ned in
x. M i the extension of f by M satisfying the following equations for f . The second projection
takes the form of an element v Tm . fg. respectively.. In the term model and in the
settheoretic model these terminal objects are the empty context and an arbitrary singleton
set. then M ff g def M f . The sets Tm can also be organised into a functor. in this model. x j x
g. This means that we have ff g def f and M ff g def M f . The morphism p can be seen as the
rst projection out of the generalised product . M .e. and M Tm . gt. x to . h. In the settheoretic
model is the disjoint union of the . the set f . It is easy to see that the required equations hold.
We usually write hi for the unique morphism from to gt. M Tm . Ty . In the settheoretic model
substitution is given by precomposition. M i v fhf.. fp g corresponding to the judgement . i. To
interpret context extension we require for each C and Ty a context C and a morphism p . fp g
. v. x x. g B . We include the typequot information in hf. M fggi B ConsNat hp . If f is a
function and is a family of sets then ff g is the family of sets given by ff g def f . If f . ff g. In the
term model is the extended context . M i def f . ff g then there is a context morphism hf.
below. Ty . f ConsL M Tm . M i as it cannot be inferred from the typesquot of f and M .x . Ty .
M.
Dybjer A category with families is given by the following data. This de nition is equivalent to
the one in x. f we have f Ty Ty and f Tm . . M i f and v fhf. The carrier sets Ty and Tm of a
CwF over category C can now be given more compactly as a single functor F C op Fam . a
functor F Ty . De nition .sorts and operations subject to the requirements set out above. a
comprehension for each C and Ty . De nition . f where f B C is a function and f fb bB is a
family of functions fb B b C f b. A morphism from B to C C . M i g M . The required equations
follow from functoriality of F . If f then writing F f f . De nition . Ty The morphism part of F is
induced by semantic substitution. A more abstract de nition We give in this section an
equivalent.. The idea of using familyvalued functors is due to Peter Dybjer.. F . Furthermore.
a category C with terminal object. given Ty and Tm we obtain a functor functor F with object
part F Ty . M i satisfying p hf. means that up to a choice of representatives a CwF is fully
determined by its underlying familyvalued functor. Tm C op Fam . Indeed. The proof is left to
the reader. The category Fam of families of sets has as objects pairs B B . f giving us
semantic substitution. Tm C op Fam be a functor. Tm . given a functor F C op Fam we de ne
Ty F and Tm . A comprehension of is given by an object of C together with two projections p
and v Tm . Conversely. fp g such that for each f and M Tm ff g there exists a unique
morphism hf. . but more abstract and more compact de nition of CwF based on familyvalued
functors and a universal property. Let C be a category and F Ty . B where B is a set and
BbbB is a family of sets indexed over B . let be an object of C and Ty . C is a pair f . The
substitution fg is understood to work for both types and terms. F where F F . The fact that
comprehensions enjoy a universal property and thus are unique up to isomorphism see E.
Tm .
These two operations establish a bijective correspondence between the collection S ectp of
sections of p and Tm . as v fM g M by ConsL and v ff g hid . In the term model a weakening
map takes the form of a projection from . M i By ConsL we have p M id thus M is a right
inverse or a socalled section of p . in the settheoretic model we have qf. p v p v id . fp gff g
Tm . that is. from x. Furthermore. fid g and thus M def hid . to . . qf. For example. v ff gi hp . B
ff g called the weakening of f by is de ned by qf. fp f g Tm . x . TyId. E. . If M Tm . by
TyComp. ff g. Terms and sections Assume a CwF. hf p ff g. Exercises E. . We introduce the
abbreviations and M for fwg and M fwg if w is a weakening map which is clear from the
context. as demonstrated in E. A context morphism qf. . v i f f by ConsNat and ConsId. and
assumption.. and explain their intuitive meaning. A weakening map is a morphism of the form
p or inductively a morphism of the form qw. Conversely. f M ff g M f . id and qf g.. if f is a
section of p . where w is a weakening map. v ff g i In the term model qf. Weakening Suppose
that f B and Ty . if f is any context morphism we may write f for qf. Ty . then also M Tm . x f f .
v ff gi . Transform the following equations into the explicit notation. we have in the term
model x ff g x ff g ff g.. B. prove them. Show that in a CwF the de ned morphisms qf. p f id
then v ff g Tm . f hp f. qg.. Also expand the expression when .. . is the eponymous syntactic
context morphism dened in x. v ff gi hp f. x. do satisfy the coherence requirements qid .
respectively. . The two projections p. q. HH q HH A .. A pullback of g along f is a pair of
morphisms p P Y and q P Z such that f p g q and whenever p P X and q P Z are two
morphisms with f p g q then there exists a unique morphism h P P such that p h p and q h q.
This and the following diagrams were typeset using Paul Taylors Latex diagram package the
use of which is herewith gratefully acknowledged.HH A . Extend P to a CwF by putting Ty P
tt Ty P ff fff. In the category Set the pullback of g Z Y along g X Y always exists and is e. q
send a pair x. given by P def fx. ttg where ff tt viewed as a category..g. Show that P has a
terminal object. A . tt. De nition . . Hint de ne comprehension by def . Check that equations
ConsL ConsId hold in the settheoretic model. Let P be the poset of truth values fff. E. f X Y
and g Z Y morphisms with common codomain.. z j x X z Z f x gzg. P H .. A key property of
these models is that substitution on terms is a de ned concept rather than a primitive.. An
intuition for this model or rather for the interpretation of the syntax in it is to view tt as
potentially inhabitedquot and ff as always emptyquot. . ttg and Tm P . . z P to x and z.E. g of
morphisms with f p g q a commuting square is called a pullback if p and q form a pullback of
g along f .. viz. HH A h . To understand how this works we need the notion of pullback in a
category.. f. HH A R j q H Z A P A p A A A A A U A p g f X Y A quadruple p. This exercise will
be taken up in later sections and will lead us up to Jan Smiths proof of the independence of
Peanos fourth axiom from MartinLofs type theory without universes Smith . Let C be a
category. Other notions of semantics In the literature other notions of model have been o
ered which mostly are equivalent to CwFs..
j y Y Gy g to Y which sends y. N i . This is precisely pGy yY in the notation of x. v i q hp q . v
ff g fhgi by ConsNat hf p . We have N Tm fp gfqg fp qg ff pg ff gfpg. f B . namely the family of
sets gyyY where gy def fz Z j gz yg. The diagram commutes by equation ConsL. h def hp. we
can put P def fx. x. v fq gi hf p by ConsR . The following square is a pullback qf. and Ty .
Conversely. A more general correspondence between pullbacks and substitution arises in
the framework of CwFs Proposition .. x and qx. f x. more precisely. Let C be a CwF. j x x and
Gf x g. v fq gi hp q by assumption q by ConsNat and ConsId . where N def v fqg. To see that
it is indeed a pullback assume p B and q such that f p p q. B ff g p ff g p B f Proof. h hf p ff g.
v ff g fhgi by ConsL . Note that this is not equal to the canonical pullback of g along f which is
fx. Now a pullback of the thus de ned g Z Y along f X Y is given by applying this construction
to the composite family Gf x xX . j x X Gf x g with projections px. . v fqgi hf p. We can
decompose q as q hp . if we are given a family of sets Gy yY we can construct a function g
into Y as the projection from the disjoint union Z def fy. to y. N i ff g B ff g We have p ff g h q
by ConsL and qf.In Set we can view a morphism g Z Y as a family of sets indexed over Y .
Therefore. v ff g i h by de nition hf p ff g h. .
ConsNat. Pitts consists of A category C with terminal object gt. A category with attributes
Cartmell . .For uniqueness assume a morphism h B ff g such that p ff g h p and qf. M i ff g
where M def v ff g fh g Tm ff p ff g h g Tm ff pg Tm fp qg Now we have v fq g v fqf. qg. given
a category with attributes we can construct a CwF by putting Tm . We must show h h. a set
Ty for each C and a function ff g Ty Ty B for each f B such that TyId and TyComp from x. v ff
g fhgi ff g using ConsId.. id f and qf g. hold. By assumption we can rewrite this to hp. ff g. M ff
g M f . De nition . Moggi . hg by assumption g v ff g fh by de nition of q and ConsR M so we
are done. de ning M ff g as the unique morphism with p ff g M ff g id B and qf. . For each f B
and Ty a pullback diagram qf. qf. Conversely. For each Ty an object and a morphism p . IdL.
def S ectp and for M Tm . i. A functor Ty C op Set . and E. B It follows from Prop. B ff g p ff g
p such that qid . we expand h as hp ff g h . . that every CwF is a category with attributes if we
forget about the terms. h q. The pullback property of substitution may be taken as primitive
thereby making substitution on terms super uous. To see this.e.
which makes the de nition of the interpretation function more complicated. The other way
round one gets back the original CwF with the set of terms Tm . ff g we put hf. . Exercises E.
If one starts out with a category with attributes. v fqg is a comprehension of ff g. Mention
must also be made of contextual categories where semantic contexts carry an explicit tree
structure corresponding to context extensions see Streicher . x. Cartmell and E. in these
models the conditions corresponding to TyComp and TyId only hold up to isomorphism.
Hyland and Pitts are less general than CwFs because semantic types are identi ed with their
associated projections. p. Agnes Diller Show that the requirement qid . M i def qf.
Locallycartesian closed categories Seely and categories with display maps Taylor . We leave
it as an exercise to verify that this de nes indeed a CwF. constructs a CwF.. Obtulowicz are
more general since they allow for morphisms between semantic types. See Hofmann b. For
a good taxonomy of the di erent notions and various backandforth constructions see Jacobs .
if Ty nothing prevents us from de ning simply as and the corresponding morphisms p and q
as identities. These morphisms make it possible to describe certain type formers more
elegantly. Jacobs . but do not have a direct counterpart in the syntax. M Tm B. replaced by
the set of right inverses to p cf... . id in Def. is actually redundant. . Ehrhard and indexed
categories Curien . Now give another proof of Prop. E. There are various other notions of
model all of which are essentially equivalent as far as interpretation of type theory in them is
concerned. Notice that context extensions in categories with attributes are not unique up to
isomorphism. Models based on brations Jacobs . M and nally de ne v as the unique
morphism v with p v p v id . and from this CwF again a category with attributes one ends up
with the one to start o with. Usually.For f B . Lamarche . Prove that comprehensions are
indeed unique up to isomorphism in the following sense If Ty and p and v Tm ff g is a
comprehension of then there exists an isomorphism f satisfying p f p and vf g v . by showing
that . For instance. Curien .
Id . g App ff g. . M . Ty and for each M Tm . . Examples of this can be found in Streicher . M.
The advantage of contextual categories is that they rule out semantic contexts which do not
arise from the empty context by successive applications of comprehension. g Ty B S S ff g. N
ff g App S . fqf. A contextual category Cartmell . Why. to convey the general pattern. M Tm .
This results in certain requirements on a CwF which follow very closely the syntactic rules. ff
g . For each C we de ne a category D with objects the types over and in which a morphism
from to is a C morphism f such that p f p . Explain why this de nes indeed a category and nd
an extension of the assignment D to a contravariant functor from C to the category of
categories. . . Such a functor is called an indexed category and forms the heart of Curien and
Ehrhards notion of Dcategories Curien . fM g such that the appropriately typed universal
closures of the following equations hold App . M. Semantic type formers In order to interpret
a type theory in a CwF we must specify how the various type and term formers are to be
interpreted. Some are treated in the exercises. This can be used to establish properties of
semantic contexts by induction on the level. fqf. N . . Equivalently a morphism from to can be
de ned as an element of Tm . Streicher is a category C with terminal object gt and a tree
structure on the objects given by a function f on the objects of C such that f gt gt and f
fatherquot is injective on C n fgtg and for each C there is a minimal nthe level of such that f n
gt. and N Tm . fqf. The reader may then by herself de ne the conditions for the other type
formers. N Tm . g M ff g. E. N ff g M fN g C ff g. . The objects of the contextual category are
lists . the assignment Ty f j f g extends to a category with attributes over C . Assume a CwF
C . there is a term . Ritter . De nition . A CwF supports types if for any two types Ty and Ty
there is a type . Moreover. and for each M Tm . there is a term App . g M fqf.E. M ff g App . k
where Ty gt and i Ty gt i . We give a precise de nition for closure under . Spell this out
without using the notion of a category with attributes and de ne a canonical construction of a
contextual category out of a CwF.
Accordingly. hN. Let be . p . . . leaves its rst two arguments unchanged.. We have N def v
Tm . hN. . def Tm . nally. g Proof. fqf. Tm . and N Tm then v fApp . . App . fN g Tm . We see
that we stipulate exactly the same type and term formers as in the syntax together with an
equation corresponding to C. Since substitution is a primitive notion in the semantics we can
obtain a more economic de nition of dependent function spaces by restricting the App
combinator to variables and replacing it by an appropriate morphism. M fp g M and. The last
equation makes implicit use of TyComp and the fact that qf. From the App morphism we can
de ne an application combinator as follows. . M. such that p App . We de ne the application
morphism as hp . . and thus corresponds to a term of . N i The veri cations are left to the
reader. . The rst equation states that App . and for any two types Ty and Ty a morphism App
. g Tm fp App . . App T and it follows from the other two equations that this term has the
required properties. . App ff g. . we have App . and M v . g qqf. Congruence rules are not
needed on the semantic level as everything preserves equality. . . suppose that a model
supports dependent function spaces in the sense of Def.The third equation typechecks by
virtue of the second. Given M Tm . and the third one to App S. M i . Proposition . M ff g M f
which follows by rewriting both sides to hf. qqf. A CwF supports dependent function spaces i
there are operations and as in Def. N Tm . for every morphism f B App . M ff gi . g Tm fN g by
Eqn. M. stability under substitution. but we need extra equations to specify that substitution
commutes with the semantic type and term formers. App T and for every term M Tm C App .
fqf. Conversely. The second equation corresponds to C. M i .
z x . A CwF supports types in the strict sense if it supports them and whenever M Tm . N def
App x M.x then we de ne . If types are supported in the strict sense then Eqn. Pitts . M . De
nition . The settheoretic model supports types in the strict sense. Pair whenever f B .This
second de nition of dependent function spaces allows for the following restriction by which .
A CwF supports types if the following data are given for any two types Ty and Ty there is a
type . ff g S . ff g.x and ab straction and application as their settheoretic companions. y . M is
required to be the unique element of Tm . w where are the variables x x in . the operation . M
x M App . for which C holds. The term model of a type theory with types supports types with
the obvious settings . x . The syntactic counterpart to these strict types is an rule which
allows one to conclude x M x M x from M x . such that p . Notice that these types are not
strict unless we enrich our type theory with the abovementioned equation. If Ty and . e. Pair
p p and such that f Pair . Moreover. N The corresponding application morphism is the context
morphism de ned by . then becomes part of an adjunction. and U Tm . . see. and App .x . Ty
such that . def x def . M. A morphism Pair . whenever f B . U M then U . S can be derived. De
nition . ff g f Pair S . App x z.g. ff g ff g. y . def x .
y This morphism Pair is surjective and thus we can take C as the de ning equation for R . is
the context morphism . H is the unique term with property C. H fRe g H . x.t. . y H Pair x x.
De nition . for each Ty I a function RId. Pair x M. which also ensures that R . z . y .x g Pair .
Also the settheoretic model supports types as follows. if . x. x . The term model of intensional
type theory supports identity types with the following settings if type then Id is the type . g a
term R . x type then . N . y type and Re is the context morphism . x . Again. z x R H. the
diagonal morphism. we say that types are supported in the strict sense if this is the case. g H
C and R . . p Id x. Tm fRe g Tm in such a way that these data are stable under substitution
w. x . . . x. ff g H ff g R S The term model supports types as follows if . y then . y Id x. H fPair
. y j x and y . def x and Pair . a morphism Re I where I Id such that pId Re equals v . Re x . x.
y . H ff g R ff g. and term H Tm fPair . . H Tm such that R . A CwF supports intensional
identity types if for each type Ty the following data are given a type Id Ty . x . z x Finally. y .r.
. morphisms f B and such that whenever Ty I and H Tm fRe g then RId. x . ff g. y def .For
every type Ty . def fx. .
We write Prop also for gtProp .p and App . x. In x.p and a morphism App .If . but not fg. We
conclude the de nition of semantic analogues to type formers by specifying the interpretation
of a universe closed under impredicative quanti cation. x. Re x then . The term model is a
model for the Calculus of Constructions with Prop equal to the type of propositions Prop in
Prop type and the type of proofs equal to Prf x in x Prop Prf x type. x P Prop . p Id x. x . x. p
type and . A type Prf Ty Prop .p like in Prop . x. x . Prf fpg is the set of functions from to fg
which is a singleton set. Notice that Prf f pg is not equal to . y. y x. y . y.x. y RId x H. If p Prop
then we def de ne p p . Notice that in this model all elements of a type Prf A are equal. Then
x P Prop is a morphism from to Prop with the required properties. empty types follows the
pattern of the types and is left to the reader. x tt for each x then Prf f pg fg. x . this bijective
correspondence enables us to de ne the required operations . A morphism from to Prop
takes the form of a term . establishing that Prf f pg is a dependent function space of Prf fpg
over such that all these data are stable under substitution. p Id x. y we have x y and
furthermore p itself equals . . x tt for all x quot.y def x y def and Re . A CwF supports the
Calculus of Constructions if it supports types and the following data are given a type Prop Ty
gt. However. a term former . p which de nes the required function. whereas . for Ty and p
Prop a morphism p Prop . y. p x. By Reynolds paradoxquot Reynolds and Plotkin this has to
be so in any settheoretic interpretation of the Calculus of Constructions. x. below we describe
a model where this is not the case. x H x. The semantic interpretation of natural numbers.
For H Tm Set fRe g we put RId. unit types.p. p def H x which is type correct because in the
presence of p Id x. y . Prf fpg but in bijective correspondence because if p . ttg and Prf x def x
tt. De nition . H . . The settheoretic model is a model for the Calculus of Constructions with
the settings Prop def fff. y. The settheoretic model supports identity types with Id .
De ne what it means for a model to support natural numbers. If Ty then de ne as considered
as a poset and let p be the inclusion from to . but that nevertheless does not determine
dependent function spaces on Poset because it is not stable under . Show that the truth
value model from E. is empty. Spell out what it means that Id and Re are stable under
substitution. E. . N i g. and show that the settheoretic model supports it by def . is an
isomorphism. E. Show that Tm .. as well as identity types with the settings .Exercises E. but
that the truth value model does not. Finally. Show that the truth value model forms adefmodel
of the Calculus of Constructions with Prop def tt. Show that the settheoretic model supports
natural numbers by N def and that def the truth value model supports natural numbers by N
tt. in this model then the set Tm Id fhM. N Tm . Ty be f j x x x g. Conclude that if M. E.
Explain how a CwF C supports unit types if but not only if there exists Ty gt such that gt is a
terminal object in C or equivalently gt is isomorphic to gt. Show that a CwF supports types in
the strict sense i it supports them and each morphism Pair . E. For Ty let . De ne what it
means to support an empty type in the sense of x. Tm . . and Id tt. Let Poset be the category
of posets and monotone functions. E. Extend Poset to a CwF by de ning Ty for poset as the
set of downclosed subsets ideals of . Prf def tt. as . E. E. and that the def truth value model
supports it by ff and that this interpretation is the only possibility. de ne Tm . E. . Show that
the settheoretic model supports such a universe. supports and types each in the strict sense.
where and denote implication and conjunction of truth values. De ne the semantics of a
universe containing a code for the empty type and a code for the unit type. def def def and .
Extensional type theory Say that a CwF with identity types supports them in the strict sense
if whenever Ty and Ty I recall that I def Id and H Tm then H RId. to establish that IdCan
cannot be derived from Re ection one needs the soundness theorem . below. In fact. Show
that if a model supports identity types in the strict sense then it supports types i it supports
them in the strict sense.y f. the CwF Poset does not support dependent function spaces.
Another example is gt with jgtj fg and n gt for all n . Independencequot is understood
informally here. A morphism from set X to Y is a function f from X to Y with the property that
there exists a partial recursive function e thought of as a natural number such that whenever
n X x then fegnthe application of e to nis de ned and realises f x. Extensional type theory is
usually formulated as a type theory with identity types where rules IdE and IdC are replaced
by the rules P Id M. The sets together with their morphisms form a category. Show that rule
IdCan is independent of Re ection by considering the settheoretic model with the setting Id .
N P Id M. Note that this is the case for the CwFs Set and P Why. .substitution. otherwise. An
example of an set is N where jNj and n N m i n m. N Re ection IdCan M N P Re M Show that
the term model of extensional type theory supports identity types in the strict sense. H fRe g.
If X is a set then we form an set X by j X j X and n X x for all n and x X . E. g if x y and . The
morphisms in the category of sets from N to N are exactly the total recursive functions. The
set model In this section we present another important CwF which provides a nontrivial
interpretation of the Calculus of Constructions in which there is a proposition N Tm Prop gt
such that Tm Prf N has more than one element. An set X consists of a set denoted jX j or X
and a relation X jX j between natural numbers and elements of X with the property that for
each x jX j there is an n such that n X x. .x. Show that a CwF with identity types supports
them in the strict sense i the morphism Re I is an isomorphism with inverse Re def p . This
set is readily seen to be a terminal object. If n X x one says that n realises x or codes x or is
a code/realiser for x so the condition on X means that every x X has a realiser.
n def m n from to . The required realisers are obtained from untyped application and
abstraction smntheoremquot. for arbitrary . This suggests to interpret the Calculus of
Constructions by putting Prop PER where PER is the set of symmetric and transitive
relations on .x j e such that T e. is a function assigning to each an element M such that there
exists a partial recursive function e with the property that for each and n the computation
fegn is de ned and fegn M . The abovede ned operation Prf then yields a type Prf Ty Prop ..
All the other type formers we have considered and many more are also supported by the set
model. Ty is modest if each is a modest set. We have m Prf R nR if mRn. M if T e. if R is any
per we can de ne a modest set Prf R having as underlying set the quotient of fn j nRng by R
which restricted to this set is an equivalence relation. An set where this is not so is called a
modest set. For set the set Ty consists of families of sets indexed over . Notice that Prop is
not modest. The remaining components are left to the reader as an exercise. and e then e .
Prop also contains . If X is modest then X is isomorphic to Prf X in the category of sets and a
per R is equal to Prf R . x if Ln and Rn x where L and R are the inverses to a bijection like P
m. If M . The set has as underlying set the disjoint union and n . M g where T e. The veri
cations are tedious but essentially straightforward. . fM x x . Thus. A modest set X induces a
symmetric. per on the set of natural numbers by putting m X n if there exists a necessarily
unique x X such that m X x and n X x. Ty means that and each is an set. . M . In other words
a modest set consists of a set X and a partial surjective function X from to X . If p Prop then
we de ne p Prop by p def .The category of sets can be extended to a CwF as follows.
Conversely. More generally. Application and abstraction are de ned as in the settheoretic
model. M means that n implies fegn M x for all x and n . If p Prop then p is a per for each and
we have Prf fpg Prf p . A term M Tm . transitive relation X a partial equivalence relation. The
set model supports types with the setting . It is easy to see that if Ty is modest then so is .Prf
fpg For mRn i m n we have that Prf R is isomorphic to the set N which means that we can
interpret a type theory in which the impredicative universe Prop contains a code for the
natural numbers. Modest sets In an set X two di erent elements can have the same realiser.
Let X be any set. . In Ehrhard such a re ection is made part of the de nition of a model for
the Calculus of Constructions. E. M . Beeson and Allen show how to model type theory with
nonimpredicative universes no entirely within the pers. For simplicity we restrict our attention
to types.. We de ne a partial interpretation function which maps precontexts to objects of C
pairs . One can de ne impredicative quanti cation in the set model by M def I x Prf M . to
families in Ty pairs . E. This means that the modest sets form a re ective subcategory of the
sets. For any set X a per I X is de ned as the transitive closure of the relation which relates
two numbers if they realise a common element of X . E. In this section we make this precise
by de ning an interpretation function and establishing a soundness property. Exercises E..
Interpretation of the syntax We have already implicitly spoken about interpretation of type
theory in CwFs by appealing to the informal analogy between components of CwFs and
typetheoretic entities. . where is a precontext and is a pretype.codes for other reasonable
data types and indeed the sets furnish a model for the CID mentioned in x.. Assume for the
rest of this section a xed type theory and a CwF C supporting the type and term formers
present in this theory. Explain how the set model supports identity types in the strict sense.
Show that if Y is a modest set and f X Y then there exists a unique morphism f Prf I X Y such
that f f X . De ne a morphism X X Prf I X which sends x X to the equivalence class of a
realiser of x. cf. where is a precontext and M is a preterm to elements of Tm for some Ty .
Explain how the settheoretic model supports lists. Show that every morphism in set from X to
N is constant and that for arbitrary set Y every settheoretic function from Y to X is a
morphism in set from Y to X . . E.
and contexts. N i . . If c txt then . .The de nition is by induction on the lengths of the involved
preterms. unde ned otherwise. x fp . like if Ty . M is an element of Tm . . x . . x . The proof of
this theorem. We also adopt the convention that expressions which do not typecheckquot.
and terms. y . We show below in Thm. N . x . The idea is to rst establish a substitution lemma
which relates syntactic substitution and weakening and semantic substitution fg. . . is an
element of Ty . .x . x M . x . . x . If type then . h . M .r. x . x . whereas their syntactic
counterparts here C refer to syntactic substitution which is de ned by structural induction. gt .
.x x . . Theorem . The interpretation function enjoys the following soundness properties If
then is an object of C . presents surprising technical di culties. fg. types. . are unde ned. App
x M. M . N App . . Due to type dependency one needs to account for substitution and
weakening in the middle and not merely at the end of a context. If then . if x not in . types. . x
. M Notice that the semantics of variables is de ned by induction on the depth of their
declaration as an appropriate weakening of a vexpression. .t. that the semantic function is de
ned on all contexts. x . . g . If M N then . although essentially straightforward. . The semantic
clauses are the following. . . If M then . x v . This is necessary because the equations
governing semantic type formers such as C are formulated w. where we adopt the
convention that an expression containing an unde ned subexpression is itself unde ned. . .
.We need some notation rst. . N be a preterm and z be a fresh variable. . x . inductively by P.
yielding . M is intended to go from . projecting out the part. z . X . . x qP. . . The expression P.
. . . . Mz and . Mz . is de ned i . Mz to . . be precontexts. . M qT. z . . Weakening Let . One
must then make a case distinction on whether it is declared in or in and perform some
equational reasoning. Similarly. . Lemma . M . X fP. X . . . M g The proofs of both lemmas
proceed by induction on the lenghts of the involved preterms. M. de ne the expression P.
Substitution Let . T. T. z . and contexts. N g. .types. If . z . M . . . For precontexts . X is de
ned then . be pretypes. N be preterms. . z . X is de ned then . fT. . M at the z position and
variables otherwise. be pretypes. and . z . z . But that this is really the case has to be proved
simultaneously with the weakening and substitution lemmas. be as before and M be a
preterm. z fresh The idea is that P. . Let X f . M is de ned i . and pretype we . Now let . g
Lemma . and z a fresh variable. T. . are both de ned and in this case is a morphism from the
former to the latter. We de ne the expression inductively by the following clauses. If . . are de
ned and in this case is a morphism from the former to the latter. The expression T. be
precontexts. to . Let X f . . . The most di cult case arises when the term N is a variable. z . . .
For possibly unde ned expressions s. If the type or the term N is a binder like x the inductive
hypothesis must be used with extended by z . . . N g and suppose that . is a morphism from .
In order to prove the correct typing of the P and T morphisms one uses the second part of
each lemma with shortened . . t we write s t to mean that if either side is de ned then so is
the other and both agree Kleene equality. p . P. The other cases follow by applying stability
under substitution of the participating semantic type and term formers such as S. M is de
ned.
. amp . Try to de ne the interpretation function on triples . For the same reason as before this
proof will not be reproduced here. M . N replaced by M N .e. For a particular model this has
been carried out in Palmgren and StoltenbergHansen . the reader is instead encouraged to
carry out at least a few cases of the inductive argument by himself and in case of serious di
culty consult Streichers monograph where the veri cation of the corresponding interpretation
in contextual categories is spelt out in a very detailed fashion. Alternatively. Formulate a
completeness theorem for the semantics and use the term model to prove it.. Deduce from
the term model that if M and M then type. The method of partially interpreting presyntax rst
and proving de nedness by induction on derivations was invented by Streicher and is used in
order to ensure that the interpretation does not depend on the particular derivation chosen. i.
of typed terms in context rather than on the pairs . with App x M. It seems di cult to prove this
general substitution lemma directly without using Lemmas . E. E. Exercises E. Extend the
interpretation function to syntactic context morphisms and state a general substitution lemma
for context morphisms Pitts . one could de ne the interpretation by induction on derivations
and then use the device of presyntax to establish coherence of the semantics with respect to
the conversion rules. Notice that derivations of a given judgement are not unique as
instances of the conversion rules TyConv and TmConv are not recorded in judgements.
What goes wrong E. Explain why the interpretation function cannot be de ned in the same
way as we did in case application is not typed. M .After this introduction we leave the proofs
themselves to the reader as following the calculations seems to require as much e ort as
doing them by oneself. Given the above two lemmas the proof of the soundness theorem
becomes a straightforward induction on derivations. . but this would result in a more
complicated proof. Extend the interpretation function to types E. Also explain why it would not
matter to leave out the type annotation in x M and similar situations.
and the soundness theorem that the following type is not inhabited in a type theory without
universes. J then . Extended example presheaf models In this section we encounter a family
of interpretations of type theory which generalises the settheoretic model in that types are
interpreted as variable sets presheaves or families of such. and Streicher where they are
used to de ne models of the polymorphic lambda calculus in which type quanti cation is
interpreted as cartesian product. Let K be a small category. There are various applications of
such interpretations. forms a conservative extension of ordinary type theory. Use the set
model to derive that in the Calculus of Constructions with natural numbers there does not
exist a term M Prop N and propositions P Prop and Q Prop such that App M. We use a
presheaf interpretation here to show that the Logical Framework in the sense of x.E. see
Coquand . We denote by K the functor category Set Kop of presheaves over K. We denote
presheaf application by subscripting. N M for all M and N Prf P M . Id N. This result appears
here for the rst time. P N and App M. Preliminaries. if F K and u KI. Deduce from E. a more
detailed version will be published elsewhere. in the settheoretic model is tt if P x is tt for
some x and ff otherwise. That is.. see for example Asperti and Martini and Altenkirch. A
presheaf over K is a contravariant functor from K to the category Set of sets and functions.
Suc type E. Q Suc N E. Conclude that the following extension of the Calculus of
Constructions by a choice function is consistent in the sense that neither the empty type if it
exists nor the type Prf c Prop c is inhabited in the empty context H Prf x P Choice H It is
known that such choice function becomes inconsistent if in addition one imposes the
equation Choice IM. Hofmann. Show that the interpretation of existential quanti cation x P as
de ned in E.
. we have ff gI I fI . R If is a presheaf then we form its category of elements with objects I.
and similarly for morphisms. . the variable v Tm fp g is de ned by v I . x j I . and
comprehension in order. A morphism from J. fI and for u KJ. If Ty and I. u to I. I and . u x. IR
such that u . We de ne a R R functor f R by f I. The veri cations are straightforward
expansions of the de nitions. etc. I is a full and . Fu FJ FI . For presheaf K we de ne R set Ty
to consist of the presheaves over the R . x . If KF. That is a presheaf means that if u KJ. Now
if Ty isR a family of presheaves then we de ne ff g Ty as the composition f . I and I then u is
an morphism from J. x u . terms. substitution. x I then u . M i I fI . f. I and I and x I then u x J u
and this action is compatible with composition and identities in K. Composition is inherited
from K. families of presheaves. for at argument I. We may think of K as a category of stages
or worlds and of a presheaf as a set varying with these stages. if these arise in the context of
a CwF. for this morphism. I then u MI MJ u . Our aim is to construct a CwF which has K as
the category of contexts. If Ty then the presheaf is de ned by I f . From now on we will use
the generic letters . Presheaves as a CwF . natural transformations. u. We have thus
established that presheaves over K furnish a CwF. . then we write I rather than I. If u KJ. I .
where I K and I . I we de ne f u. Next we de ne terms. In other words. Finally. fI . if u KJ. We
de ne types. Now R suppose that f R is a natural transformation. The projection p is de ned
by p I . This category has a terminal object given by gtI fg. if f and M Tm ff g then hf. G then I
FI GI . The Yoneda embedding y K K sending I to K. It is clear that this has the required
functoriality properties. x x. to I. If M Tm and f then M ff g Tm ff g is given by composition as
M ff gI MI fI . MI . If Ty then an element M of Tm assigns to each stage I and element I an
element MI I in such a way that if u KJ. x I g. I. to range over presheaves. is a Kmorphism u
KJ. See Barr and Wells for more faithful embedding of the stages into K information on
presheaves. If appropriate we may also write u. So.
w x. of the presheaves above is given by stagewise settheoretic dependent sum.. Indeed.
The dependent sum . x J w v def f v w. Notice that w J. then . If I K and I then an element f of
I associates to J K and w J I and xR J w an element f w. maps at stage I elements I and x I
and f I to f id I .r. I fx. x The application morphism App . . J K. x The generalisation to later
stagesquot J is necessary to make a presheaf and not merely an assignment of sets to
stages. Conservativity of the logical framework Let T be a theory of dependent types like one
of those set out in x. . for the dependent function space of and . Type formers in K The
presheaf model supports most of the type formers the settheoretic model supports. and thus
w x I w . If M Tm .t. . w J I. w w x w w . y j x I y I . often by the very same constructions..
Following the convention from x. which the presheaves are formed supports them. Suppose
that Ty and Ty . The precise nature of T is unimportant. if v I I and f I then we can de ne v v f
I v by v v f w J I . The major di erence is the interpretation of types which is carried out in a
way similar to the treatment of implication in Kripke models. w xf w. x. xg We omit the
associated term formers. it also supports universes if the ambient set theory w. It is de ned
as follows. x which is valid because w v v w . x J w def MJ w . We remark without proof that
K supports natural numbers and other inductive types. and of course similar to the de nition
of exponentiation in functor categories. M Tm is given by M I I . w . x I . It is routine to check
that this de nes dependent function spaces in the strict sense. This means that . Moreover
the assignment f must be natural in the sense that if in addition w J J then f w w. I. x J w . we
will write rather than .
We have a conversion map i translating terms. we write T and TLF for the judgement
relations in the two type theories. We have already demonstrated that T like every presheaf
model supports dependent function spaces. x type Applying the translation yields the
following judgement in TLF x El N TLF El y El NId x. Our strategy for proving this theorem
consists of exhibiting a model of TLF with the property that the interpretation of T in it notice
that such a model also models T is full. We interpret Set Ty T gt T as the presheaf Ty T
which to a context T associates the T types in context quotiented by de nitional R Set is de
ned as the equality. For example. we let TLF denote the Logical Framework presentation of
T . Due to the presence of type variables TLF is a proper extension of T . for some T type
then there exists M with T M . The fullness of the interpretation of T in T is essentially a
consequence of the Yoneda lemma and will be proved at the end of this section. We will here
use the simplest one and prove the following theorem Theorem . in T we might have x N T y
NId x. . We will do so in the sequel and omit the coercion i. Let us rst show how T models the
Logical Framework. This extends to a presheaf by term substitution. There is more than one
way to extend the notion of conservativity from logic to theories of dependent types. yId y. of
terms of type in context factored by de nitional equality. a dependent type theory with types
and one universe Set together with constants and equations corresponding to the type and
term formers in T . More precisely. Notice that M itself need not be a legal T
term.Furthermore. if Tm .e.. iN El N. types. and judgements in T into ones in TLF in such a
way that judgements are preserved. A natural question to ask is whether TLF is conservative
over T . etc. i. If T type and TLF M for some term M then there exists a term M such that T M
. but not identical to Suc . For distinction. The interpretation of El Ty T gtSet presheaf Tm T
which to jT j and Ty T Set associates the set Tm T . Judgements like Set type or F N Set F
are not in the image of i. x type In other words. it could for instance contain a subterm like X
SetSuc N which is equal. Such a model is furnished by the presheaf model T where T is the
category of contexts of the term model of T . if J in T then i iJ in TLF . That is to say. y Id y. .
If we omit the El operator and the decorations then the translated judgement looks exactly
like the one to start with.
We wish to construct an element of Tm T gt. M El . f. In order to simplify the notation and in
view of the soundness and completeness of the semantics we will use the syntax of type
theory with named variables to denote entities in T . for simplicity also denoted L. Notice that
up to the necessary abstraction e. f f .. An element of X associates by de nition of dependent
function spaces in K to f B and M Tm T B. Set which we describe explicitly by L Ty T def L
Recall that Set Ty T . m El El L . this is also the case for the type. for arbitrary . In essence.
We will deal with this task by way of example and assume that T contains types and the ad
hoc operator L from x. from Tm Set . lM Tm T . M Ty B. M ff g B. ff g a type B. Set.g. Since
the dependent function spaces in T are strict the rst task is equivalent to exhibiting an
element. SetSet and an element l Tm gt. But this means that the whole of can be
reconstructed from its particular instance def . For the demonstration that T models TLF it
remains to show that Set contains codes for all the type and term formers present in T . M
Tm T . Naturality is again a consequence of stability under substitution. El Set . we de ne it
explicitly by Ty T . v Ty .. The naturality of this assignment amounts to checking that for f B
and Ty T we have L f L f which is immediate from the properties of syntactic substitution. M ff
g Ty B. Set At stage the arguments to are a type Ty T and an element of El Set . Set. This
assignment is natural in the sense that for f B B we have B . Similarly. l Recall here that El
Tm T . El SetSet By uncurryingquot this amounts to constructing a term of Tm T Set. p . Thus
we require an element L Tm gt. El L l Again. . Set to Tm SetSet the required constants in K
are given exactly by their counterparts in T . the second task is equivalent to nding a term Tm
T Set. Call the latter set X temporarily. f. Indeed. of Tm T Set . We deal with the Loperator
rst. but due to the binding behaviour we encounter a slight complication.
id . M . we have . . f Set Thus. This allows for a systematic translation of arbitrary type and
term formers possibly binding variables from T to TLF .g. e. The general strategy should
have become clear from the example of . By induction on derivations we nd that the
interpretations of and in T have the following properties T . The same goes for the other
constants and App we face again an argument of whose de nition we omit. the arguments at
stage to the term which we aim to construct amount to a type Ty and a type Ty . Therefore. f
T . v So up to the bijection between the function space El Set and the set of types in the
constant in TLF has again been obtained directly from its syntactic companion. M id Tm T .
The theorem is proved. By ConsId we also get the converse and have thus established a
bijective correspondence between the sets El Set and Ty T Set . The important point is that
in K the function space El Set is so strongly con ned by the naturality condition that it only
contains functions induced by a syntactic type with free variable of type . One can more
generally characterise the dependent function spaces of the form El F for arbitrary presheaf
F as certain shiftsquot of F . but several other type formers like types. the interpretation of M
in T yields . One may consider a Logical Framework which does not only support types. in
particular. to de ne syntax. El Set T . e. for modularisation and natural numbers.g. Summing
up. and . Proof of Thm. is TLF equal to M . p . in T . by an analysis similar to the one which
led to the characterisation of El Set before. f. Therefore. . In the case of the dependent
function space type x El El which at stage is isomorphic to Tm T . . Suppose that T type and
that TLF M . M i g by naturality and equations ConsL and ConsR. thus T M for any
representative M in the class . Using a dependent version of the glueing construction Crole it
is possible to obtain the stronger property that the term M in Thm.f B and M Ty ff g we have
that B. We de ne the result as the syntactic dependent function space . . As long as these
type formers are supported by T and N are the conservativity theorem continues to hold by
the same proof. . we have de ned Set. M fhf.
In a similar direction goes Reus where an interpretation of type theory using synthetic
domain theory has been employed to establish the consistency of a very powerful dependent
type theory incorporating higherorder logic. References Allen. Proving strong normalization
of CC by modifying realizability semantics. and impredicativity. T. . Altenkirch. Nipkow Eds.
Barendregt and T. . There is an intriguing connection with Paulins work on program
extraction in type theory PaulinMohring and the deliverablesquot approach to program
development Burstall and McKinna . Semantical methods in order to derive syntactic
properties of type theories like strong normalisation and thus decidability of type checking
have been used in Hyland and Ong . . Other applications of semantic methods We give
some directions for further reading on the subject of semantical methods in the study of
theories of dependent types. A nontypetheoretic account of MartinLofs types. In each of
these works a type is modelled as a type or a set together with a predicate or a dependent
type and terms are modelled as terms which preserve these predicates. Independence
results are the subject of Streicher and Hofmann and Streicher . but not least we mention the
use of domaintheoretic interpretations of type theory in order to establish the consistency of
general recursion and xpoint combinators with dependent types Palmgren and
StoltenbergHansen . Mitchell. In Symposium on Logic in Computer Science. Types for Proofs
and Programs.We also remark that we have not used any particular properties of the term
model in the construction of the presheaf model so that it can be formed out of any CwF and
thus gives a canonical way to lift a model of some type theory to a model for the presentation
of this type theory in the Logical Framework. A similar interpretation has been used in
Hofmann a where a translation of a type theory with a quotient type former into ordinary type
theory and other applications of syntactic models are described. . In Moggi and Harper. S. .
Connections between categorytheoretic semantics and abstract machines have been noticed
in Curien and Ehrhard and were subsequently exploited and applied in Ritter where an
evaluator for the Calculus of Constructions is derived from its categorytheoretic semantics.
and Moggi categories with attributes are used to give an account of higherorder modules in
functional programming. Altenkirch .. general recursion. Goguen . In H. pp. Last. Springer
LNCS Vol.
Une semantique categorique des types dependants. BRA TYPES workshop. Sci. . P. Dec.
Conf. Springer. Martini . Reductionfree normalisation for a polymorphic system. Dybjer. LICS.
Springer. Sequential Algorithms and Functional Programming. Application au Calcul des
Constructions. G. Odifreddi Ed. T. P. . and S. et al. Streicher .L. T. T. and C. . of the th IEEE
Symp. T. P. Information and Computation . and C. Information and Computation . R. Univ.
Ehrhard. . PaulinMohring . R. Academic Press Ltd. Oxford. . Categorical Combinators.
Metamathematical investigations of a calculus of constructions. Also as LFCS technical
report ECSLFCS. MFCS . M. . To appear. Curien. M. Studia Logica . .. Coquand.
Alphaconversion. In LNCS . and J. Vol.. Crole. The COQ proof assistant users guide. et al. .
M. and T. . pp. D. In Proc. Category Theory and Computer Science. PrenticeHall. thesis.
Inductively de ned types. . . R. Coquand. Huet . . conditions on variables and categorical
logic. . . Beeson. Rapport technique . Springer LNCS. Cambridge University Press. V.
Fundamenta Informaticae . Dowek. . New Jersey. In P. New Brunswick. Implementing
Mathematics with the Nuprl Development System.L. Barr. T. In Proc. Ph. Constable. T. Wells
. Ehrhard. . INRIA Rocquencourt. Foundations of Constructive Mathematics. Substitution up
to isomorphism. A. Dictoses. . on Logic in Comp. Hofmann.L. International Series in
Computer Science. . Manchester. Univ. Internal type theory. June . The Calculus of
Constructions. . Torino. Generalized Algebraic Theories and Contextual Categories.
Cartmell. Asperti. Categorical models of polymorphism. pp. In Proc. Springer LNCS Vol.
Pitman. Curien. Curien. and G. Categories for Types. D. P.. . Springer LNCS. Prentice Hall.
Paris VII. Logic and Computer Science. thesis. Burstall. Coquand. .. Category Theory for
Computing Science.Altenkirch. UK. Ph. J. McKinna . In Proc. Deliverables An approach to
program semantics in constructions.
Lamarche. On the type structure of Standard ML. In Proc. Hyland. J. ACM Trans. G.
Scedrov Eds. In Categories in Computer Science and Logic. San Francisco. . Tiuryn and L. A
uniform approach to type theory. M. CA USA. D. Plotkin . . Conservativity of equality re
ection over intensional type theory.. D. Vol. a. L. M. C. In Proc. Ong . Introduction to
HigherOrder Categorical Logic. M. Extensional Concepts in Intensional Type Theory.
Programming Lang.. Typed operational semantics. A groupoid model refutes uniqueness of
identity proofs. B. . . . and J. June . In J. pp. . . H.. Pitts . M. and E. In J. J. of Edinburgh.
Proc. Jacobs. Honsell.. In Conference record of the th ACM Symposium on Principles of
Programming Languages POPL. E. and A. Poland. Univ. Higherorder modules and the
phase distinction. Huet. J. Hyland. Hofmann. . Typed Lambda Calculi and Applications. ..
Harper. Ph. Moggi . Bezem Eds. Kazimierz. January. Hofmann. The Theory of Constructions
Categorical Semantics and ToposTheoretic Models. of AMS Research Conf. Cambridge
University Press. W.Goguen. pp. In J. and Systems . TLCA . Mitchell . F. AddisonWesley.
Vol. AMS. and C. and T. University of Nijmegen. Hofmann. Gray and A. Springer LNCS.
Mitchell. . A framework for de ning logics. Springer LNCS Vol.H. C. Scott . M. Hofmann.
Harper. Modi ed realisability toposes and strong normalisation proofs. Pacholski Eds. Ph. R.
BRA TYPES workshop. Proc. thesis. R. Edinburgh. Harper. . M. In Proceedings of the th
Symposium on Logic in Computer Science LICS. Categorical Type Theory. AMS. and P. On
the interpretation of type theory in locally cartesian closed categories.. B. Comprehension
categories and the semantics of type theory. Lambek. Journal of the ACM . Paris. F. Springer
LNCS. b. . In Logical Foundations of Functional Programming. . A simple model for the
theory of constructions. Torino. pp. Springer LNCS. CSL . Theoretical Computer Science . To
appear. Colorado. F. Boulder. . . . Streicher . thesis. Groote and M. R. and G. Jacobs.
Sheperdson Eds. Nordstrom. To appear. May. in Comp. University of Edinburgh. Program
speci cation and data re nement in type theory. Struct. Clarendon Press. Z. thesis. pp. Luo.
D. MartinLof. Domain interpretation of MartinLofs partial type theory. . Types for Proofs and
Programs. P. Pollack . pp. Categorical Abstract Machines for HigherOrder Typed Lambda
Calculi. Springer LNCS Vol.. and G. Reynolds. LEGO Proof Development System Users
Manual. In Handbook of Logic in Computer Science Vol. and V. P. and R. Obtulowicz. . .
Intuitionistic Type Theory. Reus. . . Moggi. Ph. pp. Z. J. E.. S. MartinLof. Palmgren.
PaulinMohring. University of Edinburgh. Luo. Plotkin . Studia Logica . Ritter. In S. and B.
Smith . Categorical logic. On functors expressible in the polymorphic typed lambda calculus.
. ACM. C. K. P. Oxford. . . . Computation and Reasoning. Petersson. University of
Cambridge. Technical Report ECSLFCS. Bibliopolis Napoli. E. Methodology and Philosophy
of Science. TAPSOFT . StoltenbergHansen .. A categorytheoretic account of program
modules. . In Proceedings of the Sixth International Congress for Logic. B. Math. Z.
Barendregt and T. . . Logic . An Introduction. Constructive mathematics and computer
programming. D. B. . Ann. Magnusson. Munchen. D. thesis. and J. E. Extracting F s
programs from proofs in the calculus of constructions. Rose and J. A. The ALF proof editor
and its proof engine. . Springer LNCS. . Vol. . Ph. MartinLof. Categorical and algebraic
aspects of MartinLof type theory. E. SpringerVerlag. Oxford University Press. . In H. Logic
Colloquium . Technical Report ECSLFCS. VI. In Principles of Programming Languages
POPL. . Sci. . An intuitionistic theory of types Predicative part. Programming in MartinLofs
Type Theory. L. Proc. LMU. Pitts. . M. of Pure and Appl. C. Nordstrom . A. . Program veri
cation in Synthetic Domain Theory. C. Maibaum Eds. Abramsky and T. In H. E. Oxford
University Press. pp.Luo.. . Nipkow Eds. pp. NorthHolland. .
thesis. The independence of Peanos fourth axiom from MartinLofs type theory without
universes.Seely. . Birkhauser. Journal of Symbolic Logic . Recursive Domains. and D. Smith.
NorthHolland. Troelstra. . Indexed Category Theory. Streicher. University of Cambridge. and
Polymorphism. Ph. Semantics of Type Theory. . A. An Introduction. D. Volume I. . Sci. . . . P.
Taylor. . Struct. Streicher. Mathematical Proceedings of the Cambridge Philosophical Society
. . T. Habilitationsschrift. Semantical Investigations into Intensional Type Theory. Comp.
Constructivism in Mathematics. LMU Munchen. G. J. Locally cartesian closed categories and
type theory. van Dalen . T. Streicher. . R. Math. A. T. Dependence and independence results
for impredicative calculi of dependent types.