Direct Models of the Computational Lambda-calculusAcademic research paper on "Mathematics"

CC BY-NC-ND
0
0
Share paper
OECD Field of science
Keywords
{}

Abstract of research paper on Mathematics, author of scientific article — Carsten Führmann

Abstract We introduce direct categorical models for the computational lambda-calculus. Direct models correspond to the source level of a compiler whose target level corresponds to Moggi's monadic models. That compiler is a generalised call-by-value CPS-transform. We get our direct models by identifying the algebraic structure on the Kleisli category that arises from a monadic model. We show that direct models draw our attention to previously inconspicuous, but important, classes of programs (e.g. central, copyable, and discardable programs), and we'll analyse these classes exhaustively—at a general level, and for several specific computational effects. Moreover, we show that from each direct model K we can recover the monadic model from which K arises as the Kleisli category.

Academic research paper on topic "Direct Models of the Computational Lambda-calculus"

﻿Electronic Notes in Theoretical Computer Science 20 (1999)

URL: http://www.elsevier.nl/locate/entcs/volume20.html 48 pages

Direct Models of the Computational Lambda-calculus

Carsten Fiihrmann1

Division of Informatics University of Edinburgh UK

Abstract

We introduce direct categorical models for the computational lambda-calculus. Direct models correspond to the source level of a compiler whose target level corresponds to Moggi's monadic models. That compiler is a generalised call-by-value CPS-transform. We get our direct models by identifying the algebraic structure on the Kleisli category that arises from a monadic model. We show that direct models draw our attention to previously inconspicuous, but important, classes of programs (e.g. central, copyable, and discardable programs), and we'll analyse these classes exhaustively—at a general level, and for several specific computational effects. Moreover, we show that from each direct model K we can recover the monadic model from which K arises as the Kleisli category.

1 Introduction

1.1 Direct style and 'monadic style

This article is about direct-style categorical semantics of call-bv-value programming languages. A programming language can be direct-style or not, and the semantics of a direct-style language can be direct-style or not. Our direct-style language is the language in which we write our programs. For call-by-value, this could be C or Java, Lisp or ML. In a more idealised setting, we could consider call-by-value PCF, or the call-by-value lambda-calculus. In this article, we'll work with Eugenio Moggi's computational lambda-calculus (and extensions thereof) to allow a clean theoretical treatment.

In contrast to call-bv-name, reasoning about call-by-value programs doesn't allow replacing variables with arbitrary expressions, because terms can have computational effects. For example, if the effect is 'non-termination'

1 Supported by the EU TMR Marie Curie Research Training Grant №ERBFMBICT982906

(which we'll also call 'divergence'), then the equation (Xx. 1)0 = 1, where Q is a diverging program, is obviously false for call-bv-value.

There may be a compiler for our direct-style language. We'll consider only a certain kind of compilers. One example is Appel's compiler for Standard ML of New Jersey (SML/NJ) [2], It translates ML programs into terms of a 'CPS-language' (CPS stands for 'continuation-passing style'), which is in a certain sense simpler than ML, and good for code optimisation, Appel's compiler is a real-life case of a CPS-transform. If the direct-style language is the call-bv-value lambda-calculus, then CPS-language is a fragment of the A¿^-calculus, (This fragment is equivalent to Thielecke's CPS-calculus.) There, in contrast to the direct-style language, we can replace variables by arbitrary terms. The latter CPS-transform is a special case of a monadic-style transform (MS transform) of the call-bv-value lambda-calculus into Moggi's 'Meta-language', which is a fragment of the A¿^-calculus plus type- and term-constructors that describe a strong monad. (We'll see that transform later in this introduction.) From the monadic-stvle transform, we obtain the CPS-transform by instantiating the strong monad with a continuations monad.

1.2 The computational lambda-calculus

In this article, we use the computational lambda-calculus as an idealised direct-style call-bv-value language. We make a tiny change in that we use different names for the type constructors: Instead of T, x, and 1, we use L, and /, respectively, (We'll keep T, x, and 1 for the Meta-language, however.) This avoids confusing direct style with monadic style, which would be fatal. Figures 1-3 show the term formation rules.

The computational lambda-calculus has two kinds of judgements. First, equations (T b M = N : A), where (T b M : A) and (T b .Y : .1) are derivable sequents. Second, 'existence' judgements (r b M I A) (where (r b M : A) is a derivable sequent), which imply that in every judgement we can substitute M for any variable x of type A. Existence judgements hold for terms of the forms x, [M], (Xx : A.M), *, (x,y), and 7Ti(x).

The type constructor L and the two monadic term formations rules in Figure 3 don't occur explicitly in typical real-life call-by-value languages. As we shall see (Proposition 3.17), in models of the computational lambda-calculus, LX is naturally isomorphic to (I —1 X) such that [M] corresponds to (Xx : l.M), where x is fresh, and fj,(M) corresponds to M*. The main characteristic of the computational lambda-calculus is that we can't generally replace variables by arbitrary terms, but only by values. For a detailed description of the derivation rules for equations and value judgements, please see [10].

val- X\ . • 11.... , xn . An I- .!'; . Ai

id r b M : A r, x : A b N : B

r b let x = M in N : B

* r b * : I

r b M : A Tt N :B r b (M. N) : A® B

TTi r b M : Ax® A2 T b TTi{M) : Ai

constant / : A-B r b M : A r b f(M) : B

Fig. 1. "Basic" terms of the computational lambda-calculus

1.3 Categorical semantics 1.3.1 Monadic semantics

The target of the monadic-style transform is Moggi's Meta-language, It is a fragment of the A^-ealeulus plus extra structure, and its categorical models are called Ac-models [10]. A Ac-model is a category C with finite products plus a strong monad T and T-exponentials—that is, for all objects A and B, an exponential (TB)A of TB by A. A strong monad is a monad together

with a strength—that is, a natural isomorphism A x TB-T(A x B)

with certain equational properties (see [11]). Figures 4 and 5 show the Metalanguage and its categorical semantics. A sequent (r b M : A) denotes a

A T,x : A\~ M : B r b A.r : AM : A^B

app T\-M:A^B r b N : A

r b MN:B

Fig. 2. Higher-order terms of the computational lambda-calculus

H r b M : A

r b [M] : LA

ll> r b M : LA

T b n(M) : A

Fig. 3. Monadic terms of the computational lambda-calculus

morphism [r]-[A] in the Ac-model.

The lambda-calculus part of the Meta-language (Figure 4) doesn't need the monad, except the functor T to describe that all the exponentials that we need are of the form (TB)A, In Figure 5, which describes the monadic part, r] is the monad's unit, and ¡jl is the monad's multiplication. The operational idea is that a term of the form [M] stands for the delayed evaluation of M. Given [M], the interpreter does nothing—that is, it returns [M], Given (let x <= M' in N), the interpreter evaluates M' until it gets a term of the form [M], and then it evaluates M. binds the result to x, and proceeds with N.

Example 1.1 For a simple Ac-model, let C = Set, and let T be the obvious monad such that, for each set A, we have TA = {±}U{loj : a E A}. Then the Kleisli category Ct is isomorphic to the category of sets and partial functions.

In general, the monad T can be seen as a parameter that stands for a computational effect. In the above example, the effect is divergence, but there are also state monads, exceptions monads, continuations monads, and so on.

Rule Syntax Semantics

var X! : Ai,... ,xn : An b x, : Ai = A± x ■ ■ ■ x An Ai

A F,x : Ah M : B ~TxA-?-+TB

Th(\x: A.M) : A -t TB V (TB)A

ev r h M : (TB)A ~ T —U- (TB)A r h N : A - T —A

T h MN : TB = T (TB)A x A TB

* T h * : 1 I" —- 1

<- -> r h M : A - r —U- A Th N :B - T —B

r h (M, N) : A x B = T Ax B

TTi r b M : Ax x A2 = T —^ ,1, x A2

T h in(M) :Ai - T —U- Ai x .4, ^

J: A -. B r h M : A - T —A

r h /(Ai) : B = r A —B

Fig. 4. The Meta-language and its categorical semantics: The lambda-calculus part

Rule Syntax Semantics

H r b M : A -r —^ A

r b [M] : A = r —^ A —^ TA

let r b M : TA = r —^ TA T,x : At N : TB -Txi —~ TB

i' b IH .r M in N : TB = T T x TA T(T x A) JX TTB —^ TB

Fig. 5. The Meta-language and its categorical semantics: The monadic part

{A® Bf

[LAf = T (A«)

Fig. 6. Monadic-style transform from the computational lambda-calculus into Moggi's Meta-language: Types

1.3.2 The missing direct semantics

Like for the Meta-language, Moggi's semantics of the computational lambda-calculus too uses a Ac-model C. Here, a sequent (r b M : A) denotes a morphism [r]-T\AJ of C. This semantics is the same as first performing the monadic-style transform into the Meta-language and then using the semantics of the latter. The monadic-style transform sends a type A of the computational lambda-calculus to a type of the Meta-language (Fig. 6), and it sends a sequent (x\ : Ai,... ,xn : An b M : A) of the computational lambda-calculus to a sequent [xi : A{,... ,xn : A\$n b AP : T of

x^ = [x]

(let x = M m N)t = _ (let x <= 1*1 M« in

- (M. = (let x <= Mi in let y <= NUn[(x,y)])

MM))« = (let x <= Mi m Mx)])

(f(M))t = (let x <= M» inf(x))

