Syracuse University SURFACE

College of Engineering and Computer Science - Former Departments, Centers, Institutes and College of Engineering and Computer Science Projects

1995

Objects, Interference, and the Yoneda Embedding

Peter W. O'Hearn Syracuse University

Uday S. Reddy University of Illinois at Urbana-Champaign

Follow this and additional works at: https://surface.syr.edu/lcsmith_other

Part of the Programming Languages and Compilers Commons

Recommended Citation O'Hearn, Peter W. and Reddy, Uday S., "Objects, Interference, and the Yoneda Embedding" (1995). College of Engineering and Computer Science - Former Departments, Centers, Institutes and Projects. 14. https://surface.syr.edu/lcsmith_other/14

This Article is brought to you for free and open access by the College of Engineering and Computer Science at SURFACE. It has been accepted for inclusion in College of Engineering and Computer Science - Former Departments, Centers, Institutes and Projects by an authorized administrator of SURFACE. For more information, please contact [email protected].

Electronic Notes in Theoretical Computer Science to app ear

Ob jects Interference and the Yoneda

Emb edding

Peter W OHearn

Syracuse University

Uday S Reddy

University of Il linois at UrbanaChampaign

Dedicated to John C Reynolds in honor of his th birthday

Abstract

We present a new semantics for Algollike languages that combines metho ds from

two prior lines of development

the ob jectbased approach of where the meaning of an imp erative program

is describ ed in terms of sequences of observable actions and

the category approach initiated by Reynolds where the varying na

ture of the runtime stack is explained using from a category of store

shap es to a category of cp os

The semantics gives an account of b oth the phemomena of lo cal state and irre

versibility of state change As an indication of the accuracy obtained we present a

full abstraction result for closed terms of secondorder typ e in a language containing

active expressions ie valuereturning commands

Intro duction

In his inuential Turing award lecture John Backus criticized imp erative

programming languages for promoting a view of programming as wordata

time pro cessing John Reynolds expressed his resp onse to this criticism in

a meeting of IFIP working group in around which he rep eated to

several p eople privately including the second author The view put forward

by Backus Reynolds said is that imp erative programming is like working with

1

Supp orted by NSF grant CCR

2

Supp orted by NSF grant CCR

c

Elsevier Science B V

OHearn and Reddy

pigeon holes All that one do es is to take a pigeon out from a hole or to

put a new pigeon in a hole But with ob jectoriented programming he said

one works with turkey holes rather than pigeon holes Instead of taking out

a pigeon or putting in a pigeon one do es more sophisticated manipulations

such as rotate a turkey or tilt a turkey

The turkey holes that Reynolds sp oke of are what programmers call

ob jects They incorp orate some physical resources such as memory and

provide op erations for the manipulation of these resources Programs are built

by putting such ob jects together and letting them invoke each others op era

tions The state of an ob ject cannot b e manipulated by other ob jects without

the co op eration of the ob ject itself in terms of the op erations it provides

Such an ob jectbased view we nd is implicit throughout Reynoldss work

on imp erative programming

In his seminal pap er on Algollike languages Reynolds treats pro ce

dures not as actions on the global state but as actions on the state at the

p oint of their denitions To elab orate a pro cedure can only access the ob

jects that have b een allo cated when the pro cedure is dened Other ob jects

created after the p oint of denition but b efore the pro cedure is called do not

aect its b ehavior Every pro cedure lives in its own turkey hole so to sp eak

Reynolds also shows how to treat variables pigeon holes as a sp ecial case

of turkey holes ob jects with op erations for setting and reading values stored

in them This essentially frees imp erative programming from the limitations

suggested by Backus and sets up a truly ob jectbased paradigm for thinking

ab out imp erative programs

Reynoldss program for the semantics of imp erative languages was further

develop ed by Oles and Tennent and continued and expanded in

a numb er of works In a separate line of development

a mo del based more explicitly on a notion of ob jects has b een formulated

in Reynoldss conception of imp erative programming expressed ab ove

formed an imp ortant pretheoretic motivation for this work though its theo

retical development also draws inspiration from linear logic syntactic control

of interference and the relation b etween them In this pap er we obtain a new

semantics for Algollike languages via a synthesis of these two lines

the ob jectbased approach of where the meaning of an imp erative

program is describ ed in terms of sequences of observable actions and

the functorcategory approach initiated by Reynolds where the varying

nature of the runtime stack is explained using functors from a category of

store shap es to a category of cp os

In the remainder of this intro ductory section we give an informal overview of

the construction and discuss the sp ecic semantic issues addressed by it

Semantic issues Locality and irreversibility

In imp erative computation there is an idea of destroying information by over

writing parts of computer memory This is clearly imp ortant for implementa

OHearn and Reddy

tion But supplying direct access to assignment in the programming language

also results in p ositive information that programmers make use of Consider

a parameterless pro cedure gensym that returns a dierent integer each time

it is called In reasoning ab out a program using gensym for instance gen

erating fresh names when implementing substitution in calculus we would

use the prop erty that any call to gensym returns an integer that was not

returned by it previously

This prop erty exemplies one of the most basic intuitions ab out state

the general irreversibility of state change By this we mean not only that

p ortions of the store are destructively up dated during the course of a compu

tation but that in the presence of abstraction or lo cal state this irreversibility

manifests itself in observable prop erties of programs

A typical implementation of gensym would use a lo cal integer variable

that is incremented on each call When we say that gensym returns a dierent

integer each time it is called it is crucial that other pro cedures or ob jects

do not access the lo cal state of gensym directly and reset the value to a

previouslyencountered one This statement ab out the gensym pro cedure

implicitly involves interactions b etween the pro cedure and any other pieces

of a program The following co de illustrates the kind of prop erty of such

interactions we have in mind

b egin

integer x

integer pro cedure gensym f x x returnx g

x

P gensym

if gensym then diverge

end

A client pro cedure P is passed a parameterless pro cedure gensym for

generating new names P can use its argument a numb er of times we are

assuming callbyname though the eect can obviously b e simulated in call

byvalue and if it uses its argument at least once then we exp ect that the

whole blo ck will diverge Since the nonlo cal pro cedure P cannot access the

lo cal variable x if x is up dated by calling gensym then pro cedure P has

no way of resetting its value to zero It follows by intuitive reasoning that

this blo ck should have terminationnontermination b ehavior equivalent to

P diverge

This co de is not a realistic program but it is interesting for the reasoning

principle it illustrates Generally when we have an ob ject consisting of some

internal state and observable op erations it is not p ossible for a client program

to cause the internal state of the ob ject to backtrack to previous states This is

b ecause the only changes to the internal state that the client can p ossibly eect

come ab out by using the provided op erations The observable ramications

of irreversibility of state change are inextricably b ound up with lo cality

Irreversibility has proven dicult to capture in semantics b ecause most

mo dels allow for snapback op erations These op erations work by accepting a

OHearn and Reddy

pro cedure as an argument running the pro cedure and then restoring the state

to the value it had b efore the argument was executed this would contradict

the reasoning ab out gensym ab ove The snapback eect requires restoration

of even lo cal state

The phenomenon of irreversibility is not so clear cut in languages that

violate the abstractness of lo cal state such as C or when programming on a

system level where one might want access to the entire computer memory

One could in some instances achieve the eect of snapback by a series of

incremental state changes But on the level of programmable ob jects where

abstraction is central irreversibility is a familiar phenomenon one that arises

in Scheme ML Algol and most ob jectoriented languages

These intertwined notions of irreversibility and lo cality are fundamental

and should b e accounted for by a satisfactory theory of state

Overview of Approach Objects plus Yoneda

The mo del presented here builds up on the work rep orted in where a

semantics is presented based on identifying an imp erative computation with

a stream of observations For example commands are mo delled not as state

