Available online at www.sciencedirect.com

shce(S

DIRECT0

Electronic Notes in Theoretical Computer Science 158 (2006) 59-80

www.elsevier.com/locate/entcs

Computational Effects in Topological Domain Theory

Ingo Battenfeld1 '2

LFCS, School of Informatics University of Edinburgh Edinburgh, UK

Abstract

This paper contributes towards establishing the category QCB, of topological quotients of count-ably based spaces, and its subcategory TP, of topological predomains, as a flexible framework for denotational semantics of programming languages. In particular, we show that both categories have free algebras for arbitrary countable parametrised equational theories, and are thus, following ideas of Plotkin and Power, able to model a wide range of computational effects. Furthermore, we give an explicit construction of the free algebras.

Keywords: topological domain theory, domain theory, computational effects, denotational semantics.

1 Introduction

One of the main tasks in denotational semantics is to provide a mathematical framework for modelling programming languages that supports many type constructions and models a wide variety of computational phenomena. The most popular approach to this is (classical) domain theory (see [1]), in which categories of directed complete partially ordered sets (dcpos) and continuous maps are considered. Domain theory has succeeded in providing categories that are cartesian closed (and hence allow type constructions such as products and function spaces), categories that model nontermination, recursion

1 This research was supported by an EPSRC research grant, 'Topological Models of Computational Metalanguages'

2 Email: I.D.Battenfeld@sms.ed.ac.uk

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

and recursive types, categories that allow polymorphic type constructions and categories that support other computational phenomena such as nondetermin-ism or probabilistic computations (via powerdomain constructions). However, domain theory has not succeeded to provide a single category combining all these positive results. Another, simpler, approach to denotational semantics has been proposed by Smyth [19] and is based on the analogy of datatypes to topological spaces and programs to continuous functions. The goal of topo-logical domain theory is to combine these approaches and provide a category of topological spaces that models all of the features mentioned above.

The category underlying our proposed framework is QCB, the category of topological quotients of countably-based topological spaces, which has been shown to be cartesian-closed (see [4,8]) and to have a full reflective exponential ideal TP (see [2,18]) of topological predomains, which allows domain-theoretic constructions in a topological setting. One striking property is that these categories can be viewed as subcategories in the realizability topos over Scott's combinatory algebra Pu (see [2]), from which it follows that polymorphism can be modelled in them.

The goal of the present paper is to show how computational effects in the sense of Moggi [9,10] can be modelled in QCB and TP, via a free algebra approached based on the work of Plotkin and Power [12,13,14].

In general, the underlying concept of a functional programming language is given by a clean mathematical calculus, the A-calculus, enriched with some basic features, such as basic types, constants or functions. However, in computing non-functional behaviour occurs, such as for instance nondeterministic choice, nontermination, exceptions, side-effects or input/output, and these so-called computational effects are in general not covered by the pure A-calculus. Thus, if one aims at giving semantics to an actual implemented programming language, the relevant computational effects have to be taken into account.

The initial approach to this was taken by Moggi [9,10], who distinguished between types of values and types of computations. For each type of values X in the language, there is a corresponding type of computations TX, on which a computational effect can be modelled. In Moggi's theory, T is the functor of a monad, and he introduced the computational A-calculus, for which a semantic model is given by the Kleisli-category CT over some cartesian-closed category C. Recently, Plotkin and Power [12,13,14] have shown that a surprising number of the computationally interesting monads are generated as free algebras for equational theories in the sense of universal algebra. What is striking about this approach is that the associated algebraic operations are exactly the natural computational primitives for generating the relevant effects. For example, if one considers a binary operation choose : TX2 ^ TX subject to

equations expressing idempotence, commutativity and associativity, then the corresponding free algebra functor will be the functor for the nondeterminism monad. Thus, Plotkin and Power reformulated Moggi's approach, taking the operations of the effects as primitive, relating them by equations to get an equational theory in the sense of universal algebra, and then calculating the corresponding monad T as the functor that associates to an object X the free algebra TX of this equational theory. In view of Plotkin and Power's approach, one would like to show that a general framework for denotational semantics supports a free algebra construction for a sufficiently rich class of equational theories, in order to model a wide class of computational effects.

Therefore, we show that the category QCB and its subcategory TP have free algebras for countable parametrised equational theories, and thus indeed many computational effects can be modelled in them. As the objects of QCB are topological spaces, we start by looking at free algebras in Top, the category of topological spaces and continuous maps. Work on free algebras for finitary (non-parametrised) equational theories in Top has been done for instance by Malcev [7] and Taylor [20]. However, even though free algebras for equational theories exist in Top, a well-known categorical colimit construction does not work here. Equations cause particular problems, due to the lack of cartesian closedness of Top. Therefore, Porst [15] has investigated free algebras for coreflective cartesian closed subcategories of Top, and shown that here the situation improves. In [8], QCB has been introduced as a subcategory of Seq, the category of sequential spaces and continuous maps, which is a coreflective cartesian closed subcategory of Top. We will show that QCB is closed under the free algebra construction in Seq, and that free algebras in TP are obtained using the reflection functor. Some of our results on free algebras for Top and Seq in this paper are generalisations of known results for finitary equational theories to countable parametrised equational theories, such as e.g. Lemma 3.3 below. Other results, e.g. Theorem 3.8, seem to be new.

The main result of this paper is the proof that free algebras for a wide class of equational theories exist in QCB and TP, which enables us to model computational effects in the sense of Plotkin and Power. Moreover, we give an explicit construction of the free algebras in both categories, which promises to be very useful for combining our results with other properties of the framework QCB.

We start by introducing QCB and topological predomains and relating them to Seq, in Section 2. Then, guided by examples, we give our definition of countable parametrised signatures in Section 3 and examine absolutely free algebras in the categories of topological and sequential spaces, showing that countably-based spaces are preserved under this construction. In Section 4, we

look at algebraic operations (in the sense of Plotkin and Power [14]), use them to introduce equations, and show the existence of free algebras for countable parametrised equational theories in QCB. In Section 5, we transfer these free algebras to TP. We end by giving conclusions in Section 6.

2 Preliminaries

Let Top denote the category of topological spaces and continuous maps. A subset U of a topological space X is called .sequentially open if whenever x E U and a sequence (xn)n converges to x, then the sequence is eventually in U, i.e. there exists a K E N such that for all n > K, xn E U. Notice that open sets of a topological space are always sequentially open. A space X is called .sequential if the converse holds, i.e. if all its sequentially open sets are open. By Seq, we denote the category of sequential spaces and continuous maps. Seq is a full coreflective subcategory of Top, the coreflection adds to the topology of a space X all its sequentially open subsets. Moreover, Seq is cartesian closed, a property Top famously does not have. From a computational viewpoint Seq seems to be more natural than Top, as here continuity is characterised by convergence of sequences.

QCB is the category whose objects are topological quotients of second countable topological spaces and continuous maps between them. We call the objects of QCB simply qcb-spaces. QCB is a full subcategory of Top and also of Seq. It has been shown to be bi-cartesian closed in [8], and to inherit this structure from Seq and other cartesian closed subcategories and supercategories of Top in [8,4]. Furthermore, QCB can be interpreted as a category in the realizability model over Scott's graph model Pu (see [2]), and also as a category in the theory of Type-2 Effectivity (see [16]). For the purposes of the present paper, we only consider QCB as a subcategory of Top and Seq, and ignore the other connections.

A topological space can be equipped with its specialisation pre-order C, where x C y if any open set containing x also contains y. Then C is a partial order on a space if and only if it satisfies the T0-separation axiom. Conversely, any ordered set can be equipped with its Scott topology (see [5]). Then a monotone convergence .space is a topological space whose specialisation pre-order is a dcpo, and whose topology is coarser than the Scott-topology. A qcb-space that is a monotone convergence space is called a topological predomain [18], and TP is the full subcategory of topological predomains and continuous maps. It turns out that TP is a full reflective exponential ideal of QCB (see [3]), so in particular it is cartesian closed.

In classical domain theory, one often distinguishes those dcpos that have

a least element (dcppos). Topological predomains whose specialisation pre-order is a dcppo are called topological domains, and they form the category TD. Drawing a comparison between QCB and classical domain theory, TP and TD are topological analogues of DCPO and DCPPO, the categories of dcpos, resp. dcppos, and continuous maps. Remarkably, many domain theoretic properties and constructions readily carry over to the topological setting (see e.g. [18,3]).

3 Parametrised signatures and absolutely free algebras

Our aim is to model computational effects in QCB and TP, and our approach is based on the work by Plotkin and Power [12,13,14]. We start by considering some examples of effects and using them to motivate our theory.

Nondeterministic choice: Suppose we want to model nondeterminism for a datatype X. Then it is natural to have an operation choose : X2 ^ X, such that choose(x,y) denotes a nondeterministic choice between the computations x and y. Notice that by successively applying choose we can model a nondeterministic choice between any finite number of computations.

Probabilistic choice: To model probabilistic nondeterminism for a datatype X, we again need to have a choice operation choose : I x X2 ^ X, but this time parametrised by the closed unit interval I. Here choose(A,x,y) denotes that a computation x is executed with probability A, and y with probability 1 — A. We choose this approach with a parameter object I instead of the one presented in [12], where one operation choose\ : X2 ^ X is given for each A E I for two reasons. The first is that in our approach, we capture computability (given by continuity in QCB) in both the parameter object I and the computational type, not just the latter. The second reason is that having an operation for each A E I means to have an uncountable number of operations, which will not be possible in the theory presented below.

Nontermination: To model nontermination for a datatype X, we require it to have an element ± : X, which denotes some kind of nontermination. This can be seen as a nullary operation or constant ± : 1 ^ X (where 1 is the terminal element in the category we are working in). Typically, in domain theory ± denotes the least element of a dcppo X.

Global State: Let V be a set of values, L be a set of memory locations, and the global state of a system be an assignment of values to locations s E VL. We

want to model a system in which the state can be changed by updating a value in a location, and a memory location can be read out to determine a computation. For this we need a type X to support operations update : LxV xX — X, such that update(l, v, x) takes the value v, writes it into location l and carries out some computation x, and lookup : L x XV — X, such that lookup(l, f) reads out the value vi of location l, and dependent on this executes some computation f (vl).

We see that in all these examples the computational types for the effects support corresponding operations, and these operations are similar to the kind of operations considered in universal algebra. Recall that in universal algebra, one has a signature S, which is a set of operations, each of which having an arity ar(o), given by a finite number. Then a S-algebra is a set on which each of this operations can be interpreted. Following a suggestion by Plotkin, we generalise this definition to allow parameter objects, so we can interpret parametrised operations as in the example for probabilistic choice, and we allow our arities to be countably infinite, as for the lookup operation in the example for global state. To stay as general as possible, we work in a fixed category C which has countable products.

Definition 3.1 A countable parametrised signature S is a countable set of operation symbols, each of which having an arity ar(a) < u, and a parameter object Pa, which is an object of C.

As in universal algebra, we can now define S-algebras, S-homomorphisms and absolutely free S-algebras in the category C. The datatypes on which computational effects can be modelled will then be given by algebras for a signature S, whose operations are the ones causing the corresponding computational effect. As is standard, the free algebra construction presented below will yield the functors of the associated monad.

Definition 3.2 If S is a countable parametrised signature for C, a Cs-algebra (A, {oa}) is given by an object A of C together with a C-morphism oa : Pa x Aar(a) A, for each o e S.

For Cs-algebras (A, {oa}), (B, {ob}), a C^-homomorphism is a C-morphism f : A — B such that the following diagram commutes for all o E S:

p x Aar(a) ; A

p x ßar(a)

By Ce we denote the category of CE-algebras and CE-homomorphisms.

For a C-object X, the absolutely free CE-algebra over X is an object (FX, {<7£x}) of Ce, for which there exists a C-morphism ?/x : X —► FX, such that for any CE-algebra (A, {o^}) and C-morphism f : X ^ A, there exists a unique Cs-homomorphism / : (FX, {<T£x}) —► (A, {(74}) which makes the following diagram (in C) commute:

Notice that if C is a cartesian closed category, Z any object of C, and (A, {oa}) a C^-algebra, then we can equip AZ with a C^-algebra structure, by setting oaz to be the exponential transpose of:

oa ◦ (Pff x eval) : Pa x (AZ)ar(a) x Z = Pa x (Aar(a))Z x Z ^ A.

Then the diagram above can be generalised to

Zx FX- 1 >A

where f has to be a homomorphism on its second component. So in this case, a free algebra is automatically "parametrically free".

Using the Adjoint Functor Theorem, one can show that if C = Set, Top, Seq, then for any countable parametrised signature £, the forgetful functor Cs —► C has a left adjoint F_ which is the absolutely free algebra functor. In the following sections, we show that QCB is closed under the absolutely free algebra construction in Seq, for which we give an explicit construction, and that free algebras in TP can be obtained by reflecting free QCB-algebras.

In the set-theoretic case there is an inductive way to construct absolutely free algebras, which are also called term algebras. Let £ be a countable parametrised signature, and £ be the functor assigning to a set X, the set

[a(p, (Xi)iear(a) )| O G £, p e Pa, Vî. Xi G X},

i.e. S(—) = ]Jaes P° x (—)ar(a). Now define inductively for all ordinals a, Fo(X) = X, Fa+i(X) = X U S(Fa(X)) and for limit ordinals 3, Fp(X) = Ua<^ Fa(X). In other words, to obtain Fa+1(X) add all terms obtained by applying the operations of S to terms of Fa(X) and for a limit ordinal 3 take the union of all terms appearing in Fa(X) for all a < 3. It is not hard to see that for a < a', Fa(X) C Fa>(X). Moreover, for the first uncountable cardinal u1, we have ar(o) < u1 for all o E S, and thus we get FW1+1(X) = F^1 (X), and can show that the absolutely free algebra over X is given by F^1 (X). Operations are defined by aEX(p, (ti)iear(a)) = a(p, (ti)iear(a]). For any term t of the absolutely free algebra over X we denote the smallest ordinal a such that t E Fa(X) by occ(t). Notice that occ(t) is never a limit ordinal.

For the remainder of the section, assume that S is a countable parametrised signature such that any parameter object is a countably-based topological space. Then S is a well-defined parametrised signature for Top, Seq and QCB, as these categories include all countably-based spaces. We show that the absolutely-free algebra functor F_ for Top and Seq preserves countably-based spaces. For this, let |S| be the parametrised signature for Set whose operation symbol and arities coincide with S and the parameter set for o E S is lPa|, where |-| : Top — Set is the obvious forgetful functor.

Lemma 3.3 Given a topological space X, the absolutely free Tops-algebra (FX, {<7£x}) has as underlying set the absolutely free set-theoretic |£|-algebra Gi^l' {cfx}) over |A'|, and the topology 0(F_X) is the finest topology, satisfying:

(A)0(F_X) is compatible, i.e. all operations ax ■ Pa x F_Xarl-a) F_X are continuous,