[Mf = [M»]

(/i(M))« = (let x <= M«in x)

(Xx : A.MY = [Xx : A* (M«)]

(.MNf = (letf<= in let y^N^ in (fy))

Fig. 7. Monadic-style transform from the computational lambda-calculus into Moggi's Meta-language: Terms

the Meta-language (Fig. 7), Because the monadic-stvle transform is a compiler as explained in Section 1.1, we can conclude that Moggi's semantics of the computational lambda-calculus essentially performs a compilation.

By a direct semantics, I mean a semantics that doesn't compile. So, is there a direct-style categorical semantics of the computational lambda-calculus? If so, what kind of categories do we need? And what is the semantic counterpart of the monadic-stvle transform? In other words, is there a solution for X and the two dashed arrows in figure 8?

In this article, we'll find X, and we'll show that X is the only reasonable solution. We'll call the new categories direct Xc-models. They are abstract Kleisli-categories with extra structure. We get abstract Kleisli-eategories by identifying the available algebraic structure on Kleisli categories. As we shall see, every monad induces an abstract Kleisli-eategorv, What's more interesting is that from every abstract Kleisli-eategorv K, we can recover a monad that induces K, up to isomorphism. Direct Ac-models are to Ac-models what abstract Kleisli-eategories are to monads. Because Moggi's semantics of the computational lambda-calculus in a Ac-model C uses only morphisms of the

form A-TB, we can translate it into a direct semantics that uses direct

Ac-models. Because every Ac-model induces a direct Ac-model, and every direct Ac-model arises from a Ac-model, we neither loose nor gain generality by moving from Ac-models to direct Ac-models. We introduce direct Ac-models

Syntax

Semantics

direct-style

Computational

lambda-c

MS transform

Ac-models

Fig. 8. The missing direct models, marked by X

in Section 2. In Section 3, we show that the computational lambda-calculus forms an internal theory for each direct Ac-model. In Section 5, we analyse exhaustively the mathematical relation between Ac-models and direct Ac-models.

1-4 New insights from direct models

As it turns out, direct Ac-models draw our attention towards previously inconspicuous classes of well-behaved morphisms: So-called thunkable morphisms, central morphisms, copvable morphisms, and discardable morphisms. As we shall see in Section 4, these classes are closed under composition (i.e.they form categories) and more, which means that good program properties propagate along the term structure. This seems to be important for justifying direct-style code optimisations. We'll also see in Section 4 that, for each computational effect, there is the fascinating mathematical challenge to find out how these classes are related.

Abstract Kleisli-eategories are interesting from a purely mathematical point of view too. That every monad induces an abstract Kleisli-eategorv, and every abstract Kleisli-eategorv arises from a monad, follows from a stronger result: An evident category of abstract Kleisli-eategories is reflective in an evident category of Ac-models (Theorem 5.3). The analogous result holds for direct Ac-models and Ac-models (Theorem 5.18). The full subcategory of the category of monads that is equivalent under the reflection to the category of abstract Kleisli-eategories is formed by the monads that fulfil Moggi's equalizing requirement (Theorem 5.23).

1.5 Related work

I found direct Ac-models by analysing Havo Thieleeke's ®-i-eategories [17,18], which are direct models for call-bv-value languages with higher-order types and continuations, (Roughly speaking, continuations bring the power of jumps into functional programming.) As shown in [4], ®-i-eategories are the direct Ac-models that correspond to continuations monads.

Another approach to semantics of call-by-value languages is given by Freyd categories (called so by John Power—see [14,13]), A Freyd category comprises a given category C for modelling values, and a category K for modelling arbitrary terms. The main difference between Freyd categories and abstract Kleisli-eategories is that the latter don't have a given category of values, but one that can be equationallv defined.

One more approach is given by the partially closed focal premonoidal categories of Ralf Schweimeier and Alan Jeffrey [15], They have three given categories: One for modelling values, one for modelling central expressions, and one for modelling arbitrary expressions, Jeffrey and Schweimeier use a nice graphical presentation of direct-style programs (see [8]),

All approaches build on symmetric premonoidal categories, which were introduced by John Power and Stuart Anderson [1], A gentle mathematical introduction to premonoidal categories, and an explanation of their relation to strong monads, is part of see [12], However, I shall explain all necessary aspects of symmetric premonoidal categories in this article.

For direct semantics for call-bv-value with recursion, we have traced monoidal categories [6,5], They, however, rule out important premonoidal models, and therefore exclude many computational effects other than divergence, as Hasegawa pointed out in the conclusion of his thesis [6], This limitation is broken by the partially traced partially closed focal premonoidal categories of Schweimeier and Jeffrey [15],

Anna Bucalo, Alex Simpson, and myself, in our article on equational lifting monads [3], use abstract Kleisli-eategories as a vital tool to prove representation theorems for dominion models of partiality.

2 Direct models

In this section, we define the direct Ac-models by giving structure in three layers:

Direct Ac-models

Precartesian abstract Kleisli-eategories

Abstract Kleisli-eategories

The hierarchy of direct models corresponds to the following hierarchy of monadic models:

Ac-models

Computational cartesian models

In Section 2,1, we define abstract Kleisli-eategories, and find the direct semantics for the monadic term formation rules of the computational lambda-calculus, In Section 2,2, we add structure to get precartesian abstract Kleisli-eategories, and find the direct semantics for the basic term formation rules. In Section 2,3, we add structure to get direct Ac-models, and find the direct semantics for the higher-order term formation rules,

2.1 Abstract Kleisli-eategories

Suppose that T a monad with multiplication ¡j, and unit r] on a category C, and let Ct be the Kleisli category of T. As shown in [9], there is an adjunction

C j_ C'i' Gt

such that (1) GTFT = T, (2) the adjunction's unit is r], (3) letting e be the counit, the GteFt = //, and (4) FT is the identity on objects. The adjunction induces some structure on the Kleisli category: Let

L =cief Fj>G'i< d =def FTT]

We also have the counit e, which is a natural isomorphism L-Id. For

each object A, we have flA : A-LA. However, is not generally a natural

transformation Id-L, as we shall see. Of course, L, and e fulfil certain

equations. This leads us to the following definition:

Definition 2.1 An abstract Kleisli-category is

• A category K

• A functor L : K-- K

• A transformation 2 ■& : Id-L

• A natural transformation e : L-Id

2 By a transformation from a functor F : C-I? to a functor G : C-D, I mean a

map that sends each object A of C to an arrow FA-► GA

such that dL is a natural transformation L-L2, and

Id-- L Id-- L L-- L2

Let's pronounce 'thunk' and e 'force', agreeing with Hayo Thieleeke's terminology for ®-i-eategories, which turned out to be special abstract Kleisli-eategories (see [4]),

Example 2.2 The well-known category Rel of sets and relations, which is isomorphic to the Kleisli category of the covariant powerset monad (see e.g. [7]),

For a set A, let LA be the powerset of A. For a relation R : A-B, and

sets X C A and Y C B, let (where R[X] is the image of X under R)

X(LR)Y Y = R[X] xdX .V = {./•)•

Xe x x e X

Note that, for every abstract Kleisli-eategorv, L forms a comonad on K with eomultiplieation flL and counit e.

Definition 2.3 A morphism / : A is called thunkable if

B of an abstract Kleisli-eategorv K

The category G\$K is defined as the subcategory of K determined by all objects and the thunkable morphisms.

Example 2.4 In Rel, the thunkable morphisms are the total functions.

Note that, if K is the abstract Kleisli-eategorv of a monad T, then a morphisms / of K is thunkable if and only if

/; vt = /; Tri

Now suppose that K is an arbitrary abstract Kleisli-eategorv, For each / 6

K(A, B), let

[/] =def -&\Lf

Letting incl be the inclusion functor G#K c—K, there is an adjunction

[-] : K(incl(A), B) ^ (G\$K)(A, LB)

with unit fl and counit e. Note that if K is the abstract Kleisli-eategorv of a monad T, then

[/] = FTf

Now suppose that C is a Ac-model whose monad is T = (T, //, rj), and let K be the arising abstract Kleisli-eategorv, Figures 9 and 10 show that we can use K to rewrite Moggi's monadic semantics of the monadic term formation rules and the existence judgement of the computational lambda-calculus. In [10], Moggi defines (r b M I A) to hold if the denotation / factors through rj. In the presence of the equalizing requirement, which says that t}a is an equalizer of rjTA and Tr]A, / factors through rj if and only if f;rjT = f',Trj. It turns out that this equation is the suitable interpretation of (r b M I A) in the absence of the equalizing requirement. This is so because in the computational lambda-calculus (r b M I A) is interderivable with the equation (r b let x = M in[x] = [M] : LA) (see [10], bottom of p. 15), whose semantics is f;rjT = f',Trj.

Rule Syntax Monadic semantics Direct semantics

H r b M : A ^ r —^ TA — T —^ A r b [M] : LA = r -L. TA —^ TTA = T ^^ LA

fj, r b M : LA ^ r -Ï-* TTA - T LA r b //(.!/) : A = r —L. TTA —TA = T LA —^ A

Fig. 9. Monadic semantics and direct semantics of the computational lambda-calculus' monadic term formation rules

Rule Syntax Monadic semantics Direct semantics

ex T\~M: A - T —^ TA ^ T —^ A r b M I A & /; 1/r = ./':'/'// f is thunkable

Fig. 10. Monadic semantics and direct semantics of the computational lambda-calculus: The 'existence' judgement

2.2 Precartesian abstract Kleisli-categories

A direct semantics of the computational lambda-calculus' basic term formation rules needs some kind of tensor for modelling product types, projections for modelling variables, and diagonals for modelling pairing. In this section, we're aiming for direct models that arise as Kleisli categories of Moggi's computational cartesian 'models. A computational cartesian model is a category C with

given finite products and a strong monad T. Now let t : A x TB-T(A x B)

be the strength, and let t! : (TA) x B-T(A x B) be the symmetric dual

of t. The tensor and tensor unit are defined as in Figure 11. The diagonals,

A 0 B =def Ax B

I =def 1

c ® f =def (c x A ^L CxTB — T(C x B)) f ®C =def (a x C — BxTC — T(B x C))

Fig. 11. The premonoidal tensor and tensor unit on the Kleisli category of a cartesian computational model

projections, and structural isomorphisms of K are the images under FT of the corresponding maps of C. This leads to the definition of precartesian abstract Kleisli-categories. I call them 'precartesian' because they are (symmetric) premonoidal categories together with projections and diagonals that don't quite form finite products. Roughly speaking, symmetric premonoidal categories are generalised symmetric monoidal categories in that the tensor doesn't have to be a bifunctor, but only a functor in either argument. Because not everybody knows symmetric premonoidal categories, I'll introduce them here (for more, see [12]). First, a couple of auxiliary definitions:

Definition 2.5 A binoidal category is • A category C

For each object A, a functor A ® (—) : C-C

For each object B, a functor (—) ® B : C-C

such that for all objects A and B

{A®{-)){B) = {{-)®B){A)

For the joint value, we write A® B, or short AB.

Definition 2.6 A morphism / : A-A' of a binoidal category K is called

central if for each g : B-B'

AB ■ A'B

BA ■ BA'

A'g gA

B'A —± B'A'

The centre ZK of K is defined as the subcategory determined by all objects and the central morphisms.

Definition 2.7 A symmetric premonoidal category is

• A binoidal category C

• An object I of C

• Four natural isomorphisms A(BC) = (AB)C, IA = A, AI = A, and AB = BA, with central components that fulfil the coherence conditions known from symmetric monoidal categories.

The symmetric monoidal categories are the symmetric premonoidal categories that have only central morphisms. As you can easily check, the natural associativity implies that A ® (—) and (—) ® A preserve central morphisms. Therefore

Proposition 2.8 The centre of a symmetric premonoidal category is a symmetric monoidal category. □

Now for the definition of a precartesian abstract Kleisli-eategorv, It is true, but not obvious, that every computational cartesian model induces a precartesian abstract Kleisli-eategorv by the definitions in Figure 11, We'll show this later in this section.

Definition 2.9 A precartesian abstract Kleisli-category K is

• An abstract Kleisli-eategorv K

• A symmetric premonoidal structure on K

• Finite products on G\$K that agree with the symmetric premonoidal struc-

such that G\$K is a subcategory of the centre.

Example 2.10 We continue our example Rel. As we've seen in Example 2,2, Rel forms an abstract Kleisli-eategorv whose thunkable morphisms are the total functions. The tensor on objects is the cartesian product of sets. On morphisms, the tensor is given by

(x, y) (R ® S) (V, y') ^ xRx' A ySy'

As is well-known and obvious, the tensor forms a symmetric monoidal structure that agrees with the finite products on the subcategory of total functions. This example is a bit weak in that all morphisms are central, but we use it anyway in this section because it is short and elegant.

Now suppose that C is a computational cartesian model, and let K be the arising precartesian abstract Kleisli-eategorv, Figure 12 shows how to use K to rewrite Moggi's monadic semantics of the computational lambda-calculus' basic term formation rules.

In the rest of this section, we'll show that every computational cartesian model induces a precartesian abstract Kleisli-eategorv by the definitions in Figure 11, First we'll prove a proposition that helps checking whether a structure is a precartesian abstract Kleisli-eategorv, Before stating the proposition, we define two important classes of morphisms: Discardable morphisms and eopvable morphisms. For an object A of a precartesian abstract Kleisli-

eategorv K, let U : -1 be the unique element of (G#K)(A, I), and let

5 A : A-A A be the obvious diagonal.

Definition 2.11 Suppose that K is a precartesian abstract Kleisli-eategorv, A morphism / 6 K(A, B) is called discardable if

The category G\K is defined as the subcategory of K whose objects are those of K, and whose morphisms are the discardable morphisms of K.

Example 2.12 In Rel, a morphism R : A-B is discardable if it relates

every .r e A with at least one element of B. So G\Rel is the same as the category Reltot in [7].

Rule Syntax Semantics

val- , . 11.... , xn . An b %i . Ai — . 11 • • • An ' Ai

id r b M : A = r —L* A r,x : A h N : B - i',1 —^ B

r b let x = M in N : B =T —^ IT i',1 B

* r b * : I = T —- I

r b M : A = r A Tt N :B - T —^ B

r b (M, N) : A® B = r —rr Ar AS

TTi r b M : Ai® A2 - T —

r b 7r,(M) : ^ = r A^ Ai

f-.A-»B r b M : A - T —^ A

r b /(M) : B = r —^ A —^ B

Fig. 12. Direct semantics of the computational lambda-calculus: Basic structure

Next we define the notion of copyable morphism. In a precartesian abstract

Kleisli-category, consider the two equations

Both have the same solutions /, because appending the twist map, which is absorbed by S, transforms either equation into the other. But beware the conclusion that the two upper right paths are equal—they differ for continuations (proving this is outside the scope of this article).

Definition 2.13 A morphism / : A-B of a precartesian abstract Kleisli-

category K is called copyable if the two above equations hold, GgK is defined as the class of eopvable morphisms of K.

In contrast to the discardable morphisms, the eopvable ones don't always form a subcategory, as we'll see for global state (Example 4,7),

Example 2.14 In Rel, the eopvable morphisms are the partial functions. So G\$Rel is the same as the category Relsvai in [7],

Proposition 2.15 Suppose that K is an abstract Kleisli-category together

with a binoidal tensor ®, an object I, and transformations 5 a A-A® A,

7Tj : Ai 0 A2-Ai, and ¡.4 : A-I. Then K determines a precartesian

abstract Kleisli-category if and only if

(i) All morphisms of the form [f] are central, copyable, and discardable.

(ii) All components of S, Hi, and !, as well as all morphisms of the form A <S> [/] and [f] ® A, are thunkable.

(iii) Letting (/, g) =aef 8\id ® g\ f ® id, the transformations

k 1 TT2

{tïi,TÏI, (7Ti; 7T2,7T2))

A® I-- A

I® A-- A

A® B-» B ® A

(A® B) ®C-» A® (B®C)

are natural in each argument.

(iv) We have

AB-*(AB)(AB) A-» A® A

Proof. As for the 'only if, all conditions hold because all morphisms of the form [/] are thunkable and by definition the category of thunkable morphisms is a subcategory of the centre and has finite products.

Now for the 'if. Because morphisms of the form A ® [/] and [/] ® A are thunkable, the thunkable morphisms are closed under To see this, let / e (GtK)(A,B). Then (recall that •& = [id])

A® f-d = A® f-d-L(A®d)-L(A ® e) = A® f] A® L(A ® e) = A® [/]; L(A ® e) = \$-L(A®[f])-L(A®e) = L(A ® f)

Because all morphisms of the form [/] are central, so are all thunkable morphisms, To see this, let / e (G\$K)(A, B). Then for every g 6 K(A',B') we have

A ® g; f ® B' = A ® g;[f] ® B'; e ® B' = If] ® A'; LB ® g;e® B' = f ® A';i9 ® A'; LB ® g;e ® B' = f ® A'; B ® g; \$ ® B'; e ® B' = f ® A';B ® g

Because all morphisms of the form [/] are eopvable, so are all thunkable mor-

phisms. To see this, let / e (G#K)(A, B). Then

/; S = /; S; \$ <g> id <g> e; e <g> id = /; id ®e;e® id = [/]; id <g> e; e <g> id

= [/] <g> /; s- <g> id = 8] id <g> /; / <g> id

Because all morphisms of the form [/] are discardable, so are all thunkable morphisms. To see this, let / e {G\$K)(A,B). Then

/;! = /;<?;! = [/];!=!

Now we can summarise that the thunkable morphisms determine a sub bi-noidal category of the centre that has only morphisms which are eopvable and discardable, and contains 5, 7^, and !, Therefore the remaining conditions are enough to imply that /, S, and ! determine finite products on the category of thunkable morphisms. Every category with finite products determines a symmetric monoidal category (see [9], p. 159), Because the symmetric monoidal tensor of G#K agrees with the binoidal product on K, the symmetric monoidal structure on G#K extends to a symmetric premonoidal structure on K. □

Now we turn to prove a result which is slightly stronger than saying that the Kleisli category of a cartesian computational model forms a precartesian abstract Kleisli-eategorv, This is a good time to recall two definitions from [12] and [14], respectively:

Definition 2.16 Suppose that C and D are symmetric premonoidal categories, Then a functor from C to D is strict symmetric premonoidal if it sends central morphisms to such and strictly preserves the tensor, the tensor unit, and the structural isomorphisms.

Definition 2.17 A Freyd category consists of a category C with finite products, a symmetric premonoidal category K with the same objects as C, and an identitv-on-objeets strict symmetric premonoidal functor F : C-K.

Proposition 2.18 Suppose that C is a computational cartesian model. Then

the functor Ft : C-Ct together with the tensor and tensor unit defined

in Figure 11 determines a Freyd category.

Proof. In this proof, let's write semicolon for the composition of Ct, and colon for the composition of C, The structural premonoidal isomorphisms of CT have to be the images of the evident corresponding maps of C, First we prove that, if CT forms a symmetric premonoidal category, then FT is strict symmetric premonoidal. The equation FT(A x /) = A® FTf follows directly

from the equation id x rj : t = rj in the definition of a computational cartesian model. Therefore, Ft strictly preserves the tensor. To see that all morphisms in the image of FT are central, suppose that / is a morphism of C, and g is a morphism of Ct- Then

(Ft f) ® id] id® g = FT(f x id)] id ® g = f x id : id ® g = f x g : t id ® g] (Ft}') ® id = id ® g] Ft(}' x id) = id ® g : GtFt(}' x id) = id x g : t : T(f x id) = id x g : / x id : t

