TYPETHEORETIC METHODOLOGY FOR PRACTICAL

PROGRAMMING LANGUAGES

A Dissertation

Presented to the Faculty of the Graduate Scho ol

of Cornell University

in Partial Fulllmentofthe Requirements for the Degree of

Do ctor of Philosophy

by

Karl Fredrick Crary August

c

Karl Fredrick Crary

ALL RIGHTS RESERVED

TYPETHEORETIC METHODOLOGY FOR PRACTICAL PROGRAMMING

LANGUAGES

Karl FredrickCrary PhD

Cornell University

The signicance of typ e theory to the theory of programming languages has long been recog

nized Advances in programming languages have often derived from understanding that stems

from typ e theory However these applications of typ e theory to practical programming lan

guages have b een indirect the dierences between practical languages and typ e theory have

prevented direct connections b etween the two

This dissertation presents systematic techniques directly relating practical programming

languages to typ e theory These techniques allow programming languages to b e interpreted in

h mathematical domain of typ e theory Suchinterpretations lead to semantics that are the ric

at once denotational and op erational combining the advantages of each and they also lay the

foundation for formal verication of computer programs in typ e theory

Previous typ e theories either have not provided adequate expressiveness to interpret prac

tical languages or haveprovided such expressiveness at the exp ense of essential features of the

typ e theory In particular no previous typ e theory has supp orted a notion of partial functions

needed to interpret recursion in practical languages and a notion of total functions and ob

jects needed to reason ab out data values and an intrinsic notion of equality needed for most

interesting results This dissertation presents the rst typ e theory incorp orating all three and

discusses issues arising in the design of that typ e theory

This typ e theory is used as the target of a typ etheoretic semantics for a expressive pro

gramming calculus This calculus may serveasaninternal language for a variety of functional

stated as a syntaxdirected emb edding of the pro programming languages The semantics is

gramming calculus into typ e theory

A critical p oint arising in b oth the typ e theory and the typ etheoretic semantics is the issue

of admissibility Admissibilitygoverns what typ es it is legal to form recursive functions over To

build a useful typ e theory for partial functions it is necessary to have a wide class of admissible

typ es In particular it is necessary for all the typ es arising in the typ etheoretic semantics to

be admissible In this dissertation I present a class of admissible typ es that is considerably

wider than any previously known class

Biographical Sketch

Karl Crary was born in Madison Wisconsin in In he moved with his family to

Seattle Washington where he grew up He started college at Carnegie Mellon University in

and earned bachelors degrees in Computer Science and Economics in He then

b egan graduate scho ol at Cornell University where he remained until iii

Acknowledgements

I wish to thank my parents Fred and Betsy for their constant love and supp ort throughout

my childho o d and adultho o d More than anyone else they have shap ed the way I see and

think ab out the world Iwant to thank Ross Willard for intro ducing me to logic and mo dern

mathematics and John Reynolds for intro ducing me to the world of typ e theory I also am

very grateful to Rob ert Harp er for serving as my undergraduate advisor for teaching me

so much and for all his encouragement while I was his student and continuing even to day

Particular thanks go to Rob ert Constable my graduate advisor and to Greg Morrisett

The least they did was to teach me most of the material on which this dissertation and the

rest of mywork is based More imp ortantly they were a constant source of ideas sound advice

and encouragement I also wish to thanks Dexter Kozen for all his help and inuence

I also wish to thank all the many teachers family and friends who help ed me get where I

am to day and who made it pleasant getting here Finally I want to thank Go d for creating

the world and for showing me the life b eyond iv

Table of Contents

Intro duction

The KML

Features

Comparison

The Role of Typ e Theory in the Design

Principals

Typ e Theory

LambdaK

Overview

Lamb daK

The Core Calculus

The Mo dule Calculus

Static Semantics

Design Issues

The Phase Distinction

Top and Bottom Typ es

Typ eTheoretic Semantics

A Computational Denotational Semantics

The Language of Typ e Theory

Domain and Category Theory

ATyp eTheoretic Semantics

Basic Emb edding

Emb edding Recursion

Emb edding Kinds

Emb edding Mo dules

Prop erties of the Emb edding

Prosp ects for Extension

Conclusions

Foundational Typ e Theory

Nuprl

Basic Typ es and Op erators

EqualityandWellformedness

Prop ositions as Typ es

Equality and Inequality v

Constructivity

Constructing New Typ es using Logic

Computation

P artial Typ es

Sequents and Pro of

Functionality

ExtractStyle Pro of

Issues in Partial Ob ject Typ e Theory

Partial Computation

Computation in ActivePositions

Fixp oint Induction

Computational Induction

Other Contributions

Semantics

Typ e Semantics

Judgement Semantics

Classical Reasoning

Admissibility

The Fixp oint Principle

Computational Lemmas

Computational Approximation

Finite Approximations

Least Upp er Bound Theorem

Admissibility

PredicateAdmissibility

Monotonicity

Set and QuotientTyp es

Summary

Conclusions

Conclusion

A Lamb daK Typing Rules

B Nuprl Pro of Rules

C Pro ofs

Bibliography vi

List of Figures

Lamb daK Syntax

Lamb daK Shorthand

Higher Order Power and Singleton Kinds

ATypical Mo dule Enco ding

Typ e Theory Syntax

The Typ e Triangle

Emb edding Kinds and Typ es

Emb edding Terms

Emb edding Signatures

Emb edding Mo dules

Basic Nuprl Typ es

Derived Forms

Op erational Semantics for Nuprl

Primitive Nuprl Typ es

Typ e Sp ecications

Typ e Denitions Data Typ es

Typ e Denitions Assertions

Typ e Denitions Set and Quotient

Admissibility coadmissibility and monotonicity conditions vii

Chapter

Intro duction

The distance between theory and practice is shorter in theory than in practice

Unknown

The development of practical programming languages has lagged far b ehind the stateofthe

art of theoretical programming language study Examples ab ound of programming language

techniques and metho ds that havebeenwell known and understo o d for years but still haveyet

to app ear in any practical programming system This can be frustrating to the programming

language theoretician who also writes co de and that frustration is not diminished by the

knowledge that the gap b etween theory and practice is common to many if not most elds of

study

The main reason that the gap between theory and practice is often so wide is the issue

of elegance Programming languages can admit extremely elegant theoretical study This

elegance is partly resp onsible for the rapid progress of results in theoretical programming lan

guages and it is partly resp onsible for the attractiveness of programming languages as a eld

of study However such elegance is usually achieved by abstracting away from the details of

real languagesdetails that are essential for real languages to b e usable

In my thesis research I set out to design and implement a practical programming language

to incorp orate unutilized developments in programming language theory The result was a

dialect of ML that came to be called KML Not surprisingly I was so on grappling with the

elegance gap b etween theory and practice To manage the complexity of a real system I allowed

typ e theory to drive the design That is I adopted the strategy of cho osing at every design

p oint an option that was easily represented and justied in an underlying foundation of typ e

theory

This strategy proved remarkably eective and resulted in a language design that was versa

tile and p owerful but also relatively simple However allowing typ e theory to drive the design

of KML paid another dividend which had wider applications than to the KML language alone

The typ etheoretic design of KML led me to explore not only how typ e theory can motivate

language design informally but also to explore how and why to draw formal connections

between practical programming languages and foundational typ e theory

This dissertation fo cuses on the latter asp ect of my thesis research formal connections

between practical programming languages and foundational typ e theory In this thesis we will

see various sp ecic applications of such connections but from a broader standp oint the aim

of the work I discuss here is to draw theory and practice closer together The constructs that

makeuptyp e theory are p owerful and uniform making it p ossible to reason ab out issues facing

real languages without sacricing elegance

The KML Programming Language

A complete discussion of the KML programming language is b eyond the scop e of this disserta

tion I give here a brief and informal intro duction to KML and its contributions

Features

The main ob jective of KML was rst to incorp orate into a practical dialect of the ML pro

gramming language a number of useful language features not present in preceding dialects of

ML while building the entire language on a solid theoretical foundation KML is structured to

greatly resemble Standard ML for the most part Standard ML is a strict subset of KML The

dierences b etween KML and Standard ML lie in the way KML is sp ecied and in the addi

tional language features supp orted byKMLob jectoriented programming subtyping a more

expressive mo dule system and rstclass p olymorphism These features are chosen b ecause they

can assist in a real and practical way with the task of programming

A KML is implemented that consists of a KMLsp ecic front end which compiles

KML to an intermediate language based on the p olymorphic lamb da calculus and a back end

that compiles that intermediate language to Typ ed Assembly Language

At the time of this writing the design of KML is substantially complete but is still changing

in a number of areas Therefore the reader should take the following descriptions of KMLs

features as tentative

Ob jects Ob jectoriented programming is supp orted in KML through a primitive ob ject cal

culus that is substantially similar to that of Abadi and Cardelli Ob jects are seen as

collections of metho d functions each of whichtakes the entire ob ject as an argument and com

putes a result A metho ds results may b e a new ob ject of the same typ e such results are

usually pro duced by up dating one of the elds of the ob ject with a new metho d implementation

In the present design primitive ob jects are the extent of the supp ort for ob jectoriented

programming From primitive ob jects it is p ossible to co de more complicated artices like

classes and inheritance I plan builtin syntactic supp ort for classes and inheritance in a future

version of the design

Subtyping The KML typ e system completely integrates supp ort for subtyping Subtyping

arises by dropping metho ds from ob jects and elds from records and also from stated deni

tions Denitional subtyping happ ens in b ounded quantication where co de is written to be

p olymorphic over all typ es that are subtyp es of a given typ e and in abstract subtyping where

a typ e in a mo dule is sp ecied to be a subtyp e of some other typ e KML allows unrestricted

subsumption that is a memberofasubtyp e may always b e used in place of a memb er of the

sup ertyp e without any mediating syntax such as a co ercion

Expressive Mo dules The KML mo dule system builds on the mo dule system of Standard

ML with two main enhancements The rst is higherorder functors While Standard ML

functors may take and return only structures the KML mo dule system allows functors to take

other functors as arguments and return functors as results Th us the KML mo dule system is

fully featured typ ed lamb da calculus

The second enhancement is to allowtyp e denitions in signatures Allowing typ e denitions

in signatures combined with a typ e system that leaks no typ e information in the absence of

such denitions allows socalled translucent mo dules mo dules that leak exactly the desired

amount of typ e information Translucent mo dules allow the greatest amount of abstraction

p ossible in a system while still p ermitting enough leakage to link mo dules together

FirstClass Polymorphism Most dialects of ML including Standard ML restrict p olymor

phic terms so that they cannot b e placed into data structures passed to functions or returned

by functions Formally this restriction stems from a prenex restriction on quantied typ es

quantiers must app ear all the way out which means that quantied typ es cannot makeupa

comp onentofany larger typ e Thus p olymorphic values are not rst class they must always

be instantiated b efore they may be used In contrast p olymorphic values in KML are rst

class they may b e arguments or results of functions and may b e stored in data structures

KML also p ermits p olymorphic recursion where a p olymorphic function calls itself

recursively with a dierent typ e argument Polymorphic recursion is necessary to make go o d

use of rstclass p olymorphism otherwise all typ e arguments are statically predetermined but

it is also useful in other contexts

Comparison

During the time I was developing KML Xavier Leroy and his colleagues released the Ob jective

CAML system Ob jective CAML shares many of the same goals as KML in particular

the goals of providing supp ort for ob jectoriented programming and a more expressive mo dule

system However Ob jective CAML do es not supp ort rstclass p olymorphism and p ossesses

no formal semantics or denition

The greatest similarity between KML and Ob jective CAML lies in the mo dule systems

which provide almost identical expressiveness despite various technical dierences A greater

contrast exists in the ob ject system The ob ject system of KML is derived from the ob ject

calculus of Crary whichderives its lineage from the ob ject systems of Abadi and Cardelli

and their predecessors In contrast the ob ject system of Ob jective CAML is based on the

ob ject system of Remy and Vouillon which derives its lineage from the record extension

calculi of Remy

The greatest practical dierence b etween the ob ject systems of KML and Ob jective CAML

lies in supp ort for subtyping Unlike KML Ob jectiveCAMLprovides no automatic subsump

tion ob jects must b e co erced to sup ertyp es by an explicit co ercion However by abandoning

subtyping with subsumption Ob jective CAML is able to enjoy feasible typ e inference which

yping is prohibitively dicult for KML Moreover in many cases the practical b enets of subt

are obtained in Ob jective CAML by quantication over rowvariables that extend ob ject typ es

to unsp ecied sup ertyp es details app ear in RemyandVouillon and Leroy

The Role of Typ e Theory in the Design

In order to pro duce an elegant and coherent design for KML Iallowed typ etheoretic consid

erations to drive the design In order to convey the avor of this interaction I briey describ e

two design p oints that were informed bytyp e theory

In a mo dule calculus one imp ortant issue to settle is the equational theory under what

circumstances are mo dules and comp onents of mo dules considered equal to others The de

nition of Standard ML employed a system of unique stamps to dictate when two mo dules

were considered equal This system b ecomes even more involved when extended to higherorder

mo dules In KML I simplied the equational theory by eliminating equality of mo dules

in favor of equality of the typ es that make up those mo dules a similar choice was made for

Standard ML Revised and then ruling that typ es are equal exactly when equivalence

maybeproven from stated typ e denitions in a logic of typ es Leroy made a similar decision

in the design of the Ob jective CAML mo dule system

Another key design p oint was what form supp ort for ob jectoriented programming should

take Rather than b egin with a source level system of ob jects or classes I fo cused on the typ e

theoretic interpretation of ob jects With an theory of ob jects in hand I worked backwards

to the KML ob ject calculus The result was an ob ject system with comparable p ower to that

of Abadi and Cardelli but with a simpler theory and a more ecient implementation

Details app ear in Crary

Principals

Typ e Theory

One may view foundational typ e theory as b eing at its core atyp ed

language with a very rich typ e system That typ e system is capable of expressing complex

relationships b etween ob jects suciently complex that it may enco de almost any sentence

in logic and mathematics In this waytyp e theory mayserve as a foundation for mathematics

and computation

To some degree this view reects the bias of a computer scientist Typ e theory has b een

used as a foundation for mathematics since b efore the advent of mo dern computers for instance

Whitehead and Russells inuential treatise Principia Mathematica was a typ e theory

in some ways similar to the typ e theory of this dissertation Nevertheless typ e theory has b een

particularly successful as a foundation for computer science This is largely b ecause typ e theory

deals elegantly with structured data and computation the stu of computer science which

must b e painstakingly constructed in most other foundational frameworks

The particular typ e theory I use in this dissertation is a variant of the Nuprl typ e theory

Nuprl traces its lineage back to MartinLof s Intuitionistic Typ e Theory whichwas

rst intended to clarify the syntax and semantics of intuitionistic mathematics The Nuprl

typ e theory adapted Intuitionistic Typ e Theory as a foundation for computer programming by

simplifying its structure and adding a number of new typ e constructors Although my results

are stated in the context of the Nuprl typ e theorymyintention is that the metho dology b ehind

those results b e applicable to typ e theories in general

LambdaK

In order to manage the complexities of a real programming language KML is dened in terms

K

of a smaller internal language called Lamb daK provides all the expressiveness of the full

complex KML language but is considerably simpler and more elegant b ecause many of the

K

constructs of KML are broken up by the denition into simpler constructs in

The main thrust of this dissertation then is an exploration of how to draw formal connec

K

tions between the internal language and the Nuprl typ e theory These formal connections

then apply back to the highlevel language KML by way of its denition However I wish to

view the KML particulars as only a case study in the general metho dology I explore Similar

results can b e drawn for other languages for example Harp er and Stone giveaninterpre

K

tation of Standard ML in terms of an internal language very much like Thus with some

Standard ML as well Accordingly I do not minor mo dications my results would apply to

K

present the formal denition of KML in in this dissertation to do so would unduly fo cus

on the particulars and distract from the broader metho dology

The Nuprl typ e theory is predicative so in order to draw formal connections to Nuprl from

K K K

it is necessary for to be predicative as well However the used in dening KML

K

is not predicative Consequently in this dissertation I use a predicative variant of that

drops a number of features Recursive typ es stateful computation and ob jects all dep end on

impredicativity in some way and are regrettably omitted Restoring these is an imp ortant

avenue for future research and I discuss some p ossible ways it might b e done in Section

Overview

After this intro ductory chapter the technical material commences in Chapter with an ex

K K

position KMLs internal language In keeping with the view of as a case study that

K

chapter is brief The primary original contribution of is a mo dule calculus that combines

contributions from the translucent sums calculi of Harp er and Lillibridge and Leroy

the phasedistinction calculus of Harp er Mitchell and Moggi and the applicative functors

calculus of Leroy

Chapter b egins with an informal description of the Nuprl typ e theory and then con tinues

K

with an emb edding of into Nuprl the rst of the three main technical contributions of this

K

dissertation That emb edding provides a typ etheoretic semantics of and therebydraws a

sharp formal connection b etween KML and typ e theory I also discuss at length the applications

and some of the consequences of the semantics

In Chapter I discuss in detail myvariant of the Nuprl typ e theory the second main tech

nical contribution of this dissertation This typ e theory is the rst constructivetyp e theory to

include an intrinsic notion of equality and also to allow reasoning ab out b oth partial and total

functions All three notions are necessary to give an adequate account of practical program

ming languages partiality is clearly necessary for Turingcomplete languages and equalityand

totality are necessary to sayanything interesting ab out such languages once interpreted I also

discuss practical issues that arise when using a typ e theory incorp orating partiality FinallyI

give a rigorous semantics to the typ e theory and show its consistency

Central to the typ e theory is a xp oint rule for typing recursive functions However the

xp oint rule is not valid for recursive functions on every typ e Typ es for which the xp oint

rule is valid are known as admissible In Chapter I give general techniques for showing

typ es to be admissible the third main technical contribution of this dissertation Before this

work typ e theories incorp orating partiality were handicapp ed by a dearth of typ es known

metho d is a elegant least upp er b ound theorem for to be admissible A critical step in the

computational approximation with applications beyond the admissibility results to which I

apply it

Concluding remarks app ear in Chapter Following my concluding remarks the dissertation

K

closes with three app endices App endix A gives the complete typing rules for App endix

Bgives the complete inference rules for Nuprl pro ofs In the interest of readability throughout

the dissertation dicult pro ofs are removed to App endix C

Chapter

Lamb daK

The KML programming language provides a very expressive language for practical program

ming However exp erience with Standard ML has shown that although direct formal deni

tions of practical programming languages may be written those denitions are to o

unwieldy to be very useful except as a language sp ecication for compiler implementers and

are particularly impractical for theoretical study Simple languages are much more practical

for theoretical study and are useful in implementations as well The rst step of a compiler is

typically to elab orate the external language into a simpler intermediate language

In order to use a simpler and more manageable language than full KML in this thesis I

K

will be using a simple typ ed calculus called A framework that proved to be workable

was to augment the higherorder p olymorphic lamb da calculus F with p ower

and singleton kinds dep endent function and record kinds and strong sums This design is

discussed at length in this chapter

K

The syntax of is dened by the rules given in Figure and consists of ve syntactic

classes The class of terms contains the basic constructs of the p olymorphic lambda calculus

with records The class of type constructors which I will usually refer to as constructors

contains the typ es of wellformed terms and a lamb da calculus with records built over them for

computing typ es Typical typ e constructors are actual typ es suchasintegers or rstorder

typ e op erators such as lists The class of kinds then contains the typ es of typ e constructors

K

The two remaining classes modules and signatures contain the terms and typ es of s mo dule

K

system The static semantics of also uses contexts which assign kinds typ es and signatures

to constructor variables ranged over by term variables ranged over by x and mo dule

variables ranged over by s Figure contains several convenient abbreviations for use with

K

K

I consider two Throughout this thesis in any calculi with binding structure such as

expressions to b e identical if they dier only by alphavariation When two expressions e and

e are alphaequal I write e e Also the simultaneous captureavoiding substitution of

expressions e e for variables x x in e will b e denoted by ee e x x

n n n n

The Denition of Standard ML runs to pages and consists of rules plus many additional implied

rules for propagating exception packets and considerable supp orting machinery The revised Denition is

simpler but still runs to pages and rules

kinds Type j jf gjP c jS c

n n n i i

i

constructors c j c j c c jf c c gj c j c c j c c j

n n

c jf c c gjh c c ij ext m

n n n n

terms e x j xce j e e j e j ec jf e e gj e j inj e j

n n

case e x e x e j x e j ext m

n n n

c

signatures hijhhciij s jf s s g

n n n

modules m s jhcijhheiij sm j m m jf m m gj m j m

n n

contexts j j x c j s

Figure Lamb daK Syntax

def

fl ln g

n n

def

he e i fl e ln e g

n n

def

e e

i

li

def

hl ln i

n n

def

inj e inj e

i li

def

case e x e x e case e l x e ln x e

n n n n

where l l are distinguished lab els

Figure Lamb daK Shorthand

The Core Calculus

K

The typ e system of includes functions and records at the term and constructor levels and

p olymorphic functions at the term level using the standard notations Evaluation is intended

to be callbyvalue Records of terms record typ es and records of constructors that dier

only in eld order are considered identical The typ e of functions from to is denoted by

functions that return without computational eects are considered pure functions and

may b e given the pure function typ e for appropriate and The typ e system also

includes the lab elled disjoint union typ e denoted by h c c i memb ers of whichare

n n

y inj e and eliminated by case e x e x e As with records disjoint formed b

n n n

union typ es or case expressions that dier only in eld order are considered identical Recursive

functions are supp orted in the standard waybya x op erator The remaining construct ext m

deals with the mo dule calculus and is discussed in Section

K

A subtyping relation is dened over the typ es of Intuitively is a subtyp e of

denoted whenevery term b elonging to also b elongs to As usual functions are

contravariant on the left and covariant on the right records are covariant in the eld typ es and

subtyp es are pro duced by adding elds Pure function typ es are subtyp es of the corresp onding

function typ es

Kinds The kind level is more novel Ignoring the i annotations Type contains wellformed

typ es The power kind denoted by P for any typ e contains wellformed typ es that are

subtyp es of the given typ e The singleton kind denoted by S for any typ e contains

The level annotations i which are wellformed typ es that are equivalent to the given typ e

p ositiveintegers restrict the memb erships of these kinds The level of a kind or typ e is dened

to b e the highest level annotation app earing within it The kinds Type P andS contain

i i

i

def

Rc Type R c

i

i

def

Rc Rc

def

in

in

Rc f g f R c g

i i i i

i

R represents either P or S

Figure Higher Order Power and Singleton Kinds

only typ es with levels less than i Thus typ es b elonging to Type cannot contain quantify over

any nontrivial kinds and typ es b elonging to Type can only quantify over level kinds For

P c or S c the level of c must b e less than i

i i

K

This level annotation mechanism makes predicative which is necessary to p erform Chap

ter s emb edding into the predicativetyp e theory of Nuprl Since these annotations are tedious

to provide I discuss some alternatives in Section In a practical system based on this an

notation mechanism the system would have to infer level annotations for the user

The kind of functions mapping constructors of kind to constructors of kind may be

denoted but since constructors may app ear within kinds it is desirable to allow a more

precise characterization of such functions The kind includes all functions mapping

constructors to constructors where stands for the functions argumentandmay app ear

free in Such kinds are referred to as dependent function kinds since the result kind dep ends

on the argument For example a function with kind Type P when applied to anytyp e

i

i

returns a constructor of kind P that is a subtyp e of The independent function kind

i

is shorthand for when do es not app ear free in

Records of typ e constructors may also be given dep endent kinds The kind f

g contains all records f c c g such that each c has the

n n n n n i

corresp onding kind with the values of preceding elds substituted for the free variables

i

The external lab els ranged over by That is c must have kind c c

i i i i

must b e kept distinct from the internal binding o ccurrences b ecause variables must alphavary

but lab els must not This is discussed in greater length in Harp er and Lillibridge As a

shorthand I will often omit pronounced as alpha from a dep endent record kind when

do es not app ear free in the following kinds an independent record kind is one that contains

no internal binding o ccurrences at all I consider two dep endent record kinds to be identical

when they dier only in eld order so long as no eld is reordered to app ear after a eld that

dep ends up on it

Although p ower and singleton kinds are made using only typ es not higherorder construc

tors dep endent kinds may be used to build higherorder power and singleton kinds For

example the kind Type P list includes typ e constructors that are p ointwise subtyp es

i

i

of list Higherorder p ower and singleton kinds may b e generally dened as in Figure

Just as a subtyping relation was dened over the typ es a subkinding relation is dened over

the kinds This relation is denoted by when is a subkind of Function and record

kinds ob ey similar rules to the subtyping rules Additional subkinding relationships result from

level annotations Type Type and likewise for singleton and power kinds and from

i i

power and singleton kinds for any typ e S P Type and also P P

i i i i

i

when

These two names may b e burdensome for a programmer to supply so as a practical matter in KML it is

p ermitted to write one name for use as b oth the internal and the external name this p oses no problems so long

as it is p ossible to use separate names when they are needed

sig

tycon foo type

f foo s hType i

module S

fo o

S s

sig

S

f bar s hType i

tycon bar type

bar

baz s hS ext s ext s i

tycon baz foo bar

baz fo o bar

gnurf hhext s iig

