<<

Extensional in Intensional

Thorsten Altenkirch Department of Informatics University of Munich Oettingenstr. 67, 80538 Munchen,¨ Germany,

[email protected] 

Abstract also define irreducible terms at other types (like =? ). We

say that such a theory is not adequate because we can con- 

We present a new approach to introducing an extensional struct closed terms of type =? which are not reducible to propositional equality in Intensional Type Theory. Our con- numerals. struction is based on the observation that there is a sound, The problem of in Intensional Type The-

intensional model in Intensional Type theory with a ory has been extensively studied by Martin Hofmann [5].

proof-irrelevant universe of and -rules for ¡ - His basic insight is that extensional equality can be mod-

and ¢ -types. The Type Theory corresponding to this model eled by an intensional model construction such as the setoid is decidable, has no irreducible constants and permits large model, where every closed type is interpreted by a type and eliminations, which are essential for universes. an equivalence . However, a naive version of the se- Keywords. Type Theory, categorical models. toid model does not work because it does not satisfy all the required definitional equalities. In [6] Hofmann presents a solution using a modified of families. Unfor- 1. Introduction and Summary tunately, this approach does not allow definitions of sets or propositions by (large eliminations), in particular In Intensional Type Theory (see e.g. [11]) we differen- this prohibits the introduction of universes. tiate between a decidable definitional equality (which we Our solution is also based on the setoid model but as

the metatheory, where the construction takes place, we use ¤¦¥¨§ ©    denote by £ ) and a propositional equality type ( an extension of Intensional Type Theory by a universe of for any given type  ) which requires proof. Typing only

depends on definitional equality and hence is decidable. propositions XVYZ\[ , such that all proofs of a

In Intensional Type Theory the type corresponding to the are definitionally equal. Moreover, we assume that the - ¢ principle of extensionality rules for ¡ -types and -types (surjective pairing) hold in

the metatheory. We show that this extension of Intensional

 ! #"   ! +

¡%$'& (

 *) § 

§ Type Theory is decidable. Inside our metatheory we define 

' an intensional model which corresponds to a Type Theory –

©.-/©+012 ¦3 ©+04   ©,¡ §¤¦¥



6 !

5 the object theory – with the following properties:

©.-1 ¦38 ¤¦¥

) §7 

 1. Definitional equality (and hence typechecking) is de- -@£

is not inhabited. To see this let 9£;:<£>=? and

A A !E

'E cidable.

0CBD=? 0DBC=? 0HGJI

0D ¦3F£ , where addition is defined





£L0MGNI =?

.t. 09K . Using -elimination we can show that

O4PRQ O4PRQ.UVO4P Q

6O1PRQ 2. is inhabited.

¤¦¥ ©,-/©+04S 34©T01  ¤¦¥ ©.-1 ¦38

¡ is inhabited but 3 is not, because - and have different normal forms. 3. The theory is adequate, i.e. all closed natural numbers It has been an open problem how to extend Intensional

 are definitionally equal to numerals.

Type Theory s.t. is inhabited without destroying other W7 fundamental properties. is provable in Extensional 4. Large eliminations (e.g. a simply typed universe) can Type Theory [10], where propositional and definitional be interpreted. equality are identified, but then equality and type checking

become undecidable. We may introduce a constant of type Acknowledgments. I would like to thank the follow- 

but then, using the elimination constant for ¤¦¥ , we can ing people for interesting discussions, comments on earlier

%HGID % E D

0 B drafts and proof-reading: Andreas Abel, Peter Dybjer, Mar- write for ¢ . It is not necessary to introduce tin Hofmann, Ralph Matthes, Bernhard Reus and Thomas a propositional equality in the metatheory.

Streicher. We assume the existence of inductive types like the type



? BJ ¢¡¤£ I B

of natural numbers = with constructors

  

5

=? *K B = ? ? = and a family of elimination constants:

2. The metatheory 

