Available online at www.sciencedirect.com

ScienceDirect

Electronic Notes in Theoretical Computer Science 264 (2010) 47-62

www.elsevier.com/locate/entcs

On Coalgebras over Algebras

Adriana Balan1

Department of Mathematics II University Politehnica of Bucharest

Alexander Kurz

Department of Computer Science University of Leicester

Abstract

We extend Barr's well-known characterization of the final coalgebra of a £e£-endofunctor as the completion of its initial algebra to the Eilenberg-Moore category of algebras for a Set-monad M for functors arising as liftings. As an application we introduce the notion of commuting pair of endofunctors with respect to the monad M and show that under reasonable assumptions, the final coalgebra of one of the endofunctors involved can be obtained as the free algebra generated by the initial algebra of the other endofunctor.

Keywords: Coalgebra, algebras over a monad

1 Introduction

For any category C and any C-endofunctor H, there is a canonical arrow between the least and the greatest fixed points of H, namely between its initial algebra and final coalgebra, assuming these exist. Functors for which these objects exist and coincide were called algebraically compact by Barr [6] - for example, if the base category is enriched over complete metric spaces [5] or complete partial orders [23], then mild conditions ensure that the endofunctors are algebraically compact. However, if the category lacks any enrichment, as Set, this coincidence does not happen. But there is still something to be said: Barr [7] showed that for bicontinuous Set-endofunctors, the final coalgebra can be realized as the completion of its initial algebra. But this works if the functor does not map the empty set into itself, otherwise the initial algebra would be empty. Hence some well-known examples are lost, like functors obtained from powers and products. Barr's result was extended to all locally finitely

1 Supported by a Royal Society International Travel Grant

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

presentable categories by Adámek [3,4], in the sense that the completion procedure works for hom-sets, not objects, with respect to all finitely presentable objects.

In the present paper we have focused on coalgebras the carriers of which are algebras for a Set-monad, not necessarily finitary (see for example [9], [24]). Our interest arises from the following two developments.

First, streams or weighted automata, as pioneered by Rutten ([19], [20], [21]) are mathematically highly interesting examples of coalgebras, despite the fact that the type functor is very simple, just HX = A x X in the case of streams. The interesting structure arises from A, which in typical examples carries the structure of a semi-ring. In this paper, we shall bring this structure to the fore by lifting H to the category of modules for a semi-ring, or more generally, to the category of algebras for a suitable monad.

Second, in recent work of Kissig and the second author [14], it turned out that it is of interest to move the trace-semantics of Hasuo-Jacobs-Sokolova [10] from the Kleisli-category of a commutative monad to the Eilenberg-Moore category of algebras (for example, this allows to consider wider classes of monads). Again, for trace semantics, semi-ring monads are of special interest.

In the first part of this paper, we show that Barr's theorem [7] extends from coalgebras on Set to coalgebras on the Eilenberg-Moore category of algebras Alg(M) for a monad M on Set, dropping the assumption H0 = 0 (hence allowing examples like the functor H of stream coalgebras mentioned above).

We consider the situation of a Set-endofunctor H that has a lifting to Alg(M). Under some reasonable assumptions, we are able to prove that the final H-coalgebra can be obtained as the Cauchy completion of the image of the initial algebra for the lifted functor, with respect to the usual ultrametric inherited from the final sequence. For this, we need to understand better the initial algebra of the lifted functor. This is the purpose of the second part of the paper, where the special case of an initial algebra which is free (as an M-algebra) is exhibited. Namely, for two endofunctors H, T and a monad M on Set, we call (T, H) an M-commuting pair if there is a natural isomorphism HM = MT, where M is the functor part of the monad. It follows that if both algebra lift of H and Kleisli lift of T exist, then mild requirements ensure that H, the algebra lifted functor of H, is equivalent with the extension of T to Alg(M) if and only if they form a commuting pair. If this is the case, then one can recover the initial algebra for the lifted endofunctor H as the free M-algebra built on the initial T-algebra.

2 Final coalgebra for endofunctors lifted to categories of algebras

2.1 Final sequence for Set-endofunctors

Consider an endofunctor H : Set —► Set. From the unique arrow t : H1 —► 1 we may form the sequence

1H1 <----<-Hn1^Hnt Hn+11<--------(2.1)

Denote by L its limit, with pn : L —► Hn1 the corresponding cone. As we work in Set, recall that the limit L can be identified with a subset of the cartesian product Hn1, namely

L = {(^n)n>0 | Hnt(Xn+l) = Xn} By applying H to the sequence and to the limit, we get a cone