val gnurf baz

baz

ig blap hhext s i

end

bar S

val blap Sbar

end

struct

tycon foo int int

module S

f foo hint int i

struct

S

tycon bar int

f bar hint i

tycon baz

baz hint int int i

int int int

gnurf hhf int int f iig

val gnurf

blap hhiig

fn f int int f

end

val blap

end

Figure ATypical Mo dule Enco ding

The Mo dule Calculus

Lamb daK mo dules form their own syntactic class and their typ es are called signatures which

also form their own syntactic class A primitive mo dule is either a single constructor hci or a

single term hheii If c has kind then hci has signature hi Likewise if e has typ e thenhheii

has signature hh ii

Mo dules are also formed using lamb daabstractions for functors and records for struc

tures Such mo dules may be given dep endent function signatures and dep endent record sig

natures that are precisely analogous to the dep endent function and dep endent record kind

discussed ab ove Data abstraction is achieved by forgetting typ e information using the con

struct m which co erces the mo dule m to have the signature if that signature is valid

for m any typ e information ab out m not reected in is forgotten As with the subtyping

and subkinding relations over the typ es and kinds the signatures haveasubsignature relation

which ob eys rules similar to the rules governing subtyping and subkinding

Mo dules are used within the core calculus by means of the extraction construct ext m for

hi then the constructor ext m has kind Likewise if m has mo dule m If m has signature

signature hh ii then the term ext m has typ e Exactly what mo dules are legal to extract

from is an issue that is discussed in Section

With the ab ove constructs it is easy to enco de highlevel KML mo dules A KML structure

is constructed by building a record out of its contents with every constructor eld encased in hi

and every term eld encased in hhii Figure shows the enco ding of atypical KML mo dule

K

with a substructure into Note the use of an internal and an external name in the enco ding

of the blap eld of the signature Functors and their signatures are enco ded using and in

the obvious manner

Since mo dules form their own syntactic class and are not reected directly into the core

K

calculus mo dules are secondclass This decision is based on issues related to the phase

distinction Section To p ermit rstclass mo dules would require considerably dierent

approaches to these issues that would reduce the expressiveness of the calculus as we will see

shortly Fortunately the rstclass mo dule restriction do es not seem to b e an onerous one the

most commonly cited use for a rstclass mo dule the abilityto select at runtime an ecient

implementation can b e achieved using existential typ es or ob jects

Static Semantics

K

The static semantics of app ears in App endix A Nine judgements are used six for the core

calculus and three for the mo dule calculus

The kind equality judgement indicates that and are equal in context

K

The subkinding judgement indicates that every constructor in is in

K

as discussed previously

The constructor equality judgement c c indicates that c and c are equal

K

as memb ers of kind

The subtyping judgement c c indicates that every term in c is in c

K

The typing judgement e c indicates that the term e has the typ e c

K

The valuability judgement e c indicates that the term e has the typ e c and that

K

its computation terminates

The subsignature judgement indicates that every mo dule in is in

K

The mo dule signature judgement m indicates that the mo dule m has signature

K

The mo dule valuability judgement m indicates that the mo dule m has signature

K

and that its computation terminates

Four additional judgements are derived from these nine A kind is considered wellformed

when it is equal to itself and similarly a constructor b elongs to a kind exactly when it is equal

to itself in that kind A typ e or signature is wellformed when it is a subtyp e or subsignature

of itself

def

kind

K K

def

c c c

K K

def

c typ e c c

K K

def

sig

K K

Design Issues

The Phase Distinction

An imp ortant decision to be made in the design of any mo dule calculus is how to account

for the phase distinction between compiletime and runtime expressions In the

absence of the mo dule calculus it is easy to say that the evaluation of typ e constructors

is a compiletime activity and the evaluation of terms is a runtime activity However the

mo dule system presents a quandary since mo dules may contain terms and typ e constructors

may contain mo dules through the extraction construct Constructor evaluation cannot be a

runtime activity unless we are willing to sacrice typ e checking at compile time but term

evaluation clearly cannot b e a compiletime activity

The central problem is how to structure the mo dule system and its interactions with the core

calculus so that compiletime expressions kinds and constructors do not contain p ossibly di

vergent or eectful expressions I discuss here two solutions to the problem the phasesplitting

approach prop osed by Harp er Mitchell and Moggi and the value restriction approach pro

posed by Harp er and Lillibridge and Leroy Lamb daK makes use of the phasesplitting

approach

In the phasesplitting approach mo dules including functors are considered to consist of

two comp onents a compiletime comp onent and a runtime comp onent The compiletime

comp onent deals only with the constructor p ortions of mo dules while the runtime comp onent

deals also with the term p ortions Then extraction at the constructor level dep ends only on

the constructor p ortion of a mo dule any problematic b ehavior of the mo dules term p ortion

is irrelevant This approach dep ends on designing the mo dule calculus so that it is imp ossible

to write a mo dule where a constructor eld dep ends on any runtime computation otherwise

constructor elds are runtime computations themselves and cannot be phase split into the

compiletime comp onent

In a system with rst class mo dules it is easy to construct a mo dule that dep ends on the

result of a term expression which rules out the phasesplitting approach In their translucent

sum calculus which has rst class mo dules Harp er and Lillibridge enforce the phase

distinction more directly Syntactic values have no interesting runtime b ehavior and may

therefore safely be treated as compiletime expressions Extraction at the constructor level is

restricted to only valuable expression arbitrary mo dule expressions are not legal for extraction

The phasesplitting approach also has some advantages that counterbalance the imp ossibility

of rstclass mo dules First phasesplitting provides a convenien tmechanism for implementing

the mo dule system Second phasesplitting allows greater exibility in references from

the core language into the mo dule language For example phasesplitting allows extraction

from functor applications which is forbidden by the value restriction approach This can be

quite useful in practice for example it allows the expression of transparent signatures for

functors that is signatures that completely sp ecify the typ e b ehavior of the functor For

  

example supp ose s has signature s hType i Then the alternative signature s hext ss i

the behavior of s but this signature is valid only if it is p ermissible to extract fully sp ecies

from functor applications Leroy discusses this issue at length

Top and Bottom Typ es

K

Unlike many subtyping calculi do es not have top and bottom typ es This is not b ecause

they are problematic to add they are not but because a practical language is b etter o

without them The main use for top and b ottom is usually to ensure that there exist meets

and joins for anytwotyp es but it is really only imp ortant to ensure that joins and meets exist

for typ es that have an upp er or lo wer b ound In cases where two typ es have no upp er or

lower b ound it is preferable to generate an error than to allow an articial top or b ottom

b ound For example a program fragment if b then else true is almost certainly a

mistake Similarly a function that makes incompatible demands on its argument could be

given a b ottom domain typ e but again such a useless function is certainly a mistake It is

b etter the notify the programmer of the mistake immediately than to allow the trivial typ e and

postpone the error message delivering it somewhere else instead of at the lo cation where the

mistakewas made

The drawback of this design decision relates to expressions with sideeects When an

K

expression is evaluated for sideeects it is not uncommon to ignore the result value In

this must be done explicitlyas in the co de if b then f x else g x where f and

g ha ve incompatible return typ es If the language included a top typ e the programmer could

write the marginally simpler if b then f x else g x However even in very impure co de it

is not likely that allowing top and b ottom would save eort for the programmer in this manner

nearly as often as disallowing them would save eort bycatching mistakes Additionally writing

co de to ignore result values explicitly provides useful do cumentation

Chapter

Typ eTheoretic Semantics

Typ e theory has b ecome a p opular framework for formal reasoning in computer science

and has formed the basis for a numb er of automated deduction systems including Automath

Nuprl HOL and Co q among others In addition to formalizing mathematics

these systems are widely used for the analysis and verication of computer programs To do

this one must draw a connection b etween the programming language used and the language of

typ e theory however these connections havetypically b een informal translations diminishing

the signicance of the formal verication results

Formal connections have b een drawn in the work of Reynolds and Harp er and Mitchell

each of whom sought to use typ etheoretic analysis to explain an entire programming

language Reynolds gave a typ etheoretic interpretation of Idealized Algol and Harp er and

Mitc hell did the same for a simplied fragment of Standard ML Recently Harp er and Stone

havegiven suchaninterpretation of full Standard ML Revised However in each of these

cases the typ e theories used were not suciently rich to form a foundation for mathematical

reasoning for example they were unable to express equality or induction principles On the

other hand Kreitz gave an emb edding of a fragment of Ob jective CAML into the

foundational typ e theory of Nuprl However this fragment omitted some imp ortant constructs

such as recursion and mo dules

The diculty has been that the same features of foundational typ e theories that make

them so expressive also highly constrain their semantics thereb y restricting the constructs that

may be intro duced into them For example as I will discuss b elow the existence of induction

principles precludes the typing of x that is typical in programming languages In this chapter

Ishowhowtogive a semantics to practical programming languages in foundational typ e theory

K

In particular I giveanembedding of into the Nuprl typ e theory This emb edding is simple

and syntaxdirected which has b een vital for its use in practical reasoning

The applications of typ etheoretic semantics are not limited to formal reasoning ab out

programs Using such a semantics it can be considerably easier to prove desirable prop erties

ab out a programming language suchastyp e preservation than with other means We will see

two such examples in Section The usefulness of such semantics is also not limited to one

tics particular programming language at a time If two languages are given typ etheoretic seman

then one may use typ e theory to show relationships b etween the two and when the semantics are

simple those relationships need b e no more complicated than the inherent dierences b etween

the two This is particularly useful in the area of typ edirected compilation

The pro cess of typ edirected compilation consists of in part translations b etween various typ ed

intermediate languages Emb edding eachinto a common foundational typ e theory provides an

ideal framework for showing the invariance of program meaning throughout the compilation

pro cess

This semantics is also useful even if one ultimately desires a semantics in some framework

other than typ e theory MartinLof typ e theory is closely tied to a structured op erational

semantics and has denotational mo dels in many frameworks including partial equivalence re

lations set theory and domain theory Thus foundational typ e theory

maybeusedasasemantic intermediate language

A Computational Denotational Semantics

My main motivation for a typ etheoretic semantics has been to draw formal connections be

tween programming languages and t yp e theory thereby making typetheoryapowerful to ol for

reasoning ab out languages and programs without sacricing any formality However a typ e

theoretic semantics is also valuable in its own right as mathematical mo del of a programming

language

Most programming language semantics are either op erational or denotational A typical

op erational semantics is sp ecied by giving an evaluation relation on program terms or an

evaluation relation on some abstract machine along with a translation into that machine

Op erational semantics have the advantage that they draw direct connections to computation

and explaining how programs compute is one of the prime functions of a semantics However

op erational semantics are typically rather brittle a slight addition or change to an op erational

semantics often requires reworking all pro ofs of prop erties of that semantics

In contrast a denotational semantics sp ecies for every program term a mathematical

ob ject that the program term denotes Typically a terms denotational is determined by com

posing in some way the denotations of its subterms The comp ositionality of denotational

semantics usually makes them more robust to change than a typical op erational semantics

Furthermore the equational theory of a denotational semantics is easier to work with since it

derives directly from the mathematical ob jects without need for an intermediating evaluation

relation and without needing to consider any surrounding context However the connection to

computation in a typical op erational semantics although present is much more remote than

with an op erational semantics

A denotational semantics in typ e theory provides the advantages of both a denotational

semantics The typ etheoretic semantics I present is denotational and accrues all the attendant

advantages of a denotational semantics but typ e theory is in essence a programming language

itself with its own op erational semantics so this semantics also draws a strong connection to

computation

The Language of Typ e Theory

I begin with an informal overview of the programming features of the Nuprl typ e theory It

is primarily those programming features that I will use in the emb edding The logic of typ es

is obtained through the prop ositionsastyp es isomorphism but this will not b e critical to

our purp oses in this chapter I present and discuss the typ e theory in detail in Chapter

As base t yp es the theory contains integers denoted by Z b o oleans denoted by B

strings denoted by Atom the emptytyp e Void the trivial typ e Unit andthetyp e Top which

Bo oleans are actually dened in terms of the disjoint union typ e

contains every wellformed term and in which all wellformed terms are equal Complex typ es

are built from the base typ es using various typ e constructors such as disjoint unions denoted by

T T dep endent pro ducts denoted byxT T and dep endent function spaces denoted

byxT T When x do es not app ear free in T we write T T for xT T and T T

for xT T

This gives an account of most of the familiar programming constructs other than p olymor

phism To handle p olymorphism wewanttohave functions that can take typ es as arguments

a typ e of all typ es These can be typ ed with the dep endenttyp es discussed ab ove if one adds

Unfortunately a single typ e of all typ es is known to make the theory inconsistent

so instead the typ e theory includes a predicative hierarchy of universes U U U etc The

universe U contains all typ es built up from the base typ es only and the universe U contains

i

all typ es built up from the base typ es and the universes U U In particular no universe

i

is a memb er of itself

K

Unlike which has distinct syntactic classes for kinds typ e constructors and terms Nuprl

has only one syntactic class for all expressions As a result typ es are rst class citizens and may

b e computed just as any other term For example the expression if b then Z else Top where

b is a b o olean expression is a valid typ e Evaluation is callbyname but these constructions

may also b e used in a callbyvalue typ e theory with little mo dication

K

To state the soundness of the embedding of we will require two assertions from the logic

of typ es These are equality denoted by t t in T which states that the terms t and t

are equal as members of typ e T and subtyping denoted by T T which states that every

member of typ e T is in typ e T and that terms equal in T are equal in T A memb ership

assertion denoted by t in T is dened as t t in T The basic judgement in Nuprl is H P

which states that in context H which contains hyp otheses and declarations of variables the

prop osition P is true Often the prop osition P will b e an assertion of equalityormemb ership

in a typ e

The basic op erators discussed ab ove are summarized in Figure Note that the lambda

K

abstractions of Nuprl are untyp ed unlike those of In addition to the op erators discussed

here the typ e theory contains some other less familiar typ e constructors the partial typ e set

typ e and very dep endent function typ e In order to b etter motivate these typ e constructors

we defer discussion of them until their point of relevance The dynamic semantics of all the

typ etheoretic op erators is given in Figure

Domain and Category Theory

Some of the mechanisms I use in the following section to give the typ etheoretic semantics of

K

will lo ok similar to mechanisms used to give programming language semantics in domain or

category theory This is not coincidence the three theories are closely related and some of the

mechanisms I use such as the partial typ es of Section are adapted from the folklore of

domain theory

However domain theory and category theory are not interchangeable with typ e theory

for the purp oses in this dissertation Typ e theory provides the highest degree of structure of

the three theories domain theory hides some structure in the interest of greater abstraction

and generality and category theory provides the least structure and the most abstraction and

generality Thus one can easily construct a domain or a category based on the Nuprl typ e

These are sometimes referred to in the literature as dep endent sums but I prefer the terminology to suggest

the connection to the nondep endenttyp e T T

Typ e Formation Intro duction Elimination

universe i U typ e formation

i

for i op erators

disjoint union T T inj e case e x e x e

inj e

function space xT T xe e e

pro duct space xT T he e i e

e

integers Z assorted op erations

b o oleans B true false ifthenelse

atoms Atom string literals equality test

A

void Void

unit Unit

top Top

Figure Typ e Theory Syntax

theory but one cannot easily work backwards although such mo dels of typ e theory do exist

The structure of the Nuprl typ e theory stems from the fact that Nuprl provides direct access

to the primitives of computation and the typ es of Nuprl sp eak directly of the computational

b ehavior of terms This structure is essential for achieving my goal of establishing a direct

computational signicance for this semantics recall Section This structure also allows

typ e theory to address directly issues that pose signicant challenges for domain theory and

or example in typ e theory we may that are not directly meaningful in category theory F

easily include or exclude divergent terms from typ es allowing us to easily distinguish b etween

partial or total functions and more imp ortantlyallowing us to use induction prop erties that

are invalid if one includes divergent terms

A Typ eTheoretic Semantics

K

Ipresenttheemb edding of into typ e theory in three parts In the rst part I b egin by giving

embeddings for most of the basic typ e and term op erators These emb eddings are uniformly

straightforward Second I examine what happ ens when the emb edding is expanded to include

x There we will nd it necessary to mo dify some of the original embeddings of the basic

op erators In the third part I complete the semantics by giving emb eddings for the kindlevel

K

constructs of The complete emb edding is summarized in Figures through

The embedding itself could be formulated in typ e theory leaving to metatheory only the

trivial task of enco ding the abstract syntax of the programming language Were this done the

theorems of Section could be proven within the framework of typ e theory For simplicity

however I will state the emb edding and theorems in metatheory

Basic Emb edding

K

The emb edding is dened as a syntaxdirected mapping denoted by of expressions

to terms of typ e theory Recall that in Nuprl all expressions are terms in particular typ es

K

and may be computed just as any other term Many expressions are translated are terms

directly into typ e theory

def

x x

def

def

xce x e

def

e e e e

def

c c c c

Nothing happ ens here except that the typ es are stripp ed out of lamb da abstractions to match

the syntax of Nuprl Functions at the typ e constructor level are equally easy to emb ed but I

defer discussion of them until Section

Since the typ e theory do es not distinguish between functions taking term arguments and

functions taking typ e arguments p olymorphic functions may be emb edded just as easily al

though a dep endenttyp e is required to express the dep endency of c on in the p olymorphic

typ e c

def

e e

def

ec e c

def

c c

Just as the typ e was stripp ed out of the lamb da abstraction ab ove the kind is stripp ed out of

the p olymorphic abstraction The translation of the p olymorphic function typ e ab ove makes

use of the emb edding of kinds but except for the elementary kind Type I defer discussion of

the emb edding of kinds until Section The kind Type which contains leveli typ es is

i

emb edded as the universe containing leveli typ es

def

Type U

i

i

Records and Disjoint Unions A bit more delicate than the ab ove but still fairly simple is

the emb edding of records Field lab els are taken to b e memb ers of typ e Atom and then records

are viewed as functions that map eld lab els to the contents of the corresp onding elds For

example the record fx f xint xg which has typ e fx int f int int gisemb edded

as

a if a x then else if a f then xx else

A A

 

where a a is the equality test on atoms which returns a b o olean when a and a are atoms

A

Since the typ e of this functions result dep ends up on its argumen t this function must be

typ ed using a dep endenttyp e

aAtom if a x then Z else if a f then Z Z else Top

A A

In general records and record typ es are emb edded as follows

def

f e e g a if a then e

n n A

else if a then e

A n n

else

def

e e

def

f c c g aAtom if a then c

n n A

else if a then c

A n n

else Top

Note that this emb edding validates the desired subtyping relationship on records Since fx

int f int int gfx int gwewould liketheemb edding to resp ect the subtyping relationship

fx int f int int g fx int g Fortunately this is the case since every typ e is a subtyp e

typ e relating to the omitted eld if a f then of Top and in particular the part of the

Z Z else Top is a subtyp e of Top The use of a typ e Top to catch extra lab els is essential

for subtyping to work prop erly makes for a particularly elegant emb edding of records but it

is not essential In the absence of Top one could pro duce a slightly less elegant emb edding by

restricting the domain to exclude undesired lab els using a set typ e Section

Disjoint unions are handled in a similar manner The injection term inj is emb edded

x

as the pair hx i of its lab el and its argument The typ es of this term include the sum typ e

hx int f int int i whichisemb edded using a dep endenttyp e as

aAtom if a x then Z else if a f then Z Z else Void

A A

In general disjoint unions are emb edded as follows

def

h c c i aAtom if a then c

n n A

else if a then c

A n n

else Void

def

inj e h ei

def

case e x e x e if x then e xx

n n n A

else if x then e xx

n A n n

else

Again this relation validates the desired subtyping relationship

Emb edding Recursion

K

A usual approach to typing general recursive denitions of functions and the one used in

is to add a x construct with the typing rule

H e in T T

H x e in T wrong

In eect this adds recursively dened and p ossibly divergent terms to existing typ es Unfor

tunately such a broad xp oint rule makes MartinLof typ e theories inconsistent b ecause of the

presence of induction principles An induction principle on a typ e sp ecies the memb ership of

that typ e for example the standard induction principle on the natural numb ers sp ecies that

every natural numb er is either zero or some nite iteration of successor on zero The abilityto

add divergent elements to a typ e would violate the sp ecication implied bythattyp es induction

rule

One simple waytoderive an inconsistency from the ab ovetyping rule uses the simplest in

duction principle induction on the emptytyp e Void The induction principle for Void indirectly

sp ecies that it has no members

H e in Void

H e in T

However it would b e easy using xtoderive a member of Void the identity function can b e

given typ e Void Void sox xxwould havetyp e Void Invoking the induction principle

x xx would be a member of every typ e and by the prop ositionsastyp es isomorphism

would b e a pro of of every prop osition It is also worth noting that this inconsistency do es not

stem from the fact that Void is an emptytyp e similar inconsistencies may b e derived with a

K

bit more work for almost every typ e including function typ es to which the x rule of is

restricted

It is clear then that x cannot be used to dene new memb ers of the basic typ es How

then can recursive functions b e typ ed The solution is to add a new typ e constructor for partial

types For anytyp e T the partial typ e T is a sup ertyp e of T that contains all the

elements of T and also all divergent terms A total typ e is one that contains only convergent

terms The induction principles on T are dierent than those on T so we can safely typ e x

with the rule

T T H T admiss H e in

H x e in T

K

We use partial typ es to interpret the p ossibly nonterminating computations of When in

K

a term e has typ e theemb edded term e will havetyp e Moreover if e is valuable

then e can still b e given the stronger typ e Before wecanembed x wemust reexamine

the emb edding of function typ es In Nuprl partial functions are viewed as functions with

partial result typ es

def

c c c c

def

c c c c

def

c c

If partial p olymorphic functions Note that as desired since

K

were included in they would b e emb edded as c

K

Now supp ose we wish to x the function f whichin hastyp e and

supp ose for simplicity onlythat f is valuable Then f has typ e

The second subgoal that the typ e T be admissible is a technical condition related to the notion of admis

sibilityinLCF All the typ es used in the emb edding are admissible so I ignore the admissibility condition

in the discussion of this chapter Admissibilityis discussed further in Chapter and is examined in detail in

Chapter

This terminology can b e somewhat confusing A total typ e is one that contains only convergent expressions

The partial function typ e T T contains functions that return p ossibly divergent elements but those functions

themselves converge so a partial function typ e is a total typ e

This typedoesnot quite t the x typing rule which requires the domain typ e to b e partial

so we must co erce f to a xable typ e We do this by etaexpanding f to gain access to its

argument call it g and then etaexpanding that argument g

g f xg x in

Etaexpanding g ensures that it terminates since xg x is a canonical form changing its typ e

from to The former typ e is required bythex rule but the latter typ e

is exp ected byf Since the co erced f tsthex typing rule we get that x g f xg x

has typ e as desired Thus wemayembed the x construct as

def

x e x g exg x

c

K

Strictness In a function may be applied to a p ossibly divergent argument but in my

semantics functions exp ect their arguments to be convergent Therefore we must change the

emb edding of application to compute function arguments to canonical form b efore applying the

function This is done using the sequencing construct let x e in e which evaluates e to

 

canonical form e and then reduces to e e x The sequence term diverges if e or e do es

and allows x be given a total typ e

H e in T H xT e in T

H let x e in e in T

Application is then emb edded in the exp ected way

def

e e let x e in e x

A nal issue arises in regard to records and disjoint unions In the emb edding of Section

the record f eg would terminate even if e diverges This would be unusual in a

callbyvalue programming language so we need to ensure that each member of a record is

evaluated

def

e e g let x e in f

n n

let x e in

n n

a if a then x

A

else if a then x

A n n

else

A similar change must b e also b e made for disjoint unions

def

inj e let x e in h xi

Polymorphic functions are unaected b ecause all typ e expressions converge Corollary

Emb edding Kinds

K

The kind structure of contains three rstorder kind constructors Wehave already seen the

emb edding of the kind Type remaining are the p ower and singleton kinds Each of these kinds

represents a collection of typ es so eachwillbeemb edded as something similar to a universe but

unlikethe kind Type which includes all typ es of the indicated level the power and singleton

i

kinds wish to exclude certain undesirable typ es The p ower kind P contains only subtyp es

i

of and the singleton kind S contains only typ es that are equal to other typ es must b e

i

left out

The mechanism for achieving this exclusion is the set type If S is a typ e and P is a

z g contains all elements z of S such that P z is predicate over S then the set typ e fz S j P

true With this typ e wecanembed the power and singleton kinds as

def

P c fT U j T c c in U g

i i i

def

S c fT U j T c in U g

i i i

Among the higherorder typ e constructors functions at the typ e constructor level and their

kinds are handled just as at the term level except that function kinds are p ermitted to have

dep endencies but need not deal with partiality or strictness

def

c c

def

c c c c

def

Dep endent Record Kinds For records at the typ e constructor level the emb edding of the

records themselves is analogous to those at the term level except that there is no issue of

strictness

def

f c c g a if a then c

n n A

else if a then c

A n n

else

def

c c

However the emb edding of this expressions kind is more complicated This is b ecause of the

need to express dep endencies among the elds of the dep endent record kind Recall that the

emb edding of a nondep endent record typ e already required a dep endent typ e to embed a

dep endent record typ e will require expressing even more dep endency Consider the dep endent

 