BI¥§ [¡ 0 B =?

Assume ©+04 for O1PRQ

We work in an Intensional Type Theory (e.g. see [7]) L

B ©,I 

§

6O1PRQ

¢¡¤£ B¦¥¨§ [©¡ ¡¤£ ¥§ [¡ 5

with and , i.e. every is a 5



©T¡ ©MD ©K!©MDR 

¢ ¢¡¤£

type. We assume the existence of ¡ and -types in and

6O4PRQ

5



¡ ©MD

[©¡ ¥§ .

We write the domain of a ¡ -type in subscript to signal implicit which are omitted when applying a term subject to the usual equations for primitive recursion. of this type. If unambiguous we may overload a name (like We say that a Type Theory is decidable if definitional the objects and homsets of a category). When introduc- equality is decidable. This entails the of type checking. A theory is consistent if it is logically consistent ing non-prefix operators we use “ ” to mark the spaces (not all types are inhabited) and equationally consistent (not

for the explicit arguments. The curried application of  to

EE'E E'EE

 ¢ 

 all well typed definitional equalities hold). It is adequate if

2©  ¢

is written . The elements of - 

 ! E

all closed terms of type =? are definitionally equal to a

©1 2 B ¢ 0 B  : ©T01 

types are written as pairs § ,



R©,I 

numeral (i.e. a term of the form KN ).

  for ¢ -elimination we use the projections . Complex

¢ -types are introduced using named projections. The type annotations can be omitted if they can be inferred from the Proposition 1 (Properties of the metatheory) The exten-

context. sion of Intensional Type Theory by a universe of proof ir-

The definitional equality includes the -rules1: relevant propositions and -rules described above is decid-

able, consistent and adequate.

A

E

B  -/©T01 £ - 0 -

0 not free in

O

 Proof (Sketch): It is well known that the standard -



© © S  ©   £  reduction excluding the -rules and proof-irr is terminating

As already indicated in the introduction our construc- and Church-Rosser (e.g. see [1]). On the normal forms we tion hinges on the existence of a proof-irrelevant universe introduce a structural equivalence which incorporates the -

rules and proof-irr. We show that this equivalence is decid-

Z¨[NB ¥¨§ [©¡ XVYZ\[ ! ¡¤£ of propositions XVY and . The in- able and that two well-typed terms are definitionally equal tuition is that XVYZ¨[ contains only sets with at most one in- habitant. This is reflected by decreeing that any two proofs iff their normal forms are structurally equivalent. Hence £ of a proposition are definitionally equal: is decidable. It is standard that the decidability of equality

entails the decidability of type checking. Logical consis-

"$#&% "$#(' %

XVYZ¨[ *) B

B tency follows from strong normalisation. Equational con-

+-,*./.10 ,3,

2 %

"$#(' sistency can be derived from Church-Rosser and the fact



£4) B

? IJK£PK!©TI7 that the congruence does not affect = , hence .

Adequacy holds since the numerals are the only closed nor-

6 B XVYZ¨[

We introduce 5 as basic propositions together

 Q

mal forms of type =? .

B85

with the constructor 7 and the absurdity elimination

5

6:9 B;6  

constant § for any type . Furthermore we

Z¨[ ¡ ¢

close XVY under and -Types: 3. The object theory

"$#=< "

B> ¡¤£ 0 B B XVYZ\[

,3.B+

¡ A@

< E %

"$# In this section we shall specify the object theory, which

0 B B XVYZ¨[ ¡ represents our solution to the problem of extensionality.

We summarize here the essential properties of this theory,

"$#=% " %C#=D

which is an extension of basic type theory with ¡ -types

B XVYZ¨[ 0 B B XVYZ\[

A

)

,*.E+

¢ @

¡

% E D

"$# (the logical framework or ) including the -rule for -

0 B B XVYZ\[

¢ types. As a basic type we assume a type of natural numbers

R

¥¨§ [©¡ =? with the constants and equations as defined in Note that the domain of a propositional ¡ -type may be a set,

the previous section.

F40JB

we will denote this specific instance of a ¡ -type by

< E % D D %

% The object theory features an equality type

B XVYZ¨[

. If and does not depend on we

R R

1 R

S8 ¥§ [©¡ T  ¥¨§ [©¡4 0C S U We omit the assumptions that all the terms have the appropriate types. ¤¦¥8§ ©T0D

2 with the constants rise to a decidable theory since definitional equality in the

metatheory is decidable.

R R E

,¡ £¢

¡0  ¤¦¥ ©+0C 04 §

§ We give a detailed presentation of categories with fami-

 ¨

 ©¨ ! R

5 5

&

©+¤¦¥ ©+0D *S8  : ©T01 : ©S8 K¥¤§¦ K ¡

§ § 

§ lies in appendix A. The basic idea is to define a category

.

©¨

R E R

,¡ £¢

(  ) of semantic contexts and context morphisms. Se-

¡ S : ©+04 ¡

§

§

 

¨ '

! mantic types and terms can be interpreted as a func-

, ¢

¤¦¥ ©K ¤§¦-K © § ©+012 S8S *S8

6 §  .  

tor from  to the category of families of sets s.t. is

 ©¨ ! R;W7 ©¨ !

§  §6 6 the first (set) component of this functor and  the second

(family) component. We then show how to interpret the

, ¢

corresponds to the O rule for the usual definition of empty context, context extension and ¡ -types. The inter- intensional identity types. Here we require only that this pretation of the and the soundness are given equality is provable for propositional equality. The only in [7], section 3.5. definitional equality we postulate is that any two equality It is cumbersome to check all the details of the model

proofs are definitionally equal: construction, which we will only sketch here. Hence we

' ' R

 found it useful to employ the LEGO system [9]. One prob-

4) T *) ¤¦¥8§ ©S  U £ lem we faced is that LEGO (or any other implementation of To show that our construction works for large elimina- Type Theory) does not implement the metatheory described

tions we include a simply typed universe, given by a type in section 2. As a workaround we use LEGO with addi-

 R  R R ¢

tional constants which -expand elements of ¡ and -types

¥§ [¡ ©  ¥§ [©¡ and a family for any  with the following constants: and all elements of propositional types to a canoni-

cal constant. All those terms are identities in our intended

 R

 metatheory. We allow ourselves to decorate any type with

?

R  

5 5 ,3, those expansion terms. See [2] for a partial implementation ? of the model in LEGO. s.t. the following equalities hold:

4.1. The category of

  



© ?  £ =?

  <  5

,3, The basic concept of the model construction are setoids,

© ¨ 2  £ ©  © 

©,? i.e. sets with an . We shall use setoids

. 

B! Our goal is to verify that such a Type Theory exists and to interpret contexts hence we define by the fol- is also decidable, consistent and adequate. The common ap- lowing structure (i.e. a ¢ -type with named projections):

proach to introduce Type Theories is syntactical: decidabil- Q

#"$ B ¢¡¤£ 5

ity can be verified by a combination of a Church-Rosser- 5

&%(' B XVY Z¨[

theorem and strong normalisation. Our impression is that 

B F '/.1032 04%('N0

the approach fails here. *)+$-,

 

5

&

B F '/.1032S©T07%(' S8 ©S8%('N01

As indicated in the introduction we shall follow a differ- *"35£6

P¡9  

ent path here: we define a model of Type Theory inside our Q

& & :

) " B F '/.1032 5

type theoretic metatheory and verify that it is has all the re- 5

©T07% S8 ©S8%  ©+07% 

'<; '&; quired properties. This can be summarized in the following '

theorem: In the sequel we shall often omit the index of % if it is ob- vious which setoid is meant.

Proposition 2 (Existence of object theory) There is a It is important to note that % is propositional, hence we model of type theory with constants and equalities inter- do not have to state any equalities regarding the inhabitants preting the object theory defined above, which is decidable, of % . Categorically any setoid is a trivial groupoid, i.e. a

consistent and adequate. category where every morphism is an isomorphism.

.

B= ©+ >  Morphisms between setoids - correspond 4. The model construction to substitutions in the syntax. They are given by functions

between the sets which respect the equivalence relation:

Q Q 9

The notion of model we are using are categories with 5

> -@? B

"+$ "+$

  9 9

families as introduced by Dybjer and Hofmann [3, 7]. This 5

&

- B F .1032S©T07% S8 ©,-©? ©+04%DC -@? ©S8 

)+$A"+B ' is an intensional notion of model, i.e. definitional equalities ' in the object theory are interpreted by definitional equali- The definition of identity and composition and the verifica- ties in the metatheory. Such intensional models always give tion of the categorical laws is straightforward (but requires

3

¢ - )$A"+B &%@

sitional is not essential here, but simplifies the verification. The functor laws

< <



C

T U £

<

4.2. Types and terms <

T - 3EU £ T - U T 3¤U Since setoids are groupoids, it seems natural to define

can be verified automatically exploiting the fact that £ is

.

#B&

types over a fixed object as functors from to decidable.

.  <

 . This is essentially the approach we take, but we only

B  ©+  Given a type in a context we define the

require the functor laws to hold up to the internal equiva- <

 B  ©+ 

< set of semantic terms , corresponding to the

" # R

 © F

lence of setoids. Hence, a semantic type B is  judgments  . Since types correspond to func-

given by the following structure: tors terms correspond to global elements of a functor, i.e.

Q Q

<

Q

<

?

6V©+01 "+$ 0NB! *"$

5 

. to families of elements in indexed by

?

6 B *"+$ 

Q  

< which respect the equality. This can be spelt out as follows:

¡£¢

&

" " B ¡ '/. 0322©+07%('4S 

Q Q Q

E <

Q Q

< <

5 5

B ¡0 B ? ©T01 

6 "$ 6 "+$

? ?

6V©+01 "+$ 6V©S8A"+$

   §

©

Q¥¤

<   ¨§ ©   '

 B F & & ¦

)+$A"+B

' . 032

¡£¢

" " B F & & ¦ & !& © #%¦2

. 032 .1032

'



Q Q Q

< '



Q Q

< ' < '

¡¢

5

©T01  % ©S  ©  

" " 6 6



¡£¢ ¡¢

© " " © * % " " © 3 

Q

<

¤

< 6  '



¡£¢

" "

B F &

)$-,

'/. 032 . 032

 Note that we have to use to define what we mean Q

< by preserves equality, since the images of equal elements in

¡£¢

©+ ©T012 * %?

" " )+$-,

<

Q P 9

?

6 < ¤    ¨§  §  !

© 

© end up in different slices of . As for types we also

B F & & : & ¦ &  : &

) "

'/. 032 .1032

 have to define the effect of substitutions on terms, i.e. given

Q Q Q Q P¡9

< < ' < '

<

.

¡¢ ¡£¢ ¡£¢

© ) © *  % ©+ © 3)6S * 

" " " " " " ) "

B  ©+ 2 - B  ©> ¥ F

 we define

<

Q

< <

¡¢

 T - U B  ©> T - U+

?

" "

6 is the object part of the functor, the morphism

Q¥¤

<

Q Q 9

A

E

¡£¢ "

part, where " corresponds to the condition that a mor-

?

 T - U 6 £ 0  6 ©,- ©+01R

A

DE '

phism between setoids has to preserve the equivalence rela- '

¤ Q P 9

< < ¤

 T - U )$A"+B £ 0D S4 A)+$A"+B\©.-©)+$A"+B8©  

)+$-, " tion. and ) correspond to the functor laws up

to the internal equivalence of setoids ( % ). We also have to check that this construction preserves iden-

<

  ©> 

Semantic types form a presheaf, i.e. given B tity and composition:

. 

- B  © > 

and a setoid morphism we can construct 

<

C

 T U £ 

- U B   ©+ F

T s.t. identity and composition is preserved.

T - 3EU £  T - U T 3EU

This corresponds to substituting in a type syntactically. 

<

- U T is given by

Note that these equations are only well typed if the presheaf

<

Q 9

A

E < <

- U

laws for T hold. Again they can be checked automati-

? ? ?

T - U 6 £ 0 B4 *"+$ 6%©.- ©T01 

Q Q

A A

E ' E

< cally, see [2].

¡£¢

C

B ©T07% S8 T - U " " £ 0D SMB=> "+$

Q

< '

¡£¢

©,- ©  

" )$A"+B

" 4.3. Contexts

Q¥¤ Q

A

< ' E

¡£¢

T - U £ 0D SMB=> B 04% S

" " "+$ '

Q¥¤ '

< We have to define an interpretation of the empty context

¡¢

©.- ©  

" " )+$A"+B

 .

B 

¤ Q ¤ 9

A

E <

< :

T - U £ 0 B4 ©,-@? ©+01R

)$-, "+$ )$-,

Q



Q P 9 Q

A

E < ¤

"+$ £ 5

T - U ) " £ 0D S4 B7 *"+$

;

A

' E

04% S £ 5

B ©T07%(' S8S 3) B ©S8%(' 

;

Q P¡9

< ¤ '

.

) " ©,-)+$A"+B8© S -©)+$A"+B\© )6 

This is a terminal object in  .

<

. 

B  B< © F

¤ Q P¡9

< <

¤ Given a context and a type we

E <

T - U T - U

)+$-, " To see that and ) have the correct types can construct a new context which syntactically corre-

