0% found this document useful (0 votes)
30 views12 pages

Plotki and Turi - Towards - A - Mathematical - Operational - Semantics

Uploaded by

jtpaasch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views12 pages

Plotki and Turi - Towards - A - Mathematical - Operational - Semantics

Uploaded by

jtpaasch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Towards a Mathematical Operational Semantics

Daniele Turi* Gordon Plotkint


[email protected]> [email protected]>
Department of Computer Science
Laboratory for Foundations of Computer Science
University of Edinburgh, The King’s Buildings
Edinburgh EH9 352, Scotland

Abstract mapped into a suitable semantic domain endowed with


an operation for each construct of the language. Both
W e present a categorical theory of ‘well-behaved’ operational and denotational semantics are necessary
operational semantics which aims at complementing for a complete description of a programming language:
the established theory of domains and denotational se- the former for specifying the execution of the programs
mantics to form a coherent whole. I t is shown that, i f and the latter for reasoning about them in terms of
the operational rules of a programming language can be abstract, mathematical entities. It is therefore funda-
modelled as a natural transformation of a suitable gen- mental that a denotational semantics be adequate, ie
eral form, depending on functorial notions of syntax that it determines the operational behaviour of pro-
and behaviour, then one gets the following for free: an grams [24].
operational model satisfying the rules and a canonical, For languages without variable binding, but possibly
internally f u l l y abstract denotational model which sat- multi-sorted, a denotational model can be seen as a
isfies the operational rules. The theory is based on dis- C-algebra, where C is the signature of the language
tributive laws and bialgebras; it specialises to the known corresponding to the basic constructs. The programs
classes of well-behaved rules for structural operational themselves form the initial such E-algebra and the cor-
semantics, such as GSOS. responding unique homomorphism from the programs
to the denotational model is called initial algebra se-
mantics [121.
Introduction The semantic domain, ie the carrier of the denota-
tional model, can often be regarded as the final solu-
tion of a domain equation X E B ( X ) , for a suitable
Operational semantics, a fundamental tool in lan- ‘behaviour’functor B. In other words, the semantic do-
guage design and verification, provides a formal de- main is the final B-coalgebra. The transition relations
scription of the behaviour of programs. It is often may also be seen as B-coalgebras and, therefore, so
defined in terms of atomic, elementary transitions, de- can the intended operational model of a language. The
scribing local behaviour. Mathematically, these trans- corresponding unique coalgebra homomorphism, given
itions can be modelled as the elements of a relation, the by finality, from the intended operational model to
intended operational model of the language. A con- the semantic domain is called final coalgebra semantics
venient way of specifying such a transition relation i s [ 2 , 231; under suitable assumptions on B,it is fully ab-
by induction on the structure of the programs, starting stract with respect to behavioural equivalence. When
from suitable operational rules for the basic constructs initial algebra and final coalgebra semantics coincide,
of the language [Zl]. one has an adequate denotational semantics [23].
Traditionally, operational semantics is contrasted Adequacy proofs can be quite demanding, hence
with the mathematical interpretation of programs
general criteria ensuring adequacy are of interest.
called denotational semantics, where programs are
For process algebras, as used for specifying non-
*Research supported by EuroFOCS. deterministic and concurrent programs [17, 5 ] ? there
Research supported by an EPSRC Senior Fellowship. exist syntactic restrictions on the format of the oper-

1043-6871/97 $10.00 0 1997 IEEE 280


Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
ational rules which ensure that bisimulation [17] is a here is that the functor B cofreely generates a comonad
congruence. Among the rules in these formats, GSOS D which should correspond to the global behaviours
rules [B] are the best known and (negative) tree rules of the language. The comonad D, is a lifting of this
[ll]are the most general. In [22], the ‘processes as comonad D to the E-algebras, ie to the denotational
terms’ method, based on such a congruence result, is models. However, one can still speak of the opera-
presented which allows for the systematic derivation of tional monad defined by some abstract tree rules be-
adequate denotational models from ‘tyft rules’ [13], a cause a general theorem shows that liftings of D to the
class of rules equivalent to tree rules. E-algebras and liftings of T to the B-coalgebras are in
We present here a categorical reformulation and gen- 1-1correspondence.
eralisation of the above adequacy meta-results. First, In fact, these liftings are also in 1-1correspondence
we show that certain sets R of GSOS rules can be with the distributive laws X of the monad T over the
modelled as natural transformations [RIdepending on comonad D., which generalise both abstract GSOS and
the functorial notions of signature C and behaviour abstract tree rules. One is led now to consider the bial-
B. Next, it is shown that the mapping RI-) [RI is gebras of such distributive laws. When X corresponds
an essentially 1-1 correspondence. The naturality of to some abstract operational rules p, the A-bialgebras
[RIaccounts for the syntactic restrictions on the oc- can be seen as combinations of operational and denota-
currences of meta-variables in GSOS rules and provides tional models which satisfy the rules. Henceforth they
a categorical explanation of their good behaviour. are called p-models; they specialise to the GSOS mod-
The first advantage of the above approach is that els of 6251 and to models of tree rules (with an appro-
the GSOS rules can be modelled not only in Set, but priate definition).
also in every category with enough structure such as The primary fact about pmodels is that, from res-
the category of cpos and continuous functions used in ults in [15], it easily follows that the forgetful functors
denotational semantics. This is a step towards bridging to each of the categories of denotational and opera-
the gap between operational and domain theory. tional models have adjoints. One adjunction implies
A second advantage is that the mathematical mod- that there exists an initial pmodel -the intended oper-
elling of the rules is a useful semantic tool in the in- ational model T,(O)for the initial algebra of programs.
vestigation of syntactic formats. For instance, in See By the definition of morphism of pmodels, this also
the ‘dual’ of the type of natural transformation cor- implies that every gmodel is adequate with respect to
responding to GSOS also corresponds to an interesting the intended operational model in the sense that the
format, namely the safe tree rules: these form a natural behaviour of the programs can be determined from any
subclass of (negative) tree rules which always possess a gmodel up to a generalised, coalgebraic notion [4, 161
satisfying transition relation. Interestingly, the failure of bisimulation.
to fit the class of (simple negative) tree rules in the The other adjunction implies that there exists a final
present approach brought to light a slight inaccuracy p-model - the canonical denotational model D, (1)over
in the literature and, eventually, led to the discovery the final coalgebra of abstract, global behaviours. It
of the safe tree rules. is necessarily adequate; further, it is internally fully
A third advantage is that by varying C and B a wide abstract with respect to coalgebraic bisimulation. The
variety of notions of program constructs and behaviour derivation of this final model specialises to the above
can be accommodated. (See also [30].) Further, one mentioned processes-as-terms method.
can study abstract notions of operational rules p, such The unique homomorphism from the initial to the
as ‘abstract GSOS’ and ‘abstract tree rules’, applicable final pmodel is both the initial algebra and final coal-
to languages other than process algebras and whose gebra semantics for the abstract rules p. It is called
properties can be studied in general. here universal semantics; it is the most abstract com-
In this theory we assume that C freely generates positional interpretation of programs preserving beha-
a monad T which is thought of as corresponding to vioural distinctions. Moreover, if the behaviour functor
the syntax of the language. The first result is that B satisfies a certain mild condition, every pmodel has
such abstract operational rules p induce an operational a greatest (generalised) bisimulation which, moreover,
monad T, lifting the monad T to the B-coalgebras, ie is a (generalised) congruence. This specialises to the
to the operational models, in the sense that its action fact that bisimulation is a congruence for GSOS and
on the carriers is the same as the monad T . for tree rules.
If p is of abstract tree rules form rather than ab- The generalised, coalgebraic notion of bisimulation
stract GSOS, then, by duality, one first coinductively considered here is to be understood as the behavioural
derives a denotational comonad D,. The assumption equivalence corresponding to the functor B under con-

281
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
sideration. It might take forms quite different from empty set. In general, the type B of the behaviour of
ordinary (strong) bisimulation. For instance, for the the above language is
behaviour functor in [14] it specialises to the much
coarser (complete) trace equivalence. As a corollary, BX = (?fix)" (2)
one has an abstract format of rules ensuring that trace the (covariant) functor mapping a set X to the set of
equivalence is a congruence [30].

-
functions from A to finite subsets of X .
To some extent, one can also deal with weak bisimu- Let x and 9 range over X , range over (PfiXIA, and
lation in this setting. As shown, eg in [13], weak bisim- let us write a {XI,. . . ,z,} for the function from A to
ulation for a given set of rules can be reduced to strong PfiX mapping a to { X I , 2,) and all other elements
~ ~ ~

bisimulation by adding three special rules for the T- of A to the empty set. Then, for each operator U of the
action. (See also [3].) These rules are in the tyft/tyxt signature, the corresponding rules can be modelled as
format, but they can be compiled into safe tree rules, a function
hence the present theory can be applied. This way of
dealing with weak bisimulation is quite indirect, but ].[I : (xx ( P ~ x ) ~ d) (PfiTX)"
~ ~ ~ ~ ~ ( ~ )
that just reflects the absence of an established denota-
tional model for it. A more direct treatment of weak as follows.
bisimulation might arise following [9]. [nil] = ae.O
I[ .PI
n(x7 = a- {x}
1 The Motivating Example: GSOS
ix' II Y I x' E P(a))
Consider the language with signature C consisting of (%P)U II ] ( Y , P ' ) = a U
a constant symbol 'nil', a set of unary action prefixing { x II Y' I Y' E P'(4
operators indexed by a finite set A of actions ranged Using the universal property of coproducts, these func-
over by a , and a binary parallel composition operator tions can then be glued into a single function, say
')I7. This signature freely generates, for every set X of
variables x,the set T X of terms t given by the abstract [R]x1 LI ( u A ( X x B X ) ) LI ( X x B X 1 2 + B T X
grammar
. I - x I nil I a . t I t 11 t
t ..- Note one has a function [R]xfor each set X of vari-
ables. In fact, one should think of the variables in the
This set T X is the carrier of the free C-algebra over X , rules as being "eta-variables'. Most importantly, the
where, in general, a C-algebra is given by a (carrier) set above definition of [R]x is natural in X : for every
Y and a function h mapping each operator U of arity n renaming of the variables (possibly involving equating
in the signature to a function of type Y" -+ Y . More some of the variables), first renaming and then apply-
concisely, the function h can be written as ing the rules is the same as first applying the rules and
then renaming. As shown in $5 and $7 the naturality
h: yar,tY(') +y of [RIexplains the good behaviour of R.
(1)
UEC More generally, let A, and Bi range over subsets of
A and let R be a set of rules of the form
using the disjoint union functor 'U' (coproduct in Set)
to glue the interpretation of the various operators to-
gether. \"I
Next, let the operational rules R inductively defin- U(X1, ...,2") At
ing the (labelled) transitions performable by the pro- which is image finite in the sense that there are finitely
grams of the above language be many rules for each operator CT in C and action c in A.
For every set X , one can associate to R a function
a.5 A-2 x3 x 1 4YP Y
x II Y 4 I1 Y x II Y -% 2 II Y' I[R]x: ( X x (PfiX)")aety(u)3 (PfiTX)A (4)
oEC
For instance, the simple program ( a .nil) 11 ( U . nil) can
either perform the action a becoming nil 11 (a' nil) or as follows. For all t in T X , c in A , x, in X , and B, in
perform a becoming ( a . n i l ) 11 nil. The (local) beha- ( R A A ,put
viour of this program can be modelled as the function
t E I[~]lX(~((~l,Pl),...~(~",P"))>~C~
from A to finite subsets of terms mapping a to the set
{ ( a .nil) 11 nil, (a nil) 11 nil} and all other actions to the if and only if the following condition holds.

282
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
Condition 1.1 There exists a (possibly renamed) rule Pi(a)= {y$ I j = 1,.. . ,m%}so that the xi and y$ are
(3) in R such that {Y:~, . . . ,yTm;} is a subset of &(a), all distinct. Then write a rule
for a in Ai, and ,&(b) is empty, for b in Bi. U

Note the function [R]x does not need to be natural in


the set X .
whenever t E P X ( ~ ( ~ I , P. .I. ),(xn,Pn)))(c)
, and
Definition 1.1 (GSOS [ 8 ] ) A GSOS rule is a rule of Ai = { a E A I Pi(a) # 0). Naturality ensures this is a
type (3) such that the xi and ya. are all distinct and, GSOS rule. It can be further shown that naturality
1.3
moreover, these are the only variables which can occur and the finiteness of A ensure that the resulting set of
in the term t. U rules is image finite. 0
Two sets of rules are called equivalent if they prove We do not understand this situation for infinite A ,
the same rules in the sense of [ll,Def. 2.51. although the above definition of [RIstill works.

Theorem 1.1 (GSOS is natural) There is a corres- 2 @SOS is Categorical


pondence between natural transformations of type
In this section, let C be a distributive category with
( X x (PfiX)A)"'itY(U)+ (PfiTWA (5) infinite coproducts and a commutative free semi-lattice
UtC monad Pf.The claim is that GSOS rules can be mod-
and image finite sets of GSOS rules for a signature C elled in every such category.
(over a fixed denumerably infinite set of variables V ) . Note, first, that to every signature C one can asso-
Moreover, this correspondence is 1-1 up to equivalence ciate an endofunctor on Set with the same name:
of sets of rules.
Proof. We just describe the correspondence. One UEC

direction is given by the above mapping R t)[RI.


Clearly, this definition also makes sense in C.
As for naturality, let us introduce some useful
abbreviation first: for every function f : X + X',
Next, rewrite BX = as B X = (1 P ~ x + )~,
which, again, makes sense in C: the power Y A is the
write f* for the function (Pfif)A, I' for the set
[Rnx(a((xl,P1),...,(Zn,Pn)))(C), and r' for the set
product nA Y , Pfis the free semi-lattice monad which
in Set is the relevant part of the endofunctor Pfi ob-
[R]x~(a((fxl,f*Pl),. * . , (fxn,f*Pn)))(c). Then the tained by removing the empty set, and '+' is just an-
claim is that
other notation for the binary coproduct.
It remains to generalise T . For this, let C be
an arbitrary endofunctor on C and let C-Alg be the
and, conversely, corresponding category of E-algebras: objects are
pairs ( X , h ) , where the 'carrier' X is an object and
2. tlt E r', 3t E r, t' =( ~ j ) ( t ) the 'structure' h : EX +
X is a morphism of
C ; the 'homomorphisms' f : ( X ,h) -+ ( X ' , h') are the
Consider the first clause. If t is in r then Con- morphisms f : X -+ X' between the carriers such that
dition 1.1 holds. Clearly, &(b) = 0 if and only f o h = h' o (Cf). If the forgetful functor
if ( f * & ) ( b ) = 0, and {yfl,. . . , y&,} C ,&(a) implies
{fyfl, . . . ,fy&;} 5 ( f * & ) ( a ) ,therefore ( T f ) ( t )is in U' : C-Alg 4 C ( X ,h) X
I", because the xi and yrmp are the only variables oc-
mapping E-algebras to their carriers, has a left adjoint
curring in the rule. For the second clause, one also uses
FE,then the corresponding monad
the fact that the xi and the yrm; in a GSOS rule are all
distinct, hence the value of I" does not depend on any T = UCFE (7)
of the possible identifications made by the renaming
function f . is the monad freely generated by C .
In the converse direction, given a natural transform- For finitary endofunctors C as the one above, it suf-
ation px of type ( 5 ) , one can define a set of rules as fices that C has w-colimits for the adjunction F C i U c
follows. Let V be 21, z 2 , . . . and let z 3 (yl, . . .,yk} to hold and T to be defined. Thus one can take T
be an abbreviation for x 4 y1,. . . ,x -% yk. Choose to be the monad freely generated by the endofunctor

283
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
E X = U U E C X""t"(u)m In Set, its value T X at a set Several examples illustrating the use of the general-
X is the set of terms corresponding to the operators ity of (8) are given in [30]. Here is a brief summary
o of the signature and with variables x in X ; the unit thereof. Firstly, the operational rules of deterministic
qx : X + T X is the insertion-of-variables function programs with exceptions and side-effects can be mod-
which maps a variable x in X to the same variable but elled instantiating (8) with the behaviour endofunctor
seen as a term; and the multiplication px : T 2 X + T X +
BX = (S. (1 X ) ) s , where S.Y is the copower Y. us
is the operation which allows one to plug terms into As shown below, the behavioural equivalence cor-
contexts ~ responding to B X = is bisimulation; a coarser
equivalence, namely trace equivalence, can be obtained
Theorem 2.1 For any image finite set R of GSOS by considering the endofunctor BX = 1 A . X on the +
rules, a natural transformation category SL(C) of semi-lattices in a category C. (This
is a simplified version of the behaviour in [14].) The
[RJJ
: (Xx (1+ PfX)A)apzty(o)-+ (1+ P f T X ) A program construct endofunctor to be considered then is
UEC E' : SL(C) -+SL(C), a monoidal generalisation of the
can be defined in the internal language of distributive endofunctor C on Cartesian categories. For instance,
categories with infinite coproducts and a commutative +
for the language of 81, C'X = 1 H A X ( X 8 X ) , +
free semi-lattice monad P'. In the case of Set it spe- where '8,is the tensor product of semi-lattices.
cialises to the transformation (4). Note that (8) can be instantiated to rules not only
for single-sorted languages but also for multi-sorted
Proof. The transformation IR]in (4)can be defined ones; it suffices to work with signatures (and beha-
categorically using: projections and injections, pairing viours) over 'power categories'.
and copairing, and the associativity, symmetry, unit, Finally, we briefly consider recursion. GSOS stands
and distributive laws for products and coproducts; the for 'SOS for non-deterministic programs with guarded
unique map to the final object 1; the unit and the free recursion9, because the full definition also allows for
structure of the monad T ; the join of free semi-lattices; definitions of programs by guarded recursion. In [30],
the unit and the strength of the commutative monad a functorial notion of guard is given which allows one
Pf. (The use of the strength depends on the assumption to generalise the definitions by guarded recursion to
that, because R is image finite and A is finite, for each abstract rules of type (8). Moreover, one can also treat
operator the set of rules is finite.) U unguarded recursion by realising the abstract rules, for
The characterisation of GSOS given by the above instance, in the category of cpos and partial continuous
theorem allows one, for instance, to realise GSOS rules functions and exploiting algebraic compactness. This
in the category of cpos and continuous functions as involves precomposing the endofunctor C with the lift-
used in domain theory, rather than in Set. ing endofunctor, so that one freely generates not only
finite but also partial and infinite terms, the latter be-
3 Abstract GSOS ing used to unfold recursive definitions of programs.

In general, given a Cartesian category C and arbit- 4 Coalgebras


rary functorial notions of program constructs C and
behaviour B on C, with C freely generating the syntax The intended operational model of a set of con-
T, one can define a corresponding abstract notion of crete GSOS rules is the least relation R C 2'0 x A x T0
operational rules as the natural transformations p of which satisfies the rules, where x 4 IC' stands for
type (2, a, IC') E R. In general, a relation of type X x A x X
C(1d x B ) + BT (8) is called a labelled transition system [21] with set of
states X and set of labels A.
We shall need the following characterisation For image finite sets of GSOS rules it suffices to con-
sider image finite transition systems, where, for each
Proposition 3.1 There is a 1-1 correspond- state and each action, the image of the transition re-
ence between natural transformations of type lation is a finite set. These are in 1-1 correspondence
C(1d x B ) + BT and those of type C(T x BT) =+- B T . with functions k : X + (PfiX)A as follows.
Proof. One direction of the correspondence is given by
the mapping p t)e = B p o p~ : C ( T x B T ) + BT, for
2 4 2' e IC! E @)(a) (9)
p : C(1d x B ) + B T . In the converse direction, simply If, as considered here, the set A is finite, then image
precompose e : C ( T x B T ) =+- BT with C ( q x Bq). U finite transition systems cut down to finitely branch-

284
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
ing transition systems, where for each state, the set of Let B be an endofunctor on a category C with kernel
outgoing transitions is finite. pairs and let the internal equality of a coalgebra (X, IC)
A function k : X -+ (PfiX)Ais a coalgebra of the be the kernel pair (in the underlying category C) of the
endofunctor BX = on Set. Formally, given an identity on its carrier X . One can easily prove that:
endofunctor B : C -+ C, a B-coalgebra is a pair (X, k),
where the carrier X is an object and the structure
k : X -+ BX is a morphism of C. One often identifies Proposition 4.1 (Strong Extensionality)
a coalgebra (X, k) with its structure k. Internal equality is the final B-bisimulation of
The B-coalgebras form a category B-Coalg, with ho- the final B-coalgebra. 0
momorphisms f : (X,k) + (X', k') the morphisms

f In general, final coalgebras need not exist, but if C


x-X' has a final object I, and the forgetful functor Ug has a
sight adjoint Gg : C -+ B-Coalg, then G g l is the final

BX - Bf
BX'
B-coalgebra. For the endofunctor BX = (PfiX)A on
Set, such a right adjoint Gg exists [6]. It follows [29,
$131 that the final coalgebra G g l is the set of rooted,
image finite trees, with branches labelled by a E A ,
f : X + X' between the carriers such that quotiented by (ordinary) bisimulation. This is the set
k' o f = (Bf) o k. Note the forgetful functor of 'abstract global behaviours', ie the (abstract) non-
deterministic processes.
UB : B-Coalg -+ C (X,kC) x Semantically, the above strong extensionality result
specialises then to the fact that such a final coalgebra
mapping coalgebras to their carriers. i s internally fully-abstract [l]with respect to bisimu-
For BX = the coalgebra homomorphisms lation, ie its largest bisimulation is the equality, hence
are, up to the correspondence (9), the same as the P- bisimilar elements are indistinguishable.
open morphisms of [16], where P is a suitable category
of finite sequences of actions. (Thus, for this choice
of B, B-Coalg is a proper subcategory of the standard 5 Operational Monads
category of transition systems [31].) As a consequence,
two transition systems are (strongly) bisimilar 1171 if
and only if there is a span of coalgebra homomorphisms Definition 5.1 Let T and B be endofunctors on the
between them. This leads to the following coalgebraic same category C. An endofunctor ? on the category
notion of bisimulation, a mild generalisation of the one of B-coalgebras lifts the endofunctor T to the B-
coalgebras if UB? = T U B , ie the diagram

-
in [4].
-
T
Definition 4.1 (Coalgebraic Bisimulation) A B- B-Coalg B-Coalg

iUB
bisimulation between two coalgebras (XI, kl ) and
( X 2 , k z ) of an endofunctor B is a triple (X,figf2)
such that such that there exists a coalgebra structure
k : X + BX making ((X, k), f ~f 2,) a span
C-C
T
y\ (Xl k)

commutes. (Cf [15].)


(Xl,k2) (X2,k2) When both T and ? are monads, ? lifts the
monad T to the B-coalgebras if the forgetful functor
of coalgebra homomorphisms f~ , f 2 . 0
UB : B-Coalg -+ C (together with the identity natural
One can form the category of B-bisimulations transformation) is a monad morphism [27] from ?,! to
between two coalgebras (XI,kl) and (X2, k2) of an T. 0
endofunctor B on a category C : the morphisms
9 . ( X , f l , f 2 ) + ( X p s f i , f ~a) r e t h o s e g : X - + X ' i i n C
(thus not necessarily coalgebra homomorphisms) such Remark 5.1 A monad ? lifts a monad T = (T,7,p )
that fi = f j o g, for i = 1,2. to the B-coalgebras if and only if Ug? = TUB and, for

285
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
every B-coalgebra k : X + B X , the diagram T,(k) : TX + BTX to be the unique map

QX
TX- CTX

B
\xq i
BTX+ C(TX x BTX)
ex
commutes El given by the above theorem.

Consider now T to be the monad freely generated Proposition 5.1 If the morphism ex is natural in X ,
by an endofunctor C. The adjunction F C i U ’ gives a then the above construction k e T,(k) extends to a
well-known structural recursion theorem which special- monad T, lifting T to the B-coalgebras.
ises to the ordinary recursion (or iteration) theorem for Proof. First one needs to prove that, for every coal-
natural numbers, covering the simplest form of prim- gebra homomorphism f : ( X , k ) + ( X ‘ , k ’ ) , T f is a
itive recursive functions, but not others such addition, coalgebra homomorphism, ie
multiplication, exponentiation, etc, which need para-
meters and ‘accumulators’. (By structural recursion T,(k‘) oTf = BTf oT,(k)
we mean definition by structural induction.) Here we
shall need the following ‘folklore’ structural recursion so that one can define T e f to be T f . For this,
theorem [20] with accumulators, ie with terms as para- simply note that both composites T~(lc’) o Tf and

-
meters of the recursive definition. BTf o T R ( ~fit) as the unique morphism
IX $X
X TX- CTX
T h e o r e m 5.1 (Structural Recursion) Let T be a
monad freely generated by an endofunctor C on a
Cartesian category C and let $x : CTX + TX be the
structure of the free C-algebra over an object X of e.
1 C ( i d ,!)

C(TX x BTX‘)
For all morphisms f : X + Y and h : C(TX x Y ) + Y
in C there exists a unique morphism f t : T X + Y in
C such that BTX’-
QX‘
I W69 4
C(TX’ x BTX‘)

given by Theorem 5.1, hence they must be equal. (The


naturality of e is essential here!)

Y - h
E(TX x Y )
Next, one has to verify that the endofunctor T,
lifts the operations of the monad T . From Re-
mark 5.1, it suffices to show that, for every coal-
gebra structure k : X + B X , T,(k) o qx = Bqx o k
and Tp(k) o p x = Bpx o T i ( k ) , ie the unit and the
commutes. multiplication of T are coalgebra homomorphisms. For
the unit, this is immediate by definition of the func-
tor T,, while for the multiplication one also needs to
Proof. Turn h into the E-algebra structure
use the naturality of p and the fact that p is defined
($x o C T ~h, ) : C ( T X x Y ) + T X x Y over the
by (ordinary) structural recursion on the free algebra
product T X x Y and then apply the ordinary structural
structure. 0
recursion theorem to it and (qx, f ) : X + TX x Y . U
Recall Proposition 3.1. For every map Definition 5.2 The operational monad induced by
some abstract operational rules p : C(1d x B) + BT,
is the monad Te corresponding to the composite nat-
ural transformation e = Bp o p~ : C(T x B T ) + BT.
and every coalgebra k : X + B X , define the coalgebra We write Tp for this monad. U

286
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
Let us try and understand the operational monad In particular, such a lifting can be obtained from nat-
T, when p = [RI,
for R a set of concrete GSOS rules. ural transformations
Firstly, applying p to TX amounts to instantiating
the meta-variables of the rules with the terms in TX.
p : CD 3 B(ld + E) (12)
Formally, in this way the term t in a GSOS rule (3) by dualising Proposition 3.1 and putting
might contain terms as variables: one needs to apply e = p o o C6 : CD + B ( D 4- ED). This is the de-
to it the multiplication of the term monad T in order notational comonad D, coinduced by p.
to ‘unbracket’ it and obtain an elementary term. This Let C freely generate a monad T. In the next sec-
is achieved here by composing ~ T with X Bpx. tion, Theorem 7.1 shows that liftings of the comonad
Next, recall the correspondence (9) between coal- D to the E-algebras are in 1-1 correspondence with lift-
gebras k : X + BX = (PfiX)Aand image finite trans- ings ~f the monad T to the B-coalgebras. Therefore,
ition systems. By regarding X as a set of constants if C corresponds to some program constructs and B to
rather than as a set of states, the correspondence (9) some behaviour, every natural transformation p as in
can also be seen as being between coalgebras and sets (12) defines also an operational monad, say Tp (with a
of 6-rules [8], ie axiom rules. Up to these two eorres- slight abuse of notation) ~

pondences, one can then check that k ~ -Tp(k) t is the As mentioned in $4? for the endofunctor
usual construction of a transition system for a finite BX = (PfiX)A on Set the adjunction UB-iGB
set of GSOS rules R and a possibly infinite (but image exists. The value of the corresponding cofree comonad
finite) set k of 6-rules. In particular, if X is the empty D = UBGB at a set X is the set of ‘global behaviours
set, hence k is the trivial coalgebra 0 : 0 + BO and with states x in X’.Formally, it is a quotient of the
T X = T0 is the set of closed terms, this construction set of rooted, image finite trees, with branches labelled
gives the intended operational model for the rules. by a E A , and nodes labelled by x E X; the quotient
These remarks hold for arbitrary rules of type (3) is taken with respect to a form of bisimulation taking
and, correspondingly, to possibly non-natural functions into account the name of the nodes [29, $131. The
I[R]lx.The naturality of GSOS ensures that T, i s an counit E : D + Id is the operation which extracts the
operational monad, which is essential for applying the root from a tree and the comultiplication 6 : D =+ D2
theory in $ 7 ~ is the operation which replaces the name of every node
in a tree by the subtree starting at that node.
6 ‘Dualising9GSOS: Tree Rules Next, consider rules of type

The duality between algebras and coalgebras can be


exploited to find a format of rules ‘dual’ to abstract
GSOS as follows. where the Xk, y i , zi, and wj are all variables, and I and
Let C and B be two endofunctors on a cocartesian J are countable, possibly infinite index sets. It is con-
category C and let D = (D,E , 6 ) be the cofree comonad venient to consider the dependency graph [13] of such
generated by B , that is, the forgetful functor UB has a a rule, namely the directed graph having the variables
right adjoint G B : C -+ B-Coalg and of the rule as nodes, zi -% y i , for i in 1 as ‘positive’
b.
D = UBGB (11) edges, and wj 4 as ‘negative’, targetless edges. A
rule of type (13) is well-founded if all backwards chains
By the dual of Theorem 5.1 and Definition 5.1, every of edges in its dependency graph are finite [13].
natural transformation
Definition 6.1 (Tree rules [lo, 111) A (simple
e : CD + B ( D + C O ) negative) tree rule is a well-founded rule of type (13)
coinductively defines a lifting D , of the comonad D to such that the x k and the y i are all distinct variables
the C-algebras: and are the only variables occurring in the rule (ie the
h
zi and wj are all occurrences of the x k and yi).
E-Alg >C-Alg A tree rule is safe if the term t either is a variable
z or is of the form xi,. . . ,xi)for some operator
d of the signature and some (not necessarily distinct)
variables 2: . &. I a 0

c-c Tree rules are more general than GSOS: they allow
D for ‘lookahead’, in that one can look not only at the

287
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
local behaviour (a single transition x --% y ) of the as the failure t o fit these latter rules in the present the-
states like in GSOS, but also at the global one, as in ory brought to light. In fact, the safe tree rules them-
x -% y --+ b
y'. (See [13] for some examples.) The selves have been suggested to us by Rob van Glabbeek
safety restriction does not affect the expressive power as a natural subclass of (negative) tree rules possessing
of the rules, provided one is allowed to add sufficiently a satisfying transition system.
many auxiliary operators to the signature.
A tree rule (13) has the property that its depend- 7 Combining Operational and Denota-
ency graph is equal t o the graph reachable from the tional Models
nodes X I ,. . . ,z,. Moreover, the subgraph reachable
from a node xk is a tree - the dependency tree with When T is the monad freely generated by an en-
root Xk. Let us call a set of tree rules allowed if it is an dofunctor C on a category C, then one can easily see
image finite set (in the sense of $1) of tree rules whose that the category E-Alg of algebras of the endofunc-
dependency trees are image finite. Then, an allowed tor 'c is isomorphic to the category T-Alg of algebras
set R of tree rules defines, for every X , a function of the monad T = (Tg17, p ) , with objects those morph-
isms h : T X + X in C such that h o q x = id and
[R]x: C D X + ( P E T X ) ~ (14 h o T h = h o p x . Dually, the category B-Coalg of B-
as follows. coalgebras is isomorphic to the category D-Coalg of
For all t in T X , c in A, and dk in D X , put coalgebras of the comonad D cofreely generated by B
[29, 571. The results in this section should be read up
t E IIRnx(.(dl,...,d,))(c) to these two isomorphisms of categories

if and only if there exists a (possibly renamed) rule C-Alg T-Alg B-Coaig S D-Coalg
(13) in R such that the root of d k is xk, for 1 5 IC 5 n,
and the dependency trees of the rule can be embedded "*' Distributive Laws
in the d k (where the convention is that a tree with a
b Given a monad T = ( T , q , p ) and a comonad
negative edge wj can be embedded into d k only if D = (D,E,S)on a category C, a distributive law [7] of
the variable in d k corresponding to wj does not have the T over the comonad D is a natural trans-
an outgoing edge labelled by b j ) . formation X : T D + DT satisfying the laws
Theorem 6.1 (Tree rules are natural) Let D be X O Q D = DQ X o p ~ =D p o X l - o T X
the comonad cofreely generated by the endofunctor
B X = ( P E x ) ~ on Set. and their dual
For every allowed set p of tree rules the function
[R]xin (14) is natural in X . T &= ET 0 X DX o AD oTS = 6~ o X

Proof. Similar to the proof of naturality in Theorem The following theorem may well be folklore.
1.1. Note the well-foundedness of tree rules is needed.
Theorem 7.1 For a monad T and a comonad D on
For instance, the non-well-founded rule with premise
x and conclusion a.x -%nil is not natural be- the same category, the following notions are mutually

-
2
cause: first applying [ a . ] to (x -% y ) and then renam- equivalent.
ing y as x yields a {z}, while the same operations 0 Distributive laws X of T over D .
but in the reverse order yield a {x,nil}, which fact
violates naturality. 0 o Liftings ? of T to the D-coalgebras.
In particular, if the rules in R are safe, the natural
transformation [RIis of type
Liftings 5 of to the T-algebras.
Proof. Given a distributive law A, one can define the
C D 3 (",(Id + E))A corresponding liftings as follows.
Therefore, for every allobed set R of safe tree rules T x ( k ) = Ax o T k Dx(h) = D h o Xx
there exists a transition system which satisfies the
rules, namely T p ( 0 ) where
, p = [R] and Tp is the cor- Conversely, consider a lifting ?-of the comonad
responding operational monad. Contrarily to what is D to the T-algebras, hence UDT = TUD. By
stated in [ll],this fails for (simple negative) tree rules, Lemma 1 in [15], this determines a distributive

288
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
law X of the monad T over the endofunctor model, and the pentagonal law (15) says that the com-
D as follows: first take the natural transforma- bination of the two models satisfies the rules p. Hence-
tion T E: UDFGD= TUDGD= T D T, then trans- * forth such bialgebras are called p-models.
-
pose it across the adjunction U0-l GD obtain-
*
ing 1:TGD GDT, and finally define A to be 7.3 Adequacy Meta-Results
VOX: U D T G D = TD 3 DT. It is easy to prove
that X actually is a distributive law over tke Consider the forgetful functor
whole comonad D. Dually, given a lifting D,
take 70 : D 3 DT = DUTFT = UTDFT, transpose it U’ : A-Bialg + D-Coalg (X, h, k) I+ (X, k)
across FTiUT obtaining : F T D 3 EFT,and define
X to be U T I : UTFTD = T D D T = UTEjFT. The which forgets the algebra structure of a A-bialgebra.
constructions are easily seen to be mutually inverse. 0
Theorem 7.2 U’ has a left adjoint, namely:
When T is syntax and D is (global) behaviour, the
type of the distributive law X might thought of as ‘the
most general type of well-behaved rules’. Note one can (X -% DX) I%
(T2X % TX +
(k)
DTX) TA

also consider monads T corresponding to algebraic the- Proof. Dualise Theorem 4 of [15]and apply it t o
ories, with equations between the derived operators.
(See [29, 8101 for an elementary example.) UX
D-Coaig- Dx-CoaIg
7.2 Bialgebras as Models

Given a distributive law X : T D jDT, one can con-


sider the category A-Bialg of A-bialgebras. Its objects C T-Alg
c---
UT
are pairs TX h,X -% DX of T-algebras and D-
coalgebras with a common carrier X which satisfy the where A-Bialg S Dx-Coalg by Remark 7.1. 0
following ‘pentagonal law’:
Corollary 7.1 The category of A-bialgebras has an
k 0 h = D h o Xx OTIC
initial object, namely FAO,where 0 is the trivial initial
(Cf [28].) This law makes h a coalgebra homomorph- D-coalgebra. 0
ism and k an algebra homomorphism. The morphisms In particular, there exists an initial pmodel, which
f : (X, h, k) -+ (XI, h’, IC‘) of A-Bialg are those morph- can be regarded as the intended operational model over
isms f : X + X’ between the carriers which are both the initial algebra of programs TO. This implies that
T-algebra and D-coalgebra homomorphisms. every pmodel M is adequate with respect to the inten-
ded operational model of p. Indeed, the unique pmodel
Remark 7.1 The A-bialgebras are the same as the a]-
homomorphism to M given by initiality is a denota-
gebras of the monad TAof Theorem 7.1, and, dually,
tional interpretation which preserves the behavioural
the same as the coalgebras of the comonad DA:
distinctions of the intended operational model. This
TA-Alg 2 A-Bialg % DA-Coalg makes M adequate.
Now, consider the ‘dual’ of UA,namely the functor
Remark 7.2 When X is the distributive law induced
by a finite set of concrete GSOS rules, the A-bialgebras UA : A-Bialg -+ T-Alg (X, h, k ) c) (X, h)
are the GSOS-models of [25]. 0
which forgets the D-coalgebra structure of a X-
Given a E-algebra h : E X -+ X , let h* : TX + X bialgebra. Correspondingly, the following is dual to
be its inductive extension to a T-algebra. When X is Theorem 7.2.
induced by some abstract operational rules p, no mat-
ter whether of type (8) or the dual (12), A-bialgebras Theorem 7.3 UA has a right adjoint, namely:
are equivalent to pairs E X h,X -% BX such that
(TX -% X ) %t (TDX D +
A(h)
DX 6x,D2X)
k o h = B(h*) o p x o E ( i d ,k ) (15)
Corollary 7.2 The category of A-bialgebras has a fi-
The algebra structure can be thought of as a denota- nal object, namely Gxl, where 1 is the trivial final
tional model, the coalgebra structure as an operational T-algebra. cl

289
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
In particular, there exists a final pmodel which is f i ture Work
the canonical denotational model for p; it has the final
D-coalgebra as carrier which, as mentioned in $4, is in- The major challenge ahead is the operational se-
ternally fully abstract with respect to B-bisimulation. mantics of the languages with variable binders, such
The construction 1 e G e l = ( D l , De(l),SI) general- as the n-calculus and the X-calculus. (At the moment,
ises the ‘processes as terms’ construction of [22], which by working in a suitable functor category, we are able
is a systematic method for deriving adequate denota- to give a functorial description of syntax with variable
tional models from ‘tyft rules’ [13] (a class of rules equi- binders, but it is not yet clear whether this fits our pur-
valent to the tree rules without negative premises [lo]). poses.) We would also like to obtain adequacy results
For more details, see [30]. when working in categories of partial maps.
There is an obvious question about Moggi’s compu-
Corollary 7.3 The unique (both by initiality and fi- tational monads [19] and our behaviour functors which
nality) homomorphism from the initial to the final p remains t o be investigated. In a different direction, we
model is both the initial algebra semantics and the final would like to understand the relationship between the
coalgebra semantics for p . 0 transitional approach considered here and others, such
as the the reductional one arising in the X-calculus and
The above, say, universal semantics for p is thus term-rewriting in general.
a compositional interpretation of the programs which Further developments of the present theory could
preserves their behavioural distinctions. In Set, the lead to applications in modular compiler development
latter means that two programs with the same univer- technology. Perhaps there will be a useful theory of
sal semantics are B-bisimilar. One can easily see that, the combination of operational semantics of different
under the additional hypothesis that B preserves weak languages (cf [18]). Again, perhaps one can relate the
pullbacks, the converse also holds: two programs have operational semantics of a language with that of its
the same universal semantics if and only if they are translation into another target language (cf [26]).
B-bisimilar. In other words:
Acknowledgements. Thanks to Marcel0 Fiore and
Corollary 7,4 If B preserves weak pullbacks, the uni-
Alex Simpson for discussions. Part of this study is
versal semantics associated to some abstract rules p is
based on the first author’s thesis; he wishes to thank
fully abstract with respect to B-bisimulation. 0
Jaco de Bakker and Bart Jacobs for their guidance.
Next, recall Definition 4.1: by replacing spans of
coalgebra homomorphisms with spans of T-algebra ho- References
momorphisms, one has a corresponding notion of T -
congruence which specialises to the ordinary notion S. Abramsky. A domain equation for bisimulation.
of congruence. Similarly, by considering spans of X- Information and Computation, 92:161-218, 1991.
bialgebra homomorphisms one has a notion of, say, X-
bicongruence and a corresponding category. We can P. Aczel. Non-well-founded sets. Number 14 in
ask then whether there exists a final bicongruence for Lecture Notes. CSLI, 1988.
a X-bialgebra. Now, if pullbacks of cospans of carri-
ers of B-coalgebras are B-bisimulations, then, by the P. Aczel. Final universes of processes. In Math-
universal property of pullbacks, a final B-bisimulation ematical Foundations of Programming Semantics,
between two coalgebras exists: it is the pullback of the Proc. 9th Int. Conf., volume 802 of LNCS, pages
respective unique coalgebra homomorphisms to the fi- 1-28. Springer-Verlag, 1994.
nal coalgebra. This is a T-congruence as well, because P. Aczel and N. Mendler. A final coalgebra the-
the forgetful functor UT : T-Alg -+ C creates limits. orem. In D.H. Pitt et al., editors, Proc. category
Therefore, by definition of final bialgebra:
theory and computer science, volume 389 of LNCS,
pages 357-365. Springer-Verlag, 1989.
Corollary 7.5 If B preserves weak pullbacks, then
every X-bialgebra has a final bicongruence. U J.C.M. Baeten and W.P. Weijland. Process Al-
gebra. Cambridge University Press, 1990.
In particular, the behavioural endofunctor B in (2) pre-
serves weak pullbacks, hence the above corollary spe- M. Barr. Terminal coalgebras in well-founded
cialises to the well-known fact that (strong) bisimula- set theory. Theoretical Computer Science,
tion is a congruence for GSOS and tree rules. 144(2):299-315, 1993.

290
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.
[7] Jon Beck. Distributive laws. In B. Eckmann, ed- [20] A. M. Pitts. Categorical logic. Technical Report
itor, Seminar on Triples and Categorical Homo- 367, University of Cambridge Computer Laborat-
logy Theory, volume 80 of Lecture Notes in Math- ory, May 1995.
ematics, pages 119-140. Springer-Verlag, 1969.
[21] G.D. Plotkin. A structural approach to opera-
B. Bloom, S. Istrail, and A.R. Meyer. Bisimulation tional semantics. Technical Report DAIMI FN-
can’t be traced. Journal of the ACM, 42(1):232- 19, Computer Science Department, Aarhus Uni-
268, jan 1995. A preliminary report appeared in versity, 1981.
Proc. 3rd LICS, pages 229-239,1988.
e221 J. Rutten. Processes as terms: non-well-founded
J.R.B. Cockett and D.A. Spooner. Categories for models for bisimulation. Mathematical Structures
synchrony and asynchrony. Electronic Notes in in Computer Science, 2:257-275, 1992.
Theoretical Computer Science, 1, 1995.
[23] J. Rutten and D. Turi. Initial algebra and final
W. Fokkink. The tyft/tyxt format reduces to tree coalgebra semantics for concurrency. In 9. de Bak-
rules. In M. Hagiya and J.C. Mitchell, editors, ker et al., editors, Proc. of the REX workshop
Proc. TACSgd, number 789 in LNCS, pages 440- A Decade of Concurrency - Reflections and Per-
453. Springer-Verlag, 1994. spectives, volume 803 of LNCS, pages 530-582.
Springer-Verlag, 1994.
W. Fokkink and R. van Glabbeek. Ntyftjntyxt
rules reduce to ntree rules. Information and Com- [24] D, Scott. Outline of a mathematical theory of
putation, 126(1):1-107 1996. computation. In Proc. 4th Annual Princeton Con-
ference on Inf. Sciences and Systems, pages 169-
J.A. Goguen, J.W. Thatcher, and E.G. Wagner.
176, 1970.
An initial algebra approach to the specification,
correctness and implementation of abstract data 1251 A.K. Simpson. Compositionality via cut-
types. In R.T. Yeh, editor, Current Trends an Pro- elimination: Hennessy-Milner logic for an arbit-
gramming Methodology, volume IV, pages 80-149. rary GSOS. In Proc. Tenth IEEE Symp. on Logic
Prentice Hall, 1978. In Computer Science, 1995.
J.F. Groote and F. Vaandrager. fhuAUred OP- [26] C. Stone and R. Harper. A type-theoretic account
erational semantics and bisimulation as a congru- of Standard ML 1996. Technical Report CMU-CS-
ence. Information and Computation, 100(2):202- 96-136, Computer Science Department, Carnegie-
260, 1992. Mellon University, 1996.
M.C.B. Hennessy and G.D. Plotkin. Full abstrac- [27] R. Street. The formal theory of monads. Journal
tion for a simple parallel programming language. ~fPure and Applied Algebra, 2:149-168, 1972.
In J. BeEvbf, editor, Broc. 8th MFCS, volume 74
of LNCS, pages 108-120. Springer-Verlag, 1979. [28] M.E. Sweedler. Hopf Algebras. W.A. Benjamin
Inc., New York, 1969.
P.T. Johnstone. Adjoint lifting theorems for cat-
egories of algebras. Bull. London Math. Soc., [29] D. Turi. Functorial Operational Semantics and
7:294-297, 1975. its Denotational Dual. PhD thesis, Free Uni-
versity, Amsterdam, June 1996. Accessible from
A. Joyal, M. Nielsen, and G. Winskel. Bisim- <http://www.dcs.ed.ac.uk/home/dt/>.
ulation and open maps. In Proc. Eighth IEEE
Symp. on Logic In Computer Science, pages 418- 1301 D. Turi. Categorical modelling of structural opera-
427, 1993. tional rules: case studies. Preprint, accessible from
< h t t p : //www. dcs. ed. ac .uk/home/dt/>, March
R. Milner. A Calculus of Communicating Systems, 1997.
volume 92 of LNCS. Springer-Verlag, 1980.
6311 G. Winskel and M. Nielsen. Models for concur-
E. Moggi. A category-theoretic account of pro- rency. In S. Abramsky et al., editors, Handbook
gram modules. Mathematical Structures in Com- of logic in computer science, volume 4. Clarendon
puter Science, 1, 1991. Press, Oxford, 1995.
E. Moggi. Notions of computation and monads.
Information and Computation, 93:55-92, 1991.

29 1
Authorized licensed use limited to: Georgetown University. Downloaded on October 01,2024 at 19:49:54 UTC from IEEE Xplore. Restrictions apply.

You might also like