P g We might naively attempt to enco de this like the record kind f Type

nondep endent record typ e as



aAtom if a then U else if a then fT U j T in U g else Top wrong

A A

ariable is now unb ound We want to refer to the but this enco ding is not correct the v

contents of eld In the enco ding this means wewant to refer to the value returned by the

function when applied to lab el So wewantatyp e of functions whose return typ e can dep end

not only up on their arguments but up on their own return values

The second clause in the emb edding of the p ower kind c in U is used for technical reasons that require

i

that wellformedness of P imply that Type

i

i

The typ e I will use for this emb edding is Hickeys very dependent function type This

typ e is a generalization of the dep endent function typ e itself a generalization of the ordinary

function typ e and like it the very dep endent function typ es memb ers are just lamb da abstrac

tions The dierence is in the sp ecication of a functions return typ e The typ e is denoted by

ff j xT T g where f and x are binding o ccurrences that may app ear free in T but not in

T

As with the dep endent function typ e x stands for the functions argument but the addi

tional variable f refers to the function itself A function g b elongs to the typ e ff j xT T g

if g takes an argument from T call it t and returns a member of T t g x f

 

For example the kind f Type P g discussed ab ove is enco ded as a very

dep endent function typ e as



ff j aAtom if a then U else if a then fT U j T f fin U g else Top g

A A

To understand where this typ e constructor ts in with the more familiar typ e constructors

consider the typ e triangle shown in Figure On the right are the nondep endent typ e

constructors and in the middle are the dep endent typ e constructors Arrows are drawn from

typ e constructors to weaker ones that may be implemented with them Horizontal arrows

indicate when a weaker constructor may b e obtained by dropping a p ossible dep endency from

a stronger one for example the function typ e T T is a degenerate form of the dep endent

function typ e xT T where the dep endent variable x is not used in T Diagonal arrows

indicate when a weaker constructor may be implemented with a stronger one by p erforming

case analysis on a b o olean for example the disjoint union typ e T T is equivalent to the

typ e bB if b then T else T

If we ignore the very dep endent function typ e the typ e triangle illustrates how the basic typ e

constructors may b e implemented by the dep endent function and dep endentproducttyp es The

very dep endent function typ e completes this picture the dep endent function is a degenerate

form where the f dep endency is not used and the dep endent pro duct may be implemented

by switching on a b o olean Thus the very dep endent function typ e is a single unied typ e

constructor from which all the basic typ e constructors may b e constructed

In general dep endent record kinds are enco ded using a very dep endent function typ e as

follows

def

f g ff j a Atom

n n n

if a then

A

else if a then f

A

else if a then

A n

f f

n n n

else Top g

Toavoid the apparent circularity in order for ff j xT T g to b e wellformed we require that T may only

use the result of f when applied to elements of T that are less than x with regard to some wellfounded order

This restriction will not b e a problem for this emb edding b ecause the order in which eld lab els app ear in a

dep endent record kind is a p erfectly go o d wellfounded order

By switching on a lab el instead of a b o olean record typ es and tagged varianttyp es could b e implemented

and placed along the diagonals as well

xT T T T ff j xT T g

H H

H H

H H

H H

H H

H H

H H

H H

H H

Hj Hj

T T xT T

H

H

H

H

H

H

H

H

H

Hj

T T

Figure The Typ e Triangle

Emb edding Mo dules

K

As discussed in Section uses a phasesplitting interpretation of mo dules where mo dules

including higherorder mo dules are considered to consist of two comp onents a compiletime

comp onent and a runtime comp onent This is reected in the typ etheoretic semantics byan

emb edding that explicitly phasesplits mo dules The technique used is derived from Harp er et

al

The emb eddings for mo dules and signatures are given by two syntaxdirected mappings

and one for the compiletime comp onent of the given expression and one for the run

c r

time comp onent Given these the emb edding of a mo dule is a pair of the compiletime and

runtime comp onents

def

m h m m i

c r

In signatures the typ es of runtime elds may dep end up on a compiletime memb er as in

the signature ffoo s hType i bar hhext s iig corresp onding to the KML mo dule sig

fo o fo o

tycon foo type val bar foo end Consequently the emb edding of a signature is the

dep endent pro duct of the compiletime comp onent and the runtime comp onent The runtime

comp onents emb edding is a function that takes as an argument the compiletime member on

which it dep ends In the emb edding of the full signature that function is applied to the variable

standing for the compiletime memb er

def

v v

c r

The emb eddings of basic mo dules and signatures are simple The runtime comp onent is trivial

for hi signatures and hci mo dules and the compiletime comp onent is trivial for hhcii signatures

and hheii Mo dule variables s are split into separate variables s and s for each comp onent

c r

def

hci c mo dule compiletime comp onent

c

def

hci mo dule runtime comp onenttrivial

r

def

hi signature compiletime comp onent

c

def

hi v Top signature runtime comp onenttrivial

r

def

hheii mo dule compiletime comp onenttrivial

c

def

hheii e mo dule runtime comp onent

r

def

hhcii Top signature compiletime comp onenttrivial

c

def

hhcii v c signature runtime comp onent

r

def

s s mo dule compiletime comp onent

c

c

def

s mo dule runtime comp onent s

r

r

For each of the signatures ab ove it is imp ossible for there to b e any dep endency of the runtime

comp onent on the compiletime comp onent since for hi there is no nontrivial runtime to

dep end on anything and for hhcii there is no nontrivial compiletime for anything to dep end

on As a result the variable v is ignored in each case

Functors For function mo dules and signatures everything lo oks familiar in the compiletime

comp onent where the runtime material is ignored

def

s m sm

c

c c

def

m m m m

c c c

def

s s

c

c c c

However the runtime comp onent may not similarly ignore the compiletime comp onent be

cause of p ossible dep endencies Therefore the runtime comp onent abstracts over b oth the

compiletime and runtime comp onents of its argument

def

s s m sm

c r

r r

def

let x m in m m m m x

r r r c

The signatures runtime comp onent then takes an argument v representing the compiletime

comp onent and returns a curried function typ e The result typ e is the runtime comp onentof

the result signature and that dep ends on the compiletime comp onent Fortunately the results

compiletime comp onentisavailable as vs since v maps the compiletime comp onent of the

c

argument to the compiletime comp onent of the result

def

v s s vs s

c c c

c r r r

Structures For dep endent record mo dules and signatures the compiletime comp onent lo oks

like dep endent record kinds and the typ e constructor records that b elong to them

def

a if a then m f m m g

A n n

c c

else if a then m

A n n

c

else

def

m m

c c

def

f s s g ff j aAtom

n n n

c

if a then

A

c

else if a then f s

A c

c

else if a then

A n

f f s s

n n c

nc

c

else Top g

The runtime comp onent of mo dules lo oks much like the emb edding of record terms as with

those a series of op ening lets is necessary to ensure strictness

def

f m m g let x m in

n n

r r

let x m in

n n

r

a if a then x

A

else if a then x

A n n

else

where x do es not app ear free in m

i i

def

m m

r r

of signatures is also familiar except that it must deal with dep en The runtime comp onent

dencies on the compiletime comp onent Again the runtime comp onenttakes an argument v

representing the compiletime comp onent The runtime comp onent of each eld is applied

i

r

to the compiletime comp onent of that eld which is v Also each eld may have dep en

i

dencies on the compiletime comp onents of earlier elds These dep endencies will have b een

expressed by free o ccurrences of the variables s into whichwe substitute the corresp onding

ic

compiletime comp onents v It is worthwhile to note that these substitutions for s are the

i ic

only places where dep endencies on the argument v are intro duced

f s s g

n n n

r

def

v aAtom if a then v

A

r

if a then v v s

A c

r

else if a then

A n

v v v s s

n n n c

nc

r

else Top

def

Type fT U j T admiss T total g

i

i

def

def

f g ff j aAtom if a then

n n n A

f else if a then

A

else if a then

A n

f f

n n n

else Top g

where f a do not app ear free in

i

def

P c fT U j T c c in U T admissg

i i i

where T do es not app ear free in c

def

S c fT U j T c in U g

i i i

where T do es not app ear free in c

def

def

c c

def

c c c c

def

f c c g a if a then c

n n A

else if a then c

A n n

else

where a do es not app ear free in c

i

def

c c

def

c c c c

def

c c c c

def

c c

def

f c c g aAtom if a then c

n n A

else if a then c

A n n

else Top

where a do es not app ear free in c

i

def

h c c i aAtom if a then c

n n A

else if a then c

A n n

else Void

where a do es not app ear free in c

i

def

ext m m

c

Figure Emb edding Kinds and Typ es

def

x x

def

xce x e

def

e e let x e in e x

where x do es not app ear free in e

def

e e

def

ec e c

def

f e e g let x e in

n n

let x e in

n n

a if a then x

A

else if a then x

A n n

else

where x do es not app ear free in e

i j

def

e e

def

inj e let x e in h xi

def

case e x e x e let x e in

n n n

if x then e xx

A

else if x then e xx

A n n n

else

where x do es not app ear free in e

i

def

x e x g exg x

c

where g do es not app ear free in e

def

ext m m

r

Figure Emb edding Terms

Prop erties of the Emb edding

K

I conclude my presentation of the typ etheoretic semantics of by examining some of the

imp ortant prop erties of the semantics Wewant the emb edding to validate the intuitive meaning

K

of the judgements of s static semantics If is a subkind of then wewant the emb edded

kind to be a subtyp e of if c and c are equal in kind we want the emb edded

constructors c and c to be equal in and if e has typ e we want e to have typ e

and if e is valuable Similar prop erties are desired for the mo dule judgements This

is stated in Theorem

K

Theorem Semantic Soundness For every context let be dened as fol lows

def

def

def

x c x c

def

s s s s

c r c

c r

Then the fol lowing implications hold

  

If then level level and in U

K

level

def

v v

c r

where v do es not app ear free in

def

hi

c

def

hi v Top

r

def

hhcii Top

c

def

hhcii v c

r

where v do es not app ear free in c

def

s s

c

c c c

def

s v s s vs

c c c

r c r r

where v s do not app ear free in

i

def

f s s g ff j aAtom if a then

n n n A

c c

else if a then f s

A c

c

else if a then

A n

f f s s

n n c nc

c

else Top g

where f a do not app ear free in

i

def

v aAtom if a then v f s s g

A n n n

r r

if a then v v s

A c

r

else if a then

A n

v

n n

r

v v s s

n c nc

else Top g

where v a do not app ear free in

i

Figure Emb edding Signatures

  



If then in U in U

K

level level

 

If c c then c c in

K

 

If c c then c c

K

If e c then e in c

K

If e c then e in c

K

  



If then in U in U

K

level level

m in m in If m then

K

c c

If m then m in

K

Pro of

K

By induction on the derivations of the judgements

Wemay observetwo immediate consequences of the soundness theorem One is the desirable

prop erty of typ e preservation evaluation do es not change the typ e of a program Figure



gives a smallstep evaluation relation for the Nuprl typ e theory denoted by t t when t

 K

evaluates in one step to t Typ e preservation of Corollary follows directly from

soundness and typ e preservation of Nuprl Prop osition

def

m hm m i

c r

def

s s

c

c

def

s s

r

r

def

hci c

c

def

hci

r

def

hheii

c

def

hheii e

r

def

s m s m

c

c c

def

sm s s m

c r

r r

def

m m m m

c c c

def

m m let x m in m m x

r r r c

x do es not app ear free in m m where

def

f m m g a if a then m

n n A

c c

else if a then m

A n n

c

else

where a do es not app ear free in m

i

def

f m m g let x m in

n n

r r

let x m in

n n

r

a if a then x

A

else if a then x

A n n

else

where x do es not app ear free in m

i i

def

m m

c c

def

m m

r r

def

m m

c c

def

m m

r r

Figure Emb edding Mo dules

  

Prop osition If t in T and t t then t in T

Pro of

Direct from Corollary



Corollary Typ e Preservation If e and e t then t in

K

Another consequence of the soundness theorem is that the phase distinction is

K

resp ected in all typ e expressions converge and therefore typ es may be computed in a

compiletime phase This is expressed by Corollary

Corollary Phase Distinction If c then there exists canonical t such that

K



c t

Pro of

K

For anywellformed kind theemb edded kind can easily b e shown to b e a total typ e

Intuitively every typ e is total unless it is constructed using the partial typ e constructor

which is not used in the emb edding of kinds The conclusion follows directly

Prosp ects for Extension

K

In order to embed into typ e theory I abandoned impredicativity This was b ecause the

standard semantics for Nuprl discussed in Section do es not supp ort it However Mendler

has develop ed a semantic mo del of Nuprl enhanced with recursivetyp es and some impred

icative p olymorphism In that typ e theoryitisentirely straightforward to handle secondorder

impredicativity I have not used Mendlers typ e theory in this thesis because its semantics is

very complicated and b ecause it is not clear how easily it can b e extended to supp ort partial

typ es An alternative typ e theory to be explored is the Calculus of Constructions

which also supplies impredicative features and could likely supp ort the semantics discussed in

this chapter

Another imp ortant avenue for future work is to extend the semantics in this chapter to

explain stateful computation One promising device for doing this is to enco de stateful com

putations as monads but this raises two diculties In order to enco de references in

monads all expressions that may sideeect the store must take the store as an argument The

problem is howtoassignatyp e to the store Since sideeecting functions may b e in the store

themselves the store must b e typ ed using a recursivetyp e and since sideeecting expressions

take the store as an argument that recursive typ e will include negative o ccurrences of the

variable of recursion Mendlers typ e theory ma y express recursive typ es with only p ositive

o ccurrences but to allow negative o ccurrences is an op en problem

Finally a particularly comp elling direction is to extend the semantics to account for ob jects

and that turns out to require only the same mechanisms discussed ab ove In a weak sense this

semantics can already supp ort ob jects the existential ob ject enco ding of Pierce and Turner

uses only constructs available within the typ e theory used here Unfortunately that enco ding

is not practical in a predicative system b ecause it involves quantication over the typ es of an

ob jects hidden instance variables That quantication results in ob jects always b elonging to

auniverse one level higher than their underlying co de which prevents such ob ject from b eing

rstclass However in an impredicativetyp e theory Pierce and Turners ob ject enco ding can

be used quite satisfactorily In a typ e theory that additionally supplies recursive typ es with

negative o ccurrences a variety of other ob ject enco dings b ecome p ossible as w ell

Alternatively the ob ject enco ding of Hickey works entirely within the existing Nuprl

typ e theory and shows promise of b eing extendable to a practical ob ject system

Conclusions

I have shown how to give a typ etheoretic semantics to an expressive programming calculus

that supp orts mo dular and ob jectoriented features This semantics makes it p ossible to use

formal typ etheoretic reasoning ab out programs and programming languages without informal

emb eddings and without sacricing core expressiveness of the programming language

Formal reasoning aside emb edding programming languages into typ e theory allows a re

searcher to bring the full p ower of typ e theory to b ear on a programming problem For example

er kinds to a in Crary I use a typ etheoretic interpretation to exp ose the relation of pow

nonconstructive set typ e Adjusting this interpretation to make the power kind constructive

See Birkedal and Harp er for a promising approach that may lead to a solution of this problem

However in some contexts it is not necessary for ob jects to b e rst class For example Jackson inde

pendently used an enco ding essentially the same as Pierce and Turners to implement computational abstract

algebra In that context algebras were rarely intermingled with the elements of an algebra and when they were

an increase in the universe level was acceptable

results in the pro ofpassing technique used to implement higherorder co ercive subtyping in

KML

Furthermore the simplicityof the semantics makes it attractive to use as a mathematical

mo del similar in spirit if not in detail to the ScottStrachey program This semantics

works out so neatly b ecause typ e theory provides builtin structure wellsuited for analysis of

programming Most imp ortantlytyp e theory provides structured data and an intrinsic notion

of computation Nontyp etheoretic mo dels of typ e theory can exp ose the scaolding when

one desires the details of how that structure may b e implemented Section

As a theory of structured data and computation typ e theory is itself a very expressive pro

gramming language Practical programming languages are less expressive but oer prop erties

that foundational t yp e theory do es not such as decidable typ e checking I suggest that it is

protable to take typ e theory as a foundation for programming and to view practical pro

gramming languages as tractable approximations of typ e theory The semantics in this chapter

illustrates how to formalize these approximations This view not only helps to explain pro

gramming languages and their features as I have done here but also provides a greater insight

into howwe can bring more of the expressiveness of typ e theory into programming languages

Chapter

Foundational Typ e Theory

In this chapter I present in detail the foundational typ e theory of Nuprl Broadly sp eaking

the intent of the Nuprl typ e theory is to provide a formal foundation for mathematics that

is intrinsically computational Like the simpler typ e theories that provide the sup erstructure

K

for various programming languages such as Nuprl is a theory of structured data and

computation The essential dierence b etween Nuprl and other foundational typ e theories

and the simpler typ e systems of ordinary programming languages is the expressiveness

of the typ e system Foundational typ e theories provide typ e structure rich enough to enco de

almost arbitrary logical and mathematical prop ositions

This logical character of the Nuprl typ e system is not immediately evident at a rst in

sp ection Instead the constructs that make up Nuprl are those of a fairly simple programming

language data suchasintegers functions and pairs and typ es for classifying such data Those

computational constructs are interpreted as logical statements using the propositionsastypes

corresp ondence discussed in Section This conating of logic and data is one of the inter

esting asp ects of typ e theory and is in contrast to most other mathematical foundations such

as set theory whichdraw sharp distinctions b etween ob jects and logical sentences

Nuprl

The standard Nuprl typ e theory is presented in Constable et al I present here a variant

are of the Nuprl typ e theory with a number of innovations Chief among those innovations

the partial typ e mechanisms added in order to make it p ossible to reason ab out p otentially

nonterminating computations In Section I discuss some of the design decisions for my

version of Nuprl

Basic Typ es and Op erators

At the core of the typ e theory are the basic data typ es summarized in Figure Each of these

data typ es have a collection of intro duction op erators and a collection of analysis or elimi

nation op erators Nuprl do es not have distinct syntactic classes for typ es and terms instead

typ es are ordinary terms that may b e computed using the same op erations for computing data

For example if A and B are typ es then so is if b then A else B The basic typ es of Nuprl are

the following

A tom The collection of intro duction forms for Atom is the set of string literals The sole



elimination form for Atom is the equality test a a whichisequivalentto true when a

A

Typ e Formation Intro duction Elimination

atoms Atom string literals equalitytest

A

integers Z assorted op erations

b o oleans B true false if e then e else e

disjoint union T T inj e case e x e x e

inj e

pro duct space xT T he e i e

e

function space xT T xe e e

verydep endent ff j xT T g xe e e

function

unit Unit

void Void

universe i U typ e formation

i

for i op erators

Figure Basic Nuprl Typ es

 

and a are equal atoms and is equivalentto false when a and a are unequal atoms Note

that Atom has considerably less structure than a typ e of strings the essential prop erties

of Atom are only a countably innite set of intro duction forms and an equality test

Integer Z The collection of intro duction forms for Z is the set of integer literals The

elimination forms for integers are boolean equality and inequality tests and

Z Z

and a collection of binary op erations ranged over by such as plus times etc For

convenience these op erators are taken to b e dened on all integer values and return zero

in exceptional cases such as division by zero

Boolean B The intro duction forms for B are true and false Bo oleans are eliminated

by the branching construct if b then e else e For simplicitybooleans will eventually

b e dened in terms of the unit and disjoint union typ es

Disjoint Union A B The intro duction forms of A B are inj a when a is a

term b elonging to A and inj b when b is a term b elonging to B Disjoint unions are

eliminated by the case analysis construct case e x e x e

Dependent Product xAB The intro duction forms of xAB are ha bi when a be

longs to A and b b elongs to B ax Disjoint unions are eliminated by the pro jection

constructs eand e As usual when x do es not app ear free in B I write xAB

as the nondep endent pro duct A B This typ e is also known in the literature as a

dep endent sum general sum or strong sum I cho ose the term dep endent pro duct in

order to emphasize the connection to the nondep endent pro duct

Dep endent Function xAB The intro duction form of xAB is xb when bax

b elongs to B axforevery a b elonging to A Functions are eliminated by the application

construct e e As usual when x do es not app ear free in B I write xAB as the

nondep endent function typ e A B

Very Dependent Function ff j xA B g The very dep endent function typ e due to

has the same intro duction form xb as the ordinary dep endent function Hickey

typ e but allows the result typ e B to dep end not only on the argument x but on the

function itself Thus xb belongs to ff j xA B g when bax b elongs to B xb af x

for every a b elonging to A

To avoid circularity in order for a very dep endent function typ e ff j xAB g to be well

formed we require that B only use f by applying it to elements of A that are less than x

with resp ect to some wellfounded order As discussed in Section the very dep endent

function typ e is sucient to enco de many of the other basic typ es discussed here but it

is convenien t esp ecially in Chapter to retain those other typ es as primitive

Unit The typ e Unit has the intro duction form and no elimination forms For simplicity

Unit will eventually b e dened in terms of the equalitytyp e

Void The typ e Void is empty and therefore has no intro duction forms

Universe U Eachtyp e expression is Nuprl is also an ordinary term and is a member

i

of a universe typ e The universe U is the typ e containing all smal l typ es those that can

b e built without using a universe The universe U then contains all typ es that can b e

i

built using no universe higher than U In particular no universe is a member of itself

i

to include a single typ e that contained all typ es including itself would make the theory

inconsistent The intro duction forms for a universe are the t yp e formation

op erators No elimination form for universes is provided but this is only for simplicity

typ e analysis op erations could easily b e added following Constable and Zlatin

Equality and Wellformedness

Central to the typ e theory are two equality relations one for equalityoftyp es and another for

equality of terms relative to a typ e The typ e equality relation written T T states that

T and T are eachwellformed typ es and are equal to each other The term equality relation

written e e T states that T is a typ e and that e and e are memb ers of T and are equal

when considered as memb ers of T A sp ecication of these two relations app ears in Figure

The reexive forms of these relations are particularly imp ortant Note that T T exactly

when T is a wellformed typ e and that e e T exactly when e is a member of T These

reexive cases are abbreviated as T typ e and e T resp ectively

    

For example xAB xA B if and only if A A and B ax B a x whenever

   

a a A and xb xb xAB if and only if xAB typ e and bax b a x



B ax whenever a a A

We will o ccasionally have need of a sp ecial degenerate typ e to serve as a sup ertyp e of all

typ es

Top For any terms e and e e e Top For simplicity Top will eventually be

dened in terms of the every typ e



Notation I write a A P to mean a a A P and a a A P to mean

 

a a a a A P

Prop ositions as Typ es

In order to use typ e theory for mathematics we need a waytomake logical statements prop o

sitions within the formal theory This is done using the propositionsastypes corresp ondence

also known as the CurryHoward isomorphism In this corresp ondence each logical sen

tence is interpreted as a typ e with the understanding that that the sentence is true exactly

when the corresp onding typ e is inhabited by some term That inhabitant is referred to as the

witness of the prop osition

For example the prop osition False is interpreted as the uninhabited typ e Void The other

logical connectives are interpreted as follows

def

True Unit

def

P Q P Q

def

P Q P Q

def

P Q P Q

def

P Q P Q Q P

def

P P Void

def

xTP xTP

def

xTP xTP

Higherorder logic may be interpreted by this device as well We may state a prop osition

quantied over all small predicates as P P Q This is interpreted in the typ e theory by

dening the typ e of prop ositions P to b e the universe U

i i

Equality Subtyping and Inequality

Although the preceding is sucient to enco de prop ositional and higherorder predicate logic we

are short on atomic prop ositions F or example wewould like to b e able to sp eak ab out equality

within the logic but none of the typ es discussed so far is able to express such a prop osition

To handle this sort of atomic assertion we add new typ es that are dened to b e inhabited by

the trivial term when the prop osition they represent is true and empty otherwise

Equality e e in T The typ e e e in T is wellformed when e T and e T

If e e T then the typ e e e in T has the intro duction form if not then the

t yp e is empty andisinterpreted as a false prop osition Using the equalitytyp e wemay

also dene a memb ership typ e denoted e in T as e e in T

Subtyping T T The typ e T T is wellformed when T and T are well formed

 

typ es If T is a subtyp e of T ie e e T whenever e e T then T T has

the intro duction form otherwise it is empty and is interpreted as a false prop osition

The typ e n n is wellformed when n Z and n Z and is Inequality n n

inhabited by when the integer valueofisn is less than or equal to that of n

Be careful to note the distinction b etween e e in T atyp e and a prop osition within

the formal typ e theory and e e T a metatheoretical statement outside the theory

Also note that subtyping is dened as typ e inclusion if T T then the memb ers of

T are actual members of T An alternative denition would be that T T when exists a

co ercion from T to T This would provide an apparently more general notion of subtyping

since the identity function could always serve as a co ercion from a typ e to another typ e that

includes it In its greatest generality co ercive subtyping may b e represented by the prop osition

T T which states that there exists a function from T to T Alternatively if the co ercion

interpretation is restricted to use a predetermined collection of co ercions then the two notions

of subtyping may be reconciled in a common typ e system This is done by building a

new typ e system in which a typ e T contains all the members of every typ e T such that T

is co ercible to T Then the equalities on such typ es are constructed so that co ercion results