we need that <

 © F

sponds to introducing a new variable of type B .

E < 9

The non-propositional components of are given by:

?

-©)$A"+B\©+ *)+$-,1©+01R £< #)$-,¨©,- ©+01R

Q Q Q

E < E <

£ ¢ 0 B7 ? ©+04 ©+ 

"+$ 6 "+$ "+$

E

and '

©T0D 3 %('  ©S4 2 £ ¢ B ©+0 %(' S 

Q Q P¡9 Q P 9

< ' ' '



¡¢

 " " © * % -©)$A"+B8©+ ) "2© 3)6  £& ) "2©,-©)$A"+B\© S -©)+$A"+B8© )6 



4

Note that ¢ -Prop in its dependent form is essential to type The associated equality is pointwise equality:

%(' 

9 9 Q

 ! < E .

? ? ?

©  ©  % 3 -7% &  3 £ F B 6V©+01 "+$ -

)



% 

We have to show that ' is an equivalence relation.

¤

<

 !

)+$-,

Reflexivity follows from )+$-, and . Transitivity can

Q P¡9 Q P¡9

<

¤

% & 

)

To show that  is an equivalence relation we

 

) " "

be shown similarly using and ) . To show sym-

' '

% &

exploit the corresponding conditions for  .

9 Q

<

