From Comodels to Coalgebras: State and ArraysAcademic research paper on "Computer and information sciences"

CC BY-NC-ND
0
0
Share paper
OECD Field of science
Keywords
{"Lawvere theory" / (co)model / (co)algebra / (co)monad / "equivalence of categories" / "global state" / arrays}

Abstract of research paper on Computer and information sciences, author of scientific article — John Power, Olha Shkaravska

Abstract We investigate the notion of a comodel of a (countable) Lawvere theory, an evident dual to the notion of model. By taking the forgetful functor from the category of comodels to Set, every (countable) Lawvere theory generates a comonad on Set. But while Lawvere theories are equivalent to finitary monads on Set, and that result extends to higher cardinality, no such result holds for comonads, and that is not only for size reasons: it is primarily because, while Set is cartesian closed, Setop is not. So every monad with rank on Set generates a comonad on Set, but not conversely. Our leading example is given by the countable Lawvere theory for global state: its category of comodels is the category of arrays, yielding a precise relationship between global state and arrays. Restricting from arbitrary comonads to those comonads generated by Lawvere theories allows us to study new and interesting constructions, in particular that of tensor product.

Academic research paper on topic "From Comodels to Coalgebras: State and Arrays"

﻿^scienced irect.com -

direct" Electronic Notes in

Theoretical Computer

ELSEVIER Electronic Notes in Theoretical Computer Science 106 (2004) 297-314

www.elsevier.com/locate/entcs

From Comodels to Coalgebras: State and Arrays

John Power1 '2

LFCS, Division of Informatics University of Edinburgh Edinburgh, Scotland

Olha Shkaravska3,4

TCS, Institut of Informatics Ludwig-Maximilians University Munich, Germany

Abstract

We investigate the notion of a comodel of a (countable) Lawvere theory, an evident dual to the notion of model. By taking the forgetful functor from the category of comodels to Set, every (countable) Lawvere theory generates a comonad on Set. But while Lawvere theories are equivalent to finitary monads on Set, and that result extends to higher cardinality, no such result holds for comonads, and that is not only for size reasons: it is primarily because, while Set is cartesian closed, Setop is not. So every monad with rank on Set generates a comonad on Set, but not conversely. Our leading example is given by the countable Lawvere theory for global state: its category of comodels is the category of arrays, yielding a precise relationship between global state and arrays. Restricting from arbitrary comonads to those comonads generated by Lawvere theories allows us to study new and interesting constructions, in particular that of tensor product.

Keywords: Lawvere theory, (co)model, (co)algebra, (co)monad, equivalence of categories, global state, arrays.

1 This work is supported by EPSRC grant GR/N64571, EPSRC grant GR/586372/01 and AIST Japan.

2 Email: mailto:ajp@inf.ed.ac.uk

3 This work is supported by the MRG project (IST-2001-33149) which is funded by the EC under the FET proactive initiative on Global Computing.

4 Email: mailto:shkarav@tcs.informatik.uni-muenchen.de

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

1 Introduction

To give a Lawvere theory L is equivalent to giving a finitary monad T on Set [1]. More generally, for any category V that is locally finitely presentable as a symmetric monoidal closed category, one can define a notion of Lawvere V-theory L and prove that to give a Lawvere V-theory is equivalent to giving a finitary V-monad T on V [16]. One can routinely extend that equivalence to higher cardinals, in particular to define a notion of countable Lawvere V-theory for any V that is locally countably presentable as a symmetric monoidal closed category and prove that to give a countable Lawvere V-theory is equivalent to giving a V-monad T on V that is of countable rank. That equivalence, in the particular case where V is the cartesian closed category uCpo, has proved to be of fundamental importance in giving a unified theory of how to combine computational effects [9,10]. Formally, one can extend the result even further by dropping the size condition [4]: for an arbitrary symmetric monoidal closed category V, to give a generalised Lawvere V-theory is equivalent to giving an arbitrary V-monad on V. Although elegant, that result is of limited practical value as one can then no longer freely consider the sum of theories, or the tensor or theories, or the like [8]. So, formally, all V-monads can be characterised by an enriched notion of Lawvere theory of arbitrary cardinality, but in fact, the result is of most interest in the presence of a size restriction.