are deemed equal to the corresp onding co ercion arguments and thus co ercion functions may

formally b e viewed as identity functions

in Atom Certainly it is not true but Negatability Consider the prop osed prop osition

it is not false either Since the wellformedness criterion for the equality typ e requires its

equands to belong to the stated typ e in Atom is illformed and not a typ e at all This

seemingly inno cuous phenomenon has considerable consequences it means that the memb ership

prop osition is not negatable

To understand why consider the prop osition e in T If metatheoretically sp eaking e T

then e in T is wellformed and true ie inhabited On the other hand if e T then e in T

is illformed and unusable This do es not mean that memb ership prop osition is useless on

the contrary it is quite often essential However the memb ership prop osition is useless as the

antecedent of an implication As a simple example the negation e in T is either false or

illformed but never true and hence never useful More generallythe implication e T P

is no easier to prove than P b ecause the wellformedness of the implication cannot be shown

without proving the antecedent rendering the antecedent useless

The nonnegatability phenomenon is not limited to the memb ership prop osition Consider

the prop osition xT x in T This prop osition could b e used to dene the subtyping relation

but like the memb ership prop osition it is wellformed only when true That is why subtyping

is made a builtin typ e b ecause we would like to be able to prove theorems like A B

Z A Z B and U U In Section we will see a few more examples of primitive

typ es included to provide negatability

Constructivity

The interpretation of prop ositions as typ es is convenient but it also restricts the pro of tech

niques that may b e used to prove such prop ositions Consider the prop osition XM P P P

P In classical logic this prop osition is certainly true every prop osition is either true or false

alternatively every typ e is either inhabited or uninhabited However for XM to be valid in

Nuprl there must exist a function f that computes a member of P P for every small

prop osition P This is certainly imp ossible since P may express an undecidable prop osition

The Nuprl logic restricts pro ofs to using only principles of reasoning that are constructive

or intuitionistic This means that any pro of of the existence of an ob ject must showhow

to construct it and any pro of of a disjunction must showhow to determine which case is true

In practice this means that pro ofs may not use the principle of the excluded middle prop osition

XM ab ove or pro of bycontradiction Contradiction mayhowever b e used to prove theorems

of the form P

The dividend of this restriction is that pro ofs maybeinterpreted as programs Supp ose we

x y constructively In so doing wehave constructed a function inhabiting prove xZ y ZP

the corresp onding typ e xZ y ZPx y this function is the computational content of the

pro of The function may be applied to any integer x to compute the desired integer y and a

pro of of P x y More generally whenever we prove the existence of ob jects we may extract

the computational content from that pro of a program to compute those ob jects I discuss this

pro cess of extracting computational content from pro ofs further in Section In Section

I discussed the controlled reintro duction of classical reasoning principles

Prop ositions versus Bo oleans It is imp ortant to be clear on the distinction b etween the

typ e P of prop ositions and the typ e B of b o oleans Prop ositions are typ es that are inhabited

i

when their intended meaning is true and are empty otherwise Bo oleans are terms that compute

to the value true when their intended meaning is true and to false otherwise Decidable prop o

 

sitions may also be stated as b o olean expressions for example true false a a n n

A Z

  

and n n are b o olean forms of the prop ositions True False a a in Atom n n in Z

Z



and n n Undecidable prop ositions can never be stated as boolean expressions b ecause a

computation that resulted in such a b o olean would solve the undecidable problem

Constructing New Typ es using Logic

Wemay also use logical predicates to construct variants of other typ es using two sp ecial typ e

constructors due to Constable

The set type fxT j P g is the subtyp e of T that contains all t T such that P tx is true

ie inhabited

The quotient type xy TE x y when E is an equivalence relation on T is the

sup ertyp e of T that coarsens the equalityon T as follows t t xy TE if and only

if t t T and E t t x y istrueie inhabited

We may use set and quotient typ es to dene a number of imp ortant variants on existing

def def

typ es such as the natural numb ers N fn Z j ng and the integers mo dulo k Z

k

mnZm nmodk in Z Anumb er of other derived forms app ear in Figure

An imp ortant p oint ab out set and quotienttyp es is that they suppress computational con

tent of their predicate Given that n fx Z j P xg it is certainly the case that P n is

inhabited by some term but there is no way to gain access to that term An an extreme exam

def

ple consider the squashed prop osition P fx Unit j P g Metatheoretically it is easy to see

that P is inhabited exactly when P is and the implication P P can easily b e shown valid

However the converse P P is not valid b ecause it is not p ossible in general to pro duce a

pro of of a prop osition simply from knowing it to be true In order words it is not generally

p ossible to reconstruct suppressed computational content

However whenever the suppressed predicate is recursively enumerable it is p ossible to

reconstruct computational content This covers many uses including those few uses discussed

ab ove On the other hand it often is desirable to suppress computational content For example

a pro of of xZ y ZPx y computes b oth an integer y and a witness to P x y but it may

b e the case that so long as P x y is true the actual witness is not interesting In such cases

witness is cluttersome at b est and computationally exp ense at worst It would returning the

then b e more appropriate to prove the similar prop osition xZfy Z j P x y g

Computation

Intrinsic to the typ e theory is an op erational semantics that denes how Nuprl terms com

K

pute This computation system is callbyname in contrast to as is dened by a smallstep

evaluation relation t t and a set of canonical forms to which terms evaluate The com

putation system is dened to b e the restriction to closed terms of the evaluation step relation

def

Unit in Z

def

B Unit Unit

def

true inj

def

false inj

def

if b then e else e case b xe xe where x is not free in e e

def

e in T e e in T

def

T typ e T T

def

nm n m

def

N fn Z j ng

def

fn Z Z j ng

def

Z mnZm nmodk in Z

k

def

Q xy Z Z x y y x in Z

def

P fx Unit j P g where x is not free in P

def

t halts t in E

def

Top xy E Unit

Figure Derived Forms

given in Figure Whether a term is canonical is governed by its outermost op erator the

canonical forms of Nuprl are the typ e formation constructs and the intro duction forms ie

the middle column of Figure Two imp ortant prop erties of evaluation are that evaluation

is deterministic and canonical forms are terminal



Prop osition If t t and t t then t t Moreover if t is canonical then t t for



any t

  

t and t converges to If t t and t is canonical then we say that t converges abbreviated

 

t abbreviated t t Note that if t t and t t then t t and that if t is canonical then

t t

The computation system may b e used to dene a computational equivalence relation often

known as applicative bisimulation written t t Computational equivalence will b e formally

dened in Chapter Denition Intuitively two terms are computationally equivalent

if they both converge to canonical forms with the same outermost op erator and the corre

sp onding subterms are computationally equivalent or if they both fail to converge It may

be shown Lemma using Howes metho d that computational equivalence includes

b etaequivalence

The equalities on typ es are constructed to observe computational equivalence that is if

 

t T and t t then t t T This enables a powerful form of untyp ed reasoning called

direct computation When two terms are computationally equivalent for example a b eta redex

and contractum they are indistinguishable by the typ e theory and may be freely exchanged

for each other in any expression or pro of

   

Theorem If T typ e and T T then T T If t T and t t then t t T

However unlike the typ e system considered by Howe equality in this typ e theory do es not observe

computational approximation Section This is b ecause of the presence of partial typ es Section

Z For example approximates but it is not the case that in



e e

s



case e x e x e case e x e x e

s

case inj ex e x e e ex case inj ex e x e e ex

s s





e e

e e

s

s

 

e e e e xe e e e x e e he e i e

s s s s



e e

s



e e he e i e

s s





e is a stringinteger literal e e

e e

s

s

 

e e e e e e e e

A Z Z s A Z Z A Z Z s A Z Z

e and e are stringinteger literals i i e e

e and e are integer literals i i e e

e e inj e e inj

A Z s Z

i i



e e

s

e is canonical



let x e in e let x e in e let x e in e e e x

s s





eisaninteger literal e e

e e

s

s

e and e are integer literals e e e

 

e e e e e e e e e e e

s s s

x e e x e

s

Figure Op erational Semantics for Nuprl

This theorem is co died in the typ e theory by the direct computation rules Rules through

App endix B Since computational equivalence is undecidable and since we wish to be able

to eectively determine whether an instance of a rule is valid the direct computation rules

 

approximate computational equivalence with the auxiliary judgement t t where t and t

are p ossibly op en terms

A simple application of Theorem and direct computation is typ e preservation

Corollary

 

Semantic typ e preservation If t T and t t then t T

 

in T Syntactic typ e preservation If H t in T and t t then H t

Pro of

  

If t t then t t Prop osition and t t Rule Semantic preservation follows

directly by Theorem and syntactic preservation follows by application of Rules and

Partial Typ es

Of particular interest in the computation system is the op erator x which allows recursive

computation and is evaluated by the rule x f f x f The primary use of x is to

dene recursiv e functions Unfortunately in the standard Nuprl typ e theory recursion is not

as general to ol as it is in most programming languages All of the basic typ es of Nuprl are

total that is they contain only convergent terms but in general there is no guarantee that

a recursive function converges Thus a recursive function generally a recursively computed

ob ject cannot be given a typ e unless it can be shown to converge and it cannot be used

yp e However it is not always convenient or p ossible to prove that without giving it a t

recursive functions terminate and furthermore it is sometimes interesting to reason ab out

functions that are known not to terminate for all inputs

In order to b e able to assign typ es to partial functions and nonconvergent ob jects we add

anewtyp e constructor

Partial type T The partial typ e T due to Constable and Smith is like a

lifted version of T It contains all members of T plus all nonconvergent terms Terms are

T if they have the same convergence behavior and if they are equal in T when equal in

  

they converge That is t t T if and only if t t and tt t T

With this typ e available wemay express the typ e of partial functions from A to B as A B

It will also proveconvenienttohaveatyp e of all convergent terms

Every E For any convergent terms e and e e e E

In order to reason ab out termination in the logic we add a new typ e to represent the atomic

prop osition of convergence using the same device that we used to add equality subtyping and

inequalitytyp es

Convergence t in T The typ e t in T is wellformed when t T and is inhabited by

exactly when t

The use of a x op erator greatly simplies some of the results in this thesis particularly the pro of of Theorem

but it could in principle b e eliminated and replaced with the Y combinator

Note that t in T is an inhabited typ e exactly when t in T is A distinct convergence prop osition

is needed in order to provide negatability which is essential for any nontrivial termination

reasoning Observe that t in T is wellformed whenever t T but t T is wellformed only

when it is true

Constable and Smith use an untyp ed convergence assertion in their typ e systems

In this typ e theory I instead use a typ ed convergence assertion as in Constable and Smith

However an untyp ed convergence assertion can be dened as t halts t in E This is the

primary motivation for including the E typ e Unfortunatelyaswe will see in Section in

the presence of equality the untyp ed version is rarely any more useful than the typ ed version

Partial Typ e Formation The convergence typ e raises a somewhat surprising issue ab out the

formation of partial typ es The typ e equality rule for convergence typ es states that t in T and

 

t in T are equal when t t T and equal typ es should always have the same memb ership

Therefore T should never equate convergent and nonconvergent terms However we desire

 

that T be a subtyp e of T ie if t t T then t t T so T should never equate convergent

and nonconvergent terms either Since many terms Top for example do equate terms with

dierent convergence behavior we must add this as a restriction to the wellformedness of

partial typ es

To not equate convergent and nonconvergent terms is an awkward condition to maintain

T to be wellformed T must be so instead my theory imp oses the stronger condition that for

total It follows trivially that a total typ e cannot equal convergent and nonconvergent terms

The obvious denition of totality xT x in T turns out to b e nonnegatable since it dep ends

up on the wellformedness of T so I add totality as another primitivetyp e

Totality T total The typ e T total is wellformed when T typ e and is inhabited by

exactly when T contains only terms that converge

The Fixp oint Principle With partial typ es in the typ e theory recursive functions can be

typ ed using the xp oint principle

e in T T x e in T

The use of the xp oint principle was illustrated in Section However the xp oint principle

is not valid for every typ e it is only valid for typ es that are admissible Admissibility is dened

formally in Chapter Denition Intuitivelyatyp e is admissible if it contains a recursive

term whenever it contains a conite set of approximations to that term

This issue do es not arise in most ordinary programming languages b ecause most typ e sys

tems are not rich enough to allow the expression of inadmissible typ es Nuprl is expressive

enough to construct inadmissible typ es but nevertheless most typ es are still admissible Chap

ter discusses admissibilityin detail and presents a number of techniques for showing typ es

to b e admissible

Admissibilityisintro duced into the logic as another atomic prop osition

Admissibility T admiss The typ e T admiss is wellformed when T typ e and is inhabited

exactly when T is admissible by

This completes the set of primitive Nuprl typ es except for four additional atomic prop ositions

intro duced in Chapter The list is summarized in Figure

void Void equality e e in A

atom Atom subtyping A B

integer Z inequality n n

disjointunion A B convergence e in A

totality A total

pro duct space xAB

function space xAB admissibility A admiss

verydep endent function ff j xA B g

set fx A j P g

partial typ e A quotient xy AP

universe U every E

i

Figure Primitive Nuprl Typ es

Sequencing The nal construct in the partial typ e theory is the sequencing construct let x

e in e This expression evaluates e to canonical form say v then evaluates e vx Hence

the sequence term diverges if either e or e do es Since e is only evaluated if e converges

the e p ortion of the sequencing term may be typ ed under the assumption that x has a total

typ e the syntax for Nuprl sequents is formally dened in the next section

 

H e in T H xT e in T H T typ e



H let x e in e in T

As an aside if T is reinterpreted as a monad typ e M T then this is precisely the typing rule

for the bind op erator in monad systems A monad system would also have a unit

op erator to co erce T to M T in this theory that is taken care of by subsumption since T T

One may extend the theory to a full typ e theory of monads by disp ensing with T T

adding an explicit unit op erator and adding rules comprising the monadic equalitylaws This

would provide a p owerful mechanism for abstractly managing eects in general not just the

nontermination eects managed by the partial typ es I have not done so in this typ e theory

preferring instead to keep the typ e theory closely tied to its op erational semantics thereby

providing as much structure as p ossible at the exp ense of abstraction recall Section

Sequents and Pro of

The Nuprl inference system has one judgement form written as the sequent

x T x T Ct

n n

This may b e read informally as t is a member of C when x x are memb ers of T T

n n

A more precise in terpretation is discussed in Section and a formal semantics is dened in

Section The bindings x T x T to the left of the turnstile are called hypotheses

n n

C is called the conclusion and t is called the witness

The inference rules for deriving judgements of this form are listed in App endix B By way

of example Rule for applying subtyping amidst the hyp othesis list is

 

H x T J C s H T T

H x T J C s

Note that in this rule the second subgoal is a subtyping prop osition which is computationally

uninteresting it contains only terms that evaluate to Since that prop osition is compu

tationally uninteresting the statement of the rule suppresses the witness In many rules the

consequent also is computationally uninteresting and the witness is suppressed in such rules as

well In those rules the witness should b e taken to b e An example of such a rule is Rule

for applying subtyping in an equality assertion

 

H t t in T H T T

H t t in T

Implicitly this stands for the rule

  

H t t in T t H T T t

H t t in T

Functionality

A sequent x T x T C t asserts not only memb ership of the witness t in the

n n

conclusion typ e C it also asserts that the conclusion and witness are functional over the

 



hyp othesis variables That is if t t t and t t t are equal substitutions for

n

n



x T x T in a manner that will b e made precise in Section then C txC t x

n n



and ttxtt x C tx Toseewhy this interpretation is necessary consider the rule

H A typ e H x A Bb

H A B xb



The consequent states that xb is a function over A that is if a a A then bax



ba x B Under a weaker memb ership onlyinterpretation of sequents the second subgoal



is sucient to conclude that bax B and ba x B but cannot guarantee equality A

functional interpretation of sequents where sequents are seen as functions from hyp otheses to

the conclusion is necessary to validate the many rules of this form

ExtractStyle Pro of

some prop osition P the prop ositionsastyp es corresp ondence dictates that In order to prove

one prove a sequent of the form P t However it is typically the case that one is only

interested in proving the truth inhabitation of a prop osition and is not concerned that witness

b e a particular term Consequently in the Nuprl pro of development system auseris

presented with a sequent that omits the t witness term even in cases when conclusion is

computationally interesting The rules are then stated in a manner that makes it p ossible to

pro of For example consider extract the witness from the pro of This is called extractstyle

again the rule

H A typ e H x A Bb

H A B xb

In extractstyle pro of this rule is applied to a sequent of the form H P Q to pro duce

e

subgoals H P typ e and H x P Q From the pro of of the second subgoal is extracted

e e

a witness b p ossibly containing free o ccurrences of the variable x and that witness is used to

construct the extract xb of the original sequent In fact since the variable x is only used

In some alternative semantics for typ e theory suchasHowes set theoretic semantics equalityinatyp e

may b e collapsed to actual ob ject equality trivially making the memb ership and functionalityinterpretations

the same Extending the semantics of Howe to account for all the devices in this typ e theory is an op en problem

but one that shows some promise of feasibility

in the extract it may be made invisible to the user as well resulting in the simple subgoal

H P Q

e

For extractstyle pro of to b e p ossible all the rules in the system must b e of the prop er form

Sp ecically the rules must construct extracts in a b ottomup manner or in other words the

applicabilityofarulemust not dep end on the extract since the extract cannot b e known at the

time the rule is applied However the phrasing of the Nuprl pro of rules that I state in App endix

B is devised in the interest of making the typ e theory as simple as p ossible not supp orting

extractstyle pro of so some rules are not of the prop er form To supp ort extractstyle pro of

those rules must be replaced with extractcompatible rules Fortunately the necessary rules

are all derivable from the existing rules so it is p ossible to supp ort extractstyle pro of without

any additional metatheoretical justication

The necessary condition for extractcompatibility is best understo o d by examining some

rules that violate it and seeing howtheymay b e rewritten to followit

Extract and Memb ership The function typ e inhabitation rule discussed ab ove is not among

the basic rules of the inference system Rather it is derivable from them the equality rule on

function typ es

H x A Bb

H x A b in B H A typ e

H xb in A B

H A B xb

We gain considerable economy in the derivation rules by leaving out such inhabitation rules

and allowing them to b e derived from the others but in an extractstyle system they must be

builtin instead This is b ecause Rule is not appropriate for extractstyle pro of

H Ct

H t in C

For this rule to be applicable the extract t of the subpro of must be the same term t that is

sp ecied in the memb ership prop osition in the consequent and there is no guarantee that it

will Another way of lo oking at this problem is that the rule with witnesses stripp ed out is

unsound it do es not follow from the inhabitation of C that any particular term t b elongs to C

H C

e

wrong

H t in C

e

In an extractstyle pro of system Rule must b e omitted and replaced by an inhabitation rule

to mirror each basic equality rule eg However note that the converse rule

Rule do es not p ose problems for extractstyle pro of

Hyp othesis Elimination Another class of rules that imp ose a restriction on the extract

term is the hyp othesis elimination rules The hyp othesis elimination rule for pro ducts requires

Rule that all free o ccurrences of x and y in the extract term must app ear as the pair hx y i

H x A y B J hx y iz C hx y iz shx y iz

x y JCs

H z xAB J Cs

Tomake this rule suitable for extractstyle pro of it must b e rephrased as the derivable rule

H x A y B J hx y iz C hx y iz s

H z xAB J Cs z z x y

Similarly the hyp othesis elimination rule for disjoint unions

H y A J inj y x C inj y x sinj y x

H y B J inj y x C inj y x sinj y x

y JCs

H x A B J Cs

must b e rephrased as the derivable rule

H y A J inj y x C inj y x s

H y B J inj y x C inj y x s

H x A B J C case x y s ys

In contrast to these two rules the hyp othesis elimination rules for typ es with uninteresting

memb erships such as the equalitytyp es Rule do not p ose a problem



H x t t in T J x C x sx



H x t t in T J Cs

In these rules it is not a problem for terms to propagate upwards so such rules may b e applied

simply by assuming that x do es not app ear free in s

Hidden Variables A sp ecial case of hyp othesis elimination that p oses particular diculties

is that of set and quotienttyp es The hyp othesis elimination rule for set typ es Rule is

H x A y B J Cs

y JCs

H x fx A j B g J C s

As b efore y is prohibited from app earing free in the extract term s but in this case the rule

cannot b e rephrased to make the problem disapp ear The essential problem is that y represents

computational content that is not available so the extract cannot dep end up on it in anyway

To enforce this restriction wemust intro duce a new mechanism When the rule is applied the

variable y is marked as hidden establishing the invariant that it may not app ear free in the

extract

H x Ay B J C

e

H x fx A j B g J C

e

This invariant is preserved by the inference system and disallows the application of any rule

that would use that variable However when descending into subgoals that do not contribute

to the extract all hiding annotations may b e removed

It is imp ortant to note that this hidden variable mechanism is only a practical syntactic

device and has no metatheoretical signicance The sole metatheoretical issue is addressed in

Rule by the side condition that y not app ear free in the extract

Issues in Partial Ob ject Typ e Theory

eness of the standard Nuprl typ e The typ e theory presented here joins together the expressiv

theorywhich do es not supp ort reasoning ab out partial ob jects that is nonconvergent terms

and the typ e theory of Smith which addresses partial ob jects but do es not supp ort

equality This theory also enhances Smiths theory by a considerably wider class of typ es that

are admissible for xp oint induction discussed at length in Chapter Here I discuss some

issues arising in the design and application of a partial ob ject typ e theory particularly those

resulting from the combination of equality and partial ob jects

Partial Computation

Given two terms a and b each of which b elong to Z it is intuitively clear that the sum a b

Z However the rules for integer expressions deal with convergent terms should also b elong to

H a in Z H b in Z

H a b in Z

An informal argument for the desired memb ership is easy To show that a b in Z supp ose

that a b halts and show a b in Z If a b halts thena halts and b halts Consequently

a in Z and b in Z and therefore a b in Z by the rule

Unfortunately formalizing this argument as a derivation runs into a problem to show

the desired memb ership we incur the additional obligation of showing that the supp osition

a b halts is wellformed as in the derivation b elow and the eventual subgoal a b in E is

no easier to prove than the original goal a b in Z

E H a b in

H a b halts typ e

H a b halts a b halts H x a b halts a b in Z

H a b in Z

This diculty do es not reveal a defect in the logic The problem is that in the presence of

equality as discussed in Section a sequent says much more than its naive reading it

asserts the functionality of the conclusion over equal substitutions for the hyp otheses The

informal argument at the top is p erfectly valid as a metatheoretical argument for closed terms

but it do es not extend to sequents

However it certainly would be a defect in the logic if goals of this form were unprovable

This could b e settled by at by simply adding new partial typing rules for each op erator but

wewould rather a void such a heavyhanded solution I present a more palatable solution in the

next section

Computation in Active Positions

Consider the monadstyle variation of a b obtained by rst computing the summands to

canonical form and them summing their values let x a in let y b in x y This is easily

Z shown to b elong to

H x Z y Z x y in Z

Z H x Z y Z x y in Z H x Z b in

H a in Z H x Z let y b in x y in Z

H let x a in let y b in x y in Z

The desired result then follows by direct computation if it can b e shown that a b let x

a in let y b in x y Of course in general t t x is not equivalent to let x t in t

b ecause the latter necessarily evaluates t but the former might not which would lead to

dierent convergence behavior if t is divergent However in this case the term a b does

evaluate a and b b efore converging

The general principle at work here is that x and y are b oth in active p ositions in the

term x y An active p osition of a term is one that must be evaluated b efore the term can

converge Canonical terms have no active p ositions since they have already converged The

active p ositions of noncanonical terms are dened as follows

Denition Aterm e app ears actively in t if

t e or

t case t xt xt and e appears actively in t or

t t t and e appears actively in t or

 

t t and e appears actively in t or

i

t t t or t t t or t t t and e appears actively in t or t or

A Z Z

t let x t in t and e appears actively in t or t or

t t t and e appears actively in t or t or

 

t x t and e appears actively in t

Lemma If x appears actively in t then tex let x e in t

This lemma is put into practice in the typ e theory as Rule

x app ears actively in t

t t x let x t in t

Another application of this device is for computational inducement Observe that evaluating

a b induces the evaluation of a and b so if a b converges then so do a and b This can be

proven using active p ositions

H a b in Z let x a in x b a b

H let x a in x b in Z H a in Z

H a in Z

Fixp oint Induction

The principal device for reasoning ab out programs in the LCF system was xp oint induc

tion Informally xp oint induction says that if an admissible predicate holds for divergent

terms and it is preserved by f then it holds for the xp ointof f In notation if P and if

P x P f x then P x f

Using the xp oint principle in our typ e theorywemay derive a similar induction rule

H x T y x in T P P

H x T y P z fx in T P fxx

T T H f in

T P typ e H x

H T total

H T admiss

H P admiss x T

H x T y P P e

H P x f x ex f xy

This rule lo oks considerably more complicated than the informal statement so let us examine

it in detail The rst subgoal

H x T y x in T P P

corresp onds to the base case P If one accepts classical reasoning principles in particular

the prop osition x in T x in T then this goal may be proven from the simpler goal

H P x In Section I discuss how classical reasoning principles may be justied

semantically if one takes a classical view of the metatheory However it is usually the case that

x can so classical metho ds are usually the given subgoal can b e proven whenever H P