© 3)6BJ©+0C * D% B 0 %;S ©S4 3 

metry assume ' , i.e.

¡£¢

Q

< '¡ ' '

?

-©)+$A"B B ©   " " ©.-

To define ¡ assume

¡£¢

< '

) B £ © B>S %<0 © *  % 

" "+5£6

and " . Clearly ,

Q

< '¡

¡ ©  -? ©T01 BM04%4S

6 and . We have to construct

¡£¢

B " " © 2 % 

we have to construct ) . This can be

Q P¡9

¤

< < < ¤

9 9 Q

< '

?

6©+01 "35£6 ©)6 )+$-, ) "

derived from using and . ¡¢

? ?

3 )+$A"+B -©)+$A"+B7  £ © 3 ¡ ©  A" " © !©,-



0 

<

K ¥

We have to define projections K and , a pairing oper-

B ¡ ©  -? ©S8

6 ©,

ation ©    and an empty substitution . The projections

 ¥ are needed to interpret variables — K is the last variable

 We define 0

and K corresponds to weakening. Their set-theoretic com-

9

< E

? ? ?

B ¡ B 6V©S8  6V©S4 3

ponents are given by the obvious definitions: 3

9 Q 9 Q

A

E ' ' < '

¥¤§¦¡9

¨

E

¡¢ ¡£¢

. 

3? £   © 2©,-©? © ©+ © S 3   

" " " " "35£6

©. B ¡£¢  © 

9

A

E

Q Q

'¡ < ' < '

©,A? £ 0 7

¡£¢ ¡£¢

B © ©+ © S 3R % 

" " " "

where "35£6 can be de-

¨ Q P¡9 ¤

¥¤§¦¡9  RE " E < <

¤

. 

©¦  '  B ¡ © & & ¡ - B  ©  3

) " )+$-, )+$A"+B

56 ¢

¢ rived using and . To construct assume



¨

E < < "

5