By definition, premonoidal structural isomorphisms are preserved by FT.

Next we check that CT forms a symmetric premonoidal category. That A® (—) preserves the composition of K follows from a routine calculation that uses the naturalitv of t and the equation in the definition of a computational cartesian model that involves t and fj,. That A ® (—) preserves the identity of K corresponds to the equation id x r] : t = r]. By a symmetric argument, (—) ® A too is a functor, so we have a binoidal category. The premonoidal structural isomorphisms are central because they are in the image of FT, and their coherence follows from sending through Ft the coherence diagrams of the corresponding isos of C, So it remains to prove that the structural premonoidal isos of Ct are natural in each of their arguments. The naturalitv of the evident

iso I ® A-A follows from the naturalitv of the corresponding map w2 of

(t T%2 \ 1 x TA-- T( 1 x A)-- TA j = 7r2 in the definition

of a computational cartesian model. The naturalitv of the symmetry map follows from the naturalitv of the corresponding map of C, The naturalitv of the associativity map follows from the naturalitv of the corresponding map of C, and the equation in the definition of a computational cartesian model that involves the strength and the associativity map of C, □

Proposition 2.19 Suppose that F : C-K is a Freyd category, and F

has a right adjoint G with unit r] and counit e. Then K together with the L =def GF, i9 =def Ft], and e forms a precartesian abstract Kleisli-category, where S, Hi, and ! are the images under F of the corresponding maps of C. Moreover, every morphism in the image of F is thunkable.