(B) the inclusion map i]x ■ X F_X is continuous.

Given a sequential space X, the absolutely free Seq ^-algebra (FX, {<7£x}) has as underlying set the absolutely free set-theoretic |£|-algebra {<T£.y})

over |A'|, and the topology 0(F_X) is the finest topology, satisfying (B) and:

(A') 0(F_X) is sequentially compatible, i.e. all operations ax ■ Pa x FXari-a) FX are continuous, -when FA'ar(<7) is equipped with the product topology of Seq.

Proof. Notice that the result is well known for finitary signatures for Top. Let X be a topological space. If T is a set of topologies on |FA'| satisfying (A) and (B), then the topology generated by U T also satisfies these conditions. Thus, the finest topology 0(F_X) on |FA'| exists.

It remains to show that (|FA'|, {<T£x}) equipped with 0(F_X) satisfies the universal property of a free algebra. For this let f : X — A be a continu-

ous map into a Ce-algebra. Then there exists a set-theoretic homomorphism extension / : \FX\ \A\. But the topology given by {/_1(tOI V G 0(A)} satisfies conditions (A) and (B), thus is coarser than 0(F_X), and so / is continuous, as required. Uniqueness follows again from the set-theoretic result.

Similarly, if X is a sequential space, one shows that whenever S is a set of sequential structures on (a set of sequences with limit points satsfying

certain conditions, see e.g. [16,8]) satisfying (A') and (B), then the sequential structure generated by S also satisfies these conditions, and taking the topology with respect to f\S gives a finest topology satisfying (A') and (B). That the universal property of a free algebra is fulfilled is then shown by a similar argument as above. □

Remark 3.4 A similar lemma with same proof will also hold for free algebras for parametrised equational theories, which are introduced in the next section.

We now show that once we have the absolutely-free algebra over the underlying set, we can construct the absolutely-free topological algebra over a space via a countable inductive limit construction. This construction is cru-rial to show that F_ preserves countably-based spaces, which cannot be deduced from the above characterisation of the free algebra topology. So assume X is given, and we have constructed {<7£x}) and obtained the map

V \X\ ^ \FX\. Let tt0 be the topology generated by {?/([/)| U G 0(A)}, and for a given topology Qn, let Qn+1 be the topology generated by

fin u {a]Ex\(V x IJ)\ <t G £, V £ O{Pa), U G On(FXarW)},

where On(FXar{a)) is the product topology with respect to Qn. We obviously get that Hn+1 is finer than Qn, and so we obtain the diagram:

(|ZA|,n0)--(|ZA|,Hi)--(\FXin2)*----

where all arrows are the identity map. Let (|£A'|,n(3C) be the limit of this diagram, i.e. Q^ = UneN Qn. Then we get:

Theorem 3.5 For all topological spaces X, the topology on the absolutely-free Top ^-algebra (F_X, {<T£x}) is given by fl^.

Proof. We have to show that fl^ = 0(F_X), where 0(F_X) denotes the topology of the absolutely free algebra. As = UneN Qn and by construction all the Qn satisfy conditions (A) and (B) of Lemma 3.3, satisfies these conditions, and so it is coarser than O(X). Thus we only have to show O(X) C Q.

We will show that for all terms t £ FX, and U C O(FX), there exists

V £ such that t £ V C U. For this we use transfinite induction on occ(t). If occ(t) = 0, then t = x £ X, and as i]x ■ X —► F_X is continuous, we get for V = 'irl{U) that r](V) £ tt0 and t £ r}(V) C U. So let occ(t) = a > 1 and for all terms t' with occ(t') < a and opens U' £ O(X) containing t', there exists V' £ such that t' £ V' C U'. Suppose t = o(p, (ti)iear(a)). As all operations are continuous on FX, we have that (p, {ti)iear(a))) £ ^-(t/), and find a basic open W x Hiear(<7) U C containing (p, {ti)iear(a])), such that Ui = F_X for i £ ar(a) \ F for some finite F. For all i £ F, occ{U) < a and so we can apply the induction hypothesis, i.e. for all i £ F, there exists Vi £ such that ti £ Vi C Ui. Now, for each i £ F, there exists ni £ N such that Vi £ Qni, and so, as F is finite, m = maxieF ni exists and we get for

y = {a(p, (Si)iear((7))| p £ W,Vl £ F. Si £ ViM £ ar(a) \ F. Si £ FX)},

V £ Qm+1 C and t £ V C U, as required. □

Remark 3.6 The theorem also holds for more general parametrised signature £, where there is no size restriction on the arities of operations or the parameter spaces. It is a surprising result, as it shows that no matter how large the arities of operations and |£| are, the topology on the absolutely free algebra can always be obtained in a countable process.

Proposition 3.7 For a sequential space X, the absolutely free SeqE-algebra is given by the coreflection (into SeqJ of the absolutely free TopE-algebra.

Proof. Just for the proof, let TSeq : Seq ^ SeqE and TTop : Top ^ Tope denote the absolutely free algebra functors. Then we have to show that the identity maps TseqX ^ Seq(TTopX) are both sequentially continuous.

It is a straightforward observation that Seq(TTopX) is a SeqE-algebra, and therefore the universal property of TSeqX yields that the identity TSeqX ^ Seq(TTopX) is continuous. For the converse, show by induction on occ(t) and using theorem 3.5 that a sequence of terms (tk) converges to t in TTopX if and only if the tk have eventually the same structure as t, say tk = o(pk, (si,k)iear(a)) and t = o(p, (si)iear(a)), and for all i £ ar(o), (sitk) converges to si and (pk) converges to p. But as all operations in TSeqX are sequentially continuous, the sequence also converges here. Thus the identity map Seq(TTopX) ^ TSeqX is sequentially continuous as well, showing the claim. □

We now come to our main theorem of this section, showing that countably-based spaces are closed under the absolutely-free algebra construction in Seq.

Theorem 3.8 If X is a countably-based topological space, then the absolutely

free Tops-algebra and the absolutely free Seqs-algebra coincide and are again countably-based topological spaces.

Proof. With the result of the previous proposition, it suffices to show that the absolutely-free Tops-algebra over a countably-based space X is again countably-based. For this, we use theorem 3.5. We prove by induction that all the used in the construction for 3.5 have a countable base.

As X is countably-based, it is straightforward to see that (TX^ Q0) is countably-based, as well. Now assume dTX^ Qn) is countably-based, hence any countable product of (TX^ Qn) is countably-based, and so if Ba is a countable base for (TX^ Hn)a and B a countable base for Pa, then by count-ability of S, we obtain a countable base for dTX^ Qn+1) by:

B1 U {o{TX\(V x U^ O E S,V EB,U E Bar (a) } •

Thus all the have a countable base, and so has = |JneN which by theorem 3.5 is the topology on TX. □

This theorem will be a major part in the proof that QCB is closed under the free algebra construction in Seq for parametrised equational theories.

4 Parametrised algebraic operations and equational theories

So far we have introduced countable parametrised algebraic theories, in order to capture operations, which generate computational effects, on objects of a category of topological spaces. We have also shown that, in the case that all parameter spaces are countably-based, the absolutely free algebra functor F_ : C —► Ce preserves countably-based spaces for C = Top, Seq. In order to faithfully model the effects, however, we have to relate the operations by equations, as in Plotkin and Power's work. To motivate this, consider again our examples.

Nondeterministic choice: Nondeterminism was generated by a binary operation choose : X2 — X, where choose(x,y) denotes a nondeterministic choice between x and y. For real nondeterminism we will then have the following identities:

• Idempotence: choose(x, x) = x,

• Commutativity: choose(x,y) = choose(y,x),

• Associativity: choose(choose(x,y),z) = choose(x,choose(y, z)).

Probabilistic choice: Probabilistic choice was generated by an operation choose : I x X2 — X, so that choose(A, x,y) denotes that a computation x is chosen with probability A and y is chosen with probability 1 — A. A real probabilistic choice will also satisfy the following equations:

• choose(1, x, y) = x,

• choose(A, x, x) x,

• choose(A, x, y) = choose(1 — A, y, x),

• choose(\ choose(X\ x, y),z) = choose(W, x, choose((l — ), y, z).

In a category of topological spaces, I will be equipped with the topology of lower semicontinuity (equivalently the Scott topology with respect to the usual order on I).

Nontermination: Nontermination was given by a constant (or nullary operation) ±E X. In traditional denotational semantics, there is the inequation -L< x denoting that a nonterminating program gives less information than a terminating one. If we consider nontermination in a category of topological spaces, we want to have ICx, where C denotes the specialisation pre-order on X. This can be achieved, using a parametrised equational theory, by considering an auxiliary operation o : S x X — X, where S denotes Sierpinski space, the two element space {0,1}, in which the singleton {1} is open, but the singleton {0} not. Then the equations:

• o(0, x) = ±,

• o(1, x) = x

yields for the specialisation pre-order on X, ± C x for all x E X, as by continuity of o, we get for any open U containing ±, (0,x) = ±E o-1(U), hence (1,x) E o-1(U), and so x = o(1,x) E U.

Remark 4.1 In a similar fashion we can model arbitrary inequations with respect to the specialisation pre-order for S-terms. We use this indirect approach to inequations, because the theory (presented below) with parametrised equations seems much easier to handle than a theory directly using inequations.

Global State: Recall that for modelling the global state of a system, we used operations update : L x V x X — X and lookup : L x XV — X, where L is an object of C representing a set of memory locations and V an object representing a set of values. Notice that V occurs as both, a parameter object and an arity, so for our theory we have to interpret it both as an object of C

and a countable set. In particular if C = Top, Seq, QCB, then our approach supports this effect only if V is a countable discrete space, in which case it can be interpreted as a countable topological space and a countable set. For the equations, we refer to Plotkin and Power's paper [14], where 7 identities relating lookup and update are given. All these identities fit into the theories of equations presented below.

We now introduce equations for Cs-algebras and define what it means for a Cs-algebra A to satisfy such equations. We thus obtain the category C(e,E) of Cs-algebras satisfying a set of equations E. We then give a condition under which the forgetful functor U : C(S,E) — C creates coequaliz-ers, and use this result we construct the free algebra FX over X explicitly as a coequalizer of the absolutely-free Cs-algebra F_X. Applying these results to C = Seq will finally enable us to show that the free algebra functor F : Seq — Seq(S E) preserves qcb-spaces, and so restricts to a free algebra functor F : QCB — QCB(S E). Having achieved this, we will be able to model computational effects such as the ones given in the examples above in the categories of algebras, QCB(S E), for the corresponding parametrised equational theory (£, E).

Definition 4.2 Let £ be a countable parametrised signature for C

An algebraic operation of arity a and parameter object Z is an Ob(Cs)-indexed family of C-morphisms p—) : Z x (—)a — (—) such that for all Cs-homomorphisms f : (A, {o^}) — (B, {ob}), the following diagram commutes:

Zx Ba-

Sometimes we will call such an algebraic operation a (a, Z)-operation. The concept of an algebraic operation is taken from Plotkin and Power's [12], though their notion of algebraic operation is more general in the sense that it can be applied to any category of algebras of a monad in a suitable categorical setting. Examples for algebraic operations are all term maps (maps that can be defined inductively by composing operations of £ and projection maps). In the literature about finitary unparametrised signatures, such term maps are also called £-polynomials or derived operations. It would be interesting to investigate whether algebraic operations for parametrised signatures can also be defined inductively.

Definition 4.3 An equation e : (p = p') of arity ar(e) and parameter object Pe is given by a pair of (ar(e),Pe)-algebraic operations p,p'. A £-algebra (A, {oa}) satisfies an equation e : (p = p'), if pA = p'A : Pe x Aar(e) ^ A. If E is a countable set of equations and ar(e) < u for all e £E, the tuple (£, E) is called a countable parametrised equational theory.

A )-algebra is a Cs-algebra (A, {oa}) that satisfies all equations e £E, and by C(s,£) we denote the category of C(S>E)-algebras and Cs-homomorphisms. For a C-object X, the free C(S>E)-algebra over X is an object (FX, {ofx}) of C(e,s), for which there exists a C-morphism nX : X ^ FX, such that for any C(e,s)-algebra (A, {oa}) and C-morphism f : X ^ A, there exists a unique Cs-homomorphism f : (FX, {ofx}) ^ (A, {oa}) which makes the following diagram (in C) commute:

FX----- A

For the remainder of the paper (£, E) will always denote a countable equational theory.

Notice that if C has countable coproducts, then a Cs-algebra (A, {oa}) is a C(s,£)-algebra if and only if the maps

LU, Pe x 7 i A

coincide, where the e-component of ta, r'A are the respective algebraic operations of e.

For the following theorems, assume C has countable products and coproducts, and that the forgetful functor U : C(S,E) ^ C has a left adjoint, i.e. the free algebra functor F exists.

Theorem 4.4 If in C countable products preserve coequalizer diagrams, then the forgetful functor U creates coequalizers.

Proof. Assume f, g : (A, {oa}) ^ (B, {ob}) are Cs-homomorphisms. Applying the forgetful functor gives C-morphisms f, g : A ^ B. We claim that if q : B ^ Q is the coequalizer of f and g in C, then Q can be equipped with a Cs-algebra structure such that (Q, {oq}) satisfies all equations in E, q becomes a Cs-homomorphism and

(A {*a}) ==t (S, W) (Q, {aQ})

is a coequalizer diagram in C(S)E). The proof of these claims is analogous to the proof of VI.8 Theorem 1 in [6], where the property of being an absolute coequalizer is replaced by the countable product preservation. □

If T = UF, then T becomes the functor of a monad and we can consider CT the category of Eilenberg-Moore algebras for C. Beck's Theorem now gives:

Corollary 4.5 If in C countable products preserve coequalizer diagrams, then CE,£ ^ CT.

Theorem 4.6 Let F_ : C —► Cs denote the absolutely free algebra functor, and countable products preserve coequalizer diagrams in C, then:

(i) for any Cs-algebra (A, {oa}), the coequalizer of:

£(IL€fPex^>)=g=M

is a C(£e)-algebra, where ta,t'a are the unique Cs-homomorphisms extending ta,tA : UPe x Aar(e) ^ A. (ii) for each object X of C, the free C(S,E)-algebra (FX, {a>x}) is obtained as the coequalizer of:

EiUeee pe X FXa^)=^=zFX

Proof.

(i) By theorem 4.4, it is clear that the coequalizer q : (A, {oa}) ^ (Q, {oq}) of rA,r'a exists in Cs, and that it is calculated as in C. So it remains to show that (Q, {oq}) satisfies all equations in E. For this let e0 : (p = p') be one of these, then as q o ta = q o t'a, we have q o ta = q o r'A and hence q o pA = q o p'A. Now consider the following commuting diagram in C:

Peo x Aar{eo):

Pe0 Xqar(e0)

Peo X Qar(eo)-

Pe0 x qar(e0) : Pe0 x Aar(e0) ^ Pe0 x Qar(e0) is the coequalizer of Pe0 x

;p«r(eo), Pe0 x -a uBut we also have that q o pA = q o p'A coequalizes

^ar(e0)

(Peo x ta(eo)), (Pe0 x t'a( o)), and thus there is a unique mediating arrow Peo x Qar(eo) ^ Q making the diagram commute, giving pq = pQ, and so Q satisfies e0.

(ii) It remains to show that the coequalizer (Q, {<tq}) ?fx,t'fx satisfies the universal property. For this, let (A, {aA}) be any C(E)E)-algebra, f : X ^ A be any C-morphism and / : (FA', crfx) —► {A, {ca}) the corresponding C^-homomorphism. Then the commutativity of the following diagram:

EiUeee pe X FXarM)^=S==£FX

E((far<e,)ees)

n\lee£Pe X =A

ensures that / coequalizes iyx and r'FX, giving the required mediating arrow h : (Q, {aQ}) ^ (A, {aA}).

Now assume C = Seq, S is a countable parametrised signature such that all parameter spaces are countably-based, and E a countable set of equations. Then the adjoint functor theorem can be applied and the forgetful functor U : Seq(E)£) ^ Seq has a left adjoint F. Moreover, we have the following result.