tostate functions but as sequences of signals indicating a message to a

command ob ject More accurately a commandincontext C comm

translates demands for output into requests of typ ed entities Similarly

active integers are mo delled using streams of integers where we read a

stream h i as indicating an ob ject with a single op eration that returns the

rst time it is used and the second

There is a view of an active integer as an ob ject p ossessing an internal state

that may change and a metho d for accessing this state But the representation

of the state is nessed in the mathematical description of ob jects given in

state is regarded as implicit in a history of events One b enet of such

a stateless account of state is that it forces lo cality to b e resp ected when

comp osing meanings Since the internal state of an ob ject is not part of

the mathematical description the ways of combining these entities do es not

tamp er with the internal state in the way that early denotational mo dels do

Also there is no explicit state to b e sub ject to a snapback eect though

care is needed to comp ose meanings in a way that resp ects some temp oral

ordering

The work rep orted in formalizes these ideas and results in a mo del

that accounts for lo cality and irreversibility quite well But there is one di

culty in the treatment of state as an implicit attribute it is not easy to give a

satisfactory account of shared state Put another way the ob jects of are

noninterfering and it is not obvious how to deal smo othly with interference

A notion of typ e is dened but it forms a monoidal closed structure

obtained as the adjoint of a noninterfering and noncartesian pro duct

whose comp onents do not interfere As a result the semantics is dened only

for syntactic control of interference a restricted form of calculus

The constraints in this framework disallow interference b etween pro cedure and

OHearn and Reddy

argument or client and ob ject

In order to treat the full typ ed calculus a semantics is called for based

on a cartesian closed category See eg The approach that we use

here is mathematically straightforward We b egin with a category C of ob ject

spaces suitable for the semantics from and simply apply a Yoneda em

op

C

that maps this ob jectbased semantics into a cartesian b edding C Cp o

closed category of certain functors where Cp o is the category of complete

p ointed p osets and continuous functions So for instance where the typ e of

commands is interpreted as an ob ject comm of category C in the functor

category it is interpreted as the functor C comm using the order struc

ture of C Interpretations of rstorder constants are obtained immediately

using the morphism part of the emb edding functor and the fact that Yoneda

preserves pro ducts This is the mathematical side of the story

The computational intuition b ehind this construction is as follows The

op

typ es of the language are mo delled as functors F C Cp o The ob ject part

of such a functor sp ecies a cp o F X of computations for each store shap e

X Recalling that C is the category of ob ject spaces this means that our

store shap es are ob ject spaces whose elements represent ob jects with internal

state Thus a store in our sense is an arbitrary ob ject which might

b e comp osed with various comp onent ob jects such as variables inputoutput

streams windows etc The morphism part of F maps morphisms f Y X

of C to continuous functions F f F X F Y The morphism f Y X

represents a metho d for simulating a store of shap e X using a store of shap e

Y Thus Y may b e thought of as a larger store shap e than X The function

F f then sp ecies the asso ciated conversion of a computation of typ e F X

on the small store to one over the large store F Y These intuitions are

exactly as in Reynoldss functor category semantics for Idealized Algol

The only dierence is that instead of mo delling stores by their state sets we

are mo delling them as ob jects with implicit internal state and observable

b ehavior

To interpret lo cal variable declarations we follow Reynoldss ideas The

meaning of a command new x C at store shap e X is given in terms of the

meaning of C in an enlarged store shap e X var where var is a space interpret

ing a storage variable Note that this interpretation of new do es not follow

from Yoneda emb edding b ecause it semantically corresp onds to a second

order op eration

How do es this approach account for interference Generally sp eaking a

store shap e parameter X provides for a common p oint of interaction for ob jects

in F X This idea represented in the interpretation of higher typ es in the

following way A pro cedure of typ e t t for a store shap e X is a natural

When such a pro cedure is called from transformation from C X F to F

a larger store of shap e Y obtained from allo cation of additional variables we

provide a map f CY X which serves to pro ject the small store X from

Y and an argument a F Y The pro cedures own action on the store is

carried out via the map f which pro jects back to its turkey hole On the

other hand the argument a can act on Y directly The provision of the map

OHearn and Reddy

f which intuitively connects the store shap e at p oint of denition with the

p oint of call is the key ingredient added to the ob jectbased semantics of

It enables a pro cedure and argument to work with the same store shap e and

thus allows interfere by interacting with a common store ob ject A concrete

instance of this phenomenon is shown in Example

It is natural to ask whether we could obtain a similar treatment without

passing to a functor category by expressing the ideas of directly in a

cartesian closed category obtained p erhaps by leaving the framework of co

herent spaces This might b e p ossible if we were to take a concurrent view

of ob jects and accept nondeterminism but the details of such a treatment

are by no means obvious As we explain in section the Yoneda interpreta

tion accounts for interference via a determinate use of interleaving in which

interfering ob jects are interpreted in a shared context of evaluation

Overview of the pap er

After xing the syntax of a sample programming language Sec and

reviewing the relevant details of ob ject spaces Sec we present the mo del

obtained by the Yoneda emb edding in Sec In Sections and we analyze

the accuracy of the mo del arriving at the following technical results

We give explicit representations of rstorder typ es and show that all natu

ral transformations b etween pro ducts of base typ es are least upp er b ounds

of denable elements The language used for denability is an Algollike

language containing active expressions ie valuereturning commands

We give a full abstraction result for closed terms of secondorder typ e

In App endix A we also include a short discussion of ob jects with internal

state which motivates the technical denitions concerning ob ject spaces This

discussion is not used in the main b o dy of the pap er except for motivational

purp oses

We assume the readers familiarity with the theory of complete partial

orders The text also has a discussion of dIdomains and stable

functions which we mention in passing Coherent spaces form a particularly

simple class of dIdomains which we make use of in our techincal results ex

tensively Discussion of coherent spaces may b e found in as well as the

pap ers where they are applied to semantics of linear logic and ob ject

spaces resp ectively The semantics texts ab ove also contain an intro ductory

treatment of cartesian closed categories and basic denitions concerning func

tors and adjunctions Additional discussion of categorical concepts can b e

found in and standard texts such as

Syntax

We consider a language with the following base typ es

comm the typ e of commands and

aint the typ e of active integer expressions active integers for short

OHearn and Reddy

By active expressions we mean computations that p otentially cause state

changes and return values We form other typ es using binary pro duct and

function space We follow Reynolds and regard a typ e var of storage vari

ables as sugar for aint comm aint Dereferencing is second pro jection

and assignment is accomplished with the rst pro jection and pro cedure call

For instance x x desugars as xsucc x

1 2

The typ e system is that of simplytyp ed calculus with binary pro ducts

The constants are as follows

succ pred aint aint Y t t t

t

ifz aint b b b aint

new var comm comm skip comm

letval b b b b

where b b range over base typ es and t over typ es We can also consider a

version of new that taken an integerreturning pro cedure and pro duces an

integer

The arithmetic constants are just those of sequential PCF For commands

we have constants for lo cal creation and a form of sequential comp osition

letval The phrase letval M y N evaluates M binds the value obtained

to y and then executes N In case M is a command y is b ound to skip

after the execution of M The key p oint here is that the execution of M

can change the state but subsequent uses of y do not Also the sideeect

of M is p ersistent and not a snapback We use notation C C as sugar for

letval C xC where x not free in C or C This is for any combination of

base typ es for C and C When C is a command and C an integer this gives

us a sideeecting or active integer

In our very bare sample language there is no inputoutput or global vari

ables for programs to act up on Storage variables are created using new as

in new xC This creates a lo cal variable x initialized to that may b e

up dated within C recall the sugaring of assignment ab ove but this storage

variable is deallo cated on blo ck exit As a result a closed term of typ e comm