Proof. All morphisms in the image of F are thunkable, because the equation Fg] \$ = LFg is the image under F of the naturalitv square for rj. No we use Proposition 2,15, By Proposition 2,18, ® is in particular a binoidal tensor. For Condition (i) of Proposition 2,15, note that [/] = F(ft), where jj is the adjunction iso K(FA,B) = C(A,GB). Therefore, [/] is central. Because F preserves S, and !, all morphisms in the image of F are eopvable and discardable, and therefore so is [/]. For Condition (ii), note that A®[f] = A® F(p) = F(A x p). Condition (iv) obviously holds, and Condition (iii) holds because the maps that must be natural are the given structural premonoidal isos of K. □

The proposition that we were aiming for follows directly from Proposi-

A^B =def (TB)A (apply E K((A B)®A, B)) =def (ev E C ((TB)A x A, TB)) A(/ e tf (A ® B, C)) =def FT(A(/ e C(A x B, TC))

Fig. 13. The higher-order structure on the precartesian abstract Kleisli-category of a Ac-model

tions 2.18 and 2.19:

Proposition 2.20 Suppose that C is a computational cartesian model. Then the Kleisli category Ct together with the tensor and tensor unit defined in Figure 11 forms a precartesian abstract Kleisli-category. □

2.3 Direct Ac-models

In this section, finally, we shall define the direct models that arise as Kleisli categories of Moggi's Ac-models. Suppose that C is a Ac-model, and let K be the arising precartesian abstract Kleisli-category. We define higher-order structure on K as in Figure 13. This leads us to the definition of direct Ac-models.

Definition 2.21 A direct \c-model is a precartesian abstract Kleisli-category

K together with, for each object A, a functor A —1 (—) : K-G\$K and an

A : K(incl(B) ® A, C) = (G#K)(B, A ^ C)

Before we prove that the definitions in Figure 13 result in a direct Ac-model, let's consider an example, and complete the direct semantics.

Example 2.22 We continue our example Rel. For sets A and B, let A^ B be the set of relations R E A x B, and let

(R,x) apply def xRy

x(AR)S -r^def S = {(y,z) : (x,y)Rz}

Now suppose that C is a Ac-model, and let K be the arising direct Ac-model. Figure 14 shows how to use K to rewrite Moggi's monadic semantics of the computational lambda-calculus' higher-order term formation rules.

In the rest of this section, we prove that the definitions in Figure 13 result in a direct Ac-model. Like in the preceding section, we proceed in two steps. Now is a good time to recall a definition from [14].

Definition 2.23 A Frevd category F : C-K is closed if for every objects

A, the functor (F-) ® A has a right adjoint.

Rule Syntax Semantics

A 1'../• : .1 1 A/: /i -rxl-Lß

Fl A.r: A.M : A ^ B — Y (A ^ B)

app r b M -.A^B Y -L. (A B) Y b N : A -Y —A

r b MN : B -Y -^l (A- B)A^l B

Fig. 14. Direct semantics of the computational lambda-calculus: Higher-order structure

Proposition 2.24 If C is a \c-model, then the Freyd category FT C-C't is closed.

Proof. In this proof, let's write semicolon for the composition of CT, and colon for the composition of C. For each morphism / G CT(C 0 A, B) we need a unique solution g G C(C, A —1 B) for the equation

(A^B)0A^B

(.FTg) ® A

The required g is A/, where A the Curry map C(A x B,TC) = C(A, (TC)B), because (FTg) 0 A; apply = FT(g x A); apply = g x A : ev. □

Proposition 2.25 If F : C-* K is a closed Freyd-category, then K forms

a direct Xc-model.

Proof. In this proof, let's write semicolon for the composition of CT, and colon for the composition of C. Let A —1 — be the right adjoint of (F—) ® A, and apply the counit. For each morphism / G C(C 0 A, B) we need a unique

thunkable morphism h : C-(A —1 B) such that

(A^B)®A h®A

Let A be the adjunction isomorphism K((FA)®B) = C(A, B —1 C), Because FXf is a solution for h, it remains to prove that every such solution is equal to FXf. To see this, recall that saying h is thunkable is saying that l> : i/r = h : Tri, let jj be the adjunction iso K(FA, B) = C(A, GB), and consider

FXf = FX(h ® A; apply) = FX([h] ® A;e® A; apply)

= FX(F(h}) ® A;e ® A; apply) = F(h>} : A(e ® A; apply)) = F\h^)] FX(e ® A; apply) = [h]\ FX(e ® A; apply) = h] FX(e ® A; apply) = h\ Fr/; FA(e ® A; apply) = h] F(r] : X(e ® A; apply)) = h] F(X(Frj ® A-,e ® A] apply)) = h] F(A(\$ <g> A; e ® A; apply)) = h] F(Xapply) = h] Fid = h

The proposition that we were aiming for follows directly from Propositions 2.24 and 2.25:

Proposition 2.26 Suppose that C is a Xc-model. Then the precartesian abstract Kleisli-category Ct together with the definitions in Figure 13 forms a

3 Direct Ac-models and the computational lambda-calculus

In this section, we translate direct-style categorical expressions like A ® LB and /; [g] into types and sequents, respectively, of the computational lambda-calculus. As we'll see, this translation is in a certain sense the inverse of the direct semantics. We'll use the inverse translation to prove soundness and completeness.

Definition 3.1 [Direct-style signature] For a collection B of base types, the direct-style types over B are defined inductively by

direct Xc-model.

A = LA\A® A\I\A^ A\B

A direct-style constant over B is defined as a formal arrow / : A-B where

A and B are direct-style types over B. A direct-style signature is defined as a

pair £ = (B, JC) where B is a collection of base types, and JC is a collection of direct-style constants over B.

Next we define the domain of our inverse translation:

Definition 3.2 The direct-style categorical expressions over a direct-style signature £ = (B, JC) are defined inductively by

f =id,a | /; / | A ® / | / ® A | 5a | 17r24''4 I ¡a I [/] I ^A I A/ I applyAA I JC

where A ranges over the direct-style types over B, and we obey the obvious type constrains for semicolon and A,

Now for the range of the inverse translation:

Definition 3.3 The computational lamhda-sequents over a direct-style signature £ = (B,JC) are defined as the sequents generated over the base types from B by the rules in Figures 1-3,

The direct semantics implicitly defines a syntactic translation from of computational lambda-sequents into direct-style categorical expressions. Let's write c for this syntactic version of the direct semantics. Now we turn to defining the inverse translation, which we call d. For each direct-style signature £, d takes direct-style categorical expressions over £ to computational lambda-sequents over E, First some auxiliary definitions: For a direct-style type A over a collection of base types B, the factorisation of A is defined as the sequence Ai,,,, ,An of direct-style types over B such that none of the Ai is a product type or the unit type, and A is the product of the Ajt up to associativity of the product and neutrality of the unit type. For example, the direct-style type

((B0 Bi) ® LB2) ® ((LBi ® (B2 ^ Bi)) ® J) has the factorisation

Bq Bi, LB2, LBI, B2 —1 B\

The translation d takes a direct-style categorical expression / : A-B

to a computational lambda-sequent (xi : Ax,... ,xn:An b M : B), where Ai,... ,An is the factorisation of A. We use the following two abbreviations for direct-style lambda terms: First, suppose that (r b M : A) and (yi : Ai,... , yn : An b N : B) are computational lambda-sequents such that Ai,... ,An is the factorisation of A. Then let

(let yi,,,, , yn = M in N) =def(let z = M in let y\ = pi(z) in ...

let yn = pn(z) inN)

d(f : A — -B) = Xi A xn . An b f(x) : A

if / is a constant

d(f : A — -B) = r h M : B