with HL ^ 1 the unique map to the singleton set. The limit property leads to a map t : HL ^ L such that pn o t = Hpn-\.

For each H-coalgebra (C, : C —> HC) it exists a cone an : C —> Hn1 over the sequence (2.1), built inductively as follows: a0 : C —> 1 is the unique map, then if an : C —► Hn1 is already obtained, construct an+i as the composite

H n+11

Then the unique map ac : C —> L such that pn o ac = an satisfies the following algebra-coalgebra diagram ([18]):

On the sequence (2.1), endow each set Hn1 with the discrete topology (so all maps Hnt will be continuous). Then put the initial topology [22] coming from this sequence on L and HL. It follows that t is continuous. In particular, the topology on L is given by an ultrametric: the distance between any two points in L is 2-n, where n is the smallest natural number such that pn(x) = pn(y). The cone

an : C —> Hn1 yields on any coalgebra a pseudo-ultrametric (hence a topology) and the unique map ac : C —> L is continuous with respect to it.

If H is wop-continuous, it preserves the limit L, hence the isomorphism £ = t-1 : L ~ HL makes L the final H-coalgebra. Moreover, using the above topology, the map £ is a homeomorphism and verifies

Hpn-1 ◦ £ = pn

2.2 Lifting to Eilenberg-Moore category of algebras for a monad

Let M = (M, M2 -U M, Id -U M) be a a monad on Set. Denote by Alg(M) the Eilenberg-Moore category of M-algebras and by FM 4 UM : Alg(M) —> Set the adjunction between the free and the forgetful functor. Then Alg(M) has an initial object, namely (M0,M20 -U M0), the free algebra on the empty set, and a terminal object 1, the singleton, with algebra structure given by the unique map M1 —► 1.

For a Set-endofunctor H, it is well known ([12]) that liftings of H to Alg(M), i.e. endofunctors H on Alg(M) such that the diagram

Alg(M) ■

и M Set —

■Alg(M)

и M Set

commutes, are in one-to-one correspondence with natural transformations A : MH —► HM satisfying

H^H MH

M MHM—^~ HM2

Remark 2.1 It is worth noticing that the lifting is not unique (as there may be more than one distributive law Л : MH —► HM). For example, take G a group and HX = MX = G x X; consider H as an endofunctor and M as a monad with natural transformations u,m obtained from the group structure. The algebras for this monad are the G-sets. Then it is easy to see that a map f : G x G —► G x G induces a distributive law Л : MH —► HM if it satisfies f (e,x) = (x,e) for all x G G, where e stands for the unit of the group, and f (ц x G) = (G x ¡j)(f x G)(G x f), where we have denoted by ц the group multiplication. Take now f\(x,y) = (xy,x) and f2(x,y) = (xyx-1,x); these maps produce two distributive laws Л1,Л2 : MH —► HM which do not give same lifting H, as the G-action on HX would be (x,y,z) —► (xy,x ^ z) for Л1, respectively (x,y,z) —► (xyx-1 ,x ^ z) for Л2. Here x,y G G,z G X and ^ denotes the left G-action on X. If the liftings would be isomorphic, then the associated categories of coalgebras should