Proposition 4.7 In Seq, countable products preserve coequalizer diagrams.

Proof. Schroder and Simpson [17] have shown that in Seq countable products of topological quotient maps are topological quotient maps. As the topological quotient maps are exactly the coequalizers in Seq, it is straightforward to show that countable products indeed preserve coequalizer diagrams. □

Now we are able to state our main result.

Theorem 4.8 The free algebra functor F : Seq ^ Seq(E E) 'preserves qcb-spaces.

Proof. Let X be a qcb-space, and (FX, {a>x}) the free Seq(E E)-algebra over X. We have to show that FX is a qcb-space. For this, notice that the free algebra functor F is a left adjoint, hence preserves coequalizers, which in the categories of algebras are topological quotient maps by Theorem 4.4. Suppose q : A ^ X is a topological quotient map for a countably-based space A. Now

I. Battenfeld / Electronic Notes in Theoretical Computer Science 158 (2006) 59—80

we have the following diagram:

FA-^FA

where by the previous theorems the upper and lower maps are regular epis in Seqs, hence topological quotient maps. As topological quotient maps are closed under composition, we thus obtain FX as a topological quotient of FA, which is a countably-based space by 3.8. □

5 Reflecting algebras to TP

We have seen that QCB is closed under the construction of free algebras for countable parametrised equational theories in Seq, and therefore we obtain a left adjoint for the forgetful functor QCB(S E) ^ QCB namely the restriction of the free algebra functor F : Seq ^ Seq(S E) to QCB. However, the free algebra functor does in general not preserve topological predomains, which can be seen if we consider the equational theory for nondeterministic choice.