d(g : B — -co = Vi Bu... j Vn • Bn b N :C

d(f;g-.A- — C) = r h let yi, . ■■ ,Vn = M in N : C

d(id : A — -A) = Xi Al... xn . An b x : A

Fig. 15. Translating direct-style categorical expressions into the computational lambda-calculus: Rules for composition and identity

where z is a fresh variable of type A, and Pi(z) is the obvious repeated application of 7Ti and 7t2 to z. Second, suppose that (T, yi : Ai,... ,yn : An b M : B) is a computational lambda-sequent, and the direct-style type A has the factorisation Ai,... ,An. Then let

X(yi,... ,yn) : AM =def (Xz : A.let yu ... ,yn = z in M)

where z is fresh. The translation d proceeds by recursion over direct-style categorical expressions, as in figures 15-18.

The next two lemmas state that the translations c and d are essentially inverse.

Lemma 3.4 In every direct Xc-model, for every direct-style combinator term m, letting i be the evident structural iso, we have

c(c'(m)) = i\m

Proof. By induction over rn. □

Lemma 3.5 Suppose that £ is a direct-style signature, and that (r h M : A) is a computational lambda-sequent over £ such that, letting (xi : Ai,... ,xn : Ai) =def r, none of the Ai is a product type or the unit type. Suppose that M'

c'(f : A — B) r 1 A/ : B

c'(C ®f:C® A -»C® B) = yi : Ci,... '■ Cn, r h (y,M) 5 B

c'(f : A — B) 1' 1 A/ : B

c'(f®C: A® C -► B ® C) = T, yi : Ci,. • • ■) Vn '■ Cn h (M,y) B <5 5>C

c'(8 : A A® A) = si : Ai... :Anh{x ,x}:A ® A

c'(7Ti : A® B ~ A) = si : Ai... ■ An, yi : Bi,... Vn - x : A

c'(7t2 : A ® B — A) = x\ : A\... ■ An, yi : Bi,... Vn : - y : B

c'(! : A -7) = x\ •. A\... :An h * I

Fig. 16. Translating direct-style categorical expressions into the computational lambda-calculus: Rules for tensor and finite products

c'(f ■ 4 -B) = r - M : B

c'([f} : A — LB) = r -[M] : LB

c'(e LA — A) = x LA h /i(a;) : A

Fig. 17. Translating direct-style categorical expressions into the computational lambda-calculus: Rules for [—] and e

c'(f §B- = r,yi : Bi,... ,yn Brn b M : C

c'(A/ : A — (B C)) = I' b A(//|.... ,yn) B.M : B^C

c1 (apply : (A — ±B)® A-- B) = f : A^ B,x : A h - fx: B

Fig. 18. Translating direct-style categorical expressions into the computational lambda-calculus: Rules for higher-order structure

is defined by

(r b M' : A) =def c'(c(r b M : A)) Then in the computational lambda-calculus over £ we have

r b M' = M : A

Proof. By induction over (r b M : A). □

We could remove the restriction on the Ai in Lemma 3.5 by reorganising environments with respect to the tensor, but that doesn't seem to be worth the formal effort.

Definition 3.6 A direct interpretation of a direct-style signature £ = (B,)C) is a direct A^-model K together with, for each base type A e B, an object [A] G Ob(K), and for each constant (/ : A-B) G K,, a morphism

m^KdAim).

Every direct A^-model K gives an obvious direct-style signature T,K, whose base types are the objects and whose constants are the morphisms. Trivially, K forms a direct interpretation of If we know K, then by 'computational lambda-sequents' we mean the ones over T,K.

Definition 3.7 A computational lambda-theory over a direct-style signature £ is defined as a collection T of judgements (T b M = N : A) and (T b M I A) where (r b M : A) and (r b N : A) are computational lambda-sequents over E, such that T is closed under the deduction rules of the computational lambda-calculus.

Definition 3.8 A direct model of a computational lambda-theory T over a direct-style signature E is a direct-style interpretation of £ that validates all judgements of T.

Proposition 3.9 (Semantics of substitution) In every direct Xc-model К, for all computational lambda-sequents

A h N : A Г, x : А, Г' h M : В

such that (Д Ь N A), we have [Г, Д, Г' h M[x := N] : В] = (ГДГ' ГАГ' B)

Proof. By induction over the sequent (Г, x : А, Г' h M : В), The case M = x needs on obvious Lemma about the semantics of weakening, which is easy to prove, □

Like the two preceding lemmas, the next two propositions are somehow opposites of each other. Proposition 3,10 explains how to get a computational lambda-theory from a direct interpretation, and Proposition 3,12 goes in the opposite direction.

Proposition 3.10 (Soundness) Suppose that К is a direct interpretation of a direct-style signature E. Then the judgements (Г Ь M = N : A) and (Г h M J, A) over E that hold in К form a computational lambda-theory.

Proof. By checking that К validates each deduction rule of the computational lambda-calculus. That the true judgements are closed under substitution of variables by terms which 'exist' follows from Proposition 3,9, □

Definition 3.11 Suppose that T is a computational lambda-theory over a direct-style signature £, The binary relation on the direct-style categorical expressions over E is defined as follows: Let rn «7- n if and only if, letting (Г h M : A) = (■'(111) and (Г h N : A) = c'(n), we have (Г h M = N : A) in

Proposition 3.12 (Term model) Suppose that T is a computational lambda-theory over a direct-style signature E. Then ^ a congruence, and the congruence classes form a direct model of T■

Proof. The relation « is a congruence because = is a congruence (That = is a congruence is stated explicitly by deduction rules of the computational lambda-calculus). So we have a graph whose nodes are the direct-style types over E, and whose arrows axe classes of direct-style categorical expressions over E, and on this graph we have well-defined operators like composition of arrows, Л, and so on. We check that we have a direct-style Ac-model by working our way up through the structural layers: Category, abstract Kleisli-eategorv, precartesian abstract Kleisli-eategorv, direct Ac-model, Because of Proposition 2,15, all we need to check is some equations. Each such equation e is checked by deriving in the computational lambda-calculus the equation

which is the image of e under c', The details are left as an exercise. Let's call our direct Ac-model Kr■ Now it remains to prove that Kr is a direct model of T. To see this, suppose that (T h M = N : A) G T, and let m =def c(r h M : A) and n =def c(r h N : A). We need to prove that m, n. So let (r h M' : A) =def c'(m) and (T h N' : A) =def c'(n). We need (r h M' = N' : A) G T. This is so because, by Lemma 3,5, we have (I' h M = M' : A) and (T h N = iV' : A) in T. and = is transitive. Now suppose that (r h M I A) E T, and let m, =def c(r h M : A). We must prove that m is thunkable—that is m; [id] p^t [m]■ By definition of c', letting (r h M' : -4) =def c'(m), we must prove that (T b (let x = M' in [a;]) = [M1] : LA) G T. Because (i' h M I A) E T, we have(T h (let x = M va [a;]) = [M] : LA) G T. The rest follows because by Lemma 3,5, we have (T h M = M' : A). □

Definition 3.13 For every computational lambda-theory T, let Kr be the direct model induced by p^t-

Proposition 3.14 (Completeness) Suppose that T is a computational lambda-theory over a direct-style signature and that (r h M : A) and (r h N : A) are computational lambda-sequents over E. If for every direct model K of T we have

KIT h M : A] = KIT h N : Aj

(r b M = N : A) ET

If for every direct model K of T the morphism h M : A] is thunkable, then (r h M I A) E T.

Proof. First let's prove the claim for the equation judgements. By hypothesis, we have Kj-\T h M : A] = Kj-\T h N : A], By definition of l\ T. letting ^ =def c(r h M : A) and n =def c(r h N : A), we have m, p^t n■ By definition of p^Tj letting (r h M' : A) =def c'(m) and (r h N' : A) =def c'(n), we have (r h M' = N' : A) G T. By Lemma 3.5, we have (T h M = M' : A) and (r h N = N' : A) in r. Transitivity of = implies (r h M = N : A) G T. Proving the claim for the existence judgements is similar, □

Definition 3.15 Suppose that K and K' are direct interpretations of a direct-style signature £, Then a morphism of direct interpretations of £ from K to K' is a morphism of direct Ac-models from K to K' that strictly preserves all base types and constants of £,

Proposition 3.16 (Initiality) Suppose T that is a computational lambda-theory over a direct-style signature £. Then Kj- is an initial object in the category of direct models of T and morphisms of direct interpretations of £.

Proof. Suppose that K is a direct model of T, and that H : K-j--K is a

morphism of direct interpretations of £, Then for each direct-style categorical

expression rn over £, because = [m]«r> we must have H([rn]~T) =

So it remains to prove that H is well defined. To see this, let m p^t n-By definition of «7-; letting (T b M : A) =def c'(m) and (r b N : A) =def c'(n), we have (r b M = N : A) e T. Soundness implies K{T b M : Aj = K{T b N : A], and therefore c(c'(rn)) = c(c'(n)) holds in K. By Lemma 3,4, in K we have c(c'(m)) = i\m and c(c'(n)) = i] n. By transitivity and cancelling i, we have m = n in K. □

Proposition 3.17 Suppose that K is a direct Ac-model. Then there is a natural isomorphism

LA (I A)

that, for each (r h M : A), 'mediates by appending between (r h [M] : LA) and (r h Xx : I.M : I —1 A), where x is fresh, and by prefixing between (y : I Ahy* : A) and (y' : LA h fj,(y') : A).

Proof. The iso and its inverse are given by (y : LA b Xx : I.fJ,(y) : I —1 A), where x is fresh, and (y' : I —1 A h [y1*] : LA). The required properties can be checked easily with the computational lambda-calculus, □

4 Varieties of morphisms

In this section, we'll examine some 'varieties of morphisms' of direct Ac-models: thunkable morphisms, central morphisms, eopvable morphisms, and discardable morphisms. To see what I mean by 'variety', let K be a direct Ac-model, and let A and A' be objects of K. Then by variety of morphisms of K(A,A'), I mean a collection of elements of K(A,A') that solve a collection of equations that use only the signature of direct Ac-models, For example,

the central morphisms / : A-A' form a variety of K(A, A'), because they

are the solutions of the following collection of equations:

{fB- A'g = A9] fB> :B,B'e Ob(K),g e K{B, B')}

By a variety of morphisms of K, I mean a union over all objects A and A' of varieties of K(A, A') that depend uniformly on A and A'. As we shall see, it is interesting to examine and relate these varieties—in general, and for specific computational effects,

4-1 The varieties in terms of the computational lambda-calculus

First, let's recap our knowledge about thunkable morphisms. By the direct semantics rule for existence predicates, in every direct Ac-model, (r b M : A) is thunkable if and only if (r b M I A). By the deduction rules of the computational lambda-calculus, (r b M I A) implies that in all judgements we can substitute M for any free variable of type A. Moreover, (r b M I A)

is interderivable with (T b (letx = M in[x]) = [M] : LA). Therefore, (T b M : A) is thunkable if and only if in all judgements we can substitute M for any free variable of type A. Now let's look at the remaining three varieties.

Proposition 4.1 In a direct Xc-model K, for every computational lambda-sequent (r b M : A), the following are equivalent:

(i) The denotation of (r b M : A) is central.

(ii) For all sequents (A b N : B) and (E, a; : A, y : B b O : C) where E contains all variables of T and A, we have

E b (let x = M in lety = N in O) = (let y = N in let x = M in O) : C

(iii) For fresh variables x : A, y : B, and z : LB, we have

T, z : LB b(let x = M in let y = fj,(z) in (x, y))

= (let y = fj,(z) in let x = M in (x, y)) \ A® B

Proof. Obviouslv, we have (ii) =>■ (iii). Now consider Condition (ii), and let

(/ : T (9- A

(h : E AB

A) =def Kl(T b M : A)]

B) =def Kl(A \-N:B)l

C) =def KlE,x: A,y:B\~0:C}

Let d E K(E, ErA) be the obvious morphism given by the finite products on G\$K. Then the two morphisms

K\ E b (let x = M in lety = N in O) : C] K\E b (let y = N in let x = M in O) : C]

are equal to, respectively, ^ d

ErA EAA -—L EAIl —( '

rl DPA 17 £ JD i,

ErA ^ VA' Il AB

Obviously, the two agree if / is central, which proves (?) =>■ (ii). It remains to prove (iii) =>■ (i). In the case of Condition (iii), we get g = £b and h = 7t2 : EAB-AB. So Condition (iii) implies

f ® LB V® LB --- A® LB

T ® B

A® e A® B

So by Proposition 5,8, / is central.

Proposition 4.2 In a direct \c-model, the denotation a sequent (r b M : A) is discardable if and only if for a fresh variable x : A, we have

T b {let x = M in *) = *: I

Proof. Let / be the denotation of (r b M : A). By definition of the direct semantics, the right side of the equation denotes The left side denotes (5; r/;!), and we have 17;! = 5; Tf; tt2; ! = 5; tt2; /;! = /;!. □

Proposition 4.3 In a direct Xc-model, the denotation a sequent (r b M : A) is copy able if and only if for a fresh variable x : A, we have

T b (let x = M m (x, x)) = (M, M) : A 0 A

Proof. Let / be the denotation of (r b M : A). By definition of the direct semantics, the right side of the equation denotes 5; fT; Af. The left side denotes 5; Tf; ir2; 5, and we have 5; Tf; ir2; 5 = 5; 7r2; f;5 = f;5. □

4-2 Closure properties

In this section, we determine for each of the four kinds of variety the operations under which it is closed in all models. For example, we'll see that the discardable morphisms are closed under identities, composition, 5, 7r«, and !, and that all morphisms of the form [—] and Xf are discardable. Such closure properties may help direct-style code optimisation. For example, the closure properties of discardable morphisms imply that discardable terms of the computational lambda-calculus are closed under all term formation rules except ¡jl and app. So we can infer by induction over terms that a term M is discardable, and replace (letx = M in*) with *,

First, let's recap the closure properties of thunkable morphism. As we know from Section 2,3, the thunkable morphisms form a computational cartesian model. In particular, they are closed under all operations of direct Ac-models except (the nullarv operations) e and apply. Moreover, all morphisms of the form A/ and [/] are thunkable.

Proposition 4.4 The centre of a direct Xc-model is closed under composition, identities, 0, 5, Hi, and !, and all morphisms of the forms A/ and [f] are central. In particular, the centre is a symmetric monoidal category.

Proof. Morphisms of the forms id, 5, !, A/, and [/] are thunkable and therefore central. Closure under composition is obvious. The closure under ® follows from the naturalitv of the associativity iso, □

However, the centre doesn't generally have finite products. To see this, recall Rel, our leading example in Section 2,

Proposition 4.5 The discardable morphisms of a direct Xc-model are closed under composition, identities, 0, 5, Hi, !, and all morphisms of the forms

Af and [/] are discardable. In particular, the discardable morphisms form a symmetric premonoidal category.

Proof. The proof is analogous to that of Proposition 4,4, except for the tensor, To see the closure under the tensor, let / be a discardable morphism, and let A be an object. Then Af:! = Af: w2;! = 7r2; /;! = !. □

The discardable morphisms don't generally form a symmetric monoidal category—continuations form a counterexample, which is outside the scope of this article.

Proposition 4.6 The copy able morphisms of a direct Ac-model are closed under identities, ®, 8, Hi, !, and all morphisms of the forms Af and [f] are copyable. But the copyable morphisms are not generally closed under composition.

Proof. The proof of the closure properties is analogous to that of Proposition 4,4, except for the tensor. The closure under the tensor follows easily from the equation Sab = \$A\$B',i where i is the obvious structural iso. As shown in Example 4,7, the copyable morphisms of direct Ac-models for global state aren't generally closed under composition, □

Example 4.7 [Global state] Suppose that C is a cartesian-closed category, and that S is some object of C. Using the internal language of C (i.e.the A¿^-calculus), we define a direct Ac-model like in Figure 19 (Note that an element / of K(A,B) is a pair (fv,fs) that consists of a 'value component' fv E C(A x S,B) and a 'state component' fs E C(A x S,S)). The direct Ac-model K is isomorphic to the one that arises from the well-known monad TX = (X x S)s, which is also called the 'side-effects' monad. Formal element chasing shows that a morphism f E K(A, B) is copyable if and only if

f(a,s) = f(a,fs(a,s))

For A = B = I this means that / is an idempotent. And idempotents aren't generally closed under composition, as you can easily check for C = Set.

Proposition 4.8 The morphisms of a direct Ac-model which central and copyable are closed under composition, identities, ®, 8, Hi, and !. In particular, they form a symmetric monoidal category.

Proof. We have all closure properties that hold for both central morphisms and copyable morphisms. It remains to show that the composition of two central, copyable morphisms is copyable, which is obvious, □

Proposition 4.9 The morphisms of a direct Ac-model which are central, copyable, and discardable are closed under composition, identities, 8, ir«, !. Moreover, they form a category with finite products.

Proof. An easy exercise, □

Oh(K) =def 06(C) K(A, B) =def C{A x S,B x S) A®B =def Ax B (C ® /)((c, a), s) =def ((c, fv(a, s)), /8(o, s)) (/ ® C)((a, c), s) =def ((/„(a, s), c), /8(o, s)) <J(a,s) =def ((a,a),s) !(a,s) =def (*,s) TTi((ai,a2),s) =def (a¿,s)

LA =def (AS)s [f](a,s) =def (Xs'.f(a,s'),s) e(f, s) =def fs A^ B =def (BS)AS (A/)(a,s) =def (A(b,s').f((a,b),s'),s)

apphj((/, a), «) =def /(o,s)

Fig. 19. Building the direct Ac-model for global state from a cartesian-closed category

Problem 4.10 Do the morphisms which are copyable and discardable form a category? (If so, it would have finite products.)

We can think of the thunkable morphisms as effect free. By contrast, the components of e have maximal effect, as the next proposition shows.

Proposition 4.11

• If each component of e is thunkable, then every morphism is thunkable.

• If each component of e is central, then every morphism is central.

• If each component of e is discardable, then every morphism is discardable.

• If each component of e is copyable, then every morphism is copyable.

Proof. First, note that every morphism / is equal to [f];e and that [/] is thunkable and therefore central, discardable, and copyable. The claims for thunkable, central, and discardable morphisms follow from closure under composition, For the claim about copyable morphisms, suppose that e is copyable, and let / be any morphism. Then

f; S = [/]; e; S = [/]; 5; id ® e; e ® id = 5; id ® [/]; [/] ® id; id ® e; £ ® id = 5; id ® [/]; id ® e; [f] ® id; e ® id = 5; id ® f; f ® id

For some direct Ac-models, the components of e are in none of the four varieties:

Example 4.12 We continue Example 4,7, Let / e K(A, B) = C(A x S, B x S), and consider the following two equations

fv(a, s) = fv(a, s') (1)

fs(a,s)=s (2)

Equation 1 means that the value of / doesn't depend on the store, and Equation 2 means that / doesn't write to the store. As follows from a routine calculation, / is thunkable if and only if both equations hold, and / is discardable if and only if Equation 2 holds, A slightly trickier argument shows that / is central if and only if / is thunkable. Note that discardable implies copyable. Obviously, the components of e aren't generally copyable, and therefore they aren't generally in any of the other three varieties,

4-3 Relating the varieties

Figures 20 displays the four varieties (five, if we count the variety of all morphisms) for an arbitrary direct Ac-model, In this section, we give enough examples to prove that all areas in the figure are inhabited in some model. Too see this, have Figures 21-26 handy. The areas (ZK — G\K) — GgK and (ZKf]G\K)—GsK are obviously inhabited in Rel. The area (ZKC\GsK)—G\K too is inhabited in Rel, and for typical models of partiality. The area (GgK — G\K) — ZK is inhabited for global state in the sense of Example 4,7,

Führmann all

Fig. 20. Varieties of an arbitrary Ac-model all = central

Fig. 21. Varieties of Rel

Fig. 22. Varieties of models of partiality

continuations and exceptions. The area (G\K — GgK) — ZK is inhabited for continuations—proving this is outside the scope of this article. The area (GgK fi G\K) — ZK is inhabited for global state.

The only remaining area is (ZK n G\K n GgK) — G\$K. To see that it can be inhabited, consider the following example:

thunkable = central

Fig. 23. Varieties for global state

eopvable

thunkable = central

Fig. 24. Varieties of ®^-categories (continuations)

all = eopvable

Fig. 25. Varieties for exceptions (TX = X + E)

thunkable

■ all = central = discardable = eopvable

Fig. 26. Varieties for TX = X x X

Example 4.13 Let C be a category with finite products. Let K be the category defined by

ObK =def ObC K(A,B) =def C(A,B)xC(A,B)

with a component-wise definition of composition and identities. Let A®B =def Ax B and I =def 1, and define tensor, diagonal, and projections componentwise. Let

LA =def A x A L(f,g) =def (f x g, f xg)

\$ =def (\$, \$) ^ =def (7ri, 7T2)

A ^ B =def (B x B)A (or BA x BA)

K forms a direct Ac-model, which arises from an obvious Ac-model with TX = X x X. The tensor, tensor unit, diagonals, and projections form finite products on K. In particular, every morphism of K is discardable, eopvable, and central. But the thunkable morphisms are those of the form (/, /).

5 Relating monadic models and direct models

As we've seen in Section 2, every monad induces an abstract Kleisli-eategorv, and every Ac-model induces even a direct Ac-model, in which we can express the semantics of the computational lambda-calculus. In Section 3 we gave a direct-style proof of soundness and completeness. However, there is another way to get these results: The computational lambda-calculus is known to be sound and complete for Ac-models (see [10]). So it must be complete for direct Ac-models too, because if a judgement holds in all direct Ac-models, then in particular it holds in those that arise from Ac-models, and therefore it is derivable. For soundness of direct Ac-models, it is enough to prove that each one such arises from a Ac-model, because for each direct Ac-model K, all derivable judgements hold in its generating Ac-model, and therefore in K.

In this section, we prove an even stronger result, which is also interesting as pure category theory,

5.1 Reflection and soundness

In this section, we define a suitable category of monads, and a suitable category of abstract Kleisli-eategories, and prove that the second is reflective in the first. Then we'll build on this reflection to prove that precartesian abstract Kleisli-eategories are reflective in computational cartesian models, and that direct Ac-models are reflective in Ac-models, Because the counit of a reflection is an isomorphism, we'll know that every direct Ac-model is isomorphic to one that arises from a Ac-model, and therefore we'll have soundness.

Definition 5.1 AbsKl is defined as the obvious category whose objects are abstract Kleisli-eategories, and whose morphisms are functors that strictly preserve L, and e.

Definition 5.2 The category Mnd is defined as follows: An object is a pair C = (C, T), where C is a category, and T is a monad on C. A morphism is a functor that strictly preserves the monad data.

If a C and D are categories, then let's write C < D if C is reflective in D. (Because an adjunction is a reflection if and only if the right adjoint is full and faithful, < is transitive. Because an adjunction is a reflection if and only if the counit is an iso, every equivalence of categories forms a reflection.)

Theorem 5.3 The construction of the abstract Kleisli-category forms a functor Mnd-► AbsKl which is the left adjoint of a reflection

AbsKl < Mnd

To prove the theorem, we define an intermediate category KlAdj of 'Kleisli adjunctions' such that AbsKl < KlAdj ~ Mnd, and use transitivity.

Definition 5.4 A Kleisli adjunction is an adjunction F H G : K-C

such that C and K have the same objects, and F is the identity on objects. The category KlAdj is defined as follows. Objects are Kleisli adjunctions, A

morphism from (F H G : K-- C) to (F' H G' : K'-- C') is a pair of

functors h : C-C and H : K-K' such that h strictly preserves the

unit, H strictly preserves the counit, and

c —— a c —~ a

Lemma 5.5 The construction of the Kleisli category forms an equivalence

Proof. We define functors

Make Mnd

and prove that they form an equivalence. The object part of MakeKlAdj is the well-known adjunction like in [9]:

(fij, \

C _l CT G't }

For h E Mnd(C, D) let

That is, the component between the Kleisli categories acts just like h. Now

for MakeMnd. For a Kleisli adjunction F H G : K-C of KlAdj with unit

r] and counit e, let

MakeMnd (F H G) =def (C, (GF, GeF, v))

The morphism part of MakeMnd is obvious. We have MakeMnd o MakeKlAdj = Id Mnd■ So it remains to find a natural iso MakeKlAdj o

MakeMnd = IdxiAdj- Suppose that F H G : K-C is a Kleisli adjunction.

We have the unique comparison functor ! : CT-* K (like in [9], page 144,

theorem 2, where ! is called L). Let

Ef^g =def (Idc,! : Ct-- K) : MakeKlAdj o MakeMnd = IdjoAdj

Ep-\Q is a morphism of Kleisli adjunctions from FT H GT to F H G. Because F is the identity on objects, ! is an isomorphism (proving this is left as an exercise). Checking the naturalitv of E too is left as an exercise, □

Lemma 5.6 There is a reflection

Proof. We shall define a reflection

For MakeKlAdj, let K be an abstract Kleisli-eategorv, With unit •& and eounit e we have a Kleisli adjunction

MakeKlAdj (K) =def | G#K _ _l K

Now for the morphism part of MakeKlAdj. Suppose that II : K-► K'

is a morphism of abstract Kleisli-eategories, Because H strictly preserves L and H preserves thunkable morphisms. So H has a restriction H : GnK-- G#K'. Let

MakeKlAdj (H) =def (H : G\$K-- G\$K', H : K-- K')

Now for MakeAbsKl. For a Kleisli adjunction F H G : K-C with unit r]

and counit e, let

MakeAbsKl(F H G) =def (K, L, d, e)

L =def FG

\$ =def Frj

For the morphism part of MakeAbsKl, let

MakeAbsKl(h, H) =def H

We have MakeAbsKl o MakeKlAdj = IdAbsKi■ Therefore we define the counit

MakeAbsKl o MakeKlAdj-IdAbsKi of the reflection as the identity on

IdAbsKi■ For the unit, which we'll call U, suppose that F H G : K-C is a

Kleisli adjunction. If / is a morphism of C, then the square expressing that Ff is thunkable is the image of the square /; 77 = 77; GFf under F. So F has a corestriction to G\$K. Let

Uf^g =def (F : G-- G,)K. IdK)

Checking the naturalitv of U is left as an exercise, □

5.1.2 Preeartesian abstract Kleisli-eategories and cartesian computational models

In this section, we extend Theorem 5,3 to state that a suitable category of preeartesian abstract Kleisli-eategories is reflective in a suitable category of computational cartesian models.

Definition 5.7 PrecAbsKl is defined as the obvious category formed by the preeartesian abstract Kleisli-eategories and the functors that strictly preserve all operators (which are: L, e, J, 5, 1r«, and !),

Morphisms of PrecAbsKl would be strict symmetric premonoidal functors if they sent each central map to a central map. It isn't obvious that the images

of central maps are central: For suppose that F : K-K' is a morphism

of precartesian abstract Kleisli-eategories, and / is a central morphism of K. That / is central means that / commutes in the sense of Definition 2,6 with all morphisms g of K. Therefore, Ff commutes with all morphisms of the form Fg. But K' may have morphisms that are not in the image of F. Fortunately, we have

Proposition 5.8 Suppose that K is a precartesian abstract Kleisli-category. A morphism f G K(A,A') is central if for all B G Ob(K)

f ® LB , A® LB --- A ® LB

A® eB

A' ® £B

A® B —-- A ® B

Proof. Let g G K(B,B'). We have g = [g];e. Because [g] is thunkable and therefore central, / commutes with [g\. Because / commutes with e too, / commutes with g. □

Because morphisms of precartesian abstract Kleisli-eategories preserve e, we have

Corollary 5.9 Morphisms of precartesian abstract Kleisli-eategories preserve central morphisms.

Definition 5.10 Ccm is defined as the obvious category formed by cartesian computational models and the morphisms of Mnd that strictly preserve the finite products and the strength.

Theorem 5.11 The construction of the precartesian abstract Kleisli-category forms a functor Ccm-► PrecAbsKl which is the left-adjoint of a reflection

PrecAbsKl < Ccm

To prove this, we define an intermediate category IFreyd, whose objects are Kleisli adjunctions with extra structure, such that PrecAbsKl < IFreyd ~ Ccm, and then we use transitivity. First we define the objects of IFreyd.

Definition 5.12 A I-closed Freyd-category is a Frevd category F : C-K

together with a right adjoint of F.

I call them J-closed Frevd-eategories because they are between Freyd categories and closed Frevd-categories: In a closed Frevd-eategory, for each object A, the functor F(-) ® A has a right adjoint. In an I-closed Frevd-categorv, this needs to be so only for A = I.

Definition 5.13 The category IFreyd is defined as follows. The objects are

the I-closed Freyd-eategories, A morphism from (F H G : K-C) to

(F' H G' : K'-C') is a morphism (h, H) of KlAdj such that h strictly

preserves finite products, and H is strict symmetric premonoidal.

Lemma 5.14 The construction of the Kleisli category forms an equivalence

Ccrri ~ IFreyd

Proof. We extend the equivalence which is formed by MakeKlAdj and MakeMnd to an equivalence which is formed by functors

MakeJFreyd Ccrri « * IFreyd

MakeCcm

The object part of MakelFreyd follows directly from Proposition 2,18, and checking the morphism part is straightforward. For MakeCcm, suppose that

/•' H G : K-- C is an I-closed Frevd-eategory with iso jj : K(FA, B) =

C(A,GB) and counit e. The required strength is

t =def (A ® ef

Checking t is left as an exercise, as well as checking the morphism part of MakeCcm. To see that the two extended functors are inverse up to natural iso, it is enough to check that MakeCcm o MakelFreyd = Idccm (i-e. MakeCcm o MakelFreyd doesn't change the finite products and the strength), and that each component of E is a morphism of I-closed Frevd categories (i.e. the unique comparison functor that is part of every component of E is strict symmetric premonoidal). These two to checks are left as an exercise, □

Lemma 5.15 There is a reflection

PrecAbsKl < IFreyd

Proof. We extend the reflection MakeAb-sKl H MakeKlAdj to a reflection

MakelFreyd PrecAbsKl T IFreyd

MakePrecA b-sKl

The object part of MakelFreyd is obvious, and Corollary 5,9 implies that MakelFreyd sends morphisms of PrecAbsKl to morphisms of IFreyd. The object part of MakePrecAbsKl follows directly from Proposition 2,19, Checking the morphism part is left as an exercise. Because MakePrecAbsKloMakelFreyd doesn't change the finite products, it is equal to IdPrecAbsKi. Because each component of the unit U of the reflection AbsKl < KlAdj preserves the finite products, U determines a unit for the required reflection, □

5.1.3 Direct Ac-models

In this section, we extend Theorem 5,11 to state that a suitable category of direct Ac-models is reflective in a suitable category of Ac-models,

Definition 5.16 DXC is defined as the obvious category formed by direct Ac-models and the morphisms of precartesian abstract Kleisli-eategories that strictly preserve the higher-order structure.

Definition 5.17 Ac is defined as the obvious category formed by Ac-models and the morphisms of computational cartesian models that strictly preserve the T-exponentials,

Theorem 5.18 The construction of the direct \c-model forms a functor Ac-* DXc which is the left adjoint of a reflection

DXc<Xc

To prove this, we define an intermediate category ClFreyd, whose objects are closed Freyd-eategories, such that DXc ^ ClFreyd ~ Ccm, and then we use transitivity.

Definition 5.19 ClFreyd is defined as the obvious category formed by closed Frevd categories and morphisms of I-closed Freyd-eategories that strictly preserve the higher-order structure.

Theorem 5.20 The construction of the Kleisli category forms an equivalence

Xc ~ ClFreyd

Proof. We extend the equivalence which is formed by MakelFreyd and Make Ccm to an equivalence which is formed by functors

MakeClFreyd Xc ': ClFreyd

MakeXc

The object part of MakeClFreyd follows directly from Proposition 2,24, and checking the morphism part is straightforward.

For MakeXc, suppose that F H G : K-C is a closed Frevd category

with adjunction iso jj : K(FA,B) = C(A,GB). We define the T-exponentials on C by

( 1 11) 1 =def A ^ B ev =def apply

Because MakeXc o MakeClFreyd doesn't change the T-exponentials, it is the identity on Ac- It remains to prove that the components of the natural iso E : MakeClFreyd o MakeXc — IdiFreyd preserve the higher-order structure. This is left as an easy exercise, □

Theorem 5.21 There is a reflection

DXC < ClFreyd

Proof. We extend the reflection MakePrecAbsKl H MakelFreyd to a reflection

MakeClFreyd DXC T ClFreyd MakeDXc

MakeClFreyd is obvious, and MakeDXc follows directly from Proposition 2,25, Obviously we have MakeDXc o MakeClFreyd = Idnxc. Because the unit U of the reflection PrecAbsKl < IFreyd strictly preserves the higher-order structure, U determines a unit for the required reflection, □

5.2 The equalizing requirement

Because of the reflection AbsKl < Mnd, abstract Kleisli-eategories correspond to the full subcategory of Mnd that is determined by the objects (C, T) for which the reflection's unit is an iso. In this section, we identify that subcategory.

Definition 5.22 A monad T with unit r] fulfils the equalizing requirement if, for each object A, t]a is an equalizer of t]ta and Tr]A- The category Mndeq is defined as the full subcategory of Mnd determined by the objects (C, T) such that T fulfils the equalizing requirement.

Theorem 5.23 There is an equivalence of categories

Mndeq ~ AbsKl

To prove this theorem, we use a subcategory KlAdjeq of KlAdj such that Mndeq ~ KlAdjeq ~ AbsKl.

Definition 5.24 KlAdjeq is the full subcategory of KlAdj determined by the objects F H G such that, if r] stands for the unit, then for each object A, r/A is an equalizer of tigfa and GFt]a.

The next lemma follows directly from Lemma 5,5,

Lemma 5.25 There is an equivalence of categories

Lemma 5.26 Suppose that F! H G : K-C is a Kleisli adjunction with

defining isomorphism jj : K(FA,B) = C(A,GB). Then an element f of

K(A, B) is thunkable if and only if

GFB-i GFGFB

Proof. Applying the inverse of jj to either path of the diagram yields

Because L = FG and ■& = Frj, the square states that / is thunkable, □

Lemma 5.27 An object F H G : K-► G of KlAdj is in KlAdjeq if and

only if F is faithful and every thunkable morphism of K is in the image of F.

Proof. Suppose that F H G : K-G is a Kleisli adjunction. For the

'only if, let F H G be an object of KlAdj . Suppose that / is a thunkable morphism of K. By Lemma 5,26, we have P;rjGFB = P;GFrjB. Because

r]B is an equalizer of r]GFB and GFr]B, there is a unique g : A-B such

