Available online at www.sciencedirect.com

V ScienceDirect

Electronic Notes in Theoretical Computer Science 161 (2006) 43-57

www.elsevier.com/locate/entcs

A Category Theoretic Formulation for Engeler-style Models of the Untyped A-Calculus

Martin Hylanda'4 Misao Nagayama^1 '5, John Power0'2 '6 and

Giuseppe Rosolinid'3,7

a Dept of Pure Mathematics and Mathematical Statistics, University of Cambridge, Wilberforce Road,

Cambridge CB3 OWE, ENGLAND

b Japan Science and Technology Corporation, CREST, Research Center for Verification and Semantics (CVS), National Institute of Advanced Industrial Science and Technology (AlST), 3-11-46 Nakoji, Amagasaki, Hyogo, 661-0974, JAPAN

c Laboratory for the Foundations of Computer Science, University of Edinburgh, King's Buildings,

Edinburgh EH9 3JZ, SCOTLAND

d DISI, Univ. di Genova, via Dodecaneso 35, 16146 Genova, ITALY

Abstract

We give a category-theoretic formulation of Engeler-style models for the untyped A-calculus. In order to do so, we exhibit an equivalence between distributive laws and extensions of one monad to the Kleisli category of another and explore the example of an arbitrary commutative monad together with the monad for commutative monoids. On Set as base category, the latter is the finite multiset monad. We exploit the self-duality of the category Rel, i.e., the Kleisli category for the powerset monad, and the category theoretic structures on it that allow us to build models of the untyped A-calculus, yielding a variant of the Engeler model. We replace the monad for commutative monoids by that for idempotent commutative monoids, which, on Set, is the finite powerset monad. This does not quite yield a distributive law, so requires a little more subtlety, but, subject to that subtlety, it yields exactly the original Engeler construction.

Keywords: Engeler model, untyped A-calculus, cartesian closed category, distributive law, commutative monoid, finite multiset, finite powerset, Kleisli construction

1 This work is supported by the CREST project.

2 This work is supported by EPSRC grant GR/586372/01: A Theory of Effects for Programming Languages.

3 This work is supported by the MIUR project McTati.

4 Email: M.Hyland@dpmms.cam.ac.uk

5 Email: m-nagayama@aist.go.jp

6 Email: ajp@inf.ed.ac.uk

7 Email: rosolini@disi.unige.it

1571-0661/$ - see front matter © 2006 Elsevier B.V. All rights reserved. doi:10.1016/j.entcs.2006.04.024

44 M. Hyland et al. /Electronic Notes in Theoretical Computer Science 161 (2006) 43—57

1 Introduction

Dana Scott proved that any model of the untyped A-calculus, or more directly any A-algebra, generates a cartesian closed category in which the model can be seen as a reflexive object, i.e., an object D together with data exhibiting the exponential Dd as a retract of D [20]. One obtains such a category by taking the Cauchy completion, equivalently the category of retracts, generated by the model. Although a fine completeness result from a category-theoretic perspective, this result does not imply that any A-algebra appears as an object of a natural cartesian closed category such as the category uCpo or some category built from Rel. So, it is an ongoing natural question, from a category theoretic perspective, to see the various models of the untyped A-calculus as reflexive objects in natural cartesian closed categories. In this paper, we investigate the particular situation of models in the spirit of those proposed by Engeler in [8], also investigated in [17].

Engeler's original models for the untyped A-calculus are given by taking a set D for which Pf D x D is a subset of D, where Pf X is the set of finite subsets of X. The set Pf D x D acts as a kind of exponential of D to itself. Every subset is the splitting of a retraction, thus Pf D x D is a retract of D. If one could make the sense in which Pf D x D is a kind of exponential precise via a natural construction, we would have answered our question.

Consider the following heuristic argument: if there was a distributive law of the monad Pf over the powerset monad P, we would have a lifting of the monad Pf to Rel. The latter category is self-dual, so the lifting can be seen as a comonad on Rel. The category Rel is symmetric monoidal closed with products and coproducts, and the lifting sends products to the symmetric monoidal structure of Rel, thereby making the Kleisli category for the comonad cartesian closed. It follows from the structure of Rel that the closed structure in the Kleisli category would be given by PfX x Y. With a little calculation, one could thus see the Engeler construction as a reflexive object of that Kleisli category. However, the argument fails: the natural construction does not yield a distributive law of Pf qua monad over P.