do es not change the state at all it must b e equivalent to Y xx or skip

But even for this bare language there are many interesting examples that

illustrate principles of imp erative computation

Example The gensym example from the Intro duction is represented as

OHearn and Reddy

the following term

new x

gensym

letval x dd

1

letval P gensym dd

ifzhpredgensym skip Y x xi

letval xsucc x y x

1 2 2

where are pro jections For obvious reasons we will use a sugared syntax

i

when the desugaring is clear

Remark Since expressions in this language are active typical prop erties

such as commutativity of addition are lost It is p ossible to add a typ e int of

passive sideeectfree expressions and our semantic approach can handle

these quite well But we have not obtained denability and full abstraction

results in the presence of passivity Among other things the old problems with

sequential functions reapp ear

Remark Active expressions are not necessary to raise the problem of

irreversibility For example we can just use the command typ e as in the

blo ck

b egin

integer x

x

P x x

if x then diverge

end

with P comm comm This blo ck is equivalent in our language to

P diverge ie has the same terminationnontermination b ehavior in all

contexts In a language with IO or jumps these terms would b e inequivalent

Then irreversibility would b e exemplied not by a pure equivalence but as a

more complex prop erty such as equivalence of termination b ehaviour under

the precondition that P do es not p erform a jump

A Category of Ob ject Spaces

In this section we will dene the category of p ossible worlds based on the

free ob ject spaces of

Denition Let A jAj be a coherent space ie a reexive and

A

symmetric binary relation on a countable jAj The free ob ject

A

space yA associated with A is the coherent space where jyAj jAj is the set

of nite sequences of tokens in jAj and a a b b i

1 n 1 m

yA

i f minn mg a a b b a b

1 i1 1 i1 i i

OHearn and Reddy

The intuition in this denition is that tokens in yA are sequentialized

One may think of a sequence a a as representing a series of observations

1 n

made on an ob ject The coherence relation indicates when it is consis

yA

tent to regard two traces as arising from the same computational ob ject see

Example b elow Further motivation for the denition based on a discus

sion relating to ob jects and automata may b e found in App endix A A fuller

treatment is in An intro ductory account of coherent spaces and linear

maps can also b e found in that pap er as well as in the original sources

Letters X Y W will b e used to range over the free spaces yA We will

often consider X jyAj as a monoid with unit empty sequence and mul

X

tiplication concatenation written simply by juxtap osition x x x x will

1 2 1 n

typically denote a multiplication where each x is a sequence while a a

i 1 n

denotes a sequence of tokens a We write sequences as hai when

i

necessary for disambiguation

A regular map f X Y of ob ject spaces constructs a Y ob ject from an

X ob ject by simulating the op erations of the Y ob ject on the given X ob ject

Generally f will b e given by a relation f jX j jY j with elements written

as x y Note that x and y are themselves sequences here A pair x y

signies that the Y op eration y is simulated by carrying out the op eration x

on an X ob ject Now we think of x y x y x y as indicating

that x and y p ossess the same input information cf App endix A and we

require that the input part of y determine the input part of x ie

y y x x

Secondly the output part of x together with the input part of y must deter

mine the output part of y ie

x x y y

These are standard conditions for linear functions To these we add conditions

concerning the preservation of monoid structure

Denition A regular map f X Y is a relation f jX j jY j such

that for al l x y x y f

1 1 2 2

i x x y y and

1 2 1 2

ii y y x x

1 2 1 2

satisfying

iii f

X Y

iv x y x y f x x y y f and

1 1 2 2 1 2 1 2

v x y y x x x x x x y x y f

1 2 1 2 1 2 1 1 2 2

The condition ii can also b e written as x x y y x x

1 2 1 2 1 2

The conditions iiiv in the denition state that regular maps are state

indep endent or historyfree For example the condition iv means that

if x y f signifying that an action y is simulated by x then this

2 2 2 2

simulation can always b e tacked on later on top of another simulation

Even though our programming language is imp erative a form of history

freeness is appropriate in global maps b ecause these corresp ond to denotations

OHearn and Reddy

of closed terms In a language ob eying the stack discipline state is securely

encapsulated in lo cal declarations new xC so the closed terms themselves

are eectively stateless This viewp oint on global maps is also found in the

p ossible world mo dels

Denition The category Ob of free ob ject spaces has as objects the

spaces y A The morphisms are regular maps with relational composition

We can order the homsets of this category using the inclusion order of rela

tions this order corresp onds to the stable order

Commands are mo delled using the space y where where is the one

token coherent space The idea is that a command corresp onds to an ob ject

with one op eration which when invoked simply runs the command We write

comm for y

Active integers are mo delled using yint where int is the discrete coherent

space of nonnegative integers with the equality relation as Since any

int

two integer tokens are inconsistent all the tokens have the same input part

So We write aint for y int

The opp osite of int plays an input role in this category The coherent

space int has the same tokens as int but all the tokens are considered con

sistent We regard the information of a token as purely input Intuitively an

ob ject for yint is an integer acceptor that accepts an integer and uses it

to p otentially alter its internal state We write acc for y int

Remark Given an ob ject space yA let x y denote the prex relation

z xz y It follows from Denition that x y whenever x y In

particular x for all x An object behavior is a subset L jX j that is

prexclosed x y y L x L and pairwiseconsistent For example

the ob ject b ehavior for gensym is the set of initial sequences n jaintj

Thus ob ject spaces form an instance of Winskels event structures Ob ject

b ehaviors form a dIdomain under the inclusion ordering A regular map

f X Y determines a function f from ob ject b ehaviors of X to ob ject

b ehaviors of Y

f L f y jY j x L x y f g

Such a function is stable continuous and preserves consistent glbs and linear

preserves all the lubs that exist

The free ob ject space construction extends to a functor y CohL Ob

from the category of coherent spaces and linear maps to the category of ob ject

spaces We use the standard convention of writing linear maps as f A B

The morphism part of y sends a linear map f A B to

yf f a a b b a b f i n g

1 n 1 n i i

This functor is the right adjoint to the forgetful functor U Ob CohL

CohLU X A ObX yA

If f UX A is a linear map the corresp onding regular map f X yA is

f f x x a a x a f i n g

1 n 1 n i i

OHearn and Reddy

We often use this formula to dene regular maps f simply by giving the

corresp onding linear maps f Note that the adjunction gives a comonad

U y on coherent spaces which we write as y or simply y

L

The category Ob has nite pro ducts Recall rst the denition of categor

ical pro duct in the category CohL of coherent spaces and linear maps

AB jAj jB j with

A&B

a a a a

A&B A

b b b b

A&B B

a b always

A&B

The pro duct y A y A of ob ject spaces is yA A This is immediate from

1 2 1 2

the fact that y is a right adjoint The pro jections are

f ia ia a a a jA j k n g

i 1 n 1 n k i

For pairing if f yC y A then hf f i y C yA A is

i i 1 2 1 2

hf f i f x x i a i a x a f i f g k n g

1 2 1 n 1 1 n n k k i k

k

The terminal ob ject in Ob is I yemp where emp is the empty coherent

space The unique map X I is f g

X X I

To mo del storage variables we use var acc aint y int int In

tuitively an ob ject for this space has an op eration of typ e acc for setting its

value and an op eration of typ e aint for reading the value We regard the

tokens of var as strings over f put i i jint j g f get i i jint j g for

mnemonic value

The ob ject b ehavior cf Remark cel l jvarj consists of those se

quences t satisfying

t get i get i i i

t put i get i i i

t get i i

This ob ject b ehavior mo dels a declared storage variable with initial value

Example The coherence relation is meant to indicate consistency

yA

of observed b ehaviors To illustrate this consider the case A var where

we regard put i tokens as input and get i tokens as output Two sequences

a a a a and a a a a are coherent i a and a