that g; r]B = fK The inverse b of jj sends the equation g-, r]B = p to F g = /, So every thunkable morphism is the image under F of exactly one morphism. Because all morphisms in the image of F are thunkable, F is faithful. Now for the 'if. Because r] is natural, we have

t]B; t]qfb = t]bj GFrjB

for all objects B. Let g e G (A, GFB) such that

9', I]gfb = 9 ] GFrjB

We need a unique f E C(A, B) such that f\ij = g. The adjunction iso b sends the equation /; rj = g to Ff = , By Lemma 5,26, gb is thunkable. So there is exactly one solution /, □

Lemma 5.28 The functor MakeAbsKl forms an equivalence

Proof. Suppose that K is an abstract Kleisli-eategorv, By Lemma 5,27, MakeKlAdj(K) is an object of KlAdj . It remains to prove that the reflection unit U restricts to an iso IdKiA(i,Je = MakeKlAdj o MakeAbsKl. Let

F H G : K-C be an object of KlAdj . Then Uf^g is an iso, because by

Lemma 5,27, F : C-► G,)l\ is an iso, □

Let Ccmeq, XCeq, and ClFreydeq be the full subcategories of Ccm, Xc, and ClFreyd, respectively, that are determined by the objects that fulfil the equalizing requirement. Then Lemmas 5,28 and 5,25 imply

