ABSTRACT GSOS RULES AND A MODULAR

advertisement
Logical Methods in Computer Science
Vol. 9(3:28)2013, pp. 1–52
www.lmcs-online.org
Submitted
Published
Dec. 8, 2010
Sep. 27, 2013
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF
RECURSIVE DEFINITIONS
STEFAN MILIUS a , LAWRENCE S. MOSS b , AND DANIEL SCHWENCKE c
a
Lehrstuhl für Theoretische Informatik, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
e-mail address: mail@stefan-milius.eu
b
Department of Mathematics, Indiana University, Bloomington, IN, USA
e-mail address: lsm@cs.indiana.edu
c
Institute of Transportation Systems, German Aerospace Center (DLR), Braunschweig, Germany
e-mail address: daniel.schwencke@dlr.de
Abstract. Terminal coalgebras for a functor serve as semantic domains for state-based
systems of various types. For example, behaviors of CCS processes, streams, infinite trees,
formal languages and non-well-founded sets form terminal coalgebras. We present a uniform account of the semantics of recursive definitions in terminal coalgebras by combining
two ideas: (1) abstract GSOS rules ℓ specify additional algebraic operations on a terminal
coalgebra; (2) terminal coalgebras are also initial completely iterative algebras (cias). We
also show that an abstract GSOS rule leads to new extended cia structures on the terminal coalgebra. Then we formalize recursive function definitions involving given operations
specified by ℓ as recursive program schemes for ℓ, and we prove that unique solutions exist
in the extended cias. From our results it follows that the solutions of recursive (function)
definitions in terminal coalgebras may be used in subsequent recursive definitions which
still have unique solutions. We call this principle modularity. We illustrate our results by
the five concrete terminal coalgebras mentioned above, e. g., a finite stream circuit defines
a unique stream function.
1. Introduction
Recursive definitions are a useful tool to specify infinite system behavior. For example,
Milner [38] proved that in his calculus CCS, one may specify a process uniquely by the
equation
P = a.(P |c) + b.0 .
(1.1)
2012 ACM CCS: [Theory of computiation]: Semantics and reasoning—Program semantics—
Categorical semantics; Semantics and reasoning—Program reasoning—Program specifications.
Key words and phrases: recursion, semantics, completely iterative algebra, coalgebra, distributive law.
b
This work was partially supported by a grant from the Simons Foundation (#245591 to Lawrence Moss).
l
LOGICAL METHODS
IN COMPUTER SCIENCE
c
DOI:10.2168/LMCS-9(3:28)2013
CC
S. Milius, L. S. Moss, and D. Schwencke
Creative Commons
2
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
In other words, the process P is the unique solution of the recursive equation x = a.(x|c) +
b.0. Another example is the shuffle product on streams of real numbers defined uniquely by
a behavioral differential equation [42]:
(σ ⊗ τ )0 = σ0 · τ0
(σ ⊗ τ )′ = σ ⊗ τ ′ + σ ′ ⊗ τ .
(1.2)
σ′
Here the real number σ0 is the head of σ, and
is the tail; the operation + is the componentwise addition of infinite streams. Besides these and other examples in the theory of
computation, we shall mention below recursive specifications which are also important in
other realms; we shall consider non-well-founded sets [3, 14], a framework originating as a
semantic basis for circular definitions. Operations on non-well-founded sets can be specified
uniquely by recursive function definitions. For example, we prove that the equation
xky = { xky ′ | y ′ ∈ y } ∪ { x′ ky | x′ ∈ x } ∪ { x′ ky ′ | x′ ∈ x, y ′ ∈ y }
(1.3)
has a unique solution viz. a binary operation k on the class of all non-well-founded sets,
which is reminiscent of parallel composition in process calculi. It is the aim of this paper to
develop abstract tools and results that explain why there exist unique solutions to all the
aforementioned equations.
Terminal coalgebras. The key observation is that process behaviors, streams and nonwell-founded sets constitute terminal coalgebras (C, c : C → HC) for certain endofunctors
H on appropriate categories. The functor H describes the type of behavior of a class of
state-based systems—the H-coalgebras—and the terminal coalgebra serves as the semantic
domain for the behavior of states of systems of type H. All of the theory and examples in
this paper pertain to terminal coalgebras.
Abstract GSOS rules. Let us return to the case of CCS operations to situate the work
in a historical context. In the case of CCS one obtains algebraic operations on processes
using structural operational semantics (sos) [2]. Operations are specified by operational
rules such as
a
a
x → x′
y → y′
a
x|y → x′ |y ′
exhibiting the interplay between the operation and the behavior type. Syntactic restrictions
on the rule format then ensure nice algebraic properties of the specified operations, e. g.,
GSOS rules [15] ensure that bisimilarity is a congruence. Turi and Plotkin gave in their
seminal paper [39] a categorical formulation of GSOS rules, and they show how an abstract
GSOS rule gives rise to a distributive law of a monad over a comonad, where the monad
describes the signature of the desired algebraic operations and the comonad arises from the
“behavior” functor H. Later Lenisa et al. [31] proved that abstract GSOS rules correspond
precisely to distributive laws of a free monad M over the cofree copointed functor on the
behavior functor H. In this paper we shall not need the original formulation of GSOS rules,
and so the reader who is unfamiliar with this formulation will not be at a loss. What will
be important are the categorical generalizations which we call abstract GSOS rules, and we
begin with that topic in the next section. The theme of this paper is that abstract GSOS
rules, either in a form close to the original one or in a more general one that we introduce,
account for many interesting recursive definitions on terminal coalgebras in a uniform way.
These include all of the examples we mentioned above, and many more.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
3
Modularity. An important methodological goal in this paper is that our results should
be modular. What we mean is that we want results which, given a class of algebras for
endofunctors, enable us to expand the algebraic structure of an algebra from that class by
a recursively defined operation, and stay inside the class. Thus the results will iterate.
We mentioned above that our results all had to do with terminal coalgebras, and so the
reader might wonder how this idea of modularity could possibly apply. The answer is that
a classical result due to Lambek [29] implies that the structure c : C → HC of a terminal
coalgebra is an isomorphism. The corresponding inverse c−1 : HC → C turns C into an
H-algebra. Moreover, we are typically interested to start with an algebraic structure on C
that is already extended by additional operations. For example, in the case of the shuffle
product σ ⊗ τ of streams, the definition of ⊗ uses the stream addition operation + on the
right-hand side. So the definition is made on the algebra
(C,
(σ0 , σ ′ ) 7→ σ,
σ, τ 7→ σ + τ )
consisting of the set of streams of reals, its structure c−1 as an H-algebra, and its structure
as an algebra for X ×X given by componentwise addition. Returning to modularity, we aim
to isolate an appropriateness condition on algebra structures expanding the inverse c−1 of
the terminal coalgebra structure with the property that given an appropriate structure and
a definition in a certain format, the definition specifies a new operation in a unique way,
and if we add this operation to the given algebra structure, the resulting algebra structure
on C is again appropriate. This is what we will call modularity, and precise formulations of
appropriateness may be found in the Summaries 5.10 and 5.20.
Completely iterative algebras. The desired class of algebras mentioned in the previous
paragraph is formed by completely iterative algebras (cias). Complete iterativity means that
recursive equations involving algebraic operations corresponding to the H-algebra structure
c−1 can be solved uniquely (see Definition 3.1). For example, let HΣ be a polynomial
endofunctor on Set arising from a signature of operation symbols with prescribed arity. In
this case a cia is a Σ-algebra A in which every system of recursive equations
xi = t i
(i ∈ I),
(1.4)
where ti is either a single operation symbol applied to recursion variables (i. e., ti =
σ(xi1 , . . . , xin ) for an n-ary σ from Σ) or ti = a ∈ A, has a unique solution. It can
then be proved that more general equation systems involving (almost) arbitrary Σ-terms
on the right-hand side and even recursive function definitions have unique solutions in a
cia [33, 35]. Continuing, it was shown in [33] that the inverse c−1 : HC → C of the structure of the terminal coalgebra turns C into the initial cia for H. However, as we mentioned
previously, cia structures for the “behavior” functor H are not sufficient to yield the existence and uniqueness of solutions in our motivating examples; these involve additional
algebraic operations not captured by H. These operations are | and + in the CCS process
definition above, the stream addition + in (1.2), and union ∪ in the example (1.3) from
non-well-founded set theory.
Extended cia structures. We will show how the abstract GSOS rules of Turi and Plotkin
extend the structure of an initial cia for H (alias terminal H-coalgebra). This then allows us
to equip the initial cia with the desired additional operations such that circular definitions
of elements of the carrier admit a unique solution, e. g., the equation σ = 1.(σ + σ) (for
4
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
streams) defining the stream of powers of 2 or our first example (1.1) for CCS processes
above.
The first steps in this direction were taken in Bartels’ thesis [13] (see also [12]); he
systematically studies definition formats giving rise to distributive laws and shows how
to solve parameter-free first order recursive equations involving operations presented by a
distributive law; Uustalu et al. [47] present the dual of this result.
We review some basic material on abstract GSOS rules and the solution theorem of
Bartels in Section 2. In Section 3 we extend these solution theorems to equations with
parameters, thereby combining them with our previous work on cias in [4, 33]. More
concretely, given an abstract GSOS rule (equivalently, a distributive law of the free monad
M over the cofree copointed functor H × Id) we prove in Theorems 3.5 and 3.6 that the
terminal H-coalgebra carries the structure of a cia for HM and for M HM , respectively.
These results show how to construct new structures of cias on C using an abstract GSOS
rule. This improves Bartels’ result in the sense that recursive equations may employ constant
parameters in the terminal coalgebra.
In Section 4 we obtain new ways to provide the semantics of recursive definitions by
applying the existing solution theorems from [4, 33, 35] to the new cia structures. For
example, we consider solutions of recursive program schemes. Classical recursive program
schemes [20] are function definitions such as
f (x) = F (x, G(f (x)))
(1.5)
defining a new function f recursively in terms of given ones F, G. In [35] is was shown
how recursive program schemes can be formalized categorically. It was proved that every
guarded 1 recursive program scheme has a unique (interpreted) solution in every cia HA → A,
where the functor H captures the signature of given operations. This solution is an algebra
structure V A → A, where V captures the signature of recursively defined operations. As a
new result we now prove in Theorem 4.8 that the unique solution extends the structure of
the given cia for H to a cia for the sum H + V ; this yields modularity of unique solutions
of recursive program schemes.
Extended formats of function definition. The recursive program schemes from [35] do
not capture recursive function definitions like the one of the shuffle product in (1.2) above
or the one for the operation k from (1.3) above on non-well-founded sets. So in Section 5 we
provide results that do capture those examples. We introduce for an abstract GSOS rule ℓ
two formats of recursive program schemes w. r. t. ℓ: ℓ-rps and a variant called sandwiched
ℓ-rps (ℓ-srps, for short). They give a categorical formulation of recursive function definitions
such as (1.2) and (1.3) that refer not only to the operations provided by the behavior functor
H but also to additional given operations specified by the abstract GSOS rule ℓ. We will
also see that ℓ-srps’s allow specifications which go beyond the format of abstract GSOS
rules. In Theorems 5.14 and 5.23 we prove that every ℓ-(s)rps has a unique solution in
the terminal coalgebra C. Moreover, we show that this solution extends the cia structure
on C. This again gives rise to a modularity principle: operations defined uniquely by ℓ(s)rps’s can be used as givens in subsequent (sandwiched) rps’s (we make this precise in the
Summary 5.20). This modularity of taking solutions of recursive specifications of operations
does not appear in any previous work in this generality.
1Guardedness is a mild syntactic restriction stating that terms on right-hand sides of equations do not
have a newly defined function at their head.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
5
A set of examples. Finally, in Section 6 we demonstrate the value of our results by
instantiating them in five different concrete applications: (1) CCS-processes—we explain
how Milner’s solution theorem from [38] arises as a special case of Theorem 3.6, and we also
show how to define new process combinators recursively from given ones; (2) streams of real
numbers—here we prove that every finite stream circuit defines a unique stream function,
we obtain the result from [42] that behavioral differential equations specify operations on
streams in a unique way as a special instance of our Theorem 5.14, and we show how to solve
recursive equations uniquely that cannot be captured by behavioral differential equations
by applying Theorem 5.23; (3) infinite trees—we obtain the result from [45] that behavioral
differential equations have unique solutions as a special case of Theorem 5.14; (4) formal
languages—here we show how operations on formal languages like union, concatenation,
complement, etc. arise step-by-step using the modularity of unique solutions of ℓ-rps’s,
and how languages generated by grammars arise as the unique solutions of flat equation
morphisms in cias; (5) non-well-founded sets—we prove that operations on non-well-founded
sets are uniquely determined as solutions of ℓ-(s)rps’s.
Related Work. As already mentioned, Turi’s and Plotkin’s work [39] was taken further
by Lenisa, Power and Watanabe in [30, 31]. Fiore and Turi [19] applied the mathematical operational semantics to provide semantics of message-passing process calculi such as
Milner’s π-calculus. But these papers do not consider the semantics of recursive definitions.
Turi [46] gives a treatment of guarded recursion. He does not isolate the notion of
a solution of a recursive specification and whence does not prove that a solution exists
uniquely. In addition that paper does not deal with recursive function definitions as we do
here.
Jacobs [25] shows how to apply Bartels’ result to obtain the (first order) solution theorems from [4, 33]. Capretta et al. [17] work in a dual setting and generalize the results
of [12] beyond terminal coalgebras and they also obtain the (dual of) the solution theorem
from [4, 33] by an application of their general results. Our Theorems 3.5 and 3.6 are similar
to results in [17], but in the later sections we extend the work in [12] in a different direction
by considering parameters in recursive definitions. So our results in the present paper go
beyond what can be accomplished with previous work.
Modularity in mathematical operational semantics has been studied before in [40, 31].
These papers show how to combine two different specifications of operations over the same
behavior by performing constructions at the level of distributive laws. This gives an abstract explanation of adding operations to a process calculus. At the heart of our proof of
Theorem 5.14 lies a construction similar to the combination of two distributive laws that
arises by taking the coproduct of the corresponding monads. However, while in the coproduct construction of [40, 31] the two distributive laws are independent of each other, our case
is different because the operations specified by the second distributive law interact with the
operations specified by the first one.
Much less related to our work is the work of Kick and Power [27] who show how to
combine distributive laws of one monad over two sorts of behavior possibly interacting with
one another.
To the best of our knowledge the results on modularity of solutions of recursive specifications we present are new.
The present paper is a completely revised version containing full proofs of the conference
paper [37].
6
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
2. Abstract GSOS Rules and Distributive Laws
We shall assume some familiarity with basic notions from category theory such as functors,
(initial) algebras and (terminal) coalgebras, and monads, see e. g. [32, 41, 5].
Suppose we are given an endofunctor H on some category A describing the behavior
type of a class of systems. In our work we shall be interested in additional algebraic
operations on the terminal coalgebra C for H. The type of these algebraic operations is
given by an endofunctor K on A, and the algebraic operations are given by an abstract
GSOS rule (cf. [39, 30, 31]). Our goal is to provide a setting in which recursive equations
with operations specified by abstract GSOS rules have unique solutions. We now review
the necessary preliminaries.
Assumption 2.1. Throughout the rest of this paper we assume that A is a category with
binary products and coproducts, H : A → A is a functor, and that c : C → HC is its
terminal coalgebra. We also assume that K : A → A is a functor such that for every object
X of A there exists a free K-algebra M X on X.
Remark 2.2. (1) We denote by ϕX : KM X → M X and ηX : X → M X the structure and
universal morphism of the free K-algebra M X. Recall that the corresponding universal
property states that for every K-algebra a : KA → A and every morphism f : X → A there
exists a unique K-algebra homomorphism h : (M X, ϕX ) → (A, a) such that h · ηX = f .
(2) Free algebras for the functor K exist under mild assumptions on K. For example,
whenever K is an accessible endofunctor on Set it has all free algebras M X (see e. g. [9]).
(3) As proved by Barr [11] (see also Kelly [26]), the existence of free K-algebras as stated in
Assumption 2.1 implies that there is a free monad on K. Indeed, M is the object assignment
of a monad with the unit given by ηX from item (1) and the multiplication µX : M M X →
M X given as the unique homomorphic extension of idM X . Also ϕ : KM → M is a natural
transformation and
Kη
ϕ
/M )
/ KM
κ = (K
is the universal natural transformation of the free monad M . Notice that for complete
categories all free monads arise from free algebras in this way.
b → A be the unique K-algebra
Notation 2.3. For any K-algebra a : KA → A, let b
a : KA
homomorphism with b
a · ηA = idA . Then b
a is the structure of an Eilenberg-Moore algebra
for M . Notice also that
κA
/ M A ba / A) .
a = (KA
(2.1)
Example 2.4. In our applications the functor K will be a polynomial functor on Set most
of the time. In more detail, let A = Set and let Σ = (Σn )n∈N be a signature of operation
symbols with prescribed arity. The polynomial functor KΣ associated with Σ is given by
a
KΣ X =
Σn × X n .
n∈N
Algebras for the functor KΣ are precisely the usual Σ-algebras and the free monad MΣ
assigns to a set X the Σ-algebra MΣ X of Σ-terms (or finite Σ-trees) on X, where a Σtree on X is a rooted and ordered tree with leaves labeled by constant symbols from Σ or
elements of X and with inner nodes with n children labeled in Σn .
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
7
Definition 2.5. [39] An abstract GSOS rule is a natural transformation
ℓ : K(H × Id) → HM .
Remark 2.6. (1) The name “abstract GSOS” is motivated by the fact that for H the set
functor Pfin (A × −) (whose coalgebras are labeled transition systems) and K a polynomial
set functor, a natural transformation ℓ as in Definition 2.5 corresponds precisely to a transition system specification with operational rules in the GSOS format of Bloom, Istrail and
Meyer [15]; this was proved by Turi and Plotkin [39].
(2) As proved by Lenisa et al. [30, 31], abstract GSOS rules are in one-to-one correspondence
with distributive laws of the free monad M over the copointed functor H × Id. More
precisely, recall from loc. cit. that a copointed functor (D, ε) is a functor D : A → A
equipped with a natural transformation ε : D → Id. Also, notice that H × Id together
with the projection π1 : H × Id → Id is the cofree copointed functor on H. Further recall
that a distributive law of a monad (M, η, µ) over a copointed functor (D, ε) is a natural
transformation λ : M D → DM such that the following diagrams commute:
λ
/ DM
D❆
M D❆
❆❆
⑥
❆
⑥
❆
Dη
ηD ⑥
⑥⑥
❆
❆❆
❆❆
⑥⑥
⑥⑥
❆
⑥
❆
⑥
❆
⑥
❆
Mε ❆
~⑥⑥
~⑥⑥ εM
λ
/ DM
MD
M
MMD
Mλ
/ M DM
λM
/ DM M
Dµ
µD
λ
MD
(2.2)
/ DM
Then to give an abstract GSOS rule ℓ : K(H × Id) → HM is equivalent to giving a
distributive law λ of the monad M over the copointed functor H × Id.
Theorem 2.7. [13, 39] Let ℓ be an abstract GSOS rule. There is a unique structure
b : KC → C of a K-algebra on the terminal H-coalgebra C such that the square below
commutes:
KC
Khc,idC i
/ K(HC × C)
ℓC
/ HM C
Hb
b
b
/ HC
c
C
(2.3)
Remark 2.8. (1) In the terminology of [13, 39] the triple (C, b, c) is a model of the abstract
GSOS rule ℓ; in fact, it is the terminal one.
(2) For the distributive law λ : M (H × Id) → (H × Id)M from Remark 2.6(2) corresponding
to the abstract GSOS rule ℓ we have the following commutative diagram (see e. g. [13],
Lemma 3.5.2, where this is formulated for A = Set):
MC
M hc,idC i
/ M (HC × C)
λC
/ (H × Id)M C
(H×Id)b
b
b
b
C
(2.4)
/ HC × C
hc,idC i
(3) In some of the examples below an abstract GSOS rule ℓ will arise from a natural
transformation ℓ′ : K(H × Id) → HK as
ℓ = ( K(H × Id)
ℓ′
/ HK
Hκ
/ HM ) .
8
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
In this case Diagram (2.3) can be simplified; indeed, b : KC → C is then the unique
morphism such that the diagram below commutes:
KC
Khc,idC i
ℓ′C
/ K(HC × C)
/ HKC
Hb
b
c
C
/ HC
Definition 2.9. For every abstract GSOS rule ℓ we will call the algebra structure b : KC →
C from Theorem 2.7 the ℓ-interpretation in C.
Examples 2.10. We review a couple of examples of interest in this paper where A = Set.
We shall elaborate on these examples in Section 6 and present two more examples.
(1) Processes. We shall be interested in Milner’s CCS [38]. Let κ be an infinite cardinal
and Pκ be the functor assigning to the set X the set of all Y ⊆ X with |Y | < κ. Here we
consider the functor HX = Pκ (A× X) where A is some fixed alphabet of actions. Following
Milner [38], we assume that for every a ∈ A we also have a complement ā ∈ A (so that
¯ = a) and a special silent action τ ∈ A.
ā
To describe the terminal coalgebra for Pκ (A × X) we first recall the description of the
terminal coalgebra for the finite power set functor Pfin by Worrell [49]: it is carried by the
set of all strongly extensional finitely branching trees, where an unordered tree t is called
strongly extensional if two subtrees rooted at distinct children of some node of t are never
bisimilar as trees. Similarly, the terminal coalgebra for the countable power set functor Pc
is carried by the set of all strongly extensional countably branching trees, see [44]. The
technique by which this result is obtained in loc. cit. generalizes to the functor Pκ (A × X)
from above: its terminal coalgebra C turns out to consist of all strongly extensional κbranching trees with edges labeled in A; strong extensionality has the analogous meaning
as above: two subtrees rooted at distinct children of some node are never bisimilar as trees
if both edges to the children carry the same label. The elements of C can be considered as
(denotations of) CCS-agents modulo strong bisimilarity.
Notice that the inverse c−1 : Pκ (AP× C) → C assigns to a set {(ai , Ei ) | i < κ}
of pairs of actions and agents the agentP i<κ ai .Ei . The usual process combinators “a.−”
(prefixing), “|” (parallel composition), “ i<κ ” (summation), “−[f ]” (relabeling) and “−\L”
(restriction) are given by sos rules. Let E, E ′ , F , F ′ be agents and a ∈ A some action, then
these rules are:
a
E → E′
a
F → F′
a
E|F → E|F ′
E|F → E ′ |F
a
a
Ej → Ej′
a
ā
E → E′
F → F′
τ
E|F → E ′ |F ′
a
E → E′
(a 6= τ )
a
E → E′
(a, ā 6∈ L)
a
f (a)
E\L → E ′ \L
E[f ] → E ′ [f ]
Now let K be the polynomial functor for the signature given by taking these combinators
as operation symbols. It easily follows from the work in [13] and [31] that the rules above
give an abstract GSOS rule ℓ : K(H × Id) → HM , and the ℓ-interpretation b : KC → C
in C provides the desired operations on CCS-agents (modulo strong bisimilarity). Further
details are presented in Section 6.1.
a
a.E → E
(j < κ)
P
a
( i<κ Ei ) → Ej′
(2) Streams. Streams have been studied in a coalgebraic setting by Rutten [42]. Here we
take the functor HX = R × X whose terminal coalgebra (C, c) is carried by the set Rω of all
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
9
streams over R and c = hhd, tli : Rω → R × Rω is given by the usual head and tail functions
on streams.
Operations on streams can be defined by so-called behavioral differential equations [42].
Here one uses for every stream σ the notation σ0 = hd(σ) and σ ′ = tl(σ). Then, for example,
the function zip merging two streams is specified by
(zip(x, y))′ = zip(y, x′ ) .
zip(x, y)0 = x0
This gives rise to an abstract GSOS rule as follows. Let KX = X × X (representing the
binary operation zip), and let ℓ : K(H × Id) → HM be
ℓ = (K(H × Id)
ℓ′
/ HK
Hκ
/ HM )
where ℓ′ is given by
ℓ′X ((r, x′ , x), (s, y ′ , y)) = (r, (y, x′ )) .
Notice that in a triple (r, x′ , x) ∈ HX × X, x is a variable for a stream with head r and tail
referred to by the variable x′ . It is now straightforward to work out that the ℓ-interpretation
b : KC → C is the operation zip.
For another example, the componentwise addition of two streams σ and τ is specified
by
(σ + τ )0 = σ0 + τ0
(σ + τ )′ = (σ ′ + τ ′ ) .
(2.5)
In this case, we let KX = X × X, and
ℓ = (K(H × Id)
ℓ′
/ HK
Hκ
/ HM ) ,
where ℓ′ is given by
ℓ′X ((r, x′ , x), (s, y ′ , y)) = (r + s, (x′ , y ′ )) .
Again, it is not hard to show that the ℓ-interpretation b : C × C → C is componentwise
addition. (For related details, see Example 5.11 below.)
(3) Formal languages. Consider the endofunctor HX = X A × 2 on Set, where 2 = { 0, 1 }.
Coalgebras for H are precisely the (possibly infinite) deterministic automata over the set A
(as an alphabet). The terminal coalgebra c : C → HC consists of all formal languages with
c(L) = (λa.La , i) with i = 1 iff the empty word ε is in L and where La = { w | aw ∈ L }.
To specify e. g. the intersection of formal languages by an abstract GSOS rule, let
KX = X × X and let ℓ : K(H × Id) → HM be
ℓ = (K(H × Id)
Kπ0
/ KH
ℓ′
/ HK
Hκ
/ HM )
where ℓ′ : KH → HK is given by ℓ′X ((f, i), (g, j)) = (hf, gi, i∧j) where ∧ denotes the “and”operation on { 0, 1 }. Then the ℓ-interpretation is easily verified to be the intersection of
formal languages.
Our first result (Theorem 2.16) improves a result from [12, 13] that we now recall. For
the rest of this section we assume that an abstract GSOS rule ℓ : K(H × Id) → HM is
given. Recall that the structure of the terminal coalgebra c : C → HC is an isomorphism by
the Lambek Lemma [29]. From now on we will regard C as an H-algebra with the structure
c−1 : HC · C most of the time.
10
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
Definition 2.11. An ℓ-equation is an HM -coalgebra; that is, a morphism of the form
e : X → HM X.
A solution of e in the terminal coalgebra C is a morphism e† : X → C such that the diagram
below commutes:
X
e†
/C
O
c−1
HC
O
e
(2.6)
Hb
b
HM X
HM e†
/ HM C
Theorem 2.12. [12, 13] For every ℓ-equation there exists a unique solution in C.
This result follows from Corollaries 4.3.6 and 4.3.8 and Lemma 4.3.9 in [13]. The first of
these results is the dual of a result obtained independently and at the same time by Uustalu,
Vene and Pardo (see [47], Theorem 1). Notice that both [13] and [47] work at the level of
generality provided by distributive laws rather than with (the dual of) abstract GSOS rules.
And Capretta, Uustalu and Vene [17] generalize this further. In their Theorems 19 and 28
they replace the inverse c−1 of the terminal coalgebra by an algebra a : HA → A having
the property that for every coalgebra e : X → HX there exists a unique coalgebra-toalgebra homomorphism h : X → A, i. e., h exists uniquely such that a · Hh · e = h. Our
generalization in this paper goes in a different direction. We keep the algebra c−1 : HC → C
but generalize the format of equations having a unique solution in this algebra. But before
we do this let us give an example of an ℓ-equation and its solutions for streams.
Examples 2.13. As in our discussion of streams in Example 2.10(2), let HX = R × X so
that that C is the set of streams over R, let KX = X × X, and let ℓ be the abstract GSOS
rule for zipping streams so that b : KC → C is the operation of zipping. As an example of
an ℓ-equation, let X = {x, y}, and let e : X → R × M X be given by
e(x) = (0, zip(y, x))
Then the streams t =
e† (x)
and u =
e† (y)
and
e(y) = (1, zip(x, y)).
satisfy:
t = 1.zip(u, t)
u = 0.zip(t, u)
(2.7)
To continue the discussion from streams just above, we shall solve equations such as (2.9)
below which are more complicated than (2.7). To start with, for the proof of Theorem 3.6
we shall need a variant of Theorem 2.12 for equations of the form e : X → M HM X:
Definition 2.14. A sandwiched ℓ-equation is a M HM -coalgebra; that is, a morphism of
the form e : X → M HM X. A solution of e in the terminal coalgebra C is a morphism
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
11
e† : X → C such that the diagram below commutes:
e†
X
/C
O
b
b
MO C
e
(2.8)
M c−1
M HC
O
M Hb
b
M HM X
M HM e†
/ M HM C
Examples 2.15. This is a variation on Example 2.13. Using a sandwiched ℓ-equation, we
can solve
t = zip(1.u, 0.t)
(2.9)
u = zip(0.t, 1.u)
Note the difference between (2.7) and (2.9). The key point about a sandwiched system is
that the “guards” by prefix operations r.− need not occur at the head of the term on the
right-hand sides. (In this example, they are applied to the variables inside zip.) Incidentally,
the solution assigns to u the famous Thue-Morse stream and to t its dual; the solutions to
(2.7) are different. A more complicated sandwiched system would be
t = zip(0.u, zip(1.u, 0.zip(1.u, 0.u)))
u = zip(zip(0.t, 1.u), zip(0.t, 1.u)).
Theorem 2.16. For every sandwiched ℓ-equation there exists a unique solution in C.
Proof. Given a sandwiched ℓ-equation e : X → M HM X, we form the following (ordinary)
ℓ-equation:
HµHM X
HM e
/ HM M HM X
/ HM HM X ) .
e = ( HM X
From Theorem 2.12 we know that e has a unique solution e† : HM X → C. Thus, we are
finished if we can show that solutions of e and e are in one-to-one correspondence.
Firstly, from the solution e† of e we obtain
e† = ( X
e
/ M HM X
M e†
/ MC
b
b
/ C ),
12
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
and we will now verify that e† is a solution of e. To this end, consider the diagram below:
e†
X
e
b
b
(i)
M e†
M HM X❯❯
GF
/C
O
❯❯❯❯
❯❯M
❯❯e❯❯
(ii)
M HM e
❯❯❯❯
*
†
M HµHM X
/ M HM HM X M HM e /2 M HM C
M HM M HM X
❞
❞
❞
❞
❞
❞
❞❞❞
❞
❞
❞
❞
❞
❞
M HµC ❞❞❞❞❞❞❞
M HM M e†
❞❞❞❞❞❞
❞❞❞❞❞❞
M HM b
b
/ MC
O
M c−1
M Hb
b
M HM M C
/ M HC
O
M Hb
b
/ M HM C
O
(iii)
@A
BC
M HM e†
All its inner parts commute: parts (i) and (iii) commute by the definition of e† , for part (ii)
use that e† is a solution of e (i. e. apply M to Diagram (2.6) with e in lieu of e), and the
remaining parts commute by the definition of e, naturality of µ and the multiplication law
for the Eilenberg-Moore algebra b
b. Thus, the outside commutes, proving e† to be a solution
of e.
Secondly, suppose we are given any solution e† of e. Then we form
HM X
HM e† /
HM C
Hb
b
/ HC
c−1
/C,
and we now prove that this is a solution of e. Indeed, in the diagram
GF
H
HM e
b
HM e†
HM X
/ HM M HM C
HµHM C
HM HM e†
/ HM HM C
bb
H
†
e
HµHM X
@A
/ HM HM X
M
HM M HM X
M
H
M
M
H
M
e
−1
c
/C
/ HM C ❲ H b
/ HC
❲❲❲❲❲
O
O
❲❲❲❲❲
❲
❲❲❲❲H
c−1
HM b
b
❲❲bb❲❲❲
❲❲❲❲+
HC
HM O M ❖C
O
❖❖❖
❖
❖❖❖
−1
HM M c
❖❖❖
❖❖❖HµC
❖❖❖
/ HM M HC
Hb
b
❖❖❖
❖❖❖
❖❖❖
HµHC
❖❖'
/ HM HC
/ HM C
HM Hb
b
HM c−1
all inner parts commute: for the big left-hand square apply HM to Diagram (2.8), the
left-hand part is the definition of e, the two lower squares and the lower right-hand triangle
commute due to naturality of µ, the upper right-hand triangle is trivial, and the remaining
middle right-hand part commutes by the multiplication law for the Eilenberg-Moore algebra
bb. Thus, the outside commutes proving c−1 · Hb
b · HM e† to be a solution of e. Since e has
a unique solution, we have
c−1 · Hb
b · HM e† = e† .
Lastly, the two constructions are inverse to each other: starting with the unique solution
e† of e, it is clear that by applying the two constructions we obtain e† again. Starting with
any solution e† of e, the application of the second construction results in the solution
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
13
c−1 · Hb
b · HM e† = e† of e. The application of the first construction to that solution gives
back the solution e† of e:
bb · M e† · e = bb · M (c−1 · Hb
b · HM e† ) · e = bb · M c−1 · M Hb
b · M HM e† · e = e†
where the last equality uses Diagram (2.8). We conclude that e has a unique solution e† .
3. Completely Iterative Algebras
We already mentioned in the introduction that the H-algebra c−1 : HC → C is the initial
completely iterative algebra for H. After recalling this results below, it is our aim in
this section to extend Theorems 2.12 and 2.16 so as to obtain several new structures of
completely iterative algebras (for functors other than H) on C. Our first main results in
this paper, Theorems 3.5 and 3.6, go in this direction. We shall see in the next section
that having these new cia structures allows us to apply the existing theorems on completely
iterative algebras to uniquely solve much more general recursive equations than what we
have seen up to now and including this section.
We now briefly recall the basic definitions and some examples; more details and examples can be found in [33, 7, 35].
Definition 3.1. [33] A flat equation morphism in an object A (of parameters) is a morphism
e : X → HX + A. An H-algebra a : HA → A is called completely iterative (or a cia, for
short) if every flat equation morphism in A has a unique solution, i. e., for every e : X →
HX + A there exists a unique morphism e† : X → A such that the square below commutes:
e†
X
/A
O
[a,A]
e
HX + A
He† +A
/ HA + A
Examples 3.2. We recall some examples from previous work.
(1) Let T X denote a terminal coalgebra for H(−) + X. (We assume that T X exists for
all X.) Its structure is an isomorphism by Lambek’s Lemma [29], and so its inverse yields
(by composing with the coproduct injections) an H-algebra τX : HT X → T X and a
morphism ηX : X → T X. Then (T X, τX ) is a free cia on X with the universal arrow ηX ,
see [33]. Conversely, for any free cia (T X, τX ) with the universal morphism ηX , [τX , ηX ] is
an isomorphism and [τX , ηX ]−1 is the structure of a terminal coalgebra for H(−) + X. So
in particular, the inverse of the structure c : C → HC of the terminal coalgebra for H is,
equivalently, an initial cia for H.
(2) Let HΣ be a polynomial functor (cf. Example 2.4). The terminal coalgebra for HΣ (−)+X
is carried by the set TΣ X of all (finite and infinite) Σ-trees on X. According to the previous
item, this is a free cia for HΣ on X. As already mentioned in the introduction, cias for
HΣ are Σ-algebras in which systems of recursive equations (1.4) have unique solutions.
For example, let Σ be the signature with one binary operation symbol ∗ and one constant
symbol c. Consider the free cia A = TΣ Y and let t ∈ TΣ Y . Then the system
x0 = x1 ∗ x2
x1 = x0 ∗ x3
x2 = c
x3 = t
14
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
has the unique solution e† : X → TΣ Y given by
∗
∗
✎ ✴✴
✎ ✴✴
e† (x0 ) =
..
.
✎
✎✎
∗✴
✎✎ ✎ ✴✴✴
✴✴
c
e† (x1 ) =
..
.
t
✎ ✴✴
✎✎
∗✴
t
✎✎ ✎ ✴✴✴
e† (x2 ) = c
e† (x3 ) = t .
c
(3) The algebra of addition on N̄ = {1, 2, 3, . . . } ∪ {∞} is a cia for HX = X × X, see [8].
(4) Let A = CMS be the category of complete metric spaces with distances in [0, 1] and with
non-expanding maps as morphisms, and let H be a contracting endofunctor of CMS (see
e. g. [10]). Then any non-empty algebra for H is a cia, see [33] for details. For example, let A
be the set of non-empty compact subsets of the unit interval [0, 1] equipped with the Hausdorff metric [22]. This complete metric space can be turned into a cia such that the Cantor
set arises as the unique solution of a flat equation morphism (see [35, Example 3.3(v)]).
(5) Unary algebras over Set. Here we take A = Set and H = Id. An algebra α : A → A is a
cia iff α has a fixed point a0 and there is no infinite sequence a1 , a2 , a3 , . . . with ai = α(ai+1 ),
i = 1, 2, 3, . . . , except for the one all of whose members are a0 . The second part of this
condition can be put more vividly as follows: the graph with node set A \ {a0 } and with an
edge from α(a) 6= a0 to a for all a is well-founded.
(6) Classical algebras are seldom cias. For example a group or a semilattice is a cia (for
HX = X × X) iff they contain one element only (consider the unique solutions of x = x · 1
or x = x ∨ x, respectively).
Remark 3.3. In [7] the following property—called compositionality—of taking unique solutions of flat equations in a cia a : HA → A was proved. Suppose we have two flat equation
morphisms e : X → HX + Y and f : Y → HY + A. We form
f† • e = ( X
e
/ HX + Y
HX+f †
/ HX + A )
and
f e=( X +Y
[e,inr]
/ HX + Y
HX+f
/ HX + HY + A
can+A
/ H(X + Y ) + A ) .
Then
†
[(f † •e) ,f † ]
/ A ).
(f e)† = ( X + Y
This gives a first precise formulation of the modularity principle we mentioned in the introduction, albeit restricted to solutions of flat equation morphisms. Indeed, the above equation states that in order to obtain the simultaneous unique solution of e and f (i. e. (f e)† )
one may first solve f in the cia A, then plug its solution f † as constant parameters into
†
e and finally solve the resulting equation (i. e., one takes (f † • e) ). For A = Set one can
view this as using the elements f † (y), y ∈ Y , as new constants in A in the subsequent
recursive equation given by e. We shall see modularity principles for more general formats
of recursive definitions in Sections 4 and 5.
The following two theorems show that abstract GSOS rules induce further structures
of completely iterative algebras on the (carrier of the) terminal H-coalgebra C besides the
structure of an initial cia for H.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
15
Assumption 3.4. As in the previous section, we shall write (M, η, µ) for the free monad
on K to simplify notation, and we assume that ℓ : K(H × Id) → HM is an abstract GSOS
rule.
Theorem 3.5. Consider the algebra
k = (HM C
Hb
b
/ HC
c−1
/C ) ,
where b : KC → C is the ℓ-interpretation in C. Then (C, k) is a cia for the functor HM .
Proof. Let e : X → HM X + C be a flat equation morphism. We must prove that there
exists a unique morphism e† : X → C such that the following square commutes:
e†
X
/C
O
e
[k,C]
HM X + C
HM e† +C
/ HM C + C
We start by forming the ℓ-equation
e=( X +C
[e,inr]
/ HM X + C
HM X+HηC ·c
/ HM X + HM C
can
/ HM (X + C) ) .
By Theorem 2.12, there exists a unique morphism s : X + C → C such that the square
below commutes:
s
/C
X +C
c
HC
O
e
(3.1)
Hb
b
HM (X + C)
HM s
/ HM C
We will now prove that the morphism e† = s · inl : X → C is the desired unique solution of
e. We begin by proving that the equation s · inr = idC holds. Indeed, consider the diagram
below:
s
inr
/Co
/ X +C
C
O
e
c
HC
HM
C
8
rrr
r
r
rrr
rrr HηC
k
HM inr
/ HM (X + C)
HM s
ED
/ HM C
O
c−1
(3.2)
HηC
H(s·inr)
/ HC
BC
This diagram commutes: the upper right-hand square is Diagram (3.1) above, the upper
left-hand part commutes by the definition of e, the lower part commutes by the naturality
of η, and the right-hand part follows from the definition of k = c−1 · Hb
b and the unit law
bb · ηC = idC of the Eilenberg-Moore algebra (C, bb), cf. Notation 2.3. Hence, we see that
s · inr is a coalgebra homomorphism from the terminal coalgebra (C, c) to itself. Thus, s · inr
must be the identity as desired.
16
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
Next we prove that e† is a solution of e. To this end we verify that the following diagram
commutes:
e†
GF
inl
X
ED
/
q8 CO
q
q
qq
qqq
q
q
qq k
s
/ X +C
e
HM (X + C)
O
e
/ HM C
♥7
♥
♥
♥♥
♥
♥
can
♥♥♥ [HM e† ,HM C]
♥♥♥
HM s
HM6 X + HM C
❧
❧❧❧
❧
❧❧
❧
❧
❧
❧❧❧ HM X+HηC ·c
HM X + C
[k,C]
(3.3)
/ HM C + C
HM e† +C
The upper part is the definition of e† , the left-hand part commutes by the definition of e, the
upper right-hand part is Diagram (3.1), and that the inner triangle commutes follows from
the definition of e† and the fact that s · inr = idC . Finally, we consider the two coproduct
components of the lower right-hand triangle separately; the left-hand component trivially
commutes, and for the right-hand one we compute as follows:
k · HηC · c = c−1 · Hb
b · HηC · c
(by the definition of
k)
−1
= c ·c
(since bb · ηC = idC )
= idC .
To complete our proof we show that e† = s · inl : X → C is the unique solution
of e. So suppose that we are given any solution e† of e. Now form the morphism s =
[e† , idC ]. We are finished if we show that Diagram (3.1) commutes for this morphism s.
We verify the two coproduct components separately: the right-hand component is checked
using Diagram (3.2): since s · inr = idC the outside of (3.2) commutes, and commutativity
of the desired upper right-hand square composed with inr follows since all other inner
parts commute as described below (3.2). The commutativity of the left-hand component
is established using Diagram (3.3); indeed, since the outside and all other parts of that
diagram commute for our morphism s so does the desired upper right-hand part composed
with inl.
Theorem 3.6. (Sandwich Theorem) Consider the algebra
k′ = (M HM C
Mk
/MC
b
b
/C ) ,
where b : KC → C is the ℓ-interpretation in C and k = c−1 · Hb
b as in Theorem 3.5. Then
(C, k′ ) is a cia for the functor M HM .
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
17
Proof. The proof is a slight modification of the proof of Theorem 3.5: now we are given a
flat equation morphism e : X → M HM X + C and form the morphism
e=( X +C
[e,inr]
/ M HM X + C
M HM X+M HηC ·ηHC ·c
M HM X + M HM C
can
/ M HM (X + C) ).
This morphism e is a sandwiched ℓ-equation and we invoke Theorem 2.16 to see that it has
a unique solution s. The rest of this proof is left to the reader since it is very close to the
one of Theorem 3.5.
Remark 3.7. We discuss a few generalizations of the results in this section obtained by
weakening the assumptions on M or on (C, c−1 ).
(1) In our statements of Theorems 3.5 and 3.6, M was the free monad on K. However, it is
possible to abstract away from this, by considering an arbitrary monad M . In this setting,
we take
λ : M (H × Id) → (H × Id)M
to be a distributive law of the monad M over the cofree copointed functor H × Id. This
is all we need in order to define the λ-interpretation bb : M C → C such that Diagram (2.4)
commutes. cf. Theorem 2.7 and Remark 2.8(2). The version of Theorem 2.12 presented in
[12, 13] and dually in [47] states that for every e : X → HM X there is a unique solution
e† : X → C, i. e., e† is such that the diagram in (2.6) commutes. Inspection of the proofs
reveals that all our results so far hold in this generality . So Theorem 3.5 shows that (C, k)
is a cia for HM , and Theorem 3.6 shows that (C, k ′ ) is a cia for M HM .
(2) Going even further, not all of the monad structure has been used in our work. Observe
that our proof of Theorem 3.5 only makes use of the unit η : Id → M of the monad M ,
not the multiplication. In fact, there are versions of Theorem 3.5 and 3.6 that hold for a
pointed functor M in lieu of a monad and for a given distributive law of M over the cofree
copointed functor H × Id or the functor H, respectively. However, in this case we need to
assume that the category A is cocomplete. The technical details are somewhat different
than what we have seen and we discuss them in detail in an appendix that is provided as
a supplementary file with our paper.
(3) Capretta, Uustalu and Vene [17] extend (the dual) of Theorem 2.12 by replacing the
algebra (C, c−1 ) arising from the terminal coalgebra by an algebra a : HA → A having the
property that for every coalgebra e : X → HX there exists a unique coalgebra-to-algebra
homomorphism from (X, e) to (A, a). One may ask whether the two theorems above can
be extended from the initial cia to an arbitrary cia for H. However, note that our proof
makes use of the fact that c : C → HC is an isomorphism. So the desired extension of our
results is not obvious, and we leave this as an open problem for further work.
Theorems 3.5 and 3.6 extend Theorems 2.12 and 2.16 in two important ways. Firstly,
the structure of a cia allows one to reuse solutions of a given flat equation morphism by
using constants in C on the right-hand sides of recursive equations (cf. Remark 3.3). This
gives a clear explanation of why it is possible to use recursively defined objects (processes,
streams, etc.) in subsequent recursive definitions. This kind of modularity of the unique
18
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
solutions is a useful and desired property often employed in specifications. We shall discuss
a concrete instance of this in Example 6.2.
Secondly, Theorem 3.6 permits the right-hand sides of recursive specifications to be
from a wider class. For example, Milner’s solution theorem for CCS (see [38], Chapter 4,
Proposition 14) allows recursion over process terms E in which the recursion variables occur
within the scope of some prefixing combinator a.−. This combinator can occur anywhere
within E, not necessarily at the head of that term (cf. Example 2.15). Hence, Theorem 3.6
allows us to obtain Milner’s result as a special case, directly. This will be explained in detail
in Section 6.1.
4. Solution Theorems for Free
Using the new cia structures obtained from Theorems 3.5 and 3.6, the existing body of
results on the semantics of recursion in cias [4, 33, 35] now gives us further theorems.
We begin with a terse review of some terminology from the area. We assume that in
addition to the terminal H-coalgebra C, for every object X the terminal coalgebra T H X
for H(−) + X exists, i. e., in the terminology of loc. cit., H is iteratable. Our examples
in 2.10 are all iteratable endofunctors of Set.
As explained in Example 3.2(1), the structure of the terminal coalgebra T H X yields
the free cia on X with its structure and universal arrow as displayed below:
HT H X
H
τX
/T HX
X
H
ηX
/T HX .
From this it easily follows that T H is the object assignment of a monad and that η H and
τ H are natural transformations. Denote by κH the natural transformation
κH = (H
HηH
/ HT H
τH
/T H ) .
It was proved in [4, 33] that the monad T H is characterized as the free completely iterative
monad on H (with the universal natural transformation κH ). We shall not recall the
concept of a completely iterative monad as it is not needed in the present paper. However,
we shall need that the assignment H 7→ T H readily extends to natural transformations.
Let h : H → H ′ be a natural transformation between iteratable endofunctors. Then by the
universal property of T H we have a unique monad morphism
H
Th : TH → TH
′
such that
κH
/ TH
Th
h
H′
κ
H′
(4.1)
/ T H′
commutes.
Finally, let (A, a) be a cia for H. Then there is a unique H-algebra homomorphism
e
a : T HA → A
such that
H
e
a · ηA
= idA .
We call e
a the evaluation morphism associated with A. It is easy to prove that e
a · κH
A = a.
Remark 4.1. In the case of a polynomial functor HΣ on Set, the evaluation morphism e
a
can be thought of as a map that takes a (not necessarily finite) Σ-tree t with variables in
the cia A and computes the value of t in A using the algebraic operations on A given by
the structure a : HΣ A → A.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
19
In previous work it was shown how to obtain unique solutions of more general (first
order) recursive equations than the flat ones appearing in the definition of a cia:
Definition 4.2. [4, 33] An equation morphism is a morphism of the form e : X → T H (X +
A). It is called guarded if there exists a factorization f : X → HT H (X + A) + A such that
e
/ T H (X + A)
X ◆◆
O
◆◆◆
◆◆◆
H
H
[τX+A
,ηX+A
·inr]
◆◆◆
f
◆&
HT H (X + A) + A
A solution of an equation morphism e in a cia (A, a) is a morphism e† : X → A such
that the following square commutes:
e†
X
/A
O
e
e
a
T H (X + A)
T H [e† ,idA ]
/ T HA
Example 4.3. For a polynomial functor HΣ on Set an equation morphism e : X →
T HΣ (X + A) corresponds to a system of equations (1.4), where each right-hand side ti
is a (finite or infinite) Σ-tree with leaves labeled by a variable xj or elements a ∈ A. Guardedness is the syntactic restriction that no right-hand side tree ti is simply a single node
tree with a variable as a label. A solution assigns to every variable xi an element ai ∈ A
such that ai = e
a(ti [a~j /x~j ]) for every i ∈ I, i. e., if we substitute all the solutions aj for the
corresponding variables xj in ti and evaluate the resulting tree in A using e
a, then we obtain
ai .
Theorem 4.4. [33] Let (A, a) be a cia for H. Then every guarded equation morphism has
a unique solution in A.
An even more general property of cias was proved in [35]; one can solve recursive
function definitions uniquely in a cia. We recall the respective result.
Definition 4.5. Let V be an endofunctor such that H +V is iteratable. A recursive program
scheme (rps, for short) is a natural transformation e : V → T H+V . It is called guarded if
there exists a natural transformation f : V → HT H+V such that
e=(V
f
/ HT H+V
inlT H+V
/ (H + V )T H+V
τ H+V /
T H+V ) ,
where inl : H → H + V is the coproduct injection.
Now let (A, a) be a cia for H. An interpreted solution of e in A is a V -algebra structure
e‡A : V A → A giving rise to an Eilenberg-Moore algebra structure β : T H+V A → A with
H+V
= [a, e‡A ] and such that we have
β · κA
e‡A = ( V A
eA
/ T H+V A
β
/ A ).
(4.2)
Example 4.6. As explained in [35], for polynomial set functors, recursive program schemes
as defined above provide a categorical formulation of recursive function definitions such
as (1.5) from the introduction. For example, let V X = X be the polynomial functor
20
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
associated with the signature with one unary operation symbol f and let HX = X × X + X
be the polynomial functor for the signature of the givens F and G. Then (1.5) uniquely
determines the natural transformation
F✴
✎✎ ✴✴✴
✎✎
x
e:V →T
H+V
with
G
eX (x) =
f
x
Here guardedness corresponds to the syntactic restriction that the right-hand side of (1.5)
starts with a given operation symbol such as F . Any cia A for H provides interpretations of
the given operation symbols F and G as actual operations FA : A×A → A and GA : A → A,
and an interpreted solution in A is precisely a new unary operation fA : A → A such that
for all a ∈ A, fA (a) = FA (a, GA (fA (a)).
Theorem 4.7. [35] In a cia, every guarded rps has a unique interpreted solution.
We are now able to prove more. The next theorem implies modularity of taking solutions
of recursive program schemes: operations obtained as solutions of recursive program schemes
can be used as givens in subsequent definitions of other recursive program schemes. These
new schemes will still have unique solutions. For the special case of interpreted rps solutions
in cias this strengthens the results in [36].
Theorem 4.8. Let e : V → T H+V be a guarded rps, and let a : HA → A be a cia. Then
the interpreted solution e‡A : V A → A extends the cia structure on A; more precisely, the
algebra [a, e‡A ] : (H + V )A → A is a cia for H + V .
Remark 4.9. For the proof we need to recall some technical details. Recall that any
guarded rps e : V → T H+V as in Definition 4.5 induces a natural transformation
e : T H+V → HT H+V + Id
(see [35, Lemma 6.9]). The component eA of this natural transformation at A is a flat
equation morphism with parameters in A. Its unique solution in the cia (A, a) is the
H+V
Eilenberg-Moore algebra structure β : T H+V A → A in (4.2) satisfying [a, e‡A ] = β · κA
(this follows from [35], see Lemma 7.4 and the proof of Theorem 7.3).
Proof of Theorem 4.8. Let m : X → (H + V )X + A be a flat equation morphism. We need
to prove that m has a unique solution s. As shortcut notations we shall write T ′ for T H+V ,
′ : (H + V )T ′ X → T ′ X for the corresponding structure of a free cia for H + V as well as
τX
′
η and µ′ for the unit and multiplication of the monad T ′ and κ′ = τ ′ · (H + V )η ′ (cf. the
introduction to Section 4).
(1) Existence of a solution. Since T ′ A is the terminal coalgebra for (H + V )(−) + A we
have a unique homomorphism h : X → T ′ A. We show that
s = (X
h
/ T ′A
β
/ A)
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
21
is a solution of m in the algebra (A, [a, e‡A ]). To see this, consider the following diagram:
h
X
β
/ T ′A
O
/A
O
[a,e‡A ,A]
′ ,η ′ ]
[τA
A
m
(H + V )X + A
(H+V )h+A
/ (H + V )T ′ A + A
/ (H + V )A + A
(H+V )β+A
The left-hand square commutes since h is a coalgebra homomorphism, and for the right-hand
′ = id of the Eilenberg-Moore
component of the right-hand square use the unit law β · ηA
A
algebra β. It remains to prove the commutativity of the left-hand component. This is
established by inspecting the diagram below:
′
τA
GF
(H + V )T ′ A
κ′T ′ A
/ T ′T ′A
ED
/ T ′A
µ′A
T ′β
(H+V )β
(H +@A
V )A
/ T ′A
κ′A
(4.3)
β
/
BCOAO
β
[a,e‡A ]
The commutativity of the upper part is standard (see Corollary 3.17 in [35]), for the lower
one see Remark 4.9, the left-hand inner square commutes due to naturality of κ′ , and the
right-hand inner square by one of the laws for the Eilenberg-Moore algebra β.
(2) Uniqueness of solutions. Since e is a guarded rps, it factors through some f : V →
HT ′ (cf. Definition 4.5). From f and m we form a flat equation morphism
g : X + T ′ X → H(X + T ′ X) + A
w. r. t. H as follows. The left-hand component of g is
g · inl = (X
m
HX+fX +A
/ HX + V X + A
/ HX + HT ′ X + A
can+A
/ H(X + T ′ X) + A) ,
and the right-hand component of g is
g · inr = (T ′ X
eX
/ HT ′ X + X
[inl·Hinr,g·inl]
/ H(X + T ′ X) + A) .
Since (A, a) is a cia for H there exists a unique solution g† : X +T ′ X → A. Now let s : X →
A be any solution of the flat equation morphism m in the algebra [a, e‡A ] : (H + V )A → A.
We will show below that [s, β · T ′ s] : X + T ′ X → A is a solution of g in the H-algebra
(A, a). So since (A, a) is a cia we have the following equation:
g† = [s, β · T ′ s] : X + T ′ X → A .
(4.4)
g† .
Then s is uniquely determined by
In order to prove Equation (4.4) we need to verify that the following square commutes:
X + T ′X
[s,β·T ′s]
g
/A
O
[a,A]
H(X + T ′ X) + A
H[s,β·T ′ s]+A
/ HA + A
(4.5)
22
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
We shall verify the commutativity of the two coproduct components separately. For the
left-hand component we consider the diagram below:
s
X
GF
/Ao
O
ED
[a,e‡A ,A]
m
HX + V X + A
/ HA + V A + A
Hs+V s+A
HX+fX +A
g·inl
HX +
@A
[a,A]
HT ′ X
❱+❱❱A
❱❱
[Hs,H(β·T ′ s)]+A
can+A
BC
❱❱❱❱❱
*
/ HA + A
/ H(X + T ′ X) + A
(4.6)
HA+[e‡A ,A]
H[s,β·T ′s]+A
The left-hand part commutes by the definition of g, the right-hand part commutes trivially,
the upper square commutes since s is a solution of m and the lower triangle commutes
trivially, again. It remains to verify that the middle part commutes. We check the commutativity of this part componentwise: the left-hand and right-hand components commute
trivially. We do not claim that the middle component commutes. However, in order to prove
that the overall outside of (4.6) commutes, we need only show that this middle component
commutes when extended by [a, A] : HA + A → A. To see this consider the next diagram:
GF
VX
Vs
eA
eX
T ′O X
fX
@A
/ VA
T ′s
′ ·inl
τX
T ′X
/ HT ′ X
/ T ′A
O
e‡A
/A
rr8 O
r
r
r
rrrβ
r
r
r
a
′ ·inl
τA
T ′A
HT ′ s
/ HT ′ A
Hβ
/ HA
This diagram commutes: the left-hand part commutes since e is a guarded rps; the upper
and lower squares in the middle commute due to the naturality of e and of τ ′ : (H + V )T ′ →
T ′ and inlT ′ : HT ′ → (H +V )T ′ , respectively; the upper right-hand triangle commutes since
e‡A is an interpreted solution of the rps e. Finally, to see that the lower right-hand part
commutes recall from Diagram (4.3) that
[a, e‡A ] · (H + V )β = β · τA′ .
Compose this last equation with the coproduct injection inlT ′ A : HT ′ A → (H + V )T ′ A to
obtain the desired commutativity.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
23
Finally, we verify that the right-hand component of (4.5) commutes. Indeed, consider
the diagram below:
GF
eX
HT ′ X + X
@A
/ T ′A
β
/A
O
eA
g·inr
T ′s
T ′X
HT ′ s+s
[inl·Hinr,g·inl]
/ H(X + T ′ X) + A
/ HT ′ A + A
[a,A]
◆◆◆
◆◆Hβ+A
◆◆◆
◆◆◆
&
/ HA + A
H[s,β·T ′ s]+A
The left-hand part commutes by the definition of g; the upper middle square commutes
by the naturality of e, the right-hand part commutes since β is the solution of eA in the
cia (A, a) (see Remark 4.9); and for the lower middle part we consider the components
separately: the left-hand component clearly commutes by the functoriality of H, and for
the right-hand component observe that it commutes when extended by [a, A] : HA+ A → A
(see Diagram (4.6)). Thus, the outside of the diagram above commutes, and this completes
the proof.
Coming back to our setting in Section 3, let ℓ : K(H × Id) → HM be an abstract
GSOS rule, where M is the free monad on K (or, more generally, let λ be a distributive
law of an arbitrary monad over the cofree copointed functor H × Id). Assume furthermore
that the composite HM is iteratable. By applying the two Theorems 4.4 and 4.7 and
also Theorem 4.8 to the cia k : HM C → C from Theorem 3.5 we get two more solutions
theorems for free:
Corollary 4.10. Every guarded equation morphism e : X → T HM (X + C) has a unique
solution in the cia (C, k).
Corollary 4.11. Every guarded rps e : V → T HM +V has a unique interpreted solution in
the cia (C, k), and this solution extends the cia structure on C.
Assuming that M HM is iteratable two similar theorems hold for the cia k′ : M HM C →
C obtained from Theorem 3.6:
Corollary 4.12. Every guarded equation morphism e : X → T M HM (X + C) has a unique
solution in the cia (C, k′ ).
Corollary 4.13. Every guarded rps e : V → T M HM +V has a unique interpreted solution
in the cia (C, k′ ), and this solution extends the cia structure on C.
4.1. Summary: Equation Formats. (1) Until now we have seen several formats of equation morphisms. These are related in the sense that some formats comprise others as a
special case. In particular, guarded “sandwiched” equation morphisms comprise all other
24
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
formats as shown in the following picture:
guarded equation m.
X → T HM (X + C) ✤
Corollary
4.10
O
guarded equation m.
ηHM
·e
TX+C
/ X → T M HM (X + C)
Corollary
4.12
O
HM )·e
can·(κHM
X +ηC
HM +η M HM )·e
can·(κM
X
C
❴
flat equation m.
X → HM X + C ✤
Theorem
3.5
O
❴
flat equation m.
/ X → M HM X + C
Theorem
3.6
O
(ηHM X +C)·e
inl·e
inl·e
❴
❴
ℓ-equation
sandwiched ℓ-equation
ηHM X ·e
/
X → HM X ✤
X → M HM X
Theorem 2.12
Theorem 2.16
The arrows point to more general formats, and their labels indicate how one forms an
equation morphism of the more general format from a given equation morphism e of the
simpler format. Natural transformations without a superscript refer to the free monad M ,
the ones with a superscript refer to T -monads. The monad morphism T ηHM : T HM →
T M HM arises from the natural transformation ηHM : HM → M HM as explained at the
beginning of this section (cf. (4.1)). In all cases one readily proves that the solutions are
preserved along the arrows. For example, solutions of e : X → HM X + C in the cia (C, k)
are in one-to-one correspondence with solutions of (ηHF X + C) · e : X → M HM X + C in
the cia (C, k ′ ), etc.
(2) Similarly, guarded rps’s in Corollary 4.13 subsume those in Corollary 4.11 which in turn
subsume the rps of the form V → T H+V from Theorem 4.7. Pictorially, we have
(guarded) rps ✤
V → T H+V
T Hη+V ·e
/ (guarded) rps ✤
V →
T ηHM +V ·e
T HM +V
/ (guarded) rps
V → T M HM +V
Again, one readily proves that solutions are preserved along the arrows. For example,
solutions of e : V → T H+V in the cia (C, c−1 ) are in one-to-one correspondence with
solutions of T Hη+V · e in the cia (C, k).
(3) Finally, guarded rps’s subsume guarded equation morphisms. To see this let e : X →
T H (X + C) be a guarded equation morphism. Consider the constant functors CX and
CC and let H ′ = H + CC . Then e corresponds precisely to a natural transformation
e : CX → T H (CX + CC ), and this gives rise to an rps as follows
CX
e
/ T H (CX + CC )
T H κCX +CC
/ T H T CX +CC
T inl T [inr,inm]
µH+CC +CX
′
/ T H +CX .
T H+CC +CX T H+CC +CX
It is straightforward but rather tedious to check that this rps is guarded and that its solutions
are in one-to-one correspondence with the solutions of e.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
25
5. Recursive Function Definitions over the Behavior
Even with all the results we have seen so far, we are still not able to obtain functions such
as the shuffle product ⊗ on streams (see (1.2)) as a unique solution since its definition refers
to the behavior of the arguments of the function. Notice also that the specification of ⊗
makes use of the stream addition + operation, so this operation is assumed as given or
previously specified and the specification of ⊗ is built on top of the specification of +. Our
aim in this section is to prove results that yield unique solutions of such specifications in
terminal coalgebras.
Notation 5.1. From now on we shall also need to consider free monads of other functors
than K from Asumption 2.1. We follow the convention that whenever we write Fb for a
functor F we assume that a free monad Fb exists and is given objectwise by free algebras
for F (cf. Remark 2.2(2)).
Finally, to shorten notation, we usually abbreviate K + V by F .
Outline 5.2. Here is the basic plan for the results in this section. We begin, as before,
with a endofunctor H and its terminal coalgebra (C, c). We also have a separate functor
b specifying a set of “given” operations.
K, and an abstract GSOS rule ℓ : K(H × Id) → H K
When we say “specify” here, we refer to the algebra structure b : KC → C, the unique
morphism so that
c · b = Hb
b · ℓC · Khc, idC i
(see Theorem 2.7). We also have another functor V corresponding to the “new” operation
symbols that we wish to interpret. What our approach requires at this point is a natural
transformation
\
e : V (H × Id) → H K
+V.
We shall call e a recursive program scheme w. r. t. ℓ (or, an ℓ-rps, for short). From e and ℓ
we shall obtain a natural transformation
\
n : (K + V )(H × Id) → H K
+V
in a canonical way. Again, n is an abstract GSOS rule—but notice that the functor involved
is K + V , not K as it is for ℓ. This natural transformation n has an interpretation in C,
call it
a : (K + V )C → C.
Then it will turn out that a · inl = b, so that the algebra structure a is an extension of
b. The interpretation of the new operation symbols in C will correspond to the V -algebra
(C, a · inr). We will prove in Theorem 5.14 that this algebra is uniquely determined as a
solution of the ℓ-rps e.
The upshot is that we start and end with the same kind of data, but with a different
functor. We start with K, ℓ, and b, and we end with K + V , n, and a. The point we are
trying to make here is that the situation repeats, and so we can apply the result successively.
The rest of this section works out the details of this outline. To see that this approach
actually accounts for a large number of interesting operations on terminal coalgebras, we
present many examples in Section 6. Prior to this, we have two other contributions which
extend the basic result in the same ways as the results we saw in Section 2. We have a
“sandwiched” version of Outline 5.2, and we also have results about cia structures. And in
our main result, Theorem 5.23, we prove that every sandwiched ℓ-rps (see Definition 5.21 has
b K
b on C given by Theorem 3.6.
a unique solution in C which extends the cia structure for KH
26
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
Assumption 5.3. We continue to work under Assumption 2.1, and in addition we fix an
b and an endofunctor V : A → A.
abstract GSOS rule ℓ : K(H × Id) → H K
Notation 5.4. (1) We overload the notation from Remark 2.2(3) and write, for any functor
F on A, ϕ : F Fb → Fb and η : Id → Fb for (the natural transformations given by) the
structures and universal morphisms of the free F -algebras, as well as µ : FbFb → Fb and
κ : F → Fb for the multiplication and universal natural transformation of the free monad
Fb.
(2) Let F and G be endofunctors of A. The coproduct injections inl : F → F + G ← G : inr
lift to monad morphisms on the corresponding free monads, and we denote those monad
b : Fb → F\
b : inr.
c
morphisms by inl
+G←G
b : Fb → F\
Remark 5.5. (1) Notice that the monad morphism inl
+ G is uniquely determined
by the commutativity of the following square of natural transformations:
F
κ
/ Fb
b
inl
inl
F +G
κ
/ F\
+G
c
Similarly for inr.
(2) Recall from Notation 2.3 that for every F -algebra (A, a) we have the corresponding
Eilenberg-Moore algebra b
a : FbA → A and that a = b
a · κA . Moreover, the category of F algebras is isomorphic to the category of Eilenberg-Moore algebras for Fb . More precisely,
a 7→ b
a and precomposition with κA extend to mutually inverse functors.
(3) Combining parts (1) and (2) of this remark, we see that for every algebra a : (F +G)A →
b A = a\
A the equation b
a · inl
· inlA holds. Indeed, both sides are equal when precomposed
with κA :
b A · κA = b
b
a · inl
a · κA · inlA = a · inlA = a\
· inlA · κA .
If we make the coproduct algebra structure explicit as in a = [a0 , a1 ], we obtain
\
b
[a
0 , a1 ] · inlA = ab0
and
\
c
[a
0 , a1 ] · inrA = ab1 .
Definition 5.6. A recursive program scheme w. r. t. ℓ (shortly, ℓ-rps) is a natural transformation
e : V (H × Id) → H Fb ,
where (throughout this section) F = K + V .
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
27
Construction 5.7. Let e : V (H × Id) → H Fb be an ℓ-rps. This gives an abstract GSOS
rule n : F (H × Id) → H Fb defined on its coproduct components as displayed below:
V (H × Id)
❏❏
❏❏ e
❏❏
inr(H×Id)
❏❏
❏❏
%
n /
F (H × Id)
HO Fb
O
b
H inl
inl(H×Id)
K(H × Id)
ℓ
b
/ HK
We write a : F C → C for the n-interpretation in C (cf. Definition 2.9).
Remark 5.8. The construction of the abstract GSOS rule n above is reminiscent of the
composition of two distributive laws λ : M D → DM and λ′ : M ′ D → DM ′ of the monads
M and M ′ over the same copointed functor D using the coproduct of monads, see [40, 31].
c′ and for D = H × Id, λ and λ′ are equivalently
b and M ′ = G
For free monads M = G
c′ and the
b and ℓ′ : G′ (H × Id) → H G
presented by abstract GSOS rules ℓ : G(H × Id) → H G
construction of loc. cit. amounts to forming n
e as shown in the diagram below:
ℓ
G(H × Id)
b
/ HG
b
H inl
inl(H×Id)
(G + G′ )(H × Id)
n
e
O
′
/ H G\
+
O G
c
H inr
inr(H×Id)
G′ (H × Id)
c′
/ HG
ℓ′
Notice that there is no interplay between ℓ and ℓ′ . So, as explained in loc. cit., in the
case of operational rules of process combinators the formation of n
e corresponds precisely to
forming the disjoint union of two transition system specifications with mutually independent
operations. In contrast, in Construction 5.7 the left-hand component e depends on K. So
in the case of operational rules for process combinators our construction corresponds to
combining a given transition specification (modeled by ℓ) with another one (modeled by e)
which makes use of the operators specified by the first specification.
Our next result substantiates the details presented in Outline 5.2.
b Then
Proposition 5.9. Let b : KC → C be the interpretation of ℓ : K(H × Id) → H K.
for a : F C → C from Construction 5.7 we have
b = (KC
inlC
/F C
a
/C ) .
28
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
Proof. Consider the diagram below:
KC
Khc,idC i
/ K(H × Id)C
ℓC
bC
H inl
inl(H×Id)C
inlC
FC
F hc,idC i
b
/ H KC
/ F (H × Id)C
a
nC
/ H Fb C
Hb
a
C
c
/ HC o
ED
\
H(a·inl
C)
BC
The lower square commutes since a is the n-interpretation in C (cf. Theorem 2.7) and the
upper right-hand one by the definition of n (cf. Construction 5.7). The upper left-hand
square commutes by the naturality of inl : K → F , and for the right-hand part we remove
H and use Remark 5.5(3). Thus the outside commutes.
Now recall that b is uniquely determined by the commutativity of the diagram in Theorem 2.7. Thus, a · inlC = b holds, as desired.
Summary 5.10. Let us summarize and review our work in this section so far. We say that
the tuple
b
(c : C → HC, ℓ : K(H × Id) → H K,
b : KC → C)
is appropriate if c is a terminal coalgebra structure, ℓ is an abstract GSOS rule, and b is its
interpretation. Given an appropriate tuple, the work in this section shows how to obtain
another appropriate tuple: let V be a functor, let F = K + V , and let e : V (H × Id) → H Fb
be an ℓ-rps. We consider
b · ℓ, e] : F (H × Id) → H Fb .
n = [H inl
This is an abstract GSOS rule involving F , so it has an interpretation a : F C → C. So
(c : C → HC, n : F (H × Id) → H Fb , a : F C → C)
(5.1)
is again appropriate. It extends the earlier appropriate tuple in the sense that a · inr = b :
V C → C.
Example 5.11. We continue our exploration of stream operations as defined by behavioral
differential equations. We want to study the shuffle product on streams mentioned in the
introduction. It is specified by
(σ ⊗ τ )0 = σ0 · τ0
(σ ⊗ τ )′ = σ ⊗ τ ′ + σ ′ ⊗ τ .
(5.2)
The behavior functor H : Set → Set here is HX = R × X. On the right side of (5.2),
we see the stream addition operation +. This is a binary operation and so corresponds
to a K-algebra structure on C, where KX = X × X. Our work in this section shows
how to define ⊗ “on top of” (C, +). First observe that the given operation + : KC → C
b given
is obtained as the interpretation of the abstract GSOS rule ℓ : K(H × Id) → H K
by (2.5) in Example 2.10(2). Now we take V X = X × X, the type functor of the binary
operation ⊗. For F = K + V we may then identify FbX with the set of all terms obtained
by applying the operation symbols ⊗ and + to variables in X. (Note that ⊗ and + are
regarded as uninterpreted symbols at this point, and for the given operation + we have the
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
29
interpretation on C induced by ℓ.) To obtain an interpretation of ⊗ on C, we use the ℓ-rps
e whose components
eX : (R × X × X) × (R × X × X) → R × FbX
are given by
eX ((r, x, x′ ), (s, y, y ′ )) = (r · s, (x ⊗ y ′ ) + (x′ ⊗ y)) .
The abstract GSOS rule n : F (H × Id) → H Fb from Construction 5.7 now induces the
algebra structure a : F C → C whose left-hand component is, by Proposition 5.9, a · inl =
+ : KC → C and whose right-hand component is easily seen to be the desired shuffle
product a · inr = ⊗ : V C → C. So Proposition 5.9 is a kind of sanity check: the operation
induced by n for the left-hand component K of F = K + V is the same operation + we
started with as given.
Example 5.12. We present another example related to the zipping of streams; see Examb
ples 2.10(2) and 2.13. We have seen that there is an abstract GSOS rule ℓ : K(H×Id) → H K
with KX = X × X presenting the zip operation on streams. Using an ℓ-rps, we can show
that there is a unique function f : C → C satisfying
f (σ) = zip(σ, f (σ)) .
We might mention a subtlety: consider the alternative definition
g(σ) = zip(g(σ), σ) .
The uniqueness assertion fails for this. The point is that each (g(σ))0 is arbitrary. As for
f , note that (f (σ))0 = σ0 for all streams σ. In fact, this observation is central to obtaining
f via Theorem 5.14. The point is that we can write
f (σ) = zip(σ0 .σ ′ , f (σ)) = σ0 .zip(f (σ), σ ′ ) .
The last formulation makes it clear that we can obtain f using the method of this section:
one takes V X = X, and then the last equation gives rise to
e : V (H × Id) → H Fb with eX : (r, x′ , x) 7→ (r, zip(f (x), x′ )).
Incidentally, functions like f play a role in the theory of paperfolding sequences; cf. [18],
Observation 1.3.
5.1. Interpreted solutions and cia structures. At this point, the reader might wish
to revisit Outline 5.2. The work we have done so far builds a V -algebra structure on C
by taking an F -algebra structure and (in effect) throwing away the interpretation of the
“givens”, since we know them to be the same as in the original K-algebra structure. Our
next result, Theorem 5.14, provides a different way to look at things. It provides a direct
notion of an interpreted solution; this is a V -algebra. The theorem shows that ℓ-rps’s
have unique interpreted solutions. In addition, Theorem 5.14 shows that cia structures are
propagated according to our development.
30
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
Definition 5.13. Let e : V (H × Id) → H Fb be an ℓ-rps. An interpreted solution of e in C
is a V -algebra structure s : V C → C such that the triangle below commutes:
s
VC
V hx,idC i
V (HC × C)
eC
H FbC
HC
♦♦7
♦
♦
♦♦
♦♦♦ d
♦
♦
H
[b,s]
♦
/C
:
✈✈
✈
✈
✈
✈
✈✈ −1
✈✈ c
(5.3)
where b : KC → C is the ℓ-interpretation in C (cf. Definition 2.9).
Theorem 5.14. For every ℓ-rps there exists a unique interpreted solution s in C. In
addition, s extends the cia structure on C, i. e., the following is the structure of a cia for
H Fb on C:
H FbC
d
H [b,s]
/ HC
c−1
/C .
(5.4)
Proof. Given the abstract GSOS rule ℓ and the ℓ-rps e, form n as in Construction 5.7 and
define
inr /
a /
s = (V C
FC
C),
where a is the n-interpretation in C. Observe immediately that, by Proposition 5.9,
a = [b, s] : F C → C,
where b : KC → C is the ℓ-interpretation in C, and so we have
d
b
a = [b,
s] : FbC → C .
(5.5)
(1) We prove that s is a solution of e in C. Indeed, consider the commutative diagram
V hc,idC i
/ V (H × Id)C
◆◆◆
◆◆◆eC
◆◆◆
inr(H×Id)C
inrC
◆◆'
F hc,idC i
nC
/ F (H × Id)C
/ H Fb C
FC
VC
GF
s
a
(5.6)
Hb
a
@A /C
c
/ HC .
The lower square commutes since a is the n-interpretation in C, and the upper right-hand
triangle by the definition of n (cf. Construction 5.7). The upper left-hand square commtes
by the naturality of inl : V → F , and the left-hand part is the definition of s. Thus the
d
outside commutes, and we see that s is a solution of e since b
a = [b,
s] holds by (5.5).
(2) We now prove that s is unique. Suppose that t is any solution of e. We will prove that
[b, t] = a,
which implies the desired equation s = t.
(5.7)
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
31
In order to prove (5.7) we have to verify the commutativity of the following diagram
(cf. Theorem 2.7):
FC
F hc,idC i
/ F (H × Id)C
nC
/ H Fb C
d
H [b,t]
[b,t]
c
/ HC
C
We verify this for the two coproduct components of F C = KC + V C separately.
For the right-hand component we obtain diagram (5.6) above with s replaced by t and
a by [b, t], which commutes since t is a solution of e. For the left-hand component we obtain
the diagram below:
KC
Khc,idC i
b
C
inl
nC
/ H Fb C
/ K(H × Id)C (H×Id)C / F (H × Id)C
5
❘❘❘
❧❧❧
❧
❘❘❘
❧
❧
❧
❘❘❘
❧❧❧
❘❘❘
❧❧❧ H inl
ℓC
❘❘❘
bC
)
❧❧❧
c
b
H KC
❙❙
❙❙❙
❙❙❙
❙❙❙
❙❙❙
❙❙❙
Hb
b
/)
d
H [b,t]
HC
The big left-hand part commutes since b is the ℓ-interpretation in C (cf. Theorem 2.7),
the upper triangle commutes by the definition of n (see Construction 5.7), and for the
right-hand triangle remove H and notice that
dt] · inl
b C = bb
[b,
by Remark 5.5(3).
d
(3) To complete the proof we will show that c−1 · H [b,
s] : H FbC → C is the structure of
b
a cia for H F . But this is a consequence of Theorem 3.5; indeed, recall that [b, s] is the
interpretation of the abstract GSOS rule n : F (H × Id) → H Fb in C, see (5.5).
Remark 5.15. Notice that the fact that the unique solution s of an ℓ-rps extends the cia
structure on C means that the operations on C defined in this way may be part of recursive
\
definitions according to the Corollaries 4.10 and 4.11 (where M = K
+ V ).
As we shall see in Section 6, in conrete instances many operations are definable as
unique solutions of ℓ-rps’s. But there are operations that cannot be defined by any ℓ-rps
(or abstract GSOS rule):
Example 5.16. The tail function tl : Rω → Rω on streams cannot be defined as (part
b For if
of) an interpretation of any abstract GSOS rule ℓ : K(R × Id × Id) → R × K.
it were possible to obtain the tail function in this way we would have the induced cia
b → C according to Theorem 3.5. Then, for X = {x} the ℓ-equation (see
c−1 · Hb
b : H KC
b given by e(x) = (r, tl(x)) would have a unique solution
Definition 2.11) e : X → R × KX
†
e : X → C for every r ∈ R. But this is clearly not the case: every stream σ with r at its
head yields a solution e, since e† (σ) = σ.
The next proposition shows that for two ℓ-rps’s that do not interact the order in which
the algebra b : KC → C is extended by their solutions does not matter.
32
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
Proposition 5.17. Let ei : Vi (H × Id) → H K\
+ Vi , i = 1, 2, be two ℓ-rps’s. Then the cia
structure on C extended by the unique solutions si : Vi C → C of the ei is independent of
the order of extension.
Remark 5.18. More precisely, we may first take s1 : V1 C → C to obtain an extended cia
structure as in (5.4), and then take the solution of s2 : V2 C → C in the new cia, or vice
versa. Either way, the resulting extended cia structure is
\
H [b,s
1 ,s2 ]
H (K +\
V1 + V2 )C
/ HC
c−1
(5.8)
/C .
Proof of Proposition 5.17. It is sufficient to prove that the cia structure on C obtained by
b → C first by s1 and then by s2 is (5.8).
extending k : H KC
So take s1 and extend the cia structure (C, k) to obtain the cia
[
c−1 · H [b,
s1 ] : H K\
+ V1 (C) → C
(cf. (5.4)). Recall from the proof of Theorem 5.14 that this cia structure is obtained as
follows: one first forms the abstract GSOS rule
b · ℓ, e1 ] : (K + V1 )(H × Id) → H K\
n = [H inl
+ V1
whose interpretation is b′ = [b, s1 ] : (K + V1 )C → C, cf. (5.5), and then one applies
Theorem 3.5.
Now we form the following n-rps
V2 (H × Id)
e2
/ H K\
+ V2
\
H [inl,inr]
/ H (K +\
V1 + V2 ) .
Its unique solution is easily seen to be s2 ; indeed, consider the following diagram (and notice
\
′ , s ]):
that the right-hand arrow is H [b
2
V2 C
V2 hc,idC i
/ V2 (H × Id)C
(e2 )C
s2
Co
\
H [inl,inr]
C
/ H (K +\
/ H K\
+ V2 C❙
V1 + V2 )C
❙❙❙
❙❙❙
❙❙❙
\
H [b,s
❙❙❙
1 ,s2 ]
❙❙❙
\
H [b,s
2]
❙)
c−1
HC
The left-hand part commutes since s2 is the unique solution of e2 and for the right-hand
part we remove H and then precompose with κC to obtain
\
[b,\
s1 , s2 ] · [inl,
inr]C · κC
=
=
=
=
[b,\
s1 , s2 ] · κC · [inl, inr]C
[b, s1 , s2 ] · [inl, inr]C
[b, s2 ]
[
[b,
s2 ] · κC
cf. Remark 5.5(1)
see Remark 5.5(2)
see Remark 5.5(2)
The desired equality now follows since precomposition with κ yields an isomorphism of
categories, see Remark 5.5(2).
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
33
Remark 5.19. Notice that we can always consider the algebraic operation provided by c−1 :
b
HC → C as a given operation in any ℓ-rps for an abstract GSOS rule ℓ : K(H × Id) → H K.
′
More precisely, we can assume that K = K + H and that the ℓ-interpretation b : KC → C
c′
has the form b = [b′ , c−1 ]. Indeed, given any abstract GSOS rule ℓ′ : K ′ (H × Id) → H K
′
′
′
with ℓ -interpretation b , we define the ℓ -rps
e = (H(H × Id)
Hπ0
/ HH
Hinr
/ H(K ′ + H)
Hκ
′ + H).
/ H K\
It is easy to verify that c−1 is its solution; and, as we see from the proof of Theorem 5.14,
′ + H defined as in
we obtain a new abstract GSOS rule n : (K ′ + H)(H × Id) → H K\
′
−1
Construction 5.7 and having the n-interpretation [b , c ]. According to Proposition 5.17
we can do this construction at any step when defining operations, the result being always
b with K = K ′ + H and an ℓ-interpretation [b′ , c−1 ]
a GSOS rule ℓ : K(H × Id) → H K
containing the algebraic structure c−1 .
Summary 5.20. Again, we summarize and review our work in this section. Given an
appropriate tuple
b
(c : C → HC, ℓ : K(H × Id) → H K,
b : KC → C)
b
as in Summary 5.10 we know from Theorem 3.5 that c−1 · Hb
b is a cia for the functor H K.
The work in this section shows that the appropriate tuple in (5.1) is obtained as follows:
Let V be a functor, let F = K + V , and let e : V (H × Id) → H Fb be an ℓ-rps. We take the
unique interpreted solution s : V C → C of e, and then we obtain the appropriate tuple
(c : C → HC, n : F (H × Id) → H Fb, a = [b, s] : F C → C).
extending the earlier appropriate tuple.
This provides the desired modularity principle for solutions of ℓ-rps’s as discussed in the
introduction and again (restricted to flat equations) in Remark 3.3. On the level of concrete
syntactic specifications, the operations provided by the unique solution s : V C → C of any
ℓ-rps e may occur as givens in any subsequent n-rps f : W (H × Id) → H F\
+ W , which in
turn has a unique solution t : W C → C that yields another appropriate tuple etc. So our
results iterate as desired.
5.2. Sandwiched ℓ-rps’s. We will now prove a version of the Sandwich Theorem 3.6 for
ℓ-rps’s. The goal is to be able to solve specifications from a wider class uniquely. Let us
again explain the idea using the example of streams of reals. Here we have HX = R × X
on Set. Suppose that K and V both are polynomial functors associated with a signature of
givens and newly defined operations on the terminal coalgebra C = Rω . The inverse of the
coalgebra structure c = hhd, tli yields the family of prefix operations r.(−) prepending the
number r to a stream. The format of an ℓ-rps means that the new operations of type V are
always defined by an equation with a prefix operation as a guard at its head, see e. g. the
following specification of the shuffle product reformulated from the behavioral differential
equation of (5.2):
r.x ⊗ s.y = rs.((r.x ⊗ y) + (x ⊗ s.y)) .
This guard rs, − is sufficient to ensure a unique solution ⊗. However, in general it is not
necessary that the guard appears at the head of the term on the right-hand side of an
equation. We shall now define the more general format of sandwiched recursive program
34
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
schemes that allow the guard to occur further inside the term. A concrete example of this
kind of specification is the “parallel composition” of non-well founded sets in (1.3); here the
guarding operation is set-bracketing (xi )i∈I 7→ {xi | i ∈ I}, and this occurs inside the union
operation (we shall come back to this example in Section 6.5).
Definition 5.21. A sandwiched recursive program scheme w. r. t. ℓ (shortly, ℓ-srps) is a
b Fb.
natural transformation e : V (H × Id) → KH
An interpreted solution of e in C is a V -algebra structure s : V C → C such that
s=(VC
V hc,idC i
/ V (HC × C)
eC
/ KH
b FbC
d
b [b,s]
KH
/ KHC
b
b −1
Kc
/ KC
b
b
b
/ C ).
Remark 5.22. (1) The notion of an ℓ-srps subsumes the one of an ℓ-rps. Indeed, for a
given ℓ-rps e : V (H × Id) → H Fb one forms the ℓ-srps
V (H × Id)
e
ηH Fb
/HK
\
+V
b Fb .
/ KH
And one readily proves that solutions of this ℓ-srps in C are in one-to-one correspondence
with solutions of e in C.
(2) The notion of an ℓ-(s)rps is incomparable to the three formats of rps’s we saw in Section 4
(see Section 4.1(2)). Indeed, for polynomial functors on Set, the latter rps’s are systems of
recursive function equations that allow infinite trees on the right-hand sides while ℓ-(s)rps’s
correspond to recursive equations where right-hand sides are restricted to consist of terms
(or finite trees) only.
However, notice that classical recursive program schemes as in [20] are restricted to
allow only finite trees on right-hand sides of equations (as, e. g., in (1.5)). Such a restricted
rps corresponds to a natural transformation
e = (V
m
/H
\
+V
/ T H+V ),
\
where m : H
+ V → T H+V is the unique monad morphism from the free monad on H + V
H+V
to T
induced by κH+V : H + V → T H+V . This given recursive program scheme is
\
guarded if we have f : V → H H
+ V satisfying a similar property as f in Definition 4.5.
Now this clearly yields an ℓ-rps
e′ = ( V (H × Id)
V π1
/V
f
/ HH
\
+ V ),
where K = H and
ℓ = ( H(H × Id)
Hπ1
/H
Hη
b ).
/ HH
Again one readily proves that solutions of e′ are in one-to-one correspondence with solutions
of e, and so the restricted rps’s are a special instance of ℓ-rps’s.
We are now ready to state and prove the main result of this paper; it provides a unique
solution theorem for ℓ-rps’s, the most general specification format we consider in this paper.
\
In order to simplify notation we will write (M, η, µ) for the free monad K
+ V in the rest
of this section.
Theorem 5.23. (Sandwich Theorem for ℓ-srps’s) For every ℓ-srps there exists a unique
interpreted solution s in C. In addition, s extends the cia structure on C; more precisely,
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
35
the following is the structure of a cia for M HM on C:
d
M H [b,s]
M HM (C)
/ M H(C)
M c−1
/ M (C)
d
[b,s]
/C .
(5.9)
Proof. Recall from Remark 5.19 that we can assume K = K ′ + H and that the ℓ-interpretation has the form [b′ , c−1 ]. Furthermore recall from Remark 2.6(2) that ℓ gives rise to a
b
b of the free monad K
b over the cofree copointed
distributive law λ : K(H
× Id) → (H × Id)K
functor H × Id.
b
Given an ℓ-srps e : V (H × Id) → KHM
, we form the (ordinary) ℓ-rps e : V (H × Id) →
HM by defining
e
e = ( V (H × Id)
GF
b
K(HM
×M )
b
=K(H×Id)M
λM
b
/ KHM
/ (H × Id)KM
b
b
KhHM,inmM
i
/ K(HM
b
× (K ′ + H + V )M )
BC
b
K(HM
×ϕ)
b
π0 KM
b
H inlM
/ H KM
b
Hµ
/ HM M −
−→ HM ) .
Then we verify that solutions of e and e are in one-to-one correspondence. Consider the
following diagram (we drop the indices denoting components of natural transformations):
s
VC
V hc,idi
V (HC × C)
GF
e
b
KHM
C
d
b [b,s]
KH
b
Khid,ϕ·inmM
i
λM
b C
(H × Id)KM
b
π0 KM
b C
H KM
b
H inlM
HM M C
@A
(vi)
d
b [b,s]
(H×Id)K
(vii)
d
b [b,s]
HK
/ HM C
hc,idi
b
/ K(H
× Id)C
λ
b
/ (H × Id)KC
(v)
c
(5.10)
/ (H × Id)C
b
π0 K
(ix)
d
HM [b,s]
(xi)
Hµ
(iv)
ED
b
Khc,idi
(iii)
d
b
K(H×Id)
[b,s]
/ KC
b
)bb
Id
b −1
Kc
×
(ii)
/ KHC
b
(H
b
K(H
× Id)M C
e
(i)
/C
>
⑥
⑥⑥
⑥
⑥
⑥⑥
⑥
b
⑥
b ⑥
⑥⑥
⑥
⑥
⑥
⑥⑥
⑥⑥
d
H [b,s]
b
/ H KC
(viii)
❇❇
❇❇
π0
❇
b ❇❇
H inl
❇
❇
❇ Hbb
/ HM C (x) ❇❇
❇
◗◗◗
◗◗◗ ❇❇❇
◗◗◗ ❇❇
◗ ❇
d ◗◗◗◗❇! H [b,s]
(
/ HC o
BC
We first show that all inner parts except part (i) commute: for part (ii) use the definition of
e, part (iv) is the commutative diagram in (2.4), part (v) trivially commutes, the parts (vi),
b :K
b → M,
(vii), (viii) and (ix) commute by the naturality of λ, π0 : H × Id → H and inl
d
respectively, for part (x) use Remark 5.5(3), and part (xi) commutes since [b,
s] is the
36
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
structure of an Eilenberg-Moore algebra for M . It remains to verify the commutativity
b and consider the product components separately: the left-hand
of part (iii); we remove K
component commutes using c · c−1 = idC and for the right-hand one we have the diagram
d
H [b,s]
HM C
inmM
(K ′ + H + V )M C
ϕ
MC
d
(K ′ +H+V )[b,s]
/ HC
✐✐✐✐
✐
✐
✐
inm✐✐✐
✐✐✐✐
t ✐✐✐
✐
/ (K ′ + H + V )C
c−1
❯❯❯❯
❯❯❯❯
❯❯❯❯
❯❯❯❯
[b,s]
❯❯❯* /C.
d
[b,s]
Its upper part commutes by the naturality of inm : H → K ′ +H +V , for the lower part recall
d
from Notation 2.3 the definition of [b,
s] as a homomorphism of algebras for K ′ + H + V ,
and the right-hand triangle commutes since b = [b′ , c−1 ], see Remark 5.19.
Now if s is a solution of e, then the outside of Diagram (5.10) commutes. Therefore
part (i) commutes, and this proves that s is a solution of e. Conversely, if s is a solution
of e part (i) commutes and then s is also a solution of e. By Theorem 5.14, e has a unique
solution; thus, e has a unique solution, too.
We still need to prove that (5.9) is the structure of a cia for M HM . But this follows from
Theorem 3.6. Indeed, from the ℓ-rps e we form the abstract GSOS rule n : (K+V )(H×Id) →
HM analogously as in Construction 5.7, and the n-interpretation is [b, s] for the unique
solution s of e (or, equivalently, of e). Now the morphism in (5.9) is the structure k′ from
the statement of Theorem 3.6.
Remark 5.24. Notice that every operation on the terminal coalgebra C definable by a
sandwiched ℓ-rps is also definable by an ordinary ℓ-rps. In fact, the proof of the above
theorem gives a reduction of a given sandwiched ℓ-rps to an ordinary one with the same
solution. However, sandwiched ℓ-rps extend the syntactic format of recursive specifications
uniquely specifying operations on C.
5.3. Modularity, again. We formulated modularity principles in the Summaries 5.10
and 5.20. The same principles apply in the “sandwiched” case, mutatis mutandis.
Furthermore, we have modularity at the level of cia’s:
(1) For ℓ-srps’s the same modularity principle as discussed in Remark 5.15(2) applies. Given
b K
\
an ℓ-srps e : V (H × Id) → KH
+ V , then its unique solution s : V C → C arises as
\
the unique solution of the ℓ-rps e : V (H × Id) → H K
+ V . Thus, as before one can
form the abstract GSOS rule n : F (H × Id) → H Fb for F = K + V and use operations
of type F as givens in subsequent n-(s)rps’s.
(2) In addition, one can readily formulate and prove a version of Proposition 5.17 for
sandwiched ℓ-rps’s. We leave this straightforward task as an exercise for the reader.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
37
6. Applications
In this section we present five applications illustrating how to use our results from Section
3–5 to obtain unique solutions of recursive definitions in five different areas of theoretical
computer science.
6.1. Process Algebras. Recall Example 2.10(3) where HX = Pκ (A × X). We shall
first explain more in detail how the abstract GSOS rule ℓ is obtained. Recall that K is
the polynomial functor corresponding to the types of the CCS combinators, i. e., KX is a
coproduct of the following components (we shall denote elements in each component by the
corresponding flat terms):
(1) `
A × X with elements a.x, a ∈ A, for prefixing,
P
(2) n<κ X n with the n-the component consisting of elements ni=1 xi , for summation,2
(3) X × X with elements x1 |x2 , for parallel composition,
`
(4) f X, where f ranges over functions on the action set A with f (a) = f (ā) and f (τ ) = τ ,
with elements x[f ], for relabeling, and
`
(5) L⊆A\{ τ } X with elements x\L, for restriction.
b is given by the sos rules in Example 2.10(3)
The abstract GSOS rule ℓ : K(H × Id) → H K
in terms of the components of the coproduct K(H ×Id), i. e., for each combinator separately
(in the same order as above):
(1) ℓX (a, S, x) = {(a, S
x)} where S ⊆ A × X,
(2) ℓX ((Si , xi )i<n ) = i<n Si for every n < κ, where (Si )i<n is an n-tuple of sets Si ⊆ A×X,
(3) ℓX (S1 , x1 , S2 , x2 ) is given by the union of the three sets
{(a, x|x2 ) | (a, x) ∈ S1 } ,
{(a, x1 |x) | (a, x) ∈ S2 }
and
{(τ, x|y) | (a, x) ∈ S1 , (ā, y) ∈ S2 for some a ∈ A \ {τ }},
where S1 , S2 ⊆ A × X,
(4) ℓX (S, x) = {(f (a), y[f ]) | (a, y) ∈ S}, and
(5) ℓX (S, x) = {(a, y\L) | (a, y) ∈ S, a, ā 6∈ L}.
The form of these definitions is very similar to the ones given by Aczel [3] in the setting of
non-well-founded set theory. We already mentioned the ℓ-interpretation b : KC → C giving
b
the desired operations on CCS agents, and this gives the two new cia structures for H K
b K
b as in Theorems 3.5 and 3.6.
and KH
Now let us recall Milner’s solution theorem for CCS agents from [38]. Suppose that Ei ,
i ∈ I, are agent expressions with the free variables xi , i ∈ I. Suppose further that each
variable xj in each Ei , i, j ∈ I is weakly guarded, i. e., it only occurs within the scope of
some prefix combinator a.−. Then there is a unique solution of the system
xi = Ei ,
i ∈ I,
of mutually recursive equations. More precisely, let ∼ denote strong bisimilarity, and let
Ei [P~ /~x] denote simultaneous substitution of Pj for xj for every j. Then we have
Theorem 6.1. [38] There exist, up to ∼, unique CCS agents Pi such that Pi ∼ Ei [P~ /~x]
holds for each i ∈ I.
2The empty sum (for n = 0) is denoted by 0 as usual.
38
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
It is easy to see that this theorem is a consequence of our Theorem 2.16 because a
system xi = Ei where each variable is weakly guarded is essentially the same as a map
b KX,
b
X → KH
where X = {xi | i ∈ I}.
Furthermore, our Theorem 3.6 allows us to obtain unique solutions of flat equation
b KX
b + C. The extra summand C allows us to use constant agents in
morphisms X → KH
recursive specifications.
Example 6.2. Consider the recursive equation
x = a.(x|c) + b.0
from the introduction, where 0 denotes the empty sum (i. e. the “inactive agent”). For any
b = Pκ (A × KX)
b
set X, we identify elements of H KX
with terms of the form
X
ai .ti
i<κ
(modulo associativity, commutativity, idempotency and the unit laws for the sum), where
ai ∈ A and ti is a process term on variables from X for every i < κ.
b
So the above equation clearly gives an ℓ-equation f0 : {x} → H K{x},
and so we have
†
its unique solution f0 (x) = P in C from Theorem 2.12. Now consider the following system
y = b.(y + z)|a.z
z = P.
(6.1)
b K{y,
b
This gives a flat equation morphism {y, z} → KH
z} + C, which has a unique solution
in C by Theorem 3.6. Next recall Remark 3.3 and notice that the latter equation morphism
b K{y,
b
has the form f † • e, where e : {y, z} → KH
z} + {x} is given by two equations: the
b K{x}
b
first equation in (6.1) and z = x, and f : {x} → KH
+ C arises from f0 by forming
b {x}
f = inl · (ηH K)
as explained in Section 4.1(1). So we see that we obtain the same solution when we use the
constant P ∈ C in the recursive equation (6.1) in lieu of forming the composed system
x = a.(x|c) + b.0
y = b.(y + z)|a.z
z = a.(x|c) + b.0
that corresponds to the equation morphism f e.
We now turn to an applications of Theorem 5.23 that shows how to uniquely define
new process combinators. Suppose we want to define the binary combinator “alt” which
performs alternation of two processes. For its definition we shall first need another binary
combinator, sequential composition of two processes (denoted by the infix “;”). This is
defined by the following operations rules in GSOS format:
a
E → E′
a
F → F′
.
a
a
E; F → E ′ ; F
0; F → F ′
Here we suppose that the latter combinator is already included in our basic calculus—more
precisely, we add a sixth coproduct component X × X to K for sequential composition in
the above definition and complete ℓ above by
(
{(a, x; x2 ) | (a, x) ∈ S1 } if S1 6= ∅
ℓX (S1 , x1 , S2 , x2 ) =
S2
if S1 = ∅
for this coproduct component. The ℓ-interpretation then gives indeed the desired combinator for sequential composition. Moreover, as a consequence of Theorem 2.12 (now applied to
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
39
the extended K), we see that that Theorem 6.1 still holds for the calculus including this sixth
b K
\
combinator. Now for this extended ℓ we give a sandwiched ℓ-rps e : V (H ×Id) → KH
+V,
where V X = X × X, in order to define the combinator alt:


S1 ; {(a, x; alt(x1 , x2 )) | (a, x) ∈ S2 } if S2 6= ∅
eX (S1 , x1 , S2 , x2 ) = {(a, x; alt(x2 , x1 )) | (a, x) ∈ S1 }
if S1 6= ∅, S2 = ∅


∅
if S1 = S2 = ∅ .
\
Notice that the term in the first line of this definition does not lie in H K
+ V (X), so
Theorem 5.14 cannot be applied. Notice also that the above definition of e cannot be
directly translated into an operational rule in GSOS format as for the sequential composition
before. However, e could first be transformed into an ordinary ℓ-rps using the construction
from the proof of Theorem 5.23 and then translated to a set of operational rules in GSOS
b K
\
format. More directly, observe that the term in the first line does lie in KH
+ V (X), so
Theorem 5.23 tells us that e has a unique solution s : C × C → C. It is not difficult to
see that s = alt is the desired alternation combinator. Furthermore, Theorem 5.23 tells us
that s extends the cia structure on C from Theorem 3.6 applied to the abstract GSOS rule
ℓ. And, as before, this means that Theorem 6.1 remains true for the calculus extended by
sequential composition and alternation of processes, without further work.
6.2. Streams. Recall from Example 2.10(2) that here we take HX = R × X and we have
C = Rω with the structure given by hhd, tli : C → R × C. Rutten gives in [42] a general
theorem for the existence of the solution of systems of behavioral differential equations.
We will now recall this result and show that it is a special instance of our Theorem 5.14.
For a system of behavioral differential equations one starts with the signature Σ of all the
operations to be specified. One uses an infinite supply of variables, and for each variable
x there is also a variable x′ and a variable x(0) (also written as x0 ). For each operation
symbol f from Σ one specifies
f (x1 , . . . , xn )0 = hf (x1 (0), . . . , xn (0))
f (x1 , . . . , xn )′ = tf ,
Rn
(6.2)
where hf denotes a function from
to R and tf is a term built from operation symbols
′
from Σ on variables xi , xi and xi (0), i = 1, . . . , n. Theorem A.1 of [42] asserts that for every
f from Σ there exists a unique function (Rω )n → Rω satisfying the equation (6.2) above.
We shall now show that every system of behavioral differential equations (6.2) gives rise
to an ℓ-rps for a suitable abstract GSOS rule ℓ. To this end let KX = R be the constant
functor and let
Hκ /
ℓ′ /
b)
HK
HK
ℓ = (K(H × Id)
′
′
with ℓ given by ℓX (r) = (r, 0). Then the ℓ-interpretation b : R → C assigns to every r ∈ R
the stream b(r) = (r, 0, 0, . . . ).
Now given the system (6.2) let V be the polynomial functor associated with Σ, see
Example 2.4. Notice that K + V is the polynomial functor of the signature Σ extended with
a constant symbol r for every real number r. We translate the system (6.2) into an ℓ-rps
\
e : V (H × Id) → H K
+ V as follows. For every f from Σ the corresponding component of
eX is defined by
eX ((r1 , x′1 , x1 ), . . . , (rn , x′n , xn )) = (hf (r1 , . . . , rn ), tf ) ,
40
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
\
+ V (X) is obtained by replacing in tf all variables xi (0) by the
where the term tf ∈ K
constant ri . Notice also, that here hf (r1 , . . . , rn ) is a real number (the value of hf at
(r1 , . . . , rn )) whereas in (6.2) we have formal application of hf to the variables xi (0).
It is now straightforward to verify that a solution of e in C corresponds precisely to a
solution of the system (6.2). Thus, we obtain from Theorem 5.14 the
Theorem 6.3 ([42]). Every system of behavioral differential equations has a unique solution.
Example 6.4. For the system given by (2.5) and (5.2) we have V X = X × X + X × X
and e given componentwise as follows: for the + component we have
eX ((r, x′ , x), (s, y ′ , y)) = (r + s, x′ + y ′ )
(6.3)
and for the ⊗ component we have
eX ((r, x′ , x), (s, y ′ , y)) = (r · s, (x ⊗ y ′ ) + (x′ ⊗ y)) .
(6.4)
Observe that the systems of behavioral differential equations do not distinguish between given operations and newly defined ones. However, our result in Theorem 5.14 allows
us to make this distinction, and the modularity principle for solutions of ℓ-rps’s (cf. Summary 5.20) means that operations specified by behavioural differential equations may be
used in subsequent behavioral differential equations as given operations in the terms tf from
(6.2). We believe this modularity of unique solutions for behavioral differential equations
is a new result.
\
Example 6.5. Take V X = X × X and the ℓ-rps e : V (H × Id) → H K
+ V given by (6.3)
whose solution is the operation of stream addition + : V C ·C. As shown in Construction 5.7,
ℓ and e yield the abstract GSOS rule n : F (H × Id) → H Fb for F = K + V . Now let
V1 X = X × X. Then (6.4) yields an n-rps e1 : V1 (H × Id) → H F\
+ V1 whose solution is
the shuffle product ⊗ : V1 C → C.
Next, we present an example illustrating Proposition 5.17.
Example 6.6. Continuing the previous example, consider the convolution product of
streams specified by
(σ × τ )0 = σ0 · τ0
(σ × τ )′ = (σ ′ × τ + σ0 × τ ′ ) ,
see [42]. Let V2 X = X × X and let the n-rps e2 : V2 (H × Id) → H F\
+ V2 be given by
(e2 )X ((r, x′ , x), (s, y ′ , y)) = (r · s, (x′ × y) + (r × y ′ )) .
(6.5)
Notice that this illustrates why we introduced the constants r; in this way we are able to
deal with σ0 in the equation for (σ × τ )′ . Then the unique solution of e2 is the convolution
product as expected. Proposition 5.17 asserts that the extended cia structure for H Fb,
F = K + V + V1 + V2 on C does not depend on the order of taking the solution of (6.4)
and (6.5)—either way this is given by the constants coming from b and the operations of
stream addition as well as convolution and shuffle product.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
41
Stream circuits. We now turn to another method to define operations on streams—stream
circuits [43], which are also called (signal) flow graphs in the literature. We shall demonstrate that specification of operations by stream circuits arises as a special case of our
results. Stream circuits are usually defined as pictorial compositions of the following basic
stream circuits
▲▲
r
r-multiplier
adder
+
rr
r
r
C ▲▲ copier
r
register
The r-multiplier multiplies all elements in a stream by r ∈ R, the adder performs componentwise addition, the copier yields two copies of a stream, and the register prepends r ∈ R
to a stream σ to yield r.σ. The stream circuits are then built from the basic circuits by
plugging wires together, and there may also be feedback (loops). For example the following
picture shows a simple stream circuit:
σ
/+
O
/C
/ f (σ)
(6.6)
1o
It defines the following unary operation on stream:
f (σ) = (1 + σ0 , 1 + σ0 + σ1 , 1 + σ0 + σ1 + σ2 , . . . ).
For our treatment we shall consider the operations presented by r-multipliers, adders
and registers as givens. So let K be the polynomial functor associated with the signature
Σ given by these operations (copying will be implicit via variable sharing). In symbols,
KX = R × X + X × X + R × X. Our given operations are defined by the behavioral
differential equations:
(rσ)0 = rσ0
(σ + τ )0 = σ0 + τ0
(r.σ)0 = r
(rσ)′ = rσ ′
(σ + τ )′ = σ ′ + τ ′
(r.σ)′ = σ
As explained above these definitions easily give rise to an abstract GSOS rule ℓ :
b (see also [13, Section 3.5.1]). We then get the ℓ-interpretation in C
K(H × Id) → H K
and the corresponding extended cia structures by Theorems 3.5 and 3.6. A stream circuit
is called valid if every loop passes through at least one register. It is well-known that every
finite valid stream circuit with one input and one output defines a unique stream function
(see [43]). Of course, a similar result holds for more than one input and output, and we
present here a new proof of this result based on our Theorem 5.14.
Theorem 6.7. Every finite valid stream circuit defines a unique stream function at every
output.
Proof. Let a finite valid stream circuit be given. We explain how to construct an ℓ-rps
from the circuit. Notice first that the wires in a circuit can be regarded as directed edges
(cf. (6.6)). We take for every register R in our circuit an operation symbol gR and define
its arity as the number of inputs that can be reached by following all possible paths from
R backwards through the circuit. Similarly, we take for every output edge O of the circuit
an operation symbol fO with the arity obtained in the same way. Let Σ be the signature of
all fO and gR , and let V be the corresponding polynomial functor for Σ. To give an ℓ-rps
\
\
e : V (H × Id) → H K
+ V it suffices to give a natural transformation e′ : V H → H K
+V
42
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
and to define e = e′ · V π0 , where π0 : H × Id → H is the projection. To obtain e′ , we give
for each n-ary symbol s from Σ an assignment
s(r1 .x1 , . . . , rn .xn ) 7→ (r, t)
where r1 , . . . , rn , r ∈ R and t is a term built from symbols of Σ and of the signature Γ of
basic circuit operations using the variables x1 , . . . , xn . Notice that the arguments of s stand
for generic elements (ri , xi ) from HX for some set X and that r may depend on ri and t
may contain operation symbols ri .−. We now show how to define the above assignment for
each operation symbol gR . Suppose that the register R has the initial value r. Then
gR (r1 .x1 , . . . , rn .xn ) 7→ (r, tR ),
and we now explain how to obtain tR : in order to construct the term tR one starts in
R and traverses from there every possible path in the circuit backwards (i. e., one follows
edges from inputs to outputs of basic circuits) adding for every basic stream circuit the
corresponding operation symbol to tR until
(1) an input edge corresponding to some argument ri .xi is met, or
(2) some register is met.
More precisely, we construct tR as a (Σ + Γ)-tree: we follow the input edge of R backwards
until we reach either the output wire of an r-multiplier, the output wire of an adder, an
input wire of the whole circuit or the output wire of a register. For an r-multiplier or an
adder we add a node to tR labeled by the corresponding operation symbol and continue
this process for each input node of the r-multiplier or adder constructing the corresponding
subtrees of tR . For an input wire corresponding to ri .xi add a node labeled by the prefix
operation ri .− and below that a leaf labeled by xi ; for a register S add the tree (of height
2) given by gS (ri1 .xi1 , . . . , rik .xik ), where the rij .xij correspond to those input wires of the
circuit backwards reachable from the register S. (Notice that these arguments of gS form
a subset of the arguments { r1 .x1 , . . . , rn .xn } of gR since every input that is backwards
reachable from S is also backwards reachable from R. Also notice that copiers are ignored
while forming tR .) Since the given circuit C is valid we have indeed constructed only a
finite tree, whence a term tR .
We still need to define the assignment corresponding to e′ for output symbols fO :
fO (r1 .x1 , . . . , rn .xn ) 7→ (r, tO ) .
t′O
We first form the tree
in essentially the same way as tR for a register R with the
difference that for every input wire and for every register we just insert an unlabeled leaf
for the moment. To obtain r, label every leaf of t′O corresponding to the input ri .xi by ri and
every leaf corresponding to a register by its initial value; now evaluate the corresponding
term to get r. In order to get tO one replaces leaves of t′O corresponding to inputs ri .xi by
xi , and register leaves are replaced by the second components tS from the right-hand sides
of the equations for gS (ri1 .xi1 , . . . , rik .xik ).
Finally, the unique solution of e yields a unique operation fO on streams for every
output O. By construction this is the operation computing the stream circuit.
The modularity principle for the unique solution of an ℓ-rps which we discussed in
Summary 5.20 yields modularity of stream circuits: every stream circuit can be used as a
building block as if it were a basic operation in subsequent stream circuits. And Theorem 6.7
remains valid for the extended circuits.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
43
Example 6.8. The proof of Theorem 6.7 essentially gives a translation of an arbitrary
finite valid stream circuit into an ℓ-rps. We demonstrate this on the circuit given in (6.6)
above. First we introduce for the output a function symbol f and for the register output
the function symbol g. To determine their arity we count the number of input wires which
have a (directed) path to the register and the output, respectively. In both cases the arity
is one. Now we must give a definition of f (r.x) and g(r.x) for an abstract input stream with
head r ∈ R. These definitions are each given by a pair (s, t) where s ∈ R and t is a term in
the one variable x over operations corresponding to the basic circuits and f , g. We define
g(r.x) = (1, r.x + g(r.x))
f (r.x) = (r + 1, x + (r.x + g(r.x))) .
For g(r.x) we take the value 1 of the register as first component, and the right-hand term
is obtained as follows: we follow all paths from the register backwards until we find an
input or a register. So we get a finite tree or, equivalently, the desired term. For f (r.x)
we first follow all paths to inputs and registers backwards to get the term t′ = xI + xR ,
where xI represents the input and xR the register. For the first component of f (r.x) we
evaluate t′ with the head r of the input and the initial value 1 of the register, i. e., one
evaluates t′ [r/xI , 1/xR ]. And for the second component we replace in t′ the input by x
and the register by the second component of the right-hand side of the definition above of
g(r.x), i. e., one forms t′ [x/xI , r.x + g(r.x)/xR ]. The two equations above are easily seen to
\
yield an ℓ-rps e : V (H × Id) → H K
+ V , where V = Id + Id is the polynomial functor for
the signature with two unary symbols f and g. The unique solution of e gives two unary
operations fC , gC : C → C, and fC is precisely the function computed by the circuit (6.6)
and gC is the stream function output by the register in (6.6). By the modularity of stream
circuits explained above, we can use f (and also g) as “black-boxes” in subsequent stream
circuits.
6.3. Infinite Trees. Rutten and Silva [45] developed behavioral differential equations for
infinite trees and proved a unique solution theorem for them. Here we shall show that we
obtain their theorem as a special instance of our Theorem 5.14. The work is similar to what
we saw in Theorem 6.3 for streams.
Let HX = X × R × X. The terminal coalgebra C for H consists of all infinite binary
trees with nodes labeled in R, and the terminal coalgebra structure c : C → C × R × C
assigns to a tree the triple (tL , r, tR ) where r is the node label of the root of t and tL and
tR are the trees rooted at the left-hand right-hand child nodes of the root of t. Single trees
(constants) and operations on trees can be specified by behavioral differential equations.
For example,
piL = pi
pi(ε) = π
piR = pi
specifies the tree with every node labeled by the number π. For every real number r we
have the constant [r] specified by
[r]L = [0]
[r]R = [0] .
The nodewise addition of numbers stored in the nodes of the trees t and s is defined by
(t + s)L = tL + sL
(t + s)(ε) = t(ε) + s(ε)
(t + s)R = tR + sR .
[r](ε) = r
See [45] for further and more exciting examples.
44
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
In general a system of behavioral differential equations is specified as follows. Again,
we assume an infinite supply of syntactic variables. For every variable x we have the
notational variants xL , xR and also x(ε). Furthermore, let Σ be a signature of operations
to be specified. For each operation symbol f from Σ of arity n we provide equations of the
form
differential equations
initial value
(6.7)
f (x1 , . . . , xn )L = t1
(f (x1 , . . . , xn ))(ε) = cf (x1 (ε), . . . , xn (ε))
f (x1 , . . . , xn )R = t2
n
where cf denotes a function R → R and t1 and t2 are Σ-terms on the variables x1 , . . . , xn
and their three notational variants.
Theorem 6.9. ([45], Theorem 2) Every system (6.7) of behavioral differential equations
has a unique solution, i. e., for every f from Σ there exists a unique function f : C n → C
satisfying (6.7) (denoted by the same symbol).
We present a new, short proof of this result based on Theorem 5.14. Let KX = R be
the constant functor, and let the abstract GSOS rule ℓ be
ℓ = ( K(H × Id)
ℓ′
/ HK
Hκ
b )
/ HK
where the natural transformation ℓ′ is given by ℓ′X (r) = (0, r, 0). Then the ℓ-interpretation
is b : R → C with b(r) = [r]. Let V be the polynomial functor associated with Σ. Every
\
system (6.7) gives an ℓ-rps e : V (H × Id) → H K
+ V as follows: let e be given on each
component corresponding to f from Σ by
eX (((x1 )L , r1 , (x1 )R , x1 ), . . . , ((xn )L , rn , (xn )R , xn )) = (t1 , cf (r1 , . . . , rn ), t2 ) ,
where ti is obtained from ti by replacing each xi (ε) by the corresponding constant ri . The
solutions of e in C correspond precisely to solutions of (6.7); thus, Theorem 6.9 follows from
Theorem 5.14.
In addition, we have again a modularity principle (cf. Summary 5.20): operations specified by behavioral differential equations may be used as givens in subsequent behavioral
differential equations.
6.4. Formal Languages. Recall Example 2.10(3); here we have HX = X A × 2 on Set. A
coalgebra x : X → X A × 2 for H is precisely a deterministic automaton with the (possibly
infinite) state set X. Here C = P(A∗ ), and the unique homomorphism h : (X, x) → (C, c)
assigns to each state the language it accepts. We shall now show how various standard
operations on formal languages can be defined in a modular way using Theorem 5.14.
Working in a bialgebraic setting, Jacobs [24] shows that these operations can be defined as
interpretations of one abstract GSOS rule (or distributive law) in C. However, this account
does not explain why one may define these operations in a step-by-step fashion by successive
recursive definitions. This is the added value of Theorem 5.14.
We start with the functor K0 = C∅ (that means, we start from scratch with no given
c∅ = H given by the empty maps. The correoperations) and with ℓ0 : C∅ (H × Id) → H C
sponding interpretation is the empty map b : ∅ → C, and bb is then the identity on C. Thus,
c0 on C given by Theorem 3.5 is simply the initial cia (C, c−1 ) for
the cia structure for H K
H. At each subsequent step we are given a functor Ki and an abstract GSOS rule
ci with its interpretation bi : Ki C → C .
ℓi : Ki (H × Id) → H K
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
45
We then give an ℓi -rps
ei : Vi (H × Id) → H K\
i + Vi ,
and its unique solution si : Vi C → C extends the cia structure as follows: let Ki+1 = Ki +Vi
and let
b · ℓi , ei ] : Ki+1 (H × Id) → H K
[
ℓi+1 = [H inl
i+1 ,
b
c
[
where inl : Ki → K
i+1 is the monad morphism induced by inl : Ki → Ki+1 (cf. Notation 5.4(1)); so the formation of ℓi+1 from ℓi corresponds precisely to forming n from ℓ in
Construction 5.7. By induction it is easy to see that the ℓi+1 -interpretation is
bi+1 = [sj ]j=0,...,i : Ki+1 C → C .
And this gives an extended cia
[
c−1 · Hb
bi+1 : H K
i+1 (C) → C
by Theorem 3.5.
As a first step we define constants in C for ∅, {ε}, and {a}, for each a ∈ A, as solutions
of an ℓ0 -rps. We express this as an ℓ0 -rps as follows: take the functor V0 X = 1 + 1 +
c
A corresponding to these languages. We define e0 : V0 (H × Id) → H K\
0 + V0 = H V0
componentwise. We write for every set X, ∅ for inj1 (∗) ∈ V0 X and ε for inj2 (∗) ∈ V0 X.
Then (e0 )X is given by the assignments
∅ 7→ ((∅)a∈A , 0)
ε 7→ ((∅)a∈A , 1)
a 7→ ((tb )b∈A , 0),
(
ε if b = a
where tb =
∅ else .
(6.8)
It is now straightforward to check that the unique solution s0 of e0 yields the desired
constants in C extending the cia structure.
Next we add the operations of union, intersection and language complement to the cia
b · ℓ0 , e0 ] as above with interpretation b1 = s0 .
structure. Let K1 = K0 + V0 and let ℓ1 = [H inl
Let
V1 X = X × X + X × X + X
be the polynomial functor corresponding to two binary symbols ∪ and ∩ and one unary one
(−). We give the ℓ1 -rps
e1 : V1 (H × Id) → H K\
1 + V1
componentwise in the form of the three assignments in (6.9) below. We write ((xa ), j, x)
for elements of HX × X, where (xa ) is an |A|-tuple, i. e., an element of X A . We also write
elements of V2 Z, Z = HX × X, as flat terms z1 ∪ z2 , z1 ∩ z2 and z on the left-hand side for
the three components of (e1 )Z :
((xa ), j, x) ∪ ((ya ), k, y) 7→ ((xa ∪ ya ), j ∨ k)
((xa ), j, x) ∩ ((ya ), k, y) 7→ ((xa ∩ ya ), j ∧ k)
((xa ), j, x) 7→ ((xa ), ¬j)
(6.9)
where ∨, ∧ and ¬ are the evident operations on 2 = {0, 1}. The corresponding unique
solution s1 : V1 C → C is easily checked to provide the desired operations extending the cia
structure on C.
The next step adds (language) concatenation to the cia structure on C. For this let
V2 X = X × X
and let
e2 : V2 (H × Id) → H K\
2 + V2
46
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
be given by the assignment (where elements of V2 Z are written as z1 · z2 on the left-hand
side)
(
(xa · y) ∪ ya if j = 1
((xa ), j, x) · ((ya ), k, y) 7→ ((ta ), j ∧ k)
where ta =
(6.10)
xa · y
else .
As the final step we add the Kleene star operation by taking
V3 X = X
and
e3 : V3 (H × Id) → H K\
3 + V3
to be given by
e3 ((xa ), j, x) = ((xa · x∗ ), 1)
with the unique solution s3 = (−)∗ : C → C. Notice that this definition makes use of
concatenation which was a solution at the previous stage, and concatenation makes use of
union which was a solution at stage 1. This corresponds to the fact that for all languages
L, (L∗ )a = La · L∗ . Its unique solution s2 : C × C → C is the concatenation operation.
Remark 6.10. There are many further operations on formal languages that are definable
by ℓ-rps’s, including the following ones:
• prefixing a.L = {aw | w ∈ L} for any a ∈ A;
• the operation given by c−1 : C A × 2 → C (see Remark 5.19)
(S
a.La
if j = 0
((La ), j) 7→ Sa∈A
a∈A a.La ∪ {ε} else ;
S
• shuffle(L1 , L2 ) = w1 ∈L1 ,w2 ∈L2 shuffle(w1 , w2 ) where shuffle(w1 , w2 ) is the usual operation
merging the words w1 and w2 .
We leave it to the reader to work out the details. An example of an operation on languages
not definable by any ℓ-rps (or abstract GSOS rule) is the language derivative L 7→ La =
{w | aw ∈ L} for every a ∈ A; the argument is similar as for the non-definablity of the tail
operations on streams in Example 5.16, and so we leave those details to the reader, too.
Contex-free grammars. Next we show how context-free grammars in Greibach Normal
Form and their generated languages are special instances of flat equations of the form
b K
b and their unique solutions in C for a suitable functor K. (Note that
e : X → KH
these flat equations do not involve elements of C; that is, we do not need equations of the
b K
b + C.) A coalgebraic description of context-free grammars in Greibach
form e : X → KH
normal form has recently been given by Bonsangue, Rutten and Winter [48], and previously,
a coalgebraic approach to context-free grammars was given by Hasuo and Jacobs [21]. Our
approach here is completely different.
Recall (e. g. from [23]) that a context-free grammar is a four-tuple G = (A, N, P, S)
where A is a non-empty finite set of terminal symbols, N a finite set of non-terminal
symbols, P ⊆ N × (A + N )∗ is a finite relation with elements called production rules of G,
and S ∈ N is the starting symbol. As usual we write n → w for (n, w) ∈ P . A context-free
grammar G is in Greibach Normal Form (GNF, for short) if all its production rules are
of the form n → aw with a ∈ A and w ∈ N ∗ . The language generated by a context-free
grammar G is the set of all words over A that arise by starting with the string S and
repeatedly substituting substrings according to the production rules of the grammar, and
eliminating ε from the string whenever it occurs.
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
47
To see that context-free grammars in GNF yield flat equation morphisms, we consider
the constant ∅ and the operations of union and concatenation as given operations. More
precisely, let
KX = 1 + X × X + X × X
b be
be the polynomial functor corresponding to ∅, ∪ and ·, and let ℓ : K(H × Id) → H K
the abstract GSOS rule given by the corresponding assignments in (6.8), (6.9) and (6.10)
with the interpretation b : KC → C given as desired. By Theorem 3.6 we obtain the cia
b KC
b → C. Now observe that a flat equation morphism assigns to each
structure k′ : KH
x ∈ X either an element e(x) ∈ C or e(x) corresponds to a term of given operations in
b
H KX.
We now show that for every context-free grammar in GNF there is a flat equation
b with X finite whose solution e† : X → X has the property that
morphism e : X → H KX
†
e (S) is the language of the grammar. (Once again, note that each e(x) will belong to
b
b + C.)
H KX,
not just to the larger set H KX
Construction 6.11. Let G = (A, N, P, S) be a context-free grammar in GNF. We define
b KX.
b
the flat equation morphism eG : X → KH
The set X is simply the set N of nonterminals of G, and eG is the following map: for n ∈ N for which there is no production
b KX).
b
rule n → aw in P we take eG (n) = ∅, the constant term in K(H
Otherwise for each
production rule r = n → aw in P with n ∈ N on the left-hand side we define the term
b as
tr ∈ H KX
a.(n1 · n2 · · · · · nk ) if w = n1 n2 · · · nk and n1 , . . . , nk ∈ N ,
tr =
a.∅
if w = ε
using the concatenation operation. Recall from Remark 6.10 the notation a.t to see that
b
b KX)
b
tr ∈ H KX.
We define eG (n) as (the term in K(H
representing) the “union” of all
right-hand sides of production rules ri = n → awi , i = 1, . . . , l, in P ; so in symbols we have
eG (n) = tr1 ∪ tr2 ∪ · · · ∪ trl .
b
The point of using grammars in GNF is that each tr really belongs to H KX,
and so
b
b KX).
b
each eG (n) belongs to K(H KX),
hence to K(H
It is not difficult to see that the language generated by the grammar G is precisely the
language e†G (S), where S is the starting symbol of G. So as a consequence of Theorem 3.6
we see that the language generated by G arises as the unique solution of the flat equation
morphism eG .
Analogously, it is also possible to translate right-linear grammars (which are a special
case of context-free grammars generating regular languages) into flat equation morphisms
using the constant empty and empty-word languages as well as union as the given operations. Again Theorem 3.6 implies that there is a unique solution which yields the language
generated by the given grammar by the translation.
Remark 6.12. We have seen that by defining operations via ℓ-rps’s (or ℓ-srps’s) we obtain
b (or KH
b K)
b on C. It is interesting to ask what formal languages can
cia structures for H K
b (or sandwiched ones e : X → KH
b KX)
b
arise as solutions of ℓ-equations e : X → H KX
according to Theorems 2.12 and 2.16 if X is finite. Not surprisingly one obtains precisely
the regular languages for stages i = 0, 1, 2 in our definition process above, i. e., when we
add the constant languages ∅, {ε} and {a} for every a ∈ A, and the operations ∪, ∩ and
48
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
(−). But adding concatenation one obtains non-regular languages: if for i = 3 one restricts
c3 H K
c3 , the flat equation morphisms
to using union and concatenation in the terms in K
essentially correspond to context-free grammars in GNF. However, using intersection and/or
complement allows one to obtain non-context-free languages as solutions. Precisely what
class of languages can be defined by (sandwiched) ℓ-equations using different combinations
of operations remains the subject of further work.
6.5. Non-well-founded Sets. Finally, we come to an application not directly related to
computation. The theory of non-well-founded sets originated as a framework for providing
the semantics of general circular definition. For background on non-well-founded sets, the
antifoundation axiom (AFA), and classes, please see the books [3, 14]. We work here on
the category A = Class of classes. The results of Section 5 hold true for Class since every
endofunctor of Class has terminal coalgebras and free algebras (see [6]).
Consider P : Class → Class taking a class X to the class PX of subsets of X. AFA is
equivalent to the assertion that (C, c) is a terminal coalgebra, where C is the class of all
sets (usually written V ), and c : C → PC takes a set and considers it a set of sets. (That
is, c(s) = s for all s.) Let us note some natural transformations:
p : P → PP
pX (x) = P(x)
op : Id × Id → PP
opX (x, y) = {{x}, {x, y}}
cp : P × P → P(Id × Id)
cpX (x, y) = x × y
Also note that c−1 is the operation on C taking a family x ⊆ C of sets to the set { y | y ∈ x }.
We will now define three additional operations on C:
• the powerset operation b1 : x 7→ { y | y ⊆ x },
• the Kuratowski pair
b2 : (x, y) 7→ {{ x }, { x, y}}, and
• the cartesian product
b3 : (x, y) 7→ x × y.
So let K be the functor given by
KX = X + (X × X) + (X × X) + PX + PPX;
its first three components represent (the type of) our three desired operations, the fourth
component P represents c−1 and the fifth one represents c−1 · Pc−1 —the latter two are
needed for the definition of the former three. We write the coproduct injections of K as
inj1 , . . . , inj5 . We define a natural transformation ℓ′ : KP → PK componentwise, using
p
ℓ′ · inj1 P = (P
ℓ′ · inj2 P = (P × P
ℓ′
· inj3 P = (P × P
/ PP
opP
cp
Pinj4
/ PPP
/ PK )
Pinj5
/ P(Id × Id)
ℓ′ · inj4 P = (PP
/ PK )
Pinj2
ℓ′ · inj5 P = (PPP
/ PK )
Pinj4
Pinj5
/ PK )
/ PK )
Then ℓ′ yields an abstract GSOS rule
ℓ = (K(P × Id)
Kπ0
/ KP
ℓ′
/ PK
Pκ
/PK
b ).
Let b : KC → C be the ℓ-interpretation in C. Let us write b1 , . . . , b5 for the components
of b, so bi = b · (inji )C . To obtain explicit formulas for these, we use Diagram (2.3) and the
above definitions to write:
c · b1 = Pb4 · pC · c
c · b4 = Pb4 · Pc
c · b2 = Pb5 · opPC · (c × c)
c · b5 = Pb5 · P 2 c
c · b3 = Pb2 · cpC · (c × c)
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
49
We check easily that b4 = c−1 and b5 = c−1 · Pc−1 satisfy the last two equations. From
these we see that
b1 = c−1 · Pc−1 · pC · c,
b2 = c−1 · Pb5 · opPC · (c × c),
and
b3 = c−1 · Pb2 · cpC · (c × c).
In words, b4 and b5 are the identity, and b1 , b2 and b3 are as desired.
b
By Theorem 3.5, we have a cia structure (C, c−1 · Pb
b) for the composite P K.
Remark 6.13. We could have obtained the various operations on C in a step-by-step
fashion starting with b4 and b5 and then defining b1 , b2 , b3 by successive applications of
Theorem 5.14 as in the previous section on formal languages. We decided against this, to
keep the presentation short.
Continuing our discussion of non-well-founded sets, we may solve systems of equations
which go beyond what one finds in the standard literature on non-well-founded sets [3, 14].
For example, one may solve the system
x = {P(y)}
y = {y × y, z}
z = ∅,
b + C where X = {x, y, z}.
which gives rise to a flat equation morphism e : X → P KX
†
The unique solution of e satisfies e (z) = ∅ and assigns to y the non-well-founded set e† (y)
containing two elements: ∅ and the cartesian product of e† (y) with itself. And e† (x) is the
singleton non-well-founded set containing the powerset of e† (y) as its only element.
Finally, let us show how to obtain the operation specified by (1.3) in the introduction as
a unique solution of a sandwiched ℓ-rps according to Theorem 5.23. Here we have the union
operation ∪ as a given operation. So let KX = X × X be the corresponding polynomial
functor, and let us consider the natural transformation
uX : KPX → PX ,
uX (x, y) = x ∪ y .
We have the abstract GSOS rule
ℓ = (K(P × Id)
Kπ0
/ KP
u
/P
Pη
/PK
b)
whose interpretation is the union operation ∪ : C × C → C. Now let W X = X × X. Then
b
the equation (1.3) corresponds to a natural transformation e0 : W (P × Id) → KPW
, where
(e0 )X maps a pair
({xi | i ∈ I}, x), ({yj | j ∈ J}, y) ∈ W (PX × X)
to
b
{(x, yj ) | j ∈ J} ∪ {(xi , y) | i ∈ I} ∪ {(xi , yj ) | i ∈ I, j ∈ J} ∈ KPW
X.
From this we obtain an ℓ-srps
e = (W (P × Id)
e0
b
/ KPW
b
KPinr
/ KP(K
b
+ W)
K+W
b
KPκ
/ KP
b K\
+ W ).
Its unique solution in C is the desired “parallel composition” k : C × C → C of non-wellfounded sets.
50
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
7. Conclusions
In many areas of theoretical computer science, one is interested in recursive definitions of
functions on terminal coalgebras C for various functors H. This paper provides a more
comprehensive foundation for recursive definitions than had been presented up until now.
The overall idea is to present operations in terms of an abstract GSOS rule ℓ : K(H × Id) →
b We proved that ℓ induces new completely iterative algebra structures for H K
b and
H K.
b K
b on C. As a result, we are able to apply the existing body of solution theorems for
KH
cias to obtain new unique solution theorems for recursive equations of more general formats
“for free”.
Next we introduced the notion of an ℓ-rps and showed how to solve recursive function
definitions uniquely in C which are given by an ℓ-rps. Our results explain why taking unique
solutions of such equations is a modular process. And we have seen that our results can be
applied to provide the semantics of recursive specifications in a number of different areas of
theoretical computer science.
We also generalized this point to sandwiched ℓ-rps’s. The reason for doing this was
not to gain expressive power: every operation on C definable by a sandwiched ℓ-rps is also
definable by an ordinary ℓ-rps. The reason for the generalization was to have more usable
syntactic specification formats.
In concrete applications ℓ-rps’s (or abstract GSOS rules) are mostly given by finite sets
b
of rules or equations. But the conversion from an abstract GSOS rule ℓ : K(H × Id) → H K
(for set functors) to a coalgebra for H involves a finite-to-infinite blow-up, i. e., one forms
b
a H-coalgebra on KX,
which is typically an infinite set. We leave as an open question the
question to investigate exactly which operations are definable by finite ℓ-(s)rps’s.
Another related question concerns defining operations on the rational fixpoint of a
functor H [8, 34]; for a set functor H this is the subcoalgebra of the terminal H-coalgebra
given by the behavior of all finite coalgebras (e. g., regular processes, rational trees or regular
languages). The question is: when does an abstract GSOS rule induce operations on the
rational fixpoint for H? The answer to this is discussed in the recent paper [16], which is
inspired by the work of Aceto [1] who studied specification formats for operations on regular
processes (see also [2]).
There remain a number of other topics for further work. Firstly, it should be interesting to identify in the various applications concrete syntactic formats of operational rules
that correspond to ℓ-(s)rps’s. For example, in the case of process algebras as discussed in
Section 6.1, Turi and Plotkin [39] proved that abstract GSOS rules correspond precisely to
transition system specifications with operational rules in the GSOS format of [15]. Bartels
gave in his thesis [13] concrete syntactic rule formats for abstract GSOS rules in several other
concrete cases and Klin [28] studied the instantiation of abstract GSOS rules for weighted
transition systems. But concrete syntactic formats that are equivalently characterized by
ℓ-srps’s have not been studied yet.
Secondly, there remains the question whether our results can be generalized to other algebras than the initial cia (alias terminal coalgebra) along the lines of Capretta, Uustalu and
Vene [17] who generalized Bartels’ results from [12, 13]. A different kind of generalization
to be investigated concerns the step from using free monads in the definition of ℓ-(s)rps’s
to arbitrary monads. Thirdly, it should be interesting to work out further applications.
For example, it is clear that for weighted transition system specifications as considered by
Klin [28], our results can be used to obtain unique solutions of recursive specifications. It
ABSTRACT GSOS RULES AND A MODULAR TREATMENT OF RECURSIVE DEFINITIONS
51
should also be interesting to investigate whether our results yield unique solution theorems
for name and value passing process calculi as considered by Fiore and Turi [19]. Finally, it
would be of interest to extend the results of [36] on properties of recursive program scheme
solutions to the richer settings of this paper.
Acknowledgements. We thank the anonymous referees for their comments which helped
us to improve the presentation of this paper.
References
[1] L. Aceto. GSOS and finite labelled transition systems. Theoret. Comput. Sci., 131(1):181–195, 1994.
[2] L. Aceto, W. Fokking, and C. Verhoef. Handbook of Process Algebra, chapter Structural Operational
Semantics. Elsevier, 2001.
[3] P. Aczel. Non-Well-Founded Sets, volume 14 of CLSI Lecture Notes. CLSI Publications, Stanford, 1988.
[4] P. Aczel, J. Adámek, S. Milius, and J. Velebil. Infinite trees and completely iterative theories: A
coalgebraic view. Theoret. Comput. Sci., 300:1–45, 2003.
[5] J. Adámek. Introduction to coalgebra. Theory Appl. Categ., 14:157–199, 2005.
[6] J. Adámek, S. Milius, and J. Velebil. On coalgebras based on classes. Theoret. Comput. Sci., 316:3–23,
2004.
[7] J. Adámek, S. Milius, and J. Velebil. Elgot algebras. Log. Methods Comput. Sci., 2(5:4):31 pp., 2006.
[8] J. Adámek, S. Milius, and J. Velebil. Iterative algebras at work. Math. Structures Comput. Sci.,
16(6):1085–1131, 2006.
[9] J. Adámek and V. Trnková. Automata and Algebras in Categories, volume 37 of Mathematics and its
Applications. Kluwer Academic Publishers, 1990.
[10] P. America and J. J. M. M. Rutten. Solving reflexive domain equations in a category of complete metric
spaces. J. Comput. System Sci., 39:343–375, 1989.
[11] M. Barr. Coequalizers and free triples. Math. Z., 116:307–322, 1970.
[12] F. Bartels. Generalized coinduction. Math. Structures Comput. Sci., 13(2):321–348, 2003.
[13] F. Bartels. On generalized coinduction and probabilistic specification formats. PhD thesis, Vrije Universiteit Amsterdam, 2004.
[14] J. Barwise and L. S. Moss. Vicious circles. CLSI publications, Stanford, 1996.
[15] B. Bloom, S. Istrail, and A. R. Meyer. Bisimulation can’t be traced. J. ACM, 42(1):232–268, 1995.
[16] M. M. Bonsangue, S. Milius, and J. Rot. On the specification of operations on the rational behavior of systems. In B. Luttik and M. A. Reniers, editors, Proc. Combined Workshop on Expressiveness
in Concurrency and Structural Operational Semenatics (EXPRESS/SOS’12), Electron. Proc. Theoret. Comput. Sci., 2012. To appear.
[17] V. Capretta, T. Uustalu, and V. Vene. Recursive coalgebras from comonads. Inform. and Comput.,
204:437–468, 2006.
[18] M. Dekking, M. Mendès France, and A. J. van der Poorten. Folds! Mathematical Intelligencer, 4(3):130–
138, 1982.
[19] M. Fiore and D. Turi. Semantics of name and value passing. In Proc. 16th Annual Symposium on Logic
in Computer Science (LICS’01). IEEE Computer Society, 2001.
[20] I. Guessarian. Algebraic Semantics, volume 99 of Lecture Notes in Comput. Sci. Springer, 1981.
[21] I. Hasuo and B. Jacobs. Context-free languages via coalgebraic trace semantics. In J. F. et al., editor,
Proc. Algebra and Coalgebra in Computer Science: First International Conference (CALCO’05), volume
3629 of Lecture Notes in Comput. Sci., pages 213–231. Springer, 2005.
[22] F. Hausdorff. Grundzüge der Mengenlehre. Von Veit & Co., Leipzig, 1914.
[23] J. E. Hopcroft, R. Motwani, and J. D. Ullman. Introduction to Automata Theory, Languages and
Computation. Addison-Wesley Longman, Amsterdam, 3rd edition, 2007.
[24] B. Jacobs. A bialgebraic review of deterministic automata, regular expressions and languages. In Goguen
Festschrift, volume 4060 of Lecture Notes Comput. Sci., 2006.
[25] B. Jacobs. Distributive laws for the coinductive solution of recursive equations. Inform. and Comput.,
204(4):561–587, 2006.
52
S. MILIUS, L. S. MOSS, AND D. SCHWENCKE
[26] G. M. Kelly. A unified treatment of transfinite constructions for free algebras, free monoids, colimits,
associated sheaves, and so on. Bull. Austral. Math. Soc., 22:1–83, 1980.
[27] M. Kick and A. J. Power. Modularity of behaviour of mathematical operational semantics. In Proc. Coalgebraic Methods in Computer Science (CMCS’04), volume 106 of Electron. Notes Theor. Comput. Sci.,
pages 185–200, 2004.
[28] B. Klin. Structural operational semantics for weighted transition systems. In J. Palsberg, editor, Semantics and Algebraic Specification: Essays Dedicated to Peter D. Mosses on the Occasion of His 60th
Birthday, volume 5700 of Lecture Notes Comput. Sci., pages 121–139. Springer, 2009.
[29] J. Lambek. A fixpoint theorem for complete categories. Math. Z., 103:151–161, 1968.
[30] M. Lenisa, A. J. Power, and H. Watanabe. Distributivity for endofunctors, pointed and co-pointed
endofunctors, monads and comonads. In H. Reichel, editor, Proc. Coalgebraic Methods in Computer
Science, volume 33 of Electron. Notes Theor. Comput. Sci., Amsterdam, 2000. Elsevier.
[31] M. Lenisa, A. J. Power, and H. Watanabe. Category theory for operational semantics. Theoret. Comput. Sci., 327:135–154, 2004.
[32] S. MacLane. Categories for the working mathematician. Springer, 2nd edition, 1998.
[33] S. Milius. Completely iterative algebras and completely iterative monads. Inform. and Comput., 196:1–
41, 2005.
[34] S. Milius. A sound and complete calculus for finite stream circuits. In Proc. 25th Annual Symposium
on Logic in Computer Science (LICS’10), pages 449–458. IEEE Computer Society, 2010.
[35] S. Milius and L. S. Moss. The category theoretic solution of recursive program schemes. Theoret. Comput. Sci., 366:3–59, 2006.
[36] S. Milius and L. S. Moss. Equational properties of recursive program scheme solutions.
Cah. Topol. Gèom. Diffèr. Catèg., 50:23–66, 2009.
[37] S. Milius, L. S. Moss, and D. Schwencke. CIA structures and the semantics of recursion. In C.-H. L.
Ong, editor, Proc. Foundations of Software Science and Computation Structures (FoSSaCS), volume
6014 of Lecture Notes Comput. Sci., pages 312–327. Springer, 2010.
[38] R. Milner. Communication and Concurrency. International Series in Computer Science. Prentice Hall,
1989.
[39] G. D. Plotkin and D. Turi. Towards a mathematical operational semantics. In Proc. Logic in Computer
Science (LICS), 1997.
[40] A. J. Power. Towards a theory of mathematical operational semantics. In Proc. Coalgebraic Methods in
Computer Science (CMCS’03), volume 82 of Electron. Notes Theor. Comput. Sci., page 16 pp., 2003.
[41] J. J. M. M. Rutten. Universal coalgebra: a theory of systems. Theoret. Comput. Sci., 249(1):3–80, 2000.
[42] J. J. M. M. Rutten. A coinductive calculus of streams. Math. Structures Comput. Sci., 15(1):93–147,
2005.
[43] J. J. M. M. Rutten. A tutorial on coinductive stream calculus and signal flow graphs. Theor. Comput. Sci., 343(3):443–481, 2005.
[44] D. Schwencke. Coequational logic for accessible functors. Inform. and Comput., 208:1469–1489, 2010.
[45] A. Silva and J. J. M. M. Rutten. A coinductive calculus of binary trees. Inform. and Comput.,
208(5):578–593, 2010.
[46] D. Turi. Categorical modelling of structural operational rules: Case studies. In E. Moggi and G. Rosolini,
editors, Proc. Category Theory and Computer Science, volume 1290 of Lecture Notes Comput. Sci., pages
127–146. Springer, 1997.
[47] T. Uustalu, V. Vene, and A. Pardo. Recursion schemes from comonads. Nordic J. Comput., 8(3):366–
390, 2001.
[48] J. Winter, M. M. Bonsangue, and J. J. M. M. Rutten. Context-free languages, coalgebraically. In
Proc. Algebra and Coalgebra in Computer Science (CALCO’11), volume 6859 of Lecture Notes Comput. Sci., pages 359–376. Springer, 2011.
[49] J. Worrell. On the final sequence of a finitary set functor. Theoret. Comput. Sci., 338:184–199, 2005.
This work is licensed under the Creative Commons Attribution-NoDerivs License. To view
a copy of this license, visit http://creativecommons.org/licenses/by-nd/2.0/ or send a
letter to Creative Commons, 171 Second St, Suite 300, San Francisco, CA 94105, USA, or
Eisenacher Strasse 2, 10777 Berlin, Germany
Download