But we can step back. Suppose we replace Pf by Mf, the finite multiset monad. This is the monad for commutative monoids. We can prove that there is always a distributive law of the monad for commutative monoids over any commutative monad T on any base cocomplete symmetric monoidal closed category C: see Section 2. It follows axiomatically that Mf extends to a monad on the Kleisli category Kl(T) of T: see Section 3. The Kleisli category Kl(T) has a canonical symmetric monoidal structure, and the extension Mf of Mf yields the monad for the category of commutative monoids in Kl(T): see Section 4. If we then restrict to Set as base category and take T to be the powerset monad P, it follows that Kl(T) is self-dual and is routinely seen to have enough extra structure to make Kl(Mf )op cartesian closed: we can give a more general analysis of parts of that. With a little calculation, it follows that this provides a mild variant of Engeler's models: see Section 5. For a range of other variants of Engeler's models, see [17].

The difference between Mf and Pf is instructive: Mf is the monad for commu-

tative monoids, while Pf is the monad for idempotent commutative monoids. The latter involves a cartesian equation, namely x + x = x. It is this repetition of x on the left-hand side of the equation that makes the crucial difference here. (How the problem presents itself will be described in Example 2.4.) The argument we gave above for extension of a monad goes through without fuss in more general situations providing one only considers symmetric operadic structure rather than general algebraic structure: we give background in Section 2. But it does not extend to Pf without further effort.

However, returning to Engeler's original construction, suppose we try to find a distributive law of the monad Pf over P. We can readily find a distributive law of Pf qua endofunctor over P: see Section 3. And we can lift its multiplication natural transformation. The only difficulty is that the unit of the monad Pf does not lift from Set to Rel, i.e., it is natural in Set but not in Rel. But that is not so bad: the endofunctor and the multiplication allow us to build a Kleisli construction, but it is a semicategory rather than a category. And semifunctors, which are closely related to semicategories, were investigated precisely in regard to modelling untyped A-calculus by Hayashi in [9]. Semicategories have long been investigated in category theory, see for instance [11]. The data for the unit still exists, and it provides pointwise idempotents. And that is enough for us to mimic the above argument, modulo the mild additional subtlety involved with taking and splitting idempotents, returning Engeler's original model as we explain in Section 5. A fully axiomatic treatment of this more refined argument will appear in a subsequent paper.

This work leaves one striking open question that we are keen to pursue: Engeler models are a simple case of filter models for the untyped A-calculus. So, with a category theoretic formulation for Engeler models in hand, as future work, we intend to extend our category theoretic analysis to account for filter models. Since at least some filter models are naturally domains, this may require a reconstruction of domain theory. That is potentially a large job, hence our deferring it.

2 Distributive Laws and Liftings

Given a pair of monads S and T on a category C, the following result appears widely in the literature, e.g., in [1].

Theorem 2.1 To give a distributive law of monads

A : ST ^ TS

of S over T is equivalent to giving a lifting of the monad T to the category S-Alg.

In this paper, we shall focus on a class of examples of such distributive laws, which we shall describe, where S is the monad for commutative monoids in a symmetric monoidal category C, when such a monad exists, and T is an arbitrary commutative monad on C. We briefly recall the relevant definitions.

