<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Coalgebraic Aspects of Bidirectional Computation</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Faris Abou-Saleh</string-name>
          <email>Faris.Abou-Saleh@cs.ox.ac.uk</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>James McKinna</string-name>
          <email>James.McKinna@ed.ac.uk</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jeremy Gibbons</string-name>
          <email>Jeremy.Gibbons@cs.ox.ac.uk</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>. Department of Computer Science University of Oxford</institution>
          ,
          <country country="UK">UK</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>. School of Informatics University of Edinburgh</institution>
          ,
          <country country="UK">UK</country>
        </aff>
      </contrib-group>
      <fpage>16</fpage>
      <lpage>30</lpage>
      <abstract>
        <p>We have previously (Bx, 2014; MPC, 2015) shown that several statebased bx formalisms can be captured using monadic functional programming, using the state monad together with possibly other monadic effects, giving rise to structures we have called monadic bx (mbx). In this paper, we develop a coalgebraic theory of state-based bx, and relate the resulting coalgebraic structures (cbx) to mbx. We show that cbx support a notion of composition coherent with, but conceptually simpler than, our previous mbx definition. Coalgebraic bisimulation yields a natural notion of behavioural equivalence on cbx, which respects composition, and essentially includes symmetric lens equivalence as a special case. Finally, we speculate on the applications of this coalgebraic perspective to other bx constructions and formalisms.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        composition t1 # t2 for those mbx with transparent get operations – i.e. get s which are effect-free and do not
modify the state. The definition is in terms of StateT -monad morphisms derived from lenses (see Section 5),
adapting work of Shkaravska [
        <xref ref-type="bibr" rid="ref28">28</xref>
        ]. As with symmetric lenses, composition can only be well-behaved up to some
notion of equivalence, due to the different state-spaces involved. We showed that our definition of composition
was associative and had identities up to an equivalence defined by monad morphisms – in particular, given by
isomorphisms of state-spaces.
      </p>
      <p>Although this equivalence is adequate for analysing such properties, it proves unsuitably fine-grained for
comparing other aspects of bx behaviour. For instance, one may be interested in optimisation; one would then
like some means of reasoning about different implementations, to check that they indeed have the same behaviour.
Such reasoning is not possible based solely on state-space isomorphisms. As most of our work considers
statebased bx, it is natural to ask whether one can identify an alternative, less ad-hoc, notion of equivalence.</p>
      <p>
        In this paper, we present a coalgebraic treatment of our earlier work on monadic bx, inspired by Power
and Shkaravska’s work on variable arrays and comodels [
        <xref ref-type="bibr" rid="ref24">24</xref>
        ] for the theory of mutable state. Previously, we
considered structure relative to the categories Set, Hask (Haskell types and functions); in particular, we argued
that the composite mbx operations we defined on the underlying simple types respected appropriate set-theoretic
invariants. Here, the coalgebraic approach has several benefits: firstly, it gives a more direct categorical treatment
of bx composition, in terms of pullbacks. More importantly, it allows us to improve on our earlier notion of
equivalence given by state-space isomorphism, appealing instead to the theory of coalgebraic bisimularity [
        <xref ref-type="bibr" rid="ref26">26</xref>
        ];
in particular, we relate it to the equivalence on symmetric lenses [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ].
      </p>
      <p>
        The technical contributions and structure of this paper are as follows. Firstly, in Section 2 we identify a
