Scholarly article on topic 'Distributivity for endofunctors, pointed and co-pointed endofunctors, monads and comonads'

Distributivity for endofunctors, pointed and co-pointed endofunctors, monads and comonads Academic research paper on "Computer and information sciences"

CC BY-NC-ND
0
0
Share paper
Keywords
{}

Abstract of research paper on Computer and information sciences, author of scientific article — Marina Lenisa, John Power, Hiroshi Watanabe

Abstract We generalise the notion of a distributive law between a monad and a comonad to consider weakened structures such as pointed or co-pointed endofunctors, or endofunctors. We investigate Eilenberg-Moore and Kleisli constructions for each of these possibilities. Then we consider two applications of these weakened notions of distributivity in detail. We characterise Turi and Plotkin's model of GSOS as a distributive law of a monad over a co-pointed endofunctor, and we analyse generalised coiteration and coalgebraic coinduction “up-to” in terms of a distributive law of the underlying pointed endofunctor of a monad over an endofunctor.

Academic research paper on topic "Distributivity for endofunctors, pointed and co-pointed endofunctors, monads and comonads"

Electronic Notes in Theoretical Computer Science 33 (2000)

URL: http://www.elsevier.nl/locate/entcs/volume33.html 31 pages

Distributivity for endofunctors, pointed and co-pointed endofunctors, monads and

comonads

Marina Lenisa1

Dipartimento di Matematica e Informatica Universitd di Udine 1-33100 Udine, ITALY

John Power2

Laboratory for the Foundations of Computer Science, Division of Informatics

University of Edinburgh King's Buildings, Edinburgh EH9 3JZ, SCOTLAND

Hiroshi Watanabe 3

Osaka LERC Electrotechnical Laboratory Amagasaki 661-0974, JAPAN

Abstract

We generalise the notion of a distributive law between a monad and a comonad to consider weakened structures such as pointed or co-pointed endofunctors, or endofunctors. We investigate Eilenberg-Moore and Kleisli constructions for each of these possibilities. Then we consider two applications of these weakened notions of distributivity in detail. We characterise Turi and Plotkin's model of GSOS as a distributive law of a monad over a co-pointed endofunctor, and we analyse generalised coiteration and coalgebraic coinduction "up-to" in terms of a distributive law of the underlying pointed endofunctor of a monad over an endofunctor.

1 Work supported by Esprit Working Group "Types", MURST'99 Cofin. "Sistemi Formali..." grant.

2 This work is supported by EPSRC grants GR/J84205: Frameworks for programming language semantics and logic and GR/M56333: The structure of programming languages : syntax and semantics, and British Council grant 747 FCS R34807: Data and program refinement using algebraic structure.

3 The author acknowledges the support of STA through COE budget for Global Information Processing Project.

©2000 Published by Elsevier Science B. V.

1 Introduction

The notion of distributivity between a monad and a comonad plays an important role in the theory of coalgebraic methods in computer science [17,18]. But sometimes one has less data than that of a monad or a comonad, and sometimes one requires fewer commutativities, for instance having a pointed endofunctor or, dually, a co-pointed endofunctor. A pointed endofunctor has structure that is weaker than that of monad but stronger than that of an endofunctor. The notion was studied in Kelly [9], where he studied the free generation of a monad from a pointed endofunctor.

In computer science, distributivities involve such weakened notions have appeared recently in Turi and Plotkin's model of GSOS in programming languages without variable binding [22], in operations on (initial) algebras [3], and in work on generalised coiteration and coalgebraic coinduction "up-to"[13].

A distributive law of a monad (T, /i, r/) over a comonad (_D, 8} e) on a category C consists of a natural transformation TD =>- DT satisfying four commutative diagrams involving /i, r/} 8 and e. The weakenings involving removing some of the axioms, as one only has some of the data.

Previously [17,18], we gave a systematic treatment of distributivity for a monad and a comonad. We analysed, in terms of a monad and a comonad in a 2-category, Eilenberg-Moore and Kleisli constructions. Here we extend that framework to pointed/co-pointed endofunctors and endofunctors, yielding a systematic treatment. We also analyse Eilenberg-Moore and Kleisli constructions for them, giving categories of algebras for pointed endofunctors, coalgebras for co-pointed endofunctors and Kleisli categories for pointed/co-pointed endofunctors in the 2-category of small categories.

An Eilenberg-Moore coalgebra for a comonad is a coalgebra (X, k : X —y HX) which satisfies two commutative diagrams, one for each of the comultipli-cation and the counit. A coalgebra for a co-pointed endofunctor is a coalgebra for which only the diagram for the counit need commute.

In [17,18], a distributive law between a monad and a comonad was shown to be a 0-cell in a 2-category given by combining the monad and comonad constructions. Here we shall classify distributivities in a 2-categorical framework in the same manner. The abstract theory we give here is mathematically easy; but its value lies in providing substantial simplification and elucidation of applications. So we study two applications in detail.

One is an application to GSOS by Turi and Plotkin [22]. Given a syntax endofunctor E and a behaviour endofunctor _£?, they modelled a GSOS rule by an abstract operational rule, which is a natural transformation E(_E? X Id) =>-BT, where T is the free (syntax) monad on E. They showed that this natural transformation determines a distributivity A of the monad T over the comonad D, the cofree comonad on _£?, giving a category A-Bialg of A-bialgebras that provides a combined operational and denotational model of the language.

In constructing their distributive law, they constructed a lifting of T to

B-coalg, the category of coalgebras for from the abstract operational rule E(£? X Id) =>■ BT, by using a special type of recursion (Theorem 5.1 in [22]).

We apply our framework to show that their abstract operational rule S(Bx Id) =>■ BT is equivalent to a distributive law of the monad T over the co-pointed endofunctor B X Id cofreely generated by B. This distributivity also implies Turi and Plotkin's distributive law of T over D. So we shall give a simple proof avoiding the recursion theorem.

Our other application lies in generalised coiteration and coalgebraic conduction "up-to". We consider the work of [13]. Here, we express the key condition as a distributive law of the underlying pointed endofunctor of a monad T over an endofunctor F. This allows us to strengthen the main result of [13] and clarify the construction. The role of T and F is to provide an F-bisimulation up to T, and the result provides a sound coinduction principle for such bisimulations. We give a range of examples to show how this works.

In Section 2, we define the notion of pointed/co-pointed endofunctor and endofunctor in a 2-category. We refer an "endofunctor in a 2-category" as a

1-cell of a 2-category. So it needs not have anything to do with endofunctors. The same applies for pointed/co-pointed endofunctor. But we do make this convention through this paper. Then we introduce the 2-categories pEndo(A), pEndo*(A"), copEndo(A), cop En do* (A"), Endo(A") and Endo*(A"). We also explain the Eilenberg-Moore and Kleisli constructions and liftings to them. In Section 3, we show an analysis of distributive law of a monad over a co-pointed endofunctor by using our 2-categorical framework.

We introduce the notion of free pointed endofunctor and cofree co-pointed endofunctor in Section 4.

We give an application to Turi and Plotkin's work in Section 5. Their work can be captured as a distributivity of a monad over a co-pointed endofunctor. This observation simplifies the construction of distributive law of the free monad T on E over the cofree comonad D on B.

We finally investigate generalised coiteration and coalgebraic coinduction "up-to" in Section 6.

2 Eilenberg-Moore and Kleisli constructions in a 2-category

We need the basic notion of 2-categories (the definition, op, co-constructions,

2-functors and 2-adjunctions). Please see the Appendix 1 or Kelly and Street's review [10].

2.1 Monads and comonads

We give an overview of monads and comonads and the 2-categorical framework in which to treat them (for details and explicit definitions please see [17,18]). Let K be a 2-category.

Definition 2.1 A monad (C, T,/¿,77) in a 2-category K consists of a 0-cell

C, a 1-cell T on it, two 2-cells /1 : T2 =>- T and r] : Id =>- T subject to ¡i ■ Tfi = ¡i ■ fiT, ¡i ■ Ti] = idy and ¡i ■ r]T = idy.

In the above, the usual definition of a monad on a small category is captured by the case of K = Cat.

