Professional Documents
Culture Documents
This bookseries provides a distinctive publication forum for collected works and
monographs on topics such as domain theory, programming semantics, types ,
concurrency, lambda calculi, topology and logic in computer science, and especially
applications in non-traditional and emerging areas in which the development of formal
semantics deepens our understanding of a computational phenomenon.
Editorial Board
Samson Abramsky, Oxford University, UK
Stephen Brookes, Carnegie Mellon University, Pittsburg, PA, USA
Edmund Clarke, Carnegie Mellon University, Pittsburg, PA, USA
Thierry Coquand, University of Goteborg, Sweden
Pierre-Louis Curien, PPS, CNRS-Universite Paris 7, France
Manfred Droste, TU Dresden, Germany
Abbas Edalat, Imperial College, London, UK
Achim Jung , University of Birmingham, UK
Klaus Keimel, TU Darmstadt, Germany
Ying-Ming Liu, Sichuan University, P.R. China
Michael Mislovc, Tulane University, New Orleans, LA, USA
Peter O'Hearn, Queen Mary & Westfield College, London, UK
William Rounds, University of Michigan , Ann Arbor, MI, USA
Jan Rutten , CWI, Amsterdam, The Netherlands
Glynn Winskel, University of Cambridge , UK
CALL-BY-PUSH-VALUE
A FunctionallImperative Synthesis
by
Preface XXI
Acknowledgments xxv
Introduction XXVll
Vll
V lll CA LL-BY-PUSH- VALUE
Part I Language
1. CALL-BY-VALUE AND CALL-BY-NAME 3
1.1 Introduction 3
1.2 The Main Point Of T he Chapter 3
1.3 A Simp ly Typed A-Calculus 4
1.3.1 The Language 4
1.3.2 Product Types 4
1.3.3 Equations 6
1.3.4 Reversible Derivations 7
1.4 Adding Effects 8
1.5 The Principles Of Call-By-Va lue and Call-By-Name 8
1.6 Ca ll-By-Va lue 10
1.6.1 Operational Semantics 10
1.6.2 Denot at ional Semantics for print 11
1.6.3 Scott Semantics 13
1.6.4 The Monad Approach 14
1.6.5 Observational Equivalence 17
1.6.6 Coarse-Grain CBV vs. Fine-Grain CBV 17
1.7 Call-By- Name 18
1.7.1 Operational Semantics 18
1.7.2 Obse rvational Equivalence 18
1.7.3 CBN vs. Lazy 20
1.7.4 Denotational Semantics for print 21
1.7.5 Scott Semantics 22
1.7.6 Algebras and Plain Maps 23
1.8 Comparing CBV and CBN 25
2. CALL-BY-PUSH-VALUE : A SUBSUMING PARADIGM 27
2.1 Int roduct ion 27
2.1.1 Aims Of Chapter 27
2.1.2 CBV And CB N Lead To CBPV 28
2.2 Syntax 28
2.3 Operational Semantics Without Effects 30
2.3.1 Big-Step Semantics 30
2.3.2 CK-Machine 32
2.3.3 CK-Machine For Non-Closed Computations 33
2.3.4 Typing the CK-Machine 33
Contents IX
7. JUMP-WITH-ARGUMENT 141
7.1 Introduction 141
7.2 The Language 142
7.3 Jumping 143
7.3.1 Intuitive Reading of Jump-With-Argument 143
7.3.2 Graphical Syntax For JWA 144
7.3.3 Execution 145
7.4 The StkPS Transform 148
7.4.1 StkPS Transform As Jumping Implementation 148
7.4.2 Related Transforms 149
7.5 C-Machine 151
7.5.1 C-Machine for Effect-Free JWA 151
7.5.2 Adapting the C-Machine for print 153
7.5.3 Relating Operational Semantics 154
7.5.4 Observational Equivalence 155
7.6 Equations 155
7.6.1 Equational Theory 155
7.6.2 Example Isomorphisms 156
7.7 JWA As A Type Theory For Classical Logic 157
7.8 The StkPS Transform Is An Equivalence 160
7.8.1 The Main Result 160
7.8.2 Complex Values 161
7.8.3 Equational Theory For CBPV+ Control 162
7.8.4 Representing CBPV+Stacks In CBPV+Control 163
7.8.5 Stacks and Complex Values Are Computation-Unaffecting
164
7.8.6 The StkPS Transform Between Equational Theories
166
8. POINTER GAMES 169
8.1 Introduction 169
8.1.1 Pointer Games And Their Problems 169
8.1.2 Contribution Of This Chapter 170
8.1.3 More Is Simpler 171
8.1.4 Cells As Objects 171
8.1.5 Related Work On Abstract Machines 173
8.1.6 Structure Of Chapter 174
8.2 Arenas In The Literature 174
Cont ents Xlll
Part IV Conclusions
12. CONCLUSIONS, COMPARISONS AND FURTHER WORK 293
12.1 Summary of Achievements and Drawbacks 293
12.2 Simplifying Algebra Semantics 294
12.3 Advantages Of CBPV Over Monad And Linear Logic
Decompositions 294
12.4 Beyond Simple Types 296
12.4.1 Dependent Types 296
12.4.2 Polymorphism 297
12.5 Further Work 297
Appendices 298
Technical Treatment of CBV and CBN 299
A.l The Jumbo A-Calculus 300
A.1.1 Introduction 300
A.1.2 Tuple Types 300
A.1.3 Function Types 301
A.2 Languages and Translations 302
A.3 Call-By-Value 304
A.3.1 Coarse-Grain Call- By-Value 304
XVI CALL-BY-PUSH- VALUE
References 337
Index 345
List of Figures
XVll
xv III CALL-BY-PUSH- VALUE
XXI
XXII CALL-BY-PUSH- VAL UE
For readers between these two extremes, it is t he int erplay between op-
erationa l and denot ati onal aspects of CBPV that provides the greatest
int erest. This is most apparent in t he chapters on possible worlds and
pointer games.
Historical Background
• [Landin, 1966J explain ed how to combine fun ctional and imperative
features in a call-by-valu e setting, influ encing the Scheme and ML
progr amming lan guages.
• [Moggi, 1991J presented a denot ational fram ework for t his combina-
t ion using monad s.
who had not read about Jump-With-Argument , and only afte rwards
explain t he link. Bu t JWA is so fundamental to pointer games t hat t he
first acco unt of pointer games divorced from JWA was un convincing.
Consequ ently, JWA is now central to our account, and it is t he CBPV
mode l (wit h its qu esti on/answer distinction) t hat is treated afterwards.
JWA has also been integrated into Part III.
A newly discovered model for may-testing has been added at the last
minute-it appears in Sect. 5.5.4.
We have made som e cha nges in our notation to bring it into line with
common usage.
old new
pr oduce return (like in Java )
producer retur ner
outside stack
consumer continuation (like in ML )
cont inuation j um p-po int
O PS t ransform St kP S t ransfor m
os stk
let cos letstk
changecos changestk
enriched-compact bilim it-cornpact
exponent expo ne nt ial
value/ producer struct ure Freyd category
SE domain dom ain
SEAM pr edornain pr ed ornain
revised simply ty pe d A-ca lculus j umb o A-calculus
Revised-A jumbo A-calculus
isom orphism style naturality style
rep resent ation rep resen ting obj ect
(....u; ...) A{ . . . , i .Mi, . .. }
let x be V in M let V be x. M
print c; M print c. M (like in CCS )
M to x in M M to x. N
r I-h K: 11 rill. I- k Q
neverused ignored
SEAM Predom
SEstrict DomStr
SEAMpartmin Partmin
xxv
Introduction
P B Levy, Call-By-Push-Value
© Kluwer Academic Publishers 2003
XXVlll CALL-BY-PUSH- VALUE
• divergence
• erratic choice
1 A t hird m ethod of evaluat ion , call-by-need, is usefu l for im plem ent a t ion pu rposes. But it
lacks a clean denotation al semantics-at least for effect s ot he r t ha n div ergen ce a nd errat ic
cho ice whose speci al properties are ex ploite d in [Hen nessy, 1980] to provid e a call-by-nee d
model. So we sha ll not con sider ca ll-by -n eed .
xxx CALL-BY-PUSH- VALUE
Suppose we have a language £ in which both CBN and CBV programs can
be written. Then we need only give semantics for £ , and this automatically
provides semantics for CBN and CBV.
1.4 Conventions
104.1 Notation and Terminology
We write V 'M for "M applied to V " . This operand-first notation
has some advantages over the traditional notation MV. In particu lar,
it allows the "push" reading of Sect. 1.5.1.
For any nat ur al number n , we write $n for {a, . . . , n - 1}, the canonical
set of size n .
In a category, we write ] ; 9 for the composit e of ] and 9 in diagram-
matic order.
We avoid the ambiguous word "variable", using instead the followin g
dist inct terms:
INTRODUCTION XXXlll
1.4.2 Weakening
All the systems we treat have the weakening property: if I' f- M : B
then r, x : A f- M : B. We will often write the latter term not as M but
as x M. This explicit indication of weakening has two advantages.
• M and x M have different denotations: an environment for the latter
must provide a binding for x, even though this binding is not used.
• Writing x M implicitly includes the assumption that x rf. r, because
otherwise I' , x: A would not be a context.
As an example, the familiar 1]-law for functions is written
rf-M :A-+B
(1.1)
r f- M = AX.(X' XM) : A -+ B
helloO
hello2
hello3
we just pushed 7
hellol
we just popped 7
w is bound to 10
• it allows the command print "we just pushed 7" to intervene be-
tween pushing the parameter 7 and calling the procedure;
7'
print "we just pushed 7".
We have apparently excluded types such as boo L and nat from this,
but boo I can be recovered as 1 + 1. If we add type recursion as in
Sect. 4.2.2 , we can recover nat as J-lX.(l + X). In infinitely wide CBPV,
we can recover nat as LiENl.
Looking at the example computation of Sect . 1.5.2, we can see that its
type is Fnat because it returns a natural number. The identifier y has
type U(nat -+ Fnat). This means that the value to which y is bound is
a thunk (U) of a computation that pops a natural number (nat -+) and
then returns (F) a natural number (nat) .
1 The main goal is to argue the claim made in Sect. I.3~to persuade the
reader that CBPV is significant by exhibiting a wide range of elegant
semantics, from which CBN and CBV semantics can be recovered.
This goal is the subject of Part II ; the preliminary work is done in
Chap . 2.
• JWA.
Of course t he effect-free lan guage is trea ted in t he literature, so our
treat me nt is essenti ally a recapi tulation, presented in such a way as to
smoo t h the transition to t he effectful languages.
Many of these categorical st ruct ures, such as products, can be given
an elementary definition using a univers al proper ty ( "element style") ,
and a mor e abstract definition using naturality. In Ch ap. 9 we present
all the required structures in an element style, and explain how we can
use this to interpret CBPV with st acks in a CBP V adjunction model , and
JWA in a JWA module m odel. We see how all the concrete denotational
sema nt ics from Parts I-II are instances of these structures.
Each of t he following 2 cha pters is a sequ el to Cha p . 9. Chap. 10 devel-
ops t he relationship between t he categorical structures and t he syntax,
showing t hat every model of t he equational t heory is a CBPV adj unction
model.
In Cha p. 11, we show t hat each connective of CBPV is a represen ting
object for a suitable fun ct or , which gives us a naturality style definition.
Furt hermore, we show t hat our so-ca lled "CBP V adj unction models" are
indeed adj unct ions in the usu al sense .
F ina lly, in Ch ap. 12, we look at some problems an d poss ible dir ecti ons
for fur ther work .
1.6.4 Proofs
We have usuall y omitted proofs which are st raightfo rward inductions,
and we have omitted pro ofs of resul ts for CBV and CBN where we have
given corresponding resu lt s for CBP V.
INTRO DUCTION xli
C hap . 3
e x ce pt 3 .5
4 .8
~
4 .4 -4 .5 6 .10
T
~"-"
/'~,
C hap . 8
7 .7
7 .8 /1
C h a p. 10
r a,
C hap . 11
.
LANGUAGE
Chapter 1
1.1 Introduction
T here is a certain tension in t he presentati on of CBPV: how mu ch
attent ion shall we devote to CBN and CBV? On t he one hand, we are
claiming t hat CBPV "subsumes" CBN and CB V, and to see how t hat is
achieved we have to discuss CB N and CBV, at least to some exte nt . On
the ot her hand, a t horough st udy of CBN and CBV would be a waste
of effort, since a primary pur pose of CB PV is to relieve us of t hat t ask.
Once we have CBPV (which we want to int roduce as early as poss ible) ,
CBV and CBN are seen to be just particular fragments of it .
The CBNj CBV material is t herefore organized as follows. In this
chapter, we look informally at t he key concepts and prop er ties of t hese
paradigms, assuming no prior knowledge of t hem. This provides back-
groun d for CBPV which we introduce in Cha p . 2. Bu t for t he interested
read er , we provide in Appe ndix A a t horough, technical t reatment of
CBN and CBV and t heir relationship to CBPV. T his chapter can t hus
be seen as a synopsis of App endix A.
3
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
4 CALL-B Y-P USH- VALUE
The importance of this main point is that it makes it clear why CBPV,
t he subsuming paradigm , will need to have two disjoint class es of typ e.
Unfortunately, the Scott semantics obscures this main point , because
a pointed cpo is a sp ecial kind of cp o. By cont rast, the class of sets
and the class of A-sets are (as will b e apparen t onc e we have defined
A-sets) disjoint. Thus printing illustrat es our main point much b etter
t han div ergen ce does . This is why we have chosen printing as our leading
example of a com put at ional effect .
A ..= bool I A + A I A -+ A
and its terms are given in Fi g. 1.1. We write pm for "pat tern-match" ;
and recall that we write ' for op erand-first application. While let is
not strictly necessary (let M be x. N ca n be desugared as M 'AXN) , it
is convenient to include it as a primitive.
A booI-l- has a straightforward semantics wh er e typ es denote sets and
t erms denote functions . A closed t erm of ty pe bool den otes either true
or false; there is an easy decision procedure to find whi ch. We ca ll bool
the ground type.
f l-- M: A f ,x :AI-- N : B
r , x: A , r ' I-- x : A r I-- let M be x. N : B
At first sight , t he cho ice b etween projections and pat tern-mat chi ng
seems unim portant , b ecause t hese two forms of elimination r ule are
equivalent:
(M,M') as A{O.M,l.M'}
7rM as O'M
7r'M as I'M
1.3.3 Equations
Each type constructor (---+ , boo L, +) has two associated equations called
the fJ-law and the 1J-law.
We look first at the fJ-laws, which ar e straightforward.
• The fJ-law for A ---+ B :
M'AX.N = N[M/x]
let M be x. N = N[M/x]
We next turn to the 1J-laws. They ar e more subtle than the fJ-laws,
but they are important in understanding the CBV/CBN issues. So we
Call-By- Value and Call-By -Nam e 7
look at them carefully and understand why t hey are valid in t he set
semantics.
M = AX (X ' XM )
• The 17-law1 for boo I: if M has a free identifier z : boo I t hen for any
term N of typ e boo l
Intuitively, t his holds becau se, in a given enviro nment (list of bindings
for identifiers) , N denotes eit her true or false .
• The 17-law for A + A' : if M has a free identifier z : A + A' t hen for
any term N of typ e A + A'
1 Some a ut ho rs e.g. [Gira rd et al., 1988] give the name "7j-law" to t he wea ker eq uation
M = if M t hen true else f a l s e (Ll)
to gether with t he com mu ting conversi on law
M [if N then P e lse pi / z] = i f N then M [P/ z ] else M [pl / z] (1.2)
or a variant of t his . (1.1)- (1.2) tog et her a re equivalent to ou r 7j-law (1.3).
8 CALL-BY-PUSH- VALUE
1.6 Call-By-Value
1.6.1 Operational Semantics
In CBV a closed term wh ich is terminal is called a closed valu e. These
are given by
v "= true I false I inl V I i nr V I Ax .M
Every closed term M prints a string of cha racters m and then return s
a closed value V. We write M -IJ. m , V . T his is defined ind uctively in
Fig. 1.2.
if M then N else N ' .ij. m * m' , V i f M then N else N ' .ij. m * m' , V
M.ij.m ,V M.ij.m ,V
M .ij. m,V
print c. M .ij. c * m , V
• All CBV terms are called returners. (This is be cause their goal is to
return a value.)
D
Notice that a term is a value iff every closed substitution instance (sub-
st ituting only closed values) is a closed value.
We now des cribe and explain a denotational semantics for the CBV
printing language. The key principl e is that
each ty pe A denotes a set [A] whose elements are t he denot ations of closed
values of type A .
Thus the typ e boo l denotes the 2-element set {true, false} because ther e
are two closed values of type boo l . Likewise the typ e A + A' denotes
[A] + [A'] because a closed value of ty pe A + A' must be eit her of the
form inl V , where V is a closed value of type A , or of t he form inr V ,
where V is a closed value of typ e A'. We sh all come to A -+ B presently.
Given a closed value V of typ e A , we write [v] val for the element of
[A] that it denot es. Given a closed returner M of typ e A , we recall that
M prints a string of characte rs m E A* and then returns a closed value
V of typ e A. So M will denote an element [Ml et of A* x [A]. Thus a
closed value V will have two denotations [v]val and [Vl et related by
Corollary 3 (by Prop. 1) For any closed ground returner (i.e, returner
of ground type) M , we have M -lJ. m , return n iff [M] = (m, n). D
2We make the slight m od ification of using total fun ctions to lift ed cpo s instead of partial
functions .
14 CALL-BY-PUSH- VALUE
9
~ B, commutes.
V
~
Call-By- Value and Call-By-Name 15
AXTB~T(AxB)
such that the following diagrams commute:
1 x TA t{l, A ) • T(l x A) (A x B) x TC t(AXB,C! T((A x B) x C)
xr A
TA
/~~
/
A x (B x TC)
.> (
/ T Q(A ,B ,C)
Tt(A ,B )
,,(AxB)
t(A ,B)
16 CALL-BY-PUSH- VALUE
X xA
~B
g xA
V xA
.« commutes.
A cartes ian category with all exponent ials is called expone ntial. 0
r:
X xV
X X Ai 9 commut es.
~Y
A cartes ian category with all finit e distributive copro ducts is called dis-
tributio e. 0
Here are some well-known resul ts about dis tributive copro duct s, ad apted
from [Carboni et al. , 1993; Cockett, 1993].
Proposition 4 Let C be a cartesian category.
1 A distributiv e copro duct for {Ad iEI must be a copro duct for { Ad iEI.
If C is cartes ian closed , t he converse is true also.
. .
IS monic.
Call-By- Value and Call-By-Name 17
1.7 Call-By-Name
1. 7.1 Operational Semantics
In CBN the following terms are terminal:
N [M/ x] .ij. m ,T
let M be x. N .ij.m,T
i f M then N else N' .ij. m * m' , T i f M then N else N' .ij. m * m' , T
M.ij. m , T
print c. M .ij. c * m , T
Each CBN ty pe B denotes an A-set [B] = (X, *). Our intenti on is t hat
a closed term M of type B will t hen denote an element [M] of X , and
print c. M will denot e c * [M]. Thus * provides a way of "absorbing"
t he effect into X. Given an A-set (X , *) we can extend * to a fun ction
from A * x X to X in the evident way-we call t he extensio n * too. T his
extension allows us to int er pret print m. M directly.
Here are some ways of constructing A-sets.
Definition 1.14 1 For any set X , t he fr ee A-set on X has carrier
A * x X and we set c * (m, x) to be (c * m , x) .
2 For an i E I-indexed family of A-sets (Xi , *), we define t he A-set
TIiE/ (X i , *) to have carrier TIiE/ X i and structure given po intwise:
i' (c * I) = c * (i' 1) .
3 For any set X and A- set (Y, *), we define the A-s et X -? (Y, *) to have
carrier X -? Y and structure given pointwise: x' (c * I) = c * (x'l) .
D
• If [A] = (X, *) and [A'] = (X' , *) then A + A' denotes the free A-set
on X + X'. This is because any closed te rm of this ty pe print s a
string and t hen terminates as inl M or inr M , and t his behaviour
is obse rvable.
Each CBN type A denotes a cppo. Our intention is that a closed term
M of type A will denote an element of X, and if it diverges then it will
Call-By- Value and Call-By-Name 23
denote ..1. (A convergent term also may denote .1.) Thus L provides a
way of "absorbing" the effect into A.
We recall some familiar ways of const ructing cppos:
2 For an i E I-indexed famil y of cppos (Xi ' ~ '.1) the product of this
family I1i EI (Xi , ~, .1) is t he set I1i EI X i , ordered pointwis e. Its least
element is given pointwise i' .1 = .1.
3 Given a cpo (X, ~) and a cppo (Y, ~ ,.1) the expone nti al (X, ~) ----7
(Y, ~ ,.1) is the set of continuous fun ctions from (X, ~) to (Y, ~ ),
ordered pointwise. It s least elem ent is given pointwise x'.1 = .1.
• boo I denot es the lift of the cpo {t rue,false}. This is because a closed
term of type boo I either diverges or terminat es as true or false ,
an d this behaviour is observable.
• If A denotes (X, ~ ,.1) and A' denotes (X' , ~ ,.1) then A + A' de-
not es the lift of the cpo (X, ~) + (X' , ~ ) . ("CBN sum denotes lifted
sum .") This is because every closed term of this type eit her diverges
or terminates as inl M or inr M , and this behaviour is observabl e.
• If A denotes (X, ~ ,.1) and B denotes (Y, ~ ,.1) then A ----7 B denotes
(X , ~) ----7 (Y, ~ , .1). T his is because every closed term M of this type
is equivalent to some Ax.N, and if M diverges then it is equivalent
to Ax.diverge.
• The cpo semantics for CBN is the cartesian closed category of cppos
and continuous functions.
In fact, every model for CBN must be a cartesian closed category, as it
must validate the {3- and 1]-laws for funct ions.
These two cartesian closed categories are instances of a general con-
struction, based on the notion of algebra for a monad.
Definit ion 1. 16 [Mac Lane, 1971] Let (T, 1], /-l) be a monad on a cate-
gory C. A T -algebra consists of a pair (X ,8), where X is an object ofC,
8 is a morphism from T X to X, and
-,
1)X /LX
X · TX · T 2X
0 TO (1.6)
X. TX
0
2 For a family of T-algebras {(Xi , Oi) hE!, suppose {Xd iEI has a given
product in C. Then the produ ct T-algebra for {(Xi , Oi)} iEI is t he
algebra with carrier IT iEIXi and t he obvious st ructure map.
3 For a C-obj ect X a nd T- algebra (Y,O), suppose there is a given ex-
ponential in C from X to Y. Then the expon en ti al T- algebra from
X to (Y,O) is the T -algebra with carrier X -T Y and structure map
corresponding to
{J
X x T(X -T Y) tx,x ---t ~ T(X x (X -T Y)) ~ TY - -- -. Y
o
We can see how to interpret CBN types using these construct ions, and
that our constructions of cppos and of A-sets ar e sp ecial cases. For ex-
ample, the boolean type denotes the free algebra on 1 + 1. If A denotes
(X, 0) and B denotes (Y, ¢) t hen X -T B denotes t he exponent ial algebra
from X to (Y, ¢). It is now easy to see that if exponent ials to carriers of
T -algebras always exist- which implies, by the way, that Kleisli expo-
nentials exist- then t he category of algebras and plain maps is cartesian
closed .
We emphasize t hat in t he ca tegory of algebras and plain maps, an
object is an algebra (X , 0) , not just a C-object X on which t here exists a
st ruct ure map O. Although t his lat ter definition would give a cartes ian
closed ca tegory equivalent to our s, it would not give a semant ics of CBN.
To see t his, look at the sema nt ics for pm: it uses t he spec ific structure O.
In summary,
a CBV ty pe den ot es an object of C; a CBN ty pe denot es aT-algebra.
We are not claiming that eve ry model of CBN arises from a monad
in this way, just that the printing model and the Scott mod el do .
T his sit uation is seen not j ust in denotational semantics but also in
equat ions. Consider t he following equ ivalence-a special case of t he "1-
law for bool. If M has a free identifier z : boo 1 then
holds in CBV but not in CBN . It hold s in CBV because z can be bound
only to a value, true or false . It fails in CBN because z can be bou nd
to a term such as print "hel l o". true.
T hus , t he perception of CBN 's supe riority is act ua lly due to t he fact
t hat function ty pes have been considered more impor tant , and hence
have received more attention, t ha n sum ty pes or even gro und ty pes .
A consequence of t his bias (towards fun cti on ty pes and towards CBN)
has bee n t he promotion of cartesian closed category as a significant
st ruc t ure , in the semantics of programming languages and even in t he
semantics of intuitioni stic logic. T he lat ter is especially inapp ropriate,
because t he type t heory to which int uiti onisti c logic corresponds is effect-
free rather t ha n CBN or CBV, so its models must be bicartesian closed
categories.
Chapter 2
CALL-BY-PUSH-VALUE:
A SUBSUMING PARADIGM
2.1 Introduction
2.1.1 Aims Of Chapter
In this chapter we present the CBPV language and its operational
and denotational semantics for our example effects of printing and di-
vergence, and we show how it contains both CBV and CBN. Operational
semantics is presented in two forms : the familiar big-step form and the
CK-machine of [Felleisen and Friedman, 1986].
We will introduce the following vocabulary, all of which will be used
in subsequent chapters :
27
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
28 CA LL-B Y-PUSH- VA LUE
2.2 Syntax
The typ es of CBPV (as st ated in Sect . 1.5.4) are given by
r f-v V : A r ,x : A f-c M : Ii
r f-c M : Ii r f-v V : U e
r f-v thunk M : UIi r f-c force V : 11
Proof( in the sty le of [Tait , 1967]) We define, by mutua l induct ion over
types, three fam ilies of subsets:
M[V/x] JJ- T
l e t V be x. M JJ- T
M JJ- T
force thunk M JJ- T
Mi[V/ x] JJ- T
pm (i, V) as { . .. , (i, X).Mi' . . .} JJ- T
2.3.2 CK-Machine
T he CK-machine is a general form of operational semantics that can
be used for CBV and CBN as well as for CBPV. It was int roduced
in [Felleisen and Friedman, 1986] as a simplification of La ndin's SECD
mac hine[Landin, 1964], and there are many simi lar machines [Bierman,
1998; Krivine, 1985; Streicher and Reus , 1998]. At any point in time,
the machine has configuration M , K when M is the term we are eval-
uating and K is a stack' . There is no need for an environment or for
closures, because substitution is used . To incorporate types, we write a
configuration of the machine as
M K
1 When Felleis en and Fr iedman converted t he ir CK-mach ine into a small-step semantics , t hey
introd uced t he te rm evaluation con text for stack; bu t t he C K-mach ine see ms eas ier an d mor e
natural to wor k with . We use t he te rm ino logy curre nt stack rather t han current con tinu ation
beca us e in C BP V (unlike CBV) not all stacks are continua tions: for exa m ple, t he stack V :: K
is a pa ir , not a cont inuation -see DeL 2.5. We look at t his in mo re de tail in Sect . 5.4.5.
2If we wa nted ou r us age to be strictly consistent, we wou ld put the cont ext V' [.] rather than
j ust V onto t he stack, bu t t h is is un necessa ril y com plicated .
Call-By-Push- Value: A Subsuming Paradigm 33
V onto the stack, because at present we do not need it. Later, having
evaluated M to Ax.N, we can remove the operand V from the stack and
proceed to evaluate N[VIx], as the big-step semantics suggests.
To evaluate a closed computation M, we place it alongside the empty
stack nil and follow the transitions in Fig. 2.3 until we reach a configu-
ration T, nil for a terminal computation T. We shall see in Sect. 2.3.6
that this will happen precisely when M JJ. T.
Notice that
• the behaviour of V'M is to push V and then evaluate M
• the behaviour of Ax.M is to pop V and then evaluate M[VIx]
From the big-step rules we have thus recovered the push/pop reading
described in Sect. 1.5.1, although we did not mention there that the stack
is used for sequencing as well as for operands.
r M B K c (2.2)
and both rand C stay fixed during execution. The transitions are
entirely unchanged, and we need only give some additional terminal
configurations, which try to force or pattern-match a free identifier. The
details are shown in Fig. 2.4.
r M B K C
we know that r I-c M : B, but we do not as yet have a way of typing the
stack K. We therefore introduce a judgement fiB I- k K : C to achieve
this task. This judgement means that K is a stack that accompanies a
computation of type B in the course of executing a computation of type
C, with free identifiers given by r . The typing rules for this judgement
are immediate from Fig. 2.3 and Fig. 2.4, so the reader is invited to write
them out. The solution is given in Fig. 2.5.
34 CALL-BY-PUSH- VALUE
M C nil C
Transitions
let V be x. M B K C
M[Vj xJ B K C
"'"
M to x . N B K C
"'" M FA [.J to x . N :: K C
return V FA [.J to x . N :: K C
N [Vj xJ B K C
"'"
force thunk M B K C
M B K C
"'"
pm (i , V) as {. .. , (i , x).Mi , "'} B K C
"'" M dVj xJ B K C
V 'M B K C
M A-+B V ::K C
"'"
Ax.M A-+B V:: K C
M[Vj xJ B K C
"'"
Terminal Configurations
return V FA nil FA
A{ ... ,i.M i, .. .} TIiEI B i nil TIiEIB i
Ax.M A-+B nil A-+B
r M nil
Transitions
Terminal Configurations
r return V FA nil FA
r A{... ,i.Mi , . . .} TIiEIBi nil TIiEIB i
r Ax.M A---+B nil A---+B
r ,z : UB ,r' force z B K C
r ,z : E iEIAi, r' pm z as { .. . ,i.Mi, " ' } B K C
r ,z : A x A' , r' pm z as (x, y).M B K C
2 Q is terminal, and there does not exist Q' such that Q -v-+ Q'.
D
The only nontrivial part is the last part, and we defer the proof of to
Sect. 7.5.3.
Definition 2.5 (complementary to Def. 2.2(1)) A continuation is a
stack from a type FA to any type. D
Such a stack uses the value that a returner returns. For example,
[.J to x. N :: K is a continuation. (This usage of "continuation" is
consistent with the CBV literature, because in CBV, every stack is a
continuation, just as every computation is a returner.)
Lemma 14 For all M and N of type B , if, for all T , M J.l. T implies
N J.l. T, then , for every B f-k K : C , we have that C , M. K J.l. T implies
N.K J.l.T. D
Proof Induct on K. D
relation has the form M .lJ. T , it now has the form M .lJ. m , T . It seems
ther efore that we must present the big-step semantics from scratch.
Fortunately this is not the case. We simp ly replace each rule in Fig. 2.2
of the form (2.1) by
Mo.lJ. mo ,To
M .lJ. mo * ... * m r-l, T
Then we add the big-step rule
M.lJ.m ,T
print c. M .lJ. c * m , T
Proposition 16 For every comp utat ion M , ther e exists unique m , T
such that M .lJ. m , T. 0
2 .5 Observational Equivalence
As with CBV and CBN, we want to define a noti on of observational
equivalence.
We modify t his to sui t t he effect being consid ered. For printing (with-
out divergence) we say t ha t M ~ N when for every ground context C[.],
we have that C[M] -U- m , T iff C[N] -U- m , T (for every T) .
[UB] [B]
[FA] lift of [A]
[A -+ B] [A] -+ [B]
Like a value type, a context denotes a cpo , given by x. Then a value
r f-V V : A denotes a continuous function [V] from the cpo [r] to the
cpo [A], and a computation I' f-c M : B denotes a continuous function
from the cpo [r] to the pointed cpo [B].
Notice that, in both printing and Scott semantics, the constructs
thunk and force are invisible in the sense that
[thunk M] [M]
[force V] [V]
In the Scott semantics, U too is invisible, meaning [UB] = [B]' By
contrast, in many of the semantics in Chap. 5 thunk ,force and U are
all visible.
X x T Y ~ T(f x Y) ~ TZ
X xO ¢ commutes.
X xY - -- - - - - ---+
. Z
f
o
As in Sect . 1.7.6, suppose we have a strong monad T on a distributive
category C, with an exponential from A to B whenever B is the carrier
of a T -al gebra. We t hen interpret
• a value type (and hence a context ) by a C-obj ect
• a computat ion typ e by a T -a lgebra
• a value I' f-v V : A by a C-morphism from [f ] to [A]
42 CA LL-BY-PUSH- VALUE
c C V (a value type)
bool bool i.e . 1 + 1
A+B A V
- s:
A--+B U(A V --+ FB V )
Ao, . . . , A n - 1 f- V : C AoV , .. . , A n_ 1V f-v Vval : CV
x x
true true
false false
inl V inl Vval
inr V inr Vval
Ax.M thunk Ax.Mprod
A o, . .. , A n - 1 l- M : C
x return x
let M be x. N l\1 prod to x. Nprod
true return true
false return false
if M then N else N' Mprod to z . if z then Nprod else N,prod
inl M Mprod to z . return inl z
inr M Mprod to z . return inr z
pm M as {inl x.N, inr x.N'} Mprod to z . pm z as {inl x.Nprod, inr x.N,prOd}
Ax.M return thunk Ax.Mprod
M 'N Mprod to x. Np rod to f . x'(force f)
print c. M print c. Mprod
A -7 C B N B = (UA) -7 B (2.5)
boolcBN F b ool
A + CBNB F ((U A) + (U B ))
It is easily seen t hat these also respect denot ational semantics, e.g. t he
Scott semant ics for F (( U A) + (U B )) is t he lift ed sum of [A ] and [B ].
That the translation resp ects op erational semantics (to a certain degree
of intensionality) is proved in Appendix A.
sugar un sugar ed
M to {. . . , (i, x) .Ni , .. . } M to z . pm z as {.. . , (i, x) .N i , . . . }
A(x,y).M Az.(pm z as (x, y) .M)
pm M as (w, (x , y)). N pm M as (v, z).(pm z as (x, y). N)
46 CALL-BY-PUSH- VALUE
2.9.2 Commands
The types Fl and FO have a special significance in CBPV, because
they can be seen as types of commands, as we now explain.
Computations of type Fl are commands such as printing, assignment,
divergence and so on . They correspond to terms of type COmIn in Idealized
Algol [Reynolds, 1981], and to returners of type unit in ML. Such a
command can be prefixed to a computation of any type. We write
r f-c M : Fl r f-c N : B
r f-c return: Fl r f-c MiN : B
r f-c print c : Fl
r f-c M: FO
r f-c coerce e M : B fiFO f-k ignored : C
3.1 Introduction
In t his cha pter we look at 2 equationa l t heories, as shown in Fig. 3.1.
All t he extensions ar e computation-unaffecting in t he sense of Sect. 2.10.
CBPV ~ CBPV
+ complex valu es
1 conservative
We first see that , in order for the equationa l theory to have reasonable
mathemat ical prop erties (in particular, categor ical semant ics), we need
to add in Sect. 3.2 some ext ra te rms called com plex value s for the L:
an d x ty pes .
We present an equationa l theory for CBPV with complex valu es in
Sect. 3.3. Unfortunately, t here is no reversible derivat ion for F . We
use t his t heory in Sect. 3.5 to show t hat addi ng complex values is
computation-unaffecting.
We t hen look present an equational t heory for CBPV with stacks . As
well as complex valu es, t his requires complex stacks for t he IT and -7
types (t hese ar e roughly dual to t he com plex values) . T his equational
49
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
50 CALL-BY-PUSH- VALUE
theory is much better behaved: it has reversible derivations for all the
connectives. We use it to construct some isomorphisms between types.
Finally, we will look at how this theory is related to effect-free equa-
tional theories.
r f-v V : A r, x : A f-v W : B
r f-v let V be x. W : B
3.3 Equations
In Sect. 2.1 we looked at equational properties of CBV and CBN, and
the informal reasons for them:
• In CBV, the 1']-law for sum types (and boolean type) holds because
identifiers are bound to values.
• In CBN, the 1']-law for function types holds because a term offunction
type can be made to evaluate only by applying it.
f3-la w s
let V be x. Q Q[V/ x]
pm (i , V) as { . . . , (i, X).Qi , . . .} Qi[V/ X]
pm (V, V') as (x , y). Q Q[V/ x , V ' / y]
force thunk M M
(r e t ur n V) to x. M M[V/ x]
i' ..\{.. . ,i.Mi, ... } Mi
V '..\x.M M [V/ x]
1]-law s
M M to x. return x
V thunk force V
Q[V/z] pm V as { .. . , (i, x) . X(J [(i, x) / z], ... }
Q[V/z] pm V as (x, y). xYQ[(x, y)/z]
M ..\{. . . ,i .i' M, ... }
M ..\x.(x ' XM)
sequencing laws
(M to x. N) to y. P M to x. (N to y. XP)
M to x . ..\{ . . . . i.Ni , .. .} ..\{... ,i.(M to x. Ni) , ... }
M to x. ..\y.N ..\y.( XM to x. N )
print laws
(pr i nt c. M) to x. N print c. (M t o x. N)
print c. ..\{ . . . ,i.Mi, ... } ..\{ .. . ,i. (pr i nt c. M) , ... }
print c. Xx.M ..\x.(print c. M)
di verge laws
diverge to x. N diverge
diverge ..\{ ... , i. di ve r ge , . .. }
diverge ..\x.d i ve r ge
2 In t he f3-1aw
V '..\x.M ~ M[V/ x]
t he LHS means
push V.
pop x.
M
54 CALL-BY-PUSH- VALUE
The first two lines have the effect of binding x to V and leaving the
stack unchanged, so the overall effect is to obey M with x bound to
V.
3 In the 1]-law
M ~ AX.(X' XM)
the RHS means
pop x.
push x.
M - which does not mention x
Assuming again that the stack is non-empty, the first two lines have
the effect of leaving the stack unchanged and binding x to the top
entry in the stack. But we are assuming that x is not used in M, so
the binding is of no consequence.
4 The analogue of (3.1) for divergence is
diverge ~ Ax.diverge
M=M
N [V// v] = N[V/ v]
2 For a valu e Ao, . . . , An- 1 f-V V : A poss ibly containing complex val-
ues, we will define V to be a fun ction that, when applied to a sequence
Wo, . . . , Wn- 1 of complex-value-free closed valu es f-v Wi : Ai, returns
a complex-value-free closed value V(Wo, .. . , Wn-d such that
- --+
V(Wo, ... , Wn-d = V [Wi!xi]
is provable. This is defined by induction on V in Fi g. 3.4. The special
case n = 0 gives the desir ed result.
o
By choosing some such procedure, we can extend the operational se-
mantics to include gro und returners with complex values: if M is such
a returner, we say tha t M JJ. m , i iff M JJ. m , i . Becaus e of Lemma 24,
this relation do es not depend on the choice of pro cedure . ::.. .
We can adapt the proof of Prop. 25 to show that complex values can be
removed from a context . So it is immaterial whether , in our definition of
observational equivalence, we allow contexts to contain complex valu es.
We can extend Prop, 23 and Cor . 19 as follows, for the printing lan-
guage :
56 CALL-BY-P USH-VALUE
v N [V // v]
x N [x / v]
let W be x. U (let I/' be x. N[Uflv])[Wfll/']
(i , W) (let (i,l/') be v. N )[W // I/']
pm Was {.oo ,(i,X).ui , oo .} (pm I/' as {. . . , (i, X) .N[Uiflv], . . .})[Wfll/']
(W ,W') (l e t (I/' , x) be v. N )[W // I/'][W' fix]
pm Was (x, y).U (pm I/' as (x , y).N[U//v]) [Wfll/']
thunk M N [t hunk if/ v]
M if
let W be x. N (let I/' be x. N )[W fll/']
pm W as {oo . ,(i,x) .Ni , oo .} (pm I/' as {oo ., (i, x) .Ni ,oo .})[W fll/']
pm Was (x, y).N (pm I/' as (x , y).N) [W//I/']
A{oo . , i.Ni , oo .} A{oo . , i.Ni , oo .}
i'N i'N
Ax.N Ax.N
V 'N (v'N)[Vflv]
return V (return v)[V flv]
N to x. P N to x. P
force V (force v)[V//v]
print c. N print c. N
V V(~)
Xi Wi
let W be x. U [r(~, W(~))
(i , W) (i , W(~))
pm W as {oo . , (i, X).ui , . oo } Ut ( ~ V ') where W(~) = (i , V')
(W,W') (W(Wi ) , WI ( ~))
pm Was (x , y).U [r( ~ , V' , V " ) where W(~) = (V ' , V" )
- ----':--t
thunk M thunk M [Wi / X;)
This adapts to the various effects and denot ational models we will look
at.
q Q I-k K : II rl H. I-k L : I2
qc I-k K where nil is L : D
The equations for print and diverge are of course specific to our
example effects, but there are directly analogous equations for many
other effects.
One noteworthy equation of Fig. 3.6 is the 'T]-law
M M to x. return x (3.3)
(M to x. N). K M to x. (N. K) (3.4)
Complex Values and Equational Theory 59
,B- Iaw s
let V be x. Q Q[V/x]
K where nil is L K*L
pm (1;, V) as {... , (i, X).Qi ," '} Qi[V/X]
pm (V, V') as (x, y) .Q Q[V/x, V' /y]
force thunk M M
(return V) to x. M M[V/x]
i''x{. .. , i .M i" " } u,
{ .. . .K; where i :: nil, .. .} is i: : L K i*L
V ''xx .M M[V/x]
K where x :: nil is V :: L K[V/x]*L
7]-laws
Q[V/z] pm V as {.. . , (i, x). X(J [(i, x) / z], ... }
Q[V/z] pm V as (x, y) . xYQ[(x, y)/z]
V thunk force V
M.K M to x. ((return x) • XK)
K*L [.] to x. ((return x) • XK) :: L
M 'x{. . . , i. i' M, . . .}
K*L {... , (K * i :: nil) where i :: nil , .. .} is L
M 'xx.(x ' XM)
K*L (XK *x :: nil) where x :: nil is L
print law
(print c. M) • K = print c. (M. K)
diverge law
diverge. K diverge
Figure 3.6. Equa t iona l laws for CI3PV + st acks, using op erations of Sect . 2.3.5
As instances of (3.4) we have the sequ encing laws of Fig. 3.3. Similarly
the print and diverge laws of Fig. 3.3 are instances of the print and
diverge laws of Fig. 3.6.
It is thus evident that our equational t heory for CBPV+stacks ex-
tends our CBPV theory. What is not apparent at this stage is that the
exte nsion is conservat ive. We prove this in Appendix B.
60 CA LL-B Y-PUSH- VAL UE
Rules for X
r iG f-k
_ B l· ... l'EI
- r , AIQ f-k 11
rj C f-k A -t B
A -+ (B -+ C) ~ (A x B) -+ C (3.5)
UA x UA' ~ U(A n A') (3.6)
A.,= 'LiE/UBi
B.,= lliE/(UB i -+ FA i)
o
3.11 Trivialization
T he effect-free language analogous to CBPV is the x 'Lll -e-calculus
shown in Fi g. 3.8; essent ially this is the Abool-l-calculus of Sect. 1.3
extended with both pattern-match products and projection products.
As t his calculus is effect-free, it is not necessary to have both kinds of
product , just convenient .
We use the term "x -calculus" for t he frag ment of this calculus using
just x ; similarly " x 'L-calculus" and so forth .
It is easy to see that we can collapse effect-free CBPV + stacks, with
complex values and complex stacks, into the x'Lll -e-calculus. T his
62 CALL-BY-PUSH- VALUE
Types
Terms
rl- M: A r , x :A I-N: B
I' I- pm M as {. . . , (i ,x).N i , . .. } : B
... r I- M; : B; .. . i E/ r I- M : IT iE/Bi
I' I- A{.. . , i.M« , . . .} : ITi E/Bi r I- r u . s,
r , x :A I-M : B rl- M : A r l- N : A -+B
r I- Ax .M : A -+ B r I- M 'N : B
Equations , u sing conventions of Sect. 1.4.2
.a- la w s
let M be x . N N[M/ x]
pm (M , M') as (x, y ).N N[M/ x ,M' / y]
pm (i, M) as {. . . , (i , X).N i , .. .} N i [M/ x]
i' A{ . . . , i.Mi , . . .} Mi
M ' AX.N N[M/ x ]
17- la w s
N [M / z ] pm M as (x, y ).N[ (x , y)/z]
N [M / z ] pm M a s { , (i, x ).N[ (i , x)/z], .. .}
M A{ , i .i' M, . . .}
M Ax. (x ' M )
CONCRETE SEMANTICS
Chapter 4
4.1 Introduction
This cha pter is abo ut t he computational effect of di vergence. There
is lit tle origina l work here; our aim is to recall and adapt well-known
material , whi ch is not specific to CBP V, for use in subsequent chapters ,
notabl y our treatment of t hunk storage in Sect . 6.10.
F irst, we add recursion to CB P V- bot h rec urs ive te rms and recursive
ty pes -and look at t he denot ational semant ics.
Secondly, we look at a lan guage feature t hat is, in a sense, equivalent
to recursion-infinitely deep synt ax. This mean s t ha t t he parse t ree of a
term or ty pe can be infinitely deep , i.e. branches can be infinitely long.
Bohm trees are a well-known example of su ch te rms. Our only subse-
quent use of infinitely deep CBPV will be to state definability results
for game semantics in Cha p . 8.
It is important not to confuse this infinitely deep syntax with the
weaker feature of infinit ely wide syntax , which is used throughout the
book. The latter simply means that we allow types L:i E/Ai and ITi E/ B i '
where I is countably infini te. (Therefore, parse t rees of typ es and terms
are infinitely wide.) Infinitely wid e syntax does not introduce divergence
into the language, and all t he CBPV semantics in t he book can int erpret
it . It provides, for example, an easy way of giving a ty pe of natural
numbers: as L:i EN 1. We use it also as a metalan guage while describing
t he possible world semantics in Chap. 6.
It is easy to see that once we allow infinit ely deep syntax, we can en-
code infini tely wide syntax- for example, t he infinitely wide ty pe L:i EN1
65
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
66 CA LL-BY-PUSH- VA LUE
r , x: U.!1l-c M :.!1
r I-c diverge : B r I-c ux.M : B
Recursion and Infinitely Deep CBPV 67
/.Lx .M K
-v-+ M[t hunk /.Lx.Mlx] K
M [Vl x] JJ. T
pm fold V as fold x.M JJ. T
fold M c nil C
the category Cpo ! of pointed cpos and strict cont inuous functions , ev-
ery t hing generalizes 1 to bil imit-compact categories , as we now describ e.
Much of this mater ial is implicit in [Stark, 1996].
'" fb
Dd Ddd' , D d'
'
:0 ,~
'::.I ~b
V
Such a cocone is an bilimit wh en
Many properties and alt ernative definitions of bilimits are given III
[Smyth and Plot kin , 1982J.
1 Another generalization is t o t he "rat ional categories" of [Abramsky et al., 1994], but t hey
are for ca ll-by-na me .
Recursion and Infinitely Deep CBPV 71
• Composition is bi-strict.
1-;g 1-
j; 1- 1-
• C has a zero object i.e, an object wh ich is both initial and terminal.
(Because of hi-strictness, just one of these properties is sufficient.)
o
As we sha ll see in Sect. 4.3.3, t his is sufficient structure to solve domain
equations. Here are some exa mples of bilimit- compact categories.
Proposition 30 1 The category Cpo': is bilim it-compact.
(3) trivial.
(4) Given a countable dir ected diagram D in [J, C], set (Vi , {( edi' Pdi) }dEll]))
to be the bilimit in C of Di and set Vi v f . Vj to be
V(Pdi;Ddf;edj ) (4.3)
dEll])
o
72 CALL-BY-PUSH- VALUE
Proof
We have seen that minimal invariants always exist, and the same is true
for parametrized minimal invariants.
Proposition 34 Suppose C is a bilimit-compact (or merely algebraically
compact) category, and B is any Cpo-enriched category. Then any lo-
cally continuous functor
G : BOP x B x CoP X C -----+ C
Recursion and Infinitely Deep CBPV 75
h h
D - - - .... D
9
where C and D are pointed and h is strict. Let a be the least prefixed
point of f. Then f a is the least prefixed point of g. 0
cOPxc~c
HOPxH 1 ~ 1 H
vO
PX Vc;--V
where C and V are bilimit-compact and H is locally strictly continuous.
Let (D , i) be a minimal invariant for F. Then (H D , (aD D; Hi)) is a
minimal invariant for G. 0
that the thunk can be ignored here; we write this only so that the
metalanguage conforms to CBPV.)
• L::iEI extends canonically to a locally continuous functor from pCpoI
to pCpo, when we set (L::iEI Ji)(i, a) to be (i, fza) if fza is defined,
and to be undefined otherwise.
• x extends to a locally continuous functor from pCpo x pCpo to
pCpo, when we set (f x f')(a, a') to be (fa, f'a') if fa and f'a' are
both defined, and to be undefined otherwise.
• F extends to a locally continuous functor from pCpo to Cpo", when
we set (Ff)(return a) to be return (fa) if fa is defined, and to be .L
otherwise, and we set (F f) .L to be L
• TIiEI extends to a locally continuous functor from (Cpo..l)I to Cpo" ,
when we set (TIiEIgdb to be Ai.(gi(i'b)).
• -+ extends to a locally continuous functor from pC poop x Cpo': to
Cpo", when we set (f -+ g)b to be
f-V true : bool f-V fold (true ,fold (true , . . .)) : j1X.(bool x X)
f-Vfold (t r ue, fold (true , fold (true , ... ))) : j1X .(bool x X)
T his is not acceptable. It sho u ld den ote an element of [j1X.(bool x X)]- but t his
is t he em pty cpo.
r I- c ..1 : B
This larger set of terms that may use ..1 are called partial terms, whilst
terms that do not use ..1 are called total terms. The reader may wonder
what the difference is between ..1 and diverge, so we explain this as
follows. An infinitely deep term can be implemented as lazy tree, es-
sentially a program that repeatedly answers questions about its syntax.
For example, the computation Ax.d.i verge can be asked "what is your
outermost term-constructor?" and replies "Ax" . Next, it can be asked
"and what term-constructor follows that?" and it replies "diverge" .
By contrast, the computation Ax...1, when asked the second question,
diverges i.e. never replies. That is why a term without ..1 is called "total":
it always replies to queries about its syntax. The operational behaviour
of ..1 is to diverge, but this is not because there is a transition that
ensures this, as is the case for diverge. Rather, the CK-machine must
ask the current computation for its outermost term-constructor in order
to know which transition to apply. If the current computation is ..1, the
machine never receives a reply, so execution diverges.
For every finitely deep term M we define its interpretation [Mtin in the
usual way, setting [..1]p to be..1. Then, for every term M , we define
its interpretation [M]inf to be UM<lfinN[M]. It is clear that the set
{[M] : M <lfin N} is directed-the acceptability condition on branches
Recursion and Infinitely Deep CBPV 79
ensures its nonemptiness-so the join must exist. Furthermore, if M is
finitely deep then [M]inf = [Mt in, so [_]inf is an extension of [_tin.
Finally, we need to adapt the adequacy proof in Sect . 2.8 to include
infinitely deep terms. We define the various relations and prove their
admissibility just as we did there. We then prove that for any computa-
tion A o, ... ,An - 1 f-c M <lfin N : B, if ai ~A Wi for i = 0, ... ,n -1 then
-----7 •
[M]Xi a~ ~1J N[Wi!xi] ; and similarly for any values A o, . . . ,An - 1 f-v
f---7
U <lfin V : A. This is shown by mutual induction on M and U . By ad-
missibility, we see that [M] ~1J M for any closed computation M , and
this gives the desired result. ~
2We gloss over issu es of ide nt ifier binding. See [Alt en kirch and Re us, 1999; F iore et al., 1999]
for a fuller discussion .
82 CAL L-BY-PUSH- VALUE
T hus any semantics for recur sion t hat can interpret countable simulta-
neous recursions gives us a semant ics for infinitely deep syntax.
Sometimes it is easier to work wit h recursion , sometimes wit h in-
finitely deep syntax. One advantage of the form er is t hat , by allowing
only finitely deep syntax, we have a clear notion of compositional se-
mantics . Finitely deep syntax is an initi al algeb ra for an endofunctor,
and a compos it ional semantics is one spec ified by another algebra for
t his endofunctor- t he interpreta tion is t hen given by t he unique algebra
homomorp hism from the syntax to t his algeb ra [Goguen et al., 1979]. By
contrast, it is not clear in wha t sense t he semantics for infinitely deep
CB PV t hat we have cons idered can be said to be composit iona l.
ideals
w-cusls domains
compact els.
f
w-multicusls
ideals r
predomains
•
compact els.
ex V i(u)
a EA,a ~ x
T his chapter does not dep end on Chap. 3 or Chap . 4. However , all
the models in this chapter validate the equations of Ch ap . 3, and can
interpret complex values.
5.1 Introduction
The goal of Part II is to advance the following claim.
Whenever we ar e studying effect ful higher-order langu ages (a nd re me mbe r
t hat mere div ergen ce makes a lan guage "effect ful" ), t he semantic primiti ves
are given by CBPV. It is t her efore a goo d choice for our lan gu age of st udy.
While this is cer tainly a rad ical claim, we assemble, t hroughout Part II ,
extensive evidence for it. In a wide range of fields , we see firstly that
CBPV semantics is simpler than the tradit ional CBV and CBN seman-
tics , and secondly that these traditional semantics can be recovered from
the CBPV semantics-so we do not lose out by shifting our focus to
CBPV.
Admittedly, we encounter excep tions, where a CBV model does not
decompose naturally into CBPV. These except ions ar e
• the model for errat ic choice with t he constraint that choice must be
finit e (Sect . 5.5.3)
• the poss ible worlds mod el for cell generation with the const raint of
"paramet ricity in ini tializations" (Sect . 6.9)
• the model for input based on Moggi's input monad [Moggi, 1991].
The first two ar e constrained variants of a simpler CBV mod el that does
decompose into a CBPV mod el, so we do not consider t hem to be a
89
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
90 CALL-BY-PUSH- VALUE
(except for t he new model of Sect. 5.5.4). We will consider models using
sets and models using cpos. In all of the set mod els,
• a value type denotes a set
• in par ti cul ar , L iEIAi denotes the set L iEI[A i] and A x A' denotes
t he set [A] x [A']
• a context A o, . . . , A n- I denotes t he set [A o] x . . . x [A n-d
• a value r f-v V : A denotes a fun ction from [r] to [A] .
Stacks
As we stated in Sect. 2.6.2, for each of our models we can also give
semantics of stacks. In the case of global store, we can see that a stack
fiB f-k K : C, in a given environment p E [r], transforms a behaviour
of a computation M of type B into a behaviour of a computation of type
C. This transformation is not dependent on the initial store, although
M may set the store (say if B = FA) and the transformation will then
depend on this new store.
Thus K will denote a function from [r] x [B] to [C]. We omit the
interpretation of stack terms, which is straightforward.
94 CALL-BY-PUSH- VALUE
In a similar way, we can obtain a mo del for global store wit h rec urs ion .
T he semantics of ty pes and terms are as above except t hat we now
un derstand t he metali ngui sti c U,F etc . as referri ng to the Scott model
rather t han t he printi ng mo del.
letstk x. M K
~ M[K/ x] K
changestk K . M L
~ M K
We illust rate t hese constructs with an example program:
let thunk (
AX.
changestk x .
Xz.
IThe CBV cont ro l op erators (as in ML) are translated into CBP V as follow s:
cont A as stk FA
letc c x . M as letstk x . M
throw M N as M t o x. N to y. ( c hang e s t k x. ret urn y)
We have to use the t erminology "c urre nt st ac k" rather th an "cu rre nt cont inuation" (t he
phras e us ed in CBV) becau se in C BP V not every stack is a co nti nuation.
96 CALL-BY-PUSH- VALUE
return 3 + z
). be y
( 7'
print "he l l o" .
letstk a.
( ( A u.
true'
a'
force y
) to v in
return v+2
)
) to w.
return w + 5
• By t he time we reach t he line letstk a , we have printed hello and
the current stack consists of an ope rand 7 together wit h the to w
continuation (i.e. the continuation tha t begins on the line to w in),
so a is bo und to this stack.
• By the time we force y the current stack consists of operands a and
true and the to v cont inuation.
• When we force y, we pop the top operand, which is a , and bind x to
it. We now change the current stack to a.
• We pop the top operand, which is 7 (again) and bind z to it .
• We return 10 to t he current continuation which is t he to w continu-
ation. Hence we return 15.
Notice how t he stack discipline has been completely lost ; in t he absence
of t he control effects we would expect force y to return a value to t he
to v continuation , but we have used changestk to override t his.
and we add the rules for letstk and changestk in Fig. 5.1. Notice
!
+ complex valu es
conservative
CBP V ~ CBPV
+ stacks + stacks
... j +comrux v~u~/,tack'
CBP V - - CI3PV ~ CBP V
+ control + cont rol + cont ro l
+ stacks + stacks
+ complex values (in c!. ·i gn or e d )
r M B K
Transitions
r letstk x. M 11 K
r M[K/x] II K
r changestk K . M l1' L
r M 11 K
r let V be x. M II K
r M[V/x] 11 K
r M to x. N 11 K
r M FA [.J to x. N ·:: K
r fo rce thunk M II K
r M II K
r i'M -B., K
r M ITiEIlli i·:: K
r V 'M 11 K
r M A -+l1 V ·::K
T erminal Configurations
Figure 5.5. Translating CK-rnachine for CBPV into CK-rnachine for CBPV+con trol
1 Official presentation-compositional
Values types Computation types
[Um W] -+ Ans [F A] [A] -+ Ans
[l::i EIAd l::i EI[Ad m iEI~i]
[A x A'] [A] X [A'] [A -+m =
l::iEIWJ
[A] x W]
[stk~] un
2 Intuitive presentation-not compositional
Value types
[Um [stk m-+ Ans [stk FA] [A] -+ Ans
[l::iE1Ad l::iEI[Ad [stk rlEl~i] l::i EI[stk ~i]
[A x A'] [A] x [A'] [stk (A -+ B)] [A] x [stk B]
Computation types
W] [stk Q]
• [TIiEIBi] = L:iEI[B i] follows from the fact that stack from TIiEIBi
consists of a tag i E I together with a stack from B i .
Corollary 49 (by Prop . 47) Suppose Ans has 2 elements a =1= b. For a
set N and eleme nt n E N , wri t e I N,n for t he fu nct ion from N to Ans t hat
takes n to a and everything else to b. T he n for any closed gro und returner
M of ty pe F L:iEN1, we have M , nil "-,,,+* return n , nil iff [M ] I N,n = a.
Hence denotational equality implies observational eq uivalence. 0
We note t hat there are two kinds of jump-point: t hunks and continua-
tions.
We emphasize/ t hat stacks and jump-point s are quite distinct con-
cepts. Only cont inuations fall into both categories . A stack such as
V :: K is not a jump-point b ecause it den ot es a pair. The sit uat ion is
summarized in F ig. 5.7. T he reade r should beware: other autho rs some-
times use t he word "continuation" to mean "j ump-point " or "stack" .
For example:
2es pecially t o readers fam iliar with t he CBV setting, wh er e all stacks are cont inuations, and
so t he current stack is usu ally ca lled t he "cu rr ent con tinuat ion"
104 CALL-BY-PUSH- VALUE
stacks
jump-points
thunks continuations
• [Hofmann and Streicher , 1997; Laird, 1998; Streicher and Reus, 1998],
which treat CBN as well as CBV , use "continuation" to mean what
we call a stack.
Stacks
As in Sect . 2.6.2, we wish to give a semantics for stacks fiB f-k K : C.
But in this case, the semantics is immediate, for we know from Sect . 5.4.3
that we can regard this as a value I' , nil : stk C f-k K : stk B, so it
denotes a function from [r] x [C] to [B].
This can be summarized by the slogan "in a continuation model, there
is a duality between values and stacks" .
Simple Models Of CBPV 105
• a computation I' f-c M : B denotes a funct ion from [r] x [B] to the
carrier of Ans .
3 As in Sect . 5.4 .5, [1!] sho uld be thought of as shorthand for [s t k 1!].
106 CA LL-BY-PUSH- VA LUE
(T his property is satisfied by the free A- set on a set of size ~ 2.) For a
countable set N and element n E N , write I N,n for t he fun ct ion from N
to Ans t hat takes n to a and everyt hing else to b.
Then for any closed gro und ret urner M of type FL- iEN1, we have
M , nil ~* m , return n, nil iff [M ]IN,n = m * a. Hence terms with t he
sa me denotation are observationally equivalent . 0
In a similar way, we can obtain a mod el for cont rol effects with re-
cursion. The semant ics of ty pes and terms are as above except t hat
we now understand t he metalingu ist ic U etc. as referring to t he Scot t
model rather than t he printing mod el. We need only rep lace t he seman-
tic equation for print by an equat ion for recursion .
Simple Models Of CBPV 107
r c
I- choose {. .. , i .M i, " ' } : B
where i ranges over I. According to tast e, we can allow I to be finit e,
countable, nonempty or an arbitrary set (although in the last case t he
set of terms will not be small). The meaning of choose {... , i .Mi, . .. }
is "choose some i E I , then execute Mi" : Thus to the big-step semantics
we add
Proof For (;2) we induct on M JJ. T . For (~) we define subsets redA,
redk and red~ exactly as in Prop. 10, except that we replace the clause
for M E red:i!-by the following:
M E red'h iff for all b E [M] there exists T E redk such that M .lJ. T and
bE [T]. - -
We note that if T E redh then T E red~ (unlike in the proof of 10, the
converse is not apparentat this stage ofthe proof) . The rest of the proof
follows that of Prop. 10. D
IFboo 1 rLk []
. to
{true.
f 1
(return 3
5
I return 4) .. ' 1 ' F
.. nl. . nat
a se. return
The following mod el, closely related to the lower (Hoar e) powerdo-
main and to the linear logic mod els of [Huth et al., 2000], appears to
interpret errat ic choice + divergence, using may-testing equivalence. It
has just come to light at t he t ime of writing, so t he details remain to
be worked out . We do not yet have a computational understanding in
terms of behaviours, so our treatment will be very bri ef.
In the may-testing model of CBPV, each valu e type (and hence each
conte xt ) and each computation type denotes a pos et.
[UB] fglow[B]
[FA] [A]
[ITiEIBi] L iEI[Bi]
[A -+ B] [Af x [B]
The semantics of te rms is st raightforward. In par ti cular, we interpret
[M] = U [T]
M4J.T
for any closed computation M, but this has not yet been done at time
of writing. This would imply that terms with the same denotation are
may-testing equivalent.
Notice the following.
• A value type always denotes a countable disjoint union of
join-semilattices. Compare this to our definition of predomain (Def. 4.8(2))
• For each valu e typ e A, the cpo of ideals of [A] is the denotation of
A in usual lower powerdomain semantics
• For each computation type B, the complete lattice of lower sets of
[B] is the denotation of B in usual lower powerdomain semantics.
5.6 Errors
The errors feature we consider here is much weaker than the exc ep-
tions feature ofML and Java. In particular, we do not provide a handling
facility.
r f-c error e : B
Notice that error e can have any type, like diverge.
The big-step semantics now has two judgements M -U- T and M -U- e.
The rules are shown in Fig. 5.8.
112 CALL-BY-PUSH- VALUE
M[V/x] -I). e
let V be x. M -lJ. e
M -I). e
force thunk M -I). e
Mi[V/x] -lJ. e
pm (i , V) as { .. . , (i, x) .Mi , ... } -I). e
error c -I). e
• there exists unique T such that M -I). T and there do es not exist e
such that M -lJ. e
• there do es not exist T such that M -lJ. T and there exists unique c
such that M -I). e.
the following:
return V nil
A{... ,i.Mi, ... } nil
AxM nil
e
error e K
Here are some ways of const ructing E -sets (cf. Def. 1.14).
1 For any set X , the fr ee E -set on X has carrier X +E and we set
error e to be inr e.
[A -+ B] = [A] -+ ([B] + E)
Stacks
Just as for printing, a stack riB f-k K : 0 denotes a homomorphism
from [B] to [0] over [r]. Explicitly, if B deno tes (X , error) and 0
denotes (Y, error') , then K deno tes a function from [r] x X to Y such
t hat
[K](p, errore) = error'e
for all p and all e.
5.7 Summary
The easy part of all t hese models- the sem antics of values- was given
in Sect . 5.2, except for t he may-t esting model, where a valu e ty pe denot es
a poset and a valu e r f-V V : A denotes a pointwise ideal opbimodule
from [r] to [A]. In Fi g. 5.9 we summarize t he more difficul t part-the
semantics of computations and stacks. The set-based models are written
a bove the lines , the cpo- and poset-based models below the line.
Remember that , when giving semantics for global store + printing and
the semantics for control + printing, we use CBPV as a metalanguage
for the printing model: U means "carrier", F means "free A-set" . But
we can combine glob al st ore or control with any effect that we have a
model for, by understanding U and F as referring to this model.
For each effect , we see that the semantics of UF gives a monad in
the style of Moggi [Moggi, 1991]. It is rem arkable how each monad
decomposes into U and F in a specific way that fits t he ope rat ional
semant ics. In some ways, we have covered t he same ground of Moggi;
but t he key improvements are t hat
• we have included CBN as well as CBV;
effect U F UF =T
printing carrier free A- set A* x -
global store 5-+- 5x- 5 -+ (5 x - )
global st ore + printing U (5 -+-) F(5 x - ) U (5 -+ F (5 x - ))
contro l - -+ Ans - -+ Ans (- -+ Ans) -+ Ans
control + printing U (- -+ Ans) U(- -+ Ans) U (U (- -+ Ans) -+ Ans)
erratic choice -p -p
errors carrier free E-set - +E
di vergence lift lift
may-t est ing fglow fglow
effect -+ IT iI=f
printing -+ IT i Ef
global st ore -+ ITi Ef
global store + printi ng -+ ITi E f
cont ro l x L iEf
control + printing x L i Ef
er ratic choice x L i Ef
errors -+
n.;
ITi "'!
div ergen ce -+
op
may-testing - x - L i Ef
Figure 5.10. Induced semant ics for CB V and CBN fun cti on ty pes
• the uiorld , which tells us how many boolean-storing cells, how many
number-storing cells, et c., ar e in existe nce
• the store , which tells us what values these cells are storing.
117
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
118 CALL-BY-PUSH- VALUE
Assigning to a cell
r f-v V : ref A r f-v W : A r f-c M : 11
I' f-c V := W. M : B
Reading a cell
r f-v V : ref A r , x : A f-c M : 11
r f-c read V as x. M : B
This computation binds x to the cur rent contents of the cell V (in
other words , substitutes the current contents of V for x) , and then
executes M .
Equality of cells One might expect the primitive for equality testing
to be
r f-V V: ref A r f-v V' : ref A
r f-v V = V' : bool
But this is a complex value (in the sense of Sect. 3.2) . So, for the
sake of operational semantics, we take instead
L WA < 00
AEvaltypes
2 Using the notation of Sect. 1.4.1, we write cells W for the finite set
l:AEvaltypes$WA , the set of cells in w.
oA = 0 for all A.
ifB = A
otherwise
WA ~ w~ for all A.
120 CALL-BY-PUSH- VALUE
6.3.2 Stores
The world tells us only how many cells there are of each type, not
what they contain. This latter information is provided by the store.
Definition 6.2 1 Let w be a world. A w-store is a function associating
to each pair (A, i), where A is a value type and i E $WA, a closed
w-value wi f-V VAi : A. We write it
(... , cell Ai f---7 VAi ,"')
where i E $we
wlf f-v cell c i : ref e
2 In Sect. 6.10 we will explain how to adapt our approach to the general
"thunk storage" situation, where ¢( C) can be any type.
6.6 Introduction
6.6.1 What Is A Possible World Semantics?
We now turn to the real subject of the chapter, denotational semantics
using possible worlds.
How can we provide a denotational semantics for a language with cell
generation?? One plausible approach is to use the global store semantics
of Sect. 5.3, replacing the set of stores by the set of world-stores. How-
ever, by contrast with the store in Sect . 5.3, which can change in any
way at all, the world-store is constrained in the way it can change by
the fact that the world can only increase. Our goal is to provide a model
that, unlike the global store model, embodies this important constraint.
The key idea which leads to such a model is that of possible worlds:
a value type, instead of denoting just one set (or cpo) , has a different
denotation in each world. For example, refe would denote the 3-element
set $3 in a world w where there are 3 C-cells, but the 5-element set $5 in
a world w' where there are 5 C-cells. We write [A]w for the denotation
of A in the world w .
The various sets denoted by a type A are related. In the above ex-
ample, [C]w is clearly a subset of [C]w' . In general, whenever w ~ w',
there will be a function [A]~1 from [A]w to [A]w'. These functions
satisfy the equations
[A]~a a
6.6.3 Stores
We writ e Stu for the set
x [¢>(C)]w
(0, I) E cells w
We use the x symbol to emp hasize that the product is finite. An element
of 3w is called a semantic w-store, and a syntactic w-store (map from
cells to values) denotes a semantic w-store. But in the abs ence of thunk
storage, this disti nction is not so impor tant , because
Proposition 60 For every data type D and world w, the funct ion [- ]
from the set of closed w-values to to [D]w is a bijection. Hence t he
funct ion [-] fro m t he set of syntactic w-sto res to Siu is a bijection. D
That is why our model is so different from the ground storage models
menti oned in Sect . 6.6.2.
Ilw' :>-w(Sw' --+ [A]w' --+ L.wl/ :>-w'(S w"x [B] w"))
z-: U (A --+ ;-- F B)
This suggest s that a computat ion type will, like a value type, denote a
different set in each world, and that these sets are given by
thunk ( AX.
read cell 0 as y.
read X as z .
ceIIO := z.
x :=y.
new w := y + (3 x z).
return z )
This can be forced in any world-store (w' , s') , where w' ~ ui. It first
pops a celll' in ui', Then it changes the world-store to (w" , s") where
• writing y and z for the contents of cells land l' in s' resp ectively, s"
is the w"-store in which
l stores z
r stores y
I" stores y + 3 x z
every other cell stores wha t it stored in in 8', regarded as a w"-value
and returns z.
(6.8)
[ f ]W '1- [A]w"
[V]w"
must commute. In the case t ha t w = 0, we can summarize this by saying
that V denotes a natural transformation from [r] to [A].
Informally, (6.8) says that if we have an environment p of closed w ' -
values, substitute into V and then regard the result as a closed w"-value,
we obtain the same as if we regard p as an environment of closed w"-
values and substitute it int o V .
In particular, a closed valu e wi f- V : A deno tes a family {awl } WI ~ W '
where awl E [A]w' for each w' ~ w and aw" = [A] ~"awl for each w ~
I
[B]~b b
[B]~lIb [B]~I ([B]~:,b)
~
"," dlJIiJ" [r]w" X
[ ] "
[B]w" ~ [C]w"
(6.9)
must commute . In t he case t ha t w = 0, we can summa rize t his by saying
t hat K denot es a dinatural transformation from [r] x [B ] to [C].
Informally, (6.9) says t hat running against K , in an environment p E
[r]w' , a w'-computation that first generates cells up to w" and then
behaves as b E [B] w" is equivalent to first generating the cells and
t hen running the remaining computat ion agai nst K . This is similar to
t he requirement in t he printing mod el that [K ] preserve the printing
structure because running print c. M again st K will first print c and
t hen run M against K.
6.7.5 Summary
We now summarize t he denotati onal sema ntics of CBPV with cell
generation, with no t hunk storage . The seman ti cs is organized as follows.
show two examples of t his cons truction: st arting with t he A-set model
for printing, and starting with t he Scott mod el for divergence.
• A value type (and likewise a data typ e and a context ) deno tes a
covariant fun ctor from W to Set.
• A value wlr I- v V : A denot es, for each w' ~ ui"; a fun ction [V]w'
from [r]w' to [A]w' such that diagram (6.8) commutes for w ~ w' ~
ui" ,
• A valu e type (and likewise a cont ext) denotes a covariant fun ctor
from W to Cpo.
• A value wlr f-v V : A denotes, for each w' ~ w", a continuous func-
tion [V]w' from [r]w' to [A]w' such that diagram (6.8) commutes
for w :::; w' :::; w" .
• A comput at ion I' f-c M : B denotes, for each w , a cont inuous fun ction
from 8w x [r]w to [B]w.
134 CA LL-B Y-PUSH- VAL UE
• A computation wif f-c M : B deno tes, for each w' ~ w a fun ction
from 8 w' x [r]w' to [B ]w' .
The equat ions giving t he semantics of types and terms ar e exactl y the
same as in Sect . 6.8.2, except that we now interpret the metalinguistic
CBPV const ructs as referring to the Scott model rather than the printing
model.
Proof (in t he style of [Tait, 1967]) (1) is st raight forward. For (2), define,
by mutual inducti on over ty pes, t hree families of rela tions:
• for each A and w, a relati on ~Aw between [A] and closed w-values,
such that {a E [A] : a ~ Aw V} is admissible and lift-reflecting, and
a ~ Aw V and w ~ x implies ([A] ~)a ~ Ax V
• for each B and w, a relation ~~w be tween [B]w and t riples w' , s, M
where w' ~ w, s E 8w' and M is a closed w'-computation, such
t hat {b E [B]w : b ~ 1Jw x, s , M } is admissible and contains ..l, and
b ~~WI x , S, M an d w ~ w' implies ([B]~/) b ~~w x , s , M .
Possible World Model For Cell Gen eration 135
It is also easy to show that provably equal terms have the sam e denota-
tion i.e. the model validates the CBPV equ ations.
We not e that this semant ics takes place entirely in predomains and
dom ains, in the sense of Def. 4.8, because we required in Sect. 6.4 that
the set of cell types N be countable. If N were un countabl e, t hen t he
countable base condit ion would be violated.
1 Although Id eali zed Algol is a C BN language, the possible world model of [Oles, 1982] is
essent ially a model of t hunks- t his is why this model do es not allow di rect int erpret at ion
of conditionals a t all types. Hence a type of this langu age is interpreted as a V typ e, and
deno tes a cova ria nt functor.
Possible World Model For Cell Generation 137
S ~
X [1>(C)]
(C , l) E cells
[UB] ~
Us [B]
[L iEI Ai] ~
LiEI [Ai]
[A x A'] ~
[A] X [A']
[r efe] ~
$c
[F A] ~
Fs[A]
[TIiE1B i] ~
TIiEI[B i ]
[A -7 B] ~
[A] -7 [B]
138 CALL-BY-PUSH- VALUE
• X for a morphism in A
• Y for a morphism in B
Possible World Model For Cell Generation 139
• S for a morphism in S
and we use the op era tions on st rict cont inuous and par ti al cont inuous
functions defined in P rop. 37.
X XA )W = X
(A, I) E cells (A,I) E cells w
• (8, X) t---+ UsX exte nds to a locally continuous fun ctor U from Sop x B
to A , when we set
(X xX')W =XwxX'W
• (8, X ) t---+ FsX extends to a locally cont inuous fun ctor F from S x A
to B, when we set
OP
• -+ exte nds to a locally continuous fun ctor from A x B to B, when
we set
(A -+ Y )w = (Aw) -+ (Yw)
o
It is clear from Prop. 67 t hat t he isomorphisms above indeed define a
fun ct or from Cop x C to C, and we t hus obtain our sema ntics of typ es.
Havin g const ructed functors satisfying t hese isomorphisms , we define
140 CALL-BY-P USH-VALUE
op erations on semant ic stores and then define semant ics of terms just as
in Sect. 6.8.3 (where these isomorphisms ar e all identities).
Proposition 68 (Soundness/Adequacy) 1 Suppose M has type B
and w, s, M -U- w', s', T. Then [M]w[s] = ([B] ~, )([T]w'[s']).
2 Suppose w, s, M diverges. Then [M]w[s] = L
D
JUMP-WITH-ARGUMENT
7.1 Introduction
In Sect . 5.4.6, we presented a cont inuation semant ics for CBPV+ cont rol ,
together with printing. (We use printing as our leading exa mple of a non-
control effect in t his discussion, but ot hers would work as well.) We used
CBP V as t he seman tic metalanguage , and we gave not just one model,
but a whole family, parametrized by an A-set Ans. W hat we described
t here was , in effect, a translation
141
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
142 CALL-BY-PUSH- VALUE
(7.1)
Jump-With-Argument 143
where each set I is finite (or countable, for infini tely wide JWA ). A valu e
of ty pe -,A is an "A-accepting jump-point"-intuit ively, a point that we
jump to taking an argument of ty pe A. For exa mple, a BASIC line num-
ber would have ty pe -,1 , because the argume nt is trivial. Although we
have followed the established usage of -, for jump-point types, we con-
sider it to be a confusing usage because -, is not exactly logical negation ,
as we explain in Sect . 7.7. There are two judgements
r f-v V: A r f-n M
called resp ectively values and n onreturning commands (in the sens e of
Sect. 2.9.2-we will sometimes omit the word "nonret urn ing" ). The
terms of JWA are given in Fig. 7.1.
The embedding of JWA in CBPV+Ans (with printing, if desired) is
given in Fig. 7.1. We thus obtain, for each A-set Ans, denotational
semantics for JWA+print . By using the empty A-set for Ans, we can
prove
Proposition 70 There is no closed nonreturning command in JWA. 0
Because of this situation , we always consider ope rationa l semant ics for
non-closed nonreturning comma nds; execution te rminates when we at-
te mpt to jump to or pat tern-match a free identifier.
In t he abse nce of effects , JWA can be seen as a fragment of t he
x L:TI ---+-calculus (presente d in Fig. 3.8), and t his has been the usual
viewpo int in t he litera ture. However , it is not valid in t he presen ce of
effects .
The following will be of great import ance to our informal discussion
of pointer games in Cha p . 8.
Proposition 71 Any closed valu e in JWA consists of several tags and
several jump-points. 0
7.3 Jumping
7.3.1 Intuitive Reading of Jump- With-Argument
We said in Sect. 7.2 that an A-accepting jump-point (a value of type
-,A) is a point that we jump to taking an argument of type A . We
explain t he constructs for -, in a similar way.
• V /' W is the comma nd "j ump to t he point W taking argument V " .
• 'Yx .M is a point. When we jump to it taking argument V, we bind x
to V and then obey t he command M.
T he easiest way to gras p t his will be to see t he execution of an example
program. Our explanation of jumping is informal; its aim is to convey
t he jumping intuit ions of JWA.
144 CALL-BY-P USH-VAL UE
r f-v V : A r ,x : A f-n M
r ,x : A , r ' f-v X : A r l-" let V be x . M
Figure 7.1. Terms of J ump-With- Argumont , and its embe dding into CBP V+ Ans
• binding occurren ces of iden tifiers and patterns are pl aced on edge s
(enclosed in a rounded rectangle).
Jump - With-Argum ent 145
We give the name jumpabout to this kind of tree of rectangles, edges
and points. (We will not give a precise definition, as our explanation of
jumping is informal.)
7.3.3 Execution
We will illustrate execut ion using the command y : nat f-n M whe re
M is the last example in Fig. 7.2. Here is t he graphical syntax; we have
numbered each point and each rectangle for ease of reference.
obey instruction Vje obey this by just printing "h e llo" . No bind-
ing is made, so we ar e ready for the next instruction:
Notice t hat t he fun ction taking t race points and trace rectan gles to
t heir teachers describes a j ump ab ou t homomorphism called t he teacher
homom orphism from t he trace to the code. As t he trace grows during
execut ion, the teacher homomorphism grows with it.
T his example progr am is very simplist ic. More int eresting sit uations
arise when we jump several times to t he same trace po int. Each t ime,
a new branch of t he t race comes into existence, and so (un like in our
example) t here can be many t race points with t he same teacher. An
example is Fig. 7.3, wh ich t he reader is strongly encouraged to execute.
A B
UB --,B FA --,A
L: iEI A i L: iEI A i IliEIB i L: iEI B i
A xA' A X A' A --tB A xB
stk B B nrcomm 1
A o, ... , A n - l f-VV : B
x x
(i , V) (i ,V)
(V, V ') (V , V ')
thunk M , k .M
[.] to x. M :: K , x .(M[K /k])
i ·:: K (i ,K)
V ·: :K (V ,K)
A o, ... ,An - 1 f-c M : B A o, ... ,An - l , k : B f-n M
let V be x. M let V be x. M
pm V as {... , (i, x ).Mi" " } pm V as {. . . , (i , x ).M i , . . . }
pm V as (x, y ).M pm V as (x, y ).M
return V V / k
M to x. N let ,x.N be k . M
A{.. . , i . M i , . . . } pm k as {... , (i, k) .Mi" "}
i' M let (i , k ) be k. M
Ax .M pm k as (x,k) .M
V 'M let (V , k ) be k. M
force V k/ V
letstk x. M let k be x. M
changestk K . M let K be k . M
print c. M print c. M
cont A as stk FA
letcc x. M as letstk x. M
throw M N as M to x. N to y. (changestk x. return y)
Thus Ans in Fig. 7.1 has been replaced by FAns , and we have lost gen-
erality. In the case of printing, for example, the embedding in Fig. 7.1
provides us with a JWA semantics for any A-set, whereas the embedding
in CBV allows only a free A-set.
In summary: we have benefited from ensuring that both the source
language and the target language of the StkPS transform are CBPV.
7.5 C-Machine
7.5.1 C- Machine for Effect-Free JWA
Whilst the jumping operational semantics for JWA is intuitive, it is
useful to have also a more conventional operational semantics based on
152 CA LL-BY-PUSH- VALUE
Transitions
r let V be x.M
r M [V/ x]
r pm (i , V) as {... , (i , x) .Mi , .. . }
r Mi [V/ x]
r V / , x .M
r M[V/x]
Terminal Configurations
abs t ract syntax. The C-ma chin e is given in Fig. 7.5. It is similar to the
CK-machine, except that there is no need for a stack. Recalling from
Sect. 7.2 t hat we work with non-closed nonreturning commands, we fix a
context I' , and define a r -configuration to b e a nonreturning command
r f-n M .
Proposition 72 (determinism) (cf. Prop. 46) For every r -configuration
M , precisely one of t he following holds.
1 M is not t erminal , and M "", N for a unique r -configuration N.
2 M is terminal, and t here does not exist N such that M "'" N.
o
Definition 7.1 (cf. Prop. 2.4) We define the relat ion "",* on configura-
tions inductively:
M ' "",*N
- - - ( M "",M')
M "",*N
o
Jump- With-Argum ent 153
Proposition 73 (cf. 47) For every I' configur ation M there is a unique
terminal I'-configur at ion N such that M "Y'-t * N , and there is no infini te
sequence of transitions fro m M, 0
Proof (in the style of [Tait , 1967]) We fix f. We say that a f-configuration
M with the properties described in Prop. 47 is reducible. Thus our aim
is to prove that every f- configuration is reducible.
For each type A we define a set red'A of reducible values I' I- v V : A
by induction on types.
• I' I- v V : -,A is reducible iff V is eit her a free identifier or ,x.M where
for all V E red'A , M[V/xJ is reducible.
• I' I-v V : 2:iEIA i is reducible iff V is either a free identifi er or (i , W)
where W E red'A..
•
• I' I- V V: A x A' is reducible iff V is eit her a free identifier or (W, W')
where W E red'A and W' E redA,.
By mutual induction on M and V , we prove the following.
• For any non returning command I' , A o, ... , A n - 1I- n M , and any Wo E
---+
red'Ao" ' " Wn - 1 E redAn_I ' the f -configuration M[WdxiJ is reducible.
• For any value I' , A o, . . . , A n - 1 I-v V : B , and W o E red'A o"'" W n - 1 E
---+
red'An_l ' the valu e V[WdXiJ is reducible.
o
M M' (7.2)
Len we add print to the lan guage, we want a transition to have the form
M m M'
some m E A*. We therefore repl ace each t ransit ion (7.2) in Fig. 7.5 by
M 1111
M'
print c. M c M
154 CA LL-B Y- P USH- VALUE
Corollary 75 Suppose Ans has two elements a, b with the property that
(This property is satisfied by the free A-set on a set of size ~ 2.) For a
countable set N and element n , write I N,n for t he function from N to
Ans that takes n to a and everyt hing else to b.
Then for any nonreturning command k : .l:iEN1 f-n M , we have
M ~ * m , n / k iff [M](k t---+ IN,n) = m * a. Hence te rms with the same
denotation are observationally equivalent . D
Definition 7.4 Let I' 1-" M and I' 1-" N be nonr eturning comma nds .
We say t hat M ~ N when for any ground conte xt C
7.6 Equations
7.6.1 Equational Theory
We present ed the syntax for JWA in F ig. 7.1. But before we formulate
t he equa t ional t heory, we need , as usu al, to add complex values to JWA .
This is done j ust as for CBP V, in Fig. 7.6. As in Sect . 3.2, we exclude
t hese values when considering ope rationa l semantics, but include t hem
ot herwise. We define the equational t heor y in Fig. 7.7. As with CBPV,
we have
Proposition 77 1 Any comp utation is provab ly equal to a computa-
tion without complex value constructs.
156 CALL-BY-PUSH- VALUE
r f-v V : A r , x : A f-v W :B
r f-v let V be x. W : B
,B- Iaw s
let V be x. Q Q[V/x]
pm (z, V) as { . . . , (i, X) .Qi, " '} Qz[V/x]
pm (V, V') as (x, y) .Q Q[V/x, V' /y]
V / "(x.M M[V/x]
77- 1aw s
Q[V/z] pm Vas { ... , (i, x). 1<Q[(i,x)/z], ... }
Q[V/z] pm V as (x, y). xYQ[(x, y)/z]
V "(x.(x .> XV)
Figure 7.7. JWA equa t ions, using convent ions of Sect . 1.4.2
(7.3)
Ru les for x
r f-v A r f-v AI
Rules for L r f-v A x AI
Rule for -,
r, A f-n
r f-v -,A
A ..= L iE/-, A i
o
Explicitly, a type canonical form can be written
(7.4)
Some remarks:
• Any other formulation of classical logic, e.g. Hilbert 's, or that of the
Sheffer stroke, would be just as acceptable for our purposes.
We stress that this is a result about provability, not about proofs, and
we do not regard as canonical any particular translation from LK into
JWA. After all , we not would regard as canonical any particular trans-
lation from LK to Hilbert 's system. All Prop. 79 tells us is that such
Jump- With-Argument 159
A A
.A .A
E iEIAi E iE/Ai
A x A' Ax A'
D iE/ Ai ·EiE/ · Ai
A--+B . (A x .B)
lThere is a rather fort uitous result that any (finit ely wide) pr oposit ion a l formul a of t he form
-, A is classica lly valid iff it is int uitionistically vali d . On e mi ght t hink t hat t he eq uivalence
bet ween (1) and (4) is no mo re than a special case of t his fact. Bu t t hat is not so, becau se
our proof extends to t he infinit ely wide set ting, a nd ca n easi ly be exte nde d to pr ed icat e logic.
160 CALL-BY-P USH-VALUE
o
We ar gue that , in light of Prop . 79, JWA can be viewed as a typ e
theory for classical logic, provided we regard valu es (which are not log-
ically significant) as merely auxiliary. Whereas some ot her proposed
type theories such as AJL-calculus [Ong , 1996; Parigot, 1992J have to be
arbit rarily designated call-by-value or call-by-na me, JWA does not have
this problem.
CBPV ~ CBPV
\
!
+ com plex valu es
conse rvative
I
CBPV ~ CBPV
+ stacks + stacks
+OOffiPj" ",Uffi /,t,m
CBPV - CB PV ~ CBPV
+ control + control + control
+ stacks + stacks
+ com plex values (incl. -ignor ed )
JWA JWA
.!
---------------~
!(;oIlser:v<t~i.ve.
+ complex valu es
r f-v V : A r ,x : A f-v W : B
r f-v let V be x. W : B
,a- la w s
V ·Yhe r e n is L V[L/ n]
{. . . ,11; ·Yhe r e i ·:: n , . . .} is t· :: L 11; [L/ n]
V ·Yh e r e x·:: n is W .:: L V [W / x,L/ n]
changestk ([.] to x. N .:: K) . return V changestk K . N [V/ x]
changestk (t ·:: K ). A{ . . . ,i.Mi , .. . } changestk K. M ;
changestk (V ·:: K ). AX. M changestk K . M[V/ x]
changestk K . letstk x . M changestk K. M[K / x]
changestk K . changestk L . M changestk L . M
1/-laws
V [L/ z] { . . . , "V[i .:: n/z] ·Yhe r e i ·:: n , . .. } is L
V [L / z] =V [x -r: n/z] 'Yhere x c : n is L
changestk L. M [K / z] changestk K . A{ . . . , i. l e t s t k Y.
changestk L . VM[i -t: viz]' . .. }
changestk L. M [K / z] changestk K . Ax.letstk Y.
changestk L . XVM [x -r: viz]
K [.J to x . (ch ange s t k K . return x)
-i : ignored
K ·ignored
M letstk x. changestk x. "M
M changestk . ignored. M
sequencing law
changestk K. M to x . N = M to x . changestk "K, N
print law
changestk K. print c. M = print c. changestk K. M
diverge law
changestk K . diverge = diverge
1 It preserves substitution.
2 Dismantling is represented as follows. If r f-c M : B and riB f-k K :
G then
M . K = l et s t k nil. changestk K . M
Proof We will define one such procedure, and simultaneous ly, for each
value r f-v V : A , possibly containing complex valu es, and each complex-
value-free computation r , v : A f-C N : B , we will define a complex-
value-free computation r f-c N[Vjj v] : B su ch that N[Vjjv] = N [Vjv] is
provable.
Jump - With-Argument 165
M=M
N[Vjjv] N[Vjv]
v N [V#v]
x N [x/ v]
let W be x . U (let w be x. N [U// v])[W#w]
(i , W) (let (i , w) be v. N )[W#w]
pm W as {.. . , (i, X) .ui , . . .} (pm was {... , (i , x).N[ Ui//v]' ... } )[W//w]
(W,W') (l e t (w, x) be v. N )[W#w][W' #x]
pm W as (x, y).U (pm was (x,y) .N[ U#v])[W#w]
thunk M N [t hunk M Iv]
ll to x. M -i: K (letstk q. changestk k . (letstk v .
changestk q. N ) to x. M)[K//k]
i -: : K (l e t s t k q .changestk k . i' l e t s t k v .
changestk q.N)[K//k]
W ·::K (letstk q .changestk k. w'letstk v.
changestk q.N)[W#w , K//k]
W ·whe r e n is L N [W#v][L #n]
{ . . . , Wi ·whe r e i ·:: n , ... } (letstk q. changestk 1. A{ , i .l e t s t k n .
is L changestk q. (N [Wi // V]), } )[L#l]
W ·whe r e x c: n is L (letstk q . changestk 1. AX. letstk n .
changestk q . (N[ W#v ]))[L#l]
M M
let W be x. N (l e t w be x . N )[W#w]
pm W as {. .. , (i, X) .Ni , " ' } (pm was {. .. , (i , X).Ni , . . .})[W//w]
pm W as (x, y).N (pm w as (x, y).N)[W//w]
A{... , i.Ni , " ' } A{. . . , i.Ni , . . .}
i'N i'N
Ax.N Ax.N
V'N (v'N )[V#v]
return V (return v)[V#v]
N to x. P N to x. P
force V (force v)[V#v]
letstk x. N letstk x. N
changestk V. N changestk v. N [V#v]
print c. N print c. N
Ao , .. . , An_1 I-VV : B
let V be x . W l et V be x.W
pm V as {. . . , (i, x). Wi , .. .} pm V as {. . . ,(i, X).Wi, .. .}
pm V as (x, y).W pm V as (x, y) .W
V -vhere n is L let n be L. V
{... , l;i -vhare i-t : n , ... } is L pm L as {.. . , (i , n) .l;i , . .. }
V -vhar e x c: n is L pm L as (x, n) . V
·i gnor e d ,n
Figure 7.14. St kPS Tr an sform On Complex Valu es
P roposition 84 The StkPS transform preser ves su bstit ut ion and prov-
able equality. 0
The rem ainder of this section is a proof of Prop. 80. A natural ap-
pro ach is to t ry t o t rans late JW A back int o CBPV+cont ro l. The ques-
t ion is how to t rans late -' . Two possibiliti es seem natural : eit her as
U( - -+ FO ) or as stk F - (the la t t er is the cant of NJ -SM L) . Either of
t hese wou ld work, but we choose t he former.
Therefore, our inverse t rans lat ion from JWA to C BP V + cont ro l is
given by
StkPS
• CBPV+An s
[F O/Ans]
3 For each JWA type A , we define a function (3A from JWA values
I' f-v V : A to JWA values r f-v V : Af , and a function (3A: l in the
opposite direction.
A
pm V as { . . . , (i , x).(i , a Aix ), . . .}
pm W as {oo . ,(i,x) .(i ,a::;: lx), oo .}
Ax A' pm V as (x ,y) .(aAx,aA'y) pm Was (x,y) .(a::;:lx,'a:4}y)
U!1 thunk Ak.(changestk a Blk.force V)
thunk letstk k.(((aQ.k) 'force W) to x. {})
stk !1 a BV a lilW
A
pm V as {oo. ,(i,x).(i, ,BAiX), oo .}
pm W as {oo . ,(i,x) .(i , ,BAlx),oo .}
Ax A' pm Vas (x ,y) .(,BAx, ,BNY) pm Was (x,y) .(,B::;:lx,rr;}y)
-,A , (x, ()).(,B::;:IX /' V) , X.((,BAx, ()) /' W)
We have thus proved Prop . 80( 1). It is t hen st raight forward to prove
Prop. 80(2) by inducti on on A .
POINTER GAMES
8.1 Introduction
8.1.1 Pointer Games And Their Problems
In this chapte r we look at the game semantics of Hyland and Ong
[Hyland and Ong , 2000], discovered also by Nickau [Nickau , 1996]. It is
based on a cert ain kind of two-player gam e, where (generally speaking)
a player moves by
1 pointing to a previous move of the other player ;
2 passing a token.
We call such a game a "pointe r game". This is to distinguish it from
many other kinds of game, such as the purely token-passing games of
[Abram sky et al. , 1994]' which are quite different and which we sha ll
not be looking at. Pointer gam es are ext remely powerful: in a series
of striking results, they have provided universal 1 models for recursion
[Hyland and Ong, 2000], type recursion [McCusker , 1997], cont rol effect s
[Laird , 1997], ground store [Abram sky and McCusker , 1997], general
store [Abramsky et al. , 1998], errat ic choice [Harmer and McCusker,
1999] and more .
However, despite its rem ark able successes, the account of pointer game
mod els in t he literature suffers from a number of problems. The collec-
tive effect of these problems is that the reaction of many readers is
negative. They perceive game semantics as complicated and technical,
l A mo del is u nivers al [Long ley a nd P lot kin , 1997] wh en every morphism from [I'] to [A ] is
t he den ot ation of some te rm I' f- M : A. In the logical set ti ng, t his property is ca lled full
com plete ne ss [Abrarn sky, 1992].
169
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
170 CALL-BY-PUSH- VALUE
We recover , of course, the usual pointer game semantics for CBN and
CBV . But the fact that jumps (although not the destination ofreturns)
are explicit it CBPV makes it much more suitable for analyzing pointer
games, and the fact that jumps and their destinations are explicit in
JWA makes it even more suitable.
We make no claim to solve problems (2)-(3) . We emphasize that the
models per se are not new, only the way that we motivate them.
T his has ty pe
U [J {writ e.(A ---+ F1) , read.F A } (8.1)
- recall from Sect . 2.9.2 t hat F1 is the ty pe of commands. We give t he
name pseudoref A to (8.1). T he thunk associated with t he cell l is
Sin ce we are excluding cell equality testing from t he la nguage, t his t hunk
gives all the fun ct ion alit y of l . In t he game semant ics, we accordingly
int erpret
• ref A t he same way as pseudoref A
• V: = W . M t he same way as (W 'write ' (force V)) ; M
• read V as y. M t he sa me way as read ' (force V) to y. M .
T hu s, all the d ifficulty lies in the int erpretat ion of nev.
Xo : ref A o, .. . , Xn - I : ref An -I , r
Again, since we are excluding cell equality testing from t he langu age,
this thunk gives all t he functionality of l . In the game semantics, we
accordingly inter pret
• Pt~I ~ for t he arena with I roots, all labelled Qu estion , and a copy
of R; grafte d underneath t he ith roo t.
It is easy to see t hat t his int erpretati on agrees with t hat in [Hyland and
Ong, 2000], and it makes t he CBPV decomposition more appar ent.
Of cour se the difference between the two presentations is supe rficial,
bu t as with CBV t here are some advantages, for our account , in us-
ing arena familie s. In par ticular , if we int erpret as an arena, the initial
move where the Opponent plays a root does not correspond to a jump
(as moves generally do) but rather to information present in the envi-
ronment / stack before execution begins. Consequently, it is not really
meaningful to lab el it as Qor A, since t hat lab el distinguishes the two
kinds of jump.
[Laurent, 2002aJ advocates interpreting CBV and CBN ty pes in t he
same way. This implies we should eit her interpret both as an arena (as
he does, following [Hyland and Ong, 2000]) or interp ret both as an arena
family. We have argued, for both CBV and CBN , t hat it is preferable
to interpret a ty pe as a n arena family, and t his is what we shall do
throughout.
176 CALL-BY-P USH-VALUE
8.3.1 Types
Arenas
What information is needed to describe a jump? Let us say that the
jump-points we have available are ko, .. . , km - 1 ' A jump to one of these
is described by the following information:
several tags jo , .. . , j r- 1
several jump-points 10 , . .. , l s- 1
The selector together with the tags ar e called the data of the jump
and they are immediately observable by the context. The jump-points
appear just as points that ar e available for future jumping.
We depict the jumping possibilities ofko , . .. ,km - 1 as a forest -perhaps
infinitely deep-in the following recursive manner. Each choice of data
i, i« ,... , jr -1 is represented as a root (clearly there can be only countably
many) . Under this root we draw the forest depicting the jump-points
10, ... , l s - 1' In the games literature, this forest is called an "arena" .
. . . I- R t2 I- R tIl- R to
o
Some useful operations are defined as follows.
Definition 8.2 1 We write 0 for the empty arena.
2 We writ e Rl±JR' for the disjoint un ion of R (writ ing inl r for t he copy
of r E tok R) and R' (writing inr r for the copy of r E tok R') .
3 We writ e ptiE1R;, is t he ar ena with I roots (writing root i for the
ith root) and a copy of R; grafte d underneath the ith roo t (wri ting
under(i , r) for the copy of the token r E tok R;, under ro ot i ).
4 An isom orphism from an ar ena R to an ar ena S is a bijection from R
to S preserving all structure. We wr it e Arenalso for the groupoid
of arena isomorphisms .
5 An arena R is a sub-arena of an ar ena S when tok R ~ tok S and for
all r E tok R
• if r is a root in S then r is a root in R
• if r is a su ccessor of r' in S then r' E tok Rand r is a successor
of r' in R
6 Let a be a token in an ar ena R. T hen we write R ra for t he ar ena
consist ing of those tokens of R hereditarily preceded by a (exclud ing
a its elf) , with the successors of a as roots and the I- relation inherited
from R. (This is not a sub -arena of R , in the above sense.)
o
We have explained that an arena represents t he jumping possibiliti es
of a finit e sequence of jump-points . Since this arena is determined by
the typ e of these j ump-points, we shall say that it type-represents them .
If the arena R type-represents the jump-points ko, ... , km- l , and t he
arena S type-represents t he j ump-points k~ , . . . , k~ _ l ' then R l±J S type-
represents t he concatenated sequence ko, .. . , k m - l , k~ , . . . , k~ _ l ' T his is
178 CALL-BY-PUSH- VALUE
because data for the concatenated sequence must first select which of
the two sequences the destination appears in, and then provide data for
the selected sequence. Likewise the empty arena 0 type-represents the
empty sequence of jump-points.
We will give an informal example of an arena representation. Suppose
we have just one jump-point k accepting 1 + -,A where A is the type
.> -------------
inl inr
---------/~
Oth : inl Oth: inr 1st : inl 1st : inr
in(~
Here we have omitted the selector wherever there is only one jump-point.
If we jump to k with an inr tag, then there is only one accompanying
jump-point 1, so under the inr root we have not written any selectors. If
we jump to 1 with an inl root then there are two accompanying jump-
points: we can jump to the zeroth with tags inl or inr, and we can jump
to the first with tags inr. This is all represented in the arena.
We emphasize that in a jump whose data is a token a in an arena
R, the jump-points passed are type-represented by Ria. Thus, if we
subsequently jump to one of these jump-points, the data of this jump
will be a successor of a.
Semantics of Types
Now we turn to the semantics of types. A closed value of type A
consists of
• several tags io, .. . , i r - 1
Definition 8.3 Let {Ril iE! and {Sj} jEJ be countable families of are-
nas.
I
• An isomorphism from {Rili E! to {Sj hEJ is a bijection I - - - - - ' --+-. J
together with an isomorphism from R; to S Ii for each i E I.
Pointer Games 179
o
180 CALL-BY-PUSH- VALUE
{RdiEI : i : r M r'
8.3.2 Terms
Semantics of N onreturning Commands
Our next step is to give the semantics of the judgement r f-n M. It will
be recalled from Sect . 2.10 that this is the most important judgement,
as the values are merely auxiliary. We will motivate our semantics with
the command
u : ,(I + ,A) + 1 f-n M
Progr am M
Context q.]
.>: --------------
inl inr
--------/~
Oth : inl
Oth : inr 1s t : inl 1s t : inr
/
inl --------
inr
Semantics of Values
Let r be a context of jump-points ko : ,Ao, ... ,km- l : ,Am - 1 type-
represented as the arena R. Suppose we have , defined in context r , some
jump-points Vo, ... , Vn - 1 type-represented as the arena S . The jumping
behaviour of these jump-points begins when the context jumps to one
of them, with
• a selector i E $n and several tags, represented as a root a of S
• several jump-points, type-represented as S ra.
186 CA LL-B Y-PUSH- VALUE
At any time t hereafte r , t he jump-p oint Vi can at any time jump to t hese
jump-points, passing a successor of a, or to one of t he jump-p oints in r ,
passing a roo t of R.
T hus t he execu tion can be described by t he following game .
Definition 8.8 (informal) Let R and 5 be arenas. The value gam e from
R (t he source arena) to 5 (t he target aren a) is described as follows.
• Play alte rn a tes between Player and Opponent. Opponent moves first .
• Each move is classified as
a source mo ve, where a token in R is passed , or
a target mo ve , where a token in 5 is passed .
• Opponent moves initi ally by passing a ro ot T of 5. The initial
move must happen -we do not allow an emp ty play for this game.
(Roughly sp eaking, t he play comes into existence only when Oppo-
nent makes t he initial move.)
• Player moves by eit her
passin g a ro ot T of R , or
pointing to a previous O-move m , and passing a successor r of
t he to ken passed in move m.
• Opponent moves (except in t he initi al move) by pointing to a previous
P-move m , and passing a successo r r of t he token passed in move m.
We give t he name O(R , 5) to t he cpo of st rategies for t his game. D
then 8' E (J
deterministic if 8,8' E (J agree on all but the last move, then they
agree on the last move.
We write vStrat(R, S) for the cpo of value strategies from R to S, ordered
under inclusion. Directed joins are given by union. D
is also less efficient, both in time because one jump is replaced by several
jumps, and in space because one point is replaced by several points.
In a similar way, the denotation of an identifier x : -,B f-v x : -,B is a
description of the jumping behaviour of its 1]-expansion:
II nStratR l±J R ra
a Ert R
• s rR ,T is a play on R l±J T
• s rS,T is included in T
U T
To define the composite of R • S · T in C, set
(a; T)a to be a \ Ta. The composite of R U • S T in N is
defined to be a\T. These composit ions can be shown to be assoc iative
and respect t he identities.
2T hese t hread -pointers, unlike ordi nary pointers , d o not indi ca t e t he t im e of receip t of t he
jump-p oin t bein g ju mped to . T hey a re act ually redundan t , becau se, in a n int er ac ti on se-
qu en ce, a root move in R belongs t o t he sa me t hread as th e prec ed ing mo ve. However ,
removing t he t hre ad -pointers wou ld complica te ou r definiti on . T he sa me a pplies t o the
t hread-po inters in DeL 8.14.
192 CALL-BY-PUSH- VALUE
write, where i E I
written, where i E I
writteni,r where i E I, r E tok R;
read
read, where i E I
readi,r where i E I, r E tok R;
and is depicted as
write, read
/1\
written, .. ·i EI
/I~ read; . . ·i EI
/\
B
We give the semantics of the recursive initialization construct:
r ,X: ref A f-v V: A r,x : ref A f-n M
(8.4)
r l-" newrec x := V. M
Pointer Games 193
8.4.3 Claims
We have not proved the following res ults, but conjecture that t he same
methods used for call-by-value in [Abramsky et al., 1998] work for JWA.
In the following, recall from Sect. 8.1.4 how we int erpret terms in world
'W.
194 CALL-BY-PUSH- VALUE
plays the ith root. Therefore, terms with the same denotation ar e ob-
servationally equivalent. 0
• Suppose the context r denotes {Rd iET and the type B denotes {Sj h EJ.
Then a computat ion r f-c M : B denotes an element of
• Suppose the conte xt r denotes {Rdi EI and the typ e A denotes {Sj h EJ.
Then a value r f-V V : A deno tes an element of
• Suppose the context r denotes {Ri h E! , the type B denotes {Sj hEJ
and the type C denotes {Thh ETT. Then a stack fiB f-k K : C (is by
Pointer Games 195
Soundness and ad equ acy for t he CBPV mod el follow from t hat of
t he JWA mod el; t his appears to be true also for definability and full
abstraction, bu t the absence of complex valu es makes this derivation
more difficult.
• If, for each i E I , the type A i denotes {Rij h EJi ' then I:iEIAi de-
notes {Rij}( - -)E '" _ J -' This is because a closed value (i , V) of type
2,) D2 EI 2
I:iEIAi consists of a tag i E I and tags represented by j i, together
with jump-points type-represented by Rij.
• If, for each i E I , the ty pe B i denotes {~j }j EJi' then TIiEIB i denotes
{~j }(. ')E " ' . J .. This is because a stack i :: K for TIiEIBi consists
t ,J D t EI t
of a tag i E I and tags represented by j i , together with jump-points
ty pe-represented by ~j'
We int erpret infini tely deep types as for JWA in Sect. 8.3.1.
Arena 0
Q A A
I
A
A
/\ A
8 .6 Removing Control
The most imp ort ant part of t he chapter , the model for JWA and
CBP V, is now complet e, and we t urn to a more tec hnical topic. Looking
at our model for CBP V with control and storage, we can ask some
questions.
• W hat objects are definab le without stk? Between t hese,
what morphisms are definable without control ope rators?
• Wha t morphisms are definable without non-ground storage? Among
t hese ,
Pointer Games 199
A ..- ~i EIUBi
B TIiE/(UB i -t F A i)
o
P roof Similar to t he proof of P rop. 87. 0
We explain t hese as follows. In t he abse nce of stk, a value consists of
some tags and some thunks, bu t no cont inuations . In t he deno tation of
a valu e ty pe, R; ty pe-represents t he j ump-po ints accompanying the tags
des cribed by i . Since t hese jump-points are all thunks, it is impossibl e
to jump to one of them as an answer-move, and all the root s of R; ar e
200 CA LL-B Y-PUSH- VAL UE
r>.
Q .. . A
~
Q ... A
r>.
Q ... A
or of t he form
r>. r>. r>.
.. · A Q ... A Q ... A Q .. . A
--L
(the eart h symbol indica tes the absence of a pointer) , t hen the pend-
ing Q-move does not exist.
o
Thus t he pending Q-move of c, if it exists, is
• an O-move if c is await ing P
• a P-m ove if c is await ing O.
Definition 8.19 Let c be a play in a bracketable game G.
1 Let m be an A-lab elled move in c. We say that m is bracketed when
it points
Point er Games 201
II II nStratPbrack u;I±J s,
iE I j EJ
CATEGORICAL SEMANTICS
Chapter 9
9.2 Introduction
Many categorical structures, e.g. product, can be defined in two styles:
• elem ent style uses a universal property
• natumlity style uses a natural isomorphism.
The element style is easy to define and work with, so this is what we use
in this chapter. We briefly mention the naturality style formulations in
each case, but a proper treatment is deferred to Chap. II.
After presenting in Sect . 9.3 the category theory we require, we review
the semantics of effect-free language in Fig. 3.8-in particular, the use
of distributive coproducts to model sum types.
Then in Sect. 9.5, we then present the basic structure for interpreting
JWA judgements and for interpreting CBPV judgements. At this point,
the only connectives we can interpret are 1 and x. So our next step,
in Sect . 9.6, is to work through the various connectives of CBPV and
207
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
208 CALL-B Y-PUSH- VALUE
idjg 9
(l j I') : 9 = I, (I' ;g)
where 9 is a N -morphism. o
Definition 9.2 Let V be a category. A right V-module 0 consists of
• for each B E ob V , a set whose eleme nts we call O-morphisms to
B -we wri te g . B when 9 is such a morphism
9 h
where 9 is a O-morphism . D
9 h
g; id 9
g; (h; hI) (g; h) ; h'
(J ;g) ;h f ;(g;h)
where 9 is aM-morphism. D
(X , Y) r----+ V (X , Y)
Let C be a ca tegory.
• For readers familiar with indexed cate gories, a locally C-indexed cat-
egory V is a st rict C-indexed category- i.e. a fun ctor V : CoP ------7
C a t - in which all the fibres V x have the sam e class of obj ect s ob V
and all the reindexing functors Vk ar e identity-on-object s.
• For read ers familiar with enr iched categories, a locally C-indexed cat-
egory is a [COP, Set]-enr iched category.
But for the general reader , we give an explicit definition.
D efinit ion 9.6 A locally C-indexed category consists of
• a class ob V , whose elements we call V -objects and we underline
(except in cases where ob V = ob C)
• for each object X E ob C and each pair of objects Y , Z E ob V , a
set V x(Y , Z) , an eleme nt of which we call a V-morphism and wri te
1
x
• for each object X E ob C and each obj ect Y E ob V , an identity
id
morphism Y , Y
x
1 9
x x
such that
idi I I k*id id id* I I
I ; id I k* (J ; g) (k* 1); (k*g) (1 ; k) * I l *(k* 1)
(J; g); h I; (g; h)
For a C-object X , we wri te V x for the category of V-obj ects and mor-
phisms over X , also called t he "fibre over X " . If C has a te rminal obj ect
1, morphisms over it are called global mo rphism s. For a C-morphism
Y k , X , we write V X 'Dk . Vy for t he fun ctor that is iden-
ti ty on objects and k* on morphisms , also called t he "reindexing fun ct or
over k" . 0
212 CALL-BY-PUSH- VALUE
such that
Fid id
F(J;g) (FJ); (Fg)
F(k* J) k*(FJ)
I 9
x x
is given by
XxyJ!!..dlxxz 9 • W
f k
z
X' x Y ~ X x Y f • Z
Definition 9.9 Let (T, "1, fL , t) be a strong monad on a cartes ian cate-
gory C. We write CT for t he locally C-indexed categories in which an
object is a T -algebra a nd a morphism over X from (Y,O) to (Z, ¢) is a
T -a lgebra homomorphism in t he sense of Def. 2.8. 0
ob (V x V' ) ob V x ob V'
(V x V' )x ((A , A') , (B , B ')) V x (A , B ) x V'x(AI,B')
ob V
V x (B , A )
xY kf Z 19 W
• X'_ • X"_
is given by l;k((l*J);g).
It is easy to verify the identity and associativity laws. D
op Gr 'vT"l opGr i
--- op Gr(1 x 'T"l)
v
opGr((obj ~) xV)
• op Gr (BOP x 'T"l)
v
M
--
S et
oP
3 Given a functor M : opGr(B x V) ---+ Set and a V-object D, we
write M _(D, -) for the composite
O'or • GY
FY
Ff Gf commutes in V'x.
FZ • GZ
O'o~
[Xi] 1ri
[let M be x. N] (id, [M] )*[N ]
[ (M , M ') ] ([M] , [M' ])
[pm M as (x, y). N] ((id, ([M] ;1r)) , ([M];1r'))*[N]
It is vital to prove that t his soundly int erprets the equational theory,
i.e. that if M = N is provable then [M ] = [N]. But the laws mention
substitution, and so, in order to do this, we first need a substitution
lemma saying what a substit ution denotes:
[q*M] = [q]*[M]
where, if q = (Mo, . .. , Mn- d, we write [q] for ([Mo], . .. , [Mn- d) This
is proved straightforwardly. (Again, two inductions ar e required- see
[Fiore et al. , 1999] for details.) It is then straightforward to show that
the equa tions of the theory ar e validated .
r f- IliEf B i
r ,A f- B
rf-A-+B
r,A i f- B . . . iEI
r , L:i Ef A i f- B
Semantics in Element Styl e 219
We call the defin itions in Def. 9.17 elem ent style because we explicit ly
describe what the isomorphism does to an element of the homset. But
we sh all show in Sect. 11.3.1 and Sect. 11.3.3 that these structures can
also be described in naturality styl e, where, in addition to the vertex V ,
we provide
• for a product of {Ad iEJ , an isomorphism
Cx V ~ II Cx A i natural in X
i EI
This "nat urality in Y" uses the followin g notation. Given a C-morphism
X X Y h
"
Z we write
.
Cx h
CxY - -.... CxZ
r f-v V : A
id*M M
p*q*M (p; q)* M
• a cartesian category C
• a left C-module N.
D
T hus we interpret
[Xi]
[let V be x. P] (id, [V])*[P]
[(V, V')] ([V] , [V'])
[pm V as (x , y). P] ((id , ([V] ;1f)) , ([V] ;1f/))*[P]
nil*K
K*nil
(K*L)*L '
9.5.5 Enrichment
We will not look at enriched models of CBPV and JWA in general,
as the theory has not been developed, but just look at 3 examples of
enrichment. Our main reason for doing this is that in Sect. 9.7 we will
study various constructions of CBPV and JWA models, and we want
to see that these constructions enrich (i.e. can be applied to enriched
models to give other enriched models).
Suppose we want a CBPV judgement model (C ,V, 0) to interpret
CBPV with printing. Then it is not sufficient for each O-homset 0 AB
to be merely a set; it must be equipped with an A-set structure, so
that we can interpret print c. M as c * [M]. Furthermore, in order to
validate the laws
k*(c * g) c*(k*g)
(c*g);h c*(g;h)
k*..1 ..1
..1; h ..1
are satisfied for t he least element ..1 of t he computat ion hom set s.
2 A cppo-en riche d JWA judgemen t model is a JWA judgem ent model
(C,N) where
• all t he value homsets Cx Y and nonreturning command hom sets
N x ar e equippe d with a parti al order mak ing t hem cpos , and all
composit ions are continuous
• all t he nonreturning command homsets N X are pointed a nd t he
equation
k*..1 ..1
9.6 Connectives
9.6.1 Right Adjunctives-Interpreting U
In CBPV, we recall that the U connective has the following reversible
derivation
r f-c B
r f-v UB
This suggests the following definition.
Definition 9.23 (element style) A right adjunctive for a comp-object
B in a CBPV judgement model (C,D, 0) consists of a val-object V
(the vertex) together with an O-morphism. fo~e. B, such that
the functions
9.6.2 J umpwiths-Interpreting -,
The int erpret ation of -, in JWA is similar to t ha t of U in CBPV. We
recall t ha t -, has the followin g reversible deriva tion
r ,A f-n
r f-v -,A
This suggests t he following definiti on . (The idea of giving a direct cat-
egorical characterization of -, first appeared in [T hielecke, 1997b], al-
t hough t he characterization given t here was different. )
Definition 9.24 (element style) A jumpwith for an object A in a
JWA judgement model (C,N ) consists of an object V (t he verte x) to-
gether with a N-morphism V x A jump. such t hat t he fun ctions
9.6.4 Products-Interpreting Il
We first extend the notion of categorical produ ct (Def. 9.17( 1)) to a
situation where, as well as a category, t here are some right modules.
Definition 9.26 Let V be a category, an d let {OP}PEP be a family
of right V-m od ules. A product in (V , {OP}PEP) for a fam ily of V -
objects {Bdi ET consists of a V-obj ect V (t he vertex) and a morphism
11";
V • A i for each i E I , such t hat t he functions
Of course, in t he special case that the module fam ily is empty, Def. 9.26
gives t he usu al definition of categorical product in V . But , in general,
it ma kes a st ronger requi rement. We now adapt Def. 9.26 to t he locally
indexed setting .
Definition 9.27 Let C be a category, let V be a locally C-indexed cat-
egory, and let {OP}PEP be a fam ily of right V- modules. A product in
228 CA LL-B Y-PUSH- VALUE
ar e isomorphisms. D
• where the module family is singl eton {O} , giving a definition of prod-
uct in a CBPV judgement model (C ,V , 0) .
In the latter case, the isomorphism condition states that the fun ctions
ar e isomorphisms-we write qn~ Y and qn~ for the inverse. This con-
dition corresponds to the reversibl e derivations for the TI connecti ve in
CBPV:
.. . riA
- B " .. . ~"E!
f-k -~
"'" OX x lY
V x(Fl , Y) .z., "'"
--=---. OxY
Semantics in Element Style 229
~ j~
Ox(F 1, V) - TIiE! OXB i
commutes , by calculat ion. So if the top arrow is an isomorphism, t he
bottom arrow must be too. 0
Here is the semantics of TI, including complex stacks, using products.
[i'M] [M ]; O*7fi
C
[A{. .. , i.Mi , . . . } ] qIl Ai.[M i ]
[i :: K] (O*7fi) ; [K]
[{....«, wh e r e i :: nil, ... } i s L ]
k
(qIl Ai.[Ki ] ) ; [L]
We sha ll see in Sect. 11.3.4 that the na turality style description of a
product for {Bil i E1 in (V , {OP}P EP) is the vertex V together with iso-
morphisms
Vx(Y , V) rv II V x(Y , B i) natural in X and Y
i EI
are isomorphisms. o
Again, the two cases that are of interest are
In the latter case, the isomorphism condition states that the functions
are isomorphisms-we write q --+~ Y and q--+~ for the inverse. This con-
dition corresponds to the reversible derivations for the -+ connective in
CBPV:
f, AIQ f-k 11
r Ie f-k A -+ B
f,A f-C B
r f-c A -+ B
OxV - -_ . OXxAB
Ni xv ~ IT NixAi natural in X
iEI
Proposition 101 Any CBPV adjunction model, and indeed any strong
adjunction, is isomorphic to one in which the isomorphism
(9.1)
[thunk M] [M]
[force V] [V]
Despite Prop. 101, we do not incorporate this constraint into our defini-
tion of model. For while this constraint is reasonable for certain models
(e.g. Eilenberg-Moore models, as we shall see in Sect . 9.7.2) , for others,
such as continuations, games and possible worlds, requiring (9.1) to be
the identity would detract from the intuitiveness of the presentation.
Semantics in Element Styl e 235
9.6.8 Adjunction s
This section is abstract material. It provides some mathematical
conte xt to Def. 9.30.
To explain the "strong adjunction" terminology, recall t he following.
• two functors
----
F
B ·V
u
(U is called the right adjoint , F is called the left adjoint);
UFU - - -· U F
o
This definition makes sense in any 2-categories, so we can sp eak about
adjunctions in CL I Cat. The following result is proved in Sect . 11.6.1.
U'K U
KF F'
KE E' K
It is shown in [Mac Lane, 1971] t hat t here are two canonical ways of
resolving a monad in Cat: t he Eilenberg-Moore resolution , which is
termina l in Res(T ), and t he Kl eisli resolution, whi ch is initi al in Res(T )
(and every comparison fun ctor from it is fully fait hfu l). T hese met hods
exist also in CLICat , where C is any cartesian category. We look a t
Eilenberg-Moore resolu tions in Sect . 9.7.2 and Sect. 11.6.2, and at Kleisli
resolutions in Sect . 11.6.3.
9 .7 Examples
9.7.1 Trivial Models Of CBPV
We saw in Sect . 3.11 t he trivi alization transform from CBPV+ stacks
to t he x 2:IT -+ calculus. T his gives us t he following construc tion on
models.
Definition 9.34 Let C be a countably bicartesian closed category. We
obtain a CBPV adj unction mod el, called a trivial model, by setting t he
stack category to be self C and Ox Y to be Cx Y . Bot h U and F (on
objects) are t he identi ty. 0
Proof This follows from Cor . 104, because every algebra carrier is a
retract of a free algebra carrier [Mac Lane, 1971]. 0
N» = Ox Ans
A spec ial case of this const ruction is where t he CBPV model we begin
with is trivial in t he sense of Def. 9.34. T hus , we are given a countably
bicar tesian closed category C and a n object Ans, and we obtain a JWA
module model with value catego ry C, where Nx is set to be Cx Ans. In
that case, --,A is set to be A ~ Ans, since U is identi ty (on objects).
Som e aut hors e.g. [Hofmann, 1995] have generalized this by noticing
t hat C does not need to be countably bicartesian closed . It is su fficient
t hat C be countably distribut ive, and equipped wit h an expo nential from
A to Ans (whose ver tex we wri te --,A ) for every object A . Moreover ,
every J WA module mo del (C,N) is isomorphic to one arising from such
a (C, Ans)- to show t his, pu t Ans to be --,1. (More technically, t here is a
2-equivalence between t he 2-ca tegory of such (C, Ans) and t he 2-ca tegory
of JWA mod els.)
In t he oppos ite direction, we have a construc t ion corresponding to
the StkPS transform from CBPV+stacks to J WA. Suppose we have a
(A-set/cppo/domain enr iched ) JWA module model (C ,N) . We obtain
a (A-set/cppo/domain enr iched) CBPV adjunction model where
• t he value category is C
Ox Y =Nx xY
Semantics in Element St yle 239
Here are the required isomorphisms.
O~Y Ox xyAns
U' B U (B -+ Ans)
F'A U (A -+ Ans)
The mode l for erratic choice + divergence with may-t esting equiva-
lence presented in Sect . 5.5.4 is also a CBPV adj unct ion model.
O fY = O s x x Y
computations OS Z TIiEIO f x Ai Z
»..
~
X x I:iEIAi-
stacks I: iEIAi(Y ' Z)
~
TIi EI V XX Ai(Y ' Z)
product
computations Of TIiEIBi ~
TIiEIO fB i
stacks V x(Y, TIiEIBi) ~
TI i EI V x(Y, B i)
exponential
computations of A -+ B ~
O f XAB
stacks Vx(Y, A -+ B) ~
V Xx A(Y, B)
We have a similar const ruc t ion for JWA module models, correspond-
ing to a translation from JWA + global sto re to JWA. Given a JWA
module model (C,N) and an object S E ob C we obtain a JWA module
model with the sam e value category C by setting N i = N s -. x . We see
that (C,NS) has all the required isomorphisms.
jumpwith Cx-.(S x A) ~
Ni x A
distr. coproduct
values CXx I:iEIAi Y TIiEICx x AiY
~
nonret . commands NS ~
TIiEINi x Ai
Xx I:iEIA i
hw
O' YJ O' ZJ
Y w' • Z w'
(X f)*( hw')
O~Y = II O s w x x wY w
w EW
Nfc = II Nswxxw
w EW
9.8 Families
9.8.1 Composite Connectives
Certain composite connectives have reversible derivations, and it is
generally possible to describe these connectives directly in categorical
terms. We shall treat those examples which are necessary for describing
families constructions.
The most important example is in JWA, where the type 'Li EIAi
satisfies the following reversible derivation
... r, Ai f---n •.• iEI
r f---v 'LiE/Ai
the functions
ar e isomorphisms. o
Clearly, a JWA module mod el will have all countable coprod uc t-j umpwit hs ,
We shall see in Sect . 11.3.1 that , in naturality style, a copro duct-j umpwit h
for {Ad iEI is the vertex V tog ether with an isomorphism
Cx V ~ II Nx -.»; natural in X .
iEI
Similarly, in CBPV, the type PEi EIAi has the following reversible
derivation
. .. f , A i f-c Ii ... iEI
f lFL:iEIAi f-k B
are isomorphisms. o
Clearly a CBPV adjunction model will have all countabl e left copro duct-
adjunctives. We shall see in Sect. 11.3.2 that , in naturality style, a
left coproduct-adj unctive for {Ad i EI is the vertex V toget her with an
isomorphism
r v
I- U ITiEIB i
r ,A I-c B
r I- v U(A -t B)
ar e isomorphisms.
3 A right expone nti al-product-adjunctive for a family of (val-ob ject ,
comp-object ) pairs {(Ai, B i )}iEI consists of a val-object V (t he ver-
tex) together wit h a morphism V~~i ' B i , for each i E I , such
t hat t he fun ctions
natural in X .
D i EI L.j EJ CA;Bj
nonret . commands N'{ A;} ;EI D i EI N Ai
Identities and composit ion are defined in the obvious way. The connec-
tives ar e given by
{ AihEI X {Bj } j EJ {Ai X B j} (i,j) EI XJ
1 {I}
L.i EI{ A ij h EJ; { A ij} (i,j )E L.i EIJi
-,{Aih El {-'i El A i}
Semantics in Element Style 247
o
The key examples is the pointer game of model of JWA in Sect . 8.3. An
object is an arena, and the homsets are given by
1 X ' i EI
o l±J pt i E I
• all countable left copro duct -adj unct ives- we write F i EI A i for the ver-
tex
with t he obvi ous ident it ies, composition an d rein dexing . T he connectives are given
by
1 {I}
{A;} iEI X {Bj} j EJ {Ai x B j} (i,j )EIXJ
L: iEI{Aij h EJi {A ij }(.'t ,)' ) EL-t
"
i EI J t.
1 x
o l±J l±J
2 Take example (1), restrict ob e to stackf ree-in-value are nas (no root
and no successor of an A-token is an A-token) , and restrict ob D to
stackfree -in-stack arenas (no successor of an A-token is an A-tok en).
3 Take exa mple (2), and rest rict to P-b racketed st rategies. T his is the
model of Sect . 8.6.
4 Take exa mple (2), and use instead OP-bracket ed strategies, i.e. strate-
gies for t he game where bo th Player and Opponent are const ra ined
by bracketing.
In Sect . 11.6.4 we shall see more families constructions, for building
CBPV models out of CBN models and out of CBV mod els.
Chapt er 10
10.1 Introduction
We have seen that any cartesian model gives a sound semant ics for
x -calculus, any CBPV adj unction mod el gives a sound semantics for
CBPV, etc. Bu t it is useful to know t hat eve ry model of x -calculus is a
cartesian category, so t hat when we search for cartesian categories, we
are not excluding a potentially interesting model.
To exp ress such a st atem ent, we have to say what we mean by a
"model of x -calculus" , an d t hen our categorical semantics gives a fun ctor
from a category of cart esian categories to a category of models. Our
required resul t will assert that t his fun ctor is an equivalence.
In t his cha pter , we go t hro ugh t his theory for cartesian categories and
x -calculus. We then briefly give ana logous acco unts for CBP V and for
JWA; t hey are essent ially t he same st ory.
We shall see in Sect. 10.2.4 t hat a serio us drawback of our account
is t hat we have to fix object st ruc t ure . So, in a sit uation where the
operat ions on obj ect s (in the catego rical st ruc t ure ) are not the same as
t he operations on types (in the language) , our account would not be
suitable. Fortunately, t his problem does not arise for our cate gorical
semantics. But fur ther work is needed to address it.
249
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
250 CALL-BY-PUSH- VAL UE
We will begin by stating a plau sible result , and then consider what
definitions ar e required to make it true. Here is the result:
Proposition 106 Mod els of x-calculus and cartesian categories are
equivalent. 0
• an obj ect 1;
• a binary operation x : Tob X Tob - T Tob
o
We can now repl ace Prop. 106 by the following stronger st atement ;
like Prop. 106 it is not precise bec ause we have not yet defined "mo del
of x -calculus" .
Proposition 107 Let T be a x obj ect structure. Then
are equivalent. o
This statement will be easier to make precise than Prop. 106. We will
form two categories and they will be equivalent .
For the purposes of Prop. 107, we need a very specific definition of
cartesian ca tegory.
Definition 10.2 1 A cartesian category is a category C with a distin-
guished te rminal obj ect and distinguished bina ry product s.
2 The objec t structure of a cartesian category C is the x obj ect structure
(ob C, 1, x) where
• 1 is the distingu ished terminal obj ect of C;
• A X A' is the vertex of the distinguished product of t he C-obj ects
A and A' .
o
All Models Are Cat egorical Models 251
We write " ' 8 for the least congruence on these terms containing t he
equat ional laws of x -calculus.
Proposition 108 The congruence "'8 is a hypercongruence. D
a
• If s • s' is a multigraph homomorphism, t hen T a repl aces
each occurrence of a fun ction symbol f in a term built from s by
a]: Thus it takes f(M o, . . . , Mn-t} , where f is an edge in s , to
a(J)((Ta)Mo, . .. , (Ta)Mn - 1 ) , and it preserves all other term con-
structors .
We omit the proof t hat T preserves identity and compos ition, 7] and
It are natural and (T, 7], It) satisfies all t he monad laws. These are all
st raightforward inductions.
A ll Models Are Cat egorical Mod els 253
Cart.Cat., ~ Direct,
Proof (outline)
id Oxo
/*g Og(J(xo ))
1f Opm Xo as (Xi, X2). Xl
n' Opm xo as (Xl,X2). x2
(f ,g) O(f( xo) ,g(xo) )
and all requi red equations verified.
• a value object 1
K M. K
n il M
L
[.J t o x . M :: K (M to x. N) . K
[.J t o x. M :: (K -tt L )
i :: K (i'M) . K
i :: (K -tt L)
V :: K (V 'M) . K
V: : (K -tt L)
let V be x . K let V be x . (M . K )
let V be x . (K -ttL )
pm V as { ... , (i , x ).K i , . . .} pm V as { ... , (i, x ).(M . K i ), .. .}
pm V as { . . . ,(i, x). K i-tt L, ... }
pm V as (x , y ).K pm V as (x , y ).(M • K )
pm V as (x, y ). (K -ttL )
K where nil is K' (M • K) • K'
K where nil i s (K' -ttL)
{. .. , K i where i :: n il , .. .} i s K ' (A{ , i .(M . K i) , .. .}) . K'
{ , K, where i :: nil , .. .} is (K' -tt L )
K where x :: nil i s K ' (Ax. (M . K )) • K'
K whe re x :: nil i s (K' -ttL )
f evo, . . . , VT- d [']) :: K f evo, . .. , VT- dM) • K
f evo, . . . , VT- d [' ]) :: (K -ttL )
Figure 10.2. Dism ant ling and Concatenation (Including Com plex Stacks And Oper-
ation Symbols)
All Models Ar-e Cat egorical Models 257
Our next st ep is to write " ' 8 for the least congruence on the terms built
from s cont aining the equa t ional laws of x -calculus.
Proposition 110 The congruence e- is a hyp ercongruence. D
• 'Tfs takes
f in s(Ao, , A n- 1 f-v B) to t he value f(xo , . . . , xn-t}
f in s(A o, , A n - 1 f-v C) to the computation f(xo , ... , Xn - l)
fin s(Ao, , An- l IB f-k C) to the st ack f(xo , ... , xn-l l[- ]) "
nil .
It preserves all other term const ru ctors; for example, it maps (M , M')
to ((fJ,s)M, (fJ,s)M') .
Proof (outline)
CA B to be s(A f-v B)
'DA(B , C ) to be s(AIB f-k C)
oAB to be s(A f-c B)
The combinators are defined following Fig. 10.3, and all the required
equat ions verified.
o
All Models A re Cat egorical Models 259
id (in C) (h o
r 9 (g a C- or V-morphism) Og(f(xo))
r h (h a V-morphism) Oh(f(xo)I[·]) :: nil
g j h (g an V-morphism) Oh(xolg(xo))
id (in V) Onil
h ; k (h a V-morphism) Oh(xol[']) :: k(xol[']) :: nil
Opm Xo as (Xl ,X2) . Xl
Opm Xo as (Xl ,X2) . X2
(f ,g) O(f(xo) , g(xo))
force Oforce Xo
qU f Othunk f(x o)
return Oreturn Xo
qFf 0[·] to xi . f( (x o, Xl) ) :: nil
in; O(i , xo)
qI: >.i.gi Opm Xo as {. . . , (Xl , (i , X2 ) )./i ( (Xl, X2)) , . .. }
11"; Oi :: nil
q0>.i .gi ss.
an V-morphism) O>.{ , i. gi (XO), ... }
q0>'i .hi (hi a V-morphism) O{ , (hi(xol[']) :: nil) where i :: nil , . .. } is nil
ev Oxo :: nil
q---> 9 (g a n V- morphism) O>'X l .g((XO, Xl))
q" h (h a V-morphism) O(h((xo, xdl[']) :: nil) where Xl :: nil is nil
r I- Vo : A o . . .
V
r I- Vr -
V
l : Ar - l
v
f E 8 (A o, . . . , A r - l l-" B)
r I- f( Vo, . .. , Vr- l) : B
r I-v Vo : A o . .. r I-v Vr - l : Ar - l
f E 8 (A o, ... , A r - l 1-")
r 1-" f (Vo, ... , Vr- l)
260 CALL-BY-PUSH- VALUE
This is proved in the same way as Prop. 109 and Prop. 111.
10.5 Enrichment
In a sim ilar manner to Prop. 111, we can show t hat our categorical
semantics of CBPV + stacks + print in an A-set enr iched CBPV ad -
junction model is an equivalence. And in a simi lar mann er to Prop. 112,
we can show that our categorical semantics of JWA + print in an A -set
enriched JWA module model is an equivalence.
It appears that these 2 theorems could be generalized from printing
to other strong monads sp ecified by algebraic operations an d equati ons
in the manner of [Plotkin and Power , 2002]; but we do not trea t this
here.
Chapter 11
REPRESENTING OBJECTS
11.1 Introduction
A key concept of category theory is that of representabl e object (or
representation , or un iversal elem ent) . This concept can be defined in
both element style and naturality style-the equivalence of the two defi-
nitions follows from the Yoneda Lemma . So by describing something as
a rep resentable object, we automatically obtain both an element-style
and a naturality-style description.
The main goal of this chapter is to des cribe each of our connectives as
a rep resenting object for a sui table functor. In each case we recover the
element style defin ition given in Chap. 9 as well as the naturality style
definition briefly mentioned there.
It is because our connect ives are representing objects that they are
automatically unique up to unique isomorphism, and there is no need
for any coherence conditions su ch as are required in [Selinger, 2001;
Thielecke, 1997b] and in models for linear logic. c
The functors that our connect ives represent are built out of hom -
set functors. We described the homset functor for ordinary categories
(Def. 9.4) and locally indexed categories (Def, 9.12) , and these suffice
for most of our connectives. But for distributive coproducts and CBPV
products and exponentials, we require other homs et functors.
261
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
262 CA LL-BY-PUSH- VALUE
• For CBPV product s and expo nent ials, we will see in Sect . 11.3.4
how to glue right modules to a category (in t he manner of [Carbo ni
et al., 1998]) and give an appropriate homset fun ctor , enabling us to
cha racterize t hese structures as representing objects.
• T he most difficul t case is in Sect. 11.3.5, where we t reat a carte-
sian category with some left modules. This was t he st ructure used
in Sect. 9.6.6 to define distributive copro ducts in JWA and CBPV.
Again by gluein g modules, we define a suitable homset fun ctor, and
t hen we can characterize a distributive coprod uct as a representing
object.
We then look at parametrized represe n tabilit y, which show us how to
make each connective int o a fun ctor. We use this firstly to complete
our definition of possible world semantics that we began in Sect . 9.7.6,
and secondly to show that a st rong adj unct ion is indeed an adjunction
(Prop. 102).
Finally, we look at CBV and CBN. We give a categorical struct ure
for each, and see how, for a given CBPV adj unction mod el, we interpret
CB V inside the Kleisli part and CBN ins ide t he co-Kleisli part.
Note Some aut hors use t he te rm "represent at ion" instead of "repre-
senting object" , reservin g t he lat ter term for what we have called t he
vertex. However , "representation" has many ot her meanings.
F inally, we can adapt Prop. 113 and P rop. 114 to allow us to use the
idiom "a x (Y, Z ) is natural in X , Y and Z " .
Proposition 115 Let 1) and 1)' be locally C-indexed categories, and
let F and G be functors from opGr(1) x 1)') to E. Suppose we ar e given
a function Fx(Y , Z ) QX (r,~! Gx(Y , Z ), for each X E ob C, Y E ob 1)
and Z E ob 1)' . T hen a is a natural transformation from F to G iff
• a x (Y , Z) is na tural in X E CoP for each Y E ob 1) and Z E ob 1)'
• ax(Y , Z) is nat ural in Y E 1)x for each X E ob C and Z E ob 1)'
• a x (Y , Z) is natural in Z E 1)'x for each X E ob C and Y E ob 1).
D
q~
opGr((self Ct ) ~ Cop
264 CALL-BY-PUSH- VALUE
Here , the functor q takes (X, Y) to x Y and (k ,1) to k7r'* f. (We could
remove all these - op marks by using the Groth endieck construction rather
than opGrothendieck here.)
We make use of . in defining the following most important functor.
Definition 11.1 Let V be a locally C-indexed category, where C is
cartesian. We write growall for the functor
opGr((self C)OP x V) - - opGr V
op Gr V -opGr i
op Gr (1 x V) opGr(objA xV)
• op Gr (( se If C)OP x V) -growall op Gr V
Explicitly, this is given by
opGr V - opGr V
V(iV, X) a: . FX natural in X.
If we write the representing objects in element style as (V, v) and (V' , v')
then f is characterized by (F~f)v = v'. 0
Proof This is proved the same way as Prop. 121 below; in fact it is a
special case. 0
ar e isomorphisms.
o
P roposit io n 118 The naturality style and element style formulations
of Def. 11.5 are equivalent , and a global representing obj ect is unique
up to unique isomorphism. 0
But, in fact , there is a third homset functor hom xc sp ecial to carte sian
categori es:
opGr self C - Set
xY I ) CxY
X X'xY CxY 9
X' Y'
h I ) Ckh
Cx 'Y' (id,(k;g)) *h
I
This fun ctor provides all t he homset information we need . From it , we
can recover horn.;
growall (11.1)
• a morphism c p - - --+-
. kZ is an OP-morphism - -- ---+-
. Z
• identi ties and compos it ion are defined as in V and t he various OP.
o
We can see tha t this achieves our goal, becau se
(11.3)
We ca n use Def. 11.9 to t urn Def. 9.26 into naturali ty sty le.
x
• a morphism cp - - -+. kZ is an OP- morphism - - ---+
. Z
x X
o
We can see that this achieves our goal , because
hom~V(ky, Z)
hom~V(Cp, Z)
Furthermore we have
(11.4)
We can use this to adapt Def. 9.27 and Def. 9.28 to naturality style.
Definition 11.13 Let C be a cartesian category. Let V be a locally
C-indexed category (whose obj ects we underline) and {OP}P EP a family
of right V-modules.
Representing Objects 271
f • vz 9
• the composite of vY
X X
• vW is (Jr, J) *g
f • vz 9
• the composite of vY
X X
• :Up is (Jr, J) *9
k f
• the reindexing along X ' • X of vy
X
• vz is (k xY) *j
k f
• t he reindexing along X' • X ofVY x • :Up is (kx Y)* j.
We wr ite v- for t he fully faithful fun ctor from self C to self CN. 0
xY 1-
1 - ------+) C Y
X
k It 1-1 - - --t, C, h 1
x' y' Cx, y' (id,(k;g))*h
X X' xY Cx Y 9
growall hOmsell CN
hom x CN
opGr self cN - - - - -- - - - -- - ----+
. Set
and we write growhom x CN for t he composite of this. For each C-obj ect
A , we therefore have
_ ~
Cx V(I) "'" Fx _
I natural in X
276 CA LL-B Y-PUSH- VA LUE
o
P roof Using (11.6) , it is easy but tedious to check tha t V is a fun ct or
and that a is natural. Conversely, suppose we have a fun ctor V making
f
a natural. Then for each -I A • -J we have
Cx UB ~ O x B
natural in B as well as in X .
R epresenting Objects 277
natural in A as well as X.
o
x
• (A X A')g is defined to be Ag x A'g using C x C - -_ . C.
x
• (A x A')g is defined to be A g x A'g using C x C - - _ . C.
Defining all the homset operations in the possible world model and
proving that all t he required equat ions hold can be done by exp ressing
them as diagrams of homsets in the original model. We use all the natu-
ralities in Prop. 120, Cor. 123 and Cor. 125 together with t he equat ions
CjO*jg CU,g)
j· O*jg j xg
An alte rnative approach is to work in the term calc ulus , exploit ing our
kn owledge t hat all t he equations of CBPV + stacks are validated in a
CBPV adj unction mod el, and all t he equations of J WA are validated in
a J WA mo dule mod el.
----
F
B •V
u
• an isomorphism
u
• a functor 1) • B
• for each Y E ob B, a representing object for B(Y, U -), whose
vertex we call FY.
3 An adjunction from B to 1) consists of
F
• a functor B • 1)
• for each Z E ob 1) a representing object for 1)(F-, Z), whose
vertex we call U Z .
4 An adjunction from B to 1) consists of
• two functions
F
ob B • ob 1)
u
• for each X E ob Band Z E ob 1) a bijection
B(Y, UZ) ~ 1)(FY, Z)
f
such that, for each B-morphism Y' - - ---. Y and each C-morphism
Z g . Z', the following commutes:
,
B(Y, UZ) ~ 1)(FY, Z)
BdY',UZ)
yY 0'
~
'0
1)(FY, Z')
~..L <><t'
, "\lV ~0'
y
Proposition 126 Def. 11.17( 1)- (5) and Def. 9.33 are all equivalent . D
• a bijection
Note In the lit erature, the condit ion of naturality in I' is usually
replaced by the B eck-Ch evalley condition . The two conditions
ar e equivalent (assuming naturality in Y and Z) , but we use the
former because we consider it to be mor e intuitive.
such that , for each B-m orphism Y' - -- -. Y and each C-morphism
9
x
Bx(Y' , UZ)
'
' 'r~--1-
<;' t'
0'
~..J ~+
V x (FY' , _
Z')~Bx (Y' ,U_
Z')
Strong Adjunctions
We now prove Prop. 102, using Def. 11.18(2) to define adjunction
between self C and V.
Proo] Given a strong adj unction from C to V , we const ruct U as in
Cor . 125(3). Given a C-obje ct A , we construct an isomorphism
as t he composite
opGr U
opGr 'D • opGr self C
'D _ (FA , - )
~ opGr U
opGr 'D -
;:/
opGr self C self C_ ( A ,- )
Se t = == Se t = = = = Se t = = = = Se t
2 Let (C, V , 0) be a st rong adj unction. Write (T, 'fl, p" t ) for t he strong
monad it gives rise to .
is the identity. 0
It follows from this that if (V, 0) is a CBPV adjunction model, then
EM(T) will have all countable distributive coproducts, and it will have
all finite products of comp-objects by Prop. 103(2). If all idempotents
split in C, then Cor. 105 tells us that EM(T) must be a CBPV adjunction
model. Otherwise, it might not be .
given by
ob V' ob B
V'( A ,B) V(F A , F B)
M' (A , B ) = M (A , F B )
F 'A A
U'B UFB
with its identities, composit ion, isomorphisms etc. all inheri ted from
(B , V , M , U, F) . Dually, we define its co-Kl eisli part (B' , V , M ' , U' , F ')
to the co-Kleisli adjunction given by
ob B' ob V
B'(G, D ) B(UG, UD )
M '(G ,D) = M(UG,D)
U'D D
F'G FUG
with all structure inherited. o
Proposition 129 An adj unction (B, V, M , U, F) and its Kleisli part
(C, V , M , U', F ' ) give rise to t he same monad. The unique compari-
son functor is given by F on objects, and t he identity on morp hisms.
Similarly for the co-Kleisli part. 0
B[_," ,
,
1-
u ,
, "
>~ V
Kleisli I- '~~' -1 co-K leisli
, ,
, ,
, ,
, ,
K ' '0 £
Strong Adjunctions
We shall see that the notions of Kleisli adjunction, co-Kleisli adjunc-
tion and Kleisli part apply straightforwardly to strong adjunctions, but
not the notion of co-K leisli part.
Definition 11.21 1 A strong adj unction (C, V , 0 , U, F) from C to V
is Kl eisli iff ob C = ob V and t he left adjoint F is ident ity-on-objects.
286 CALL-BY-PUSH- VALUE
1 If we are modelling finit ely wide synt ax only, it suffices to require all right ex ponent ial-
adjunctives, as in [Levy et al., 2003J. This automaticall y gives us all finite rig ht expone nt ial-
prod uct- adj uncti ves, usin g th e finit e products in C.
288 CALL-B Y-PUSH- VALUE
• a right adj unct ive for each obj ect A , whose ver tex is A
• all count able left copro duct-adj unct ives, whose vertex we wri te as
L iE/Ai
• all countable products and exponentials.
o
In such a mod el, the left copro duct-adj unct ives model sum types in CB N.
We now see that the Kleisli and co-Kleisli parts of a CBPV model do
ind eed have these st ru ct ures .
Proposition 131 1 A CBV adjunction model is a Kleisli strong ad-
junction. The Kleisli part of any (A-set/cppo/domain enriched)
CBPV adjunction model (C , D, G) is a (A-s et/cppo/domain enr iched )
CBV adjunction model.
2 A CBN adjunction model is a co-Kleisli st rong adj unct ion . The
co-Kleisli part of any (A-set/cppo/domain enr iched ) CBPV adjunc-
tion model (C , D, G) -which is well defined because D must have
finit e products-is a (A-set/cppo/domain enr iched) CB N adj unct ion
mod el.
o
This is summarized by t he slogan "CBV is Kleisli, CBN is co-Kleisli" .
A spec ial case is where t he CBP V adjunction model is a cont inuation
mod el, obtained from t he JWA module model (C ,N) . In this case,
• t he denotation of a CBV term is a N-morphism from [r] x .[A]
• t he denotation of a CB N term is a N-morphism from -,[I] x [B ].
This is described in [Streicher and Reus, 1998] as "duality between CBV
and CB N, with control ope rators" , and the theme is further developed
in [Curien and Herb elin, 2000; Selinger , 2001; Wadler , 2003]. It is a
consequence of the duality between valu es and stacks, and between F
and U, in a continuation model.
C'{A;}iEI {B
- j }-
] EJ III:CAiB j
iEl j EJ
tr.{A;}iEI (B
- , -C) II V Ai(B , C)
iEI
O{ A;}iEI B = II
iEI
O AiB j
with the evident identi ti es, composit ion and reindexing. The connectives
are given by
1 {1}
{ A i h El x {B j h EJ { A i x B j }c i ,j )El XJ
L iEl { A ij }j EJi {Aij} (i,j )E L iElJi
{AJ i El -t B ITiEl (A i -t B )
UB {B}
F { A i h El L iElAi
and comp-object product s as in t he CBN model. o
Clearly the co-Kleisli part of such a CBPV model is isomorphic to our
original CBN adjunction mod el.
The predomain/domain CBPV model is an instance of this construc-
tion , because we defined a predomain to be any cpo that is a countable
disjoint union of domains. This construction is used also in [Abramsky
and McCusker, 1998J to build Q/ A-lab elled pointer games. Indeed , given
a CBP V pre-families model, we can first obtain a CBN adj unction model
and t hen a CBPV adjunction model, and t his compos it e construction is
t he same as Def. 9.4l.
T he construction from a CBV model is more complicated. The idea
is t hat, since every computation ty pe in CBP V is isomorphic to one
of the form ITiEl (A i -t F Bi)- alb eit not uniquely-we can simulate a
comp-object as a family of pairs of val-obj ects.
290 CALL-BY-PUSH- VALUE
C~B CAB
1)~ ({ in.;Cd h Ef, {(Dj , Ej)} j EJ) II :L) CA XDj B i x 1)A x Dj ic; E j )
j EJ iEI
II O A XDj E j
j EJ
with the obvious identi t ies, composit ion and reind exing. The connectives
ar e given by
Clearly the Kleisli part of this CBPV model is isomorphic to our original
CBV adj unction model.
IV
CONCLUSIONS
Chapter 12
• the model for input based on Moggi's input monad [Moggi, 1991]
• the constrained model for finite erratic choice based on the strong
monad Pfin on Set, described in Sect. 5.5.3;
293
P B Levy, Call-By-Push-Value
© Springer Science+Business Media Dordrecht 2003
294 CALL-BY-PUSH- VALUE
(A -+ B)w = r
i.:
(Aw' -+ Bw')
(We are underlining the types because they denote pointed cpos.)
296 CALL-BY-PUSH- VA LUE
Much is lost in t he translation from CBN into t his lan guage. For
exa mple, O'He arn's sem an tics of global store
[A -t C B N B ] = (8 -t [A] ) -t [B ]
an d t he Streicher-Reu s conti nuation semantics
[A -t C B N B] = (---,[A]) x [B ]
do not exhibit the linear decomposition. On e reason for this is that , as
we said in Sect . 1.2.3, t he linear A-calculus ass umes commutat ivity of
effects .
For t he same reason, t he pointer game mod el for CB N (given by the
CBPV model of Ch ap. 8) does not exhibit the linear decomposition of
-tC B N . This is perhaps sur prising, given the influence of linear logic on
t he development of game semantics.
12.4.2 Polymorphism
From an ope rational perspective, we sp ecul ate that we could add poly-
morphism to CBPV by adding the following type construc tors:
Let {ri}; EI be a hyper-arity. We define the tuple connective for this hyper-
arity as follows . Suppose that for each i E I we have a finite sequence of types
L..iEIE$ r i A i i . ThIS
AiO , .. . , A i (ri- I ) ' Then we form the tuple type ",Xj . d enotes t h e set
APPENDIX A : Technical Treatment of CBV and CBN 301
:LiE/ ([Ai O] x . .. X [Ai (r. -1) ]), or, isomorphically, t he set of t uples (i , ao,·· · , ari-d ,
wh ere aj E [A i j l
When eac h r i = 1 t his con nective is t he usual sum :LiE/ Ai. In par t icular, wh en
I = {O, I} we obtain t he binary sum A + B and wh en I is empty we obtain t he zero
type O.
When I is a sing leton set {*} and r , = 2, we obtain a pat t ern- mat ch binar y
product ty pe A x B . Sim ilar ly, when I is a singleton set {*} and r; = 0, we obtain
t he patt ern-m atch-unit ty pe 1.
In t he effect -free setting , :L, x and 1 are sufficient to give all t uple ty pes b ecau se
of t his decomposit ion :
", Xi ESri A i j =
L.JiE/ L.JiE/ (A i O X
~ '"
" ' X
A
i (ri- )
I) (A. I)
However , it is not apparent a priori wh ether (A.I ) will remain valid when we add
effects. This is the reason for providing general t u ple ty pe s. (In fact , (A.1) is valid in
C BV bu t not in CBN .)
An other spec ial case of t uple typ es is when eac h r i = O. Such a t uple typ e is
called a ground type. Its closed te rms are of t he form (i) , for i E I; sometimes we
wri t e t his just as i. In par ticular whe n I = {true, false} we call this ty pe bool and
when I = N we ca ll t his ty pe nat . We wri t e true for (t rue) , false for (fa lse) and
i f M then N else N ' for pm M as {(true). N , (fa lse) . N'} .
However , it is not apparent a priori whe ther (A .2) will rem ain valid when we add
effects . T his is t he reason for providing general function ty pes . (In fact , (A.2) is valid
in CBN bu t not in CBV.)
" , X j E $r 'A
Types A ::= L.J i EI 1 ij
T erms
r f- M : A r ,x : A f- N : B
r , x: A, r ' f- x : A r f- let M be x . N : B
r f- (
A
l, M o, . . . ,Mri - I :
) ", X j E $r i
LJ i E/
A ij
r L '{ . . . ,
IA L 'Z' , xo, . . . , Xri -l. M t·,· · · } .. r r --+
iE jI E $r
i A IJ
· ·B 1·
A
r f- M« : AiO ... r f- M r, - I : A i (ri- I ) r f- N:
--+ j E $ r i
r r iE / ijBi
r f- L i , M« , . . . , M ri _ 1 'N : B,
,B-la w s
let M be x . N
pm (i ,Afj) as {... , (i, xj ).Ni , ... }
a , Afj'A{ . . . , L i , xj .N i , . .. }
1]-laws
N [M / z ] pm M as {. . . , (i, xj) .1j(i , xj)/z]' ... }
M A{... , L i , xj .(Li , x j'M) , . .. }
coarse-grain
lazy
/
CBV
fin~ifvain / B
N'
f ~BPV
fine-grain
CBV
+ complex
values"
CBPV
+ complex
values"
• t he t rans lation pr eserves provable equa lity (whe re t he source lan guage has an
equat ional t heory)
• the translation preserves and reflects ope rational semantics for gro und terms
• t he translation reflects observational equivalence.
We would like each trans lation to have t he following propert ies:
• t he translation com mutes exac t ly with subst it ution and weakening
• t he translation preserves and reflects ope rational semantics for all terms .
However , t hese pro pe rties usu ally fail, and t o achieve t hem we have t o extend t he
trans lation from a fun ct ion between terms t o a relati on between terms .
T he t wo t ranslations int o CBP yl have t he following pr op er ti es:
• every type in t he target lan gu age is isomorphic t o t he t ranslation of some ty pe in
t he source lan gu age
• every term in t he target langu age (of appropriate ty pe and context) is provably
equal t o t he tran slati on of some term in t he source langu age
• t he trans lation reflects provable equality
• t he trans lation preserves observationa l equivalence (full abst raction ).
A.3 Call-By-Value
A .3.1 Coarse-Grain Call-By-Value
For CG-CBY we evaluate t o t he following term in al closed te rms :
Deno t ational semantics for printing is given as in Sect . 1.6.2 . The ty pe constructors
are inter preted as follows.
M JJ- (i,~)
pm M a s {. . . , (i , ij ).N i , . . .} JJ- T
r f-v V : A
wh ich resp ect ively say t hat V is a va lue of type A and t hat M is a returner of typ e
A (i.e, M ret urns a value of t yp e A ).
The calculus t hat t his lea ds t o is called fin e-grain en V. The terms an d big- st ep se-
m antics are given in F ig. A .4. We do not evaluate values , so t he op er ati on al semantics
is defin ed only on returner s.
It is conve n ient in FG -CBV to write TA as sy ntact ic sug ar for I1 E{*}A. Thus in
t he print ing sem antics T A denot es A * x [A ], an d in t he Scott semantics T A den ot es
[A ]l- . We write thunk M for A *.M an d force V for *'V . Because of t he im p ort ance
of T A , we present ru les and equat ions for it exp licit ly, even t ho ug h t hey are j ust
sp ecia l cases of t he rules a nd equ ations for funct ion ty pes.
Note t hat in FG-CBV let is used only for binding ide ntifiers. The sequencing of
returner s, wh ich was wr itten in CG -CBV as let M be x . N is in FG-CBV wri t t en
306 CALL-BY-PUSH- VAL UE
r f-v V : A r ,x : A f-P M : B
r L V
r
('Z, =7)
Vj
" , X j E $r iA
: LJ i E I ij
-------,----t
r f-v V . " , X j E $ r i A ·· ... r , Xj : A i j f-P M i : B ... i EI
. LJ i E I 'J
r LV
r
'{
A
r:
••• , L ~, Xj .
:::-+ M i , · · ·
} :
n --+ j E $ r i
i EI
A ij B i
r LV
r \Ij :
A i j) r LV
r W :n --+j E $ r .
i EI '
A i j Bi
M[V/x].J,J. W
let V be x. M .J,J. W
r f-P print c. M : A
and adapt and t hen exte nd t he big-step sem ant ics exact ly as in Sect . 2.4.1. We t he n
ob t ain :
Proposition 133 For every closed returner M , t here is a un iqu e m , V such t hat
M .u.m,v. 0
Observational Equivalence
Definition A.2 Given two returners I' f-P M , M ' : B , we say that
1 M ~ground M ' wh en for all ground returner conte xts C[·], C[M] .u. m , i iff C[M'] .u.
m ,i
2 M ~anytype M' when for all returner conte xts C[·] of any type, C[M] .u. m , T for
som e T iff C[M'].u. m , T for some T
Similarly for valu es. o
Proposition 134 The two rela tions ~ground and ~anytype ar e the same . o
r f-v V : A r ,x : A f-v W : A
r f-v let V be x . W : A
.a- la w s
l e t V be x . M M[V/xJ
l e t V be x. W W[V/xJ
(r e t ur n V) t o x. M M[V/xl
pm (i, ~) as { , (i, X"j ).Mi , } M;(Vj/x{ J
pm (i, ~) as { ,(i, X"j) .Wi, } W;[Vj/X{J
Li, ~ 'A{ . . . , a , X"j .Mi, .. .} M;(Vj/x jJ
for ce thunk M M
1)- la ws
M M to x . return x
M[V/ z] pm V as { , (i, X"j) .M[(i, X"j) / z]' }
W[V / zJ pm V as { , (i, X"j ).WJ (i, X"j )/ zJ, }
V A{. . . ,Li, X"j .(Li, x/ V), .. .}
V thunk force V
print law s
(print c. M) to x . N pri nt c. (M to x . N )
The equat ion for print is of course spec ific t o our exa m ple effect, bu t there ar e di-
rectly analogous eq uations for man y other effects. For example, if we wer e considering
div ergence, we would have an equation
d i verge to x . M = diverge
We call this theory (without the print equation) the CBV equational theory.
Proposi tio n 135 1 T here is an effect ive procedure that given a ret urn er I' f-P M :
A, possibly containing complex values , returns a returner I' f-P 1\1 : A without
complex values , such that M = 1\1 is provable.
2 There is an effective procedure that , given a closed value f-v V : A, possibly
cont aining complex values, returns a closed value f-v V : A witho ut complex
valu es, such that V = V is provable.
o
We now address the tec hnical pr op erti es of t he t rans lation. It neither commutes
with substitution nor preserves op erational sem an t ics.
substitution It is not t he case t hat (M[V/x])'g and M cg[vcgv.l/x] are the same term
(although t hey will are provably equa l in the CBV equational theory of Fig. A.5).
To see t his, let M be x and V b e (0, (0)) , where 0 is a tag. Then
g
(M[V/x])C return (0) to x. return (0 , x)
M cg[V cgv.1 / x] return (0 , (0))
operational semantics It is not t he case t hat M -lJ. m, V implies Mcg -lJ. m , V cgv.' .
For examp le, let M b e let (0 , (0)) be x. A * .x.
T he issu e is t hat CG-C BV cannot rec ognize t hat what is substit ute d is not a cer tai n
kind of returner (t o be t rivially reevalu at ed when required) bu t somet hing genuinely
different - a value .
To salvage wha t we can, we pro ceed as follows. First , we writ e t he two t rans lations
as relations I-t cg and I-t cgv•1 from CG-C BV t o FG -CBV te rms . We can pr esent F ig. A.6
by rules suc h as t hese :
2 If M H cg M' and M' .ij. V ' , t hen, for som e V , M .ij. V and V H cgval V'.
o
S return V I l e t V be x . S IS to x . S
I pm V as { . . . , (i , xj ).Si, . .. }
In summ ary, a return er is sa fe iff, inside it , every application occ urs in t he scope of a
A.
cg
Lemma 139 Su ppo se A o , .. . , A n - 1 f- M H M ' : B . Then
1 M is safe iff M' is safe.
2 Suppose M is safe and Uo H cgval U~ , ... , Un-l H cgval o:. , i U, and U; may not
be safe).
-----t ~]'
• If M [Ui/X;] .ij. V , t he n , for some V , , M , [Ud Xi .ij. V a nd V H
c al
gv V,.
• If M'[U; /x : ].ij. V ' , t hen, for some V , M [U;j x:].ij. V and V Hcgval V' .
We prove t his by induction on M H cg M ' . F inally we prove Prop . 138 by ind uction
on M.ij. V (for (1)) and on M ' .ij. Vi (for (2)) .
APPENDIX A : Technical Treatment of CBV and CBN 311
N [M / x] .l).T
let M be x. N .l). T
L.i,M~i'N .l).T
A.4 Call-By-Name
For CBN we evaluate t o t he following terminal closed terms:
Proposition 140 For each closed te r m M , we have M .l). T for a unique term ina l
te r m T . 0
To add our exam ple effect , we adapt and extend F ig. A.7 exactly as in Sect . 2.4.1.
We then have
Proposition 141 For every closed t erm M , t here is a unique m , T such t hat M .l).
m ,T . 0
(3- la w s
let M be x . N
pm (i, Mj ) a s {. . . , (i , x)) .Ni , . . .}
Lt, Mj'A{ ... , a , x) .N i , .. .}
7]-l a ws
M A{. . . , Li, x) .(L i , x)'M ), .. .}
p a t t ern-ma t ching la w s
M pm M a s { , (i, x) ).(i, x) ), }
pm M as {.. . , (i , x} ) .(pm N; as { , (k , yt .Pk, . . .}), }
pm (pm M as {. . . , (i , x}) .Ni , }) as { , (k , yt) .Pk , ... }
pm M as { . . . , (i, x} ).A{ . . . , L k, yt .Nik, } , ... }
= A{. .. ,Lk,yt.(pmM as { , (i, x} ).N i k, . . .}) , . . .}
print laws
print c: (pm M as { . . :,~ ,x}).Ni ' .. .}) pm (pr i nt c.. !1!1
as ~ . .. , (i , x} ).Ni ' . . .}
pnnt c. A{ ... , L z, xj .Mi, . .. } A{. . . , L z, xj .(pn nt c. Mi) , ... }
D efinit io n A.4
A value is a lazy term wh ose su bst it ution instances ar e all terminal. Unlike in CBV
an identifier is not a valu e becau se an y term can be substituted for it , so value s are
just the following:
A returner is a lazy term (so-called beca use a closed returner returns a closed value) .
o
We translate t he lazy language into FG-CBV in Fig. A.9. The t ranslation is
essent ially that given in [R atcliff and Danvy, 1997]. Like t he trans lation from CG -
CBV to FG -CBV, t he translation on terms is defined in two parts: _ lazy is defined on
returners , and _ lazyvaJ is defined on valu es.
The t rans lat ion is motivated as follows.
• Id en tifiers in the lazy lan guage ar e bound to unevalu at ed te r ms , so we regar d
t hem (from a CBV persp ective) as b ound to t hunks.
• Similarly, t u ple-com ponents and ope rands in t he lazy language ar e un evaluated
te rms , so we regard t hem as t hunks.
APPENDIX A : Technical Treatment of CBV and CBN 313
• Consequently, identifiers, t uple-comp onents and op erands all have ty pe of t he
form T A- a thunk type .
T he t ranslation from lazy to FG-CBV is very similar to t he t ranslation from CB N to
CBPV.
Figure A .9. Translat ion from lazy to FG-CBV: t yp es, returners, valu es
T his t ranslation does not commute with substi tution or pr eserv e op erational se-
man ti cs precisely- onl y up t o the pr efix force thunk. (Recall that force thunk M =
M is provabl e in t he CBV equational t heory. )
substitution It is not the case t hat (M[Nlx])'az y and M1azY[thunk N 1azyIx] are the
sa me t erm (although t hey will be pr ovably equal in the CBV equational t heory )..
To see this, let M be x. Then (M[Nlx])'az y = N1azy but M1azY[thunk N 1azy Ix] =
force thunk N 1azy.
operational s emantics It is not the case t hat M .lJ. Tn, V implies M1azy .lJ. rn , v1azyval .
For example, let M be let (0) be x. (0, x) .
To make t he rel ationship pr ecise, we proceed as follows. First, we wri t e the two
t ranslat ions as relations H 1azy and Hlazyval from lazy t o FG-CBV te r ms. We ca n
present Fi g. A .9 by rules such as t hese :
1azy
let M be x. N H let (thunk M ' ) be x . N '
Proposi tion 142 For any returner M , we have M >--+ Iazy M lazy, and if M >--+Iazy M '
t he n M ' = M1azy is provable in t he CBV equational t heory; sim ilar ly for values . 0
2 If M >--+Iazy M ' and M ' .ij. V ', t he n, for some V , M .ij. V and V >--+ Iazyval VI .
o
We prove t hese by induction primarily on .ij. and secondarily on >--+Iazy .
Propo si tion 145 For a returner M , (M[V/ xJr and M V[Vv /x] are t he same te rm;
and similarly for values. 0
Proposition 147 T he t rans lation .:» pr eserv es and reflects operational sem ant ics:
I if M .ij. V t he n M V .ij. return V V
2 if M V .ij. return V ' t he n M .ij. V for some V such t hat VV = V'.
o
C C V (a value type)
A..
)"'X j E $ ri
L: iE/(Ai OV x · · · x A i (r i _ 1 )V)
~i E/ 'J
ses-, A B
IT iE I ij i UIT iE/(A i OV -+ .. . -+ A i (r i _ 1 )v -+ FB;')
TA UFN
A o, . . . , A n - 1 f-v V : B
x x
(i, Vo, , Vri-I) Ct, (VoV, , Vr i - 1 V))
A{.. . , Li , xn, ,X r i - 1.M i , . . . } thunk A{. . . , i.AXO AXr i -1.Mi " ; .. . }
thunk M thunk M V
A o, .. . , A n - 1 f-P M : C AoV, . . . , A n - 1 v f-c M V : FC v
let V be x. M let VV be x. M V
return V return VV
M to x. N M Vto x. N V
pm Vas { , (i , X;) .Mi , ...} pm VV as {. . . , (i, (X;)) .MiV, . ..}
Li, Vo, , Vr i - 1 'W Vr i - 1 " •• • ' Vo" i'f or ce W V
force V force VV
print c. M print c. M V
When we add complex values to the sour ce language FG-CBV, we must add them
also to the target language CBPV, and we then extend the t ranslat ion as follows:
A o , .. . , A n - 1 f-v V :B
let V be x. W let VV be x. W V
pm Vas { . .. , (i , X; ).W i , .. .} pm VV as { ... ,(i,(X;)) .WiV, . . .}
Corollary 149 (Full Abstraction) For any FG-CBV returners Ao, ... , A n - 1 f-P
M , M' : B , if M ~ M' t hen M V ~ M" ; and sim ilar ly for valu es. (The converse is
trivial.) 0
Proof Suppose C[M V] -lJ. rn , return i , for some CBPV ground context C of type
FL:iE/l. Construct a FG-CBV context C' su ch that C" = C is provable in CBPV.
Then we reason as follows.
1 Since in CBPV provable equality implies obs ervational equivalence, (C'[M])' -lJ.
rn , return i using the fact that (C'[M])' is precisely C"[M V] .
2 By Prop. 147(2) , C'[M] -lJ. m, i .
3 Since M ~ M' , we have C'[M'l-lJ. Tn,i.
4 By Prop. 147(1) , (C'[M'Jr -lJ. rn , i .
5 Since in CBPV provable equality implies observational equivalence, C[M 'V] -lJ.
rn , return i.
The proof for valu es is similar. 0
- 1
To prove Prop. 148, we give a translation .:» from CBPV to FG-CBV. (We shall
see that , up to isomorphism, it is inverse to _v .) At first glan ce, it is not apparent
how to make such a translation. For while it will translate a valu e ty pe into a CBV
316 CALL-BY-PUSH- VAL UE
ty pe, wh at will it t ranslate a com put at ion type into? T he answer is: a family of pairs
of CBV ty pes {(Bi , C i )}i EI. To see t he principl e of t he t rans lation , we not ice t hat in
CBPV (following Prop. 27) any computation type mu st be isomorp hic to a ty pe of
t he form Il iEI (Bi -+ F C i ). This motivates t he followin g.
It is clear t hat the exte nde d t ranslation pr eserv es provabl e equa lity.
The reverse t rans lation , pr esen ted in Fig. A.ll is organi zed as follows:
- I
• a valu e ty pe A is t rans lated into a CBV ty pe A V
- I
• a computat ion typ e ll. is translated int o a CBV pseudo-computation-type ll.v
• a CBP V value A o, . . . , A n - I I- v V : B is translat ed into a CBV value
v- I v- I v v- I v- I
A o , . . . , A n - I I- V :B
• a computat ion A o , . . . , A n - I 1-< M : ll. is tran slated into an FG -CBV pseudo-
A v- I c
.
co m p uta t io n ° ,...,
Av-I
n- I I- CBv M
v- I
: ll.
v- I
.
It is easy to show t hat t he reverse t rans lation com mutes with substit ution (of
valu es), and t hence t hat it pr eser ves pr ovable equality.
Using t his t rans lation (and a resul t t hat it ag rees with ope rational sem ant ics in a
certain sense) we ca n obtain from t he printing den ot ati on al semant ics for FG-CB V an
alte rnative semantics for C BPV . Thus a computation ty pe will denote a family of pair s
of sets and a com putation will denot e a family of fun cti on s. More generally we ca n
obtain a C BP V semantics from any FG-CB V semantics. However , t he construction
is artificial and we ar e not aware of any natural mod el for C BPV t hat ari ses in t his
way.
A PPENDIX A : Technical Treatment of CBV and CBN 317
A where
B wh ere
{(I , A' )) i E { *}
v V·- 1
x X
- I - I
let V be x. W let V ' be x. W '
(h, V ) (h, V· - I
)
- 1 - 1
pm Vas { ... , (k, X),W k" " } pmV' as{ . .. , (k, x) .Wk' , . . .}
(V, V ') (V ·- I , V ,· - I)
- I -I
pm V as (x , y ).W pm V ' as (x, y) .W'
- I
thunk M A{ . . . , L i, n.M i , ... }
M where
let V be x. M let V' be x. M'[
- I
return V ret ur n V '
- 1 - 1
M to x . N M: [O / n] to x. Ni
f or c e V a ,n 'force V ' -I
- I -I
pm V as {... , (k , x ).Mk , ... } pm V ' as {. . . , (k , X).(M k )i , . . .}
- I - I
pm V as (x, y ).M pm V ' as (x, y).M i
= (h,i)
-I
A{. . . , k .M k , .. . } (MiJi l
- I
h'M Mk~ '
1 - I
Ax.M pm n as (x, n). M i
- 1 - 1
V 'M Mi [(V' , n) / n]
- I
print c. M print c. M]
- I
Fiqu re A.ll . T he Re verse Translation .:»
To show that t he two t rans lations are inv ers e u p to isomorphism , we first const r uct
t he isomorphisms.
I For each CBV ty pe A we define a fun ctio n QA from CBV values I' l-" V : A to
I
CBV values I' f-' W : A··- , and a fun ction QA 1 in t he opp osite direct ion .
2 For each CBP V value ty pe A we define a fun ction (3A from CBP V values I' f-' V :
A to values I' f-' W : A · - I. , and a fun ction (3A 1 in t he op posite direction.
3 For each CBP V com putation ty p e !l we define a fun cti on (3l! from CBPV com-
pu t at ions r f-c M : !1 to CBP V com putations r f-c N : !l.- I. and a fun ction (3/"/
in t he opposit e direct ion . -
318 CALL-BY-PUSH- VALUE
(1) is defined by induction on A. (2) and (3) are defined by mutual induction on A
and 11- We omit the definitions, which are straightforward.
The following equ ations are provable in the CBPV equational theory.
These are each proved by ind uct ion over types. Using (3A, we have now proved
Prop. 148(1).
The tran slations are inv erse up to these isomorphisms, in the following sense:
These resu lts can be extended to terms with holes i.e, contexts. D
D efinition A.6 1 For any CBPV value A o" ... , A n - I v I-v W: B V define t he FG -
CBV value OW to be
v - I v- I [ )]
A o, ... , A n - I I- aB W aAix;j xi : B
o
Lemma 152 1 For any CBPV ret urner Ao", . . . , A n - Iv I-c N : F B V , t he equation
(ON)" = N is prova ble in C BPV.
2 For any FG-CBV returner A o, . . . , A n - I I-P M : B , t he equation O(M V) = M is
provabl e in CBV.
Sim ilar ly for values . This can all be extended to t erms with holes i.e, contexts. 0
P roof
The te chnical treatmen t of this t ran slation is also very sim ilar to t he trea tment of
t he t ranslation in Sect . A.5.
T his translation does not com mut e with substit ut ion or preserve op erational se-
man t ics pr ecisely-only up t o t he pr efix force thunk. (R ecall t hat in t he CBV equa-
tional theor y, we have
force thunk M = M .)
substitution It is not the case t hat (M[N/x])" and M "[thunk N" /x] are t he same
term (although t hey will be provabl y equal in the CBPV equational theor y) . To
see this, let M b e x. T hen (M[N/x])" = N " but M"[thunk N" /x] = force thunk N ".
operational semantics It is not the case t hat M .ij. m, T implies M" .ij. m , T" . For
example, let M be let (0) be x. (0, x) .
To m ake the relat ionsh ip pr ecise , we proceed as follows. First , we wri t e t he t rans-
lation as a relation >--t" from CBN t er ms to CB PV computat ions. We can present
Fig. A.12 by rules such as t hese :
Lemma 155 For an y term M , we have M >--t" M" , and if M!-t" M ' t he n M ' = M"
is provabl e in t he CB PV equat ional theory. D
Lemma 156 If M >--t" M ' and N >--t" N' t hen M[ N/x] >--t" M'[thunk N' /x]' and
similarly for multiple su bs tit ut ion. D
Proposition 157 1 If M .ij. N and M >--t" M' , t hen, for some N ' , M' .ij. N ' and
N >--t" N ' .
2 If M!-t" M ' and M ' .ij. N', t he n , for some N , M.ij. Nand N!-t" N ' .
D
Proposition 158 1 Every CBPV com putat ion type !1 is isomorphic to B" for
some CBN type B.
2 For any CBPV com put at ion U A 3, . . . , U A~ _l I-- c N : B" t here is a CBN te r m
A o, . . . , A n - 1 I-- M : B su ch t hat M" = N is provabl e in CB PV .
3 For any CBN terms I' I-- M , M' : B , if M" = M '" is provabl e in CBPV then
M = M ' is provable in CB N .
(2)-(3) can be extende d t o te rms with hol es i.e. conte xts. D
APPENDIX A: Technical Treatment of CEV and CEN 321
D efinition A .7 • A eEN pseudo-valu e-typ e is a fam ily {A;} iEI of CBN ty pes.
• Let {AO;}i Elo," " {A (n- l )i}; Eln_1 be a sequence of CBN pseudo-value-types and
let {B j h EJ be another CBN pseudo-value-type. We wri t e
{AO;} iElo," " {A (n-l )i}; Eln_1 I-(:BN {(V . if ,Vy-> Hi.Ef'.
J J J
: {BjhEJ
-,-+
to mean t hat , for each io E Io, oo . , i n- I E In- I , we have V . ij E J and Vy-> is a
CBNterm Aoio, · · · ,A(n- l )in_1 1-li';-+ : B v . Y-> · We say that {(V. if, li';-+Hi.E;,. isa
J J 3 1 1
e B N pseudo-value of type {Bj hEJ on t he con tex t {AO;} iElo,"" {A (n- 1)i };EJ n_1'
Given t wo such pseudo- valu es { (V . if , Vy-> Hi'EI '. and {( W . if, W y-> Hi .EJ'. , we say
J J J ~ J ~ J -,-+
t hat t hey ar e provably equal in e B N wh en for each ij E I j we have V . ij =W . ij
and t he equation Vy-> = W y-> is provable in CBN .
J J
• Let {A O;} iElo, .. . , { A (n- l )i };El n_1 be a sequence of CBN pseudo-valu e-typ es and
let B b e a CB N ty pe. We wri t e
t o m ean that , for each io E Io, .. . ,in- l E I n- I, we have t hat M y-> is a CBN
J
t erm A Oio , " ., A (n- l )in _ 1 I- M y-> : B . We say t hat {MY->} i ' EI'. is a eBN pseudo-
1 J J J
computation of type B on the conte xt {AO;}iElo, " " {A (n- l )i}; Eln_1' Giv en two
such ps eudo-computations {My-> }i 'EI'. and {Ny-> }i 'EJ '. , we say that they are prov-
J ~ J J J
we write {M~ } ~
l,j 1.j E lj
to mean t he CBPV computation
A whe re
{Q" }
{A kl h EK,I EL k
{A k Il A;}k EK,I EL
wh ere
A "- I = {A;} i EI
v V;.-I
,. wh ere
xr
let V be x . W
-+
let V~-l be x . W~~l
1,. ij k
V"
- I
• ij = k•
(V, V') (V "- I • ~
~j , V
,"-I • ;4)
~j
- 1 /n- 1
..\{O.V;'
'tj
, 1.V.,...
't
}
- I -+ •• J
pm V as (x ,y) .W W" • i j kl
-+ ••
= (k , l)
- 1 -1 - I - I
let O'Vi' be x, 1 ' ~..!'; be y. W~ .. V" . ij
ii kl
• -I' -+ ' - 1
(1. , V ) (k, V" • i j) V;'
- I -+. 'i
pm V as (Wk)" • ij I
- I -+ ••
{ , . . , (k, X)'W k," ' } let V;.- I V" • ij = (k , I)
'i
thunk M
*
- I
M ,.
M~ where
let V be x. M let Vi' be x. M!f+ k V" • ij = 1.
1 - 1 ]-1 - I - I -+ ••
pm V as ( x , y ).M let O'V;' be x , l 'V;' be y. M~ . . V" . ij= (k , l)
tj 1i ii kl
pm V as
- 1 - 1 -I -+ ••
{ . . . , (k , x).M k, . .. } l e t Vi' be x . (Mk)'h V" • ij = (k , I )
- 1 J J
force V V;'
'i
" - I -+ -I
return V (v • ij ,v;. )
- 1 tj - 1
M to x . N pm M~ as { ... , ( i , x) . N~ , ... }
Ij t jl
-I
..\x.M ..\{. .. , i ."\x.M!f+ i , .. . }
- I - I -4 - I
V 'M Vi' 'V " • ij' M!f+
J - 1 J
..\{ .. . , k .Mv , ... } ..\{.. . , k. (M k)';.. , . .. }
'" - 1 1j
1.'M k 'M~
tj - 1
print c. M print c. M~
'i
- I
Figure A .13. T he Reverse Translation -"
324 CALL-BY-PUSH- VALUE
OA(N[Mlx]) (o AN)[Mlx]
o Ao ::l 1M M
o::lloAM M
a B( pm M a s {... , (i , x}) .Ni , . . .}) pm M a s {... , (i , x)) .OBNi , .. .}
The following equat ions are provable in the CBPV equat iona l theory.
o
These ar e each proved by induction over types . Using fJ~, we have now proved
Prop. 158(1) .
The translations are inverse up to these isomorphisms, in t he following sense:
These results can be extended to terms with holes i.e. cont ext s. o
This is proved by induction over terms using Lemma 160.
We are now in a position to prove Prop. 158(2)-(3) . Fix a CBN context A o, .. . ,A n - 1
and CBN type B .
D efinitio n A .8 For any CBPV computation U Ag, . . . ,U A~ - l f-c N : B " d efine the
CBN t er m ¢N to be
- 1 )
A o , . . . , A n - 1 f- o BN~ .... [OA; xi/x;] : B
o
APPENDIX A : Technical Treatment of CBV and CBN 325
Lemma 162 1 For any CBPV com putat ion UA 3, . . . , UA~ _1 f-c N : En , t he equa-
t ion (fjJN)n = N is provabl e in CBP V.
2 For any CB N te rm A o, . . . , A n - 1 f- M : B , t he equation fjJ (M n) = M is provable
in CB N.
o
P roof
1 - 1 )
(1) By Lemma 161, N = (3"B N" n((3u Aixi/X;] is provable, and we can see that
1n
(3"B 1 N n- [(3uA i x;jx; j = (fjJN)" by expanding both sid es and using Lemma 160.
(2) This follows directly from Lemma 161.
T his can all be extende d to te rms with holes i.e. cont ext s. 0
Prop . 158(2)- (3) follows immedi ately from Lemma 162.
Appendix B
Models In The Style Of Power-Robinson
328 CALL-BY-PUSH- VALUE
B.l Introduction
In this appendix we give ca t egorica l semanti cs for C BP V without t he st ack judge-
ment f- k. Our purpose is to prove
Propo si tion 163 The equational theory for CBPV+ stacks (Fig. 3.6) conser vat ively
extends the equat ional theory for CBPV wit hout stacks (F ig. 3.3) . This remains t rue
wh en we include the printing laws in eac h . 0
The categor ical semantic s pr esented here do es no t appear t o be a useful way of orga-
nizin g CBP V models in practic e, becau se all the mod els we have seen model st acks
in a natural way, and we would wan t t o describe t his explicitly.
As usual we first define a judgem en t model (a "st aggered Freyd ca tegory ") and
then trea t t he vari ous connect ives. We see, by means of a full reflection, that each
m odel of C BP V of this kind arises from a CBPV adj unct ion model. We see how to
generate a categorical model from a t heory, and use t his to prove t he conservation
result .
• a categor y C;
• a n object 1;
• a functor ® : C x C ----t C;
• natural isomorphisms
A ® (B ®C)
A
~ ~
A ®(B ®(C ®D))
/ / 1-
(A ®B) ®(C ®D) -- «A ®B) ®C) ®D A ®B
-j
A ® «B ® C) ® D) ~ (A ® (B ® C)) ® D (A ® 1) ® B ~ A ® (1 ® B)
com mute.
2 Let (C, 1, ®) be a mon oidal ca tegory and V a ca tegory. A left C-action on V
cons ists of a fun ctor 0 from C x V to V , to gether with natural isomorphism s
A 0 (B 0 Z) (A ®B) 0 Z
Z 1 0Z
APPENDIX B : Models In The Style Of Power-Robinson 329
such that the diagrams
A 0 (B 0 (C 0 Z» ~ (A (9 B) 0 (C 0 Z) ~ ((A (9 B) (9 C) 0 Z A0 Z
-j /
A 0 ((B (9 C) 0 Z) ~ (A (9 (B (9 C» 0 Z
/j.
(A (9 1) 0 Z ~ A 0 (1 0 Z)
commute. A right C-action on TJ is defined similarly.
o
It is clear that
• every cartesian category is monoidal;
• every monoidal category has a canonical left action and right action on itself.
Proposition 164 (coherence) 1 Given a monoidal category C, every diagram
built from structural isomorphisms commutes.
2 Given a monoidal category C and a left C-action on a category TJ, every diagram
built from structural isomorphisms commutes.
o
A precise statement and a proof of Prop. 164(1) can be found in [Mac Lane, 1971].
Prop. 164(2) is stated and proved similarly.
B .5 Enrichment
As in Sect. 9.5.5, we define enrichment for judgeme nt models.
(c*f) jg c * (fj g)
(Lf) j (c * g) C*((Lf) jg)
A x (c*g) c * (A x g)
are satisfied. o
In a similar way we can define cppo enriched and domain enriched staggered Freyd
ca t egories.
B.6 Connectives
D e finition B .1 5 Let (C, E, L, x) be a staggered Freyd category.
1 Write N for the family of left C-modules E(L - ,X] indexed by target obj ects 1':.. A
distributive coproduct for a family of C-objects {Ai h E! is a distributive coproduct
for {Aih E! in (C,N), in t he sense of Def. 9.29 and Def. 11.16 .
2 A product for a fam ily of comp-object s {~J iE! is a representing object for
o
Pro posi t ion 1 6 5 Let (C, E, L, x) be a staggered Freyd category with all right adj unc-
tives. Then a distributive coproduct for {A ihE! in C is automatically a distributive
coproduct in (C,E,L, x). (The converse is trivial.) 0
2 A right product- adjunctive for a family of comp-objects {lIJ iEI is a represen ting
obj ect for
II
op
£(~ - ,lIi) : C -+ Se t
iEI
II
op
£ (~ - X A i, 1I;) : C -+ Se t
iEI
It is easy to see how to in ter pret CBPV in such a struct ure, and we obtain a direct
model/ cat egorical model equivalence as in Chap. 10. For a CBPV obje ct structure
r , we define a r -sequent to be eit her A o, . . . , A n - 1 l-" B or A o, .. . , A n - 1 f-c 1I, wh ere
A o, .. . , A n - 1 and B and 1I are r -objects. A r -signature s provides a set s( Q) for
each T-sequ ent Q.
Given a r -signature s, we define the set of terms built from s. These ar e indu ct ively
defin ed by the rules of JWA+complex valu es, toget her with t he ru les
Proposi tion 166 Let r be a CBPV obj ect structure. The "categorica l semantics"
fun ct or from CBPV staggere d Freyd cate gor ies with ob ject structure T to the cat egory
of algebras for T on Sig; is an equivalenc e. 0
T his is proved in the same way as Prop. 109 and Prop. 111.
APPENDIX B: Models In The Style Of Power-Robinson 333
ValProd T T -.
u
--
:F
AdjT
9
B
h h'
A A
9
h k 9
A
334 CALL-BY-P USH- VALUE
o A11 = E(A,11)
• T he comp osite of
9 h
A A
This is st rai ghtforwar d to prove. T hus we can set the counit of our full reflection t o
be t he ident it y, while t he un it is defined as follows.
takes - _ -,--9_
x
•• 11 to ('Tr' *g);('Tr*h) .
D
Finally, we have to veri fy t he triangle laws for an adj unction . Because the counit is
ident ity, these are qui te simple.
• :FunitA = idF A. This sim ply says t hat unit., is ident ity on C-morphisms , which is
true by definit ion .
• unituM = iduM . T his is easily verified .
B.9 Theories
Eac h of our equivalences between direct mod els and cate gorical mod els can be
formulat ed as an equivalence between theories and categorical models. A t heo ry is a
present ation of a direct model, sim ilar to a pr esen tat ion of a group by generators and
relati ons . We need t his formul ation for our conservat ivity result .
We present t his m at eri al for x -calc ulus, bu t it adapts straightfo rwardly to CBP V
with st acks, t o ,JWA, and, most import an tl y for our present purposes, to CBPV
withou t stacks.
APPENDIX B: Models In The Style Of Power-Robinson 335
f
T8 Ti • T1" - - -_ I r
we have
~ C ker [-]i
i.e, terms related by ~ have the same denotation.
3 A model of (8, ~) is a direct r-model (1',0) together with an interpretation i of
(8 ,~) in (1',0) .
4 A model morphism from a r-model (r,O,i) to a r-modcl (r' ,O' ,i') , of (8 ,~) is a r
.
signature morp hiIsm T f, • T suc h th a t t.; f = t.,.
~ = ker[-]i
i.e, terms are related by ~ iff they have the same denotation. D
This is entirely analogous to the construction of a group from generators and relations.
It is sometimes called the classifying model of the theory.
Proof We define r to consist of equivalence classes under ~ of terms under ~ , and
obtain a quotienting map T s q • 1' . We define 0 by induction in the obvious
way, and show by induction that (Tq); 0 = J-ts j r, We define i to be TIT j q. The required
properties are straightforward. D
We now reformulate Def. B.21 and Prop. 168 using categorical models rather than
direct models.
Unpacking, we see that (1) is the usual definition of categorical model , whereas (2) is
more restrictive than usual in its requirement that the functor be identity-on-objects.
This is in keeping with our fixing of object structure throughout.
336 CALL-BY-PUSH- VALUE
i.e. terms are re lated by ~ iff they have the same denotation. o
T his is sometimes called the classifying category of the theory.
B.lO Conservativity
Propo sition 170 Let A be a (A -set/cppo/domain enriched) CBPV adjunction model.
If P is a term of CBPV without stacks (wit h printing /recursion), t hen t he denotation
of P in A is equal to the denotation of P in FA. 0
Pro p o sition 171 There is a (A -set enriched) CBPV staggered Freyd category M
such that parallel (i.e. same context and ty pe) terms P and Q (with printing) have
the same denotation if they are provably equal in t he equational theory for CBPV
without stacks (wit h printing). 0
Proof T his follows from Prop. 166 t he same way that Prop . 169 follows from Prop. 109.
o
Finally, we can achieve t he goal of the chapter: to prove Prop . 163.
Proof Let M be defined as in Prop. 171. Let P, Q be par allel terms in CBPV
wit hout stacks (wit h printing) . Suppose P and Q are provably equal in CBPV+stacks
(with printing) . T hen they have the same denotation in every adjunction model, in
particular in UM , and so (by Prop. 170) the same denotation in FUM , which is M
(Prop . 167). By the definition of M , they must be provably equal in CBPV wit hout
stacks (with printing) . 0
References
337
338 CALL-BY-PUSH- VALUE
Gir ard, J .- Y , Lafont , Y., and Taylor , P. (1988). P roofs an d Types. Ca mbridge Tr acts
in Theoreti cal Computer Science 7. Ca mbridge Univers ity Press. (pp 7, 158)
Goguen , J ., That cher , J ., and Wagn er , E . (1979). An ini ti al algebra approach to t he
specification, correct ness , and implem entation of abstract dat a typ es. In Yeh , R .,
edito r , Current Trends in Programming M ethodology IV, pages 80-149. Prent ice-
Hall. (p 83)
Griffin , T . G . (1990). The formulae-as-typ es notion of control. In Conf. R ecord 17th
Annual ACM Symp. on P rinciples of Program m ing Languages, P OPL '90, San
Francisco, CA , USA , 17-19 Jan 1990, pages 47- 57. ACM Press, New York. (pp 142,
158)
Gunt er , C . A. (1995) . S emantics of P rogram m ing Languages. MIT P ress. (p xxix)
Harmer , R . and McC usker, G . (1999) . A fully a bstra ct ga me semantics for finit e non-
determinism . In LICS : IEEE Sy mp osiu m on Logic in Computer Science. (p 169)
Hatcliff, J . and Dan vy, O . (1997). Thunks and t he A-calculus. J ourn al of Fun ctional
Programming, 7(3) :303- 319. (ppxxx, xxxi, 20, 151, 312)
Hennessy, M. C . B. (1980) . The semanti cs of call-by-valu e and call-by-name in a non-
det erministic environment. SIAM Jo urnal on Computing, 9(1):67- 84. (pxxix)
Hennessy, M. C. B. and Ash croft , E . A. (1980) . A m athema ti cal semantics for a nonde-
te rm inist ic ty ped lambda -calculus. Th eoretical Computer Sc i ence, 11(3):227- 245.
(p 20)
Hofm an n , M. (1995) . Sound and complete ax iomatisations of call-by-value cont rol
operators . Mat hematical St ructures in Computer Scienc e, 5(4):461-482. (p 238)
Hofmann, M. and St reicher, T . (1997) . Cont inuation models ar e universal for AJ1o-
calculus. In Proc., T welfth A nnual IEEE S ym posium on Logic in Compu ter S cience,
pages 387- 395, War saw , Pol and. IEEE Comput er Society Press. (pp 103, 151,
158)
Honda , K. and Yoshida, N. (1997). Game theoreti c ana lysis of ca ll-by-value com -
pu t ati on . In Degan o, P. , Gorrieri , R. , and Marchet ti -Sp accarn ela , A., edit ors, Au-
tom ata, Languages and P rogram m ing, 24th Intern ational Colloquium, volume 1256
of L N CS , pages 225-2 36, Bologna , It aly. Springer- Verl ag. (pp xx ix , 175)
Hu th, M., J ung , A., and Keim el, K. (2000). Linear types and ap proximation . Math .
S tru ct. in Compo Scienc e, 10:719- 745. (p 110)
Hyland, J . M. E. and On g, C.-H. L. (2000). On full abstract ion for P CF : I, II , and
III. Information an d Computation, 163(2):285- 408. (pp xx ix , 47, 66, 169, 174,
175, 176, 201)
Ing erman , P. Z. (1961) . Thunks: A way of com piling procedure stat eme nts with some
comme nts on pro cedure declarations. Com m unica ti ons of the A CM, 4(1) :55-58.
(p xxxiv)
J acobs, B. (1999) . Cat egoria l Logic and Type Th eory. Elsevier , Am st erdam . (p 268)
J effrey, A. (1999) . A fully abstract semantics for a high er-order fun cti on al lan gu age
wit h nondet erminist ic comput at ion. T CS: T heoreti cal Computer S cien ce, 228. (p 251)
Jung , A. (1990) . Colim its in DCPO . 3-page manuscript , available by fax . (p 136)
Kri vin e, J .-L. (1985). Un interprct eur de A-calcul. Unpublished . (p32)
Krivine, J .-L . (2001). person al com munication . (p 54)
Lafont , Y ., R eus, B., and Streicher , T . (1993). Cont inuation semant ics or expres sing
implicati on by negati on . Techni cal R ep ort 9321, Ludwig-Maximilian s-Universit at ,
Miinchen . (pp 142, 158)
340 CALL-BY-PUSH- VALUE
Laird, .I. (1997) . Full abstraction for functional languages with control. In Proceedings,
Twelfth Annual IEEE Symposium on Logic in Computer Science, pages 58-67,
Warsaw, Poland. IEEE Computer Society Press . (pp 20, 169)
Laird, .I. (1998) . A S emantic Analysis of Control. PhD thesis, University of Edinburgh.
(p 103)
Laird, .I. (2003) . A categor ical semantics of higher-order st ore. In Proc., 9th Con-
ferenc e on Cat egory Th eory and Computer Science, Ottawa, 2002, volume 69 of
El ectronic Not es in Theoretical Computer Sci ence. (p 171)
Lambek, J . and Scott, P. (1986) . Introduction to Higher Order Categori cal Logic.
Cambridge Univ ersity Press, Cambridge. (p 235)
Landin, P. J . (1964) . The mechanical evalua tion of expressions. The Computer Jour-
nal, 6( 4) :308~320 . (p 32)
Landin, P. J. (1966) . The next 700 programming languages. Communications of th e
A CM , 9(3) :157~ 164. Or iginally presented at the Proceedings of the ACM Program-
ming Language and Pragmatics Conference, August 8-12 , 1965. (pxxii)
Laurent , O. (1999) . Pol ari zed proof-nets: proof-nets for LC (extended abs tract) . In
Girard, .I.-Y ., edit or, Typed Lambda Calculi and Applications '99, volume 1581 of
Lecture Not es in Computer Sci ence, pages 213-227. Springer. (pxxxi)
Laurent, O. (2002a) . Etude de la polarisation en logique. PhD thesis, Universite Aix-
Marseille II. (p 175)
Laurent, O . (2002b) . Polarized games. In Logic in Computer Sci ence, pages 265-274,
Los Alamitos, CA , USA. IEEE Computer Society. (p 174)
Lawvere, F . W . (1963) . Functional S emantics of Algebraic Theories. PhD thesis,
Columbia University. (p 216)
Levy, P. B. (1996) . A-cal culus and cartesian closed categories. Essay for Part III of
the Mathematical Tripos, Cambridge University, manuscript. (p 251)
Levy, P. B. (2001). Call-by-push-valu e. PhD thesis, Qu een Mary, University of London.
(p xxi)
Levy, P. 13. (2002) . Possible world semantics for general storage in call-by-value. In
Bradfield , J., edit or , Proc., 16th Annual Conference in Computer Science Logic,
Edinburgh, 2002, volume 2471 of LNCS, pages 232-246. Springer. (pp xxxix,
126)
Levy, P. B. (2003) . Adjunction models for call-by-push-value with stacks. In Proc., 9th
Conference on Category Theory and Computer Science, Ottawa, 2002, volume 69
of Electronic Notes in Th eoretical Computer Science. (p xxii)
Levy, P. B., Thielecke, H., and Power, A. J. (2003). Modelling environments in
call-by-value programming languages. Information and Computation, 185 :182~21O .
(p 287)
Longl ey, J. and Plotkin, G. (1997). Logical full abstraction and PCF. In Ginzburg,
J., editor, Tbilisi Symposium on Languag e, Logic and Computation. SiLLI/CSLI.
Also available as LFCS Report ECS-LFCS-97-353 . (p 169)
Mac Lane, S. (1971) . Cat egories for the Working Math ematician , volume 5 of Graduat e
Texts in Mathematics. Springer-Verl ag , New York . (pp24, 236, 237, 264, 284,
329)
Marz, M. (2000) . A Fully Abstract Model for S equential Computation. PhD thesis,
Technische Universitat Darmstadt. published by Logos-Verl ag, Berlin. (p xxxi)
Marz, M., Rohr, A., and Streicher, T . (1999) . Full abstraction and universality via
realisability. In LICS: IEEE Symposium on Logic in Computer Sci ence. (p xxxi)
McCusker, G. (1996) . Games and Full Abstra ction for a Functional Metalanguage
with R ecursiv e Types. PhD thesis, University of London. (pp 80, 174, 176, 179)
REFERENCES 341
McC usker , G . (1997). Games and definabili ty for FPC. Th e Bulletin of S ym bolic
Logic, 3(3):347-362. (p 169)
Moggi, E . (1988) . Computational lambda-calculus and mo nads. LFCS R eport ECS -
LF CS-88-66 , University of Ed inburg h . (pp xxxi, 18)
Moggi, E . (1991). Notions of computation and mon ads. Inform ation and Compu tation,
93:55-92. (ppxxii, xxv iii, xxxi, xx xii , 14, 18, 20, 89, 90, 114, 216, 293, 307)
Moggi, E. (90) . An abstract view of pr ogramming lan gu ages. Technical Rep ort EC S-
LF CS-90-113 , Dept. of Com puter Science, Edinburgh Univ . (pp xx ix, 125, 136)
Murthy, C. (1990) . Extracting Cons tructive Cont ent f rom Classica l Proofs. PhD t hes is,
Cornell University, Dep ar tment of Comput er Science. (p 158)
Nickau, H. (1996 ). Heredita rily S equent ial Funct ionals: A Gam e-Theoretic Approach
to S equentiality. Sh aker-Verl ag. Disser t ation, Univers itat Gesamt hochschule Siegen.
(pp xxix, 169)
Odersky, M. (1994) . A fun ction al theory of local names. In ACM , editor, Proceedings of
21st Annual ACM SIGACT-SIGPLAN Symposium on Pr in ciples of Programming
Languag es (POPLj, pages 48-59 , New York , NY , USA. ACM Press. (p 137)
O 'Hearn, P. W . (1993). Op aque ty pes in algol-like lan gu ages. manuscript . (pp 90,
116)
O 'Hearn, P. W . and Tennent , R. D. (1995). Parametricity and local variables. Journal
of th e A CM, 42(3):658- 709. (pp 136, 137)
Oles, F . J . (1982). A Category- Theoretic A pproach to th e Semantics of Programming
Languages. Ph. D. dissert ati on , Syracuse University. (pp xxix, 125, 136)
On g, C. H. L. (1988) . Th e Lazy Lambda Calculus: A n Investigation int o the Foun-
dations of Functional P rogram m ing. PhD t hesis, Imperi al College of Scienc e and
Technology. (p 20)
On g, C.-H. L. (1996). A semantics view of classical pro ofs: type-theoretic, categorical,
den otati onal characterizations. In Proc, 11th IEEE Annual S ymp osium on Logic
in Compu ter Science, pages 230-241. IE EE Com puter Soc iety Press. (p 160)
Pari got , M. (1992). AJL-calculus: An algorit hm ic interpretati on of classical natural
deduction . In Voronk ov, A., edit or , Proceedings of th e Intern ational Confe rence on
Logic Programming an d A ut omated R easoning (LPA R'92j, volume 624 of L NAI,
pages 190-201 , St . Peter sburg, Ru ssia. Springer Verl ag. (p 160)
Park , D. (1968) . Som e sem antics for data struct ures. In Michie, D., edit or, Ma chin e
Int elligence 3, pages 351-371. American Elsevier, New York. (pxxxiii)
Pi t ts , A. M. (1996) . Relational properties of domains. Info rm ation and Computation,
127:66-90 . (pp69 , 74, 76, 140)
Pi tts, A. M. and Stark , 1. D . B. (1993). Obs ervable properties of higher order fun ctions
that dynamically create local names , or : What 's new? In Math ematical Foundations
of Computer Science, P roc, 18th Int. Symp ., Gdansk, 1993, volume 711 of LNCS ,
pages 122-141. Springer-Verl ag, Berlin. (p 125)
Pl otkin , G . D. (1976). Call-by -name, call-by-value and t he A-calculus. Th eoretical
Compu ter Science, 1(1):125-1 59. (pp xxxi, 20, 150, 151)
Pl otkin , G. D . (1977). LCF as a pro gramming lan gu age. Th eoretical Compu ter Sci-
ence, 5. (pp xx viii, 20, 47)
Pl otkin, G . D. (1983) . Dom ains. 1992 TeXe d editi on of course notes prepared by Yugo
Kashiwagi and Hid etaka Kondoh from not es by Ta tsuya Hagin o. (p 84)
Pl otkin , G. D. (1985) . Lectures on predom ain s and partial functions. Course notes,
Center for t he St udy of Lan guage and Informati on , Stanford . (pp xxviii, 13)
342 CALL-BY-PUSH- VALUE
Plotkin, G. D. and Power, A. J . (2002) . Notions of com put at ion determine mon-
ads . In Proc., Foundations of Software Sci ence and Computation Structures 2002,
Grenoble, France , volume 2303. LNCS. (pp 260, 294)
Power (2002) . Premonoidal categories as categories with algebraic structure. Theoret-
ical Computer Science, 278(1~2) :302~331. (p 329)
Power, A. J. and Robinson, E . P. (1997) . Premonoidal categories and notions of
comput at ion . Math . Struct. in Compo Sci ., 7(5) :453-468. (p 329)
Power, A. J . and Thielecke, H. (1999) . Closed Freyd- and kappa-categories. In Proc,
ICALP '99, volume 1644 of LNCS, pages 625-634. Springer-Verlag, Berlin. (p 329)
345
346 CA LL-B Y-P USH- VALUE