An immediate question arises for workers in coalgebra: what is the situation when one replaces a monad by a comonad? As implied by the above paragraph, the answer is not simple: all of the above results depend upon V being symmetric monoidal closed, but even Setop with its finite product structure, i.e., the finite coproduct structure of Set, is not closed. So the most substantial parts of the above results collapse. That collapse is further indicated by the many recent results giving syntax for coalgebra, for instance [5,6], as the syntax is invariably based upon something considerably more sophisticated than the routine replacement of finite product structure by finite coproduct structure. But that does not mean there is nothing of interest to say here: although there is not an equivalence between comonads and a natural notion of theory based on finite coproducts, one direction of a putative equivalence exists, includes substantial examples, and supports a body of mathematical theory.

It is trivial to define a dual to the notion of Lawvere theory. A Lawvere theory consists of a small category L with finite products together with an identity-on-objects strict finite product preserving functor J : Natop —► L, where Nat is a skeleton of the category of finite sets. Natop can be characterised as the free category with finite products on 1. So an obvious definition of a Lawvere co-theory would be a small category C with finite co-

products and an identity-on-objects strict finite coproduct-preserving functor J : Nat —► C, as Nat is the free category with finite coproducts on 1. But it would be redundant to make such a definition because to give a Lawvere co-theory would then be exactly equivalent to giving a Lawvere theory, simply by applying (—)op. So we shall not formally define a notion of Lawvere co-theory, but rather use the standard definition of Lawvere theory and define a category of comodels that is in some sense dual to the usual definition of a category of models.

For any category C with finite products, a model of a Lawvere theory L in C is a finite product preserving functor M : L —► C. So we define a comodel of a Lawvere theory L in a category C with finite coproducts to be a finite coproduct preserving functor M : Lop —► C. Thus, taking all natural transformations as arrows, we have the category Comod(L,C), which, by definition, is isomorphic to Mod(L,Cop)op, cf [13]. Taking C to be Set, it is not entirely obvious but nonetheless true that the inclusion of Comod(L, Set) in the functor category [Lop, Set] has a right adjoint, and so the forgetful functor from Comod(L, Set) to Set is comonadic: that is the main result of Section 2. The result enriches and extends to other base categories such as Poset and Cat, and, generalising from finiteness to countability, to uCpo. Thus Lawvere theories yield comonads on Set. Generalising to a fixed regular cardinal, it follows that every monad T with rank on Set induces a comonad: given T, let L be the corresponding generalised Lawvere theory, and consider the comonad generated by the forgetful functor from Comod(L, Set) to Set.

From the perspective of coalgebra, several questions arise: are there comon-ads of computational interest that arise from comodels of Lawvere theories? Does the construction of a comonad on Set from a monad with rank on Set yield an interesting relationship between monads and comonads? Are there interesting constructions of or results about categories of comodels that do not hold of categories of coalgebras in general or may not hold in the same way? To what extent to these results extend from Set to other natural base categories? These are some of the questions we wish to explore, the answers generally being positive.

Our leading example of a category of comodels is that for arrays, with the relationship between the monad for global state and the comonad for arrays being given by the above construction: we analyse the countable Lawvere theory, hence monad, for global state in Section 3 and we analyse arrays in Section 4. The notion of array, of course, has been extant for decades, see for instance [3,14]. Given a finite set Loc of locations and a countable set V of values, a (Loc, V)-array may be axiomatised as a set A together with functions

sel : A x Loc —► V

upd : A x Loc x V —► A

satisfying four axiom schema, which we list in Section 4, cf [7,17]. Arrays naturally form a category (Loc, V)-Array, and it can be readily checked that (Loc, V)-Array is the category of comodels of the countable Lawvere theory Lloc,v for global state: we describe LLoc,v in Section 3 and give the proof of the relationship with arrays in Section 4. The technical core of the proof reformulates and extends a result by Hofmann and Pierce in the case where Loc has one element [7].

Restricting attention from arbitrary comonads to those arising from co-models of Lawvere theories allows us to tap into the extant body of knowledge of the latter. In particular, we can speak of the sum and especially the tensor product of theories [9,10]. The sum yields the product of the induced comonads. And the tensor product of has the universal property

Comod(L tg> L', C) ~ Comod(L, Comod(L', C))