A 2-category Mnd(A") of monads in K is as follows. A 0-cell is a monad in K, a 1-cell from (C, T, /i,??) to (C, T',//, ?/) is a monad morphism, i.e., a

1-cell J : C —y C' and a 2-cell j : T'J =>■ .IT in K subject to two coherence conditions, and a 2-cell from (J,j) to (H,h) is a 2-cell a : J H in K satisfying one coherence condition.

Using the op-construction, a 2-category Mnd*(A") is defined by Mnd*(A") = Mnd(A"op)op. Each 0-cell of this 2-category is also a monad in K.

If we reverse the directions of a 1-cell and 2-cells in the definition of a monad in K, we have a definition of a comonad in K.

In the same manner, we can define the 2-category Cmd(A") of comonads in K as Cmd(A") = Mnd(A^co)co. We can also define Cmd*(A^) as Cmd*(A^) = Cmd(A"op)op. Both 2-categories Cmd(A") and Cmd*(A") have comonads in K as 0-cells.

2.1.1 Eilenberg-Moore/Kleisli constructions

For each of the 2-categories Mnd(A"), Mnd*(A"), Cmd(A") and Cmd*(A"), there is a 2-functor Inc from the base 2-category K to the 2-category which sends each 0-cell X of K to the identity monad/comonad on the 0-cell X in K. By using the four 2-functors Inc, we can characterise these four notions.

• the Eilenberg-Moore constructions for monads/comonads,

• the Kleisli constructions for monads/comonads.

For example, a 2-category K admits Eilenberg-Moore constructions for monads if the 2-functor Inc : K —> Mnd(A") has a right 2-adjoint. Similarly, K admits Eilenberg-Moore constructions for comonads if Inc : K —> Cmd(A") has a right 2-adjoint.

The validity and the reason for this definition is because Cat admits Eilenberg-Moore constructions for both monads and comonads. The right

2-adjoint functor to each 2-functor Inc sends each monad/comonad to the category of Eilenberg-Moore algebras/coalgebras for the monad/comonad.

Dually, we say a 2-category K admits Kleisli constructions for monads if the 2-functor Inc : K —> Mnd*(A") has a left 2-adjoint. Similarly, K admits Kleisli constructions for comonads if the 2-functor Inc : K —>■ Cmd*(A") has a left 2-adjoint.

The validity and the reason for this definition is because Cat admits Kleisli constructions for both monads and comonads. The left 2-adjoints send each monad/comonad to its Kleisli category respectively.

For the above four 2-functors Inc, we call each image 0-cell in K under the right 2-adjoint functor an Eilenberg-Moore construction, the image 0-cell

under the left a Kleisli construction.

2.1.2 Liftings to Eilenberg-Moore/Kleisli constructions

Suppose a 2-category K admits Eilenberg-Moore constructions for monads, i.e., the 2-functor Inc : K —>■ Mnd(A") has a right 2-adjoint.

Given 0-cells T = ((7, T, 77), T' = (C, T', //, r]') in Mnd(A^), a 1-cell J : C —>■ C' lifts to a 1-cell J : T-Alg —T'-Alg on Eilenberg-Moore constructions if UT' J = JUT holds, where UT is the 1-cell part of the (C, T, /i, ?7)-component of the counit. When K = Cat, UT : T-Alg —> C is the forgetful functor from the category of Eilenberg-Moore algebras for a monad (T,/¿,77) to its base category C.

We can also define the notion of liftings for 2-cells. Suppose 1-cells J, H : C —>■ C' lift to J, H respectively on Eilenberg-Moore constructions. A 2-cell a : J =>■ H : C —> C' lifts to a 2-cell a \ J H on Eilenberg-Moore constructions if the equation UT'a = aUT holds.

The right 2-adjoint functor sends each 1-cell (J,j) in Mnd(A") to a 1-cell in K which is a lifting of J, and each 2-cell a : (J,j) (H} h) in Mnd(A") to a lifting of a : J H. Moreover this map on 1-cells and 2-cells is bijective, so it gives an equivalence between lifting 1-cells in K and the 1-cells in Mnd(A"), and lifting 2-cells in K and 2-cells in Mnd(A"). These results yield an adjunction between the construction and its base 0-cell in A", and yield adjoint liftings [8,10].

We can also apply these results to Eilenberg-Moore constructions for comon-ads, by reversing the argument, to Kleisli constructions. For detail please see [17,18].

2.1.3 Distributive laws of a monad and a comonad

Definition 2.2 Given a monad (T, /i, 77) and a comonad (_D, 8, e) on an object C of a 2-category A", a distributive law of T over D is a 2-cell A : TD DT such that the four elementary diagrams involving each of /i, 77, 8 and e commute.

This distributive law can be captured as a 0-cell in each of the 2-categories CmdMnd(A") = MndCmd(A^), Cmd*Mnd(A^) and Mnd*Cmd(A^).

2.2 Pointed endofunctors, co-pointed endofunctors

If we forget the multiplication and co-multiplication in the definition of monad and comonad, we can define the notion of a pointed/co-pointed endofunctor.

Definition 2.3 A pointed endofunctor in a 2-category K consists of a 0-cell C, a 1-cell T : C C, and a 2-cell 77 : Id =>■ T

Definition 2.4 A co-pointed endofunctor in a 2-category K consists of a 0-cell C, a 1-cell D : C C, and a 2-cell e : D => Id

We can also define 2-categories of pointed endofunctors and co-pointed endofunctors and dual 2-categories for each of them.

Definition 2.5 For any 2-category A", the following data forms a 2-category pEndo(A) of pointed endofunctors:

• A 0-cell (C, T, rj) is a pointed endofunctor in K.

• A 1-cell in pEndo(A) from (C, T, 77) to (C, T', 77') consists of a 1-cell H : C —> C together with a 2-cell h : T'H => HT in K satisfying h ■ Hr] = rj'H.

• A 2-cell in pEndo(A^) from (H,h) to (H',h') is a 2-cell a : H =>■ H' in K satisfying h' ■ T'a = aT ■ h.

We can also give another definition of a 2-category of pointed endofunctors by using the op-construction as follows:

Definition 2.6 pEndo*(K) = pEndo(/iop)op

For co-pointed endofunctors, we can also define 2-categories of co-pointed endofunctors by using co-constructions and op-constructions as follows:

Definition 2.7 We define copEndo(/i) = pEndo(/ico)co, and copEndo*(K) = copEndo (Kop)op.

Example 2.8 When K = Cat a pointed endofunctor consists of an endofunctor T : C —y C and a natural transformation rj : Id T, and a co-pointed endofunctor consists of an endofunctor D : C' —> C' and a natural transformation e : D =5- Id.

2.2.1 Eilenberg-Moore/Kleisli constructions

As in Section 2.1.1, we can define Eilenberg-Moore/Kleisli constructions for pointed endofunctors and co-pointed endofunctors.

For each of the above 2-categories pEndo(Ji'), pEndo*(/i'), copEndo(Ji') and cop En do* (A"), there is a 2-functor Inc from the base 2-category K to the 2-category which sends each 0-cell X of K to the identity pointed/co-pointed endofunctor on it. For each of pEndo(A") and cop En do (A"), the forgetful 2-functor U to K always has the 2-functor Inc as a left 2-adjoint.

Definition 2.9

• A 2-category K admits Eilenberg-Moore constructions for pointed endofunctors if the 2-functor Inc : K —> pEndo(A") has a right 2-adjoint.

• A 2-category K admits Eilenberg-Moore constructions for co-pointed endofunctors if the 2-functor Inc : K —> Cmd(A") has a right 2-adjoint.

Example 2.10 Cat admits Eilenberg-Moore constructions for pointed endofunctors. For the 2-functor Inc : Cat —> pEndo(Cat), the right 2-adjoint functor sends each pointed endofunctor (C, T, r/) to the category of (T, ?y)-algebras for the pointed endofunctor. Here the category (T, r/)-alg of (T, r/)-algebras for a pointed endofunctor (T, r/) on a category C is defined as follows:

• Each object is a T-algebra (A, k : TA —A) satisfying k o t/a = icU.

• Arrows are morphisms of T-algebras.

Similarly, Cat admits Eilenberg-Moore constructions for co-pointed endofunc-tors. The right 2-adjoint functor sends each co-pointed endofunctor (C, D, e) to the category (_D, e)-coalg of (_D, e)-coalebras for the co-pointed endofunctor. Here the category (_D, e)-coalg of (_D, e)-coalgebras for a co-pointed endofunctor (_D, e) on a category C is defined as follows:

• Each object is a D-coalgebra (A, k : A —>■ DA) satisfying ca ° k = id^.

• Arrows are morphisms of D-algebras.

Dually, for each of the pEndo*(A") and cop En do* (A"), the forgetful 2-functor U to K always has the 2-functor Inc as a right 2-adjoint.

Definition 2.11

• A 2-category K admits Kleisli constructions for pointed endofunctors if the 2-functor Inc : K —> pEndo*(A") has a left 2-adjoint.

• A 2-category K admits co-Kleisli constructions for co-pointed endofunctors if the 2-functor Inc : K —> cop En do* (A") has a left 2-adjoint.

The 2-category Cat admits both Kleisli/co-Kleisli constructions for pointed/co-pointed endofunctors. By using the left adjoint 2-functors we can characterise both Kleisli categories for pointed endofunctors and co-Kleisli category for co-pointed endofunctors.

Proposition 2.12 The Kleisli category (T, 77)-K1 for a pointed endofunctor (T, rj) is given as follows:

• Each object o/(T, 77)-K1 is the same as that of C.

• Let a}b be objects of (T, 77)-Kl. The homset from a to b is given by the quotient set (T, ?7)-Kl(a, b) = HnGNC(a, Tnb)/ ~a,&, where ~aj6 is the smallest equivalence relation on UnejqC(a}Tnb) generated by f ~aj6 r/T^b 0 f ~a,6 Tr]Tm-ib o f 6 • • • 6 Tm-1?76 o f for each f : a —> Tmb in C for m £ N.

We write the equivalence class of f by [f]. For arrows [f] : a —> b and [g\ : b —y c in (T, 77)-Kl, represented by arrows f : a —> Tmb and g : b —> Tnc in C for some m,n G we define the composition [g][f] in (T}r])-Kl by the equivalence class of the arrow (Tmg)of : a —> Tm+nc in C. The identity arrow on a seen as an object o/(T, 77)-Kl is the equivalence class of the identity arrow ida in the category C.

Proof. See Appendix 2. □

Remark 2.13 The characterisation of a co-Kleisli category for a co-pointed endofunctor is given by reversing the arrows in the above Proposition.

2.2.2 Liftings

Suppose K admits Eilenberg-Moore constructions for pointed endofunctors. For each pointed endofunctor (C, T, r/) in A", we call the image, (T, r/)-alg under the right 2-adjoint functor the Eilenberg-Moore construction for the pointed endofunctor.

Definition 2.14 Let (C, T, rj) and (C, T', r/') be 0-cells in pEndo(A^). A 1-cell J : C —y C' in K lifts to a 1-cell J on Eilenberg-Moore constructions if the following diagram commutes in K.

(T,r})-alg -Î* (T',r}')-alg

lj(T,v)

lj(T',v')

C—j—C,

where U^T'n'> is the 1-cell part of the (T, /^-component of the counit.

Example 2.15 When K = Cat, each U^ : (T,rj)-alg C is the forgetful functor.

Definition 2.16 Suppose both 1-cells J, H : C —> C lift to J, H respectively on Eilenberg-Moore constructions. A 2-cell a: : J H lifts to a 2-cell a : ,J H on Eilenberg-Moore constructions if the equation ,7] holds.

Proposition 2.17 The right 2-adjoint functor from pEndo(Ji') to K sends each 1-cell (J,j) : (C}T}rj) —> (C, T", 77') to the lifting of J, and each 2-cell a : (J,j) (H,h) to a lifting of a : J H.

Outline of Proof. These results follows from the 2-naturality of the counit for 1-cells and 2-cells. □

Remark 2.18 The above results are the same as the results obtained in the case of Mnd(A") and Cmd(A") in Section 2.1.2 (or see [18]). Although every

1-cell in pEndo(A") determines a lifting 1-cell if Eilenberg-Moore constructions exist, the converse does not hold. This is in contrast to the situation for monads, and the reason is that we can not use the argument of adjoint lifting because, in general, there is no

left adjoint to the 1-cell : (T, rj)-alg C

Hence we conclude

Corollary 2.19 If K admits Eilenberg-Moore constructions for pointed endofunctors, then every 1-cell in pEndo(A") determines a lifting 1-cell. Every

2-cell in pEndo(A") determines a lifting 2-cell.

Remark 2.20 Similarly we can define the notion of lifting to Eilenberg-Moore constructions for co-pointed endofunctors, and we can define the notion of lifting to Kleisli constructions using pEndo*(A") and cop En do* (A").

2.3 Endofunctors

Forgetting the unit and the counit of the definitions of pointed endofunctor and co-pointed endofunctor, we have just endofunctors. We can also provide a 2-categorical framework here.

Definition 2.21 For any 2-category A", the following data forms a 2-category Endo(A") of endofunctors in K:

• Each 0-cell (C, T) consists of a 0-cell C and a 1-cell T : C —> C in K.

• A 1-cell from (C, T) to (C, T') consists of a 1-cell J : C C' together with a 2-cell j : T'J =>• JT in K.

• A 2-cell from (J,j) to (J\jr) is a 2-cell a : J J' in K subject to aT ■ j = f ■ T'a.

We can also define another 2-category of endofunctors in K by using the op-construction as follows:

Definition 2.22 Endo*(A^) = Endo(A^op)op.

Proposition 2.23

• Endo(A"co)co = Endo*(A");

• Hence Endo(A"co op)co op = Endo(A^).

If, in Proposition 2.23, we replaced Endo(A") by Mnd(A"), the result would not hold. This, along with the existence or otherwise of liftings and adjoints (see Remarks 2.18, 2.24, 2.31), is a fundamental difference in the treatment of monads and endofunctors: for monads, we have Mnd(A"co)co = Cmd(A"). The reason for the difference is that, in the precise sense in which monads are dual to comonads, the concept of endofunctor is self-dual.

2.3.1 Eilenberg-Moore/Kleisli constructions

Again as in Section 2.1.1, we can define Eilenberg-Moore/Kleisli constructions for endofunctors.

For each of the above 2-categories En do (A") and En do* (A"), there is a 2-functor Inc from the base 2-category K to the 2-category which sends each 0-cell X of K to the identity endofunctor on the 0-cell X in K. But this time, we have

Remark 2.24 For each of Endo(A") and Endo*(A"), the forgetful 2-functor U to K does not have the 2-functor Inc as a left or right 2-adjoint.

In consideration of Proposition 2.23, we define:

Definition 2.25

• A 2-category K admits Eilenberg-Moore constructions for endofunctors if the 2-functor Inc : K —En do (A") has a right 2-adjoint.

• K admits Eilenberg-Moore constructions for co-endofunctors if the 2-functor Inc : K —> En do* (A") has a right 2-adjoint.

Example 2.26 When K = Cat, K admits Eilenberg-Moore constructions for endofunctors. For the 2-functor Inc : Cat —Endo(Cat), the right 2-adjoint functor sends each pointed endofunctor (C, T) to the category T-alg of T-algebras for the endofunctor T : C —>■ C.

Similarly, Cat admits Eilenberg-Moore constructions for co-endofunctors. The right 2-adjoint functor sends each endofunctor (C, D) to the category D-coalg of D-coalebras for the endofunctor D : C —> C.

For the constructions corresponding to Kleisli ones, we define:

Definition 2.27

• A 2-category K admits Kleisli constructions for endofunctors if the 2-functor Inc : K —En do* (A") has a left 2-adjoint.

• K admits co-Kleisli constructions for endofunctors if the 2-functor Inc : K —> Endo(A") has a left 2-adjoint.

The 2-category of all small categories Cat admits Kleisli constructions for endofunctors, and also admits co-Kleisli constructions for endofunctors. We can characterise the Kleisli category for a endofunctor in Cat.

Proposition 2.28 The Kleisli category T-K1 for an endofunctor T : C —C is characterised as follows:

• Objects ofT-K1 are the same as those of C.

• Let a}b be objects ofT- Kl. A homset from a to b is given by the disjoint union T-Kl(a,6) = UnejqC(a}Tnb).

For arrows f : a —> b and g : b —> c in T-K1; i.e., arrows f : a —> Tmb and g : b —> Tnc in C for some to, n £ we define the composition gf in T - Kl by the arrow (Tmg) o f in C. The identity arrow on a seen as an object ofT- Kl is the identity arrow ida in the category C.

Outline of Proof. The proof is similar to Proposition 2.12. □

Remark 2.29 By reversing the arrows in the above Proposition, we can characterise the co-Kleisli category T-coKl for an endofunctor T on C.

2.3.2 Liftings

We can define the notions of lifting to these constructions as in Section 2.2.2. So we omit the definition.

• Eilenberg-Moore constructions for endofunctors,

• Eilenberg-Moore constructions for co-endofunctors,

• Kleisli constructions for endofunctors,

• co-Kleisli constructions for endofunctors.

The point is the following which is similar to the Proposition 2.17.

Proposition 2.30 Every right or left 2-adjoint functor to Inc corresponding to each of the above constructions sends each 1 -cell to a 1 -cell in K that is a lifting for the construction, and each 2-cell to a lifting 2-cell.

Remark 2.31 We remark that the correspondence is not bijective as in the pointed/co-pointed case (Remark 2.18). Although every 1-cell in each 2-category determines a lifting 1-cell if each of the above constructions exist, the converse does not hold. This is in contrast to the situation for monads, and the reason is that we can not use the argument of adjoint lifting.

Hence we conclude

Corollary 2.32 If K admits Eilenberg-Moore constructions for endofunctors, then every 1-cell in Endo(A") determines a lifting 1-cell. Every 2-cell in Endo(A") determines a lifting 2-cell.

2-4 Summary of the 2-categorical framework

Given a 2-category K, we have defined 2-categories Mnd(A"), Mnd*(A"), Cmd(A"), Cmd*(A"), pEndo(A), pEndo*(A"), copEndo(A), copEndo*(A"), Endo(A") and Endo*(A"). Modulo size, these constructions can themselves be made 2-functorial, yielding 2-functors Mnd, Mnd*, Cmd, Cmd*, pEndo, pEndo*, copEndo, copEndo*, Endo and Endo* on 2-Cat.

For each of the 2-categories, we have a 2-functor Inc from K to it, which sends each 0-cell X in K to the identity on it. The existence of Eilenberg-Moore constructions is characterized by right 2-adjoints to Inc.

Mnd(A"), Cmd(A"), pEndo(A), copEndo(A), Endo(A"), Endo* (A")

Suppose the existence of a right 2-adjoint to Inc. The right 2-adjoint sends each 1-cell to a 1-cell in K and a 2-cell to one in A", which are liftings to the Eilenberg-Moore constructions.

We remark that for Mnd(A") and Cmd(A") this correspondence is bijective. Hence a lifting 1-cell or 2-cell to Eilenberg-Moore constructions is equivalent to a 1-cell or 2-cell.

The existence of Kleisli constructions is characterized by left 2-adjoints to

Mnd* (A"), Cmd *(K), pEndo*(A"), copEndo*(A"), Endo *(K), Endo(A^)

Suppose the existence of a left 2-adjoint to Inc. The left 2-adjoint sends each 1-cell to a 1-cell in K and a 2-cell to one in A", which are liftings to the Kleisli constructions.

We remark that for Mnd* (A) and Cmd*(A") this correspondence is bijec-tive. Hence a lifting 1-cell or 2-cell to Kleisli constructions is equivalent to a 1-cell or 2-cell.

3 Distributive laws

Sometimes, the distributive law of a monad and a comonad as in Section 2.1.3 is too demanding, so we require fewer commutativities. We can weaken the condition of the distributive law of a monad and a comonad by replacing a monad by a pointed endofunctor or an endofunctor, and a comonad by a co-pointed endofunctor or an endofunctor. These variations of distributive laws are captured as 0-cells in 2-categories given by combining one of six 2-functors

Mnd, Mnd*, pEndo, pEndo*, Endo and Endo*

with one of six 2-functors

Cmd, Cmd*, copEndo, copEndo*, Endo* and Endo,

like MndCmd(A), in our 2-categorical framework. Also the notions of Eilenberg-Moore constructions and Kleisli constructions help the analysis of distributive laws and relationships to liftings. Especially, Cat admits all Eilenberg-Moore constructions and Kleisli constructions, so the liftings always exist.

We explain by giving an analysis of a distributive law. The analysis of the other distributive laws is routine.

Here, let us consider a distributive law of a monad over a co-pointed endofunctor.

Definition 3.1 A distributive law of a monad (T,/¿,77) over a co-pointed endofunctor (_D, e) is a 2-cell A : TD =>■ DT such that the three elementary diagrams involving each of /i, 77 and e commute.

The distributivity of a monad over a co-pointed endofunctor can be captured as a 0-cell in each of the 2-categories Mnd(copEndo(A")), copEndo(Mnd(A")),

copEndo*(Mnd(/i)) and Mnd*(copEndo(/i)).

We analyse the 2-category Mnd(copEndo(A")) as a representative example.

3.1 Mnd(copEndo(/i))

First, we can re-express the definition as follows:

Proposition 3.2 For any 2-category K, Mnd(copEndo(A")) is isomorphic to

the following:

• A 0-cell consists of a 0-cell C of K, a monad (T,/¿,77) on it, a co-pointed endofunctor (D, e) on it, and a distributive law A : TD =>■ DT of the monad over the co-pointed endofunctor.

• A 1 -cell (J,jujd) ■ (C,T,D, A) (C',T',D', A') consists of a 1 -cell J : C —y C' in K together with a 2-cell jt : T'J JT subject to the monad laws, together with a 2-cell in K of the form jd : JD =5- D'J subject to the law of co-pointed endofunctor, all subject to one coherence condition given by a hexagon

JTD-► JDT

• A 2-cell from (J,jt,jd) t° (H,ht,hd) consists of a 2-cell from J to H in K subject to two conditions expressing coherence with respect to jt and ht and coherence with respect to jd and hd-

Lemma 3.3 For any 2-category K, copEndo(Mnd(/i')) is isomorphic to Mnd(copEndo (K)).

Now suppose a 2-category K admits Eilenberg-Moore constructions for both monads and co-pointed endofunctors, i.e., we have right 2-adjoint functors to both Inc 2-functors to Mnd(A") and copEndo(A"). Since both copEndo and Mnd are 2-endofunctors on 2-Cat, they send adjunctions to adjunctions, so both copEndo(Znc) : copEndo(A") —y copEndo(Mnd(A")) and Mnd(/nc) : Mnd(A") —y Mnd(copEndo(A")) have right 2-adjoint 2-functors.

For given a distributive law A : TD DT of a monad (T, /i, 77) over a co-pointed endofunctor (D,e) on object C, it is a 0-cell of both copEndo(Mnd(A"))

and Mnd(copEndo(A")). Consider the images under the right 2-adjoint functors to copEndo(Znc) : copEndo(A) —> copEndo(Mnd(A")) and Mnd(/nc) : Mnd(A^) Mnd(copEndo(/i)).

The right 2-adjoint functor to copEndo(Znc) sends the distributive law A to a co-pointed endofunctor (T-Alg, D, e) in A", where T-Alg is an Eilenberg-Moore construction for the monad (C, T,/¿,77), D is a 1-cell which is a lifting of D, and e is a 1-cell which is a liftings of e to Eilenberg-Moore constructions for monads.

Note that as this right 2-adjoint functor is basically given by the right 2-adjoint to Inc : K —Mnd(A"), we can retrieve the information of the distributive law A from the co-pointed endofunctor (T-Alg, D, e) which consists of liftings to Eilenberg-Moore constructions for monads.

The right 2-adjoint functor to Mnd(/nc) sends the distributive law A to a monad ((D}e)-coalg}T} ji,f)) in A", where (D, e)-coalg is an Eilenberg-Moore construction for the co-pointed endofunctor (C, D, e), T is a 1-cell which is a lifting of T, and ft and 77 are 2-cells that are liftings of ¡i and 77 respectively to Eilenberg-Moore constructions for co-pointed endofunctors. Hence we conclude

Proposition 3.4 If K admits Eilenberg-Moore constructions for monads and co-pointed endofunctors, then conditions (i) and (ii) are equivalent, and (i) determines (Hi).

(i) A distributive law X of a monad (T,/¿,77) over a co-pointed endofunctor

(D,e),

(ii) the lifting of a co-pointed endofunctor (_D, e) to T-Alg the Eilenberg-Moore construction for a monad (T,//,77),

(Hi) the lifting of a monad (T, //,77) to (D,e)-coalg the Eilenberg-Moore construction for a co-pointed endofunctor (_D,e).

4 Free pointed endofunctors and cofree co-pointed endofunctors

The following observation [9] is simple and almost trivial, but it is important.

Proposition 4.1 Let C be a category with binary sums, and H be an endofunctor on it. Then the pair (H + Id, inr) consisting of the endofunctor iT + Id and the inclusion inr : Id =>- iT + Id is the free pointed endofunctor on H [9], in the sense that for any pointed endofunctor (T, 77) on C, composition with the inclusion in 1 : H H Id gives a bijection between the collection of natural transformations a : H + Id T satisfying a ■ inr = r], and the set of natural transformations Nat(i7, T).

Moreover the isomorphism (H + Id,inr)-a/g = H-alg holds.

Proof. Let (T, 77) be a pointed endofunctor on category C. Since the category

C has binary sums, for each natural transformation a : H + Id =>■ T there is a pair of natural transformation a\ : H =>■ T and a2 : Id =>■ T such that a = [«1, a2]. If a satisfies a ■ inr = 77, we have a2 = rj. Hence giving a natural transformation a : H + Id =>■ T satisfying a ■ inr = rj is equivalent to giving a natural transformation a\ : H =>■ T. Since a ■ in; = a 1 holds, it is easy to see the composition with in; gives the above bijection.

A (i7 + Id, inr)-algebra is a pair (X, k : HX + X —X) such that ko'mrX = idx, so the structure morphism k : HX-\-X —X consists of an identity arrow on X and an arrow k : HX —X in C. And every morphism of (i7+Id, inr)-alg from (X, [k,idx] : HX + X X) to (Y, [I, idy] : HY + Y Y) consists of an arrow / : X —> Y such that [/,idy] o Hf + / = / 0 [£;,idx], equivalently I o Hf = f o k. Hence the isomorphism (H + Id, inr)-alg = H-alg holds. □

By using the dual argument, we have the following result.

Proposition 4.2 Let C be a category with binary products, and let H be an endofunctor on it. Then the pair (H X Id, prr) consisting of the endofunctor Fx Id and the projection prr : H X Id Id is a cofree co-pointed endofunctor on H, in the sense that for any co-pointed endofunctor (D, e) on C, composition with pr; : H X Id H gives a bijection between the collection of natural transformations a : D H x Id satisfying prr • a = t, and the set of natural transformations Nat(Z), H).

Moreover the isomorphism (H X Id, prr)-coalg = H-coalg holds.

5 Application 1: Distributivity in Turi and Plotkin's work

5.1 Review

We first review the work of Turi and Plotkin [22]. Given a cartesian category C, a signature endofunctor E and a behaviour endofunctor B on C, with E freely generating the syntax monad (T,/¿,77), and given image finite GSOS (Generalized Structural Operational Rule), they showed, using the functorial-ity of GSOS, that each GSOS rule can be modelled by an abstract operational rule, which is a natural transformation p : E(_B X Id) BT. Next, each abstract operational rule p : E(_B X Id) BT determines a distributive law A : TD DT of the monad T over a comonad D, where the comonad D is cofreely generated by the behaviour functor B (assuming C and B have structure giving the existence of such D). The category A-Bialg of A-bialgebras provides combined operational and denotational models. They gave an analysis of those models. For details, see [22].

Their derivation of a distributive law from an abstract operational rule is given as follows:

(i) Given an abstract operational rule p : E(£? X Id) BT, first they show that the monad (T,/¿,77) on C lifts to the category B-coalg of B-

coalgebras by using structural recursion ([22] Theorem 5.1).

(ii) Since the category B-coalg is isomorphic to D-Coalg, the category of Eilenberg-Moore coalgebras for the comonad (_D, e) cofreely generated by B, the monad (T,/¿,77) lifts to the category D-Coalg.

(iii) By using an adjoint lifting theorem (see [8,19,17,18]), a lifting of the monad T to D-Coalg is equivalent to a distributive law A : TD =>■ DT of T over D.

The first step above is intricate because of the use of a structural recursion theorem. So we shall give a different proof.

5.2 Feedback from our framework

Now we use our framework to analyse the above. The fundamental observation is that an abstract operational rule can be seen as a distributive law of a monad over a co-pointed endofunctor. This allows a more general argument avoiding the special recursion theorem.

Proposition 5.1 The co-pointed endofunctor (B X Id, pr2) is the cofree co-pointed endofunctor of the endofunctor B.

Outline of Proof. This follows from Proposition 4.2. □

Let (H} e) be a co-pointed endofunctor on a category C. We say a natural transformation p : YjH =>■ HT respects the structure of the co-pointed endofunctor (H} e) if the following diagram commutes:

where 9 : E =>■ T is the unit exhibiting T as the free monad on the endofunctor E.

Proposition 5.2 To give an abstract operational rule p : E(_E? X Id) =>■ BT is equivalent to giving a natural transformation g : E(_E? X Id) =4* (B X Id)T which respects the structure of the co-pointed endofunctor (B X Id, pr2).

Proof. For each natural transformation g : E(_E? X Id) =>■ (B X Id)T that respects the structure of (B X Id, pr2), the second component must be

E(B x Id) Spf2 . E---» T.

So giving an natural transformation g : E(_E? X Id) =4- (B X Id)T that respects the structure of (B X Id, pr2) is equivalent to giving the first component S(Bx Id) =4- BT, i.e., an abstract operational rule. □

Let (H, e) be a co-pointed endofunctor on C.

Proposition 5.3 Each natural transformation g : YjH =4- HT respecting the structure of(H,e) determines a distributive law of the free monad T on E over (H,e).

Proof. We first show that the endofunctor H lifts to an endofunctor H on the category E-alg, and the natural transformation e : H =4- Id lifts to t : H =4- Id.

Define the action of H : Yi-alg —Yi-alg as follows: A E-algebra k : EX —> X is sent to Hk" o gx, where : TX —Y X is the corresponding Eilenberg-Moore algebra for the monad (T, /i, r/) under the isomorphism Yi-alg = T-Alg. An arrow / of E-algebras from k : EX —> X to I : EY" —Y, i.e., an arrow / : X Y in C satisfying / o k = I o E/, is sent to Hf : HX HY. Then the functor H : Yi-alg —> Yi-alg is a lifting of H.

Next, for each E-algebra k : EX —> X, we show that the X component £x : HX —y X of e gives a morphism of E-algebras from Hk to k, i.e., ExHk = kYj&x'- since the natural transformation g respects the structure of (H, e), each part of the following diagram commutes:

gx Hkl E HX * • HTX-► HX

EX-► TX---► X

Since the bottom arrow of above diagram is o Ox = k and the top arrow is Hk, the arrow ex : HX —y X is a morphism of E-algebras from Hk to k.

We give e : H Id by defining k : EX —> X component to be ex- That this is natural follows from naturality of e.

It is easy to see that ê is a lifting of e to E-algebras.

Because Yi-alg is isomorphic to T-Alg, both the functor H and the natural transformation t : H =5- Id are liftings of H and e to T-Alg.

By using Proposition 3.4, this condition is equivalent to a distributive law of a monad (T,fj,,r¡) over a co-pointed endofunctor (H,e). This concludes the proof of Proposition 5.3. □

¿From Propositions 5.2 and 5.3, we conclude that

Theorem 5.4 Each abstract operational rule p : E(_BxId) BT determines a distributive law A : T(B X Id) =4* (B X Id)T of the monad (T,p,r¡) over the co-pointed endofunctor (B X Id, pr2).

5.2.1 A deduction of Turi and Plotkin's distributive laws We apply the previous observations to the implication of distributivity in Turi and Plotkin's work, and modify the procedure. The procedure 1 in Section 5.1 can replaced as follows:

(a) Any abstract operational rule p : E(£? X Id) =>■ BT determines a distributive law A : T(B X Id) =4* (B X Id)T of the monad (T, /i, r/) over the co-pointed endofunctor (B X Id, pr2) by Theorem 5.4.

(b) Since the 2-category Cat admits Eilenberg-Moore constructions for co-pointed endofunctors, we can lift the monad (T, /i, r/) to (B X Id, pr2)-coalg the category of coalgebras for the co-pointed endofunctor by Proposition 3.4.

(c) Since the co-pointed endofunctor (B X Id,pr2) is cofreely generated by the endofunctor B (Proposition 5.1) and (B X Id,pr2)-coalg = B-coalg, this means the monad (T,/i,??) lifts to the the category B-coalg. This is the lifting monad obtained by Turi and Plotkin.

Hence we can obtain the same distributive law of a monad over a comonad, but in a more structured manner not using a recursion theorem.

6 Application 2: Generalized coiteration and coalge-braic coinduction "up-to"

In this section, we illustrate how the categorical pattern of a pointed endofunctor (T, rj) that distributes over an endofunctor F arises in the context of the coalgebraic approach to coinduction.

The gist of the coalgebraic approach to coinduction is that, under suitable conditions, equivalences induced by coiterative morphisms can be characterized as greatest coalgebraic F-bisimulations ([1,2,20]). The problem addressed in [13] and in this section, is that of extending this paradigm to generalized coiterative morphisms, thus providing coalgebraic coinduction principles for reasoning on them.

Generalized coiterative morphisms arise from the generalized coiteration scheme, which we call (T, ^-coiteration, where (T, r/) is a pointed endofunctor. This scheme subsumes the standard coiteration scheme, and the corecursion scheme (see e.g. [5]), which in turn is dual to the scheme of primitive recursion. Standard coiteration is recovered by taking T to be the identity functor.

In [13], the notion of F-bisimulation "up-to-T", for T a monad, appeared generalising Aczel's original notion of T-bisimulation. The notion of T-bisimu-lation "up-to-T" can be viewed as the coalgebraic counterpart/generalization of the set-theoretic notion of bisimulation "up-to" due to Milner [14] (see [13] for more details). If the pointed endofunctor underlying the monad T distributes over F, then the equivalence induced by standard coiterative morphisms from T-coalgebras of the shape (TX, a : X —> FTX) can be charac-

terized as the greatest T-bisimulation "up-to-T", thus providing a sound and complete principle of coalgebraic coinduction "up-to-T".

This result may be used to prove the soundness of a coinduction principle, in terms of T-bisimulations "up-to-T", for reasoning on the equivalence induced by a (T, ?y)-coiterative morphism, when (T, r/) is the pointed endo-functor underlying the monad (T, This substantiates the claim of the

connection between generalized coiteration schemata and bisimulations "up-to".

In this section, we provide a range of concrete examples of (T, ?y)-coiterative morphisms and associated coinduction principles, including corecursive mor-phisms on streams, linear time semantics, and coiterative morphisms "up-to-context", thus emphasizing the pervasiveness of the abstract pattern of a distributive law described in Section 3.

Throughout this section, let C be a category, F : C —> C an endofunctor, and (T, i]) a pointed endofunctor on C.

6.1 (T,rj)-coiteration

We start by recalling the definition of standard coiteration and corecursion schemata:

Definition 6.1 [Coiteration] Let F have final T-coalgebra (vF, o,vf), and let (X, ax ) be an T-coalgebra. The coiterative morphism determined by the F-coalgebra (X, ax) is the unique T-coalgebra morphism / from (X, ax) to (isF, avF), i.e. the unique morphism / : X —> uF in C making the following diagram commute:

Definition 6.2 [Corecursion] Let C be a category with coproducts, let F have final T-coalgebra (vF, olvf)i and let (X + vF, [ai,T(in2) o avp]) be an T-coalgebra, where in2 : uF —> X + uF is the canonical sum injection. The corecursive morphism determined by the T-coalgebra (X + vF, [ai,T(in2) o avF]) is defined by / oim, where / is the coiterative morphism determined by

the T-coalgebra (X + vF, [ai} T(in2) o avF}). I.e.:

X + vF

[ai, T(in2) o auF]

F(X + uF)

Definition 6.3 [(T, ?/)-coiteratiorL, [13]] Let F : C —> C have final coalgebra (vF, auF)} and let (TX, a) be an F-coalgebra. We define the (T, rj)-coiterative morphism h : X —> uF as / o rjx, where / : TX —y uF is the coiterative morphism induced by the F-coalgebra (TX,a). I.e.:

FTX-► F(uF)

Ff K '

The (T, ?7)-coiteration subsumes both standard coiteration, by taking T to be the identity functor, and corecursion, by taking T to be the pointed endofunctor underlying the corecursion monad Tp defined as follows:

Definition 6.4 [Corecursion monad] Let C be a category with coproducts, and let F : C —V C have final coalgebra (uF, avF). Let (Tp,/i,rj) be the monad defined by:

T+X = X + uF ,

V/ : X —y Y morphism in C. Tp f = [ini o /, in2] ;

• i]x = mt : X X + vF]

• fix = [id, in2] : (X + vF) + vF X + uF, where ini, in2 are the canonical sum injections.

6.2 F-bisimulations "up-to-T" and coalgebraic coinduction "up-to-T"

We introduce the notion of F-bisimulation "up-to-T", for T = (T,//,77), and we use this notion to prove soundness and completeness of a principle of coalgebraic coinduction "up-to-T" for establishing equivalences induced by

coiterative morphisms. The principle of coalgebraic coinduction "up-to" is the counterpart of a suitable set-theoretical generalization of Milner's principle of bisimulation "up-to". This is discussed in [13]. In Section 6.3, we show that coalgebraic coinduction "up-to-T" is related to the (T, ?y)-coiteration scheme introduced above, in the sense that it can be used to derive a proof principle for establishing equivalences induced by (T, ?y)-coiterative morphisms, where (T, i]) is the pointed endofunctor underlying the monad T.

We start by introducing the notion of T-bisimulation "up-to-T". We stress the fact that we assume T to be a monad, and not just a pointed endofunctor.

Definition 6.5 [T-bisimulation "up-to-T", [13]]

Let F ; C —y C, let (T, /i, r/) be a monad on C, and let (TX, a) and (TY, f3) be T-coalgebras. An F-bisimulation "up-to-T" on the T-coalgebras (TX,a) and (TY,/3) is a span (TZ, ri,r2) on TX and TY, such that there exists an arrow of C, 7 :TZ—> FT (TZ), making the following diagram commute:

r i r2 TX ----TZ--—* TY

FT (TV)

where r\, r\ are the unique extensions of ri, r2 given by the universality property of rj in the adjunction between the Eilenberg-Moore category of T-algebras and the category C, i.e. r\ o r]jz = r4-.

Aczel's original notion of T-bisimulation ([2]) is recovered by taking T to be the identity monad, and by considering the set-theoretical relation underlying the span, i.e. {(x,y) £ X x Y \ 3u £7Z . (ri,r2)(u) = (x,y)}.

The following technical Theorem 6.6 is the core of this section. It allows to prove the soundness and completeness of a principle of Coinduction "up-to-T" (Principle 6.7 below).

Theorem 6.6 Let C be a cocomplete category, let F : C —> C, let (T,fj,,rj) be a monad over C. Lf

1) the pointed endofunctor (T, r/) distributes over F,

2) ((TZ, 7), ri, r2) is an F-bisimulation "up-to-T" on F-coalgebras (TX,a) and (TY, (3) ==?■ ((T(TZ), A o T7), r\, r\) is an F-bisimulation "up-to-T" on F-coalgebras (TX,a) and (TY,/3) ,

i) Lf ((TZ, 7), ri, r2) is an F-bisimulation on (TX,a) and (TY,f3), then ((TZ iF(r]-ji) 07),n,r2) is an F-bisimulation "up-to-T" on (TX,a) and (TY,f3).

ii) For all (TZ, ri,r2) F-bisimulation "up-to-T" on (TX,a) and (TY,f3), there exists (7Z,r\,r2) F-bisimulation on (TX,a) and (TY,/3) such that TZ< TZ.

Proof. The proof of item i) is immediate. In order to prove item ii), let R : u —y C be a diagram given by R(n) = TnR and R(n —> n + 1) = t/t^r for each n £ u. Let a : R —colimi? be the colimiting cocone. Define R = colimi?.

Given 7 : R —FTR} we first define arrows 7„ : TnR —> FTn+1R for n > 0 inductively as follows: 7o = 7 : R FTi?, 7« = o r(7n_i) for each n > 1.

Next, we define a collection of arrows vn = F<rn+i o 7^ for each n. Then v becomes a cocone of R because the following equation holds for each n.

un+1 o R(n n + 1) = (F(an+2) o A^+i^ o T7„) o rjTnR = F(crn+2) o Axn+i^ o i7FTn+i(J?) o

= F(crn+2) ° F(r/Tn+i(_R)) ° 7« by distributivity

= F(crn+i) o =

Let 7 : colimi? —Fcolimi? be the unique morphism from the colimiting cocone a to the cocone v : R —Fcolimi?.

The construction of the arrow r\ : colimi? —TX from ri : R —TX is as follows. Let r : R —TX be the cocone over R given inductively by T0 = rx : R ^ TX and rn = : TnR TX for each n > 1. We define the arrow ri : colimi? —TX to be the unique morphism from the limiting cocone of R.

The construction of r2 : colimi? —TY from r2 : R —>■ TY is the same. Then the condition 1Z< 1Z follows immediately by construction.

Finally, we are in a position to prove that the following diagram commutes:

TX --colimi?

FTX -—— Fcolimi? Ft\

We have two cocones to the object FTX over the diagram R whose n-components are given by aofi oan and Fr\ o^oan. If we show they are equal, then the universality of the colimiting cocone, the above diagram commutes.

Since ri is the universal arrow from the cocone r to the colimiting cocone, we have a o f[ o an = a o rn.

For the second cocone, we have Fr\o^ o crn = Ffiojyn = Ffi o Fcrn+i = Frn+1 o 7„.

So, in order to show the commutativity, we have to check that, a o rn =

Frn+1 o holds for each n > 0. This follows immediately by induction on n, from the definitions of 7„, Tn and by hypothesis 2). Hence we have the commutatiity of the above diagram.

The same holds for r2. □

Specializing Theorem 6.6 to endofunctors on the category Set, for simplicity, we obtain an alternative characterization of the greatest T-bisimulation a) on ^-coalgebra (TX,a), which yields the following:

Principle 6.7 (Coalgebraic Coinduction "up-to-T") Let F : Set —> Set

and let T be a monad over Set satisfying the hypothesis 1,2 of endofunctor distributes over F. Lf moreover F preserves weak pullbacks and has a final coalgebra, then the following principle is sound and complete

(1Z, ri, r2) F-bisimulation "up-to-T" on (TX,a) x1Zy

X ~(TX,a) y

where a) denotes the greatest F-bisimulation on the coalgebra (TX,a),

and, by abuse of notation, x 7Z y denotes the fact that the pair (x,y) belongs to the set-theoretical relation underlying the span {JZ, ri,r2), i.e. (x,y) £ {{x,y) £ TX x TX I 3u en . (ri,r2)(u) = (x,y)}.

6.3 Reasoning on equivalences of T-coiterative morphisms

In this section, the principle of Coalgebraic Coinduction "up-to-T" is put to use for reasoning on equivalences induced by (T, ?y)-coiterative morphisms, for (T, rj) the pointed endofunctor underlying the monad T.

First, we need to recall the notions of image and inverse image of spans. Set-theoretically, these are to be intended as the (inverse) image of the sub-object of Xi X X2 determined by the relation underlying a span on X1?X2. See [4] for more details.

Definition 6.8 [(inverse) Image of spans] Let C be a category with products and pullpacks.

• The image of a span {JZ, ri,r2) on X1?X2 by (/i : X\ —> f2 : X2 —> Y2), denoted by {fi, f2)+{TZ,r\,r2), is the span (TZ, fx o r\,f2 o r2) on YUY2.

• The inverse image of a span {JZ, ri,r2) on X1?X2 by (/i : Yl —> X\,/2 : Y2 —)■ X2), denoted by (/i, f2)~l(TZ, rt, r2), is the span (V, p2] 7Ti, p2] 7r2) on Y1?Y2, where (V,pi,p2) is the pullback of (ri,r2) : 7Z —>■ X\ X X2 and (/i ° 7Ti, /2 o tt2) : Fi x y2 X\ x X2.