1 n n+1 n+2 1 n n+1

n+1 n+2 n+1

are coherent The interesting case is when a a If these are output to

n+1

n+1

kens get i and get j then the sequences are incoherent b ecause i and j indicate

dierent or inconsistent output observations notice the implicit determinacy

assumption For coherence if a a then one must b e a put j token

n+1

n+1

There is no inconsistency b etween an input action put j and any other action

b ecause we do not immediately observe the internal result of the input

action Notice that there is no relationship b etween a and a

n+2

n+2

For example consider two sequences put get and put get The

sequences dier coherently in the rst p osition and so are deemed coherent

OHearn and Reddy

n

zero I aint f hi n g

I

succ aint aint f i i i i

1 n 1 n

n i jint j g

k

pred aint aint f i i i i

1 n 1 n

n i g

k

n

skip I comm f hi n g

I

n n

seq comm comm comm f hi n g

deref var aint f get i get i i i n i jint j g

1 n 1 n

k

n

assign var aint comm fi puti i puti hi n i jint j g

1 1 n n

k

a i B cond aint yA yA yA f i B a a a

1 n i X 1 i n 1 n

n

1

n i jint j a jAj g

k k

Table Examples of regular maps

even though they are incoherent in the second p osition This is reasonable

b ecause we could certainly conceive of the following ob ject when given a

put it changes its state to when given a put it changes its state to and

when a get request is issued it simply returns the value of its internal state

So it is logically consistent to regard the two sequences as arising from the

same ob ject This is why is dened so that sequences must b e coherent

yA

only at the rst place they dier With dierent changes of state such as

in put and put there is no inconsistency in having completely unrelated

subsequent observations

Example Some examples of regular maps are given in Table The

notation B a in the denition of cond means a if i and a otherwise

i X

Each of these maps may b e understo o d as a simulation of the op erations of

one typ e on ob jects of another typ e For example the map seq simulates

the unique op eration of a command ob ject comm on an ob ject with two

command op erations

By virtue of isomorphism many of the maps in Example are

uniquely determined by linear maps of coherent spaces for instance

seq y f g

0

We sum up some of this discussion for the record

Lemma The category Ob has nite products The forgetful functor U

Ob CohL has a right adjoint y

OHearn and Reddy

Remark The induced comonad y on CohL do es not satisfy the isomor

L

phism y A y B y AB characteristic of in linear logic The

L L L

reason is that y interleaves tokens from AB and the order of interleaving

L

is imp ortant

Remark The category Ob is the category of free coalgebras for y which

L

is equivalent to the Kleisli category of y The denition of ob ject spaces in

L

is more general b ecause it uses coalgebras other than the free ones This is

needed for closure under tensor pro ducts and for the treatment of passivity

But for the example programming language considered here the free coalgebras

suce

Finally we note an imp ortant prop erty of the space aint of active integers

it is a generator for the category Ob in the following ordered sense

Lemma For maps f g X Y in Ob

f v g e aint X e f v e g

Pro of The direction is trivial Conversely supp ose x y is a pair in f

that is not in g where x a a We want to nd a map e aint X

1 n

such that e f v e g Treat a as a function f ng jX j If i i

1 k

f ng is a string write a for a a Let e yint X b e the regular

i i

1

k

map f a f ng g To see that this is indeed a regular map

note that two strings and are consistent in yint i one of them say is a

prex of the other In that case a a and we have a a If in

addition a a then and must b e p ermutations of each other Since

is a prex of this means The other conditions of regular maps can

b e veried easily Now n y is a pair in e f but not in e g 2

This prop erty will play a key role in connecting the mo del to the programming

language with the typ e aint used to generate distinguishing contexts

Interference via Yoneda

The category Ob has a categorical pro duct for mo delling in our program

ming language But it do es not have exp onentials with a natural isomorphism

Ob X Y Z Intuitively the problem is that a regular ObX Y Z

map f X Y Z is a simulation using an X Y ob ject ie an ob ject

with X and Y op erations on some shared state The currying transformation

would require us to separate the X and Y parts of the X Y ob ject But

they are not separable as they act on shared state

To obtain the required interpretation we emb ed this semantics together

with its treatment of rstorder maps in Table into a Cartesian closed cat

egory of functors using a Yoneda emb edding Thus we interpret comm as

Ob comm and aint as Ob aint and the function typ e using the functor

category exp onent The computational intuition underlying this reinterpre

tation is the following We now regard an Algol command as a regular map

W comm where the role of W is something like that of the store parameter

in traditional A map W comm is the simulation

OHearn and Reddy

of a command in a W typ ed store All Algol typ es are similarly parameter

ized by W s and this allows interference or sharing to b e accounted for by

considering meanings dep endent on the same parameter W

Domains Functors and the Yoneda Embedding

We will b e working with an enriched version of the Yoneda emb edding see

for enriched notions We use Cp o to denote the category of complete

p ointed p osets and continuous functions and Cp o for the sub category of

strict functions We refer to the ob jects simply as cp os

Supp ose C is a small Cp oenriched category This means that each hom

set CX Y comes equipp ed with a cp o structure and that comp osition is

continuous with resp ect to this structure Cp o itself has the obvious enriched

op op

structure We can then lo ok at enriched functors C Cp o where C

uses the same ordering as C In this case enriched functors are simply ordi

op

nary functors whose action on the hom sets C X Y Cp oF X FY is

continuous

Denition Given a smal l Cp o enriched category C the category M is

C

dened as fol lows

op

Objects Cp oenriched functors F C Cp o that factor through the

inclusion functor Cp o Cp o

Morphisms Al l natural transformations of such functors

The factoring condition is from

The category M contains a copy of C For any ob ject X of C there is

C

op

a functor C X C Cp o whose action is to send

an ob ject Y to the cp o CY X and

an arrow f Y Y to the g f g CY X

CY X

The functor C X lives in M and represents the ob ject X in M

C C

Lemma C X is an object of M

C

Pro of C X g f g is clearly continuous in f Thus C X is an

enriched functor Since Cf X is strict in f it factors through the inclusion

Cp o Cp o 2

op

Lemma Yoneda Lemma For any functor F C Cp o NatC X F

F X where the set of natural transformations on the left is ordered pointwise

Pro of This is a standard Yoneda Lemma argument Given C X F

id is an element of F X and this element uniquely determines by the

X X

naturality condition Moreover v implies id v id Hence we

X X X

X

have an order isomorphism 2

It follows that the functor Yon C M given by YonX C X is a full

C

and faithful emb edding taking F C X in the Yoneda Lemma we obtain

NatC X C X CX X It is also noteworthy that the emb edding

OHearn and Reddy

x t u ux

X

x M s t uY f a M f ux a

X Y

MN t u M uX id N u

X X X X

M N t t u M u N u

1 2 X X X

M t u M u

i i X i X

Table Interpretation of a typ ed lamb da calculus

YonX YonY preserves all the existing pro ducts in C YonX Y

This follows from a basic prop erty of categorical pro ducts viz C X Y

C X C Y

A second fact of interest is that we can interpret typ ed calculus and

recursion in M

C

Lemma M is Cartesian closed I It has a least xedpoint

C

combinator Y A A A for each functor A in M

A C

Pro ducts in M are dened p ointwise as is usual in functor categories The

C

exp onent is dened with the help of the Yoneda lemma On Cob jects

F GX NatC X F G ordered p ointwise

and on morphisms when f Y X

F Gf p Y g Y Y a pY g f a

Fixedp oints are given by dening Y X p to b e the least xedp oint of

A

apX id a AX AX

X

Y satises typical uniformity criteria for xedp oints such as dinaturality

See eg for the uniformity criterion

To indicate how the interpretation go es we show in Table the semantics