. 

) BI#% 

 , we have to show that

©

  © T - U   ©

9 9 Q

A

E

Q 9 9

©+01R ©,-1  A? £ 0 ©,-@? ©+04S *

6

¡£¢

 © ©+ ©S8S 3)6S 3? ©   % 3? © 2

" "

)+$-, (Q)

 ¥¤§¦¡9  RE

0

K B ¡ © & &

¢ 56 ¢

Q

< '

¡£¢

¨ ¨

" E < "

 £ ©+ © S 3  £

" " "35£6

5

 .

. is inhabited. Let ,

Q Q ¤

< ' <

 ©   © 

¡¢ ¡¢

© © 2 32 -

" " "35£6 " " )+$A"+B

9 9

A E

 . Using and we can derive

0 

? ?

K ©,-  £ 0  ©,- ©+04 

Q 9 9

¥¤§¦¡9  RE



¡£¢

 © © ©S82 *)6S -@? ©  R% -@? ©  

" )$-,

" (H)

& K ¥ B ¡ © &

¢ 56 ¢

¨

" E < E < 

.  0

Q

< '

©

¡%- B  ©   © T K ©.-  U+

¡¢

)  ? ©+0D © © 2 32R

" " "35£6

from . This equality lives in 6 .

Q 9

A

E

Q

< '



¡£¢

 ?

K ¥ ©.-  6 £ 0  ©,- ©+04 

 B ©+0C ©+ © S 2 % ©S4 2

" "35£6

We can construct " us-

Q P 9 ¤ Q ¤

< ¤ <

¡¢

 

) " )+$-, " "

¡ + , ing and . Applying to to (H) we de-

The verification of the corresponding K components is

rive an equation in the same slice as (Q). (Q) can be derived

Q P¡9 ¤

straightforward. ¤

 

" )$-, from this using ) and exploiting proof-irr. Using pairing and projection we can define a lifting op-

The details of this construction and the derivation of

 

¡

, ¢ , 

eration which will be useful for the definition of -types:

<

K¥¤ ¦-K ? K 

. , and have been formally checked, see

B  © > S B=  ©>  given - we define

[2].

E < E <

. 

¡

B  ©+ T - U. ¡> 

- We have to check that our definition of -types is

  

  

0 consistent with substitution, this corresponds to the Beck-

£ ©,- K © $ S 3K ¥ © $+ 

 ' 

' Chevalley condition in fibered category theory, i.e. given

. 

B  © > F

We note that - we have to verify:

9

9

< <

?

- ©T0D 3 £ ©.- ©+04S 3

?

¡ ©   T - U £ ¡ © T - U. ¡&T - U+

4.4. ¡ -types Again this is an instance of the decidable definitional equal-

ity. A

Higher order types, i.e. ¡ -types, provide the essential To interpret -abstraction and application in the syntax

<

 

+ +

B   ©+ F

?  

test that our construction works. Given and we have to provide the constants ? and . Their

< E <

B   © F ¡ © ¡  B

a semantic type  we define components are given by:

©+  ¡

 . This corresponds to the -. Ele-

 ¥¤§¦¡9   E

?  B ¡ © & © &  ©

56 5 

ments of ¡ -types are dependent functions which respect

Q

<

5

0 B "+$ - B

© ©

©    ©,¡ ©    

the equivalence relation, i.e. assuming : 

Q

<

Q Q Q Q

A

 < E

?

©   6©+04A"+$

¡ is given by the following structure:

?  ©  * B ? ©T01  £ 0 B7 ©R©+0C *  

6 "$ 6 "$ 6

9 Q Q

< E

¥¤§¦¡9   E

+ +

? ? ?

- B ¡HB 6V©+04A"+$  6©+0D 3 A"+$

? B ¡ © & © &  ©

56 5 

 § ! 



< E <



5

& ¦ -©)$A"+B B F &

.1032



© ©

 ©,¡ ©     ©  



Q 9 9 Q Q Q

A

' E < E

+ + 

¡¢

? ? 

 " " ©R©+ *)+$-,4©+012 S - © R%J- © 2 ? ©  6 £ 0 B ©+  "+$ - 6©+0 0 

5

, +

It is straightforward to verify the K components. We also 4.6. The simply typed universe

have to check the definitional equalities corresponding to O



and hold: .

B  B  © F

Given we define as a constant

Q





T T = ? U U T T¨ U U £ T T U U ©T01

"+$

+ +   ?

type similar to — 6 is given by

?  ©T? © R £

 the inductive type generated by

+ +

? © ?  ©   £ 

¨  B T T¨ ¨U U

and that both operations behave correctly wrt. substitution 



? BAT T ¨U U

,*,

? ©1 3 B T T ¨U U

 

?  ©  T - U £ ?  © T - U 

 

5 5

+-+  + + 