If (7Z, ri,r2) is a span on X and / : X —> Y, g : Y —> X, we simply denote by f+(TZ,r1?r2) the image of (TZ,r1?r2) by (/,/), and we denote by g~1(7Z, ri, r2) the inverse image of {JZ, ri, r2) by (g,g).

Using the principle of Coalgebraic Coinduction "up-to-T", we can prove the following theorem

Theorem 6.9 (Coalgebraic Coinduction for T-coiterative Functions)

Let F : Set —> Set and let (T,/¿,77) be a monad on Set such that the pointed endofunctor (T, 77) distributes over F. Let h be the T-coiterative morphism induced by the F-coalgebra (TX,a), i.e. h = / o r/x, where f : TX —> uF is the coiterative morphism determined by (TX} a). Then the following principle is sound

xlZy rix(7Z, ri, ^2) F-bisimulation "up-to-T" on (TX,a)

x ~h,y '

where denotes the equivalence induced by the T-coiterative morphism h. Proof. One can easily check, using Principle 6.7, that

r)x(7Z, ri, r2) T-bisimulation "up-to-T" on (TX,a) =>■ (i?, ri,r2) < ?7^1(~/, 7Ti, 7r2) ,

where ~j denotes the equivalence induced by the coiterative morphism /. □

6.4 Examples