unnecessary

The second subgoal

H x T y P z fx in T P fxx

corresp onds to the inductive case P x P f x The z hyp othesis indicates that we are not

in the base case ie f x and may b e dropp ed if desired to bring the goal more in line

with the informal statement

The next three subgoals are basic wellformedness conditions The sixth subgoal H

T admiss is also a wellformedness condition whichis needed to take the xp ointof f The

seventh subgoal H P admiss x T is the requirement on the admissibility of the predicate

More on this in Section

The nal subgoal is the most curious

H x T y P P e

This goal stems from the uniformity condition for admissibilityofsettyp es Section but

we may give an informal explanation directly in the context of xp oint induction Supp ose

v and g are the computational content of the base case and inductive case resp ectively For

simplicity assume that v P x and g P tx P f tx for all t T Then we

may build a sequence of P inhabitants for each of the nite approximations of x f Let

v g v so v P x v P f x v P f f x etc We need a limit term

i i

to inhabit the prop osition P x f x However the sequence terms v v v are unrelated

by computational approximation Section and do not in general approachany limit

The nal subgoal provides a term e that allows us to build a uniform sequence of inhabitants

that will approachalimit Since the sequence v v v inhabits the various P prop ositions

the sequence exef xef f x also inhabits the various P prop ositions and

the latter is guaranteed to approach a limit

Lemma The xpoint induction rule is derivable

Pro of



The full derivation of the rule is tedious so I sketch the argument Let T fx T j P g

  

The key p oints are to show T fx T j P g and to show that f in T T From the



latter and since T is admissible Rule and subgoals and wemay conclude that



x f in T Thus bytherst p oint x f in fx T j P g We may then use subgoal to

reconstruct the suppressed computational content of P x f x

 

Toshow T fx T j P g uses the base case Supp ose x in T We wish to showthat x in T



and P is inhabited The former is easy since T T To showthe latter supp ose x halts



ie x in T Then x in T so P is inhabited Hence x in T P By the base case

subgoal P is inhabited

  

To show f in T T uses the inductive case Supp ose x in T We wish to show that





fx in T Supp ose fx halts ie fx in T Then we wish to show that fx in T that

is that fx in T and P fxx is inhabited The former follows trivially from fx in T To



T j P g since T fx T j P g Consequently P is show the latter observe that x in fx

inhabited By the inductive case subgoal P fxx is inhabited

Two somewhat similar results to Lemma were proven by Smith Smiths results

diered in that one used classical reasoning principles and was based on the thenconjectural

admissibility of set typ es and the other required the witnesses of the base and inductive cases

to have particular forms

Computational Induction

Smiths typ e theory also provided another principle computational induction for reasoning

ab out partial ob jects The idea to computational induction is that when a term converges

it induces a wellfounded order on its computations intermediate values Computational in

duction is generally useful for reasoning ab out programs since it corresp onds to the intuitive

mechanism of reasoning ab out recursive programs by preconditions and p ostconditions but it

is particularly useful for proving partial correctness of programs Other induction principles are

inadequate for such pro ofs if one could nd a wellfounded order on the inputs of a recursive

function one could show total correctness instead

Unfortunately computation is an intrinsically intensional prop erty that is it requires rea

soning ab out the structure of terms as well as ab out their result value In contrast my typ e

theory is extensional terms with the same result value are indistinguishable Consequentlyit

is trivially true that P t P t when t t andonemay not drawany inductive conclu

sions from the fact Smiths typ e theory was able to supp ort computational induction b ecause

it supp orted no notion of equality or functionality

In order to supp ort computational induction we need to add supp ort for intensional rea

soning ab out terms Wemay do this by adding to the typ e theory representations for all terms

and by adding rules for reasoning intensionally ab out those representations and for linking

those representations back to the terms they represent Mechanisms for accomplishing this are

discussed in detail in Constable and Crary

Other Contributions

The version of the Nuprl typ e theory presented in this chapter makes a few minor contributions

other than those contributions relating to partial typ es

By adding a primitivesubtyping assertion subtyping b ecomes negatable recall Section

This makes it p ossible to prove theorems that dep end up on subtyping conditions

More imp ortantlyhowever it makes it p ossible to dene the p ower kind as P T fS

i

U j S T g recall Section Without a negatable subt yping assertion this set typ e

i

is illformed

This typ e theory adds rules for a typ eho o d assertion T typ e which may be dened

either as xx in T T or as T T Iuse the latter denition in order to share some

rules with the subtyping assertion Using a typ eho o d assertion streamlines dealings with

wellformedness subgoals such as the rst subgoal of

H A typ e H x A b in B

H xb in xAB

In the standard Nuprl theorywhichdoesnotusetyp eho o d assertions the wellformedness

subgoal is stated as memb ership in some universe A in U However to prove such a

i

subgoal requires the determination of which universe U the typ e A b elongs to This is

i

often inconvenient and is sometimes imp ossible For example sometimes typehood can

only b e shown using an inhabitation rule Rule



H t t in T

H T typ e

This rule could not b e stated in the standard theory using universe memb ership b ecause

it would need to conclude that T was a memb er of some unknown universe U and there

i

is no facility for existentially quantifying universe indices

The use of typ eho o d assertions is also useful in that it makes the typ e theory extensible

to systems where some typ es do not b elong to any universe For example supp ose the

computation system were augmented with a noncanonical op erator U with the eval

uation rule U n U for integer literals n Then xZUxwould b e a valid typ e

s n

but since U x spans the universes the typ e would be to o large to b elong to any single

universe

The inclusion of an inhabitationtomemb ership rule Rule makes it p ossible to derive

the typ e inhabitation rules from the rules governing equality on typ es This cuts the

number of rules nearly in half As discussed in Section an extractstyle pro of

developmentsystemmust reintro duce those rules but they may b e reintro duced as derived

rules without additional metatheoretic justication

Semantics

The remaining task is to show that the typ e theory presented here is consistent As usual I

do this byshowing it sound with resp ect to a semantics The development of the semantics is

divided in to two parts I b egin by giving a semantics for typ es and then extend that semantics to

cover judgements as well Igivethissemantics in the framework of partial equivalence relations

Semantics exist for related theories standard Nuprl or MartinLof typ e theory in the

frameworks of set theory and domain theory among others and could

probably b e develop ed for my theory as well

Typ e Semantics

The semantics of typ es is characterized by the relations t t T and T T from Section

The rst relation asso ciates with eachtyp e T a partial equivalence relation T

over the set of terms That relation dictates which terms b elong to the typ e and which are

typ e The second relation is another partial equivalence relation over terms equal within that

that dictates which terms are typ es and which are equal typ es

A symmetric and transitive relation

t T i t t T

T typ e i T T

     

T T i T T T T T T T T

        

t t T i t t T t t t t T T t t T

t t Void

  

a a Atom a a atoms i a a

  

n n Z n n integers i n n

 

t t E i tt

 

inj ainj a A B i A B typ e a a A

 

inj binj b A B i A B typ e b b B

   

ha bi ha b ixAB i xAB typ e a a A b b B ax

   

xb xb xAB i xAB typ e a a A baxb a x B ax

   

xb xb ff j xA B g i ff j xA B g typ e a a A baxb a x B xb af x

  

t t T i T typ e tt tt t T

 

a a fx A j B g i fx A j B g typ e a a A b b B ax

  

a a xy AB i xy AB typ e a A a A b b B a a x y

  

a a in A i a a in A typ e a a A

 

A B i A B typ e a a A a a B

     

t t i t t typ e n n t n t n n n

a in A i a in A typ e a

A total i A total typ e t A t

A admiss i A admiss typ e AdmA

   

For T T i T T and for T T i T T U

i

Void Void Atom Atom Z Z E E

   

A B A B i A A B B

     

A a a A B ax B a x xAB xA B i A

     

xAB xA B i A A a a A B ax B a x

  

ff j xA B gff j xA B g i A A

   

A P x y A a a a P a a a a x y P a

  

a a aa e e P a a x y is wellfounded

 

a a A t t ff j xfe A j P e ax y gB g

  

B t af x B t a f x





T T i T T t T t

    

fx A j B gfx A j B g i A A a a A B ax B a x

   

a a A B ax B a x

 

t t xA B B t t xA B B

  

B i A A xy AB xy A

   

x y a A B a a x y B a A a a a a

     

a a A a a A B a a x y B a a x y

 

t t xA y A B B t t xA y A B B

t t xA B xy t t xA y A B B y xx y

t t xA y A z A B B y zx y B zy

a a in A

     

a A a a a A in A i A A a a

   

A B A B i A A B B

   

t t t t i t t Z t t Z

   

a in A a in A i A A a a A

 

A total A total i A A

 

A admiss A admiss i A A

U typ e

i

U U i ij

i j

Figure Typ e Sp ecications

These relations are sp ecied in Figure Unfortunately the sp ecication contains negative

o ccurrences of the relations b eing dened so it cannot b e taken as a valid inductive denition

However examination reveals that each clause of the sp ecication uses the relations only at

typ es smaller than the typ e at issue in the clause This suggests a way that we may rephrase

the sp ecication as a valid inductive denition The technique I use is due to Allen my

contribution here is its extension to a number of new typ es An alternative but similar technique

is that of Harp er who shows how the sp ecication can be rephrased to dene an explicit

set theoretic relation as the least xed p oint of a monotone op erator

The principal notion in the construction is that of a A candidate type system

 

is a relation T T between closed terms T and T and binary relations over closed terms

 

The intended reading of T T is that T and T are equal typ es and is their equality relation

Denition A typ e system is a candidate type system that satises seven properties

   

is uniquely valued if T T and T T then is

 

is type symmetric if T T then T T

then T T is type transitive if T T and T T

 

is type value respecting if TT and T T then T T



is term symmetric if T T then is symmetric



is term transitive if T T then is transitive

  

is term value respecting if T T and tt and t t then t t

The goal is to build a typ e system that captures the intended meanings of the typ es I

do this be dening a series of op erators on candidate typ e systems Note that each op erator

uses it argument only in p ositive p ositions so they maybeassembled into a valid inductive

denition

The rst and most imp ortant step of the construction is to dene for eachtyp e construc

tor an op erator on candidate typ e systems Given candidate typ e system each op erator is

to return a typ e system that contains all typ es built using its typ e constructor from typ es in

For example Prod will contain all pro duct typ es built from typ es in These op erators

dene the meanings of the typ e constructors Their denitions app ear in Figures through

Next we dene another op erator Close on candidate typ e systems Given typ e system

Close contains all typ es built from typ es in using any typ e constructor other than

universes The intention is that the argument dene all universes up to some U in which

i

case Close will dene all typ es built from those universes that is all members of U

i

Close is dened to b e the smallest candidate typ e system such that

W

  

opClose TT Close TT i T T

opTypes

Void Atom Int Every Union

where Types Prod Fun VFun Bar Eq Sub

Ineq Conv Total Adm Set Quot

Next weusemutual induction to dene two series of candidate typ e systems Univ and Nuprl

i i

Univ denes all universes U where j i and Nuprl denes all typ es built up from those

i j i

   

VoidTT i T Void T Void t t tt

    

Atom TT i T Atom T Atom t t tt a fatomsgt a t a

    

Int TT i T Z T Z t t t t n fintegers gt n t n

    

Every TT i T E T E t t t t tt

  

Union TT i A B A B

    

T A B T A B AA BB

 

t t t t

   

a a t inj a t inj a aa

   

b b t inj b t inj b b b

  

Prod TT i A B A B

   

T xAB T xA B AA

   

a a a a B axB a x

a

 

t t t t

      

a b a b t ha bit ha b i aa b b

a

  

Fun TT i A B A B

   

T xAB T xA B AA

   

a a a a B axB a x

a

 

t t t t

  

b b t xb t xb

   

a a a a bax b a x

a

  

VFun TT i A B A B P

  

T ff j xA B gT ff j xA B gAA

   

a a a a a a a a

 

P a a x y P a a x y

a a



 

a a a a e e e is wellfounded

aa

      

a t a t a a t t B t af xB t a f x

a

ta



e t t e e



t t

e

  

b b t xb t xb

   

a a a a ae bax b a x

ta

 

t t t t

  

b b t xb t xb

   

a a a a bax b a x

ta

 

Bar TT i A A

 



T A T A AA

a a a a

 

t t t t

 

tt ttt

Figure Typ e Denitions Data Typ es

   

a Eq TT i A A a a a

   

T a a in A T a a in A

  

AA a a a a

  

t t t t t t a a

  

Sub TT i A B A B

    

T A B T A B AA BB

     

t t t t t t a a aa a a

  

Ineq TT i e e e e n n fintegers g

  

T e e T e e

  

n n e n e e n e

  

t t t t t t n n

  

Conv TT i A A aa

   

T a in A T a in A AA

 

e e e e a a aa a

  

t t t t t t a

 

Total TT i A A

  

T A total T A total AA

  

t t t t t t a a a a

 

Adm TT i A A

  

T A admiss AA T A admiss

 

t t t t



t t

 k k 

f f f f

f e e j k j e e e e

Figure Typ e Denitions Assertions

universes

 

Univ TT i j i T U T U

i j j

  

A A A A Nuprl AA

j

def

CloseUniv Nuprl

i i

Finally wemay dene a candidate typ e system Univ that denes all universes and dene the

desired Nuprl to b e its closure

 

Univ TT i i T U T U

i i

  

A A AA Nuprl AA

i

def

Nuprl CloseUniv

Wemaynow dene the desired equality relations using Nuprl

Denition

T T i Nuprl T T

t t T i Nuprl TT t t

It remains to show that the equality relations have the desired prop erties First wemust show

that Nuprl is actually a typ e system as intended Then we will observethat Nuprl adheres

to the sp ecication in Figure

Lemma If is a type system then for each op Types op is a type system

Lemma Each operator in Types denes disjoint types from the others and from when

ormal ly if denes only universes F

    

Set TT i A B A B ee

  

T fx A j B gT fx A j B gAA

  

a a aa B axB a x

a

     

a a aa B axB a x

a



B implies B

      

b a a b b ea bx y ea b x y a b a

a

a



B implies B

        

a b a b a a b b e a bx y e a b x y

a

a

  

t t tt tt b b b

t

    

Quot TT i A B A B ee e e e

r s t

  

T xy AB T xy A B AA

   

a a a a a a a a

 

B a a x y B a a x y

a a



   

a a a a a a a a

    

B a a x y B a a x y

a a





B implies B

     

a a a a bb a a a a b b

a a



   

ea a bx y z ea a b x y z

a a





B implies B

      

b b a a bb a a a a a a

a a



  

ea a bx y z ea a b x y z

a a



reexivity

  

aa e ax e a x a a

r r

aa

symmetry

     

a a a a bb a a a a b b

a a



  

e a a bx y z e a a b xyz

s s

a a



transitivity

    

a a a a a a b b b b

  

a a a a a a

 

b b b b

a a a a

  

e a a a b b x y z v w

t

a a



    

e a a a b b x y z v w

s

   

t t tt tt t t b b b

tt

Figure Typ e Denitions Set and Quotient

is type symmetric and type transitive and

denes only universes that is if T T then T U for some i and

i

 

and and Close T T Close T T



either T T or T T

  

then either T T and T T or for some op Types opClose T T and



opClose T T

Lemma If is a type system and if denes only universes then Close is a type

system

Lemma For al l i Univ and Nuprl are type systems

i i

Lemma Univ and Nuprl are type systems

Pro of

First show that Univ is a typ e system All but unique valuation and typ e transitivity are

directly by Lemma For unique valuation and typ e transitivity use Lemma with

 

the observation that Univ is cumulative for all i j if Univ TT then Univ TT

i i j

Then Nuprl is a typ e system by Lemma

Prop osition The equality relations T T and t t T adhere to the specication

in Figure

Judgement Semantics

I b egin the semantics for judgements by dening the notion of an assignment of closed terms

to variables

Denition

An assignment is a sequence of pairs hx t i hx t i such that each x is a distinct

n n i

variable and each t is a closed term

i

The application t of an assignment to a term t where hx t i h x t i is

n n

tt t x x

n n

As discussed in Section the intended meaning of the sequent H C t is that C

  

C andt t C when and are equal assignments for the hyp otheses H In

order to formalize this as a semantics for judgements I must dene exactly what is meant by

equal assignments

The obvious idea is to say that assignments are equal when their corresp onding terms are

equal in the appropriate t yp es Wemay call this notion assignment similarity

Denition Assignment similarity written H is the smal lest relation such

that

hx t i hx t iH x T if H and t t T

This notion provides a good starting point but it will not serve as the needed notion of as

neither symmetric nor transitive Symmetry do es not hold signment equality b ecause it is

b ecause it is not generally the case for similar assignments and that T T so

t t T do es not imply t t T Transitivity fails for the same reason

The solution is to imp ose on the inductive case the additional requirement that T

T The leads to the rst of three denitions of assignment equality

Denition Assignment equality with minimal functionality written H is

min

the smal lest relation such that

min

hx t i hx t i H x T if

min

H and

min

t t T and

T T

Prop osition Assignment equality with minimal functionality is symmetric and transitive

This notion of equality is called minimal functionality b ecause it uses the minimum extra con

straintover similarity to ensure symmetry and transitivity By strengthening that constraint

we can get two other interesting forms of assignment equality Note that in the third clause

of the inductive case of Denition the assignments and are similar since clearly

H implies H and xed Wedenepointwise functionality by allowing

min

one of the similar assignments to varyandwedeneful l functionality by allowing b oth of the

similar assignments to vary

Denition Assignment equality with pointwise functionality written H is

pw

the smal lest relation such that

pw

hx t i hx t i H x T if

pw

H and

pw

t t T and

for al l if H then T T

Denition Assignment equality with ful l functionality written H is the

ful l

smal lest relation such that

ful l

hx t i hx t i H x T if

ful l

H and

ful l

t t T and

  

for al l if H then T T

Following are some imp ortant prop erties of pointwise and full functionality For any of the

three forms of functionality I write H to mean H

Prop osition

  

If H then for any H implies H

pw pw

If H then for any H implies H

ful l ful l

Assignment equality with pointwise functionality is symmetric and transitive

Assignment equality with ful l functionality is symmetric and transitive

We can now dene the semantics of Nuprl judgements Following Constable et al I use

p ointwise functionality An avenue for future research is to explore semantics based on full

or minimal functionality The semantics given by Constable et al is equivalent to this

one but is considerably more complicated



Denition The judgement H C t is valid if for al l assignments and

   

H implies C C and t t C The judgement t t is valid if

pw



t t

Theorem Nuprl Soundness Any judgement derivable in the Nuprl proof rules is

valid

Pro of

By induction on derivations

Corollary Nuprl Consistency The Nuprl proof rules are consistent

Pro of

The judgement Void is invalid and therefore unprovable

Classical Reasoning

As discussed in Section classical reasoning principles are semantically invalid within the

typ e theory In the Nuprl semantics validity of the excluded middle principle P P P

would imply the existence of a computable function that would determine the truth or falsity

of every prop osition However in the underlying metatheory we may consider using classical

reasoning principles

The pro of rules given in App endix B and not marked as classical may all be proven valid

without classical reasoning However there are some additional rules that may b e shown valid

in a classical metatheory

The primary such rule is a weak form of the excluded middle principle

XM

H P P P P x

i

Prop osition The rule XM is semantical ly valid in a classical interpretation

Note that this works b ecause of the squashing of P P The alternativeaxiom P P PP

i

is not semantically valid b ecause it still implies the existence of a general decision function

even though that function is still not provided In Chapter we will see another example of

imp ortant rules validated by a classical metatheory but not a constructive metatheory These

are the coadmissibility rules for partial typ es Rules PWC and PC

One practical use of the XM rule is for xp oint induction Section Recall that the

T y x in T P P This subgoal xp oint induction rule generates the subgoal H x

may be proven from the simpler subgoal H P x using the XM rule and some of the

other subgoals of the xp oint induction rule Instantiating XM gives x in T x in T

Then P can be proven by cases invoking hyp othesis y if x in T and substituting for x if

x in T By subgoal wemay conclude P from P

Chapter

Admissibility

One of the earliest logical theorem provers was the LCF system based on the logic of

partial computable functions Although LCF enjoyed many groundbreaking successes

one problem it faced was that although it supp orted a natural notion of partial function it had

diculty expressing the notion of a total function Later theorem provers based on constructive

typ e theory such as Nuprl based on MartinLof typ e theory and Co q based on

the Calculus of Constructions faced the opp osite problem they had a natural notion of

total functions but had diculty dealing with partial functions The lack of partial functions

reason seriously limited the scop e of those theorem provers because it made them unable to

ab out programs in real programming languages where recursion do es not always necessarily

terminate

This problem may b e addressed in typ e theory by the partial typ e discussed in Chapter

In a partial typ e theory recursively dened ob jects may be typ ed using the xpoint principle

if f has typ e T T then x f has typ e T However the xp oint principle is not valid

for every typ e T it is only valid for typ es that are admissible This phenomenon was not

unknown to LCF LCF used the related device of xp oint induction whichwas valid only for

admissible predicates When the user attempted to invoke xp oint induction the system would

automatically check that the goal was admissible using a set of syntactic rules

Despite their obvious uses in program analysis partial typ es have seen little use in theorem

proving systems This is due in large part to two problems partial typ e extensions

have been develop ed only for fragments of typ e theory that do not include equality and to o

few typ es have b een known to b e admissible I addressed the former problem in Chapter in

this chapter I address the latter

Smith gave a signicant class of admissible typ es for a Nuprllike theory but his class

required pro duct typ es to be nondep endent The typ e xAB where x app ears free in

B was explicitly excluded Later Smith extended his class to include some dep endent

pro ducts xAB but disallowed any free o ccurrences of x to the left of an arrowinB Partial

typ e extensions to Co q were also restrictive assuming function spaces to be the only typ e

restrictions are quite strong dep endent pro ducts are used in enco dings constructor These

of mo dules ob jects algebras and even such simple devices as variant records

Furthermore ruling out dep endent pro ducts disallows reasoning using xp oint induction as

in LCF This is explained further in Section Finally the restriction is particularly

unsatisfying since most typ es used in practice do turn out to b e admissible and may b e shown

so by metatheoretical reasoning

In this chapter I presentavery wide class of admissible typ es using two devices a condition

called predicateadmissibility and a monotonicity condition In particular many dep endent

pro ducts may be shown to be admissible Predicateadmissibility relates to when the limit

of a chain of typ e approximations contains certain terms whereas admissibility relates to the

memb ership of a single typ e Monotonicity is a simpler condition that will b e useful for showing

typ es admissible that do not involve partiality

The Fixp oint Principle

The central issue of this chapter is the xpoint principle

f T T x f T

The xp oint principle allows us to typ e recursively dened ob jects such as recursive functions

Unfortunatelyunlike in programming languages where the principle can usually b e invoked on

arbitrary typ es expressivetyp e theories suchas the one in this thesis contain typ es for which

the xp oint principle is not valid I shall informally saythatatyp e is admissible if the xp oint

principle is valid for that typ e and give a formal denition in Section To make maximum

use of a partial typ e theory one wants as large a class of admissible typ es as p ossible

In Section I will explore two wide classes of admissible typ es one derived from a predicate

admissibility condition and another derived from a monotonicity condition But rst it is

worthwhile to note that there are indeed inadmissible typ es

Theorem There exist inadmissible types

Pro of Sketch

Z j ng Let T be the typ e of This example is due to Smith Recall that N fn

functions that do not halt for all inputs and let f be the function that halts on zero and

on any other n immediately recurses with n This is formalized as follows

def

T hN N xN h x in N Void

def

f phx if x then else px yi

Z

Intuitively any nite approximation of x f will recurse some limited number of times

and then give up placing it in T but x f will halt for every input excluding it from T

Formally the function f has typ e T T but x f T The pro of of these two facts

app ears in App endix C Therefore T is not admissible

Computational Lemmas

Before presenting my main results in Section I rst require some lemmas ab out the com

putational b ehavior of the xp oint op erator The central result is that x f is the least upp er

b ound of the nite approximations fff with regard to a computational ap

proximation relation dened b elow The compactness of x if x f halts then one of its nite

approximations halts will b e a simple corollary of this result However the pro of of the least

upp er b ound theorem is considerably more elegant than most pro ofs of compactness

Computational Approximation

For convenience throughout this section we will frequently consider terms using a unied repre

sentation scheme for terms A term is either a variable or a comp ound term x x t

k

x x t where the variables x x are b ound in the subterm t For example the

n n i i

nk ik

n

i

term xT T is represented T xT and the term ht t i is represented hit t

Informally sp eaking a term t approximates the term t when if t converges to a canonical

form then t converges to a canonical form with the same outermost op erator and the subterms

of t s canonical form approximate the corresp onding subterms of t s canonical form The

formal denition app ears b elow and is due to Howe Following Howe when R is a binary

relation on closed terms I adopt the convention extending R to p ossibly op en terms that if t

  

and t are p ossibly op en then tR t if and only if t Rt forevery substitution such that



t and t are closed

Denition Computational Approximation

 

Let R be a binary relation on closed terms and suppose e and e areclosed Then eCR e

  

exactly when if e x t x t then there exists some closed e x t x t

n n n

n

  

such that e e and t Rt

i

i

 

e e whenever e and e are closed

 