Given a symmetric monoidal category C, a strength for a monad (T, n, on C is a natural transformation with components of the form tx,Y : X ® TY —> T(X ® Y) satisfying four axioms expressing coherence with respect to the monad structure of

T and the symmetric monoidal structure of C [15]. A monad with a strength is called commutative if the diagram

tT X Y Tt XY 0

TX ® TY ' ■ T(TX ® Y) —T2(X ® Y)

¡J'X®Y

T(X ® TY)-»- T2(X ® Y)-»- T(X ® Y)

TtX,Y ^X®Y

commutes for all X and Y, where t* is defined from t using the symmetry of C [15].

Given an arbitrary symmetric monoidal category C, one can readily define the category CMon(C) of commutative monoids in C. It inherently comes equipped with a forgetful functor U : CMon(C) —> C. In full generality, the forgetful functor need not have a left adjoint. But it does have a left adjoint in a very wide class of cases, including all that are of primary interest to us: see [14] for some such general conditions. For a far more restricted class than necessary but one that includes our leading examples, if C is closed and cocomplete, the left adjoint exists. In the case that C is Set, the monad for commutative monoids in C is Mf, the finite multiset monad. Extending that notation, we shall denote by Mf the monad for commutative monoids in any symmetric monoidal category for which the left adjoint and hence the monad exists.

It is routine to verify that U : CMon(C) —> C always satisfies the other conditions of Beck's monadicity theorem, so the existence of the left adjoint is sufficient to prove monadicity of CMon(C) over C [14]. Putting this together, we have the following.

Theorem 2.2 If C is a cocomplete symmetric monoidal closed category, the category CMon(C) of commutative monoids in C is monadic over C.

The theorem allows us to express our leading class of examples of distributive laws as follows, cf [15].

Example 2.3 Let C be a cocomplete symmetric monoidal closed category, and let T be a commutative monad on C. It is routine to verify that T lifts to the category CMon(C) of commutative monoids in C. So, Theorem 2.1 yields a distributive law of Mf over T. In particular, taking C to be Set, this induces a canonical distributive law of the monad Mf for finite multisets over any commutative monad T.

This example evidently extends, generalising from the category CMon(C) of commutative monoids in C to the category of models in C of any symmetric operad. We shall not develop that point further here but we intend to do so in future work. For a class of non-examples of a distributive law of monads, but in the same spirit as Example 2.3 and whose structure we shall consider in detail later, consider the following.

Example 2.4 Let C be a category with finite products and let T be a commutative monad on it. Attempting to restrict Example 2.3 to the category ICMon(C) of idempotent commutative monoids (semi-lattices) in C, one fails: the lifting described in Example 2.3 sends an idempotent commutative monoid to a commutative monoid that need not be idempotent. For the specific example relevant to this paper, let C be Set and let T = P be the usual power-set monad. Now the lifting from Example 2.3 amounts to the following. If (A, ■) is a commutative monoid, then P(A) inherits the structure of a commutative monoid with multiplication given by X ■ Y = (a ■ b | a £ X, b £ Y}. But for A idempotent, P(A) is generally not idem-potent (with that multiplication). Now the monad for idempotent commutative monoids is Pf, the finite powerset monad, and we see that the distributive law of Example 2.3 does not quotient to give a distributive law of the monad Pf over the monad P. (It is routine to check the failure of lifting directly.)

It follows from the ideas in [21] that one can generalise Theorem 2.1 and the definitions in it to happen inside a 2-category subject to mild axiomatic conditions. Rather than have a category C, one has an object of a 2-category; similarly for functors and natural transformations; one can readily generalise the construction of the category S-Alg to a construction within a 2-category with some finite 2-categorical limits. The work of the next section, where we investigate the Kleisli construction Kl(S) rather than S-Alg, can also be done in Street's setting and can be seen as a kind of dual.

3 Distributive Laws and Kleisli Extensions

Given a monad (T, n, on a category C, we denote the Kleisli category for (T, n, by Kl(T), and we denote the canonical identity-on-objects functor from C to Kl(T) by J : C —> Kl(T). Note that the functor J need not be faithful, so need not be an inclusion. Nevertheless, it usually is an inclusion, and it is usually harmless to think of it as such. In fact, the functor J is faithful if and only if n is a pointwise monomorphism.

Definition 3.1 Given a monad (T, n, on a category C, and an endofunctor H on C, an extension of H to Kl(T) is an endofunctor H on Kl(T) such that HJ = JH.

Observe that, in the definition, we demand an equality of functors, not merely an isomorphism. That is not only convenient in avoiding coherence conditions, but it is also essential to providing a precise and reasonable result.

Definition 3.2 A distributive law of an endofunctor H over a monad T on a category C is a natural transformation

A:HT ^ TH

subject to commutativity of the evident two diagrams expressing coherence with respect to the unit and multiplication of T.

Proposition 3.3 To give a distributive law of an endofunctor H over a monad T is equivalent to giving an extension of H to Kl(T).

Proof. To go from a distributive law to an extension is routine. And, given an extension H, applying H to the map in Kl(T) from TX to X given by idxx in C, i.e., to the counit of the canonical adjunction, yields a distributive law. It is routine to verify that the two constructions are mutually inverse. □

Given a distributive law A : HT ^ TH, we denote the induced extension by H\. The combination of Theorem 2.1, Example 2.3 and Proposition 3.3 immediately yields a class of examples of extensions for us.

Example 3.4 Let C be a cocomplete symmetric monoidal closed category and let T be a commutative monad on C. As explained in Example 2.3, T lifts to a monad on the category CMon(C) of commutative monoids in C. By Theorem 2.1, this lifting yields a canonical distributive law of the monad Mf for commutative monoids over T. A fortiori, this is a distributive law of Mf qua endofunctor over T. So, applying Proposition 3.3 yields a canonical extension of the functor Mf to Kl(T).

Example 3.5 Taking C to be Set and P to be the powerset monad, the distributive law of Example 3.4 quotients to give a distributive law of the finite powerset functor Pf over P and hence an extension of Pf to Rel, i.e., to Kl(P). This result does not seem to hold for an arbitrary commutative monad T in place of P. The distributive law sends a finite subset A of P(X) to the subset Y of Pf X determined by those finite subsets B of X for which Vb £ B3a £ A.b £ a and Va £ A3x £ a.x £ B.

Trivially, an extension of an endofunctor H to Kl(T) induces an extension of the composite HH to Kl(T): one requires a little care as there may be more than one extension of H to Kl(T). It is routine to verify that a distributive law A : HT ^ TH induces a distributive law of HH over T given by

HHT-»- HTH-»- THH

which we denote by A2. It is straightforward to prove the following result.

Proposition 3.6 Given a distributive law A of an endofunctor H over a monad T, the extension H\2 is exactly the composite H\H\.

We extend the notion of an extension of an endofunctor to Kl(T) and the equivalence with a distributive law to the situation of a natural transformation between endofunctors as follows.

Definition 3.7 Given a monad T on a category C, given endofunctors H and K on C and extensions H and K of H and K to Kl(T), and given a natural transformation a : H ^ K, an extension of a to Kl(T) is a natural transformation a : H ^ K such that a J = Ja.

An extension of a natural transformation is unique if it exists: the data for a is determined by the fact that J : C —> Kl(T) is the identity-on-objects, so the only question is whether the data satisfies the naturality axiom with respect to H and K. Observe that we make mild abuse of notation here: we speak of a extending to

Kl(T) whereas its extension really relies upon a pre-existing choice of extensions of H and K to Kl(T), of which there may be many.

Definition 3.8 Given endofunctors H and K on a category C, a natural transformation a : H ^ K, and a monad T on C, and given distributive laws Ah : HT ^ TH and Ak : KT ^ TK, we say a distributes over T if the diagram

iiT-— Tii

KT-► TK

commutes.

Proposition 3.9 Given distributive laws Ah : HT ^ TH and Ak : KT ^ TK, and a natural transformation a : H ^ K, the natural transformation a distributes over T if and only if there is an extension (necessarily unique) of a to Kl(T).

The proof is routine.

We can combine the above propositions to yield easy proofs of several results. We do not spell out the definitions of a distributive law of each of a pointed end-ofunctor, a copointed endofunctor, a monad, and a comonad, over a monad: the four definitions are routine consequences of the above definitions and propositions (see [16] for the cases involving a comonad). But writing down the result of primary interest to us that flows from the above analysis, we have the following.

Definition 3.10 Given monads (S, n,/) and T on a category C, an extension of S to Kl(T) is a monad (S,n,/i) on Kl(T) such that S, n, and / extend S, n and / respectively.

Theorem 3.11 Given monads S and T on a category C, to give a distributive law of S over T is equivalent to giving an extension of the monad S to Kl(T).

This immediately allows us to develop Example 3.4.

Example 3.12 Let C be a cocomplete symmetric monoidal closed category, and let T be a commutative monad on C. Then the monad Mf for commutative monoids in C extends to Kl(T).

Example 3.13 By dint of Theorem 2.1 and Example 2.4, Example 3.12 does not induce an extension of the monad Pf from Set to Rel: the latter is Kl(P) and we know that the distributive law of Mf qua monad over P does not quotient to one of Pf over P, as otherwise the lifting of P to CMon(C) would restrict to ICMon(C), as discussed in Example 2.4. However, by Example 3.5, there is a distributive law of Pf qua endofunctor over P. Moreover, it is routine to verify that the natural transformation given by the multiplication of Pf distributes over P too. So the functor Pf together with its multiplication natural transformation extend to Rel.

Our development in this section extends readily to the situation of 2-categories and pseudo-monads. Considerably more care is required there with coherence issues, making our perhaps apparently slow progress through this section vital to providing rigorous proofs at that increased level of generality. We shall return to the two-dimensional case in future work, as it coheres with the work of Winskel and colleagues on domain theory for concurrency, where Set is replaced by Cat, the powerset monad is replaced by the presheaf construction, which is a pseudo-monad in every way except for size, and where commutative monoids are replaced by symmetric monoidal categories [4]. The notion of commutative monad generalises to that of pseudo-commutative 2-monad, and our axiomatic development of commutative monads and their relationship with commutative monoids extends to pseudo-commutative 2-monads and symmetric monoidal categories [12]. Details of the definitions and constructions involved with pseudo-distributive laws will appear in [22] but see also [5] for an outline.

4 Symmetric Monoidal Adjunctions and Commutative Monoids

Our attention so far has focused on a commutative monad T on a symmetric monoidal closed category C, and we have considered the relationship between the monad Mf for commutative monoids on C and T, equivalently the extension of Mf to Kl(T). The latter is a statement about the monad structure of Mf. In this section, we address issues that more specifically involve the commutative monoid structure of Mf: but the following does still apply to symmetric operads more generally. The commutative monoid structure of Mf involves the symmetric monoidal structure of C more directly, together with the notion of commutative monoid in C and in Kl(T). We recall some elementary definitions from [7].

Given symmetric monoidal categories C and D, a symmetric monoidal functor from A to B is a functor H : A —> B together with natural transformations with components HX ® HY —> H(X ® Y) and I —> HI subject to four coherence conditions to the effect that the associativity, left and right unit, and symmetry isomorphisms are respected. A symmetric monoidal functor is called strong if the structural natural transformations are invertible. A symmetric monoidal natural transformation between symmetric monoidal functors H and K is a natural transformation a : H ^ K that respects the rest of the structure for a symmetric monoidal functor. Small symmetric monoidal categories, symmetric monoidal functors, and symmetric monoidal natural transformations form a 2-category SymMon. A symmetric monoidal adjunction is an adjunction in the 2-category SymMon.

The following result is straightforward to prove and is implicit in [7].

Theorem 4.1 Every symmetric monoidal adjunction from A to B lifts to an adjunction from CMon(A) to CMon(B).

That is the result we need, providing we can obtain a symmetric monoidal adjunction between a base category C and Kl(T) for a commutative monad on C.

In fact, we can do that, via the following line of argument. The following result is not in its most general form (see [3]) but is in the form we need here [13].

Theorem 4.2 Given symmetric monoidal categories A and B and given an ordinary adjunction F H G : A —> B, to extend the adjunction to an adjunction of symmetric monoidal categories is equivalent to giving a strong symmetric monoidal structure on the ordinary functor F : B —> A.

We can combine that characterisation of symmetric monoidal adjunctions with the following result in [19].

Theorem 4.3 Given a symmetric monoidal category C and a monad T on it, to give a commutative strength for T is equivalent to giving a symmetric monoidal structure on Kl(T) such that the Kleisli adjunction is a symmetric monoidal adjunction.

The significance of this for us is that, given a commutative monad T on a cocomplete symmetric monoidal closed category C, it yields a characterisation of the extension Mf of Mf to the category Kl(T).

Corollary 4.4 For any cocomplete symmetric monoidal closed category C and for any commutative monad T on C, the extension Mf of Mf is the monad describing the free commutative monoid in the symmetric monoidal category Kl(T).

Proof. By Theorem 4.2 and Theorem 4.3, the Kleisli adjunction extends canoni-cally to a symmetric monoidal adjunction between C and Kl(T). By Theorem 4.1, the adjunction lifts to an adjunction between CMon(C) and CMon(Kl(T)). In particular, the diagram of categories

CM<m(Kl(T)) — CManiC)

Kl(T)-- C

commutes, with the evident labelling of functors. The left adjoint of the composite is JMf = Mf J, and the counit of the symmetric monoidal adjunction extends from Kl(T) to CMon(Kl(T)). So Mf must act as the free commutative monoid in Kl(T). □

We have one final axiomatic result here. In some categories with finite products and finite coproducts, notably Set, the monad Mf admits the property that the canonical comparison map

Mf (X + Y) —> Mf X x Mf Y

is always an isomorphism. For those categories C for which that is true, we seek conditions under which, given a commutative monad T, that fact lifts to Mf, by which we mean that the isomorphism induces an isomorphism from Mf (X + Y)

to MfX ( Mf Y, using the fact that coproducts extend to Kl(T) and using the symmetric monoidal structure on Kl(T) induced by Theorem 4.3. The only issue is one of naturality of the comparison map with respect to Kl(T).

Proposition 4.5 For any commutative monad T on a cocomplete cartesian closed category C, the extension Mf of Mf sends coproducts in Kl(T) to the symmetric monoidal structure of Kl(T) if the diagram

Mf(TX + TY) — MfTX x MfTY — TMfX x TMfY

MfT(X + Y)-► TMf(X + Y)-► T(MfX x MfY)

with all maps given by the canonical choices, commutes.

Evidently, this result extends beyond Mf to any symmetric operad and to some non-operadic monads such as that for Abelian groups.

In order to analyse Engeler-style models of the untyped A-calculus as we shall do in the next section, we should like to find axiomatic conditions under which the category Kl(Mf )op for a commutative monad T on Set is cartesian closed: we know it has finite products, as Kl(Mf) has finite coproducts. And the above proposition helps, as it means that a map out of a binary product in Kl(Mf )op, i.e., a map into a binary coproduct in Kl(Mf), can be seen as a map into a tensor product in Kl(T), but from that point, at present, we do not see how to proceed without using the self-duality and closedness of our leading example, that where T is P and therefore Kl(T) is Rel. We can, however, generalise in a non-trivial way to 2-categories: the bicategory Prof of small categories and profunctors is not quite self-dual in the sense we use here, but it has enough self-dual structure to allow us to mimic our argument.

5 Engeler Models

In this section, we finally link our axiomatic development of previous sections with Engeler's construction. We first consider the variant given by finite multisets, as that provides easier and more elegant category-theoretic models of untyped A-calculus. We then proceed to Pf, as Engeler originally considered. That involves more complex category theory, but it also allows us to make a more precise statement of the relationship.

The following easy result has been fundamental to the semantics of linear logic over many years [2].

Theorem 5.1 Let C be a symmetric monoidal closed category with finite products, and let G be a comonad on C that sends finite products to the symmetric monoidal structure. Then the Kleisli category Kl(G) is cartesian closed, with exponential given by the linear exponential [GX, Y] in C.

Example 5.2 The category Rel is symmetric monoidal closed, in fact compact closed, with the symmetric monoidal structure given by the product of sets, and it has both products and coproducts given by the coproduct of sets. Moreover, it is self-dual and the linear exponential is given, most unusually, by the product of sets. We know from previous sections that Mf extends to a monad on Rel, hence equally to a comonad on Rel, and the extension sends coproducts to tensors. Thus, if we denote the comonad corresponding to Mf by Mf, it follows that Kl(Mf), equally Kl(Mf )op, is cartesian closed. The closed structure is given by Mf X x Y.

Example 5.2 gives us a cartesian closed category. To give a reflexive object of the category is to give a set D together with data to exhibit Mf D x D as a retract of D in Kl(Mf). But retractions are preserved by all functors, and there is a canonical composite inclusion functor from Set to Kl(Mf). So, given any retraction in Set, i.e., any set D together with an inclusion of MfD x D into D, application of the canonical inclusion yields a reflexive object of Kl(Mf). One can obtain sets satisfying the conditions required of D by solving the evident domain equation. Thus the variant of Engeler models given by replacing Pf by Mf may be seen as reflexive objects in the cartesian closed category Kl(Mf).

We now consider exactly Engeler's models by replacing finite multisets by finite subsets. In principle, we wish to remain as axiomatic in our development as reasonably possible. But, as discussed in Example 3.13, the natural extension of the monad Pf to Rel does not satisfy the axioms for a monad on Rel, and so does not yield a Kleisli category for a monad on Rel. This leads us to relax the definition of category to consider semicategories: a semicategory consists of the data for a category except for the existence of identity maps, the only axiom being that composition is associative. Semifunctors are graph morphisms that preserve composition, see for instance [11].

We do not assert definitiveness of the following definition, but it is convenient for us in expressing the results of this section.

Definition 5.3 A near-monad on a category C consists of an endofunctor S on C, a natural transformation ^ : S2 ^ S satisfying the associativity condition

53 fiS f g2

and an ObC-indexed family of maps nx : X

SX such that the following dia-

grams commute:

SX —^ sx S2X

Example 5.4 Our leading example is given by the extension to Rel = Kl(P) on Set of the endofunctor Pf and its multiplication natural transformation as in Example 3.13, together with the data for the unit of Pf.

Definition 5.5 Let S be a near-monad on C. Denote by Kl(S) the semicategory whose objects are those of C, with the homset Kl(S)(X, Y) defined to be C(X, SY), and with composition defined by

X-SY Vz t sz

The construction Kl(S) is limited as a generalisation of the Kleisli construction: observe that the canonical graph morphism from C to Kl(S) need not even satisfy the axiom for a semifunctor as it need not preserve composition. So in order to make any axiomatic progress, we need to make ancillary constructions as follows.

Definition 5.6 Given a near-monad S on C, denote by Cn the subcategory of C with the same objects as C, with a map f : X —> Y of C lying in Cn if the diagram

commutes.

Definition 5.7 Given a near-monad S on C, denote by Kl(S)n the subsemicat-egory of Kl(S) determined by all objects of Kl(S) together with those maps f : X —> Y for which the following diagram in Kl(S) commutes:

There is a key difference between the above two definitions residing in the direction of the right-hand vertical arrow: in the former definition, it points downward, while in the latter, it points upward. In the former, the arrow can only point downward as there is no natural arrow upward. But in the latter, the direction of the arrow is exactly that required to make Kl(S)n the full subcategory of the idem-potent splitting of Kl(S) determined by the idempotents (X, nx) in Kl(S). The idempotent splitting is the cofree category on the semicategory Kl(S).

Note that the maps nx need not lie in the category Cn: they do not form a natural transformation, so there is no reason to believe that they are natural with respect to themselves. But they do lie in Kl(S)n, where they act as identity maps. And they do lie in C, allowing us to prove the following result.

Proposition 5.8 Given a near-monad S on C, the canonical graph morphism from C to Kl(S) restricts to a functor J : Cn —> Kl(S)n.

We can extend this proposition to deal with coproducts in C: in our leading class of examples, C is of the form Kl(T), which always has coproducts if the base category does, and we are trying to make a further Kleisli-like construction on Kl(T) that is functorial, so preserves retracts, and preserves coproducts: the latter become products in the presence of self-duality. In fact, preservation of coproducts is routine.

Proposition 5.9 Suppose C has finite coproducts. Let S be a near-monad on C for which the coprojections X^ —> X0 + Xi lie in Cn. Then Cn has and J : Cn —> Kl(S)n preserves finite coproducts. Hence, Kl(S)n has finite coproducts.

From this point, an axiomatic development seems forced. So we shall restrict to the particular example of primary interest to us, where C is Rel and S is given by Pf together with its multiplication and the data for the unit of Pf, i.e., the singleton maps X —> Pf X.

By Proposition 5.9, the category Kl(Pf)n has finite coproducts, and, as n is natural on Set, and using the self-duality of Rel, we have a canonical functor from Set into Kl(Pf)np. The latter category need not in general be cartesian closed, but, as in [9], its idempotent-splitting is, with the exponential

of sets X and

Y given by splitting an evident idempotent on PfX x Y, exactly analogously to the situation for finite multisets in Example 5.2. So, analogously to Example 5.2 but with one further step, any set D with PfD x D exhibited as a subset of D yields the structure making D a reflexive object of the cartesian closed category determined by the idempotent-splitting of Kl(Pf : for the exponential Dd is a retract of Pf D x D, which is in turn a retract of D.

Once again, as was the case for finite multisets, in order to obtain a particular reflexive object D, one simply needs solve in Set the domain equation D = A + Pf D x D for countable A = 0. The least fixpoint yields a countable set, with the binary operation on Pf (D) given by the relation R from Pf (D) x Pf (D) to D defined as follows:

(u, v)Rb if (u = {(ui,b), •••, (un,6)}) A (v = [_Ji ui).

This generates a set-theoretic A-model on any homset with codomain D, and, considering the hom of 0 into D yields exactly Engeler's original model [8].

By way of conclusions we say something about the connection between our view of Engeler's model and that current in the literature. (A good survey of constructions from this domain-theoretic point of view is in Plotkin [18].) The simplest story starts from the theory of semifunctors (Hayashi [9]). As shown by Hoofman [10] (but see also [11]) this theory allows the construction of the category POW of power sets and continuous maps using a quite different structure associated to finite subsets. Hoofman observed that Engeler's model can be regarded as lying in (the idempotent completion of) POW which is a category of domains. For us Engeler's model lies naturally in Kl(Pf )np. This latter category is emphatically not a category of domains; specifically it does not have enough points. What we wish to stress then is that Engeler's model works for a combinatorial reason independent of domain theory. However POW is locally a retract of Kl(Pf )np and in a way which is a bijection on points. In this way one can retrieve the domain-theoretic point of view.

We close by explaining the programme of work which we initiate here. Filter lambda models as introduced by the Torino school (see [6] for example) are usually taken to amount to a presentation of domain theoretic models. Certainly they are lambda models as they appear to come from categories with enough points. But our analysis of the Engeler model is that it naturally arises from a category without enough points. So in our formulation it is naturally a lambda algebra in the established terminology. Now the Engeler model is taken to be part of the general family of filter models. So this raises (at least for us) questions along the following lines. Which filter models really are domain models (after all nobody doubts Scott's DTO), and which are naturally something else? There seems much more to understand about concrete constructions of models for the lambda calculus (that is, in general about lambda algebras).

References

[1] M. Barr and C. Wells, Toposes, Triples, and Theories, Grundlehren der math. Wissenschaften 278, Springer-Verlag, 1985.

[2] N. Benton, G. Bierman, V. de Paiva, and M. Hyland, Linear A-Calculus and Categorical Models Revisited, Proc. Computer Science Logic 1992, Lecture Notes in Computer Science 702, Springer-Verlag, 1993, 61-84.

[3] R. Blackwell, G.M. Kelly, and A.J. Power, Two-Dimensional Monad Theory, J. Pure Appl. Algebra 59 (1989) 1-41.

[4] Gian Luca Cattani and G. Winskel, Profunctors, Open Maps and Bisimulation, Mathematical Structures in Computer Science (to appear).

[5] E. Cheng, M. Hyland, and A.J. Power, Pseudo-Distributive Laws, Proc. MFPS 2003, Electronic Notes in Theoretical Computer Science 83 (2003).

[6] M. Coppo, F. Honsell, M. Dezani-Ciancaglini and G. Longo, Extended type structures and filter lambda models, Logic Colloquium '82, North-Holland, Amsterdam 1984, 241-262.

[7] S. Eilenberg and G.M. Kelly, Closed Categories, Proc. Conference on Categorical Algebra La Jolla 1965, (1966) 421-562.

[8] E. Engeler, Algebras and Combinators, Algebra Universalis 13 (1981) 389—392.

[9] S. Hayashi, Adjunction of Semifunctors: Categorical Structures in Nonextensional A-Calculus,

Theoretical Computer Science 41 (1985) 95-104.

10] R. Hoofman, The Theory of Semi-Functors, Mathematical Structures in Computer Science 3 (1993) 93-128.

11] R. Hoofman and I. Moerdijk, A Remark on the Theory of Semi-Functors, Mathematical Structures in Computer Science 5 (1995) 1-8.

12] M. Hyland and A.J. Power, Pseudo-Commutative Monads and Pseudo-Closed 2-Categories, J. Pure Appl. Algebra 175 (2002) 141-185.

13] G.M. Kelly, Doctrinal Adjunction, Category Seminar Sydney 1972/73, Lecture Notes in Mathematics 420, Springer-Verlag, 1974, 257-280.

14] G.M. Kelly, A Unified Treatment of Transfinite Constructions for Free Algebras, Free Monoids, Colimits, Associated Sheaves, and so on, Bull. Austral. Math. Soc. 22 (1980) 1-83.

15] A. Kock, Closed categories generated by Commutative Monads, J. Austral. Math. Soc. 12 (1971) 405424.

16] M. Lenisa, A.J. Power, and H. Watanabe, Distributivity for Endofunctors, Pointed and Co-pointed Endofunctors, Monads and Comonads, Proc. CMCS 2000, Electronic Notes in Theoretical Computer Science 33 (2000).

17] G. Longo, Set-Theoretical Models of A-Calculus: Theories, Expansions, Isomorphisms, Ann. Pure Appl. Logic 24 (1983) 153-188.

18] G.D. Plotkin, Set-Theoretical and Other Elementary Models of the A,-Calculus, Theoretical Computer Science 121 (1993) 351-409.

19] A.J. Power and E. Robinson, Premonoidal Categories and Notions of Computation, Proc. LDPL 1996, Mathematical Structures in Computer Science 7 (1997) 453-468.

20] D.S. Scott, Relating Theories of the A-Calculus, To H. B. Curry: Essays in Combinatory Logic, A-Calculus and Formalism, Academic Press, 1980, 403-450.

21] R. Street, The Formal Theory of Monads, J. Pure Appl. Algebra 2 (1972) 149-168.

22] M. Tanaka, Pseudo-Distributive Laws and a Unified Framework for Variable Binding. Edinburgh Ph.D. thesis (submitted).