? ©  T - U £ ? © T - U 

 .B T T ¨U U T T U U XVYZ\[

We define % in the same O1PRQ

fashion as % :

Non-dependent spaces are a special case of the

<

   

 

¡ ¡ B= ©+ 

%   ? £ 5

-construction. Given we define ?

  G

,3, ,3,

? ©1 2%  4? © 3  £ ©*%   ©  %  

<¡ < 

0

 £ ¡ © &T K U+

*%  £ 6

 otherwise

B   ©+ F

 E 

T T U UDB=  ©+ T T¨ ¨U U+ T T U U

?

6 ¢

< We define : is given by:

0

   ©T01

We note that © can be defined using only

<

  



? ©+04S  ? ©+04 6

6 and we denote this by

T T U U ©+0C ?  £ T T =? U U ©+04

? ?

6 6

  

,3,

5

. ¤£ .  .

?

T T U U ©+0D ? © ¨ 2  £ T T U U ©+0D 3  6?T T U U ©T0D 2

? ? ?

6 6 6

? B   

6



Q

¡£¢

T T U U "

This observation leads to a simpler definition of the simply " and the other components of the structure can be typed universe. derived from the corresponding components of .

4.5. Natural numbers 4.7. The equality type



. 

< <

B  T T =? U UVB& ©+  

Given we define by a con- .

B  B  © F T T ¤¦¥/U U¦©  B

Given we define

E < E < < < 

stant family: 0

©  £ T K U

 , where . From now in we shall

Q 

 ignore weakening morphisms and use variables to denote

T T = ? U U ©T01 "+$ £ =? ?

6 projections. We define:

  O1PRQ !



%  

O1PRQ 

is defined by structural recursion, i.e. by trans- Q

< '



L

?

T T ¤¦¥/U U¦©  6V©T0D 3¨ 2A"$ £ #% 



lating the following definition into applications of § :

 '   



& !& ) £ 5 %  



I %NI £ 5

Q

<

¡¢

T T ¤¦¥/U U © 

" "

!©¦¥ %NI £ 6

K To define assume that

'



I %4K!©MD £ 6

© 3) 6 B ©+0C *1 32% ©S1 3  

'  

K!©¦¥ %4K!©MD £ ¥ % M

 Q

' ' < '

O4PRQ

¡¢

L

B 0 % 0 B © 3 %  "

i.e. , " and

Q

' < '

Again using § it is straightforward to show that

¡£¢

  O1PRQ !

B © 3<%  ) B  % 

" "

 . Now given we

Q Q

< ' < ' <

%  

Q

 is an equivalence relation.

¡¢ ¡¢

¡¢

© 3  % © 2

" " " " "

know using " . Using

Q P 9

<

T I1U U T T KU U

The definition of T and is obvious:

?

V©+04 ) "  %;

6 we can derive . The verification of the

  



T ¤¦¥ U U %  

other components of T is trivial because is propo-

T T I1U U B T T =? U U

A E

9 sitional.

T T I1U U £ 0 I

?

,¡ £¢

T T U U



 To define we construct

T T¨§ U U B T T =? U U T T = ? U U

A

E

R E RB< 9

, ¢

T T § U U £ 0C M K'©MD

T T U U B  ©T0  T T ¤¦¥/U U T ©+0C *1 *  U

?

A

E <

9

,¡ £¢

, +

T T U U £ 0D 3 ? ©+01

6 )+$-, ?

The corresponding K -components are inhabited since



,¡ £¢ , ¢

O4PRQ

I % I K!©¦¥ %?K'©MDW£©¥ %4M

T U U £ ?  ©*T T U U 

and . T L

The interpretation of § is more involved using the

,¡ + corresponding constant in the metatheory. In this case K is trivial.

6

E <

B  © 

Given  we define 5. Discussion and further work

 < R RB< RB< E

. 

T T K¥¤§¦ K U U¦© ¡  B  ©T0 3 

To show that setoids from a category  we do not

E

T ¤¦¥/U U T ©+0C *1 3 U =T*©T0D *  U. ¡&T ©+0D 2 U+

T require proof-irr, but already to have a notion of semantic

A

 < E

9

T K¥¤ ¦-K U U¦©   £ ©+0C *1 3 *) S8

T types along the lines we have described here relies on this

?

Q ¡ £¢

, feature of the metatheory, e.g. see section 4.2. In the entire

¡¢

 " " ©R© ©T012 *)6S *S8

<   <

 construction proof-irr is needed frequently.

T K ¤§¦-K U U ©   £ ?  ©T T K¥¤ ¦-K U U¦©   

T We are not able to show that proof-irr is essential for the

 

¡ construction but experience with previous attempts (by the

N

 ?  where ? is the -fold application of . author and by Martin Hofmann) does suggest this. Hav-

We also define ing to deal with inconvertible proofs perpetrates the con-

R E RB< E R

< struction and eventually leads to failure. Having proof-irr

,¡ £¢

T T U U © ¡  B  ©T0  S &T ©+0C *  U

adds some extensionality to the system, in particular since

 <

T T ¤¦¥ U U T ©+0C '©*T T K¥¤ ¦-K U U © ¡  T ©+0C *1 *1 ¡

XVYZ\[ is closed under -types whose domains are sets. In

,¡ £¢

the pure system it is not even provable that a ¡ -type whose

T T U U T ©+0C *  U S8 U. *S R U+

¤

A

< E

9

,¡ £¢

is propositional, i.e. has at most one , is

T T U U ©   £ ©+0C *1 S8  )+$-, ©R©+0C * S *S 