We discuss some concrete examples of generalized coiteration and we derive the corresponding coinduction principles "up-to".

6-4-1 Corecursion on streams

Let Fs : Set —> Set be the functor defined as follows:

FS(X) = N x X ,

V/ : X —y Y morphism in Set. Fs(f) = idjv X / ,

where N denotes the set of natural numbers.

We recall that the final Ts-coalgebra is the set Sn of all (infinite) streams on natural numbers.

A simple example of a corecursive function from streams to streams which cannot be captured by the standard coiteration scheme is the following.

Definition 6.10 Let h0 : Sn —> Sn be the function which, given a stream of natural numbers s, yields the stream obtained by replacing the first element of s by the constant 0, i.e., for all streams (n,s),

h0(n,5) = (0,5) .

One can easily check that

Proposition 6.11 i) The function h0 is not coiterative, in the sense that there is no way of endowing Sn with a structure of Fs-coalgebra a : Sn —> Fs(Sn) so that ho is the coiterative morphism determined by (S'jv,«). ii) The function h0 is the corecursive function determined by the Fs-coalgebra

(Sn + Fs(in2)]), where a\ : Sn ~У N X (Sn + Sn) is defined by

ai(n,s) = (0,m2(s)); i.e. h0 = f0 о where:

c inl С I с с