of a typ ed lamb da calculus in M The meaning of a term in typing context

C

M t is a natural family in X of continuous functions X

tX We also use the abbreviated notation M when the typing judgement

is clear from context If is the typing context x s x s then we

1 1 n n

regard X as the cp o of environments fx a x a g where

1 1 n n

each a s X

i i

Remark The role of the functor C X in F GX is just as in

standard functorcategory semantics except that its order structure is also

taken into account This will allow certain of these hom functors to play a

double role used for quantication over contexts and for interpreting base

typ es in the programming language See Lemma for where this is used

Remark Oles used the strictness condition on functors in order to obtain

Cartesian closure With hindsight we can see this condition arising in another

op

C

way The category Cp o is symmetric monoidal closed and there is an

OHearn and Reddy

op op

C C

endofunctor Cp o Cp o obtained by comp osing on the

right with lifting that has a comonad structure M is equivalent to the

C

Kleisli category of Thus Oless strictness condition arises naturally if we

take Cp o together with the lifting comonad as fundamental and lo ok for a

mo del of intuitionistic linear logic based on functors into Cp o rather than

lo oking directly for a mo del of intuitionistic logic cf

Semantic Model

The semantics is given in M For the typ es dene

Ob

comm Ob comm

aint Ob aint

s t s t

s t s t

The dened typ e var gets the interpretation

var aint comm aint

Variables of this kind Algol variables can b e more complicated than variable

ob jectsinstorecontexts but note that the latter can b e easily turned into Al

gol variables Sp ecically there is a natural injection Ob var var

dened by X v a r where

aY f e hf v ei assign

r v deref

The data assign and deref may b e found in Table

The interpretations of rstorder constants are obtained from the maps

in Table by the Yoneda emb edding For instance ifz is interpreted by the

comp osite map iso Ob cond where iso is the appropriate isomorphism

b

iso

-

Ob aint Ob b Ob b Ob aint b b

All that is left is to interpret new and letval

To interpret letval we dene a map letval b b b b which is

determined uniquely by the following prop erty x hai letvalX p q i

x x jX j x x x

1 2 1 2

n jbj x hni p x hai q X id k

1 2 X n

By fo cusing on a single output token hai we are essentially using the Kleisli

representation of regular maps The idea is that we evaluate the argument p

consuming x from the statecontext and then we consume x while pro ducing

1 2

a k ObX aint is the evident constantlyn active integer the unique

n

map containing e n in the case that b aint and it is the constantly

X

command skip if b comm Sending k as an argument to q shows how

n

further evaluations of this argument always yield the same integer or command

action

OHearn and Reddy

For the semantics of new we need a map

new var comm comm

For every pro cedure p var commX newX p must b e a regular

map X comm There are two main parts to obtaining such a amap newX

must call p in an enlarged store typ e X where there is an additional variable

v var X This gives a command p X comm Second newX must

convert p to a command X comm by supplying it with an appropriate

enlarged store of typ e X

The rst part is done by taking the space X X var and calling p with

the variable obtained from the second pro jection X var var

2

p pX var X var X var comm

1 2

where Ob var var is the emb edding dened earlier For the second

part of converting p to X comm dene newX p as the unique regular map

including the following pairs

f x x hi s s cel l x s x s x hi p g

0 k 1 k 0 1 1 k k

Again this is the Kleisli representation which by the adjunction U a y

determines the map completely We are using the monoid multiplication jux

tap osition here so for example some of the sequences x may well b e empty

i

The idea of this denition is that the uses s of the lo cal variable are simply

i

ignored at the nonlo cal level Note that while we can convert commands

X var comm to X comm we do not have a corresp onding regular map

X X var Indeed since regular maps are historyfree they cannot create

new ob jects

This completes the denition of the mo del

Example Consider the application map app aint aint aint

aint On the level of functor categories the denition is app X p a

pX id a On the level of ob jectspaces the eect is as follows Applying

X

the Yoneda lemma a numb er of times we nd that this application map

determines a continuous function

aint aint aintX aintX

ObX aint aint Ob X aint Ob X aint

The induced function takes a pair p f of maps and pro duces a regular map

X aint

hid f i

p

- -

X X aint aint

This comp osite is the unique regular map containing the following pairs

x y x y x hai whenever there is k k jaintj such that

0 1 1 n n 1 n

y hk i f x k x k x hai p

i i 0 1 1 n n

This is the form of sharing or interference that we obtain by placing ob jects

into the same context the common context here b eing X The x and y in

i j

x y x y x represent interleaved uses of X by p and f Thus the Yoneda

0 1 1 n n

emb edding leads not only to a treatment of function typ es that is technically

OHearn and Reddy

correct but an implementation of sharing that is intuitively reasonable and

which has proven dicult to come by otherwise

op

Remark It is p erhaps surprising that a category C can b e used as

the category of worlds where C is a category of functions In previous work

the categories of worlds typically involved morphisms that were

more than even opp osites of functions they were pairs of functions one

for deallo cation of storage variables and one for overwriting small pieces

of large states In an explicitstate setup when mo delling commands as

statetostate functions b oth the co and contravariant roles of state need

to b e accounted for in order to get a functor of command meanings The

op

completely contravariant account given here via C using only deallo cations

Weakenings to interpret declarations is p ossible b ecause of the demand

driven nature of the treatment of commands in

Firstorder denability

We know that the spaces Nats t of natural transformations are cp os but

to study denability in the mo del we need more information on their structure

In this section we use the Yoneda lemma to calculate the structure precisely

by showing that for base typ es s and t these cp os are algebraic In fact we

show much more each of these cp os is isomorphic to the set of p oints of a

coherent space

Given this characterization we move on to show that every nite element

in these domains is denable by a closed term in the programming language

By algebraicity every element is then the lub of denable ones Standard

ccc manipulations allow us to obtain an analogous result for all global el

ements I t where t is an arbitrary rstorder typ e The order of a

typ e is dened inductively orderaint ordercomm orders t

maxorders order t and orders t maxorders ordert

Lemma Suppose b b b are base types Then

1 n

Natb b b

1 n

with pointwise order is isomorphic to a coherent space

In the statement of the lemma and throughout we confuse a coherent space

with the cp o of its p oints ordered by inclusion

Pro of Let A and B b e the coherence spaces used in the interpretations of

i

b and b int in the case of aint in the case of comm Let us calculate

i

Nat b b b

1 n

Nat Ob yA Ob yA Ob yB denition

1 n

Nat Ob yA yA Ob yB Yoneda preserves

1 n

ObyA yA yB Yoneda lemma

1 n

ObyA A yB denition of

1 n

CohLy A A B U a y y U y

L 1 n L

OHearn and Reddy

2

Prop osition Given base types b b and b any nite element in

1 n

Natb b b is denable by a termincontext

1 n

x b x b Q b

1 1 n n

Pro of We use the representation in terms of yA A B and con

1 n

sider tokens of A A as of the form ia for i n the i indicating

1 n

the comp onent Let f b e a nite linear map Dene the size of f to b e the

numb er of tokens of A A and B in its trace The pro of is by induction

1 n

on the size of f There are three cases

f Then Q some divergent term of typ e b

a f Coherence of f implies that f f ag If b is comm

a

let Q skip If b is aint then let Q succ

ias b f Coherence of f means that if i a s b f then

i i Supp ose that b is aint Let z b e the collection of those a where

i

ia s b f for some s b Since f is nite z is nite For each a z

0 0

is denable by a fs b ia s b xg By induction f let f

a a

0

Let k k b e an enumeration of z Note that z is not empty term M

1 n a

Then f is denable by the following term using evident notation for if where

x aint is the identier corresp onding to b

i i

letval x m aint

i

if m k then M

1 k

1

else if m k then M

2 k

2

else if m k then M

n k

n