e e if and only if eC e

i i

 

e e if and only if e e for every i

i



Denition Computational Equivalence The terms e and e are computational ly

  

equivalent e e if and only if e e and e e

The following are facts ab out computational approximation that will b e used without ex

plicit reference The rst two follow immediately from the denition the third is easy using

determinism Prop osition and the last is proven using Howes metho d

Prop osition

and are reexive and transitive

i

  

t t If t t then t t and

i

  

If t t then t t and t t

i

   

Lemma Congruence If e e and t t then etx e t x

Howes denition actually diers slightly from the one here he denes as the greatest xed p oint of the

op erator C It is not dicult to showthatthetwo denitions are equivalent as long as the computation system

is deterministic Prop osition If the computation system is nondeterministic the denition here fails to b e

a xed p oint and the more complicated greatest xed p oint denition must b e employed

Finite Approximations

With this notion of computational approximation in hand we may now show that the terms

f ff form a chain of approximations to the term x f Let be the divergent

i

term x xx Since never converges t for anytermt Let f b e dened as follows

def

f

def

i i

f f f

Certainly f f since f By congruence f f f f and thus f f Similarly

i i

f f for all i Thus f f f forms a chain I now wish to show that x f is an

i i

upp er b ound of the chain Certainly f x f Supp ose f x f By congruence f f

i i

f x f Thus since x f f x f it follows that f f f f x f x f By

induction it follows that x f is an upp er b ound of the chain The following corollary follows

from congruence and the denition of approximation

j

Corollary If there exists j such that ef x then ex f x Moreover the canonical

j

forms of ef x and ex f x must have the same outermost operator

Least Upp er Bound Theorem

In this section I summarize the pro of of the least upp er b ound theorem To b egin we need a

lemma stating a general prop ertyofevaluation Lemma captures the intuition that closed

noncanonical terms that lie within a term b eing evaluated are not destructed they either are

moved around unchanged the lemmas rst case or are evaluated in place with the surrounding

term left unchanged the lemmas second case The variable x indicates p ositions where the

term of interest is found and in the second case the variable y indicates which of those p ositions

if any is ab out to b e evaluated

Lemma If e tx e and e tx is closed and t is closed and noncanonical then

either

    

there exists e such that for any closed t e t x e t x or

      

there exist e and t such that e e xy t t and for any closed t e t txy

  

e t t x y

It is worthwhile to note that Prop osition and Lemmas and are the only prop erties

of evaluation used in the pro of of the least upp er b ound theorem and that these prop erties are

Consequently the theorem maybe true in computational systems with considerable generality

used in a variety of applications b eyond the computational system of this thesis

Lemma shows that x terms may b e eectively simulated in any particular computation

by suciently large nite approximations The lemma is simplied by using computational

approximation instead of evaluation for the simulation which makes it unnecessary to track

which of the approximations are unfolded and which are not an issue that often complicates

compactness pro ofs

Lemma Simulation For al l f e and e where f is closed and x is the only free

  

variable of e there exist j and e such that if e x f x e then e e x f x and

 k j k

for al l k j e f x e f x

j

Theorem Least Upp er Bound For al l f t and e where f is closed if j ef x

t then ex f x t

Pro of Sketch

By induction on l that ex f x t The complete pro of in App endix C addresses

l



free variables Supp ose ex f x evaluates to some canonical form e x f x where

 

e is chosen by Lemma Let e be of the form x t x t Using Lemma

n n

k  j

the assumption k ef x t and transitivity we may show that e f x t for all j

  j 

Therefore t x t x t andt f x t for all j Now by induction t x f x

n i i

l

n

i



t Thus ex f x t

l

i

There are two easy corollaries to the least upp er b ound theorem One is that x f is the least

xed p ointof f and the other is compactness

Corollary Least Fixed Point For al l closed f and t if f t t then x f t

Pro of

j

Certainly f t Then f f f f t t Similarlyby induction f t for any

j Therefore x f t by Theorem

Corollary Compactness If f is closedandex f x then there exists some j such

j j

that ef x Moreover the canonical forms of ex f x and ef x must have the same

outermost operator

Pro of

j j

Supp ose there do es not exist j such that ef x Then ef x for all j By Theorem

e x f x Therefore ex f x do es not converge but this contradicts the

j j

assumption so there must exist j such that ef x Since ef x ex f x the

j

canonical forms of ef x and ex f xmust have the same outermost op erator

Admissibility

Iamnow ready to b egin sp ecifying some wide classes of typ es for which the xp oint principle

is valid First we dene admissibility The simple prop ertyofvalidating the xp oint principle

is to o sp ecic to allow any go o d closure conditions to be shown easily so we generalize a bit

to dene admissibility A typ e is admissible if the upp er b ound tx f of an approximation

chain tf tf tf b elongs to the typ e whenever a conite subset of the chain b elongs

to the typ e This is formalized as Denition but rst I dene some convenient notation

j j

f

Notation For any natural number j the notation t means tf w and the notation

f

t means tx f w Also the f subscript is dropped when the intended term f is unam

biguously clear

Denition Atype T is admissible abbreviated AdmT if

 k k 

T f t t j k j t t T t t

Although this pro of is nonconstructive aslightly less elegant constructive pro of maybederived directly

from Lemma

As exp ected admissibilityissucient to guarantee applicability of the xp oint principle

 

T T then x f x f Theorem For any T and f ifT is admissible and f f

T

Pro of

j j

T typ e since T T typ e Note that f f T for every j Supp ose x f By

j j j j 

compactness f for some j Since f f T it follows that f and thus x f by

 

Corollary Similarly x f implies x f It remains to show that x f x f T

j

when x f Supp ose again that x f As b efore there exists j such that f by

j j 

compactness Hence f f T Since T is admissible x f x f T

A number of closure conditions exist on admissible typ es and are given in Lemma

Informally basic comp ound typ es other than dep endent pro ducts are admissible so long as

their comp onent typ es in positive p ositions are admissible Base typ esnatural numbers

convergence typ es and for this lemma only equalitytyp esare always admissible These are

essentially the admissible typ es of Smith except that for a function typ e to b e admissible

Smith required that its domain typ e b e admissible

Lemma

AdmA B if AdmA and AdmB

AdmxAB if a A AdmB ax

AdmA B if AdmA and AdmB

AdmVoid AdmAtom AdmZ and AdmE



Adma a in A



Adma a

AdmA if AdmA

Adma in A

Pro of

The pro of follows the same lines as Smiths pro of except that handling equality adds a

small amount of complication to the pro of Ishow the function case byway of example

 k k

Let f t and t be arbitrary Supp ose j is such that k j t t xAB I need

 j

to show that t t xAB Since xAB is inhabited it is a typ e Both t and

j  

t converge to lambda abstractions so by Corollary t xb and t xb for

   

some terms b and b Supp ose a a A To get that bax b a x B ax it

 

B ax Since AdmB ax it suces to show that suces to show that t a t a

k k 

k j t a t a B ax whichfollows from the supp osition

Unfortunately Lemma can show the admissibility of a pro duct space only if it is

nondependent Dep endent pro ducts do not have an admissibility condition similar to that

of dep endent functions This reason for this is as follows Admissibility states that a single

xed type contains the limit of an approximation chain if it contains a conite subset of that

chain For functions disjoint union partial typ es and nondep endent pro ducts it is p ossible

to decomp ose prosp ective memb ers in sucha way that admissibilitymay b e applied to a single

typ e such as the typ e B ax used in the pro of of Lemma In contrast for a dep endent

pro duct the righthand terms desired typ e dep ends up on the lefthand term whichischanging

at the same time as the righthand term Consequently there is no single typ e into whichto

place the righthand term

However understanding the problem with dep endent pro ducts suggests a solution to gen

eralize the denition of admissibility to allow the typ e to vary This leads to the notion of

predicateadmissibility that I discuss in the next section

PredicateAdmissibility

Denition Atype T is predicateadmissible for x in S abbreviated AdmT j x S if

 k k k k 

f t t ee S j k j e S t t T e x t t T e x

The term predicateadmissibility stems from its similarityto the notion of admissibility



of predicates in domain theory and LCF If one ignores the inhabiting terms t and t which

may b e seen as evidences of the truth of the predicate T then predicateadmissibilityissaying

k

e if T e for all k greater than some j This is precisely the notion of admissibilityof T

predicates in domain theory Indeed the results here were inuenced by the work of Igarashi

who established conditions on admissibility of domaintheoretic predicates

To show the admissibilityof a dep endent pro duct typ e it is sucient to show predicate

admissibility of the righthand side along with admissibility of the left

Lemma The type xAB is admissible if AdmA and AdmB j x A

Pro of

 k k

Let f t and t be arbitrary Supp ose j is such that k j t t xAB It is



necessary to show that t t xAB Since xAB is inhabited it is a typ e Both

j j   

t and t converge to pairs so by Corollary t ha bi and t ha b i for some

   

terms a b a and b To get that a a A it suces to show that t t A

k k

Since AdmA it suces to show that k j t t A which follows from

the supp osition



To get that b b B ax the interesting part it suces to show that t



t B t x Since AdmB j x A it suces to show that t A which

k k k k

has already b een shown and k j t A t t B t x which

follows from the supp osition

The conditions for predicateadmissibility are more elab orate but also more general I

may immediately state conditions for basic typ es other than functions Informally basic com

p ound typ es other than functions are predicateadmissible so long as their comp onenttyp es are

predicateadmissible and base typ es are always predicateadmissible

Lemma

AdmA B j y S if s S A B sy typ e and AdmA j y S and AdmB j y S

sy typ e and y SA typ e and AdmA j y S AdmxAB j y S if s S xAB

and AdmB z z y x j z y SA

AdmVoid j y S AdmAtom j y S AdmZ j y S and AdmE j y S

Adma a in A j y S if s S a a in Asy typ e and AdmA j y S

Adma a j y S

A j y S if s S Asy typ e and AdmA j y S Adm

Adma in A j y S if s S a in Asy typ e

Predicateadmissibility of a function typ e is more complicated b ecause a function argu

ment with the typ e Ae x do es not necessarily b elong to any of the nite approximations

j

Ae x To settle this it is necessary to require a co admissibility condition on the domain

typ e Then a function typ e will b e predicateadmissible if the domain is weakly coadmissible

and the co domain is predicateadmissible

Denition A type T is weakly coadmissible for x in S abbreviated WCoAdm T j x S

if

 k 

f t t ee S j k j e S t t T e x

 k

j k j t t T e x

Atype T is coadmissible for x in S abbreviated CoAdmT j x S if

 k 

f t t ee S j k j e S t t T e x

k k k

j k j t t T e x

Lemma AdmxAB j y S if s S xAB sy typ e and WCoAdmA j y S and

s S a Asy AdmB ax j y S

Clearly coadmissibility implies weak coadmissibility A general set of conditions listed in

Lemma establish weak and full coadmissibilityforvarious typ es Weak and full coadmissi

bility are closed under disjoint union and dep endent sum formation and full coadmissibilityis

additionally closed under equalitytyp e formation I use b oth notions of coadmissibility rather

than just adopting one or the other b ecause full coadmissibility is needed for equalitytyp es but

under certain circumstances weak coadmissibility is easier to show Prop osition b elow

Lemma

for y in S if s S A B sy typ e and A and B are A B is weakly coadmissible

weakly coadmissible for y in S

WCoAdm xAB j y S if s S xAB sy typ e and WCoAdm A j y S and

s S a Asy WCoAdm B ax j y S

s S xAB sy typ e and y SA typ e and CoAdmA j y CoAdmxAB j y S if

S and CoAdmB z z y x j z y SA

Void Atom Z and E are strongly or weakly coadmissible for y in any S

CoAdma a in A j y S if s S a a in Asy typ e and CoAdmA j y S

a a is strongly or weakly coadmissible for y in any S

A is weakly coadmissible for y in S if s S Asy typ e and A is weakly coadmissible

for y is S

a in A is strongly or weakly coadmissible for y in S if s S a in Asy typ e

When T do es not dep end up on S predicateadmissibility and weak coadmissibility b ecome

easier to show

Prop osition Suppose x does not appear free in T Then

AdmT if AdmT j x S and S is inhabited

AdmT j x S if AdmT

WCoAdm T j x S

There remains one more result related to predicateadmissibility Supp ose one wishes to

show AdmT j x S where T dep ends up on x There are two ways that x may be used in

T First T might contain an equalitytyp e where x app ears in one or b oth of the equands In

that case predicateadmissibility can b e shown with the to ols discussed ab ove Second T may

be an expression that computes a typ e from x In this case T can be simplied using direct

computation Section but another to ol will be needed if T p erforms any case analysis

K

as in the emb edding of the disjoin t union typ e in Section

Lemma Consider a type case d xA xB that depends upon y from S Suppose there

exist T and T such that

s S dsy T T sy

s S t T sy As ty x typ e

s S t T sy Bs ty x typ e

y ST typ e and y ST t yp e

Then the fol lowing are the case

Admcase d xA xB j y S if AdmA z z y x j z y ST and

AdmB z z y x j z y ST

WCoAdm case d xA xB j y S if WCoAdmA z z y x j z y ST and

WCoAdm B z z y x j z y ST

CoAdmcase d xA xB j y S if CoAdmA z z y x j z y ST and

CoAdmB z z y x j z y ST

Monotonicity

In some cases a very simple device may be used to show admissibility We say that a typ e is

monotone if it resp ects computational approximation and it is easy to show that all monotone

typ es are admissible



Denition A type T is monotone abbreviated Mono t if t t T whenever t T



and t t

Lemma Al l monotone types are admissible

Pro of

 j j

Let f t and t be arbitrary and supp ose there exists j such that t t T Since

j j  j j 

t t and t t it follows that t t T and t t T The result

follows directly

All t yp e constructors are monotone except universes and partial typ es which are never

monotone The pro of of this fact is easy

Prop osition

Mono A B if Mono A and Mono B

Mono xAB if Mono A and a A Mono B ax

Mono xAB if Mono A and a A Mono B ax

Mono Void Mono Atom MonoZ Mono E Mono a a A Monoa a

and Mono a in A

Set and Quotient Typ es

Given the parallel between the dep endent pro duct and set typ es it is natural to exp ect that

set typ es would have a similar admissibilityrule that fx A j B g if A is admissible and B is

predicateadmissible for x in A Surprisingly this turns out not to be the case Supp ose that

k k

t fx A j B g for all k j Then for every k j there exists some term b B t x We

k

would like it to follow by predicateadmissibilitythat there exists b B t x but it do es

not The problem is that each b can b e a completely dierent term and predicateadmissibility

k

k

applies only when each b is of the form bf w for a single xed b

k

Intuitively the desired rule fails b ecause the set typ e fx A j B g suppresses the computational

content of B and therefore B can be inhabited nonuniformly by unrelated terms for related

j j j

members of A In contrast if the chain t t t belongs to xAB then the chain

j j j

t t t uniformly inhabits B

For a concrete example consider

def

Unit jnZ gn in Zg T fg Z

def

f h x if x then else hx

Z

def

t y w y

k k

f f f

The typ e T is not admissible For all k t k diverges so t T but t converges for all

f

arguments so t T However nZ gn in Z is predicateadmissible for g in Z Unit

The problem is that the inhabiting integers are not related by computational approximation

that is they are not uniform

Toshow a set typ e admissible we needtobeabletoshow that the selection predicate can

b e inhabited uniformly

Lemma The type fx A j B g is admissible if

AdmA and

AdmB j x A and

 

there exists b such that bax B ax whenever a A and b b B ax

Another way to state the uniformity condition the third clause is that the computational

contentofB should b e recoverable from knowing it exists ie there exists a function with typ e

xA B B In fact the twoversions are equivalent mo dulo a few functionality requirements

Prop osition

 

If f xA B B then bax B ax whenever a A and b b B ax where

b fx

   

If baxba x B ax whenever a a A and b Bax and if B axB a x



whenever a a A then xy b xA B B

Wemaygive a similar predicateadmissibility condition

Lemma Admfx A j B gj y S if s S fx A j B gsy typ e and y SA typ e

and AdmA j y S and AdmB z z y x j z y SA and there exists b such that

 

ba sx y B a sx y whenever s S and a Asy and b b B a sx y

Coadmissibility and monotonicitywork on single terms not chains so the uniformity issue do es

not arise resulting in conditions fairly similar to those for dep endent pro ducts

Lemma

WCoAdm fx A j B gj y S if s S fx A j B gsy typ e and WCoAdmA j y S and

s S a Asy WCoAdm B ax j y S

CoAdmfx A j B gjy S if s S fx A j B gsy typ e and y SA typ e and

CoAdmA j y S and WCoAdm B z z y x j z y SA

Mono fx A j B g if MonoA

The conditions for quotienttyp es are similar to those for set typ es

Lemma

Admxy AB if AdmA and AdmB z z x y j z A A and there exists b

     

such that ba a x y B a a x y whenever a A and a A and b b B a a x y

Admxy AB j z S if s S xy AB sz typ e and z SA Atyp e and AdmA j z

   

S and AdmB z z z zxy j z z SA A and there exists

 

b such that ba a sx y z B a a sx y z whenever s S and a Asz and

   

a Asz and b b B a a sxyz

S xy AB sz typ e and WCoAdm A j z S and WCoAdm xy AB j z S if s

 

s S a Asz a Asz WCoAdm B a a x y j z S

CoAdmxy AB j z S if s S xy AB sz typ e and z SA A typ e and

   

z z z zxy j z z SA A CoAdmA j z S and CoAdmB

Mono xy AB if Mono A

Summary

Figure provides a summary of the basic admissibility results of this chapter It is worthwhile

to note that all these results are proved constructively with the exception of weak and full

coadmissibility of partial typ es The following theorem shows that the pro ofs of coadmissibility

of partial typ es are necessarily classical if a constructive pro of existed then one could extract an

algorithm meeting the theorems sp ecication which can b e used to solve the halting problem

Theorem There does not exist an algorithm that computes an integer j such that k

 k 

j t t T e x when given S T f t t e and i such that

T sx typ e s S

CoAdmT j x S

e S

k

k i e S



T e x t t

Recall the inadmissible typ e T from Theorem That typ e fails the predicateadmissibility

condition b ecause of the negative app earance of a function typ e which could not be shown

weakly coadmissible and it fails the monotonicity condition b ecause it contains the partial

typ e N

Conclusions

An interesting avenue for future investigation would b e to nd some negative results character

izing inadmissible typ es Such negative results would b e particularly interesting if they could

be given a syntactic character like the results of this chapter Along these lines it would be

interesting to nd whether the inability to show coadmissibility of function typ es represents a

weakness of this pro of technique or an inherent limitation

The results presented ab ove provide metatheoretical justication for the xp oint principle

ust be over many typ es In order for these results to be useful in theorem proving they m

intro duced into the logic One way to do this and the way it is done here is to intro duce typ es

to represent the assertions AdmT AdmT j x S etc that are inhabited exactly when the

underlying assertion is true in much that same way as the equality typ e is inhabited exactly

when the equands are equal and to add rules relating to these typ es that corresp ond to the

lemmas of Section This brings the to ols into the system in a semantically justiable way

but it is unpleasant in that it leads to a proliferation of new typ es and inference rules stemming

from discoveries outside the logic Of the Nuprl pro of rules of App endix B rules not quite

half deal with admissibility It would b e preferable to deal with admissibility within the logic

A theory with intensional reasoning principles such as the one prop osed in Constable and Crary

would allow reasoning ab out computation internally Then these results could be proved

within the theory and the only extra rule that w ould b e required would b e a single rule relating

admissibility to the the xp oint principle

However they are placed into the logic these results allow for recursive computation on a

wide variety of typ es This make partial typ es and xp oint induction a useful to ol in typ e

theoretic theorem provers It also makes it p ossible to study many recursive programs that

used to b e barred from the logic b ecause they could not b e typ ed

For T

A B xAB xAB

AdmT if

T typ e and AdmA AdmB a A AdmB ax AdmA AdmB j x A

AdmA j y S

WCoAdmA j y S AdmB z z y x

AdmT j y S if AdmA j y S s S a Asy j z y SA

s S T sy typ e and AdmB j y S AdmB ax j y S y SA typ e

WCoAdmA j y S

WCoAdmT j y S if WCoAdmA j y S s S a Asy

s S T sy typ e and WCoAdmB j y S WCoAdmB ax j y S

CoAdmA j y S

CoAdmB z z y x

CoAdmT j y S if CoAdmA j y S j z y SA

s S T sy typ e and CoAdmB j y S y SA typ e

MonoA Mono A

Mono T if Mono A Mono B a A MonoB ax a A Mono B ax

For T

Void Atom Z E a a a in A a a in A A

AdmT if

T typ e and yes yes AdmA

AdmT j y S if

s S T sy typ e and yes AdmA j y S AdmA j y S

WCoAdmT j y S if

s S T sy typ e and yes CoAdmA j y S WCoAdmA j y S

CoAdmT j y S if

s S T sy typ e and yes CoAdmA j y S CoAdmA j y S

MonoT if yes yes

Figure Admissibility coadmissibility and monotonicity conditions

Chapter

Conclusion

In this dissertation I have explored how to draw formal connections between typ e theory and

practical programming languages These connections allow the full p ower of foundational typ e

theory to b e brought to b ear on research problems arising from real programs and programming

languages

The least consequence of these contributions is that program verication results in typ e

theoretic systems may be directly applied to real programs without trusting an intermediate

hand translation into typ e theory More signicantly typ e theory may be applied to pro

gramming languages as a whole this allows us to understand programming languages within a

rich mathematical framework but one that is inherently computational and that also do es not

disturb the essential structure of programs

Three main technical achiev ements made this p ossible First I presented a semantics for

a practical programming calculus in the framework of the Nuprl typ e theory This semantics

was stated as a syntaxdirected embedding of the constructs and used novel typ etheoretic

mechanisms to address the language mechanisms of recursion a rich dep endent kind structure

and a higherorder mo dules system with translucent signatures

Second backing up the typ etheoretic semantics was the rst constructive typ e theory

to include an intrinsic notion of equality and to supp ort reasoning ab out partial and total

functions All three are necessary to allowinteresting reasoning ab out real programs Partiality

e use of recursion However a notion of totalityis is necessary b ecause real programs often mak

also necessary to allow reasoning ab out pure values whicharecentral to real programs as well

Third broad new techniques for showing admissibilityoftyp es for xp oint induction were

necessary for each of the previous contributions Although the techniques I present are still

conservative they make p ossible admissibility pro ofs for many typ es that could not b e shown

admissible by previous techniques For example typ es arising in the emb edding of disjoint

unions Section and in xp oint induction Section required the new techniques to

be shown admissible

The broadest aim of this work has b een to bring theory and practice closer together Aside

from the sp ecic contributions that make up this dissertation I have found that an imp ortant

waythiswork has help ed achieve that is as a conceptual to ol for thinking ab out programming

and programming languages Practical languages are made up of diverse sets of often compli

cated mechanisms In contrast languages for theoretical study usually are made up of small

sets of elegant mechanisms Typ e theory like other theoretical languages is made up of ele

gant mechanisms but I have shown in this dissertation that those mechanisms are suciently

powerful to account for most of the diverse mechanisms of practical languages and those that

remain show great promise of b eing addressed as well recall Section

Consequently I have found it very protable to use typ e theory as a to ol for considering

general programming issues The p ower and elegance of typ e theory allow a researcher to derive

elegant solutions to diverse problems but do not require one to ignore practical issues to get

them

App endix A

Lamb daK Typing Rules

Level Denitions Subkinding

def

K

level Type i

i

SubkindReex

K

def

level P c i

i

def

level S c i

i

def

K IL

level maxlevel level

SubkindTrans

def

K

in

n

level f g max level

i i i i

i

i j

Kind Formation and Equality

Type Type Typ eSub

K

i j

K

KindEqSymm

K

K

K

kind

K

K IL

PiSub

K

KindEqTrans

K

j i

for i n

j j K i

i

j i

Type Type Typ e

K

kind for n i m

i i

j j K i

j i

kind for i n

j K

j i

in

im

g f gf

K i i i i i

i

K K

im

m n

i

K

DepRecordSub

Pi

c c

K

i j

j i

P c P c PowSub

K i j

for i n

K i j j

i

in

in

f g f g

K i i i i i

i

c Type

i m

K

i

i

P c Type PowTyp e

K i

i

DepRecord

c c Type

K

i

c c Type

K

i

i j

P c P c Pow

K i i

S c S c SingSub

K i j

c c Type c Type

K K

i i

S c S c Sing S c P c SingPow

K i i K i i

Constructor Formation and Equality

c c Type for i n

K i

c c

j

i

K

c c EqSymm

K

f c c g Record

K n n

f c c g Type

n

n j

c c c c

K K

c c Type for i n

K i

j

i

c c EqTrans

K

h c c i Union

K n n

h c c i Type

n

n j

Typ eVar

K

c c

K K

c c Subkind

K

kind c c

K K

c c

K

c c

K

PiIntro

c c c c PiBeta

K

c c c c

K K

c c c c c

K

c

K

PiElim

c

cc PiEta

K

j i j i

c c c

K i i

i

j j

in

for i n

f c g

K i i

j

in

j n

f g kind

K i i i

in

f c gc

K i i j

j

in

in

g f c g f c

K i i i

DepRecordBeta

i