also be isomorphic. In particular, notice that H is a comonad (as any set, in particular G, carries a natural comonoid structure) and both maps fi,f2 are actually inducing monad-comonad distributive laws Ai, respectively A2. Hence each lifting carries a comonad structure such that the associated categories of coalgebras for the lifted functors are Eilenberg-Moore categories of coalgebras and they should also be isomorphic. But for fi, a corresponding coalgebra is the same as a G-set (X, endowed with a map 9 : X —> G such that 9(g ^ x) = gO(x), while for the second structure, the compatibility relation yields a crossed G-set, i.e. 9(g ^ x) =

g9(x)g-i.

Assume from now on that a lifting of H to Alg(M) exists, given by A : MH —► HM. For any M-algebra (X, x), HX becomes an algebra

with MHXHMX HX and for any algebra map (X,x) —► (Y,y), the corresponding arrow HX —► HY respects the algebra structure. Also, for any H-coalgebra (C, C HC), MC inherits an H-coalgebra struc-

ture by £ : MC MHC HMC . In particular, if the final coalgebra

(L, L —U HL) exists, then there is a unique coalgebra map 7 : ML —> L, given by:

MLMHL^^ HML (2.6)

Y i \-Y tí? L---^ HL

Then (L,y) and (HL, H^Al) are M-algebras and £ : (L,y) —> (HL, H^Al) becomes an M-algebra map. By the lifting property, H(L,y) = (HL, H^Al) and as any H-coalgebra (its underlying set) is the carrier of an H-coalgebra, it follows that ((L,y),£) is the final H-coalgebra. Hence despite the fact that the lifting might not be unique, the underlying set of the final H-coalgebra is preserved (but with possibly different algebra structure, depending on A).

Coming back to the final sequence (2.1), note that any term Hn1 is an M-algebra

• the obvious unique M-algebra structure on 1, a0 : M1 —► 1;

• given an : MHn1 —► Hn1, define an+i as the composite

MHn+i1 HMHn1 -^n Hn+i1 (2.7)

Moreover, all maps in the sequence (2.1) are M-algebra maps by (2.5). Applying M to the sequence produces a cone from ML. If we assume H uop-continuous (hence £ : L ~ HL is an isomorphism), we can understand better this cone-construction:

Lemma 2.2 The cone (ML MHnl Hn\)n>0 coincides with the cone an : ML —► Hnl induced by the H-coalgebra structure of ML from (2.6).

Proof. Inductively. For n = 0, there is nothing to show as 1 is the terminal object

in Set. Assume an = an o Mpn, then in the following diagram

Mh"+11 HMHnl

HMp„-

Han H n+11

the triangle on the left commutes by (2.3), the middle diagram commutes by natu-rality of A and the triangle on the right by applying H to the inductive hypothesis. It follows that an+1 = an+1 o Mpn+1. □

In consequence, the unique coalgebra map 7 : ML —> L constructed in (2.6) is also the anamorphism auh : ML —► L for the coalgebra ML.

Lemma 2.3 The projections pn : L —► Hn1 are M-algebra morphisms, with (2.6) and (2.7) giving the algebra structures of L, respectively Hn1.

Proof. Again by induction. The first step is trivial. Assume that pn is an algebra map: nn o j = an o Mpn; then we have the following diagram

Mpn + 1

-MHn+11

(2) -L (4)

HM^-HMpnHMHn1

HY (5)

HL Han

where: (1) commutes by applying M to (2.3); (2) commutes by (2.6); (3) commutes by (2.3); (4) commutes by the naturality of A and (5) commutes by applying H to the inductive hypothesis. □

Resuming all above, we have the following diagram of M-algebras and M-algebra morphisms, in which the lower sequence is limiting:

M lMHl-

-MHn1MHtMHn+11-

Hn+1l-

2.3 Topology on the final coalgebra

From now on, we shall assume that H is an wop-continuous endofunctor which admits a lifting to Alg(M). Remember that on all Hn1 we have considered the discrete topology. Endow also all MHn1 with the discrete topology (intuitively, this corresponds to the fact that operations on algebras with discrete topology are automatically continuous) and ML with the initial topology coming from the cone Mpn : ML —► MHn1 (which is the same as the initial topology from the cone

ML MHn1 Hn1, as an are continuous maps between discrete spaces).

Proposition 2.4 Under the above assumptions, the final H-coalgebra inherits a structure of a topological M-algebra2 , i.e. L has a M-algebra structure 7 : ML —> L such that 7 is continuous with respect to the topologies on L and ML.

Proof. By definition of the initial topology, 7 is continuous if and only if all compositions 7 ◦ pn are continuous. But 7 o pn = an o Mpn, an are continuous as maps between discrete sets and Mpn are continuous by the initial topology on ML. □

Notice that this result relies heavily on the construction of the final coalgebra as the limit of the sequence (2.1). Without it, we can not obtain Proposition 2.4 just by assuming the existence of the final H-coalgebra and of the lifting to Alg(M), as there is no obvious choice for the topology on ML. Also Proposition 2.4 can be interpreted by saying that all operations on L are continuous (as they are obtained as limits of operations on discrete algebras).

Remark 2.5 Instead of an wop-continuous endofunctor, we could use a finitary one. It is known [25] that the final coalgebra exists, but the previous limit is not enough. From this, a supplementary construction gives the final coalgebra. Obviously, the final coalgebra has an M-algebra structure as in (2.6). Following Worrell's construction [25], the terminal sequence would still induce a topology on L, and the easiest way would be to take on ML the initial topology with respect to 7, but this is not the same as the construction pursued here (the topology on ML comes from the terminal sequence).

2.4 Initial H-algebra and final H-coalgebra in Alg(M)

If H preserves colimits of w-sequences, then the initial H-algebra is easy to build, using a dual procedure to the one in (2.1): recall that Alg(M) has an initial object, namely the free algebra on the empty set, FM0 = (M0,M20——M0). In order to simplify the notation, we shall identify all algebras HnFM0 with their underlying sets HnM0. Then it is well-known that the initial H-algebra is the colimit in Alg(M) of the chain

t TT\ lJn\

M0 HM0 -— ... —► HnM0 ... (2.8)

2 Usually the notion of a topological algebra refers to an algebra for some finitary, algebraic theory whose underlying set is equipped with some topology, such that the algebra operations are continuous ([13]). As Eilenberg-Moore algebras for a Seí-monad are the same as algebras for (not necessarily) finitary algebraic theories ([i]), we find that the term topological algebra characterizes the best the present situation.

where ! : M0 —► HM0 is the unique algebra map. Denote by in : HnM0 —► I the colimiting cocone. We do not detail anymore this construction as we did for coalgebras as it will not be used in the sequel. However, we shall need the following (which requires only the existence in Alg(M) of the limit of the terminal sequence (2.1), respectively of the colimit of the initial sequence (2.8)): there is a unique M-algebra morphism f : I —► L such that

HnM 0I (2.9)

commutes for all n (see for example [3], Lemma II.5 for a proof), where s : M0 —► 1 is the unique algebra map from the initial to the final object in Alg(M). If M0 not empty, then I will also be not empty, as it comes with a cocone of algebra maps with not empty domains.

We shall generalize in this section the result of Barr ([7]) from Set to Alg(M), for the special case of Alg (M)-endofunctors arising as liftings of Set-endofunctors. The proofs use similar ideas to the ones in [7] and [3]. We shall assume that there is an algebra map

j : 1 —► M0 (2.10)

As M0 is initial, j o s = Id. By finality of 1 in Alg(M), s o j = Id, hence we may identify M0 and 1 as the zero object in the category of algebras.

Remark 2.6 There is a large class of monads satisfying this condition: the list monad (and the commutative monoid-group-semi-ring monad), the (finite) powerset monad, the maybe monad, the k-modules monad for a semi-ring k. For all these, the free algebra with empty generators is built on the singleton set. But there are also monads for which the carrier of the free algebra on the empty set has more than one element, as the exception monad or the families monad, or it is empty, as is the case for the monad MX = X x m, for m a monoid. It is still under work whether the results of the present paper hold under this weakened assumption.

We have ! : 1 = M0 —► HM0 = H1 and to! = Id in Alg(M). Hence in the final sequence (2.1) all morphisms are split algebra maps, the colimit is the initial H-algebra and the limit is the final H (and Hf)-coalgebra:

1 ^ H1 ^ ... ^ Hn1 ^ Hn+11 ^ ... (2.11)

Theorem 2.7 Let H a Set-endofunctor uop-continuous, M a monad on Set such that:

(i) H admits a lifting H to Alg(M) which is u-cocontinuous;

(ii) M0 = 1 in Alg(M);

then the final H-coalgebra is the completion of the initial H - algebra under a suitable (ultra)metric.

Proof. Consider the following diagram (in Alg(M)), where all algebras involved have structure maps defined via the distributive law A.

Put on I the smallest topology such that f is continuous, where L has the structure of a topological algebra from Proposition 2.4. This coincides with the initial topol-

ogy given by the cone I —> L Hn1. Moreover, I becomes a topological algebra and all in are continuous algebra maps, if on MI we take the topology induced by the map Mf : MI —► ML. In particular, Mf is continuous. Denote by MI I the algebra structure map of I. Then f o Z = 7 o Mf (remember that f is an algebra map). As L is a topological M-algebra, it follows that f oZ is continuous, hence Z is continuous. About in: these are by construction algebra maps (as the components of the colimiting cocone in Alg(M)) and also continuous, as Hn1 are discrete. The only remaining thing we need to prove is the density of I (more precisely, of Imf) in L. We start by applying Barr's argument to show that L is complete under this ultrametric. First, use that limits in Alg(M) are computed as in Set to conclude that L is Cauchy complete: take a Cauchy sequence x(n) in L with respect to the initial topology (ultrametric) and assume d(x(n),x(m)) < 2-mm(m>n) for all m, n. This implies pn o f (x(n)) = pn o f (x(m)) for all n < m. Thus y = (pn o f (x(n)))n>0 defines an element of L such that lim x(n) = y. Next, a similar construction to the one in [4] will show us that the image of I under the algebra morphism f is dense in L. For this purpose, consider the additional M-algebra sequence of morphisms (hn)n>o, given by

hn : L Hn1 = HnM0 —™ Hn+1M0 —+1 I f L

We have pn+i o hn = Hn! o pn. Consider now an element x £ L. Then by construction (y(n) = hn(x))n>0 form a sequence of elements lying in the image of f and we shall see that this sequence is convergent to x. Indeed, from pn+1(y(n)) = Hn! o pn(x) it follows that

pn(y(n)) = Hn o t o pn+i(y(n)) = Hn o t o Hn! o pn(x) = pn(x)

the n-th projection of the n-th term of the sequence (yn))n>0 coinciding with the n-th projection of the element x; hence d(y(n),x) < 2-n which implies limy(n) = x in L. Therefore the image of I through the canonical colimit—► limit arrow is dense in L. □