J]\1 -*- J]\1 J]\1 -*- J]\1

[«1, Fs(in2) О as

F(SN + SN)--prr* F(SN)

The essence of the corecursion scheme is that we can make a choice between the two possibilities offered by the two branches of the disjoint sum in the F-coalgebra. Notice how this is exploited in the definition of the Fs-coalgebra in Proposition 6.11 above.

Now we come to discussing the principle of coalgebraic coinduction (Principle 6.7) in the special case of corecursion on streams. One can check that (ft,ri,f2) is an Fs-bisimulation "up-to-_ + Sn" on (Sn + Sn,[&i, Fs(in2)]) if and only if the set-theoretic relation TZC. (Sn + Sn)2 underlying the span (lZ}ri}r2) is a <I>+-bisimulation "up-to-U ~2", where

• Ф+ : V(T(SN + Sn) X T(Sn + SN)) V(T(SN + SN) x T(SN + SN)) is the

monotone operator defined by

Ф+(7г) = {(¿m(s),im(s')) | 7ri(ai(s)) = 7n(ai(s')) A ^2(«i(5)) К Tr2(ai(s'))} U

{(in2(s),in2(s')) I 5 = s'};

• ~2= {{in2(s),in2(s')) I 5 G Sn};

• 7Z Ф+-Ь1з1ти1а11оп "up-to-U means that 1Z С Ф+(7£и и2).

Then the principle of coalgebraic coinduction "up-to-_+iSjv" for corecursive functions can be simply expressed as follows:

xTZy гта+(7г) С Ф+(гта+(7г)Ц ^2)

ж ~h У '

where inf(7Z) denotes the set-theoretic image of 1Z by in\. 6-4-2 Linear time semantics

There is a straightforward natural definition of linear time semantics for CCS processes as Vnn( )-coiterative morphism, where Vnn( ) denotes the finite powerset monad defined as follows:

Definition 6.12 [Powerset monad] Let (Vnn( )}fi}rj) be the monad defined by:

• ~Pfin( ) : Set —У Set is the finite powerset functor in Set;

• Vx = { } : X —У Vfin(X) is singleton constructor;

Lenisa, Power and Watanabe • l^x ■ Pfi„CPfi„PO) Vfin{X) is defined by

Vx G Vfin(Vfin(X)). nx{x) = |Jy .

The notion of linear semantics that we consider here is that determined by all the possible (not necessarily complete) traces generated by a closed CCS process.

In order to define the linear trace semantics, we consider the Vnn( )-coiterative scheme obtained by taking F, in the generalized coiteration scheme, to be the functor Vfin(A X _). Let (Vfin(Proc°ccs)} ai) be the Vnn{A x _)-coalgebra defined by:

ai{P) = {(a, {Pl | 3p G P. p A Pl}) | a G A} .

Let (P, ap) denote the final coalgebra for Vnn{A X _). Let hi : Proc°ccs —> P be the "Pfin(-)-coiterative function determined by the coalgebra (Vfin(Proc°ccs), on), i.e. hi = fi o {_}, where:

Proches

viin (P

Viin{A x Viin{Proc°ccs))

Viiri(idA x fi)

Viin{A x P)

Proposition 6.13 The equivalence induced by the V(_)-coiterative morphism hi : Proc°ccs —> P is the linear trace equivalence.

A natural question that one can ask at this point is whether it is possible to define a (interesting) trace semantics as a final semantics, 1.6. cts ct standard coiterative morphism, or the trace semantics is intrinsically non-coiterative. All the attempts in the literature of giving a trace semantics by finality actually hide a definition by "Pfin-coiteration.

Here we just notice that the function hi escapes the standard coiteration scheme. In fact, there is no way of endowing Proc°ccs with a Vnn{A X _)-coalgebra structure in order to recover the linear-time semantics. On the other hand, notice that the powerset of the set of traces of CCS processes is a proper subset of the final coalgebra of Vnn{A X _), which in turn consists of all branching-time processes. Therefore, a related issue is that of looking for different functors whose final coalgebras are tighter to the powerset of the set of CCS-traces.

6Jf.3 Coiteration and coinduction "up-to-context"

Another interesting coiteration scheme is the one which we call context-coite-ration. This is related to the (set-theoretic) principle of bisimulation "up-to-context", which has been used quite extensively in providing smooth proofs of important properties of CCS and 7r-calculus (see e.g. [15,21]), and, more recently, also for reasoning on various observational (contextual) equivalences on A-calculus (see e.g. [7,11,12,6]).

We focus on CCS processes. We recall the definition of context on CCS processes:

Definition 6.14 [CCS contexts] The class of CCS contexts is defined as follows:

C[] ::= p I [] I a.C[ ] | C[]\C[] | C[] + C[] | rec x.C[ } , where p £ Process.

Definition 6.15 [Context monad] Let Tc '■ Set —Set be the endofunctor defined as follows:

Tc(X) = C[X] = {C[x] \x(EX A C[ ] is a closed CCS context} ,

Vf :X ^Y morphism in Set. Tc(f) = C[x] ^ C[f(x)] .

The functor Tc can be endowed with a structure of monad by defining

• T]X :X ^ Tc(X) by x^ [a;]

• : T*(X) Tc(X) by C1[C2[x]] ^ C^i ]/[ ]][x].

This time we discuss a special instance of the Principle of Coalgebraic Coinduction 6.7 for reasoning on standard coiterative morphisms.

Let us consider the functor F to be Vnn(A X _), and the Vnn{A X _)-coalgebra (CfProc^^], as), where as : CfProc^^] —> V(A X CfProc^^]) is defined by:

as(C\p]) = {(a,C\p 1]) \ P^Pl} .

One can check that, a span (lZ}ri}r2) is a Vnn{A X _)-bisimulation "up-to-C[ ]" on the Vnn{A X _)-coalgebra (CfProc^^], as) if and only if the set-theoretic relation 1Z underlying the span is a $s-bisimulation "up-to-context" for the operator $s : V{Tc{Proc°ccs) X Tc{Proc°ccs)) V{Tc{Proc°ccs) X Tc(Proc°ccs) defined by:

$s(7\!.) = {(u, v) | (V(a, Ui) £ as(u). 3(a, ^i) £ as(v). Ui 1Z ^i) A (V(a, ^i) £ as(v). 3(a, Ui) £ as(u). Ui 1Z ^i)} .

I.e. the following principle "up-to-context" is sound and complete:

xKy K<Z$S(C[K])

where is the equivalence induced by the coiterative morphism determined by the coalgebra (CfProc^^], as), i.e. strong bisimilarity.

References

[1] P. Aczel, Non-well-founded sets, CSLI Lecture Notes 14, Stanford (1988)

[2] P. Aczel and N. Mendler, A Final Coalgebra Theorem, Proc. CTCS'89, Lecture Notes in Comp Science 389, D. Pitt et al (eds.) Springer-Verlag (1989), 357-365