else

If b is comm the pro of is simpler 2

i

Notice that there is a form of sequentiality at work in case of the pro of

Coherence of a nite element f means that if i a s b f and i as

b f then i i This corresp onds to the intuition that the ith comp onent

is queried rst by f which is why we are accounting prop erly for sequential

facilities at rst order The active nature of the arguments is crucial here as

this kind of account of sequentiality do esnt adapt to PCFstyle computation

Corollary For any rstorder type t NatI t is isomorphic to a coher

ent space each of whose nite elements is denable by a closed term Q t

Pro of From the prop osition using standard syntactic versions of ccc ma

nipulations involving currying pairing and the cartesian isomorphism A

A B A C 2 B C

Example Closed terms of typ e comm comm are interpreted as ele

ments of NatI comm comm Let us calculate this hom set using the

OHearn and Reddy

argument in the pro of of lemma

Nat I comm comm

Nat comm comm enriched ccc isomorphism

Nat Ob y Ob yB denition

Oby y Yoneda lemma

CohLy U a y y U y

L L

N calculation

where N is the at natural numb ers see Each n N corresp onds

n 0

to a Church numeral cc of typ e comm comm where c skip and

i+1 i

c c c The least element this typ e is the divergent command Ycc

Thus every element in the hom set NatI comm comm is denable

This representation of NatI comm comm should b e compared

op

to where the corresp onding representation yields N Vnat with

op

Vnat the upsidedown vertical natural numb ers and the smash pro duct

op

The Vnat comp onent has entirely to do with snapback op erations which in

this case lead to a more complex domain

A Full Abstraction Result

In reasoning ab out secondorder terms we need to consider the denotations

of rstorder typ es at various p ossible worlds and not only global elements

I t for rstorder t Syntactically this corresp onds to the fact that the

context lemma do es not hold in our example language one needs more

than closed applicative contexts to distinguish closed terms of functional typ e

Semantically it corresp onds to the fact that the category is not well p ointed

to distinguish parallel maps f g s t it is not enough to comp ose on the

left with maps I s out of the terminal ob ject So the denability result of

the previous section do es not immediately give us full abstraction for closed

terms of second order

To get full abstraction at second order we rst show that for the ap

propriate typ es dierent natural transformations can b e distinguished at the

p ossible world aint This then enables us to use the programming language

typ e aint together with new to build distinguishing contexts It suces to

consider applicative contexts with a single free identier of typ e aint wrapp ed

in the scop e of a new variable declaration used to generate an active integer

to bind to this free identier

Lemma v s t t aint v aint for order types

t s t

Pro of The direction is trivial Supp ose v Then for some X

0

using a representation of X v X ObX A A ObX A

s t t

the typ es calculated as in Lemma Consider f Ob X A A where

s t

X f v X f By Lemma there exists a map e aint X such that

OHearn and Reddy

e X f v e X f Naturality of and with resp ect to e then implies that

ainte id f v ainte id f and we are done 2

Next we want a denability result ab out rstorder typ es instantiated at

world aint

Lemma For order types s and t s tX is isomorphic to a coherent

space Further each nite element of s taint is denable in an evident

sense by a termincontext y aint M s t

The term M determines an element of s taint using the isomorphism

Nataint s t s taint

This is where Ob aint is playing a double role used in the denition of

s taint and as the interpretation of aint in Nataint s t

Pro of We can calculate the domain explicitly using a Yoneda lemma argu

ment again as in Lemma

s tX

NatOb X s t denition

ObX yA yA as b efore

CohL U X yA A by

This gives the rst part of the lemma

In the case that X aint yint we use the denition of pro duct in Ob

to obtain the representation

CohLy int A A

L

Once again A and A are the coherent spaces used in the interpretation of s

and t p ossibly applying pro ductpreservation of y

To dene the nite elements of this domain recall that we have seen that it

is isomorphic as a cp o to the space of natural transformations Nataint s

t and we have already shown that these nite elements are denable by

termsincontext

y aint x s Q t

The desired termincontext

y aint Q s t

denes the corresp onding nite element of s taint 2

Theorem Inequational Full Abstraction

If M t t t t and N t t t t are closed

1 n 1 n

terms of secondorder type then

M v N C C M v C N

Here C ranges over ground contexts

Pro of Only the direction needs to b e proven Supp ose M v N We

will construct a commandtyp ed context C where C M v C N

OHearn and Reddy

Since M and N are closed terms they determine natural transformations

t t t t Using Lemma Lemma algebraicity of

1 n

t t taint and continuity we may calculate

1 n

M v N

M aint v N aint

nite d t t taint M aint d v N aint d

1 n

By Lemma there is y aint Q t t t that denes d

1 n

We do the rest of the pro of for the case of t aint comm b eing easier

Given such a d we know that the trace sets of M aint d and N aint d in

commaint CohLy int int are such that M aint d N aint d

say s m M aint d and s m N aint d We construct a termin

context x var c aint as follows If s k k then c is the term

1 n

x x if x then k

1

else if x then k

2

else if x n then k

n

else

Here recall that we are using a sequencing combinator C E as sugar for

letval C z E where z is not free in C or E If s then c is it

do esnt matter what c is in this case

With this c and Q a context distinguishing M and N is

new xx

if y aint Qc m then skip else

where we test for equality explicitly in if which can b e programmed using ifz

and other constants 2

We have formulated the full abstraction result for secondorder functions

that take a single rstorder function as an argument It should b e clear from

the form of the pro of that the argument works for all secondorder typ es We

dont know if the result can b e extended to higher typ es

Example We illustrate the semantics for the example from the Intro

duction First we have a regular map gensym var aint that builds the

b ehavior of gensym by simulating its output in terms of vartyp ed actions

gensym is given by

f get i put i get j get i put i get j j j

1 1 1 n n n 1 n

i j jint j g

k k

As mentioned in Remark the regular map determines a function from

ob ject b ehaviors of var to those of aint In particular when applied to the

b ehavior cel l jvarj the function gives an ob ject b ehavior f h ni n

jintj g of typ e aint This corresp onds to how gensym is dened in terms of a

declared variable

OHearn and Reddy

The meaning of the blo ck

b egin

integer x

integer pro cedure gensym f x x returnx g

x

P gensym

if gensym then diverge

end

is a natural transformation of typ e aint comm comm Its

action at a p ossible world W is a continuous function

NatOb W aint comm Ob W comm

which using a Yoneda lemma calculation reduces to a continuous function

f ObW aint comm ObW comm The action of f on a regular map

p W aint comm may b e calculated as the following map

f w w t cel l t jvarj i jint j s s jaintj

1 n 1 n

t hput it hget i put i get i i i

t s s gensym

1 n

w s w s p g

1 1 n n

For clarity we have shown a linear map of typ e W The corresp onding

regular map W comm is obtained by iterating this b ehavior The se

quence t denotes the op erations p erformed on the variable x Given that the

nal value of x must b e no greater than the sequences t and s s can

1 n

only b e empty Thus the linear map is equal to

f w w p g

It is clear that the meaning of P diverge maps p to precisely the same regular

map

We must admit that the reasoning in this example is rather technical

Nevertheless it illustrates an interesting feature of the ob jectbased semantics

After applying a Yoneda lemma argument we see that the denotation of

pro cedure P is a regular function W aint comm with W corresp onding

to the context of evaluation and aint to the argument The semantics in this

case works by communication b etween the pro cedure P and the lo cal blo ck

Where P exp ects an argument of typ e aint the blo ck simulates the argument

in terms of the vartyp ed b ehavior cel l The interesting p oint is that the

domain W aint for P do es not mention the space var corresp onding to lo cal

variable x at all or for that matter any other typ e that may b e used in a

simulation of the aint argument This corresp onds to the intuition that any