Remark 2.8 (i) If we consider on the initial algebra I the final topology coming from the w-chain, this is exactly the discrete topology (and metric), since all Hn1 are discrete, hence I would be Cauchy complete and f : I ^ L automatically continuous. No interesting information between I and L can be obtained in this situation.

(ii) From (2.9) and (2.10) we have pn o f oin = Id, hence f oin is a monomorphism. But all morphism in the above sequence are split algebra maps by (2.11), hence all Hn! are mono's. Recall now from [3] that in any locally finitely presentable category,

• the cocone to the colimit of an w-chain formed by monomorphisms is a monomorphism,

• for every cocone to the chain formed by monomorphisms, the unique map from the colimit is again a monomorphism.

If we assume M finitary, the Eilenberg-Moore category of algebras would be locally finitely presentable. Hence the algebra map f would be mono. But remember that any Set-monad is regular ([1]). It follows that we can identify I with a subalgebra of L. The algebra isomorphism g : I ~ Imf would also be a homeomorphism, if we take on Imf the induced topology from L.

(iii) The w-cocontinuity of H is automatically satisfied if we assume M, H to be finitary. For, the monad being finitary, the forgetful functor UM would preserve and reflect sifted colimits. But UMH = HUM, hence H commutes with sifted colimits, in particular with colimits of w-chains.