[3] A. Corradini, M. Grosse-Rhode and R. Heckel, Structured Transition Systems as Lax Coalgebras, Proc. first Workshop of CMCS'98, Electric Notes in Theoretical Computer Science, Vol. 11 (1998),

http://www.elsevier.nl/locate/entes/volume11.html

[4] P. Freyd and A. Scedrov, Categories, Allegories, North-Holland, Amsterdam (1990)

[5] H. Geuvers, Inductive and Coinductive types with Iteration and Recursion, Proc. 1992 Workshop on Types for Proofs and Programs, Bastad, Sweden, eds. B. Nordstrom, K. Petersson and G.Plotkin (1992), 183-207,

[6] F. Honsell and M. Lenisa, Coinductive Characterizations of Applicative Structures, Math. Struct, in Comp. Science 9 (1999), 403-435.

[7] D. Howe, Proving congruence of bisimulation in functional programming languages, Inf. and Comp. 124(2) (1996), 103-112.

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

[9] G.M. Kelly, A Unified Treatment Of Transfinite Constructions For Free Algebras, Free Monoids, Colimits, Associated Sheaves, And So On, Bull. Austral. Math. Soc. vol. 22(1980), 1-83

[10] G.M. Kelly and R. Street, Review of the elements of 2-categories, Sydney Category Seminar, Lecture Notes in Mathematics 420 (1974), 75-103