in

f g

i i i

DepRecordIntro

in

in

f c g f g

K i i i i

i

in

in

f c g c f g

K i i i i in

i

c c f g

K j j j

DepRecordEta

c c

K

i i

j i

j i

c c Type

K

i

c

i

j

j

c S c SingIntro

i n

K i

DepRecordElim

c S c

K i

c c Type SingElim

K

i

c c Type c c Type

K K

i i

c c c c Type

K

i

Arrow

c c Type c P c

K K i

i

c c P c PowFun

K i

c c Type c c Type

K K

i i

c c c c Type

K

i

TArrow

c c Type c S c

K K i

i

c c S c SingFun

K i

c c Type

K K

i

c c Type

K

i

m hi

K

level i

ext m Typ eMo dElim

K

Quant

Subtyping

e c c e c

c c c c

K K

K K

e e c ArrowElim

c c SubTrans

K

K

c c c c

K K

c typ e x c e c

K K

x

c c c c ArrowSub

K

xc e c c

K

TArrowIntro

c c c c

K K

e c c e c

K K

c c c c TArrowSub

K

e e c TArrowElim

K

c typ e c typ e

K K

kind e c

K K

c c c c TotalSub

K

e c

K

QuantIntro

K

e c c

c c

K K

K

c typ e

ec c c QuantElim

K

K

QuantSub c c

K

e c for i n

K i i

c c for i n

f e e g f c c g

K i

K n n n n

i

c typ e for ni m

RecordIntro

K i

m n

f c c g

K n m

g c f c

n

n

e f c c g

K n n

i n

RecordSub

ec

K i

i

RecordElim

for i m c c

K i

i

e

K

typ e for mi n c

K

i

m n

inj eh i UnionIntro

K

h c c i

K n m

h c c i

n

n

UnionSub

e h i

K n n

x e for i n

i i K i

c c c Type c Type

K K K

i i

case e x e x e

K n n n

c P c

K i

UnionElim

PowIntro

c P c

K i

e c c c c

K

c c PowElim

K

x ec c Fix

K

c c



Typing

xc m hhcii

K

x c Var

K

ext mc TermMo dElim

K

c typ e x c e c

K K

x

e c c c

K K

xc e c c

K

e c Subtyp e

K

ArrowIntro

Valuability Signature Formation and Subsignatures

xc

K K

x c VarHalt

K

SubsigTrans

K

c typ e x c e c

K K

x

K

xc e c c

K

h ih i Typ eSig

K

ArrowIntroHalt

c c

K

c typ e x c e c

K K

x

hhc iihhc ii TermSig

K

xc e c c

K

TArrowIntroHalt

K

e c c e c

K K

s

K

e e c

s sig

K

K

TArrowElimHalt

s s PiSig

K

kind e c

K K

j i

e c

K

s for i n

j j K i

i

QuantIntroHalt

j i

s sig for ni m

j j K i

j i

s sig for i n

j K

j i

e c c

K K

in

im

f s g f s g

K i i i i i

ec c c QuantElimHalt

i

K

im

m n s

i

RecordSig

e c for i n

K i i

f e e gf c c g

K n n n n

Mo dule Formation

RecordIntroHalt

s

s Mo dVar

K

e f c c g

K n n

i i n

e c

K i

i

c

K

RecordElimHalt

hci hi Typ eMo d

K

e

K

e c

K

inj e h i UnionIntroHalt

K

hheii hhcii TermMo d

K

e h i

K n n

sig s m

K K

x e for i n

i i K i

s m s PiMo dIntro

K

case e x e x e

K n n n

UnionElimHalt

m s m

K K

e c c c c

K

m m m s PiMo dElim

K

x e c c FixHalt

K

c c



m hhcii

K

j i j i

m m s

K i i

j j

ext m c TermMo dElimHalt

K

for i n

in

f s g sig

K i i i

in in

e c c c

K K

f m g f s g

K i i i i i

e c Subtyp eHalt

K

RecordMo dIntro

in

m f s g

K j j j

j i

j i

m m s

K i

i j

j

i n

RecordMo dElim

m

K

m Co erce

K

s ms s

K

s m

PiMo dEta m s

K

in

in

m g f s g f

i i i K i

i

in

m f s g

K i i i

RecordMo dEta

Mo dule Valuability

s

s Mo dVarHalt

K

c

K

hcihi Typ eMo dHalt

K

e c

K

hheiihhcii TermMo dHalt

K

sig s m

K K

s m s

K

PiMo dIntroHalt

j i j i

m m s

K i i

j j

for i n

in

f s g sig

K i i i

in in

f m g f s g

K i i i i i

RecordMo dIntroHalt

in

m f s g

K j j j

j i

j i

m m s

K i

i j

j

i n

RecordMo dElimHalt

m

K

m Co erceHalt

K

App endix B

Nuprl Pro of Rules

Conventions Substitution

H C t x s

Variables b ound in a sequent are taken to b e

H t t in T H x T C typ e

distinct For example Rule has the implicit

side condition that x not b e b ound by H and

H C tx s

Rule has the implicit sidecondition that x

and y are distinct variables and neither is

Direct Computation

b ound by H or J

H C t x s t t

Rules apply only when the consequent and

H C tx s

subgoals are closed sequents For example

Rule has the implicit sidecondition that x

not app ear free in H and also since bythe

H x T t y J Cs t t

rst convention x cannot be bound by H

H x T ty J Cs

that x not app ear free in J C or t

When the inhabitant is omitted in the bot

t t

tom consequent of a rule the inhabitantis

taken to b e

t t

Rules that maybederived from other rules

t t

are marked with a D

t t t t

Structural Rules

t t

H x T J x in T

t t t t

t t x t t x

H J Ct

H x T J Ct

t t

s

t t

H y T x S J Ct

The evaluation step relation is dened in Figure

H x S y T J Ct

x app ears actively in t

H t in C

t t x let x t in t

H Ct

The active p ositions of a term are dened in De

nition

H Ct

H t in C

x t and x t

H T t H x T Ct

let x t in let x t in t

let x t in let x t in t

H C t x tt x D

Equality Atom

H Atom in U

H t t in T

i

H t t in T

string literal a

H a in Atom

H t t in T H t t in T

H a a in Atom H a a in Atom

H t t in T

H a a a a in B

A A

H t t in T

H a a in Atom

H T typ e

H a a true in B

A

Subtyping

H a a true in B

A

H a a in Atom

H x T x in T

H T typ e H T typ e

Integer

H T T

H Z in U

i

H t t in T H T T

integer literal n

H n in Z

H t t in T

H C x b

H x T J Cs H T T

H x Z y x z C x x Cu

H x T J Cs

H x Z y x z C x x Cd

H x Z C

x f x

H T T

if x then b

Z

H T typ e

else if x then u f x y z

Z

else d f x y z x

H T T

H T typ e

H n n in Z H n n in Z

H n n n n in B

Z Z

Universes

ij

H n n in Z

H U in U

i j

H n n true in B

Z

H T in U

i

H n n true in B

Z

ij

H T in U

j

H n n in Z

H T T in U

i

H n n in Z H n n in Z

H T T

H n n n n in B

Z Z

Void

H n n

H Void in U

i

H n n true in B

Z

H t in Void

H n n true in B

Z

H C

H n n

H t t in xAB

H n n in Z H n n in Z

H t t in A

H n n n n in Z

H t t in xAB

Not shown are the various rules governing the b e

H t t in B tx

havior of the binary op erations

H x A y B J hx y iz

Disjoint Union

C hx y iz shx y iz

H A A in U H B B in U

H z xAB J Cs

i i

H A B A B in U

i

H p p in A

H A typ e H B typ e

H p p in B p x

H A B typ e

H p in xA B

H p in xA B

H xAB typ e

H a a in A H A B typ e

H p p in xAB

H inj ainj a in A B

Functions

H A A in U H x A B B in U

i i

H b b in B H A B typ e

H xAB xA B in U

i

H inj binj b in A B

H A typ e H x A B typ e

H t t in A B

H xAB typ e

H x A t t in T

H x B t t in T

in T xt H case t xt xt case t xt

H A typ e H x A b b in B

H xb xb in xAB

H y A J inj y x

H f f in xAB H a a in A

C inj y x sinj y x

H fa f a in B ax

H y B J inj y x

C inj y x sinj y x

H x A f x f x in B

H x A B J Cs

H A typ e

H f in xA B

Pro ducts

H f in xA B

H A A in U H x A B B in U

i i

H f f in xAB

H xAB xA B in U

i

VeryDep endent Functions

H A A in U

i

H A typ e H x A B typ e

H y A z A P in U

i

H xAB typ e

H x A e

H y A z A w P eyx ezx

H x A

f fg j y fy A j P xz g B H a a in A g yf xg

H b b in B ax H xAB typ e B B in U

i

H ha bi ha b i in xAB H ff j xA B g ff j xA B g in U

i

Convergence

H A typ e

T H t in T H t in

H y A z A P typ e

H t in T

H x A e

H y A z A w P eyx ezx

H t in T

H x A

t canonical

H t in T

f fg j y fy A j P xz g B g yf xg

B typ e

H t in T

H ff j xA B g typ e

H t in T

H t in T H t t in T

H ff j xA bg typ e

H t t in T

H x A b b in B xbf

H xb xb in ff j xA bg

H x T x in T H T typ e

H T total

H g g in ff j xA B g H a a in A

H ga g a in B g af x

H t in T H T total

H t in T

H x A g x g x in B g f

H ff j xA B g typ e

H let x t in t in B H t in A

H g in ff j xA B g

H t in A

H g in ff j xA B g

H g g in ff j xA B g

Sequencing

H t t B in

Partial Typ es

H x B t t in A H A typ e

H T T in U H T total

i

H let x t in t let x t in t in A

H T T in U

i

H T total

H t in B H x B t in A

H T typ e

H let x t in t t t x in A

H t t in T H T typ e

Set

H t t in T

H A A in U

i

H x A B in U

i

H x A B in U

i

H x t in T t t in T

H x A B B

T typ e H t in T t in T H

H fx A j B g fx A j B g in U

i

H t t in T

H A typ e H x A B typ e

H f f in T T H T admiss

H fx A j B g typ e

H x f x f in T

H a a in A

H T T H T total

H B ax H fx A j B g typ e

H T T D

H a a in fx A j B g

H t in T H t in T

H x A B typ e H x A y B J Cs

H t t in Top

H x fx A j B g J Cs

H T total

Note that in Rule y may not app ear free in J

H T E D

C or sbyconvention

Equality Typ e

Quotient

H T T in U

i

H T T in U

i

H t t in T H t t in T

H x T y T E in U

i

H t t in T t t in T in U

i

H x T y T E in U

i

H x T y T E E

H x T E xy

H H T typ e H t in T H t in T x T y T z E E y xx y

H x T y T z T

H t t in T typ e

w E w E y z x y E zy

H xy TE xy T E in U

i

H t t in T

H in t t in T

H T typ e

H x T y T E typ e H x t t in T J x C x sx

H x T E xy

H x t t in T J Cs

H x T y T z E E y xx y

H x T y T z T

w E w E y z x y E zy

Subtyping Typ e

H xy TE typ e

H T T in U H T T in U

i i

H T T T T in U

i

H t t in T H xy TE typ e

H T typ e H T typ e

H t t in xy TE

H T T typ e

H T T

H t in T H t in T

H in T T

H e in E t t x y H xy TE typ e

H t t in xy TE

H x T T J x C x sx

H x T T J Cs

H x A y A E typ e

H x xy TE J T typ e

Inequality Typ e

H x A y A z B J s s yx in T

H n n in Z H n n in Z

H x xy TE J s s in T

in U n H n n n

i

Every Typ e

H n n

H in n n

H E U

i

H x n n J x C x sx

H t in T H t in T

H x n n J Cs

H t t in E

Convergence Typ e Totality

H T total

H T typ e

T T in U H t t in T H

i

H t in T t in T in U

i

H U total

i

H t in T

H Void total

H t in T typ e

H Atom total

H t in T

H in t in T

H Z total

H x t in T J x C x sx

H A B typ e

H x t in T J Cs

H A B total

Totality Typ e

H xAB typ e

H xAB total

H T T in U

i

H T total T total in U

i

H xAB typ e

H xAB total

H T typ e

H T total typ e

H A total H fx A j B g typ e

H fx A j B g total

H T total

H in T total

H A total H xy AB typ e

H xy AB total

H x T total J x C x sx

H x T total J Cs

H E total

Admissibility Typ e

H t t in T typ e

H T T in U

i

H t t in T total

H T admiss T admiss in U

i

H T T typ e

H T T total

H T typ e

H T admiss typ e

H t in T typ e

H t in T total

H T admiss

H in T admiss

H T total typ e

H T total total

H x T admiss J x C x sx

H T admiss typ e

H x T admiss J Cs

H T admiss total

Admissibility

H t t typ e

H T admiss

H t t admiss

H T typ e

H t in T typ e

H t in T admiss

H Void admiss

H T total typ e

H Atom admiss

H T total admiss

H T admiss typ e

H Z admiss

H T admiss admiss

H A admiss H B admiss

More Admissibility Typ e

H A B admiss

H A A in U

i

H x A B B in U

i

H B admiss x A

H A admiss H B admiss x A

B admiss x A in U

i

H xAB admiss

H A typ e H x A B typ e

H B admiss x A typ e

H x A B admiss H xAB typ e

H xAB admiss

H B admiss x A

H in B admiss x A

H T admiss H T typ e

H T admiss

H x B admiss x A J x

C x sx

H A admiss

H x B admiss x A J Cs

H B admiss x A

H x A y B B

H fx A j B g admiss

H A A in U

i

H x A B B in U

i

H B wcoadmiss x A

H A admiss

B wcoadmiss x A in U

i

H B z z x y admiss z A A

H x A y A z B B

H xy AB typ e

H A typ e H x A B typ e

H B wcoadmiss x A typ e

H xy AB admiss

H E admiss

H B wcoadmiss x A

H in B wcoadmiss x A

H t t in T typ e

H t t in T admiss

H x B wcoadmiss x A J x

C x sx

H T T typ e

H T T admiss H x B wcoadmiss x A J Cs

H A mono

H A A in U

H A admiss

i

H x A B B in U

i

H T typ e

H B coadmiss x A

B coadmiss x A in U

H Void coadmiss x T

i

H Void mono

H A typ e H x A B typ e

H B coadmiss x A typ e

H T typ e

H Atom coadmiss x T

H B coadmiss x A

H Atom mono

H in B coadmiss x A

H T typ e

H Z coadmiss x T

H x B coadmiss x A J x

C x sx

H Z mono

H x B coadmiss x A J Cs

H A admiss x T

H B admiss x T

H T T in U

i

H A B admiss x T

H T mono T mono in U

i

H T typ e

H A wcoadmiss x T

H T mono typ e

H B wcoadmiss x T

H A B wcoadmiss x T

H T mono

H in T mono

H A coadmiss x T

H B coadmiss x T

H x T mono J x C x sx

H A B coadmiss x T

H x T mono J Cs

More Admissibility

H A mono H B mono

H A admiss x T H T

H A B mono

x A

H A admiss

H A admiss y T

H A admiss H T typ e

H B z z y xadmissz y TA

x A

H A admiss x T

H xAB admissy T

H A typ e H T typ e

x A

H A wcoadmiss y T

H A wcoadmiss x T

H y T x Ay y B wcoadmiss y T

H y T xAB typ e

H A coadmiss x T

H xAB wcoadmiss y T

H A wcoadmiss x T

H A admiss z T

H A coadmiss y T

H B w w w z x y

H B z z y x coadmiss z y TA

admissw z TA A

H xAB coadmiss y T

H z T x A y A w B B

H y T xy AB typ e

H xy AB admiss z T

H A mono H x A B mono

H xAB mono

H A wcoadmiss z T

H z T x Az z y Az z

B wcoadmiss z T

H A wcoadmiss y T

H z T xy AB typ e

H y T x Ay y B admiss y T

H xy AB wcoadmiss z T

H y T xAB typ e

H xAB admissy T

H A coadmiss z T

H B w w w z x y

H A mono H x A B mono

coadmissw y TA A

H xAB mono

H xy AB coadmiss z T

A typ e H A admiss x T H x T

H A mono H xy AB typ e

H A admiss x T

H xy AB mono

H T typ e

H A admiss y T

H E coadmiss x T

H B z z y x admiss z y TA

H y T x A z B B

H E mono

H y T fx A j B g typ e

H fx A j B g admiss y T

H A admiss x T

H x T a a in A typ e

H A wcoadmiss y T

H a a in A admiss x T

H y T x Ay y B wcoadmiss y T

H y T fxA j B g typ e

H fx A j B g wcoadmiss y T

H A coadmiss x T

H x T a a in A typ e

H a a in A coadmiss x T

H A coadmiss y T

H B z z y x coadmiss z y TA

H a a in A typ e

H fx A j B g coadmiss y T

H a a in A mono

H A mono H fx A j B g typ e H x T a a typ e H T typ e

H fx A j B g mono H a a admissx T

Classical Rules

H x T a a typ e H T typ e

H P P P P x XM

i

H a a coadmiss x T

H A wcoadmiss x T H x T A typ e

H a a typ e

H A wcoadmiss x T

H a a in A mono

PWC

H x T a in A typ e H T typ e

H A coadmiss x T H x T A typ e

H a in A admiss x T

H A coadmiss x T

PC

H x T a in A typ e H T typ e

H A A in U

i

H y A z A P in U

H a in A coadmiss x T

i

H f N A nN Pf n f ny z

H x A

H a in A typ e

f fg j y fy A j P xz g B g yf xg

B B in U

i

H a in A mono

H ff j xA B g ff j xA B g in U

i

VF

H y T d in T T

H y T x T A typ e

H A typ e

H y T x T B typ e

H y A z A P typ e

H A z z y x

H f N A nN Pf n f ny z

admissz y TT

H x A

H B z z y x

f fg j y fy A j P xz g B g yf xg

admissz y TT

B typ e

H case d xA xB admiss y T

H ff j xA B g typ e

VFT

H y T d in T T

H y T x T A typ e

H y T x T B typ e

H A z z y x

wcoadmissz y TT

H B z z y x

wcoadmissz y TT

H case d xA xB wcoadmiss y T

H y T d in T T

H y T x T A typ e

H y T x T B typ e

H A z z y x

coadmissz y TT

H B z z y x

coadmissz y TT

H case d xA xB coadmiss y T

App endix C

Pro ofs

 

Lemma C If T U and T T then T T U

i i

Pro of

It is easy to verify that the statement holds for all T if it holds for canonical T Therefore I

assume without loss of generality that T is canonical and prove the statementby induction

on the structure of T I show the function and partial typ e cases the other cases are similar

     

Supp ose T U and T T where T xAB Then for some A B T xA B

i

   

where A A and B B By induction A A U Supp ose a a A Then

i

      

B axB a x U and B a x B a x so by induction B a xB a x U It

i i

  

follows that B axB a x U so T T U

i i

   



Supp ose T U and T T where T A Then for some A T A where A A Since

i

 



A U it follows by induction that A A U Hence A A U so T T U

i i i i

   

Theorem If T typ e and T T then T T If t T and t t then t t T

Pro of

The rst part is shown by a similar argument to Lemma C For the second part it is easy

to verify that the statement holds for all T if it holds for canonical T Therefore I assume

without loss of generality that T is canonical and prove the statement by induction on the

structure of T The case where T U follows from Lemma C I show the function and

i

partial typ e cases the other cases are similar

   

Supp ose t xAB and t t Then for some b t xb Therefore for some b t xb

     

and b b Supp ose a a A Then bax ba x B ax and ba x b a x

    

a x B ax so so by induction ba xb a x B ax It follows that bax b



t t xAB

 

T and t t Certainly t t Supp ose t then t T By induction Supp ose t

 

t t T and hence t t T

Lemma C If x appears actively in t and tex then e

Pro of

By induction on the structure of t

Lemma If x app ears actively in t then tex let x e in t

Pro of

This pro of makes use of Prop osition and Lemma but those facts are shown without

using this lemma I rst show that let x e in t tex Let be a substitution such

that let x e in tand tex are closed and supp ose without loss of generality that

do es not substitute for x Supp ose further that let x e in t Then e so let

e v Note that e v Therefore let x e in t let x e in t let x

v in t tvx t ex tex Hence let x e in t etx

x e in tand tex are Inow showthat tex let x e in t Again supp ose let

closed and supp ose without loss of generality that do es not substitute for x Supp ose

further that tex Note that the active p ositions of t are also activein t By Lemma

C e Thus tex let x e in t in a similar manner as b efore

Lemma If isatyp e system then for each op Types op isatyp e system

Pro of

By tedious verication of all cases The only subtle argument is for unique valuation For

each op erator other than VFun the existential prexs instances are uniquely given by T



and T Parametric variables eg are unique over the memb ership of Therefore

is uniquely given for op erators other than VFun



For the VFun op erator the term P is not uniquely given by T and T The relations

and also are not but they are unique when also given P Further it is not



obvious that is uniquely given by T and T but again it is clearly unique when also

 

given P Supp ose and are dierent equalities resulting from terms P and P Dene

  

and and and so forth to b e the various relations resulting from P and P Wewish

     

to show that t t implies t t Supp ose t t Then t xb and t xb It remains to

     

show that bax b a x implies bax However b a x whenever aa

ta ta

ta

 

are identical relations when they are b oth dened so it suces to show that and

ta ta



is dened for all aa This maybeshown by induction using the order

Lemma If

is typ e symmetric and typ e transitive and

denes only universes that is if T T then T U for some i and

i

 

Close T T and Close T T and



either T T or T T

  

and T T or for some op Types opClose T T and then either T T



opClose T T

Pro of

By insp ection

Lemma If is a typ e system and if denes only universes then Close is a typ e

system

Pro of

All but unique valuation and typ e transitivity are directly by Lemma and induction

Unique valuation and typ e transitivityareby Lemma to ensure b oth antecedents are

from the same case then by Lemma and induction

Lemma For all i Univ and Nuprl are typ e systems

i i

Pro of

By complete induction on i

Theorem There exist inadmissible typ es

Pro of

This example is due to Smith Let the typ e T and the function f b e dened as follows

def

T hN N xN hx in N Void

def

f phg y i

def

g x if x then else px



It is easy to verify that T typ e We wish to showthat f has typ e T T Supp ose t t T



We need g tpg t p N N and y xN g tp x in N Void The former

is easily shown to show the latter I assume that g tpn converges for every natural

number n and draw a contradiction It follows that xN g t px in N is empty and

y is vacuously a function from any emptytyp e to Void Supp ose g tpn converges for

natural number n Then the term if n then else tn also converges every

for every natural number n It follows that t since t and hence t T Thus

xN tx in N Void is inhabited by t and consequently it cannot b e the case

that tn for every natural number n But this is a contradiction since tn

for every n Therefore f T T

However it is not the case that x f T Supp ose x f T Then x f T since

x f converges in two steps Thus x f xN x f x in N Void which

implies that x f is not total on N but it is easy to showby induction that x f

is in fact total on N Therefore x f T and hence T is not admissible

   

Lemma If e e and t t then etx e t x

Pro of

The pro of is a straightforward application of Howes metho d In order to keep this pro of

brief I draw from the terminology and results of Howes pap er and will not rep eat the

k   k  

denitions or lemmas I write t t when t t in k steps and t t when t t in less

than k steps It is sucienttoshow that each of the noncanonical op erators are extensional

  k 

e e and a are closed Supp ose further that t a Case Supp ose t e e t

  k

e e and the induction hyp othesis holds for every closed u u and u if u u

i

i

  k k

and u u then u u Then e xb and be x a By the induction

     

xb By By Howes Lemma there exists b b suchthat e hyp othesis xb e

     

Howes Lemma be x b e x By the induction hyp othesis a b e x However

        

t b e xsob e x t Consequently a t as desired

   

Case Supp ose t case e xe xe t case e xe xe and a are closed Supp ose

k     k

further that t a e e e e and the induction hyp othesis holds Then e inj b

i

j

i

k  

for some j or and e bx a By the induction hyp othesis inj b e

j

j

   

By Howes Lemma there exists b b such that e inj b By Howes Lemma

j

         

e bx e b x By the induction hyp othesis a e b x However t e v x so

j

j j j

    

e v x t Consequently a t as desired

j

  k

Case Supp ose t e t e and a are closed Supp ose further that t a

i i

k k  

Then e hb b i and b a By the e e and the induction hyp othesis holds

i

     

induction hyp othesis hb b i e By Howes Lemma there exist b b and b b

        

suchthat e hb b i By the induction hyp othesis a b However t b so a t

i i

  

Case Supp ose t e e t e e and a are closed Supp ose further

A A

k  

that t a e e and the induction hyp othesis holds Then for some atoms and

i

i

k

e If then a true and otherwise a false By the induction hyp othesis

i i

     

e By Howes Lemma e Hence t asoa t The cases for and

i i Z Z

i i

are similar

  

Case Supp ose t let x e in e t let x e in e and a are closed Supp ose

k    k

further that t a e e e e and the induction hyp othesis holds Then e v

k  

and e vx a By the induction hyp othesis v e By Howes Lemma there exists

      

v v such that e v x By the induction v Then byHowes Lemma e vx e

        

v xso a t v x However t e hyp othesis a e

  k