Example 2.9 The functor HX = k x XA is built from products, hence is w-continuous. The H-coalgebras are known as Moore automata. Such a functor always admits at least one lifting to Alg(M) for any monad M, provided k carries an algebra structure. The lifted functor is given by the same formula as H, where this time the product and the power are computed in the category of algebras.

In particular, consider A a finite set, k a (not necessarily commutative) semiring and M the monad that it induces (as in [16], Section VI.4, Ex. 2, where the ring R is replaced by the semi-ring k); then Alg (M) is the category of k-modules and M0 is the zero module. The final H-coalgebra is kA*, the set of all functions A* —► k, also known as the formal power series in non-commuting A variables, while the initial H-algebra is the direct sum of A* copies of k (the polynomial algebra in same variables) (recall that in this case, finite products and coproducts coincide in Alg(M)). The approximants of order n in the corresponding w-sequence are Hn1 = k1+A+'"+A", the polynomials in (non-commuting) A-variables of degree at most n. We shall detail this for the easiest case, where A is the singleton {t}; the distance between two elements of the final coalgebra k[[t]], i.e. between two power series f (t),g(t) in variable t, is given precisely by 2-ord(f(i)-g(i)), where ord(f (t) — g(t)) is the order of the difference f (t) — g(t) (the smallest power of t which occurs with a nonzero coefficient in the difference). Take a Cauchy sequence of polynomials fn(t) = a]j + ant + ..., where only finitely many a^ are nonzero, for

each n,j £ N. For every r > 0, there exists an nr such that for every n > nr, we have ord(fn(t) — fnr(t)) = r; this implies an = anr for all j < r and n > nr. Let f(t) = ajn° + an11 + .... One immediately verifies that the power series f(t) is the limit of of the sequence (fn(t))n>0. Hence the final coalgebra k[[t]] is indeed the completion of the initial H-algebra k[t].

3 Application: M-commuting pairs of endofunctors

Consider an endofunctor H and a monad M, both on Set. There are two ways of relating the endofunctor to the monad by a natural transformation, as follows:

• X : MH —► HM satisfying (2.5), which is the same as an algebra lift H : Alg(M) —► Alg(M), UMH = HUM;

? : HM —► MH satisfying

H—^ HM

HM2 MHMM 2H

It is well known that this is equivalent to the existence of a Kleisli lift, i.e. an endofunctor H : Kl(M) —► Kl(M) such that HFM = FMH, where Fm : Set —► Kl (M) is the canonical functor to the Kleisli category of the monad. In this case, we can perform the following additional construction: denote by I : Kl(M) —► Alg(M) the comparison functor. Take the Alg(M)-endofunctor given by the left Kan extension along I (which exists since every algebra in Alg(M) arises as a coequaliser of free algebras in a canonical way):