?

 <

< propositional itself.



,¡ £¢ ,¡ £¢

T U U¦©   £ ?  ©T T U U © ¡   T We have already mentioned Martin Hofmann’s work on

the subject [5],[6]. It is also interesting to compare our con-

, +

Again K is trivial. Q

< struction with the groupoid model used in [8]. Note, that

-1 3 B ¡ ©  A? ©+01 "+$

Assuming 6 we define the groupoid model requires an extensional type theory as RE<

¢¤£ metatheory. Another difference is that the equalities corre-

+-+ + +

 

,  , ¢

@©.-1 ¦38W£J¡ © T 0 U T T ¤¦¥/U U T 0D !©T? ©,-1 3 S R? ©+31 3R U

? K ¤§¦-K sponding to K and have to hold strictly (i.e. for metatheoretical equality) whereas we state them in

We note that terms of the equalities of the respective semantic types.

Q Q <

¢¤£ We have only presented a simply typed universe to show

@ ©,-1 3 A? ©T01 £ T T ¤¦¥ U U ©,¡ ©   -? ©+01

"+$ 6 "+$ 6 that our construction allows large eliminations and hence essentially generalizes Hofmann’s construction [6]. We be- Hence we can define

lieve that it is possible to interpret a full dependent universe

Q

E  < R E R < ¡¤£

(corresponding to in our metatheory) using inductive-

?

T T U U ©   B  ©+0 -1 3 ¡ © ¡  6 ©+01 "+$

¢¤£ recursive definitions as introduced in [4], but we have not

B @©.-1 ¦38S

) yet verified all the details.

<

T ¤¦¥/U U ©,¡ ©    T ©+0C -1 3  U 

T It should be straightforward to interpret quotient types

A

 < E 9

as described in [6]. Another interesting application is the

T T U U © ¡  £ ©+0D -1 ¦34 *)6 )

?

7 <   <

introduction of coinductive types.

T U U¦©   £ ?  ©*T T U U ©   

T Finally, it would be interesting to implement the object Q

< theory directly, without translating it into the metatheory,

T T ¤¦¥/U U¦© A? ©+0C *1 3 "+$ All elements of 6 are definitionally possibly using a substitution calculus for dependent types. equal in the metatheory since it is propositional, hence the required definitional equality holds. 4.8. Proof of the main theorem [1] T. Altenkirch. Constructions, Inductive Types and Strong Proof: The model construction above verifies our Normalization. PhD thesis, University of Edinburgh, November 1993. main theorem, proposition 2. We have interpreted all the [2] T. Altenkirch. The implementation of a setoid model in constants introduced in section 3 and have checked that LEGO. Available on the WWW at: the equational conditions hold. Equality in the model is http://www.tcs.informatik.uni-muenchen.de/ decidable because it is given by definitional equality in ˜alti/drafts/setoid.html, December 1998.

the metatheory. We observe that it is consistent since [3] P. Dybjer. Internal type theory. Lecture Notes in Computer

©TI\ §7©TI7  I §7©TI7

¤¦¥ is not inhabited and and are not defini- Science, 1158, 1996.

 ? tionally equal. It is adequate because = only contains [4] P. Dybjer. A general formulation of simultaneous inductive- elements which are definitionally equal to numerals. Note recursive definitions in type theory. Journal of Symbolic that we use proposition 1 here. , 1997.

7

< <

C

 © > S * B  © S - B

[5] M. Hofmann. Extensional concepts in intensional type the- which given B

¦ ¦

.  . 

© ¡> S 3HB  ©  ory. PhD thesis, University of Edinburgh, 1995.  satisfies

[6] M. Hofmann. A simple model for quotient types. In Proc.



C

T U £  TLCA '95, volume 902 of LNCS, pages 216–234, 1995. 

[7] M. Hofmann. of of Computation, chap-

 T - 3EU £  T - U T 3EU ter Syntax and Semantics of Dependent Types. Cambridge University Press, 1997.

[8] M. Hofmann and T. Streicher. The groupoid interpretation A.4. Wellfounded context comprehension

 . 

of type theory. In Venice Festschrift. 1996. B

¥¤§¦¡9

E E

5 

[9] Z. Luo and R. Pollack. The LEGO proof development sys- .

B ¡  ©+  

'

¥¤§¦¡9

tem: A user’s manual. LFCS report ECS-LFCS-92-211, E