Let (£, E) be the equational theory for nondeterministic choice, and consider the free algebra over the space X, given by 3-element chain 0 < 1 < 2 equipped with the Alexandroff (or Scott) topology. Then the free algebra (FX, {o^x}) has as underlying set the power set PX, and the operation is union. But in the specialisation pre-order we get {1, 3} = {1, 2, 3}, as in the absolutely free algebra we have

choose(1, choose(1, 3)) Q choose(1, choose(2, 3)) Q choose(1, choose(3, 3))

and the left and right hand terms will be identified with {1, 3}, the one in the middle with {1, 2, 3}. Thus FX is not a T0-space, and so not a topological predomain. (A similar argument can be found in the chapter about powerdomains in [11].)

To fix this deficit, we consider algebras in reflective subcategories, and show that the reflection functor M : QCB ^ TP restricts to a reflection functor on the respective categories of algebras.

Assume that D is a full reflective subcategory of C with reflection functor R : C ^ D, both are countably complete and cocomplete, and (£, E) is a countable parametrised equational theory for C such that all parameter objects are in D. Then we get the following theorem which will be proved by two lemmas.

76 I. Battenfeld /Electronic Notes in Theoretical Computer Science 158 (2006) 59—80

Theorem 5.1 If the reflection functor R : C ^ D preserves countable products, then it restricts to a functor R(e,E) : C(s,E) ^ D(SjE).