Corollary 5.29 There are equivalences of categories

Ccm^ ~ IFreydeq ~ PrecAbsKl Xceq ~ ClFreyd ~ DXc

Acknowledgements

I am indebted to Havo Thielecke, whose ®-i-eategories were the main inspiration for my analysis of direct models. Thanks a lot to John Power for explaining to me premonoidal categories and more, and commenting on my work. Thanks to Peter Selinger for many discussions. Thanks to Stuart Anderson for commenting on several versions of this article. Thanks to Peter O'Hearn for constructive comments. And a historical remark: Recently, Alex Simpson made me aware of his 1993 LFCS Lab-Lunch talk [16], There he sketched what I call direct models. He had already found the essence of my reflection theorem for monads (Theorem 5,3), But there was no way to transfer this to strong monads, because premonoidal categories had not yet emerged. Finally, I'd like to thank Paul Taylor for his prooftree and diagram macros.

References

[1] Anderson, S. O. and A. J. Power, A representable approach to finite nondeterminism, Theoretical Computer Science 177 (1997), pp. 3-25.

[2] Appel, A. W., "Compiling with Continuations," Cambridge University Press, 1992.

[3] Bucalo, A., C. Fiihrmannand A. Simpson, Equational lifting monads, Available from http://www.dcs.ed.ac.uk/home/car/research.htm (1999), submitted.