meaning for pro cedure P is dened without reference to the lo cal variable

OHearn and Reddy

Related Work

Although there has b een a go o d deal of theoretical work on the foundations of

ob jectoriented programming most of it has concentrated on typing issues in

a purelyfunctional context see for example and so b ears little relation

to our work For us the initial conception of ob ject involves at least a hidden

lo cal state together with op erations acting up on it

Much closer to our concerns is work on translating ob jects into pro cess

calculi eg In this approach an ob ject is treated as a pro cess of

a certain form with the state implicit in the history of events this asp ect

is clearly related in pretheoretic conception to the approach of But

the results and details are dicult to compare Here the fo cus has b een on

denotational metho ds and examining the connection full abstraction with

an example programming language In comparison the pro cess approach can

b e thought of as b eing broader handling more features but as far as we are

aware no analysis indicating the accuracy of the resultant enco dings has yet

b een given

Closer still to our concerns is a variety of applications and extensions of

functor category semantics One of these is the work of Pitts and Stark on

dynamic allo cation where a language is considered in which mere equality

of names is the basic op eration b esides lo cal allo cation they obtain a full

abstraction result for rstorder typ es Equality of names or lo cations do es

not t so easily into the ob jectbased mo dels which follow Reynoldss lead

in taking a lo cationfree view of state It do es not app ear that the

phenomenon of irreversibility arises in this very bare setting of lo cal names

but neither is it certain that actual storable values are necessary for mild

cases of irreversibility to arise For instance something similar app ears to b e

present in a simple form in the language SPCF of though we are unsure

of the exact relationship

Sieb er has built a mo del for an Algollike language in which functors are

equipp ed with logical relations that are used to constrain function typ es

and has obtained a full abstraction result for the closed terms of secondorder

The pro of is subtle and original making use of nitely determined natural

transformations it is not obvious whether the cp os in Sieb ers semantics are

even algebraic The pro of given here is much less sophisticated using the

usual metho d of denability of nite elements

There are imp ortant dierences b etween our language and the one in

First and foremost is that Sieb ers results are for a language with a snapback

combinator so in comparison to the work rep orted here we may say that his

mo del accounts for lo cality to a go o d degree but not for irreversibility An

other dierence is that Sieb ers language has a form of side eectfree integer

expression whereas we have used active integers Our mo del can easily b e

extended to deal with passive integers but in that case we have not obtained

a full abstraction result the old problems with sequential functions crop up

again

But we should emphasize that though it do es not have passive integers

OHearn and Reddy

the language considered here is sequential it is one where the order of evalua

tion of at least basetyp e arguments can b e recorded using storage variables

cf It would seem to make sense to try to push this explanation of

active sequentiality utilizing coherent spaces and the stable order on reg

ular functions as far as p ossible b efore abandoning coherent spaces And of

course full abstraction is not the ultimate aim of the semantics though in the

course of proving the result we did nd legitimate structure asso ciated with

imp erative typ es this structure is of more interest than the result itself which

is only a technical indicator

But it is interesting that b oth Sieb ers results as well as ours stop at full

abstraction for secondorder typ es The reason is essentially that we are inter

preting Algol typ es as parameterized typ es functors and our present under

standing of parameterized typ es at higher orders is sketchy at b est While we

were able to show that all rstorder Algol typ es hace he structure of coherent

spaces we do not even know if the cp os arising at second order are algebraic

A more thorough understanding of parameterized typ es at higher orders is

needed to make further progress on this front

The parametricity mo dels based on PERs and logical relations presented

in do not account for irreversibility either However we may under

stand the main message of that work as applying more broadly than to the

sp ecic mo dels The prop osal there was that the abstractness of lo cal state

could b e understo o d in terms of Stracheys concept of parametric uniform

p olymorphism This leads to quite a convincing explanation of lo cal

ity Furthermore it has recently b ecome clear that a slight variation on the

parametricity semantics based on a strict function mo del of linear even rel

evant p olymorphism rules out the snapback and other unwanted op erations

There should b e close connections b etween the parametric and ob jectbased

semantics

We exp ect that some readers will feel with us that the mo del here works

in a slightly mysterious fashion without providing an explanation of lo cality

and irreversibility The metho ds of building up computational entities in the

mo del do not mention any conditions related to these prop erties The prop er

ties to the extent we know what they are arise as a consequence of the way

ob jects are constructed It may simply b e that an axiomatic approach to these

issues fo cusing more on properties characteristic of lo cality and irreversibility

is b est carried out within the context of an explicitstate semantics though

this is by no means certain In any event we have shown that the mo del is

quite accurate and so we exp ect that such an explanation should also b e

consistent with the ob jectbased semantics

Ultimately we do not b elieve that there should b e a conict b etween the

explicit state view as exemplied by the the parametricity mo dels and the

view of state as implicit in histories of events Very often it is most ecient

to conceive of ob jects as computational entities with pieces of state and op

erations though at other times it can b e more ecient to work directly in

terms of traces or similar representations For instance here we were able to

calculate the domaintheoretic structure of typ es with great ease while the

OHearn and Reddy

principles explicitly adopted in the parametricity mo dels often but not al

ways lead to smo other reasoning ab out sp ecic examples Ideally one would

hop e to have precise means of linking these two forms of description enabling

passage back and forth b etween one and the other These connections await

further development

Acknowledgement

We are grateful to Bob Tennent for comments and discussions

App endix

A Ob jects Coherent Spaces and Automata

We think of an ob ject as a computational entity with a mutable internal store

and a collection of observable op erations that can read and alter the store In

this resp ect ob jects are much like automata Elementary notions of ob jects

can receive some illumination by comparing to concepts of automata theory

Let M M e b e a monoid ie a set with an asso ciative op eration

M

and a unit e for this op eration We often write a pro duct x y as simply

M

xy An automaton for M is a pair Q Q M Q where Q is a

set of states and is a partial function the transition function satisfying

q e q

M

A

q xy q x y

These identities are understo o d in the context of partial functions if either

side is dened the other side is dened and equal Such automata are also

called monoid actions or Msets with partial functions

Often one takes M to b e a free monoid the set of strings over an

alphab et In this case is uniquely determined by giving a onestep

transition function Q Q If is a oneelement set fg then

0 0

reduces to a function Q Q An automaton of this form can b e regarded as

a command ob ject an ob ject with a single op eration that alters the store

Another example is an active integer that returns the rst time it is used

the second and continues doubling its value thereafter As an automaton one

representation is obtained by taking Q f g f g and

n

setting then n n This active integer illustrates the irreversibility

0

of state changes mentioned earlier we never return to the state after an

initial use of the ob ject assuming as the initial state The representation

of active integers as automata is not entirely satisfactory in that we would like

to think of the integer as an output of the automaton but nothing in the

denition suggests this This is remedied b elow in the denition of ob jects

with reference to coherent spaces

If Q M Q is an automaton its behavior at a state q Q is dened

OHearn and Reddy

as

L q f x M q x is dened g

L q is leftclosed ie xy L q x L q By the second identity

of A if q xy is dened q x must b e dened Conversely given any

leftclosed subset X M we can recover an automaton from it though not

uniquely A canonical choice is to take Q X and dene X M X by

x y xy

Then L e X This is the initial automaton with b ehavior X The nal

M

automaton is obtained by identifying all the rightcongruent elements in X

These two automata sandwich all the other automata with b ehavior X at

designated start states

This discussion illustrates how we might regard automata as intensions and

their b ehaviors as extensions We can obtain technical economy by identifying

automata with their b ehaviors

Objects denable in Algol are similar to automata but with one dierence

The op erations of an ob ject have b oth input and output information This

is in contrast to the instructions of an automaton the elements of M which

are to b e regarded as having only input information The input and output