Case Supp ose t x e t x e and a are closed Supp ose further that t a

k k  

xb and bx ex a By e e and the induction hyp othesis holds Then e

   

the induction hyp othesis xb e By Howes Lemma there exists b b such that

      

e xb By Howes Lemma bx ex b x e x since x e x e By the

       

induction hyp othesis a b x e x However t b x e xsoa t

Lemma If e tx e ande tx is closed and t is closed and noncanonical then either

    

t x or suchthatforany closed t e t x e there exists e

      

there exist e and t suchthate e xy t t and for any closed t e t txy

  

e t t x y

Pro of

   

t txy t y and t e Then e Supp ose e x Then t e tx e Let e

   

t e t t x y The remaining cases are by induction on the derivation of e tx e

Ishow the lamb da rules the other cases are similar

Supp ose the rule used is

z ba baz

The term e txmust have the form of a lamb da abstraction applied to an argument Thus

e mustbeofthe form z ba since e x is already handled and e xa is imp ossible

 

b ecause t is noncanonical Let e baz and supp ose t is closed Then

  

e t x z bt xat x

 

bt xat xz

 

t x since t is closed baz

 

e t x

Supp ose the rule used is



f f



fa f a

Then it must be the case that e is of the form f a since e x is already handled and

f tx f for some f Hence the induction hyp othesis holds for f Supp ose the rst

      

case holds there exists f such that for any closed t f t x f t x Let e f a and



supp ose t is closed Then

  

e t x f t xat x

  

f t xat x

 

e t x

   

Supp ose the second case holds there exist f and t such that f f xy t t and for

        

any closed t f t tx y f t t x y Let e f a and supp ose t is closed Then

    

e t txy f t tx y at txy

   

f t tx y at t x y since y is not free in a

    

f t t x y at t x y

  

e t t x y

Lemma For all f e and e where f is closed and x is the only free variable of e

  

there exist j and e such that if e x f x e then e e x f x and for all k j

 k j k

e f x e f x

Pro of

Ishow the lemma for evaluations of length exactly one The result then follows by induction

on the length of the evaluation sequence summing the numbers j



Use Lemma Supp ose the rst case holds there exists e such that for any closed t

  k  k

e tx e tx Then e x f x e x f x and for any k e f x e f x

 k k 

Thus e f x e f x Supp ose the second case holds there exists e such that e

    

t x f x y e t f x f x y Let e e fxy e xy and for any closed t e

  k  k k

Then e x f x e x f x Supp ose k then e f x e f f x y

 k k k

e f f x y e f x

j

Theorem For all f t and e where f is closed if j ef x t then ex f x t

Pro of

j

By induction on l that for all f t and e where f is closed j ef x t ex f x

l

t The result follows by the denition of The basis is trivial

j

Assume the induction hyp othesis for l and j ef x t Let be a substitution such

that ex f x and t are closed and supp ose without loss of generalitythat do es

j j

not substitute for x Then ex f x ex f x ef x ef x for



any j and the only free variable of e is x Supp ose ex f x e By Lemma

   k j k

e x f x and for some j and all k j e f x ef x Then by e

 k j

assumption and transitivity k j e f x t Therefore changing variables to

 k

replace k j with k e f x t for any k



Let e x t x t and supp ose without loss of generality that x do es not app ear

n n

  k 

in any x Then t x t x t where for i n and any k t f x t

i n i

n

i



t and hence By induction t x f x t for any i Therefore ex f x

i

l l

i

ex f x t

l

Lemma

AdmA B j y S ifs S A B sy typ e and AdmA j y S and AdmB j y S

AdmxAB j y S ifs S xAB sy typ e and y SA typ e and AdmA j y S

and AdmB z z y x j z y SA

AdmVoid j y S AdmAtom j y S AdmZ j y S and AdmE j y S

Adma a in A j y S ifs S a a in Asy typ e and AdmA j y S

Adma a j y S

A j y S ifs S Asy typ e and AdmA j y S Adm

Adma in A j y S ifs S a in Asy typ e

Pro of

Ishow the pro duct and equality cases the other cases are similar but easier



Case For the pro duct case let f t t and e be arbitrary Supp ose e S and

k k k k

j is such that k j e S t t xAB e y It is necessary to show



that t t xAB e y Since e S it follows that xAB e y typ e

j j   

Both t and t converge to pairs so by Corollary t ha bi and t ha b i

  

for some terms a b a and b To get that b b B e y ax it suces to show



that t t B e y t x Rearranging it suces to show equality in

B z z y xhe ti z

Since AdmB z z y x j z y SA it suces to show that he ti y SA

k k k k

and k j he ti y SA t t B z z y xhe ti z

The former will followfroma Ae y and the supp osition The left half of the latter also

k

follows from the supp osition Rearranging the right half it suces to show that t

k k k 

t B e y t x whichfollows from the supp osition The pro of that a a



y Ae y is similar but easier Hence t t xAB e



Case For the equality case again let f t t and e b e arbitrary Supp ose e S and j

k k k k

is such that k j e S t t a a in Ae y It is necessary to show that



t t a a in Ae y Since e S it follows that a a in Ae y typ e

j j 

Both t and t converge to soby Corollary t and t converge to It remains

to showthat a e y a e y Ae y Since AdmA j y S it suces to show that

k k k k k

y a e y Ae y This follows since a a in Ae y k j e S a e

is inhabited for all k j

Lemma AdmxAB j y S ifs S xAB sy typ e and WCoAdmA j y S and

s S a Asy AdmB ax j y S

Pro of

 k

Let f t t and e be arbitrary Supp ose e S and j is such that k j e S

k k k 

t t xAB e y I need to show that t t xAB e y Since

j j

e S it follows that xAB e y typ e Both t and t converge to lambda

  

abstractions so by Corollary t xb and t xb for some terms b and b

  

Supp ose a a Ae y To get that baxb a x B e ayx it suces to show

 

a B e ayx that t a t

Since e S it follows that AdmB ax j y S Therefore it suces to show that for

  k k  k

some j and all k j t a t a B e ay x Since WCoAdm A j y S there exists

   k  

j such that k j a a Ae y Therefore j max j j suces

Lemma

A B is weakly coadmissible for y in S if s S A B sy typ e and A and B are

weakly coadmissible for y in S

WCoAdm xAB j y S if s S xAB sy typ e and WCoAdmA j y S and

s S a Asy WCoAdm B ax j y S

S xAB sy typ e and y SAtyp e and CoAdmAjy S CoAdmxAB jy S ifs

and CoAdmB z z y x j z y SA

Void Atom Z and E are strongly or weakly coadmissible for y in any S

CoAdma a in A j y S ifs S a a in Asy typ e and CoAdmA j y S

a a is strongly or weakly coadmissible for y in any S

A is weakly coadmissible for y in S if s S Asy typ e and A is weakly coadmissible

for y is S

a in A is strongly or weakly coadmissible for y in S if s S a in Asy typ e

Pro of

The pro of is largely similar to the preceding pro ofs but inverted I show the pro ofs for full

coadmissibility of pro ducts and partial typ es



Case For the pro duct case let f t t and e b e arbitrary Supp ose e S j is such that

k 

k j e S andt t xAB e y It is necessary to show that there exists

  k k k k

j such that k j t t xAB e y For any k j xAB e y typ e

 

Both t and t converge to pairs so by compactness there exists some j such that for all

 k k  

k j t and t converge to pairs Thus it suces to showthatforsomej maxj j

 k k k k k k k

and all k j t t Ae y and t t B e t y x I

show the latter the former is similar

k

Rearranging it suces to show equalityinB z z y xhe ti z By coadmis

  k

sibility it suces to show he ti y SA and j k j he ti y SA and



t t B z z y xhe ti z The rst follows from the supp osi

k k

tion and the second will follow from t Ae y and the supp osition Rearranging



the third is suces to show that t t B e y t x which follows

from the supp osition



Case For the partial typ e case let f t t and e be arbitrary Supp ose e S j is

k  

such that k j e S and t t Ae y I need to show that there exists j

 k k k k

such that k j t t Ae y For any k j Ae y typ e Supp ose t do es



not converge Note the nonconstructivity of this argument Then t do es not converge

k k k k k

and neither do es t or t for any k since t t and t t for all k Thus for all

k k k

Ae y k j t t

 

Supp ose t converges Then t t Ae y By coadmissibility there exists j such

 k k k  k k k

t t Ae y Hence k max j j t t that k j y A e

Lemma Predicateadmissibilityandweak and full coadmissibility of case analysis

Pro of

The pro of follows the same lines as those of Lemmas and

Lemma The typ e fx A j B g is admissible if

AdmA and

AdmB j x A and

 

there exists b such that bax B ax whenever a A and b b B ax

Pro of

 k k

Let f t and t b e arbitrary Supp ose j is such that k j t t fx A j B g Since



fx A j B g is inhabited it is a typ e Since AdmA t t A By set memb ership

  k k k

for all k j there exists b suchthatb B t x Thus bt x B t x for all k j

Hence bt x B t xfollows by predicateadmissibility

Lemma Predicateadmissibilityofsettyp es

Pro of

The pro of follows the same lines as Lemma

Lemma Weak and full coadmissibility and monotonicityofsettyp es

Pro of

The pro of follows the same lines as Lemma and Prop osition

Lemma Admissibility predicateadmissibilityweak and full coadmissibility and mono

tonicity of quotienttyp es

Pro of

The pro of follows the same lines as the pro ofs for the set typ e

Theorem There do es not exist an algorithm that computes an integer j suchthat k

 k 

j t t T e x when given S T f t t e and i such that

T sx typ e s S

CoAdmT j x S

e S

k

k i e S



T e x t t

Pro of

Supp ose such an algorithm exists Let g b e an arbitrary term that computes a total function

on integers that is g Z Z Given the algorithm wemay eectively determine whether

g iterated on ever computes which is certainly undecidable Let f h n if n

Z

then else hgx and let h x f Note that f Z Z Z Z and h Z Z By

construction g iterated on computes if and only if h

We will use the algorithm to determine an upp er bound on the number of recursive calls

needed to simulate h Let

S Z

T x in Z

f as ab ove



t t let y h in

e w

i

k k

Observethate h and e f so the rst four preconditions of the algorithm

are satised Moreover CoAdmT j x S can be shown constructively For the nal

precondition supp ose t Then h so t h in Z

j

exactly when Therefore let j b e the result computed by the algorithm Ishow that f

j j

h Since f approximates h it follows that f implies h By the algorithm

j j

j

sp ecication t f in Z If h then tsot f in Z and consequently f

j times

z

 j 

Let h f f f y and observe that f exactly when h Consequently

 

h exactly when h However h is total so we may decide whether h by



running h

Bibliography

Martn Abadi and Luca Cardelli A theory of primitive ob jects Untyp ed and rstorder

systems In Theoretical Aspects of Computer Software volume of Lecture Notes in

Computer Science pages SpringerVerlag April

Martn Abadi and Luca Cardelli ATheory of Objects SpringerVerlag

Martn Abadi Luca Cardelli and Ramesh Viswanathan An interpretation of ob jects

and ob ject typ es In TwentyThird ACM SIGACTSIGPLAN Symposium on Principles

uary of Programming Languages pages St Petersburg Florida Jan

Peter Aczel Frege structures revisited In B Nordstrom and J Smith editors Proceedings

of the Marstrand Workshop

Stuart Allen A nontyp etheoretic denition of MartinLofs typ es In Second IEEE

Symposium on Logic in Computer Science pages Ithaca New York June

Stuart Allen A NonTypeTheoretic Semantics for TypeTheoretic Language PhD dis

sertation Department of Computer Science Cornell University Ithaca New York

Philipp e Audebaud Partial ob jects in the calculus of constructions In Sixth IEEE Sym

posium on Logic in Computer Science pages Amsterdam July

Bruno Barras Samuel Boutin Cristina Cornes Judicael Courant JeanChristophe

Filliatre Eduardo Gimenez Hugo Herb elin Gerard Huet Cesar Munoz Chetan Murthy

Catherine Parent Christine PaulinMohring Amokrane Sabi and Benjamin Werner The

CoqProof Assistant Reference Manual INRIARo cquencourt CNRS and ENS Lyon

David A Basin An environment for automated reasoning ab out partial functions In

Ninth International Conference on Automated Deductionvolume of Lecture Notes in

Computer Science SpringerVerlag

Michael Beeson Recursive mo dels for constructive set theories Annals of Mathematical

Logic

Lars Birkedal and Rob ert Harp er Relational interpretations of recursive typ es in an

op erational setting In Theoretical Aspects of Computer Software

Val BreazuTannen Thierry Co quand Carl A Gunter and Andre Scedrov Inheritance

as implicit co ercion Information and Computation

Kim B Bruce A paradigmatic ob jectoriented programming language Design static

typing and semantics Journal of Functional Programming April

Kim B Bruce Luca Cardelli and Benjamin C Pierce Comparing ob ject enco dings In

Theoretical Aspects of Computer Software Sendai Japan Septemb er

Peter Canning William Co ok Walter Hill John Mitchell and Walter Oltho Fb ounded

quantication for ob jectoriented programming In ConferenceonFunctional Programming

Languages and Computer Architecture pages Septemb er

Luca Cardelli Phase distinctions in typ e theory Unpublished manuscript January

Luca Cardelli Structural subtyping and the notion of power typ e In Fifteenth ACM

SIGACTSIGPLAN Symposium on Principles of Programming Languages pages

San Diego January

Luca Cardelli Typ eful programming In Formal Description of Programming Concepts

SpringerVerlag

RL Constable SF Allen HM Bromley WR Cleaveland JF Cremer RW Harp er

DJ Howe TB Knoblo ck NP Mendler P Panangaden JT Sasaki and SF Smith

Implementing Mathematics with the Nuprl Proof Development System PrenticeHall

Rob ert L Constable Intensional analysis of functions and typ es Technical Rep ort CSR

Department of Computer Science June

Rob ert L Constable Constructive mathematics as a programming logic I Some principles

of theory In Topics in the Theory of Computation volume of Annals of Discrete

Mathematics pages Elsevier Selected pap ers of the International Conference

on Foundations of Computation Theory

Rob ert L Constable Typ e theory as a foundation for computer science In Theoretical

Aspects of Computer Software volume of Lecture Notes in Computer Science

pages Sendai Japan SpringerVerlag

Rob ert L Constable and Karl Crary Computational complexity and induction for partial

computable functions in typ e theory Technical rep ort Department of Computer Science

Cornell University

Rob ert L Constable and Scott Fraser Smith Partial ob jects in constructivetyp e theory

In Second IEEE Symposium on Logic in Computer Science pages Ithaca New

York June

Rob ert L Constable and Scott Fraser Smith Computational foundations of basic recursive

function theory In Third IEEE Symposium on Logic in Computer Science pages

Edinburgh Scotland July

Rob ert L Constable and Daniel R Zlatin The typ e theory of PLCV ACM Transactions

on Programming Languages and Systems January

Thierry Co quand An analysis of Girards paradox In First IEEE Symposium on Logic

in Computer Science pages Cambridge Massachusetts June

Thierry Co quand Metamathematical investigations of a calculus of constructions In

P Odifreddi editor Logic and Computer Science volume of The APIC Series pages

Academic Press

Thierry Co quand and Gerard Huet The calculus of constructions Information and Com

putation

Karl Crary Foundations for the implementation of higherorder subtyping In ACM

SIGPLAN International ConferenceonFunctional Programming pages Amster

dam June

Karl Crary Simple ecient ob ject enco ding using intersection typ es Technical Rep ort

TR Department of Computer Science Cornell University April

N G de Bruijn A survey of the pro ject Automath In J P Seldin and J R Hindley

editors To HB Curry Essays on Combinatory Logic LambdaCalculus and Formalism

pages Academic Press

Michael Dummett Elements of Intuitionism Oxford Logic Guides Clarendon Press

Andrzej Filinski Control ling Eects PhD dissertation Carnegie Mellon University

Scho ol of Computer Science Pittsburgh Pennsylvania May

JeanYves Girard Une extension de linterpretation de Godela lanalyse et son application

alelimination de coupures dans lanalyse et la theorie des typ es In J E Fenstad editor

Proceedings of the Second Scandinavian Logic Symposium pages NorthHolland

Publishing Co

JeanYves Girard Interpretation fonctionel le et elimination des coupures de larithmetique

dordre superieur PhD dissertation UniversiteParis VI I

JeanYves Girard Yves Lafont and Paul Taylor Proofs and T ypes Cambridge University

Press

Michael J Gordon Arthur J Milner and Christopher P Wadsworth Edinburgh LCF

A Mechanised Logic of Computation volume of Lecture Notes in Computer Science

SpringerVerlag

Michael J C Gordon and Tom F Melham Introduction to HOL A Theorem Proving

Environment for HigherOrder Logic Cambridge University Press

Rob ert Harp er Constructing typ e systems over an op erational semantics Journal of

Symbolic Computation

Rob ert Harp er Personal communication

Rob ert Harp er Furio Honsell and A framework for dening logics

Journal of the ACM January

Rob ert Harp er and Mark Lillibridge Explicit p olymorphism and CPS conversion In

Twentieth ACM SIGACTSIGPLAN Symposium on Principles of Programming Lan

guages pages January

Rob ert Harp er and Mark Lillibridge Atyp etheoretic approach to higherorder mo dules

with sharing In TwentyFirst ACM SIGACTSIGPLAN Symposium on Principles of

Programming L anguages pages Portland Oregon January

Rob ert Harp er and John C Mitchell On the typ e structure of Standard ML ACM

Transactions on Programming Languages and Systems April

Rob ert Harp er John C Mitchell and Eugenio Moggi Higherorder mo dules and the

phase distinction In Seventeenth ACM SIGACTSIGPLAN Symposium on Principles of

Programming Languages pages San Francisco January

Rob ert Harp er and Rob ert Pollack Typ e checking with universes Theoretical Computer

Science

Rob ert Harp er and Chris Stone Atyp etheoretic interpretation of Standard ML In Proof

Language and Inter action Essays in Honour of Robin MilnerThe MIT Press To

app ear

Jason J Hickey Formal ob jects in typ e theory using very dep endenttyp es In Foundations

of Object Oriented Languages

Jason J Hickey A semantics of ob jects in typ e theory Unpublished manuscript

W Howard The formulasastyp es notion of construction In J P Seldin and J R

Hindley editors To HB Curry Essays on Combinatory Logic LambdaCalculus and

Formalism pages Academic Press

Douglas J Howe The computational behaviour of Girards paradox In Second IEEE

Symposium on Logic in Computer Science pages Ithaca New York June

Douglas J Howe Equality in lazy computation systems In Fourth IEEE Symposium on

Logic in Computer Science

Douglas J Howe Semantic foundations for emb edding HOL in Nuprl Technical rep ort

Bell Labs

Shigeru Igarashi Admissibility of xedp oint induction in rstorder logic of typ ed theories

Technical Rep ort AIM Computer Science Department Stanford UniversityMay

Paul Jackson The Nuprl Proof Development System Version Department of Com

puter Science Cornell University

Paul Bernard Jackson Enhancing the Nuprl Proof Development System and Applying it

to Computational Abstract Algebra PhD dissertation Department of Computer Science

Cornell University Ithaca New York January

Samuel Kamin Inheritance in Smalltalk A denotational denition In Fifteenth ACM

SIGACTSIGPLAN Symposium on Principles of Programming Languages pages

San Diego January

Christoph Kreitz Formal reasoning ab out communications systems I Technical rep ort

Department of Computer Science Cornell University

John Launchbury and Simon L Peyton Jones State in Haskell Lisp and Symbolic Com

putation Decemb er

Xavier Lero y Unboxed ob jects and p olymorphic typing In Nineteenth ACM SIGACT

SIGPLAN Symposium on Principles of Programming Languages pages

Xavier Leroy Manifest typ es mo dules and separate compilation In TwentyFirst ACM

SIGACTSIGPLAN Symposium on Principles of Programming Languages pages

Portland Oregon January

Xavier Leroy Applicative functors and fully transparent higherorder mo dules In Twenty

Second ACM SIGACTSIGPLAN Symposium on Principles of Programming Languages

San Francisco January

Xavier Leroy The Objective Caml System Release Institut National de Recherche

en Informatique et Automatique INRIA

David MacQueen Using dep endent typ es to express mo dular structure In Thirteenth

ACM SIGACTSIGPLAN Symposium on Principles of Programming Languages pages

St Petersburg Beach Florida January

David B MacQueen and Mads Tofte A semantics for higherorder functors In Fifth

European Symposium on Programmingvolume of Lecture Notes in Computer Science

pages SpringerVerlag

Per MartinLof An intuitionistic theory of typ es Predicative part In Proceedings of the

Logic Col loquium volume of Studies in Logic and the Foundations of Mathematics

pages NorthHolland

Per MartinLof Constructive mathematics and computer programming In Sixth Interna

tional Congress of Logic Methodolo gy and Philosophy of Sciencevolume of Studies in

Logic and the Foundations of Mathematics pages NorthHolland

Paul Francis Mendler Inductive Denition in PhD dissertation Depart

ment of Computer Science Cornell University Ithaca New York Septemb er

Alb ert R Meyer and Mark B Reinhold Typ e is not a typ e In Thirteenth ACM SIGACT

SIGPLAN Symposium on Principles of Programming Languages pages St Pe

tersburg Beach Florida January

Robin Milner Mads Tofte and Rob ert Harp er The Denition of Standard ML The MIT

Press Cambridge Massachusetts

Robin Milner Mads Tofte Rob ert Harp er and David MacQueen The Denition of Stan

dard ML Revised The MIT Press Cambridge Massachusetts

John C Mitchell and Gordon D Plotkin Abstract typ es have existential typ e ACM

Transactions on Programming Languages and Systems July

Eugenio Moggi Notions of computation and monads Information and Computation

Greg Morrisett Compiling with Types PhD dissertation Carnegie Mellon University

Scho ol of Computer Science Pittsburgh Pennsylvania Decemb er

Greg Morrisett Karl Crary Neal Glew and David Walker Stackbased typ ed assembly

es in Compilation March language In Second Workshop on Typ

Greg Morrisett David Walker Karl Crary and Neal Glew From System F to typ ed

assembly language In TwentyFifth ACM SIGACTSIGPLAN Symposium on Principles

of Programming Languages pages San Diego January Extended version

published as Cornell Universitytechnical rep ort TR

Alan Mycroft Polymorphic typ e schemes and recursive denitions In Sixth International

Symposium on Programming number in Lecture Notes in Computer Science pages

SpringerVerlag April

Chris Okasaki Catenable doubleended queues In ACM SIGPLAN International

Conference on Functional Programming pages Amsterdam June

Erik Palmgren An information system interpretation of MartinLofs partial typ e theory

with universes Information and Computation

Erik Palmgren and Viggo Stoltenb ergHansen Domain interpretations of intuitionistic

typ e theory UUDM Rep ort Uppsala University Department of Mathematics

January

Simon L Peyton Jones and Philip Wadler Imp erative functional programming In Twen

tieth ACM SIGACTSIGPLAN Symposium on Principles of Programming Languages

Charleston South Carolina January

Benjamin C Pierce and David N Turner Simple typ etheoretic foundations for ob ject

oriented programming Journal of Functional Programming April

Didier Remy Programming ob jects with MLART An extension to ML with abstract and

record typ es In Theoretical Aspects of Computer Software volume of Lecture

Notes in Computer Science pages Sendai Japan SpringerVerlag

Didier Remy and Jerome Vouillon Ob jective ML A simple ob jectoriented extension of

ML In TwentyFourth ACM SIGACTSIGPLAN Symposium on Principles of Program

ming Languages pages Paris January

The essence of Algol In J W de Bakker and J C van Vliet editors John C Reynolds

Proceedings of the International Symposium on Algorithmic Languages pages

Amsterdam Octob er NorthHolland

Adrian Rezus Semantics of constructive typ e theory Technical Rep ort Informatics

Department Faculty of Science Nijmegen University The Netherlands Septemb er

Dana Scott Outline of a mathematical theory of computation In Fourth Princeton

Conference on Information Sciences and Systems pages

Dana Scott Lattice theoretic mo dels for various typ efree calculi In Fourth International

Congress of Logic Methodology and Philosophy of Science NorthHolland

Dana Scott and Christopher Strachey Toward a mathematical semantics for computer

languages In Proceedings of the Symposium on Computers and Automata volume of

Microwave Research Institute Symposia SeriesPolytechnic Institute of Bro oklyn

Scott F Smith Hybrid partialtotal typ e theory International Journal of Foundations of

Computer Science

Scott Fraser Smith Partial Objects in Type Theory PhD dissertation Department of

Computer Science Cornell University Ithaca New York January

D Tarditi G Morrisett P Cheng C Stone R Harp er and P Lee TIL A typ e

directed optimizing compiler for ML In ACM SIGPLAN ConferenceonProgramming

Language Design and Implementation pages May

Philip Wadler Comprehending monads In Mathematical Structures in Computer Science

volume pages Cambridge University Press

Philip Wadler The essence of functional programming In Nineteenth ACM SIGACT

SIGPLAN Symposium on Principles of Progr amming Languages Albuquerque New Mex

ico January

Alfred North Whitehead and Bertrand Russell Principia Mathematica Cambridge Uni

versity Press nd edition