and that is genuinely a construction on theories rather than on comonads: it involves the comodels of L in Comod(L',C), and that is not equivalent to a lifting of one comonad to the category of coalgebras of another, cf [9,10]. We outline the situation briefly in Section 5.

For further work, we should very much like to be able to characterise those comonads, at least on Set, that arise from categories of comodels. But that looks like a very difficult problem. The best one can realistically seek are probably conditions on presentations, a few of which are implicit in Section 2. We should also like to explore the example more, as one extends from global state/arrays to variants. And we hope to explore more the significance of constructions one can make on comonads by restricting to those generated by comodels.

2 From Comodels to Coalgebras

In this section, we define the notion of comodel for a Lawvere theory, and we show that the category of comodels in Set of a Lawvere theory is comonadic over Set. The results of this section enrich routinely to categories that are locally finitely presentable as cartesian closed categories, and can be extended also routinely in regard to size, in particular to the notion of countable Lawvere theory, which was the focus of [9,10] and as is needed in order to account for uCpo. But, for simplicity of exposition, in this section, we shall restrict attention to the usual notion of Lawvere theory, i.e., that in which the objects are natural numbers, corresponding to finitary monads on Set.

Let Nat denote the full subcategory of Set given by natural numbers. So, it contains one object n for each natural number, and the maps are all functions between such natural numbers. The category Nat has finite coproducts given by the sum of natural numbers.

Definition 2.1 A Lawvere theory consists of a category L with finite products and an identity-on-objects strict finite product preserving functor J : Natop —► L. A model of L in a category C with finite products is a finite product preserving functor from L to C. A comodel of L in a category C with finite coproducts is a finite coproduct preserving functor from Lop to C.

The models of L in a category C with finite products form a category Mod(L,C), whose arrows are given by all natural transformations. And the comodels of L in a category C with finite coproducts form a category Comod(L,C), whose arrows are given by all natural transformations. So, almost by definition, for any category C with finite coproducts, we have the following:

Comod(L, C) = Mod(L, Cop)op

Given a Lawvere theory L, the forgetful functor U : Mod(L, Set) —► Set has a left adjoint, exhibiting Mod(L, Set) as finitarily monadic over Set. That result generalises routinely from Set to an arbitrary locally finitely presentable category C. But Setop is not locally presentable, so we require greater delicacy in order to prove that the forgetful functor from Comod(L, Set) to Set has a right adjoint, or equivalently that the forgetful functor from Mod(L, Setop) to Setop has a left adjoint, cf [12,13].

Theorem 2.2 For any Lawvere theory L, the forgetful functor

U : Comod(L, Set) —► Set has a right adjoint, exhibiting Comod(L, Set) as comonadic over Set.

Proof. The assertion of the existence of a right adjoint is equivalent to the assertion that the inclusion of Comod(L, Set) into [Lop,Set] has a right adjoint. For that, the key point is that for any natural number n, the functor n x — : Set —► Set sends a set X to the n-fold coproduct of copies of X, and it preserves limits of w-cochains.

Given a functor H : Lop —► Set, there is a canonical map fin : n x H1 —► H(n x 1). A map in L of the form f : n —► 1 is sent by H to a function of the form Hf : H1 —► H(n x 1). So we need to pullback Hf along We need to do that simultaneously for all maps in L, yielding a limit H11 together with a function ai : H11 —► H1. In general, Hi will not extend to

a finite-coproduct preserving functor because of non-triviality of

n x a1 : n x H11 —► n x H1

But one can continue inductively to build a cochain of length u: in defining H21, one must also account for equalities in L, i.e., given f : n —► 1 and gi : ni —► 1 for 1 < i < n, one must account for f (g1, ■ ■ ■ ,gn). But after defining H21, it is routine to extend to all n. In the limit, Hw is functorial as one can define Hw f by using the limiting property of the cochain given by n x ak. It is routine to verify that Hu is the right adjoint.

For comonadicity, it is routine to verify the conditions for the dual of Beck's monadicity theorem, i.e., that U reflects isomorphisms and that split equalisers lift [1]. □

Observe that the central point used here was cartesian closedness of Set: we used the fact that the tensor of n with X had the universal property of a product. It follows that one can generalise this result to categories such as Poset, Cat, and uCpo, and that it generalises to enrichment in a cartesian closed category subject to size constraints, including categories such as Poset, uCpo, and Cat. We just remark on that here without exploring it further.

The leading example for us of a category of comodels is given by the notion of array, as investigated in Section 4. So we shall not develop examples much here. But just to give an idea of what sort of comonads we cover here, we give two examples.

Example 2.3 Consider the Lawvere theory Ln generated by one n-ary operation, i.e., freely generated by a map n —► 1. A comodel of Ln in Set consists of a set X together with a function

X —► A x X

where A is of cardinality n. As we shall outline in the next section, it is straightforward to generalise from the finiteness of n.

Example 2.4 Consider the Lawvere theory LB generated by B unary operations, i.e., freely generated by B maps 1 —► 1. A comodel of LB in Set consists of a set X together with a function

The above examples are particularly simple in that they involve no nontrivial equations. But they do give an idea of what comonads are induced by this construction: our leading example is in Section 4. Observe that there seems no way to include examples that involve a powerset.

3 The Countable Lawvere Theory for Global State

In the previous section, we began to develop the notion of comodel of a Law-vere theory and its induced comonad. For simplicity of exposition, we used the usual notion of Lawvere theory, while remarking that greater generality is possible. In fact, our leading example is of a countable Lawvere theory rather than an ordinary one; so we start here by giving a brief account of how the main definitions above extend from finiteness to countability.

In this section, we define and investigate the countable Lawvere theory for global state. That countable Lawvere theory is implicit in [15], but that paper makes no explicit reference to any notion of Lawvere theory, it is not entirely trivial to pass from the explanation in that paper to the theory, and the papers that do describe countable Lawvere theories do not contain this example in detail [9,10].

Let denote a skeleton of the full subcategory of Set given by countable sets. So, up to equivalence, it contains one object n for each natural number, together with an object to represent a countable set. The category has countable coproducts.

Definition 3.1 A countable Lawvere theory consists of a category L with countable products and an identity-on-objects strict countable product preserving functor J : —► L. A model of L in a category C with countable products is a countable product preserving functor from L to C.

The models of L in a category C with countable products form a category Mod(L,C), whose arrows are given by all natural transformations.

We assume we are given a finite set Loc of locations and a countable set V of values. We identify Loc with the natural number given by its cardinality, and we identify V with When we write a product X x Y, we mean the product of sets, not the product in the countable Lawvere theory L, which is given by the coproduct of sets. And given a map, say f : Y —► Y', in L, when we write X x f : X x Y —► X x Y', we mean the map in L given by the product of X copies of f. That is a particularly convenient notation but it requires considerable care: there is an evident way, using symmetries, to define f x X, but x is not even monoidal, i.e., given g : X —► X' and

f : Y —► Y', the diagram

A x Y-X x Y'

g x Y '

A'' x Y-- A'' x Y'

A" x /

need not commute unless one of f or g lies in the image of cf [11]. If in any doubt, it generally helps to consider what the diagrams mean for a model in Set as x is sent to an exponential by a model [15].

Definition 3.2 The countable Lawvere theory LLoc,v for global state is the theory freely generated by maps

l : V —► Loc u : 1 —► Loc x V

subject to commutativity of the following diagrams. First, we have four interaction diagrams as follows:

Locx V

Locx l

Loc <-— Loc x Loc

where 5 : Loc —► Loc x Loc and t : Loc —► 1 are the diagonal and terminal maps in (so must be reversed to be considered as maps in

V x l l x Loc

I x I -► I x Loc-► Loc x Loc

V-- Loc

Loc X V X U Loc x V->- Loc x V x Loc x V

Locx s xV

Loc X n

Loc V V

SxV xV

Loc Loc V V

l Loc x u V->- Loc->- Loc x Loc x V

V x Loc x V

Locx S

suppressing two isomorphisms. We also have three commutation diagrams as follows:

v ,, ^xl = Locx I V xV->- V x Loc->- Loc x V->- Loc x Loc

Loc Loc

V x Loc->- Loc x V

Loc x Loc ■

where s signifies symmetries and Loc2 denotes the set of ordered pairs of distinct elements of Loc, with the unlabelled maps both given by the same canonical map,

u Loc x V x u —>- Loc x V->- Loc x V x Loc x V

Loc V Loc V

Loc V u

Loc V Loc V

Loc2 x V x V

where s again signifies a symmetry and with the unlabelled maps again given by the same canonical map, and

Loc Loc V

V x Locx V

Loc V Loc

Loc x V x V

Loc V Loc

Loc2 x V

Loc x V x l

where, again, the unlabelled maps are given by the same canonical map. Proposition 3.3 The diagram

in L commutes.

Proof. Use two applications of the first axiom and one application of the second axiom. □

The following theorem, stated in slightly different but equivalent terms, is the first main theorem of [15].

Theorem 3.4 For any category C with countable products and countable co-products, the forgetful functor U : Mod(LLocy, C) —► C exhibits the category Mod(LLoCvV, C) as monadic over C, with monad (S <%> -)S, where S is the set VLoc and S ® X is the coproduct of S copies of X.

We do not repeat the proof here, but we do make a few remarks, in order to facilitate our comparison with arrays in the next section. First observe that the result holds for an arbitrary category C with countable products and countable coproducts. So it holds equally for Setop as for Set: we need the former in order to characterise arrays.

Theorem 3.4 allows us to explain why we refer to LLocy as the countable Lawvere theory for global state. Taking C = Set, the induced monad is the monad for global state or side-effects [15]. Consider the free algebra on 1. It is of the form A = (SS, lookup, update) with typing lookup : \A\V —► \A|Loc and update : \A\ —► \A\LocxV. The function lookup sends a computation c e \ A\V to the computation c' e \ A\Loc given by

c'(loc)(a) = let v=sel(a, loc) in c(v)(a)

where sel(a,loc) = a (loc) looks up loc in a state a. Similarly, the function update sends a computation c e \A\ to the computation c' e \A\LocxV given by

c'(loc, v)(a) = c(upd(a, loc, v))

where upd(a, loc, v) updates a state a in location loc by v.

The structure on the left adjoint in general is given by the following proposition, cf [15].

Proposition 3.5 The left adjoint of the forgetful functor U : Mod(LLocy, C) -C sends an object X of C to the object (S ® X)S together with the maps

u : (S ® X)S ^ ((S ® X)S)LocxV

determined by composition with the function

Loc x V x VLoc —► VLoc

that, given (loc, v, a), "updates" a : Loc —► V by replacing its value at loc by v and

l : ((S ® X)S)V ^ ((S ® X)S)Loc

determined by composition with the function

Loc x VLoc —y V x VLoc

that, given (loc, a), "lookups" loc in a : Loc —► V to determine its value, and is given by the projection into VLoc.

For any countable Lawvere theory, one can routinely give an equational language for which equations between infinitary terms of the language correspond to commutative diagrams in the theory. So, for further comparison with arrays in the next section, the seven commutative diagrams in the definition of LLocy can be expressed equationally as the following seven axioms involving infinitary expressions respectively:

(i) lioc((uioc,v(a))v) = a (ii) lloc( (lloc( (avv' )v ))v' ) = lloc((avv)v)

(iii) Uloc,v(Uloc,v' (a)) = Uloc,v' (a)

(iv) Ul oc,v\bloc ( (av)v ) ) = Ul oc,v (av)

'■'loc ((ll oc! ( (avv' )v' ))v) hoc' ((ll oc ( (avv' ) v ))v') where loc = loc'

(vi) Uloc,v(uloc',v'(a)) = Uloc',v'(uloc,v(a)) where loc = loc'

(vii) Uloc,v(lloc'((av')v' )) = lloc'((Uloc,v(av'))v' ) where loc = loc'.

4 Arrays

In this section, we define and investigate the structure of the category of arrays, in particular showing that the category of (Loc, V)-arrays for a given finite set Loc and a countable set V is equivalent to the category of comodels for the countable Lawvere theory LLocy we defined for global state in the previous section. In giving an axiomatic definition of an array, we follow and mildly generalise the approach to arrays in [3,7,14,17].

Definition 4.1 Given a finite set Loc of locations and a set V of values, a (Loc, V)-array consists of a set A together with functions

sel : A x Loc —► V

Upd : A x Loc x V —► A subject to commutativity of the following four diagrams in Set:

A x Loc x V —>- A x Loc x V x Loc

upd x Loc

A x Loc

where the unlabelled map is determined by a diagonal 5Loc : Loc —► Loc x Loc and a symmetry,

A x Loc —>- A x Loc x A x Loc

A x Locx sel

A Loc V

where the unlabelled map is determined by a diagonal 5AxLoc : A x Loc A x Loc x A x Loc and a symmetry,

upd x Loc x V

A x Loc x V x V —>- A x Loc x V x Loc x V->- A x Loc x V

A Loc t V

A Loc V

where the unlabelled map is given by a diagonal ôLoc : Loc —► Loc x Loc

together with a symmetry, and A x Loc2 x V x V

A x LocxV x Locx V

upd x Loc x V

A Loc V Loc V

A Loc V

A Loc V Loc V

upd x Loc x V

A Loc V

where the two unlabelled maps are the same, both determined by the canonical inclusion of Loc2 into Locx Loc, and where s represents the canonical symmetry applied to Loc x V.

The axioms can equally be written as equations between terms. The maps sel and upd are functions, so the four axioms can expressed as follows: for loc and loc' in Loc, for v and v' in V, and for a in A,

(i) sel(upd(a, loc, v), loc) = v

(ii) upd(a, loc, sel(a, loc)) = a

(iii) upd(upd(a, loc, v), loc, v') = upd(a, loc, v')

(iv) upd(upd(a, loc, v), loc', v') = upd(upd(a, loc', v'), loc, v) where loc = loc'

There is an evident notion of a map of arrays from (A, sel, upd) to (A', sel', upd'), namely a function h : A —► A' that makes the evident two diagrams commute. This yields a category (Loc, V)-Array.

The relationship between the definition of an array and the Lawvere theory Lloc,v as we described it in Section 3 is not entirely trivial. The most obvious dissimilarity is that the former has four axioms while the latter has seven, and the next most obvious dissimilarity is that, if one thinks about duals for u and l, it is clear that u matches upd but that l does not match sel. On the other hand, the four array axioms are remarkably similar to four of the global state axioms, and to give a function sel : A x Loc —► V is equivalent to giving a

function sel' : A x Loc —► A x V subject to the axioms

.4 x Loc -—► .4 x V

A x Loc -—► A x V

So, a priori, there is good reason to hope that arrays are comodels of the countable Lawvere theory for global state. We proceed to give one way to show that, exhibiting a few side-results en route.

Proposition 4.2 The functor from Set to (Loc,V)-Array sending a set R to VLoc x R with the structure maps

VLoc x R x Loc —► V

VLoc x R x Loc x V —► VLoc x R

given by evaluation and by updating, is an equivalence of categories.

Proof. It is straightforward to verify that the structure maps given in the statement of the proposition satisfy our axioms for arrays. For the inverse, first observe that, for any array (A,sel,upd), there is a canonical function

upd : A x VLoc —► A given by a succession of Loc many applications of upd: putting Loc = {1,...,n}

upjdfa, vi,..., vn) = upxln{upxln-i(...), vn, n)

Now, given an array (A, upd, sel), define RA to be the set of all functions from VLoc to A of the form

upd(a, — ) : V

This trivially is a set. We need to give an isomorphism from the set VLoc x RA to A and prove that it respects upd and sel. We define a bijection p : A —►

VLoc x Ra as p(a) = (^(seli(a), ... , seln(a)), upd(a, — Using axioms one can show that sel and upd are respected. □

The proposition is essentially a reformulation and generalisation to many locations of a result in [7], which essentially amounts to the case of Loc being a one element set. It also bears remarkable and not coincidental similarity to the proof in [15] of Theorem 3.4 here: for that proof, we needed to make a construction on u that was essentially the same as that we have made here

on upd; we also needed to make such a construction for l, but here, our formulation in terms of sel rather than sel' makes that implicit, as the following results indicate.

Proposition 4.3 For any non-empty set X, the functor

-x X : Set —► Set is comonadic, with comonad given by (—)X x X.

Proof. The functor — x X has a right adjoint given by (—)X. Since X is non-empty, it also reflects isomorphisms. And it is routine to verify that it preserves equalisers. So, by the dual of Beck's monadicity theorem, it is comonadic [1]. □

Combining the two propositions, we can conclude the main result of this section.

Theorem 4.4 The forgetful functor from (Loc, V)-Array to Set is comonadic over Set, with comonad given by (—)V °° x VLoc.

The category Setop has countable products and countable coproducts, with products given by the coproducts of Set and with coproducts given by the products of Set. So, combining Theorem 3.4 with Theorem 4.4, we have the following result.

Corollary 4.5 Let LLoc,v be the countable Lawvere theory for global state. Then Comod(LLoc V,Set) is equivalent to (Loc,V)-Array.

5 Constructions: sum and tensor

Finally, in this section, we describe very briefly some theoretical value that derives from restriction from arbitrary comonads on Set to those comonads generated by comodels. We regard the example of arrays as our best example, and we regard the relationship between global state and arrays as inherently interesting. But there is more we can say on an abstract, technical level.

The notions of sum and tensor product of Lawvere theories have existed for many decades, but a recent account and references appear in [9,10].

Proposition 5.1 The sum L + L' of Lawvere theories L and L' is characterised by the universal property that to give a model of L + L' in any category C with finite products is equivalent to giving both a model of L and a model of L' that, when restricted along J : Natop —► L and J' : Natop —► L' are equal.

This universal property trivially can be described in terms of comonads. It follows immediately that the sum of Lawvere theories corresponds to the product of the comonads generated by each of them.

The tensor is more interesting: it yields a construct that does not seem to be a natural construct when considered in terms of comonads.

Proposition 5.2 The tensor product L ® L' of Lawvere theories is characterised by the universal property

Mod(L, Mod(L', C)) - Mod(L ® L', C) for any category C with finite products.

This yields the following result in terms of comodels.

Corollary 5.3 The tensor product L® L' of Lawvere theories is characterised by the universal property

Comod(L, Comod(L', C)) - Comod(L ® L', C)

for any category C with finite coproducts.

Observe that this involves taking models of L in the category Comod(L', C) rather than in C. That lifting is not, in general, given by a distributive law of comonads: see [9,10] for analysis of the dual situation. So it seems to be a genuinely new construction in regard to comodels relative to the known work on coalgebra. We have not yet explored the significance of that.

References

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

[2] Blackwell, R., G.M. Kelly and A.J. Power, Two-dimensional monad theory, J. Pure Appl. Algebra 59 (1989), 1-41.

[3] Collins G., and D. Syme, "A Theory of Finite Maps", Proc. 8th International Workshop on Higher Order Logic Theorem Proving and its Applications, eds. E.T. Schubert, P.J. Windley and J. Alves-Foss, Lecture Notes in Computer Science 971, Springer-Verlag, 1995.

[4] Dubuc, E., "Kan Extensions in Enriched Category Theory", Lecture Notes in Mathematics 145, Springer-Verlag, 1970.

[5] Ghani, N., C. Luth, F. de Marchi and A.J. Power, Algebras, Coalgebras, Monads and Comonads, Proc. CMCS 2001, Electronic Notes in Theoretical Computer Science 44 (2001),

URL: http://www.elsevier.com/locate/entcs/volume44.html.

[6] Ghani, N., C. Luth, F. de Marchi and A.J. Power, Dualising Initial Algebras, Mathematical Structures in Computer Science 13 (2003), 349-370.

[7] Hofmann, M., and B.C. Pierce, Positive Subtyping, Information and Computation 126 (1996), 11-33.

[8] Hyland, M., P.B. Levy, G.D. Plotkin and A.J. Power, "Combining Continuations with other Effects", Proc. Continuations Workshop 2004, BRICS Lecture Notes (to appear).

Hyland, M., G.D. Plotkin and A.J. Power, "Combining Computational Effects: commutativity and sum", Proc. 2nd IFIP Conf. on Theoretical Computer Science, eds. Ricardo A. Baeza-Yates, Ugo Montanari and Nicola Santoro, Kluwer, 2002.

[10] Hyland, M., G.D. Plotkin and A.J. Power, Combining effects: sum and tensor, Theoretical Computer Science, to appear.

11] Hyland, M., and A.J. Power, "Symmetric Monoidal Sketches", Proc. PPDP 2000, ACM, 2000.

12] Kelly, G.M., 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.

13] Kelly, G.M., "Basic Concepts of Enriched Category Theory", Cambridge University Press, 1982.

14] Oles, F., "Type Algebras, Functor Categories, and Block Structures", Algebraic Methods in Semantics, eds. Maurice Nivat and John C. Reynolds, Cambridge University Press, 1985.

15] Plotkin, G.D., and A.J. Power, "Notions of Computation determine Monads", Proc. FOSSACS 2002, Lecture Notes in Computer Science 2303, Springer-Verlag, 2002.

16] Power, A.J., "Enriched Lawvere Theories", Theory and Applications of Categories, 2000.

17] Stump, A., C.W. Barrett, D.L. Dill and J. Levitt, "A Decision Procedure for an Extensional Theory of Arrays", Proc. 16th IEEE Symposium on Logic in Computer Science, IEEE Press, 2001.