parts of an ob ject op eration can b e causally interlinked in a complex fashion

So streamlined constructions like Mealy machines will not do

We use coherent spaces to treat the complex inputoutput breakdown of

the ob ject op erations We equip a monoid with a consistency relation that

we conceptualize in intuitive terms as follows For elements x y M we say

that x and y are consistent and write x y if x and y have diering input

information or have the same output information The complement relation

x y x y signies the opp osite while the inconsistency relation

x y x y x y signies that x and y have the same input

information Supp ose Q M Q is the transition function of an ob ject

Whenever q x is dened we exp ect that the output part of x as well the

nal state q x is uniquely determined by q and the input part of x In

other words

q x and q y are b oth dened x y A

For example for an active integer ob ject we dene that two distinct integers

are always inconsistent This ensures that q i is dened for at most one i

which is then regarded as the output of the ob ject in the state q Supp ose

x x x and y y y in A ab ove Condition A shows that q x

1 2 1 2 1

and q x are b oth dened So we exp ect x y Secondly if x y then

2 1 1 1 1

q x x and q x y are b oth dened So we exp ect y y

1 2 1 2 1 2

This motivates the basic denition of an ob ject space

Denition A An ob ject space is a pair X jX j where jX j

X

jX j e is a monoid and is a reexivesymmetric binary relation on

X

X

jX j such that

x x y y x y x y x y

1 2 1 2 1 1 1 1 2 2

X X X

Then yA creates the free ob ject space asso ciated with a coherent space A

OHearn and Reddy

Finally we can regard an object for an ob ject space X as a pair Q

Q jX j Q satisfying the condition A The b ehavior L q for any

state q Q is a leftclosed pairwiseconsistent set

Regular maps f A B determine functions from Aob jects Q

to B ob jects Q The transition map Q jB j Q is given by

q y q x x y f q x q This is the formaliza

tion of simulation mentioned in Section Conversely all functions from

Aob jects to B ob jects that are uniform in state sets Q in an appropriate

sense arise from regular maps in this fashion

While ob jects as considered here suce for the treatment of Algollike

languages one would want additional structure to treat other features of

ob jectoriented languages such as references comparison op erations and the

notion of self

References

J Backus Can programming b e lib erated from the von Neumann style A

functional style and its algebra of programs Comm ACM

August

G Berry Stable mo dels of typ ed lamb da calculi In G Ausiello and C Bo ehm

editors Automata Languages and Programming volume of Lecture Notes in

Computer Science pages Berlin SpringerVerlag

R Cartwright PL Curien and M Felleisen Fully abstract semantics for

observably sequential languages Information and Computation

PL Curien Categorical Combinators Sequential Algorithms and Functional

Programming Birkhauser Boston edition

JY Girard Linear logic Theoretical Comput Sci

JY Girard Y Lafont and P Taylor Proofs and Types Cambridge Univ

Press

JY Girard Y Lafont and Paul Taylor Proofs and Types Cambridge

University Press

C A Gunter Semantics of Programming Languages Structures and

Techniques MIT Press

C A Gunter and J C Mitchell editors Theoretical Aspects of ObjectOriented

Programming Types Semantics and Language Design The MIT Press

CB Jones An ob jectbased design metho d for concurrent programs Univ of

Manchester CS tech rep ort UMCS

GM Kelly Basic Concepts of Enriched Category Theory Cambridge

University Press London Math So c Lecture Notes Series

OHearn and Reddy

S Mac Lane Categories for the Working Mathematician SpringerVerlag New

York

A R Meyer and K Sieb er Towards fully abstract semantics for lo cal

variables preliminary rep ort In Conf Record th ACM Symp on Principles

of Programming Languages pages ACM New York

R Milner Fully abstract mo dels of typ ed calculi Theoretical Computer

Science

J C Mitchell Typ e systems for programming languages In J van Leeuwen

editor Handbook of Theoretical Computer Science Volume B pages

NorthHolland Amsterdam

E Moggi Computational lamb dacalculus and monads In Proceedings Fourth

Annual Symposium on Logic in Computer Science pages Pacic Grove

California IEEE Computer So ciety Press

M Odersky A functional theory of lo cal names In Conf Record th ACM

Symp on Principles of Programming Languages Charleston South Carolina

ACM New York

P W OHearn A mo del for syntactic control of interference Mathematical

Structures in Computer Science

P W OHearn A J Power M Takeyama and R D Tennent Syntactic

control of interference revisited in thie volume

P W OHearn and R D Tennent Semantical analysis of sp ecication logic

part Information and Computation

P W OHearn and R D Tennent Parametricity and lo cal variables J ACM

May

F J Oles A CategoryTheoretic Approach to the Semantics of Programming

Languages PhD thesis Syracuse University Syracuse NY

F J Oles Typ e algebras functor categories and blo ck structure In M Nivat

and J C Reynolds editors Algebraic Methods in Semantics pages

Cambridge University Press Cambridge England

A Pitts and I Stark On the observable prop erties of higherorder functions

that dynamically create lo cal names preliminary rep ort In ACM SIGLPLAN

Workshop on State in Programming Languages pages Available

as Yale Technical Rep ort YALEUDCSRR

A M Pitts and I Stark Observable prop erties of higher order functions that

dynamically create lo cal names or Whats new In Mathematical Foundations

of Computer Science numb er in Lecture Notes in Computer Science pages

SpringerVerlag

G D Plotkin The category of complete partial orders a tool for making

meanings Lecture notes for the Summer Scho ol on Foundations of Articial

Intelingence and Computer Science Pisa June

OHearn and Reddy

G D Plotkin Typ e theory and recursion In Proceedings Symposium on Logic

in Computer Science Montreal IEEE Computer So ciety Press

U S Reddy Passivity and indep endence In Proceedings th Annual IEEE

Symposium on Logic in Computer Science pages IEEE Computer

So ciety Press Los Alamitos California

U S Reddy Global states considered unnecessary intro duction to ob jectbased

semant ics Lisp and Symbolic Computation February Sp ecial issue on

State in Programming Languages

J C Reynolds Syntactic control of interference In Conf Record th ACM

Symp on Principles of Programming Languages pages Tucson Arizona

ACM New York

J C Reynolds The essence of Algol In J W de Bakker and J C van Vliet

editors Algorithmic Languages pages NorthHolland Amsterdam

J C Reynolds The essence of Algol In J W de Bakker and J C van Vliet

editors Algorithmic Languages pages NorthHolland

J C Reynolds Typ es abstraction and parametric p olymorphism In R E A

Mason editor Information Processing pages North Holland

Amsterdam

R A G Seely Linear logic autonomous categories and cofree coalgebras In

J W Gray and A Scedrov editors Categories in Computer Science and Logic

volume of Contemp Math pages AMS

K Sieb er Full abstraction for the second order subset of an Algollike language

preliminary rep ort Technischer Bericht A Universitaet des Saarlandes

February

I A Stark Categorical mo dels of lo cal names Lisp and Symbolic Computation

C Strachey Fundamental Concepts in Programming Languages Unpublished

lecture notes International Summer Scho ol in Computer Programming

Cop enhagen August

R D Tennent Functorcategory semantics of programming languages and

logics In D Pitt S Abramsky A Poigne and D Rydeheard editors Category

Theory and Computer Programming volume of Lecture Notes in Computer

Science pages Guildford UK SpringerVerlag Berlin

R D Tennent Semantical analysis of sp ecication logic Information and

Computation

R D Tennent Semantics of Programming Languages PrenticeHall

International

D Walker Ob jects in the calculus Information and Computation

February

OHearn and Reddy

G Winskel Event structures In W Brauer W Reisig and G Rozenb erg

editors Petri Nets Applications and Relationships to Other Models of

Concurrency volume of LNCS pages SpringerVerlag