[11] S. Lassen, Relational Reasoning About Contexts, Higher Order Operational Techniques in Semantics, A.Gordon and A.Pitts (eds.), Cambridge University Press (1996).

[12] M. Lenisa, Themes in Final Semantics, Ph.D. Thesis TD-6/98 (1998), Dipartimento di Informática, Universitá di Pisa, Italy.

[13] M. Lenisa, From Set-theoretic Coinduction to Coalgebraic Coinduction: some results, some problems, Proc. CMCS'99, Electric Notes in Theoretical Computer Science, Vol.19 (1999),

http://www.elseier.nl/locate/entcs/volume19.html

[14] R. Milner, Calculi for synchrony and asynchrony, Theoretical Computer Science 25 (1983), 267-310

[15] R. Milner, J.Parrow and D.Walker, A calculus of mobile processes, Inf. and Comp. 100 (1992), 1-77.

[16] J. Power and D. Turi, A Coalgebraic Foundation for Linear Time Semantics, Proc. CTCS'99, Electric Notes in Theoretical Computer Science, vol.24 (1999)

[17] J. Power and H. Watanabe, Distributivity for a monad and a comonad, Proc. second Workshop of CMCS'99, Electric Notes in Theoretical Computer Science, Vol. 19 (1999),

http://www.elsevier.nl/locate/entcs/volume19.html

[18] J. Power and H. Watanabe, Combining a monad and a comonad, ETL Technical Report TR-99-33 (submitted to TCS)

[19] R. Street, The formal theory of monads, J. Pure Appl. Algebra 2 (1972), 149168

[20] J. Rutten and D. Turi, Initial algebra and final coalgebra semantics for concurrency, Proc. REX workshop A Decade of Concurrency - Reflections and Perspectives, Lecture Notes in Comp Science 803, J. de Bakker et al (eds.) Springer-Verlag (1994), 530-582

[21] D. Sangiorgi, On the bisimulation proof method, Math. Struct. In Comp. Science 98(8) (1998), 447-478.

[22] D. Turi and G. Plotkin, Towards a mathematical operational semantics, Proc. LICS 97 (1997), 280-291

Appendix 1

2-category, op-construction, co-construction

Definition 6.16 A 2-category K consists of

• a set of 0-cells or objects,

• for each pair of 0-cells X and Y, a category K(X} Y) called the homcategory from X to Y,

• for each triple of 0-cells X, Y and Z, a composition functor o : K(Y, Z) X K(X,Y)^K(X,Z),

• for each 0-cell X, an object idx of K(X,X), or equivalently, a functor idx : 1 —K(X,X), called the identity on X,

such that the following diagrams of functors commute

K(Z, W) x K(Y, Z) x K(X, Y)

o x K(X, Y)

K(Y., W) x K(X, Y)

K(Z, W) x o

K(Z, W) x K(X, Z)

K(X, W)

K(X, Y) x K(X, X)

K(X, Y) x idx

idY x K(X, Y)

K(Y, Y) x K(X, Y)

In the definition of a 2-category, the objects of each K(X} Y) are often called 1 -cells and arrows of each K(X,Y) are often called 2-cells.

Example 6.17 The leading example of a 2-category is Cat, in which the 0-cells are small categories and Cat(C} D) is defined to be the functor category [C}D]- In this paper, we treat Cat as through Set is a 0-cell of Cat. Technically, the existence of two strongly inaccessible cardinals together with a careful variation in the use of the term small allows that.

There are two dual constructions which make other 2-categories.

Definition 6.18 For any 2-category K, the opposite 2-category Kop is defined as follows:

• 0-cells are the same as that of K,

Definition 6.19 The 2-category Kco is defined as follows:

• 0-cells are the same as those of K,

• Kco(X}Y) = K(X,Y)op-

Hence the op-construction reverses the 1-cells of K, and the co-construction the 2-cells of K.

Appendix 2

We show the Propostion 2.12 in the following form.

Kop(X,Y) = K(Y,X).

Proposition 6.20 Cat admits Kleisli constructions for pointed endofunctors. The left 2-adjoint functor sends each pointed endofunctor (T, r/) on a category C to (T, r])-K\ the Kleisli category for the pointed endofunctor.

Proof. Let (T, rj) be a pointed endofunctor on a category C and J : C —> (T, r])~K1 be a functor sending each object a in C to a and an arrow / : a —b in C to [y] ; a —y b in (T, r])-Kl.

We define a natural transformation j : JT =>- J by the arrow ja = [idya] : Ta —a in (T, r])~Kl for each object a in C. These data give rise to a 1-cell (J,j) : (C,T,r)) Inc((T,r))-Kl) in pEndo*(CW).

Now we show that (J,j) is the unit for a left 2-adjoint to Inc : Cat —> pEndo*(Cat). Given a category X and an arrow (K,k) : (C, T) —> Inc(X) in pEndo*(Cat), define K : (T, 77)-Kl -y I on objects by setting Ka = Ka, and on arrows by sending [/] : a —> b in (T, r/)-Kl, which is represented by an arrow / : a —> Tnb in C for some n £ N, to k^ o k^b o • • • o kTn-ib o Kf. Then the following diagram commutes in pEndo*(Cat).

Since each arrow [/] : a —> b in (T, r/)-Kl, which is represented by an arrow / : a —> Tnb in C for some n £ N, can be written as composites kb o kxb o • • • o kTn-ib o Jf in (T, r])~Kl, the unicity of such K follows immediately.

It remains to verify the 2-dimensional property that every 2-cell a : (K} k) —> (L, I) in pEndo*(Cat) extends uniquely to a natural transformation a : K —> L such that Inc(a) o (J, j) = a holds. If we define a by aa = aa for each object a in (T, r])~Kl, then this is the unique natural transformation which satisfies the 2-dimensional property. □