H = Lam (IH)

As the Kleisli category Kl(M) is isomorphic to a full subcategory of Alg(M), this would yield a natural isomorphism IH = HI. Composing this with the functor Fm, we obtain HFM = FMH, as in the diagram below:

Alg(M).....Alg (M)

F M l(M)—Kl (M FM

We shall call H an extension of H to algebras.

With the above notations, consider now two Set-functors T, H such that both an algebra lift of H and a Kleisli lift of T exist and H = T. Then we have

MMT_U Mf = u

= U MHFM = HUMFM = HM i.e. M acts like a switch (up to isomorphism) between the endofunctors T and H.

Definition 3.1 Let M = (M, m, u) be a monad on Set. A pair of Set-endofunctors (T, H) such that HM = MT is called an M-commuting pair.

Example 3.2 One can easily obtain commuting pairs in the following situations:

• Take T = H = Id or T = H = M and M = (M, m, u) any monad;

• Consider T = H = A + (—), M = B + (—). Then commmutativity of the coproduct ensures the commuting pair; similarly for products: T = H = A x (—), M = B x (—), where this time B is a monoid (this works more generally, in any monoidal category).

To the best of our knowledge, it seems that the notion of commuting pairs has not been considered previously, although the above examples show that it arises naturally in mathematics. We shall later see more (non-trivial) examples. But before that, we come back to the situation considered earlier, of the two endofunctors T and H such that H = T. This implies

H FM = TFM = F MT

which can be rephrased by saying that HM = MT is an isomorphism of M-algebras, where the algebra structure of HMX, for a set X, is induced by the distributivity law A : MH —► HM, i.e. the following diagram commutes:

MHMXM 2TX (3.4)

HM2X mTx

HMX = > MTX

where the lower horizontal arrow is HM = MT, while the upper arrow is obtained by applying M to this.

Conversely, if (T, H) is an M-commuting pair, one may wonder about their relation with the category of M-algebras. Suppose H has an algebra lifting H, T has a Kleisli lift (hence an extension T) and HM = MT such that (3.4) holds; then from HM = MT and

HM = HUMFM = U MHF m MMT_U MF MT = U MTFM

it follows that UMHFM = UMTFM, that is, the images of H and T on free algebras share (up to bijection) the same underlying set. Taking into account that HM = MT is an isomorphism of M-algebras (3.4), we obtain that H = T on free algebras. Assume now that M, T and H are finitary. Then, by construction, T is

determined by its action on finitely generated free algebras, and so is H (because it preserves sifted colimits by Remark 2.8(iii)). It follows that H = T. We have obtained thus

Proposition 3.3 Let H, T two endofunctors on Set and M a monad on Set. Assume that H has an algebra lift H and T has a Kleisli lift with respect to the monad M. Denote by T the corresponding left Kan extension, as in (3.2). Then:

(i) If H = T, then (T, H) form an M-commuting pair and HM = MT is an algebra isomorphism.

(ii) Conversely, if M, H, T are finitary and MT = HM as algebras, then H = T.

Example 3.4 Take TX = 1+AxX, with A finite set and M any Set-monad. Then

a Kleisli lifting of T exists, namely for each map X —► MY, take TX —► MTY to be the composite

TX = 1 + A x X 1 + A x MY —►

1 + M (A x Y) —► M1 + M (A x Y) —► M (1 + A x Y)

where the map 1+AxMY —► 1+M(Ax Y) is obtained from the canonical strength of the monad, while 1 + M(A x Y) —► M1 + M(A x Y) uses the unit of the monad and M 1 + M (A x Y) —► M (1 + A x Y) comes from the coproduct property. Also, it is easy to see that the extension of T to M-algebras is TX = FM1 + A ■ X, for each algebra X, where this time the coproduct (respectively the copower) is computed in Alg (M). If the category of M-algebras has finite biproducts (as in the case of the monad induced by a semi-ring, see Example 2.9), then T is the lifting to Alg(M) of the Set-endofunctor HX = M1 x XA. Hence (T, H) form a commuting pair.

The motivation for studying commuting pairs appears clearly if we combine the previous proposition with our main result from Theorem 2.7, obtaining the following:

Corollary 3.5 Assume the assumptions of Proposition 3.3(ii) hold. If H is wop-continuous and M0 = 1 as M-algebras, then the final H-coalgebra is the completion of the free M-algebra built on the initial T-algebra under a suitable metric.

Proof. Follows from Theorem 2.7, by noticing that the M-image of the initial T-algebra (which exists as T is finitary, hence w-cocontinuous) is the initial T-algebra (by construction, T is finitary, so w-cocontinuous), while H and H share same final coalgebra. □

Example 3.6 We come back to Example 3.4 and take the monad induced by a semi-ring k, as in Example 2.9. Then the initial T-algebra is A*, the monoid of all finite words (including the empty one) built on the alphabet A. The free M-algebra is the direct sum of A* copies of k, that is, the polynomial k-algebra in non-commuting A-variables k[A] (in the category of k-semimodules), while the final H-coalgebra is kA*, the non-commutative power series k-algebra.

The situation described until now in this section can be presented as follows: If two endofunctors T and H are given, one may search for the appropriate monad such that (T, H) form a commuting pair. As there is a special bond between algebras of T and coalgebras of H, it is not clear whether the general case of any two (finitary) Set-endofunctors would have a solution. But there is another possible approach: Start only with one endofunctor and additionally with a (finitary) monad; find then a distributive law inducing a Kleisli (or algebra) lift. Once this is accomplished, one should built a second endofunctor on Set (assuming this is possible) in order to obtain a commuting pair, using the functor obtained on Alg(M).

For lifting to the Kleisli category, there is the following suitable situation: for all commutative monads M and all analytic functors T, a distributive law TM —► MT can always be constructed ([17]). The commutativity of M ensures also the existence of a tensor product ® on Alg(M), such that the free functor FM : (Set, x) —>

(Alg(M), &) is strong monoidal ([11]). If T is a polynomial functor TX = An x

Xn, an obvious choice of Kleisli lift would give (the extension) TX = U FMAn ®

X®n, where this time X £ Alg(M). Now recall that both the coproduct and the tensor product on Alg (M) are obtained as reflexive coequalizers, hence if we assume the monad not only commutative but also finitary (as all results in this section rely on the finitariness of M), it follows that the forgetful functor would transform the coproduct, respectively the tensor product of any two algebras (X,x), (Y,y) into a reflexive coequalizer computed this time in Set. In particular, for the polynomial functor T, a corresponding commuting pair (T, H) exists and can be constructed by the above argument. Moreover such H is finitary by construction. If H is also wop-continuous and M0 = 1 as algebras, then by Corollary 3.5 the final H-coalgebra should be realized as a completion of the (image) of the free algebra built on the initial T-algebra (which is well known to be the set of finite trees with branching and labeling given by the signature of T).

However, lifting functors to the Eilenberg-Moore category seems to be more problematic, even for the simplest case of polynomial functors, as follows:

• if H is a constant functor, then the image of H (the set) must be the carrier of an M-algebra (A, a); if this is the case, one may form a commuting pair if and only if A is a free algebra. Then T is also a constant functor; in particular, Corollary 3.5 is trivially true.

• if HX = A x X, and A is the carrier of an algebra, a lift is easily seen to exist, as the forgetful functor UM preserve products. Conversely, if H is a lifting of H, then there is an algebra structure on A, namely H1. If the category Alg(M) has finite biproducts (for example if M is the monad induced by a semi-ring k) and A is the carrier of a free algebra with set generators B, then there is a commuting pair (T, H) with TX = B + X. The final H-coalgebra is the set of all streams on A, while the M-algebra on the initial T-algebra is the w-copower of MB = A.

• if HX = Xn, a finite power functor, then the lifting exists as the forgetful functor UM preserves limits; the existence of finite biproducts in Alg(M) is again the most

convenient way of finding the correspondent functor as a copower TX = n ■ X. But in this case no relevant answers are obtained in the initial-final (co)algebra relation, as these objects are trivial (empty initial T-algebra, singleton final H-coalgebra).

• if HX = A + X or HX = X + X, there is no obvious distributive law A : MH —► HM, unless the monad itself is obtained as a sum (like the maybe monad MX = 1 + X).

4 Conclusions

The general picture behind Barr's theorem is conceptually simpler: if one starts with an arbitrary category C (with initial object, final object and w-(co)limits) and a C-functor, then the theorem roughly says that the w-limit of the terminal sequence is a completion of the wop-colimit of the initial sequence. Of course an appropriate notion of completion is required; it could be of topological nature (as in [7]), or about ordered structures ([3]). In the present paper we have emphasized the topological aspect (Cauchy completion) for base category C with algebraic structure, namely the Eilenberg-Moore category of a Set-monad. The end-ofunctors considered were obtained as liftings from Set, as one of our motivations came from the following question: given a continuous Set-functor H with H0 = 0, what can be said about the final H-coalgebra? If the functor is not necessary continuous (for example the finite powerset functor), then the final sequence has to be extended beyond w steps. What happens with the completion procedure on Alg(M) in such cases? We believe that an answer to this question is worth considering in the future.

The second part of the paper introduces the notion of a commuting pair of endofunctors with respect to a monad. This seems to be new, however a detailed analysis and more examples are needed in order to better understand this structure (like the connection between bisimulations and traces exhibited in [8]). We plan to do this in a further paper.

Acknowledgement

The authors would like to thank the referees for their valuable suggestions, which helped improving the first version of this paper.

References

[1] Adamek J., H. Herrlich and G.-E. Strecker, "Abstract and Concrete Categories", John Wiley & Sons, 1990.

[2] Adamek, J. and J. Rosicky, On sifted, colimits and generalized varieties, Theory Appl. Categ. 8 (2001), 33-53.

[3] Adamek, J., Final coalgebras are ideal completions of initial algebras, J. Log. Comput. 12 (2002), 217-242.

[4] Adamek, J., On final coalgebras of continuous functors, Theor. Comput. Sci. 294 (2003), 3-29.

[5] America, P. and J. Rutten, Solving reflexive domain equations in a category of complete metric spaces, J. Comput. Syst. Sci. 39 (1989), 343-375.

Barr, M., Algebraically compact functors, J. Pure Appl. Algebra 82 (1992), 211-231. Barr, M., Terminal coalgebras in well-founded set theory, Theor. Comput. Sci. 114 (1993), 299-315.

Bonchi, F., M. M. Bonsangue, J.J.M.M. Rutten and A.Silva, Algebraic enriched coalgebras. submitted, 2010.

Corradini A., M. GroBe-Rhode and R. Heckel, Structured transition system as lax coalgebras. In "Coalgebraic methods in computer science CMCS'98", Electr. Notes Theor. Computer Sci. 11 (1998), 22-41.

Hasuo I., B. Jacobs and A. Sokolova, Generic trace theory. In "Coalgebraic methods in computer science CMCS'06", Electr. Notes Theor. Computer Sci. 164 (2006), 47-65.

Jacobs, B., Semantics of weakening and contraction, Ann. Pure Appl. Logic 69 (1994), 73-106.

Johnstone, P. T., Adjoint lifting theorems for categories of algebras, Bull. London Math. Soc. 79 (1975), 294-297.

Johnstone, P. T., "Stone spaces", Cambridge Univ. Press, Cambridge, 1982. Kissig, C. and A. Kurz, Generic Trace Logics, draft, 2010.

Linton, F.E.J., Coequalizers in categories of algebras. In "Seminar on Triples and Categorical Homology Theory", LNM 80, Springer Verlag, 1969, 75-90.

Mac Lane, S., "Categories for the working mathematician", 2nd ed., GTM 5, Springer Verlag, New York, 1998.

Milius, St., Th. Palm and D. Schwencke, Complete Iterativity for Algebras with Effects. In "Algebra and Coalgebra in Computer Science", LNCS 5728, Springer Verlag, 2009, 34-48.

Moss, L., A Note on Expressive Coalgebraic Logics for Finitary Set Functors, J. of Logic and Comput. Adv. Access, doi:10.1093/logcom/exn095, 2008.

Rutten J., Automata and coinduction - an exercise in coalgebra. In "CONCUR'98", LNCS 1466, Springer Verlag, 1998, 194-218.

Rutten J., Behavioural differential equations: A coinductive calculus of streams, automata, and power series, Report SEN-R0023, CWI, Amsterdam, 2000.

Rutten J., Coinductive counting with weighted automata, J. Autom. Lang. Comb. 8 (2003), 319-352.

Schaefer H. H., "Topological vector spaces", GTM 3, Springer Verlag, New York, 1971.

Smyth, M.B. and G. D. Plotkin, The category-theoretic solution of recursive domain equations, SIAM J. Comput. 11 (1982), 761-783.

Turi D. and G. D. Plotkin, Towards a mathematical operational semantics. In "Proceedings of the 12th Annual IEEE Symposium on Logic in Computer Science", LICS, IEEE Computer Society, Washington, DC, 1997, 280-291.

Worrell, J., On the final sequence of a finitary set functor, Theor. Comput. Sci. 338 (2005), 184-199.