categorical setting, and useful properties, for interpreting bx in terms of coalgebras. In Section 3, we introduce
an equivalence on coalgebras, namely pointed coalgebraic bisimulation, and demonstrate how this equivalence
relates to that of symmetric lenses, in addition to various effectful bx scenarios. (Pointedness identifies initial
states, with respect to which coalgebra behaviours are compared.) In Section 4 we give a detailed account of
composition of coalgebraic bx in terms of pullbacks, which is both more direct and categorically general than
our earlier definition [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], highlighting subtleties in the definitions (such as Remark 4.8). We prove that our
coalgebraic notion of composition is associative, and has identities, up to the equivalence we have introduced.
Finally, in Section 5 we show that coalgebraic bx composition is coherent with that of [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
      <p>NB We discuss only key ideas and techniques; an extended version with detailed proofs is available at
http://groups.inf.ed.ac.uk/bx/cbx-tr.pdf.
2
2.1</p>
    </sec>
    <sec id="sec-2">
      <title>Coalgebraic bx</title>
      <p>
        Categorical Prerequisites
1. We will assume an ambient category C with finite products X × Y and exponentials X Y (essentially,
the space of functions from Y to X ), on which a strong monad M is defined. (See for example Moggi’s
original paper [
        <xref ref-type="bibr" rid="ref21">21</xref>
        ] for a discussion of the need for such structure.) This allows us to make free use of the
equational theory of do-notation as the internal language of the Kleisli category Kl(M ) (see [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] for more
detail). Rather than using pointfree strength and associativity isomorphisms, do-notation is convenient for
representing value-passing between functions using pointwise syntax.
2. In order to define coalgebraic bx composition in Section 4, we further require that C have pullbacks, and
that M weakly preserve them [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]; we say “M is wpp”, for short. The following diagrams make this more
explicit. Recall that a pullback of two arrows f : X → B and g : Y → B is an object P and span of arrows
pX : P → X , pY : P → Y making the below-left diagram commute, such that for any object Q and span
cX , cY making the outermost ‘square’ in the middle diagram commute, there is a unique arrow h making the
whole diagram commute. Finally, the wpp property (for M ) asserts that the span M pX , M pY forms a weak
pullback of Mf and Mg : for any object S and span dX , dY making the outermost ‘square’ in the right-hand
diagram commute, there is an arrow k , not necessarily unique, making the whole diagram commute.
pY
      </p>
      <p>P
Y
pX
g
/ X
/ B
f</p>
      <p>Q
cY
∃!h</p>
      <p>P
! Y
cX
pX
pY
g
/ X
/ B</p>
      <p>f
dY</p>
      <p>dX
∃k
"
M P M pY/ M" X
!
M Y</p>
      <p>M pX</p>
      <p>Mg</p>
      <p>Mf
/ M B</p>
      <p>
        Remark 2.1. The wpp condition lets us consider (at least for C = Set) monads M of computational interest
such as (probabilistic) non-determinism [
        <xref ref-type="bibr" rid="ref12 ref29">12, 29</xref>
        ], which are wpp but do not preserve pullbacks; more generally,
we can include I/O, exceptions, and monoid actions, by appealing to a simple criterion to check wpp holds for
such M [11, Theorem 2.8].
2.2
      </p>
      <sec id="sec-2-1">
        <title>Bx as Pointed Coalgebras</title>
        <p>
          We now give a coalgebraic description of bx, i.e. as state-based systems. We begin by noting that many bx
formalisms, such as (a)symmetric lenses and relational bx, often involve an initialised state. The behaviours of
two such bx are compared relative to their initial states. Hence, to reason about such behaviour, throughout
this paper we concern ourselves with pointed coalgebras with designated initial state. Coalgebras with the
same structure, but different initial states, are considered distinct (see [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] for more general considerations).
Corollary 4.14 makes explicit the categorical structure of bx represented by such structures.
Definition 2.2. For an endofunctor F on a category C, a pointed F -coalgebra is a triple (X , α, α) consisting
of: an object X of C – the carrier or state-space; an arrow α : X → FX – its structure map or simply structure;
and an arrow α : I → X picking out a distinguished initial state. We abuse notation, typically writing α for the
pointed coalgebra itself.
        </p>
        <p>
          Now we define the behaviour functors we use to describe bx coalgebraically; as anticipated above, we
incorporate a monad M into the definition from the outset to capture effects, although for many example classes, such
as symmetric lenses, it suffices to take M = Id , the identity monad. Here are several example settings, involving
more interesting monads, to which we return in Section 3.2:
• Interactive I/O. In [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ] we gave an example of an mbx which notifies the user whenever an update occurred.
        </p>
        <p>Extending this example further, after an update to A or B , in order to restore consistency (as specified e.g.
by a consistency relation R ⊆ A × B ) the bx might prompt the user for a new B or A value respectively
until a consistent value is supplied. Such behaviour may be described in terms of a simplified version of the
I/O monad MX = νY . X + (O × Y ) + Y I given by a set O of observable output labels, and a set of inputs
I that the user can provide. Note that the ν-fixpoint permits possibly non-terminating I/O interactions.
• Failure. Sometimes it may be simply impossible to propagate an update on A across to B , or vice versa;
there is no way to restore consistency. In this case, the update request should simply fail; and we may model
this with the Maybe monad MX = 1 + X .
• Non-determinism. There may be more than one way of restoring consistency between A and B after
an update. In this case, rather than prompting the user at every such instance, it may be preferable for
a non-deterministic choice to be made. We may model this situation by taking the monad M to be the
(finitary) powerset monad.</p>
        <p>Definition 2.3. For objects A and B , define the functor FAMB (−) = A × (M (−))A × B × (M (−))B .</p>
        <p>
          For a given choice of objects A and B , we will use the corresponding functor FAMB to characterise the behaviour
of those bx between A and B , as FAMB -coalgebras. By taking projections, we can see the structure map α : X →
FAMB X of a pointed FAMB -coalgebra as supplying four pieces of data: a function X → A which observes the
A-value in a state X ; a function X → (MX )A which, uncurried into the form X × A → MX , gives us the
sideeffectful result MX of updating the A-value in the state X ; and two similar functions for B . These respectively
correspond to the getL, setL, getR, and setR functions of a monadic bx with respect to the state monad MX
(with state-space X ), as outlined above. Note that in this coalgebraic presentation, the behaviour functor makes
clear that the get operations are pure functions of the coalgebra state – corresponding to ‘transparent’ bx [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ].
Convention 2.4. Given α : X → FAMB X , we write α.getL : X → A, and α.setL : X → (MX )A, for the
corresponding projections, called ‘left’- or L-operations, and similarly α.getR : X → B , α.setR : X → (MX )B for
the other projections, called R-operations. Where α may be inferred, and we wish to draw attention to the carrier
X , we also write x .getL for α.getL x , and similarly for the other L-, R-operations.
Remark 2.5. Note that FAMB may be defined in terms of the costore comonad S × (−)S , used in [
          <xref ref-type="bibr" rid="ref24">24</xref>
          ] to describe
arrays of independent variables. However, we differ in not allowing simultaneous update of each source (which
would take S = A × B ), because updates to A may affect B , and vice versa.
        </p>
        <p>To ensure that pointed FAMB -coalgebras provide sensible implementations of reading and writing to A and B ,
we impose laws restricting their behaviour. We call such well-behaved coalgebras coalgebraic bx, or cbx.
Definition 2.6. A coalgebraic bx is a pointed FAMB -coalgebra (X , α : X → FAMB X , α) for which the following
laws hold at L (writing x .getL for α.getL x , etc. as per Convention 2.4):
(CGetSetL) (α) :
(CSetGetL) (α) :
x .setL (x .getL)</p>
        <p>= return x
do {x 0 ← x .setL a; return (x 0, x 0.getL)} = do {x 0 ← x .setL a; return (x 0, a)}
and the corresponding laws (CSetGetR) and (CGetSetR) hold at R.</p>
        <p>
          These laws are the analogues of the (GS), (SG) laws [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ] which generalise those for well-behaved lenses [8, see
also Section 5.2 below]. They also correspond to a subset of the laws for coalgebras of the costore comonad
S × (−)S , again for S = A and S = B independently, but excluding the analogue of ‘Put-Put’ or
very-wellbehavedness of lenses [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. We typically refer to a cbx by its structure map, and simply write α : A −−X B , where
we may further omit explicit mention of X .
        </p>
        <p>Here is a simple example of a cbx, which will provide identities for cbx composition as defined in Section 4
below. Note that there is a separate identity bx for each pair of an object A and initial value e : A.
Example 2.7. Given (A, e : A), there is a trivial cbx structure ι(e) : A −−A A defined by ι(e) = e; a.getL = a =
a.getR; a.setL a0 = return a0 = a.setR a0.</p>
        <p>Remark 2.8. Our definition does not make explicit any consistency relation R ⊆ A × B on the observable A
and B values; however, one obtains such a relation from the get functions applied to all possible states, viz.
R = {(a, b) : ∃x . getL x = a ∧ getR x = b }. One may then show that well-behaved cbx do, indeed, maintain
consistency wrt R.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Behavioural Equivalence and Bisimulation</title>
      <p>In this section, we introduce the notion of pointed coalgebraic bisimulation, which defines a behavioural
equivalence ≡ for pointed cbx. In Section 3.1 we compare this equivalence to the established notion of equivalence for
symmetric lenses. We then discuss in Section 3.2 the behavioural equivalences induced for the classes of effectful
bx described in Section 2.2: interactive I/O, failure, and non-determinism.</p>
      <p>Definition 3.1. A pointed (F -)coalgebra morphism h between pointed coalgebras (X , α, α) and (Y , β, β ) is a
map h : X → Y such that β ◦ h = Fh ◦ α and h ◦ α = β .</p>
      <p>Remark 3.2. In terms of do notation, h : X → Y being an FAMB -coalgebra morphism between α and β is
equivalent to the following laws (where we again write x .setL for α.setL x , and so on):
(CGetPL)(h) :
(CSetPL)(h) :
x .getL = (h x ).getL
do {x 0 ← x .setL a; return (h x 0)} = do {let y = (h x ); y 0 ← y .setL a; return y 0 }</p>
      <p>
        We now define a modest generalisation to C of the standard Set-based definition of (coalgebraic) bisimulation
relations [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ]. (Since we are concerned only with the existence of bisimulations between X and Y , we may
consider them to be given non-uniquely by some jointly monic pair, as follows).
      </p>
      <p>Definition 3.3. A bisimulation between pointed coalgebras α and β is a pointed coalgebra ζ and a span (p, q )
of pointed coalgebra morphisms p : ζ → α, q : ζ → β which is jointly monic (in C) – meaning that whenever
p ◦ f = p ◦ f 0 and q ◦ f = q ◦ f 0, we have f = f 0.</p>
      <p>Definition 3.3 characterises bisimulation in the concrete case C = Set and M = Id as follows:
Proposition 3.4. A pointed FAIdB -bisimulation R on a pair of coalgebraic bxs α, β is equivalent to a relation
R ⊆ X × Y such that ( α, β ) ∈ R, and (x , y ) ∈ R implies, for all a : A and b : B ,
• x .getL = y .getL and x .getR = y .getR;
• (x .setL a, y .setL a) ∈ R, and (x .setR b, y .setR b) ∈ R.</p>
      <p>Definition 3.5. We say that two cbx α, α0 are behaviourally equivalent, and write α ≡ α0, if there exists a
pointed coalgebraic bisimulation (ζ, p, q ) between α and α0.
3.1</p>
      <sec id="sec-3-1">
        <title>Relationship with Symmetric Lens Equivalence</title>
        <p>
          In this subsection, we describe symmetric lenses (SL) [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ] in terms of cbx, and relate pointed bisimilarity between
cbx and symmetric lens (SL-)equivalence [ibid., Definition 3.2]. First of all, it is straightforward to describe a
symmetric lens between A and B with complement C – given by a pair of functions putr :: A × C → B × C ,
putl :: B × C → A × C and initial state C together satisfying two laws – as a cbx: take M = Id and
statespace X = A × C × B , encapsulating the current value of the lens complement C , as well as those of A and B
(cf. [5, Section 4]). We now define the analogues of the SL-operations for a cbx between A and B :
Definition 3.6. (Note that this is the opposite L-R convention from [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ]!)
x .put L : A → (B × X )
x .put R : B → (A × X )
x .put L a = let x 0 = x .setL a in (x 0.getR, x 0)
x .put R b = let x 0 = x .setR b in (x 0.getL, x 0)
Proposition 3.7. Taking C = Set and M = Id , a pointed FAIdB -bisimulation R between cbxs α, β is equivalent
to a relation R ⊆ X × Y such that ( α, β ) ∈ R, and (x , y ) ∈ R implies the following:
        </p>
        <p>
          Expressing cbx equivalence in these terms reveals that it is effectively identical to SL-equivalence. The
cosmetic difference is that we are able to observe the ‘current’ values of A and B in any given state, via the
get functions. This information is also implicitly present in SL-equivalence, where a sequence of putr or putl
operations amounts to a sequence of set s to A and B , but where we cannot observe which values have been set.
Here, the get operations make this information explicit. We say more about the categorical relationship between
cbx and SLs in Corollary 4.15 below.
We take MX = νY . X + (O × Y ) + Y I , where O is a given set of observable outputs, and I inputs the user
can provide. The components of the disjoint union induce monadic return : X → MX and algebraic operations
out : O × MX → MX and in : (I → MX ) → MX (c.f. [
          <xref ref-type="bibr" rid="ref23">23</xref>
          ]). In the context of cbx that exhibit I/O effects in this
way, an operation like setL : X → (MX )A maps a state x : X and an A-value a : A to a value m : MX , where m
describes some path in an (unbounded) tree of I/O actions, either terminating eventually and returning a new
state in X , or diverging (depending on the user’s input).
        </p>
        <p>One may characterise pointed bisimulations on such cbx as follows. Intuitively, behaviourally equivalent
states must “exhibit the same observable I/O activity” during updates setL and setR, and subsequently arrive at
behaviourally equivalent states. To formalise this notion of I/O activity, we need an auxiliary definition (which
derives from the greatest-fixpoint definition of M ):
Definition 3.8. With respect to an I/O monad M and a relation R ⊆ X × Y , the I/O-equivalence relation ∼R
⊆ MX × MY induced by R is the greatest equivalence relation such that m ∼R n whenever:
• m = return x , n = return y , and (x , y ) ∈ R for some x , y ; or
• m = out (o, m0) and n = out (o, n0) for some o : O and m0 ∼R n0; or
• m = in (λi → m(i )) and n = in (λi → n(i )), where m(i ) ∼R n(i ) for all i : I .</p>
        <p>One may now show that a pointed FAMB -bisimulation R on a pair of such cbxs α, β is equivalent to a relation
R ⊆ X × Y such that ( α, β ) ∈ R, and (x , y ) ∈ R iff
• x .getL = y .getL and x .getR = y .getR;
• for all a : A and b : B , (x .setL a) ∼R (y .setL a) and (x .setR b) ∼R (y .setR b).</p>
        <p>Such an equivalence guarantees that, following any sequence of updates in α or β, the user experiences exactly
the same sequence of I/O actions; and when the sequence is complete, they observe the same values of A and B
for either bx. Thus, pointed bisimulation asserts that α, β are indistinguishable from the user’s point of view.
3.2.2
Here we take MX = 1 + X , and write None and Just x for the corresponding components of the coproduct. This
induces a simple equivalence on pairs of bx, asserting that sequences of updates to either bx will succeed or fail
in the same way. More formally, a pointed bisimulation R on a pair of coalgebraic bxs α, β is equivalent to a
relation R ⊆ X × Y such that ( α, β ) ∈ R, and (x , y ) ∈ R iff for all a : A and b : B ,
• if x .setL a = None then y .setL a = None – and vice versa;
• if x .setL a = Just x 0, then y .setL a = Just y 0 for some y 0 with (x 0, y 0) ∈ R – and vice versa;
• two analogous clauses with B and setR substituted for A and setL.
3.2.3</p>
      </sec>
      <sec id="sec-3-2">
        <title>Non-determinism</title>
        <p>Taking M to be the finitary powerset monad, the resulting behavioural equivalence on bx comes close to the
standard notion of strong bisimulation on labelled transition systems – and as we will see, shares its excessive
fine-grainedness. A pointed FAMB -bisimulation R on a pair of cbxs α, β is equivalent to a relation R ⊆ X × Y
such that ( α, β ) ∈ R, and (x , y ) ∈ R iff for all a : A and b : B ,
• x .getL = y .getL;
• for all a : A and x 0 ∈ x .setL a, there is some y 0 ∈ y .setL a with (x 0, y 0) ∈ R;
• for all a : A and y 0 ∈ y .setL a, there is some x 0 ∈ x .setL a with (x 0, y 0) ∈ R;
• three analogous clauses with B and getR/setR substituted for A and getL/setL.</p>
        <p>In contrast with the case of user I/O, this equivalence may be too fine for comparing bx behaviours, as it
exposes too much information about when non-determinism occurs. Here is a prototypical scenario: consider the
effect of two successive L-updates. In one implementation, suppose an update setL a changes the system state
from s to t , and a second update setL a0 changes it to either u or u0. Each state-change is only observable to
the user through the values of getL and getR; so suppose u.getR = u0.getR = b. (Note that u.getL = u0.getL = a0
by (CGetSetL)). This means u and u0 cannot be distinguished by their get values.</p>
        <p>
          In a different implementation, suppose setL a instead maps s to one of two states t 0 or t 00 (both with the same
values of getR and getL as state t above), and then setL a0 maps these respectively to u and u0 again. The states
called s in both implementations, although indistinguishable to any user by observing their get values, are not
bisimilar. In such situations, a coarser ‘trace-based’ notion of equivalence may be more appropriate [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ].
4
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Coalgebraic bx Composition</title>
      <p>
        A cbx α : A −−X B describes how changes to a data source A are propagated across X to B (and vice versa).
It is then natural to suppose, given another such β : B −−Y C , that we may propagate these changes to C (and
vice versa), raising the question of whether there exists a composite cbx α • β : A −−Z C for some Z . Here, we
give a more general, coalgebraic definition of cbx composition than our previous account for mbx [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]; this lets us
reason about behavioural equivalence of such compositions in Section 4.1.
      </p>
      <p>First, we introduce some necessary technical details regarding weak pullback preserving (wpp) functors. Wpp
functors are closed under composition, and we also exploit the following fact:
Lemma 4.1. A wpp functor preserves monomorphisms, or “monos” (maps f which are ‘right cancellable’:
g .f = h.f implies g = h) [25, Lemma 4.4].</p>
      <p>Remark 4.2. The following technical observation will also be useful for reasoning about FAMB -coalgebras. As M
is wpp (assumption 2 of Section 2.1), so too is FAMB , using the fact that A × (−) and (−)A preserve pullbacks,
and hence are wpp. Then by Lemma 4.1, FAMB also preserves monos.</p>
      <p>Finally, we will employ the following in proofs, where k x a is a block of statements referring to x and a:
Lemma 4.3. (CSetGetL) and (CGetSetL) are equivalent to the following ‘continuation’ versions:
(CGetSetL) (α) : do {let a = x .getL; x 0 ← x .setL a; k x 0 a } = do {let a = x .getL; k x a }
(CSetGetL) (α) : do {x 0 ← x .setL a; k x 0 (x 0.getL)} = do {x 0 ← x .setL a; k x 0 a }
Similarly, there are continuation versions of the coalgebra-morphism laws (CGetPL)(h), (CSetPL)(h), etc. in
Remark 3.2, which we omit. We are now ready to define cbx composition; we do this in four stages.
(i)</p>
      <sec id="sec-4-1">
        <title>Defining a State-space for the Composition of α and β</title>
        <p>The state-spaces of coalgebraic bx α : A −−X B , β : B −−Y C both contain information about B , in addition to
A and C respectively. As indicated above, we define the state-space Z of the composite as consisting of those
(x , y ) pairs which are ‘B -consistent’, in that x .getR = y .getL. We must also identify an initial state in Z ; the
obvious choice is the pair ( α, β ) of initial states from α and β. To lie in Z , this pair itself must be B -consistent:
α.getR = β .getL. We may only compose cbx whose initial states are B -consistent in this way.</p>
        <p>We now give the categorical formulation of these ideas, in terms of pullbacks:
Definition 4.4. Given two pointed cbx α:A −−X B and β :B −−Y C , we define a state-space for their composition
α • β to be the pullback Pα,β in the below-left diagram. It is straightforward to show that this also makes the
below-right diagram (also used in Step ((iii)) below) into a pullback, where eα,β is defined to be hpα, pβ i.</p>
        <p>Pα,β</p>
        <p>pα
X</p>
        <p>pβ
α.getR
/ Y
/ B
β.getL</p>
        <p>Pα,β
pα</p>
        <p>X
eα,β=hpα,pβi
hα.getR,α.getRi</p>
        <p>Pα,β = {(x , y ) | x .getR = y .getL } = {(x , y ) | (x .getR, y .getL) = (x .getR, x .getR)}
and α•β is the pair of initial states ( α, β ), assuming α.getR = β .getL.</p>
        <p>Remark 4.5. Towards proving properties of the composition α • β in Section 3, we note that eα,β is also the
equalizer of the parallel pair of arrows α.getR ◦ π1, β.getL ◦ π2 : X × Y → B . Hence, a fortiori eα,β is monic (i.e.
left-cancellable), and thus by Lemma 4.1, so too is its image under the wpp functors M and FAMB .</p>
        <p>This allows us to pick out an initial state for Z , by noting that the arrow ( α, β ) : I → X × Y equalizes the
parallel pair of morphisms in Remark 4.5; universality then gives the required arrow α•β : I → Z .
(ii)</p>
      </sec>
      <sec id="sec-4-2">
        <title>Defining Pair-based Composition α</title>
        <p>β
Definition 4.6. (X × Y , α</p>
        <p>β) is an FAMC -coalgebra with L-operations (similarly for R):
(x , y ).getL = x .getL</p>
        <p>(x , y ).setL a = do {x 0 ← x .setL a; y 0 ← y .setL (x 0.getR); return (x 0, y 0)}
(iii)</p>
        <sec id="sec-4-2-1">
          <title>Inducing the Coalgebra α • β on the Pullback</title>
          <p>We now prove that the set operations of α β produce B -consistent pairs – even if the input pairs (x , y ) were not
B -consistent (because the set operations involve retrieving a B -value from one bx, and setting the same value
in the other). Note that this implies α β will generally fail to be a coalgebraic bx, as it will not satisfy the
coalgebraic bx law (CGetSet): getting and then setting A or C in a B -inconsistent state will result in a different,
B -consistent state, in contrast to the law’s requirement that this should not change the state.
Lemma 4.7. The following equation (†L) holds at L for the setL operation of Definition 4.6, and a corresponding
property (†R) for setR. (The last two occurrences of x 0.getR may equivalently be replaced with y 0.getL.)
=
do {(x 0, y 0) ← (x , y ).setL a; return (x 0.getR, y 0.getL)}
do {(x 0, y 0) ← (x , y ).setL a; return (x 0.getR, x 0.getR)}
(†L)
Proof. We prove (†L); the argument for (†R) is symmetric.</p>
          <p>=
=
=
=
do {(x 0, y 0) ← (x , y ).setL a; return (x 0.getR, y 0.getL)}</p>
          <p>[[ definition of (x , y ).setL ]]
do {x 0 ← x .setL a; let b = x 0.getR; y 0 ← y .setL b; return (x 0.getR, y 0.getL)}</p>
          <p>[[ (CSetGet) (β), where k y 0 b is return (x 0.getR, b) (N.B. k doesn’t use y 0) ]]
do {x 0 ← x .setL a; let b = x 0.getR; y 0 ← y .setL b; return (x 0.getR, b)}</p>
          <p>[[ undo inlining of let b = x 0.getR ]]
do {x 0 ← x .setL a; let b = x 0.getR; y 0 ← y .setL b; return (x 0.getR, x 0.getR)}</p>
          <p>[[ definition of (x , y ).setL ]]
do {(x 0, y 0) ← (x , y ).setL a; return (x 0.getR, x 0.getR)}
Remark 4.8. In general, this is a stronger constraint than the corresponding equation
do {(x 0, y 0) ← (x , y ).setL a; return (x 0.getR)} = do {(x 0, y 0) ← (x , y ).setL a; return (y 0.getL)}
(†∗L)
although it is equivalent if the monad M preserves jointly monic pairs (Definition 3.3). To illustrate the difference,
suppose B = {0, 1} and consider a non-deterministic setting, where M is the (finitary) powerset monad on Set
(and indeed, it does not preserve jointly monic pairs). In state (x , y ), suppose that (setL a) can land in either
of two new states (x1, y1) or (x2, y2), where x2.getR = y1.getL = 0 and x1.getR = y2.getL = 1. Then (†∗L) holds
at (x , y ) as both sides give {0, 1}, but (†L) does not, because the left side gives {(0, 1), (1, 0)} and the right gives
{(0, 0), (1, 1)}. We require the stronger version (†L) to correctly define composition below.</p>
          <p>Our goal is to show that the properties (†L) and (†R) together are sufficient to ensure that the operations
of α β : X × Y → FAMC (X × Y ), restricted to the B -consistent pairs Pα,β , induce well-defined operations
Pα,β → FAMC Pα,β on the pullback.</p>
          <p>To do this, it is convenient to cast the properties (†L), (†R) in diagrammatic form, as shown in the left-hand
diagram below. (It also incorporates two vacuous assertions, (x , y ).getL = (x , y ).getL and similarly at R, which
we may safely ignore.) Then, we precompose this diagram with the equalizer eα,β as shown below-right, defining
δ to be the resulting arrow Pα,β → FAMB X given by the composition FAMB π1 ◦ (α β) ◦ eα,β .</p>
          <p>Although this does not explicitly define the operations of the composition α • β, it does relate them to those
of α β via the monic arrow FAMC eα,β (Remark 4.5) – allowing us to reason in terms of B -consistent pairs
(x , y ) : X × Y , appealing to left-cancellability of monos. Moreover, in spite of only weak pullback preservation
of FAMB , the coalgebra structure α • β is canonical: there can be at most one coalgebra structure α • β such that
eα,β is a coalgebra morphism from α • β to α β. This is a simple corollary of Lemma 4.11 below.
(iv)</p>
        </sec>
      </sec>
      <sec id="sec-4-3">
        <title>Proving the Composition is a Coalgebraic bx</title>
        <sec id="sec-4-3-1">
          <title>Proposition 4.9. (CGetSet) (α • β) and (CSetGet) (α • β) hold at L and R.</title>
          <p>Proof. We focus on the L case (the R case is symmetric). As described in (iii) above, we prove the laws
postcomposed with the monos M eα,β and M (eα,β × id ) respectively; left-cancellation completes the proof. (The law
(CSetPL)(eα,β ) is given after Definition 3.1 below.) Here is (CGetSetL) (α • β) postcomposed with M eα,β :</p>
          <p>Pα,β
δ :=</p>
          <p>v
α•β
FAMC pα
/ X × Y</p>
          <p>α β
FAMC (α.getR×β.getL)
/ FAMC (B × B )
FAMC π1</p>
          <p>X × Y</p>
          <p>α β</p>
          <p>FAMC (X × Y )
FAMC (α.getR×β.getL)</p>
          <p>eα,β
FAMC π1
/ X × Y</p>
          <p>α β</p>
          <p>FAMC (X × Y )
FAMC (α.getR×β.getL)
FAMC X
v</p>
          <p>/ FAMC (B × B )
FAMC hα.getR,α.getRi</p>
          <p>FAMC X</p>
          <p>/ FAMC (B × B )
FAMC hα.getR,α.getRi
Under the assumption that M is wpp, so is FAMC . Hence, the image under FAMC of the ‘alternative’ pullback
characterisation of Pα,β (the right-hand diagram in Definition 4.4) is a weak pullback; it is shown below-left.
Now the above-right diagram contains a cone over the same span of arrows; hence (by definition) we obtain a
mediating morphism Pα,β → FAMC (Pα,β ) (not a priori unique) as shown below-right. We take this to be the
coalgebra structure α • β of the composite bx.</p>
          <p>FAMC Pα,β</p>
          <p>FAMC eα,β
/ FAMC (X × Y )</p>
          <p>Pα,β</p>
          <p>eα,β
FAMC X</p>
          <p>/ FAMC (B × B )
FAMC hα.getR,α.getRi</p>
          <p>FAMC X
y</p>
          <p>FAMC hα.getR,α.getRi
FAMC pα</p>
          <p>FAMC (α.getR×β.getL)
δ</p>
          <p>%
FAMC Pα,β</p>
          <p>FAMC eα,β
/ FAMC (X × Y )
=
=
=
=
=
=
=
do {let a = z .getL; z 0 ← z .setL a; return (eα,β (z 0))}</p>
          <p>[[ (CSetPL)(eα,β) ]]
do {let a = z .getL; let (x , y) = eα,β (z ); (x 0, y0) ← (x , y).setL a; return (x 0, y0)}</p>
          <p>[[ swapping lets, and using (CGetPA)(eα,β) ]]
do {let (x , y) = eα,β (z ); let a = (x , y).getL; (x 0, y0) ← (x , y).setL a; return (x 0, y0)}</p>
          <p>[[ definitions of (x , y).getL and (x , y).setL ]]
do {let (x , y) = eα,β (z ); let a = x .getL; x 0 ← x .setL a; let b = x 0.getR; y0 ← y.setL b; return (x 0, y0)}
[[ (CGetSetA) for α ]]
do {let (x , y) = eα,β (z ); let b = x .getR; y0 ← y.setL b; return (x , y0)}</p>
          <p>[[ (x , y) = eα,β (z ) implies x .getL = y.getR by definition of eα,β ]]
do {let (x , y) = eα,β (z ); let b = y.getL; y0 ← y.setL b; return (x , y0)}</p>
          <p>[[ (CGetSetL) for β ]]
do {let (x , y) = eα,β (z ); return (x , y)}</p>
          <p>[[ inline let; do-laws ]]
return eα,β (z )
(CSetGetL) postcomposed with M (eα,β × id ):
=
=
=
=
=
=
do {z 0 ← z .setL (a); return (eα,β (z 0), z 0.getL)}</p>
          <p>[[ inlining let; definition of z 0.getL ]]
do {z 0 ← z .setL (a); let (x 0, y0) = eα,β (z 0); return ((x 0, y0), x 0.getL)}</p>
          <p>[[ (CSetPL)(eα,β) ]]
do {let (x , y) = eα,β (z ); (x 0, y0) ← (x , y).setL a; return ((x 0, y0), x 0.getL)}</p>
          <p>[[ definition of (x , y).setL ]]
do {let (x , y) = eα,β (z ); x 0 ← x .setL a; let b = x 0.getR; y0 ← y.setL b; return ((x 0, y0), x 0.getL)}
[[ (CSetGetL) for α ]]
do {let (x , y) = eα,β (z ); x 0 ← x .setL a; let b = x 0.getR; y0 ← y.setL b; return ((x 0, y0), a)}
[[ definition of (x , y).setL ]]
do {let (x , y) = eα,β (z ); (x 0, y0) ← (x , y).setL a; return ((x 0, y0), a)}</p>
          <p>[[ (CSetPL)(eα,β); inline let ]]
do {z 0 ← z .setL a; return (eα,β (z 0), a)}
4.1</p>
        </sec>
      </sec>
      <sec id="sec-4-4">
        <title>Well-behavedness of cbx Composition</title>
        <p>Having defined a notion of composition for cbx, we must check that it has the properties one would expect, in
particular that it is associative and has left and right identities. However, as noted in the Introduction, we cannot
expect these properties to hold ‘on the nose’, but rather only up to some notion of behavioural equivalence. We
will now prove that cbx composition is well-behaved up to the equivalence ≡ introduced in Section 3 (Definition
3.5). Recall also the identity cbx ι (a) : A −− A introduced in Example 2.7.</p>
        <p>Theorem 4.10. Coalgebraic bx composition satisfies the following properties (where α, α0 : A −− B , β, β0 : B −− C ,
and γ, γ0 : C −− D, and all compositions are assumed well-defined):
identities: ι( α.getL) • α ≡ α and α • ι( α.getR) ≡ α
congruence: if α ≡ α0 and β ≡ β0 then α • β ≡ α0 • β0
associativity: (α • β) • γ ≡ α • (β • γ)</p>
        <p>To prove this, we typically need to exhibit a coalgebra morphism from some coalgebra α to a composition
β = ψ • ϕ. As the latter is defined implicitly by the equalizer eψ,ϕ – which is a monic coalgebra morphism from
β to γ = ψ ϕ – it is usually easier to reason by instead exhibiting a coalgebra morphism from α into γ = ψ ϕ,
and then appealing to the following simple lemma:
Lemma 4.11. Let F be wpp, and a : α → γ ← β : b a cospan of pointed F -coalgebra morphisms with b monic.
Then any m : α → β with b ◦ m = a is also a pointed F -coalgebra morphism. If a is monic, than so is m; and
for any q with (a, q) jointly monic, so is (m, q).</p>
        <p>Proof. One may show that Fb ◦ (β ◦ m) = Fb ◦ (Fm ◦ α) by a routine diagram-chase. Then using the fact that
F preserves the mono b, we may left-cancel Fb on both sides. Moreover, if m ◦ f = m ◦ f 0, then post-composing
with b (and applying b ◦ m = a) we obtain a ◦ f = a ◦ f 0; the result then follows.
Remark 4.12. In the following proof, we will often apply Lemma 4.11 in the situation where b is given by
an equalizer (such as eψ,ϕ, after Definition 3.5) which is also a coalgebra morphism, and where the coalgebra
morphism a also equalizes the relevant parallel pairs. Then we obtain the arrow m by universality, and the
Lemma ensures it is also a coalgebra morphism.</p>
        <p>We also use this simple fact in the first part of the proof (identities for composition):
Remark 4.13. A monic pointed coalgebra morphism h from α to α0 trivially yields a bisimulation by taking
(ζ, p, q ) = (α, id , h), and hence α ≡ α0; but not all bisimulations arise in such a way.</p>
        <p>We are now ready for the proof of Theorem 4.10.</p>
        <p>Proof. The general strategy is to prove that two compositions γ = δ • ϑ and γ0 = δ0 • ϑ0 are ≡-equivalent, by
providing a jointly monic pair of pointed coalgebra morphisms p, q from some ζ into δ ϑ and δ0 ϑ0 respectively,
which equalize the relevant parallel pairs. Lemma 4.11 and Remark 4.12 then imply the existence of a jointly
monic pair of pointed coalgebra morphisms m, m0 into δ • ϑ and δ0 • ϑ0, giving the required bisimulation. We
indicate the key steps (i), (ii), etc. in each proof below.
identities: We sketch the strategy for showing ι( α.getL) • α ≡ α, as the other identity is symmetric. We exhibit
the equivalence by taking α itself to be the coalgebra defining a bisimulation between α and ι( α.getL) • α.
To do this, one shows that (i) h = hα.getL, id i : X → A × X is a pointed coalgebra morphism from α to
the composition ι( α.getL) α defined on pairs, and (ii) h also equalizes the parallel pair ι( α.getL).getR ◦ π1
and α.getL ◦ π2 (characterising the equalizer and coalgebra morphism from ι( α.getL) • α to ι( α.getL) α
– see Remark 4.12). Moreover, h is easily shown to be monic. Hence by Lemma 4.11, h induces a pointed
coalgebra morphism from α to ι( α.getL) • α which is also monic (in C), and hence by Remark 4.13 we obtain
the required bisimulation.</p>
        <p>As for pointedness, the initial state of ι( α.getL) α is ( α.getL, α), and this is indeed h ( α) as required.
congruence: We show how to prove that right-composition (− • β) is a congruence: i.e. that α ≡ α0 implies
(α•β) ≡ (α0 •β). By symmetry, the same argument will show left-composition (α0 •−) is a congruence. Then
one may use the standard fact that ‘bisimulations compose (for wpp functors)’: given pointed bisimulations
between γ and δ, and δ and ε, one may obtain a pointed bisimulation between γ and ε – provided the
behaviour functor FAMC is wpp, which follows from our assumption that M is wpp. This allows us to deduce
that composition is a congruence in both arguments simultaneously, as required.</p>
        <p>So, suppose given a pointed bisimulation between α and α0: an FAMB -coalgebra (R, r ) with a jointly monic
pair p, p0 of pointed coalgebra morphisms from r to α, α0 respectively. One exhibits a bisimulation between
α • β and α0 • β as follows, by first constructing a suitable coalgebra (S , s), together with a jointly monic
pair (q , q 0) of coalgebra morphisms from s to the compositions α • β, α0 • β. To construct s, let ζ be the
equalizer of the following parallel pair – or equivalently, the pullback of r .getR and β.getL.</p>
        <p>S
ζ
/ R × Y
r.getR◦π1
β.getL◦π2
// B
One may then follow the steps (i)-(iii) in Section 4, where ζ and r play the role of the equalizer eα,β and β
respectively, to construct s, such that ζ is a coalgebra morphism from s to r β. Even though r is not a
coalgebraic bx, it satisfies the following weaker form of (CSetGetL) (and its R-version), sufficient for Lemma
4.7 to hold. (Here, we take j : R and a : A; there is a continuation version as in Lemma 4.3.)
(CSetGetL−)(r ) : do {j 0 ← j .setL a; return j 0.getL } = {j 0 ← j .setL a; return a }
To construct q : S → Pα,β , it is enough to show (i) the composition of the upper and right edges in the
following diagram equalizes the given parallel pair:</p>
        <p>S
q
Pα,β</p>
        <p>ζ
eα,β
/ R × Y</p>
        <p>p×id
β.getL◦π2
// B
By also showing that (ii) p × id is in fact a coalgebra morphism, we can then appeal to Lemma 4.11 to show
that q itself defines a coalgebra morphism from s into the composition α • β. One obtains the coalgebra
morphism q 0 from s to α0 • β in an analogous way. Finally, from p, p0 being jointly monic, and the fact that
eα,β is an equalizer, we obtain a proof that q , q 0 are jointly monic.
associativity: We follow the same strategy as we did for proving the identity laws: we may prove this law by
providing a pointed coalgebra morphism p from the LHS composition to the RHS, which is moreover monic.
We will do this in two stages: first, we show how to obtain an arrow p0 : P(α•β),γ → X × Pβ,γ making the
square in the following diagram commute; then, by applying Lemma 4.11 and Remark 4.12, we will show it
is a pointed coalgebra morphism from (α • β) • γ to α (β • γ), which is also monic.</p>
        <p>P(α•β),γ</p>
        <p>p0
X × Pβ,γ
e(α•β),γ
id×eβ,γ
/ Pα,β × Z</p>
        <p>f
/ X × (Y × Z )
id×(β.getR◦π1)
id×(γ.getL◦π2)
// X × C
In this diagram, the arrow f is defined by f (u, z ) = do {let (x , y ) = eα,β (u); return (x , (y , z ))}, but it
may also be expressed as f = assoc ◦ (eα,β × id ), where we write assoc for the associativity isomorphism
on products; the isomorphism, and the pairing with id , make it apparent that f is monic. Note that the
functor X × (−), being a right adjoint, preserves equalizers, and hence (id × eβ,γ ) is the equalizer of the
given parallel pair (and moreover monic).</p>
        <p>Following the proof strategy outlined above, to obtain p0 one must show that: (i) f ◦ e(α•β),γ equalizes the
parallel pair in the above diagram, ensuring existence of an arrow p0 making the square commute; (ii) the
equalizer id × eβ,γ is a pointed coalgebra morphism from α (β • γ) to α (β γ); and (iii) f is a pointed
coalgebra morphism from (α • β) γ to α (β γ). The facts (ii), (iii) allow us to apply Lemma 4.11 and
Remark 4.12, to deduce that p0 is a pointed coalgebra morphism, and moreover monic (using the fact that
f and e(α•β),γ are, and hence their composition too).</p>
        <p>The final stage of constructing the required arrow p : P(α•β),γ → Pα,(β•γ) is to show that: (iv) p0 equalizes
the parallel pair defining Pα,(β•γ) as shown below. Thus we obtain p as the mediating morphism into the
equalizer Pα,(β•γ); by Remark 4.12 it is a coalgebra morphism, and it is monic because p0 is monic.
(1)
P(α•β),γ</p>
        <p>p
Pα,(β•γ)</p>
        <p>p0
eα,(β•γ)
)
/ X × Pβ,γ</p>
        <p>α.getR◦π1
(β•γ).getL◦π2
// B</p>
        <p>This well-behavedness of composition allows us to define a category of cbx:
Corollary 4.14. There is a category Cbx• of pointed cbx, whose objects are pointed sets (A, a : A) – sets with
distinguished, “initial” values a – and whose arrows (A, a) → (B , b) are ≡-equivalence classes [α ] of coalgebraic
bx α : A −− B satisfying α.getL = a and α.getR = b.</p>
        <p>
          We now describe how this category is related (by taking C = Set and M = Id ) to the category of symmetric
lenses defined in [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ]. The point of departure is that cbx encapsulate additional data, namely initial values
α.getL, α.getR for A and B . The difference may be reconciled if one is prepared to extend SLs with such data
(and consider distinct initial-values to give distinct SLs, cf. the comments beginning Section 2.2):
Corollary 4.15. Taking C = Set and M = Id , Cbx• is isomorphic to a subcategory of SL, the category of
SL-equivalence-classes of symmetric lenses; and there is an isomorphism of categories Cbx• ∼= SL• where SL• is
the category of (SL-equivalence-classes) of SLs additionally equipped with initial left- and right-values.
5
        </p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Relating Coalgebraic and Monadic bx</title>
      <p>
        Here, we consider the relationship between our coalgebraic notion of bx and our previous monadic account [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
The latter characterised bx in terms of monadic get and set operations, where the monad was not assumed a
priori to refer to any notion of state – such as the monad StateT X M , abbreviated to TXM throughout this
paper. The monad was only restricted to this stateful form for defining bx composition; such monadic bx were
called StateTBX . By contrast, our coalgebraic bx are explicitly stateful from the outset. Therefore, to compare
cbx and mbx in a meaningful way, throughout this Section we restrict mbx to StateTBX , i.e. with respect to
the monad TXM (as in most of our leading examples of monadic bx). Moreover, as was necessary for defining
composition for such mbx, we also assume them to be transparent : the get operations neither change the state
nor introduce M -effects, i.e. getL = λx .return (f x , x ) for some f :: X → A (likewise getR).
      </p>
      <p>
        Finally, we also assume monadic bx A ⇐⇒ B have explicit initial states, rather than the more intricate process
of initialising by supplying an initial A- or B -value as in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
5.1
      </p>
      <sec id="sec-5-1">
        <title>Translating a Coalgebraic bx into a Monadic bx</title>
        <p>Given a cbx α : X → FAMB X , we can define its realisation, or “monadic interpretation”, [[α]] as a transparent
StateTBX with the following operations. (Following conventional Haskell notation, we overload the symbol ()
to mean the unit type, as well as its unique value.)
d=ef do {x ← get ; return (x .getL)}
d=ef do {x ← get ; return (x .getR)}
[[α]].setL : A → TXM () d=ef λa → do {x ← get ; x 0 ← lift (x .setL a); set x 0 }
[[α]].setR : B → TXM () d=ef λb → do {x ← get ; x 0 ← lift (x .setR b); set x 0 }
Here, the standard polymorphic functions associated with TXM , namely get : ∀α . TαM α, set : ∀α . α → TαM (),
and the monad morphism lift : ∀α . M α → TXM α (the curried form of the strength of M ) are given by:
get = λa → return (a, a) set = λa0 a → return ((), a0)
lift = λma x → do {a ← ma; return (a, x )}
Proposition 5.1. [[α]] indeed defines a transparent StateTBX over TXM .</p>
        <p>Lemma 5.2. The translation [[·]] – from cbx for monad M with carrier X , to transparent StateTBX with an
initial state – is surjective; it is also injective, using our initial assumption that return is monic.</p>
        <p>This fully identifies the subset of monadic bx which correspond to coalgebraic bx. Note that the translation [[·]]
is defined on an individual coalgebraic bx, not an equivalence class; we will say a little more about the respective
categories at the end of the next section.
5.2</p>
      </sec>
      <sec id="sec-5-2">
        <title>Composing Stateful Monadic bxs</title>
        <p>
          We will review the method given in [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ] for composing StateTBX , using monad morphisms induced by lenses on
the state-spaces. We show that this essentially simplifies to step (ii) of our definition in Section 4 above; thus,
our definition may be seen as a more categorical treatment of the set-based monadic bx definition.
Definition 5.3. An asymmetric lens from source A to view B , written l : A ⇒ B , is given by a pair of maps
l = (v , u), where v : A → B (the view or get mapping) and u : A × B → A (the update or put mapping). It is
well-behaved if it satisfies the first two laws (VU), (UV) below, and very well-behaved if it also satisfies (UU).
(VU)
u (a, (v a)) = a
(UV) v (u (a, b0)) = b0
(UU) u (u (a, b0), b00) = u (a, b00)
        </p>
        <p>
          Lenses have a very well-developed literature [6, 8, 16, 18, among others], which we do not attempt to recap
here. For more discussion of lenses, see Section 2.5 of [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ].
        </p>
        <p>
          We will apply a mild adaptation of a result in Shkaravska’s early work [
          <xref ref-type="bibr" rid="ref28">28</xref>
          ].
        </p>
        <p>Proposition 5.4. Let l = (v , u) : Z ⇒ X be a lens, and define ϑ l to be the following natural transformation:
ϑ l :: ∀α . (Z ⇒ X ) → TXM α → TZM α
ϑ ma d=ef do {z ← get ; (a0, x 0) ← lift (ma (v z )); z 0 ← lift (u (z , x 0)); set z 0; return a0 }
If l is very well-behaved, then ϑ l is a monad morphism.
l2 = (v2, u2) : (X × Y ) ⇒ Y
v2 (x , y ) = y
u2 ((x , y ), y 0) = (x , y 0)
This gives us a cospan of monad morphisms left = ϑ (l1) : TXM →. T(MX ×Y ) ←. TYM : ϑ (l2) = right , allowing us to
embed computations involving state-space X or Y into computations on the combined state-space X × Y .</p>
        <p>
          Now suppose we are given two StateTBX t1 : A ⇐⇒TXM B , t2 : B ⇐⇒TYM C with
t1.getL :: TXM A t1.getR :: TXM B t2.getL :: TYM B t2.getR :: TYM C
t1.setL :: A → TXM () t1.setR :: B → TXM () t2.setL :: B → TYM () t2.setR :: C → TYM ()
In [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ], we used left , right to define t1 # t2, a composite StateTBX with state-space X × Y , as follows:
(t1 # t2).get L = left (t1.get L) (t1 # t2).get R = right (t2.get R)
(t1 # t2).set L a = do {left (t1.set L a); b ← left (t1.get R); right (t2.set L b)}
(t1 # t2).set R c = do {right (t2.set R c); b ← right (t2.get L); left (t1.set R b)}
We then defined the subset, X on Y , of X × Y given by B -consistent pairs, and argued that t1 # t2 preserved
B -consistency – hence its state-space could be restricted from X × Y to X on Y . We will use the notation t1 • t2
for the resulting composite StateTBX .
        </p>
        <p>In the context of coalgebraic bx, we made this part of the argument categorical by defining X on Y to be a
pullback, and formalising the move from the pairwise definition α β to the full composition α • β by step (iii) of
Section 4. Given the 1-1 correspondence between transparent StateTBX and cbx given by Lemma 5.2, this may
be considered to be the formalisation of the monadic move from the composite t1 # t2 on the product state-space
to the composite t1 • t2 on the pullback.</p>
        <p>This allows us to state our second principal result, namely that the two notions of composition – coalgebraic
bx (as in Definition 4.4) and StateTBX – may be reconciled by showing the pairwise definitions coherent:
Theorem 5.5. Coherence of composition: The definitions of StateTBX and coalgebraic bx composition on
product state-spaces are coherent: [[α]] # [[β]] = [[α β]]. Hence, the full definitions (on B -consistent pairs) are also
coherent: [[α]] • [[β]] = [[α • β]].</p>
        <p>Proof. The operations of the monadic bx [[α]] at the beginning of Section 5.1, and the computation ϑ (v , u) ma,
may be re-written in do notation for the monad M rather than in StateT X M , as follows:
[[α]].getL : TXM A [[α]].setL : A → TXM () ϑ (v , u) ma : ∀α . TZM α
[[α]].getL = λx → return (x .getL) [[α]].setL a = λx → do {x 0 ← x .setL a; return ((), x 0)}
ϑ (v , u) ma = λz → do {(a0, s0) ← ma (v z ); let z 0 = u (z , x 0); return (a0, z 0)}
Applying ϑ to the lenses l1 and l2 gives the monad morphisms left and right as follows:
left = ϑ (l1) : ∀α . TXM α → T(MX ×Y ) α
left = λmxa (x , y ) → do { (a0, x 0) ← mxa x ; return (a0, (x 0, y )) }
right = λmya (x , y ) → do {(a0, y 0) ← mya y ; return (a0, (x , y 0)) }</p>
        <p>right = ϑ (l2) : ∀α . TYM α → T(MX ×Y ) α
This allows us to unpack the operations of the composite [[α]] # [[β]] to show they are the same as [[α
β]].</p>
        <p>
          Again, this result concerns individual cbx, and not the ≡-equivalence classes used to define Cbx•. We now
comment on how one may embed the latter into a category of transparent StateTBX . In [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ] (Theorem 26),
we defined an equivalence on StateTBX (∼, say) given by operation-respecting state-space isomorphisms, and
showed that •-composition is associative up to ∼. In line with Corollary 4.14, one obtains a category Mbx• of
∼-equivalence-classes of transparent StateTBX , and initial states as at the start of Section 5).
        </p>
        <p>Translating this into our setting (by reversing [[·]] from Lemma 5.2), one finds that two transparent StateTBX
are ∼-equivalent iff there is an isomorphism of pointed coalgebra morphisms between their carriers – which is
generally finer than ≡. Therefore, we cannot hope for an equivalence-respecting embedding from Cbx• to Mbx•.
However, we may restrict ≡ to make such an embedding possible:
Corollary 5.6. Let ≡! be the equivalence relation on coalgebraic bx given by restricting ≡ to bisimulations whose
pointed coalgebra morphisms are isomorphisms; and let Cbx!• be the category of equivalence-classes of cbx up to
≡!. Then there is an isomorphism Cbx!• =∼ Mbx•.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Conclusions and Further Work</title>
      <p>In our search for unifying foundations of the field of bidirectional transformations (bx), we have investigated a
number of approaches, including monadic bx, building on those of (symmetric) lenses and relational bx.</p>
      <p>We have given a coalgebraic account of bx in terms of intuitively simple building blocks: two data sources
A and B ; a state space X ; operations on X to observe (getL, getR) and update (setL, setR) each data source;
an ambient monad M of additional computational effects; and a collection of laws, entirely analogous to those
in existing bx formalisms. Moreover, these structures, being defined categorically, may be interpreted in a wide
variety of settings under very modest assumptions about the underlying category C.</p>
      <p>Initial states were handled by introducing pointed coalgebras and bisimulations. A more elegant approach
would be to work in the category I / C of pointed objects from the outset – i.e. pairs (A, a : I → A) of an
object of C and an initial value a. Coalgebra morphisms and bisimulations are then automatically pointed,
and the assumption of initial B -consistency used in Section 4 ((i)) is enforced at a type level. However, lifting
exponentials (and strong monads) from C into I / C is rather delicate; we leave the details for future work.</p>
      <p>Our definition allows a conceptually more direct, if technically slightly subtle, treatment of composition – in
which the state space, defined by a pullback, captures the idea of communication across a shared data source,
via the idea of B -consistent pairs. Our proof techniques involved reasoning about composition by considering
operations defined on such pairs. We defined an equivalence on cbx based on coalgebraic bisimulation, and
showed that composition does indeed define a category, up to equivalence. The notion of bisimulation improves
on existing, more ad-hoc definitions, such as that of symmetric lens equivalence, and we take this as further
evidence for the suitability of our framework and definitions.</p>
      <p>
        We described several concrete instantiations of the general definition of bisimulation, given by varying the effect
monad M . Coarser equivalences may be suitable for modelling non-deterministic bx, and could be introduced
via alternative methods such as [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]; but we do not have space to explore this further here.
      </p>
      <p>
        It is also worth investigating the relationship between our coalgebraic formulation of bx, and the spans of
lenses considered by Johnson and Rosebrugh [
        <xref ref-type="bibr" rid="ref20">20</xref>
        ]. A coalgebraic bx may be seen as a generalisation to a span of
‘monadic lenses’ or ‘M -lenses’, allowing effectful updates. However, in defining equivalence for spans of lenses,
Johnson and Rosebrugh consider an additional condition, namely that the mediating arrow between two spans,
witnessing equivalence, is a lens in which the get arrow is a split epi. It is unclear to us the relationship between
this condition, and pointed coalgebraic bisimulation. We leave such investigations to future work.
      </p>
      <p>
        Another area to explore is combinatory structure for building larger cbx out of smaller pieces, in the style of
existing work in the lens community. Some examples were given in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] – of which bx composition was by far the
most challenging to formulate – and we expect the other combinators to apply routinely for cbx as well, along
the same lines as [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. One would expect coalgebraic bisimulation to be a congruence for these combinators; it
would be interesting to investigate whether the work of Turi and Plotkin [
        <xref ref-type="bibr" rid="ref33">33</xref>
        ] can help here.
      </p>
      <p>
        We set great store by the fact that our definitions are interpretable in categories other than Set; we hope
thereby to incorporate richer, more intensional structures, such as delta lenses [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], edit lenses [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ] and ordered
updates [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ] in our framework, and not merely the state-based extensional bx we have considered so far. We also
hope to explore the connections between our work and existing coalgebraic notions of software components [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ],
and techniques for composing coalgebras [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ].
      </p>
      <p>
        Acknowledgements An extended, unpublished abstract [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] of some of the results here was presented
at CMCS 2014; we thank the participants there for useful feedback. Our work is supported by the UK
EPSRC-funded project A Theory of Least Change for Bidirectional Transformations [
        <xref ref-type="bibr" rid="ref32">32</xref>
        ] (EP/K020218/1,
EP/K020919/1); we are grateful to our colleagues for their support, encouragement and feedback during the
writing of the present paper.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>F.</given-names>
            <surname>Abou-Saleh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Cheney</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Gibbons</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>McKinna</surname>
          </string-name>
          ,
          <string-name>
            <given-names>and P.</given-names>
            <surname>Stevens</surname>
          </string-name>
          .
          <article-title>Notions of bidirectional computation and entangled state monads</article-title>
          .
          <source>In MPC</source>
          ,
          <year>June 2015</year>
          . To appear. Extended version available at http://groups. inf.ed.ac.uk/bx/bx-effects-tr.
          <source>pdf.</source>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>F.</given-names>
            <surname>Abou-Saleh</surname>
          </string-name>
          and
          <string-name>
            <given-names>J.</given-names>
            <surname>McKinna</surname>
          </string-name>
          .
          <article-title>A coalgebraic approach to bidirectional transformations</article-title>
          .
          <source>In CMCS. ETAPS</source>
          ,
          <year>2014</year>
          . Talk abstract.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>J.</given-names>
            <surname>Ad</surname>
          </string-name>
          ´amek, S. Milius,
          <string-name>
            <given-names>L. S.</given-names>
            <surname>Moss</surname>
          </string-name>
          , and
          <string-name>
            <given-names>L.</given-names>
            <surname>Sousa</surname>
          </string-name>
          .
          <article-title>Well-pointed coalgebras</article-title>
          .
          <source>Logical Methods in Computer Science</source>
          ,
          <volume>9</volume>
          (
          <issue>3</issue>
          ),
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>L. S.</given-names>
            <surname>Barbosa</surname>
          </string-name>
          .
          <article-title>Towards a calculus of state-based software components</article-title>
          .
          <source>J. UCS</source>
          ,
          <volume>9</volume>
          (
          <issue>8</issue>
          ):
          <fpage>891</fpage>
          -
          <lpage>909</lpage>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Cheney</surname>
          </string-name>
          ,
          <string-name>
            <surname>J. McKinna</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Stevens</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Gibbons</surname>
          </string-name>
          , and
          <string-name>
            <given-names>F.</given-names>
            <surname>Abou-Saleh</surname>
          </string-name>
          .
          <article-title>Entangled state monads (extended abstract)</article-title>
          .
          <source>In Terwilliger and Hidaka</source>
          [
          <volume>31</volume>
          ].
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>K.</given-names>
            <surname>Czarnecki</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. N.</given-names>
            <surname>Foster</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Hu</surname>
          </string-name>
          ,
          <string-name>
            <surname>R.</surname>
          </string-name>
          <article-title>L¨ammel, A. Schu¨rr, and</article-title>
          <string-name>
            <given-names>J. F.</given-names>
            <surname>Terwilliger</surname>
          </string-name>
          .
          <article-title>Bidirectional transformations: A cross-discipline perspective</article-title>
          .
          <source>In ICMT</source>
          , volume
          <volume>5563</volume>
          <source>of LNCS</source>
          , pages
          <fpage>260</fpage>
          -
          <lpage>283</lpage>
          . Springer,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Diskin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Xiong</surname>
          </string-name>
          , and
          <string-name>
            <given-names>K.</given-names>
            <surname>Czarnecki. From</surname>
          </string-name>
          state
          <article-title>- to delta-based bidirectional model transformations: the asymmetric case</article-title>
          .
          <source>JOT</source>
          ,
          <volume>10</volume>
          :6:
          <fpage>1</fpage>
          -
          <lpage>25</lpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J. N.</given-names>
            <surname>Foster</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. B.</given-names>
            <surname>Greenwald</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. T.</given-names>
            <surname>Moore</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. C.</given-names>
            <surname>Pierce</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Schmitt</surname>
          </string-name>
          .
          <article-title>Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem</article-title>
          .
          <source>ACM TOPLAS</source>
          ,
          <volume>29</volume>
          (
          <issue>3</issue>
          ):
          <fpage>17</fpage>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>J.</given-names>
            <surname>Gibbons</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Hinze</surname>
          </string-name>
          .
          <article-title>Just do it: Simple monadic equational reasoning</article-title>
          .
          <source>In ICFP</source>
          , pages
          <fpage>2</fpage>
          -
          <lpage>14</lpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>J.</given-names>
            <surname>Gibbons</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Johnson</surname>
          </string-name>
          .
          <article-title>Relating algebraic and coalgebraic descriptions of lenses</article-title>
          .
          <source>ECEASST</source>
          ,
          <volume>49</volume>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>H. P.</given-names>
            <surname>Gumm</surname>
          </string-name>
          .
          <article-title>Functors for coalgebras</article-title>
          .
          <source>Algebra Universalis</source>
          ,
          <volume>45</volume>
          (
          <issue>2-3</issue>
          ):
          <fpage>135</fpage>
          -
          <lpage>147</lpage>
          ,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>H. P.</given-names>
            <surname>Gumm</surname>
          </string-name>
          .
          <article-title>Copower functors</article-title>
          .
          <source>TCS</source>
          ,
          <volume>410</volume>
          (
          <issue>12</issue>
          ):
          <fpage>1129</fpage>
          -
          <lpage>1142</lpage>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <surname>I. Hasuo.</surname>
          </string-name>
          <article-title>The microcosm principle and compositionality of GSOS-based component calculi</article-title>
          .
          <source>In Algebra and Coalgebra in Computer Science</source>
          , pages
          <fpage>222</fpage>
          -
          <lpage>236</lpage>
          . Springer,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>I.</given-names>
            <surname>Hasuo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Jacobs</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Sokolova</surname>
          </string-name>
          .
          <article-title>Generic trace semantics via coinduction</article-title>
          .
          <source>CoRR, abs/0710.2505</source>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>S. J.</given-names>
            <surname>Hegner</surname>
          </string-name>
          .
          <article-title>An order-based theory of updates for closed database views</article-title>
          . Ann. Math. Art. Int.,
          <volume>40</volume>
          :
          <fpage>63</fpage>
          -
          <lpage>125</lpage>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>M.</given-names>
            <surname>Hofmann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. C.</given-names>
            <surname>Pierce</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D.</given-names>
            <surname>Wagner</surname>
          </string-name>
          .
          <article-title>Symmetric lenses</article-title>
          .
          <source>In POPL</source>
          , pages
          <fpage>371</fpage>
          -
          <lpage>384</lpage>
          . ACM,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>M.</given-names>
            <surname>Hofmann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. C.</given-names>
            <surname>Pierce</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D.</given-names>
            <surname>Wagner</surname>
          </string-name>
          .
          <article-title>Edit lenses</article-title>
          .
          <source>In POPL</source>
          , pages
          <fpage>495</fpage>
          -
          <lpage>508</lpage>
          . ACM,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Hu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Schurr</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Stevens</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J. F.</given-names>
            <surname>Terwilliger</surname>
          </string-name>
          . Dagstuhl seminar 11031:
          <article-title>Bidirectional transformations (BX)</article-title>
          .
          <source>SIGMOD Record</source>
          ,
          <volume>40</volume>
          (
          <issue>1</issue>
          ):
          <fpage>35</fpage>
          -
          <lpage>39</lpage>
          ,
          <year>2011</year>
          . DOI:
          <volume>10</volume>
          .4230/DagRep.1.1.42.
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <given-names>B.</given-names>
            <surname>Jacobs</surname>
          </string-name>
          and
          <string-name>
            <given-names>J.</given-names>
            <surname>Rutten</surname>
          </string-name>
          .
          <article-title>A tutorial on (co)algebras and (co)induction</article-title>
          .
          <source>Bulletin EATCS</source>
          ,
          <volume>62</volume>
          :
          <fpage>222</fpage>
          -
          <lpage>259</lpage>
          ,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          [20]
          <string-name>
            <given-names>M.</given-names>
            <surname>Johnson</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Rosebrugh</surname>
          </string-name>
          .
          <article-title>Spans of lenses</article-title>
          .
          <source>In Terwilliger and Hidaka</source>
          [
          <volume>31</volume>
          ].
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          [21]
          <string-name>
            <given-names>E.</given-names>
            <surname>Moggi</surname>
          </string-name>
          .
          <article-title>Computational lambda-calculus and monads</article-title>
          .
          <source>In LICS</source>
          , pages
          <fpage>14</fpage>
          -
          <lpage>23</lpage>
          . IEEE Computer Society,
          <year>1989</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          [22]
          <string-name>
            <given-names>E.</given-names>
            <surname>Moggi</surname>
          </string-name>
          .
          <article-title>Notions of computation and monads</article-title>
          .
          <source>Inf. Comput.</source>
          ,
          <volume>93</volume>
          (
          <issue>1</issue>
          ):
          <fpage>55</fpage>
          -
          <lpage>92</lpage>
          ,
          <year>1991</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref23">
        <mixed-citation>
          [23]
          <string-name>
            <given-names>G. D.</given-names>
            <surname>Plotkin</surname>
          </string-name>
          and
          <string-name>
            <given-names>J.</given-names>
            <surname>Power</surname>
          </string-name>
          .
          <article-title>Notions of computation determine monads</article-title>
          .
          <source>In FOSSACS</source>
          , volume
          <volume>2303</volume>
          <source>of LNCS</source>
          , pages
          <fpage>342</fpage>
          -
          <lpage>356</lpage>
          . Springer,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref24">
        <mixed-citation>
          [24]
          <string-name>
            <given-names>J.</given-names>
            <surname>Power</surname>
          </string-name>
          and
          <string-name>
            <given-names>O.</given-names>
            <surname>Shkaravska</surname>
          </string-name>
          .
          <article-title>From comodels to coalgebras: State and arrays</article-title>
          .
          <source>ENTCS</source>
          ,
          <volume>106</volume>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref25">
        <mixed-citation>
          [25]
          <string-name>
            <given-names>J.</given-names>
            <surname>Power</surname>
          </string-name>
          and
          <string-name>
            <given-names>H.</given-names>
            <surname>Watanabe</surname>
          </string-name>
          .
          <article-title>An axiomatics for categories of coalgebras</article-title>
          .
          <source>ENTCS</source>
          ,
          <volume>11</volume>
          :
          <fpage>158</fpage>
          -
          <lpage>175</lpage>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref26">
        <mixed-citation>
          [26]
          <string-name>
            <given-names>J.</given-names>
            <surname>Rutten</surname>
          </string-name>
          .
          <article-title>Universal coalgebra: a theory of systems</article-title>
          .
          <source>Theor. Comput. Sci.</source>
          ,
          <volume>249</volume>
          (
          <issue>1</issue>
          ):
          <fpage>3</fpage>
          -
          <lpage>80</lpage>
          ,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref27">
        <mixed-citation>
          [27]
          <string-name>
            <given-names>A.</given-names>
            <surname>Schu</surname>
          </string-name>
          <article-title>¨rr and</article-title>
          <string-name>
            <given-names>F.</given-names>
            <surname>Klar</surname>
          </string-name>
          .
          <article-title>15 years of triple graph grammars</article-title>
          .
          <source>In ICGT</source>
          , volume
          <volume>5214</volume>
          <source>of LNCS</source>
          , pages
          <fpage>411</fpage>
          -
          <lpage>425</lpage>
          . Springer,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref28">
        <mixed-citation>
          [28]
          <string-name>
            <given-names>O.</given-names>
            <surname>Shkaravska</surname>
          </string-name>
          .
          <article-title>Side-effect monad, its equational theory and applications</article-title>
          . Seminar slides available at: http://www.ioc.ee/~tarmo/tsem05/shkaravska1512-slides.pdf,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref29">
        <mixed-citation>
          [29]
          <string-name>
            <given-names>A.</given-names>
            <surname>Sokolova</surname>
          </string-name>
          .
          <article-title>Probabilistic systems coalgebraically: A survey</article-title>
          .
          <source>TCS</source>
          ,
          <volume>412</volume>
          (
          <issue>38</issue>
          ):
          <fpage>5095</fpage>
          -
          <lpage>5110</lpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref30">
        <mixed-citation>
          [30]
          <string-name>
            <given-names>P.</given-names>
            <surname>Stevens</surname>
          </string-name>
          .
          <article-title>Bidirectional model transformations in QVT: Semantic issues and open questions</article-title>
          .
          <source>SoSyM</source>
          ,
          <volume>9</volume>
          (
          <issue>1</issue>
          ):
          <fpage>7</fpage>
          -
          <lpage>20</lpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref31">
        <mixed-citation>
          [31]
          <string-name>
            <given-names>J.</given-names>
            <surname>Terwilliger</surname>
          </string-name>
          and S. Hidaka, editors.
          <source>BX Workshop</source>
          . http://ceur-ws.
          <source>org/</source>
          Vol-
          <volume>1133</volume>
          /#bx,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref32">
        <mixed-citation>
          [32]
          <string-name>
            <given-names>TLCBX</given-names>
            <surname>Project</surname>
          </string-name>
          .
          <article-title>A theory of least change for bidirectional transformations</article-title>
          . http://www.cs.ox.ac.uk/ projects/tlcbx/, http://groups.inf.ed.ac.uk/bx/, 2013-
          <fpage>2016</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref33">
        <mixed-citation>
          [33]
          <string-name>
            <given-names>D.</given-names>
            <surname>Turi</surname>
          </string-name>
          and
          <string-name>
            <given-names>G.</given-names>
            <surname>Plotkin</surname>
          </string-name>
          .
          <article-title>Towards a mathematical operational semantics</article-title>
          .
          <source>In LICS</source>
          , pages
          <fpage>280</fpage>
          -
          <lpage>291</lpage>
          . IEEE, Computer Society Press,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>