For the two lemmas assume the assumption of the theorem is fulfilled.

Lemma 5.2 For any C(s,E)-algebra (A, {aA}), RA can be equipped with a C(e,s)-algebra structure, so that it becomes a D(SjE)-algebra and the canonical map nA : A ^ RA a C^-homomorphism.

Proof. As R preserves countable products, for each a E £ the map Roa : R(Pa x Aar(a)) = Pa x RAar(a) RA

is well defined. So setting ura = Rua, makes (RA, [ura}) into a C^-algebra, and therefore a Ds-algebra. To see that nA is a C^-homomorphism, observe that the diagram below commutes for each u E £:

p x Aar(a) .

tj ar(a)^ Pa X'nA =nP„ X Aar (a)

I' X RAar(a) ■

vra=r°a

It remains to show that for each e : (p = p') EE, pRA, p'RA : Pe x RAar(e) ^ RA coincide. But as nA : A ^ RA is a C^-homomorphism and R preserves countable products, we get the following commuting diagram:

l> X Aar(e) :

Pe*nA =npexAar(e)

Pe x RAar{e) ^ R(Pe x Aar{e)):

And so as pA and p'A coincide, the universal property of the reflection functor yields pRA = p'RA, as required. □

Lemma 5.3 R maps C^-homomorphisms onto C^-homomorphisms, and therefore onto D^-homomorphisms.

Proof. Let f : (A, {aA}) ^ (B, [aB}) be a C^-homomorphism. As Cs-homomorphisms are closed under composition, we get the following commut-

ing diagram:

j\ar(cr) _ RBar(a) .

VB °f

Now the properties of a reflection ensure that Rf : (RA, {ora}) ^ (RB, {orb }) is a Cs-homomorphism, as well. □

This completes the proof of Theorem 5.1.

Now we can apply these results to the reflection M : QCB ^ TP, because Schroder and Simpson have shown the following result in [17].

Proposition 5.4 The reflection functor M : QCB ^ TP preserves countable products.

Thus we get that for a topological predomain X, ((M ◦ F)X, (mof)x }) is a TP(S £)-algebra and it is easy to verify that it satisfies the universal property for a free algebra in TP. Thus we obtain the following commutative diagram of functors:

(£,£) ■

(£,£ )

where the unlabelled arrow is obtained as the composite of the inclusion functor followed by forming the free QCB(S f^-algebra and then reflecting back to TP. This yields the following result.

Corollary 5.5 For countable parametrised equational theories (£, E) for TP, the forgetful functor TP(£,£) ^ TP has a left adjoint. Moreover, the free algebra functor is obtained as the free algebra functor in QCB followed by the reflection into TP.

6 Conclusions

We have shown that computational effects can be modelled in the categories QCB and TP via a free algebra approach. In order to do this, we have introduced countable parametrised equational theories for the category Seq, in which free algebras exist by the Adjoint Functor Theorem, and are formed as in the set-theoretic case. We have then shown that QCB is closed under the

free algebra construction in Seq, and free algebra functors for Seq restrict to free algebra functors for QCB. Furthermore, we have obtained free algebra functors in the subcategory TP using the reflection functor from QCB to TP. We have motivated our results by examples of how to model some specific effects in QCB. Our results can be applied to most of the effects and combinations of them covered by the work of Plotkin and Power (there are a few exceptions where functor categories are involved, as e.g. for the local state effect).

It is worth mentioning that the category TD^ of topological domains and strict continuous maps, i.e. those continuous maps that preserve the smallest element of the specialisation order, is exactly the category of TP-algebras for the nontermination effect. Here the free algebra functor is just the reflection from TP to TD.

Considering the global state example, it certainly is a drawback that our theory only captures the case when V, the space of values, is discrete. It would be more satisfactory if we could generalise the results to operations whose arity is given by certain kind of topological spaces, e.g. countably-based core compact spaces. However, once non-discrete arities are introduced, any approach based on the set-theoretic construction (such as ours) breaks down, and one has to come up with a new construction. Notice, that QCB and TP are internally complete in the realizability topos over Pu, and thus the free algebras exist for abstract reasons. However, it is not straightforward to give an explicit construction of these free algebras, as in the present paper.

Parametrised equational theories also arise in standard mathematics. For instance topological vector spaces can be described by a parametrised equa-tional theory (£, E), where £ consists of a binary operation for vector addition, a unary operation for vector negation, a constant for the zero vector and a parametrised (1, Reoperation for scalar multiplication, and E is given by the usual nine vector space axioms. Then the free algebra over the n-element discrete space will be isomorphic to the topological vector space R".

Computational effects have also been investigated in classical domain theory. The category DCPO indeed has free algebras for arbitrary equational theories by the Adjoint Functor Theorem. However, it has no intrinsic notion of computability and does not model polymorphism. Also the categories of continuous, resp. algebraic, dcpos, which have a notion of computability, have free algebras for arbitrary equational theories. However, these categories are not cartesian closed, and the general existence proof of free algebras fails when one restricts attention to the cartesian closed subcategories thereof. Various notions of powerdomains have been considered, e.g. the Plotkin powerdomain to model nondeterminism and the probabilistic powerdomain to model

probabilistic computations. But, whereas it has been shown that there exist cartesian closed categories of continuous domains which support the Plotkin powerdomain construction, this is not the case for the probabilistic powerdomain. It is one of the benefits of Topological Domain Theory that it provides us with the category of topological predomains, which is cartesian closed, and supports arbitrary combinations of effects specified by countable parametrised equational theories. It would also be interesting to compare the classical notions of powerdomains with the algebras for nondeterministic and probabilistic choice given here.

Acknowledgement

I have benefited from many discussions with Alex Simpson, and am indebted to Gordon Plotkin for suggesting to use parametrised theories. I am also very grateful to John Coleman for supplying me with the necessary background on topological algebras.

References

[1] Abramsky, Samson and Achim Jung, Domain theory, Handbook of logic in computer science Vol. 3, 1-168, Oxford Sci. Publ., Oxford Univ. Press, New York, 1994.

[2] Battenfeld, Ingo, "A category of topological predomains", Diplomarbeit, TU Darmstadt, 2004.

[3] Battenfeld, Ingo, Matthias Schroder and Alex Simpson, Compactly generated domain theory, Math. Struct. of Comp. Science 16 (2006), no. 2, 1-21.

[4] Escardo, Martin, Jimmie Lawson and Alex Simpson, Comparing Cartesian closed categories of (core) compactly generated spaces, Topology Appl. 143 (2004), no. 1-3, 105-145.

[5] Gierz, G., K.H. Hofmann, K. Keimel, J.D. Lawson, M. Mislove and D.S. Scott, "Continuous lattices and domains", Encyclopedia of Mathematics and its Applications 93, Cambridge University Press, Cambridge, 2003, xxxvi+591 pp.

[6] MacLane, Saunders, "Categories for the working mathematician", Second edition, Graduate Texts in Mathematics 5, Springer-Verlag, New York, 1998, xii+314 pp.

[7] Mal'cev, A.I., Free topological algebras, Amer. Math. Soc. Transl. (2) 17 (1961), 173-200.

[8] Menni, Matias and Alex Simpson, Topological and limit-space subcategories of countably-based equilogical spaces, Math. Structures Comput. Sci. 12 (2002), no. 6, 739-770.

[9] Moggi, Eugenio, Computational lambda-calculus and monads, Proceedings of the Fourth Annual Symposium on Logic in computer science, LICS 1989, 14-23.

[10] Moggi, Eugenio, Notions of computation and monads, Information and Computation, 93(1), 1991, 55-92.

[11] Plotkin, Gordon, "Pisa Notes (On Domain Theory)", 1983, available online.

[12] Plotkin, Gordon, and John Power, Algebraic operations and generic effects, On formal description of computations—refined structures and new trends (Cork, 2000), Appl. Categ. Structures 11 (2003), no. 1, 69-94.

Plotkin, Gordon, and John Power, Computational Effects and Operations: An Overview, Electr. Notes Theor. Comput. Sci. 73 (2004), 149-163.

Plotkin, Gordon, and John Power, Notions of Computation Determine Monads, Foundations of software science and computation structures (Grenoble 2002), 342-356, Lecture Notes in Comput. Sci. 2303, Springer, Berlin, 2002.

Porst, H.-E., Free algebras over Cartesian closed topological categories, General topology and its relations to modern analysis and algebra VI (Prague, 1986), 437-450, Res. Exp. Math., 16, Heldermann, Berlin, 1988.

Schroder, Matthias, "Admissible Representations for Continuous Computations", Dissertation, FernUniversitat-Gesamthochschule Hagen, 2002.

Schroder, Matthias, and Alex Simpson, Two Preservation Results for Countable Products of Sequential Spaces, Submitted, 2005.

Simpson, Alex, Towards a Convenient Category of Topological Domains, In Proceedings of thirteenth ALGI Workshop, RIMS, Kyoto University, 2003.

Smyth, Michael B., Topology, Handb. Log. Comput. Sci. 1, Oxford Univ. Press, New York, 1992, 641-761.

Taylor, Walter, Varieties of topological algebras, J. Austral. Math. Soc. Ser. A 23 (1977), no. 2, 207-241.