[4] Fiihrmann, C., Relating two models of continuations, Available from http://www.dcs.ed.ac.uk/home/car/research.htm (1998).

[5] Hasegawa, M., Recursion from, cyclic sharing: traced monoidal categories and models of cyclic lambda calculi, in: Proc. 6th International Conference on Category Theory and Computer Science (CTCS'95), LNCS 1210 (1997).

[6] Hasegawa, M., "Models of Sharing Graphs (A Categorical Semantics of Let and Letrec)," Distinguished Dissertation Series, Springer-Verlag, 1999.

[7] Jacobs, B., Semantics of weakening and contraction, Annals of Pure and Applied Logic 69 (1994), pp. 73-106.

[8] Jeffrey, A., Premonoidal categories and a graphical view of programs, Available from http://klee.cs.depaul.edu/premon/ (1998).

[9] Lane, S. M., "Categories for the Working Mathematician," Graduate Texts in Mathematics, Springer-Verlag, 1971.

[10] Moggi, E., Computational lambda-calculus and monads, Technical Report ECS-LFCS-88-66, Edinburgh Univ., Dept. of Comp. Sci. (1988).

[11] Moggi, E., Notions of computation and monads, Information and Computation 93 (1991).

[12] Power, J. and E. Robinson, Premonoidal categories and notions of computation, Mathematical Structures in Computer Science 7 (1997), pp. 453-468.

[13] Power, J. and H. Thielecke, Environments, continuation semantics and indexed categories, in: Proceedings TACS'97, LNCS 1281 (1997), pp. 391-414.

[14] Power, J. and H. Thielecke, Environments in Freyd categories and n-categories (1999), iCALP'99, to appear.

[15] Schweimeier, R. and A. Jeffrey, A categorical and graphical treatment of closure conversion, in: Electronic Notes in Theoretical Computer Science. Proceedings MFPS XV, New Orleans, 1999.

[16] Simpson, A., Towards algebraic semantics of programming languages, Notes for a talk at the LFCS Lab Lunch (1993).

[17] Thielecke, H., "Categorical Structure of Continuation Passing Style," Ph.D. thesis, University of Edinburgh (1997).

[18] Thielecke, H., Continuation semantics and self-adjointness, in: Proceedings MFPS XIII, Electronic Notes in Theoretical Computer Science, URL: http://www.elsevier.nl/locate/entcs/volume6.html (1997).