. 

 ©>  B ¡(C

University of Edinburgh, 1992. ©.

E E ¥¤§¦¡9 

.

¡ - B  ©+ ¡>  & B ¡ &

[10] P. Martin-Lof.¨ Intuitionistic Type Theory. Bibliopolis, 1984. ©¦  ' 

C C

56 '

< E <

5 

[11] T. Streicher. Investigations into intensional type theory, .

' © T - U+  ©+ ¡> 

1993. Habilitationsschrift. 

E ¥¤§¦¡9  

0

& K B ¡ &

C C

56 '

E <

5

. . 

©+ >   © > 

A. Categories with families as models of Type 

E ¥¤§¦¡9 



& K ¥ B ¡ &

C C

56

Theory '

E < E < 

. 0

¡%- B  ©+ ¡>  8' © T K ©.-  U+

<

  . 

A model of Type Theory is given by the following data: .

#B  © S - B  © > 2 B

which given

< E <

. 

 © >   B 8' © T - U 2 ¨§ B  © > S 3 B

¦ 

A.1. A category of contexts and context morphisms .

© F

 satisfies:

. 

 B ¥§ [©¡

£ ©,

'

5 5

.  .  . 



 B   ¡¤£

0

K ©.-1   £ -

¥¤§¦¡9

E



. 

B ¡  © ¥ F

'



K ¥ ©.-1   £ 

¥¤§¦¡9

E

. 



& &

 B ¡  © 6 ¥ 

'¡ '£¢ '¥¤

0 

© K © §1S 3K ¥C© §1  £ §

5 5

.  . 

 

 © ¥ !  © ¥ 

©.-1    3 £ ©,- 31 * T 3¤U+

 

¦

0 0

.  . 



K ©,-   3 £ K ©,-  38

B  © > FS 3 B  © > S ¨§ B

which given -

¦ ¦

.  

 



 © 

satisfies:

K ¥ © §¨ T 3¤U £ K ¥ © §  3 

<



. 

'  - £ -

B  ©+ > 2 B=  ©> 

Given - define



E < E <

C

- £ -

.

- B  ©+ T - U > 

  

 

©,-  38 ©§ £ -%© 3 ©§¨

0 

£ ©.- K © $ 2 *K ¥D© $  

'  ' 

A.2. A presheaf of types

A.5. Closure under ¡

¥¤§¦¡9

E < E E <

5

. 

5

  B  ¥¨§ [©¡

¡ B= © F  ©    ©+ F ¡ B ¡ '

¥¤ ¦ 9

E

¥¤§¦¡9   E 

&

(T U B ¡ C   ©> 

'

& &  ?  B ¡

' 5 ' 56 ' 

<

5 5

.

5

 ©+ >   © F

 '  ©   *' ©T¡ ©  R

¥¤§¦¡9   E

+ +

< ¦ ¦

& &  ? B ¡

' 5 ' 56 ' 

. .

B  © > S - B  © ©+ > 2 ¦3 B  

which given <

5

' ©,¡ ©    *'  ©  

satisfies: 

< E <

< <



 4© FS ¡ B  © S - B

which given B

<

C

T U £

.  

 © > FS * B  '  © 2 B 8' ©T¡ © ¡   <

< satisfies

T -  3¤U £ T - U T 3EU

< <

¡ ©   T - U £ ¡ © T - U &T - U+

 

 ©  T - U £ ?  © T - U 

A.3. Families of terms ?

¥¤ ¦ 9

+-+  + + 

E

5

? ©  T - U £ ? © T - U 

 B ¡   ©+ F ¡¤£

'



¥¤ ¦ 9  + +   E <

?  ©T? © R £

C

(T U B ¡ & &  © 

C C

' 56



+ +

E <

5

.

? © ?  © R £ 

¡ - B  ©+ ¡>   ' © T - U+

8

B. Interpretation of the syntax

T* U U We define a partial interpretation ( T of annotated syn- tax in a model as defined in the previous section, i.e. terms,types and substitutions are annotated with their con-

texts and types. We assume as given an interpretation of

" "

T U T T¡ ¨U UMB   ©T T U U+

type constants as and term con-

R "  

 T U T T ¢ U UCB  ©   ©*T T U UT

stants ¢ as .

"

. 

T U UCB 

Contexts T



T T U U £

" E R " E

T T 0 U U £ T T U U T T U U

"

© &

§

T 0 U U B7 ©T T U U T T U UT

Variables T

¨

  ¨



© &

 § §



©  + T T 0 U U £ K ¥ ©

 §

¨

  ©¨ 



© & ©8&

 §  

0

©  + U T T 0 U U £ T T 0 U U T K ©

 §

© &

¢

¨

"

.

T¤£ U UDB  ©T T U U T T U U+

Substitutions T

T T U U £ ©.

£ £

T T S R0M£  U U £ ©*T T U U T T  U U+

"

©

T  U U B7  ©T T U U 

Types T

R E

T T ¡ 0  : U U £ ¡ ©T T U U T T :/U UT

 

©8&

§

T  U UCB  ©   ©T T U UT

Terms T

A

R E 



T T 0   U U £ ?  ©*T T  U UT

¨

 



© & ©¦¥+& ¥

) §  §

 + + 

T T  ©  U U £ ? ©*T T  U UT T © ©  + U

" "

T U U £CT T U U T T U U £8T T  U U if T and

Given a definition of the following judgments:

Contexts #="

¨

"$# R £

Substitutions 

¨

"$# R



££

Equality of substitutions £ "$#

Types 

"$# £J:

Equality of types 

"$# R 

Terms 

"$# R



£  Equality of terms  we can state the soundness theorem (see [7]) Theorem 1 (Soundness) The partial interpretation given above is 1. total for derivable judgments, 2. derivable equalities are reflected by equal elements in the model.

9