On CSP and the Algebraic Theory of Effects

Rob van Glabbeek and Gordon Plotkin^{∗}

Abstract We consider CSP from the point of view of the algebraic theory of effects, which classifies operations as effect constructors and effect deconstructors; it also provides a link with functional programming, being a refinement of Moggi’s seminal monadic point of view. There is a natural algebraic theory of the constructors whose free algebra functor is Moggi’s monad; we illustrate this by characterising free and initial algebras in terms of two versions of the stable failures model of CSP, one more general than the other. Deconstructors are dealt with as homomorphisms to (possibly non-free) algebras.

One can view CSP’s action and choice operators as constructors and the rest, such as concealment and concurrency, as deconstructors. Carrying this programme out results in taking deterministic external choice as constructor rather than general external choice. However, binary deconstructors, such as the CSP concurrency operator, provide unresolved difficulties. We conclude by presenting a combination of CSP with Moggi’s computational λ-calculus, in which the operators, including concurrency, are polymorphic. While the paper mainly concerns CSP, it ought to be possible to carry over similar ideas to other process calculi.

Rob van Glabbeek NICTA, Sydney, Australia University of New South Wales, Sydney, Australia Gordon Plotkin Laboratory for the Foundations of Computer Science, School of Informatics, University of Edinburgh, UK ∗ This work was done with the support of a Royal Society-Wolfson Award.

1 Introduction

We examine Hoare’s CSP [BHR84, Hoa85, Ros98] from the point of view of the algebraic theory of effects [PP02, PP04, HPP06, PPr09], a refinement of Moggi’s seminal ‘monads as notions of computation’ [Mog89, Mog91, BHM02]. This is a natural exercise as the algebraic nature of both points to a possibility of commonality. In the algebraic theory of effects operations do not all have the same character. Some are effect constructors: they create the effects at hand; some are effect deconstructors: they respond to effects created. For example, raising an exception creates an effect—the exception raised—whereas exception-handling responds to effects— exceptions that have been raised. It may therefore be interesting, and even useful, to classify CSP operators as constructors or deconstructors. Considering CSP and the algebraic theory of effects together also raises the possibility of combining CSP with functional programming in a principled way, as Moggi’s monadic approach provides a framework for the combination of computational effects with functional programming. More generally, although we mainly consider CSP, a similar exercise could be undertaken for other process calculi as they have a broadly similar algebraic character.

The theory of algebraic effects starts with the observation that effect constructors generally satisfy natural equations, and Moggi’s monad T is precisely the free algebra monad for these equations (an exception is the continuations monad which is of a different character). Effect deconstructors are treated as homomorphisms from the free algebra to another algebra, perhaps with the same carrier as the free algebra but with different operations. These operations can be given by combinations of effect constructors and previously defined deconstructors. The situation is much like that of primitive recursive definitions, although we will not present a formal definitional scheme.

We mainly consider that part of CSP containing action, internal and external choice, deadlock, relabelling, concealment, concurrency and interleaving, but not, for example, recursion (we do, albeit briefly, consider the extension with termination and sequencing). The evident constructors are then action prefix, and the two kinds of choice, internal and external, the latter together with deadlock. The evident deconstructors are relabelling, concealment, concurrency and interleaving. There is, however, a fly in the ointment, as pointed out in [PPr09]. Parallel operators, such as CSP’s concurrency and interleaving, are naturally binary, and respond to effects in both arguments. However, the homomorphic approach to deconstructors, as sketched above, applies only to unary deconstructors, although it is possible to extend it to accommodate parameters and simultaneous definitions. Nonetheless, the natural definitions of concurrency and interleaving do not fall within the homomorphic approach, even in the extended sense. This problem has nothing to do with CSP: it applies to all examples of parallelism of which we are aware.

Even worse, when we try to carry out the above analysis for CSP, it seems that the homomorphic approach cannot handle concealment. The difficulty is caused by the fact that concealment does not commute with external choice. Fortunately this difficulty can be overcome by changing the effect constructors: we remove external choice and action prefix and replace them by the deterministic external choice operator (a_{1} → P(a_{1}) | ... | a_{n} → P(a_{n})), where the a_{i} are all different. Binary external choice then becomes a deconstructor.

With that we can carry out the program of analysis, finding only the expected difficulty in dealing with concurrency and interleaving. However, it must be admitted that the n-ary operators are somewhat clumsy to work with, and it is at least a priori odd to take binary external choice as a deconstructor. On the other hand, in [Hoa85, Section 1.1.3] Hoare writes:

The definition of choice can readily be extended to more than two alternatives, e.g.,

(x → P | y → Q | ... | z → R)

Note that the choice symbol | is not an operator on processes; it would be syntactically incorrect to write P | Q, for processes P and Q. The reason for this rule is that we want to avoid giving a meaning to

(x → P | x → Q)

which appears to offer a choice of first event, but actually fails to do so.

which might be read as offering some support to a treatment which takes deterministic external choice as a primitive (here = constructor), rather than general external choice. On our side, we count it as a strength of the algebraic theory of effects that it classifies effect-specific operations and places constraints on them: that they either belong to the basic theory or must be defined according to a scheme that admits inductive proofs.

Turning to the combination with functional programming, consider Moggi’s computational λ-calculus. Just as one accommodates imperative programming within functional programming by treating commands as expressions of type unit, so it is natural to treat our selection of CSP terms as expressions of type empty as they do not terminate normally, only in deadlock. For process languages such as ACP [BK85, BK86] which do have the possibility of normal termination, or CSP with such a termination construct, one switches to regarding process terms as expressions of type unit, when a sequencing operator is also available.

As we have constructors for every T (X), it is natural to treat them as polymorphic constructs, rather than just as process combinators. For example, one could have a binary construction for internal choice, with typing rule:

\frac{M:σ N:σ}{M ⊓ N:σ}

It is natural to continue this theme for the deconstructors, as in:

\frac{M:σ}{M\a:σ}  \frac{M:σ  N:τ}{M ||N:σ × τ}

where the thought behind the last rule is that M and N are evaluated concurrently, terminating normally only if they both do, when the pair of results returned individually by each is returned.

In the case of CSP a functional programming language CSPM incorporating CSP processes has been given by Scattergood [Sca]; it is used by most existing CSP tools including the Failures Divergences Refinement Checker (FDR), see [Ros94]. Scattergood’s CPSM differs from our proposal in several respects. Most significantly, processes are not treated on a par with other expressions: in particular they cannot be taken as arguments in functions, and CSP constructors and deconstructors are only available for processes. It remains to be seen if such differences are of practical relevance.

In Section 3 we take deadlock, action, binary internal and external choice as the constructors. We show, in Theorem 3.4, that, with the standard equational theory, the initial algebra is the ‘finitary part’ of the original Brookes-Hoare-Roscoe failures model [BHR84]; which is known to be isomorphic to the finitary, divergenceand ✓-free part of the failures/divergences model, as well as the finitary, divergenceand ✓-free part of the stable failures model, both of which are described in [Ros98]. In Section 4 we go on to consider effect deconstructors, arriving at the difficulty with concealment and illustrating the problems with parallel operators in the (simpler) context of Milner’s synchronisation trees. A reader interested in the problem of dealing with parallel operators algebraically need only read this part, together with [PPr09].

We then backtrack in Section 5, making a different choice of constructors, as discussed above, and giving another characterisation of the finitary failures model as an initial algebra in Theorem 5.2. With that, we can carry out our programme, failing only where expected: with the binary deconstructors. In Section 6 we add a zero for the internal choice operator to our algebra; this can be interpreted as divergence in the stable failures model, and permits the introduction of a useful additional deterministic external choice constructor. Armed with this tool, in Section 7, we look at the combination of CSP and functional programming, following the lines hinted at above. In order to give a denotational semantics we need, in Theorem 7.4, to characterise the free algebras rather than just the initial one.

As remarked above, termination and sequencing are accommodated within functional programming via the type unit; in Section 7.1 we therefore also give a brief treatment of our fragment of CSP extended with termination and sequencing, modelling it in the free algebra over the one-point set.

The concluding Section 8 contains a brief discussion of the general question of combining process calculi, or parallelism with a global store, with functional programming. The case of CSP considered here is just one example of the many possible such combinations. Throughout this paper we do not consider recursion; this enables us to work within the category of sets. A more complete treatment would deal with recursion working within, say, the category of ω-cpos (i.e., partial orders with lubs of increasing ω-sequences) and continuous functions (i.e., monotone functions preserving lubs of increasing ω-sequences). This is discussed further in Section 8. The appendix gives a short presentation of Moggi’s computational λ-calculus.

2 Technical preliminaries

We give a brief sketch of finitary equational theories and their free algebra monads. For a fuller explanation see, e.g., [Bor94, AGM95]. Finitary equational theories Th are derived from a given set of axioms, written using a signature Σ consisting of a set of operation symbols op: n, together with their arities n ≥ 0. One forms terms t from the signature and variables and the axioms then consist of equations t = u between the terms; there is a natural equational logic for deducing consequences of the axioms; and the theory consists of all the equations derivable from the axioms. A ground equation is one where both terms are closed, meaning that they contain no variables.

For example, we might consider the fragment of CSP with signature □:2, Stop:0 and the following axioms for a semilattice (the first three axioms) with a zero (the last):

Associativity (x □ y) □ z = x □ (y □ z)
Commutativity  x □ y = y □ x
Idempotence  x □ x = x
Zero  x □ Stop = x

A Σ-algebra is a structure A = (X,(op_{A} :X^{n} → X)_{op:n∈Σ} ); we say that X is the carrier of A and the op_{A} are its operations. We may omit the subscript on operations when the algebra is understood. When we are thinking of an algebra as an algebra of processes, we may say ‘operator’ rather than ‘operation.’ A homomorphism between two algebras is a map between their carriers respecting their operations; we therefore have a category of Σ-algebras.

Given such a Σ-algebra, every term t has a denotation [[t]](ρ), an element of the carrier, given an assignment ρ of elements of the carrier to every variable; we often confuse terms with their denotation. The algebra satisfies an equation t = u if t and u have the same denotation for every such assignment. If A satisfies all the axioms of a theory Th, it is called a Th-algebra; the Th-algebras form a subcategory of the category of Σ-algebras. Any equation provable from the axioms of a theory This satisfied by any Th-algebra. We say that a theory This (ground) equationally complete with respect to a Th-algebra if a (ground) equation is provable from Thif, and only if, it is satisfied by the Th-algebra.

Any finitary equational theory Thdetermines a free algebra monad T_{Th} on the category of sets, as well as operations

op_{X}:T_{Th}(X)^{n} → T_{Th}(X)

for any set X and op: n ∈ Σ, such that (T_{Th}(X),(op_{X}:X^{n} → X)_{op:n∈Σ} ) is the free Thalgebra over X. Although T_{Th}(X) is officially just a set, the carrier of the free algebra, we may also use T_{Th}(X) to denote the free algebra itself. In the above example the monad is the finite powerset monad:

F (X) = {u ⊆ X | u is finite}

with □_{X} and Stop_{X} being union and the empty set, respectively.

3 A first attempt at analysing CSP

We consider the fragment of CSP with deadlock, action prefix, internal and external choice, relabelling and concealment, and concurrency and interleaving. Working over a fixed alphabet A of actions, we consider the following operation symbols:

Deadlock

                             Stop:0

Action

a → −:1 (a ∈ A)

Internal and External Choice

⊓,□:2

Relabelling and Concealment

f(−),−\a:1

for any relabelling function f : A → A and action a. If A is infinite, this makes the syntax infinitary; as that causes us no problems, we do not avoid it.

Concurrency and Interleaving

||,|||:2

The signature of our (first) equational theory CSP(□) for CSP only has operation symbols for the subset of these operators which are naturally thought of as constructors, namely deadlock, action and internal and external choice. Its axioms are those given by de Nicola in [DeN85]. They are largely very natural and modular, and are as follows:

• □,Stop is a semilattice with a zero (i.e., the above axioms for a semilattice with a zero).

• ⊓ is a semilattice (i.e., the axioms stating the associativity, commutativity and idempotence of ⊓).

• □ and ⊓ distribute over each other:

x □ (y ⊓ z) = (x □ y) ⊓ (x □ z) x ⊓ (y □ z) = (x ⊓ y) □ (x ⊓ z)

• Actions distribute over ⊓:

a → (x ⊓ y) = a → x ⊓ a → y

and:

a → x □ a → y = a → x ⊓ a → y

All these axioms are mathematically natural except the last which involves a relationship between three different operators.

We adopt some useful standard notational abbreviations. For n ≥ 1 we write ⨅_{i=1}^{n} t_{i} to abbreviate t_{1} ⊓ ...⊓ t_{n}, intending t_{1} when n = 1. We assume that parentheses associate to the left; however as ⊓ is associative, the choice does not matter. As ⊓ is a semilattice, we can even index over nonempty finite sets, as in ⨅_{i∈I} t_{i}, assuming some standard ordering of the t_{i} without repetitions. As □ is a semilattice with a zero, we can adopt analogous notations □_{i=1}^{n} t_{i} and □_{i∈I} t_{i} but now also allowing n to be 0 and I to be ∅.

As ⊓ is a semilattice we can define a partial order for which it is the greatest lower bound by writing t ⊑ u as an abbreviation for t ⊓u = t; then, as □ distributes over ⊓, it is monotone with respect to ⊑: that is, if x ⊑ x′and y ⊑ y′then x□y ⊑ x′□y′. (We mean all this in a formal sense, for example, that if t ⊑ u and u ⊑ v are provable, so is t ⊑ v, etc.) We note the following, which is equivalent to the distributivity of ⊓ over □, given that ⊓ and □ are semilattices, and the other distributivity, that □ distributes over ⊓:

x ⊓ (y □ z) = x ⊓ (y □ z) ⊓ (x □ y)  (1)

The equation can also be written as x ⊓ (y □ z) ⊑ (x □ y). Using this one can derive another helpful equation:

(x □ a → z) ⊓ (y □ a → w) = (x □ a → (z ⊓ w)) ⊓ (y □ a → (z ⊓ w))  (2)

We next rehearse the original refusal sets model of CSP, restricted to finite processes without divergence; this provides a convenient context for identifying the initial model of CSP(□) in terms of failures.

A failure (pair) is a pair (w,W) with w ∈ A^{∗} and W ⊆_{fin} A. For every set F of failure pairs, we define its set of traces to be

tr_{F} = {w | (w,∅) ∈ F }

and for every w ∈ tr_{F} we define its set of futures to be:

fut_{F}(w) = {a | wa ∈ tr_{F}}

With that a refusal set F (aka a failure set) is a set of failure pairs, satisfying the following conditions:

1. ε ∈ tr_{F}

2. wa ∈ tr_{F} ⇒ w ∈ tr_{F}

3. (w,W) ∈ F ∧ V ⊆ W ⇒ (w,V) ∈ F

4. (w,W) ∈ F ∧ a ∉ fut_{F} ⇒ (w,W ∪ {a}) ∈ F

A refusal set is finitary if its set of traces is finite.

The collection of finitary refusal sets can be turned into a CSP(□)-algebra R_{f} by the following standard definitions of the operators:

\begin{aligned}Stop_{R_{f}} & = & \{(ε,W) | W ⊆_{fin} A\} \\ a →_{R_{f}} F & = & \{(ε,W) | a ∉ W \} ∪ \{(aw,W) | (w,W) ∈ F \} \\ F ⊓_{R_{f}} G & = & F ∪ G \\ F □_{R_{f}} G & = & \{(ε,W) | (ε,W) ∈ F ∩ G\} ∪ \{(w,W) | w ≠ ε, (w,W) ∈ F ∪ G\} \end{aligned}

The other CSP operation symbols also have standard interpretations over the collection of finitary refusal sets:

\begin{aligned}f(F) & = & \{(f(w),W) | (w,f^{−1} (W) ∩ fut_{F}(w)) ∈ F \} \\ F \a & = & \{(w\a,W) | (w,W ∪ \{a\}) ∈ F \} \\ F || G & = & \{(w,W ∪ V) | (w,W) ∈ F, (w,V) ∈ G\} \\ F ||| G & = & \{(w,W) | (u,W) ∈ F, (v,W) ∈ G, w ∈ u|v\} \end{aligned}

with the evident action of f on sequences and sets of actions, and where w\a is obtained from w by removing all occurrences of a, and where u | v is the set of interleavings of u and v.

Lemma 3.1. Let F be a finitary refusal set. Then for every w ∈ tr_{F} there are V_{1},...,V_{n} ⊆ fut_{F}(w), including fut_{F}(w), such that (w,W) ∈ F iff W ∩ V_{i} = ∅ for some i ∈ {1,...,n}.

Proof. The closure conditions imply that (w,W) is in F iff (w,W ∩fut_{F}(w)) is. Thus we only need to be concerned about pairs (w,W) with W ⊆ fut_{F}(w). Now, as fut_{F}(w) is finite, for any relevant (w,W) ∈ F, of which there are finitely many, we can take V to be fut_{F}(w)\W, and we obtain finitely many such sets. As (w,∅) ∈ F, these include fut_{F}(w). ⊓ ⊔

Lemma 3.2. All finitary refusal sets are definable by closed CSP(□) terms.

Proof. Let F be a finitary refusal set. We proceed by induction on the length of the longest trace in F. By the previous lemma there are sets V_{1},...,V_{n}, including fut_{F}(ε), such that (ε,W) ∈ F iff W ∩ V_{i} = ∅ for some i ∈ {1,...,n}. Define F_{a}, for a ∈ fut_{F}(ε), by:

F_{a} = {(w,W) | (aw,W) ∈ F }

Then it is not hard to see that each F_{a} is a finitary refusal set, and that

F = ⨅_{i} □_{a∈V_{i}}a → F_{a}

As the longest trace in F_{a} is strictly shorter than the longest one in F, the proof concludes, employing the induction hypothesis. ⊓ ⊔

We next recall some material from de Nicola [DeN85]. Let L be a collection of sets; we say it is saturated if whenever L ⊆ L′⊆ ⋃ L, for L ∈ L then L′∈ L. Then a closed CSP(□)-term t is in normal form if it is of the form:

⨅_{L∈L} □_{a∈L}a → t_{a}

where L is a finite non-empty saturated collection of finite sets of actions and each term t_{a} is in normal form. Note that the concept of normal form is defined recursively.

Proposition 3.3. CSP(□) is ground equationally complete with respect to R_{f} .

Proof. Every term is provably equal in CSP(□) to a term in normal form. For the proof, follow that of Proposition A6 in [DeN85]; alternatively, it is a straightforward induction in which equations (1) and (2) are helpful. Further, it is an immediate consequence of Lemma 4.8 in [DeN85] that if two normal forms have the same denotation in R_{f} then they are identical (and Lemma 7.2 below establishes a more general result). The result then follows. ⊓ ⊔

Theorem 3.4. The finitary refusal sets algebra R_{f} is the initial CSP(□) algebra.

Proof. Let the initial such algebra be I. There is a unique homomorphism h:I → R_{f} . By Lemma 3.2, h is a surjection. By the previous proposition, R_{f} is complete for equations between closed terms, and so h is an injection. So h is an isomorphism, completing the proof. ⊓ ⊔

4 Effect deconstructors

In the algebraic theory of effects, the semantics of effect deconstructors, such as exception handlers, is given using homomorphisms from free algebras. In this case we are interested in T_{CSP(□)}(∅). This is the initial CSP(□) algebra, R_{f} , so given a CSP(□) algebra:

A = (T_{CSP(□)}(∅),⊓_{A} ,Stop_{A} ,(a →_{A} ),□_{A} )

there is a unique homomorphism:

h:R_{f} → A

Relabelling We now seek to define f(−):T_{CSP(□)}(∅) → T_{CSP(□)}(∅) homomorphically. Define an algebra Rlon T_{CSP(□)}(∅) by putting, for refusal sets F,G:

                         Stop_{Rl} = Stop_{R_{f}}

(a →_{Rl} F) = (f(a) →_{R_{f}} F)
F ⊓_{Rl}G = F ⊓_{R_{f}} G F □_{Rl}G = F □_{R_{f}} G

One has to verify this gives a CSP(□)-algebra, which amounts to verifying that the two action equations hold, for example that, for all F,G:

a →_{Rl} (F ⊓_{Rl}G) = (a →_{Rl} F) ⊓_{Rl}(a →_{Rl} G)

which is equivalent to:

f(a) →_{R_{f}} (F ⊓_{R_{f}} G) = (f(a) →_{R_{f}} F) ⊓_{R_{f}} (f(a) →_{R_{f}} G)

We therefore have a unique homomorphism

R_{f} −→^{h_{Rl}} Rl

and so the following equations hold over the algebra R_{f} :

                         h_{Rl}(Stop) = Stop

h_{Rl}(a → F) = f(a) → h_{Rl}(F)
h_{Rl}(F ⊓ G) = h_{Rl}(F) ⊓ h_{Rl}(G) h_{Rl}(F □ G) = h_{Rl}(F) □ h_{Rl}(G)

Informally one can use these equations to define h_{Rl} by a ‘principle of equational recursion,’ but one must remember to verify that the implicit algebra obeys the required equations.

We use h_{Rl} to interpret relabelling. We then immediately recover the familiar CSP laws:

                         f(Stop) = Stop

f(a → x) = f(a) → f(x)
f(x ⊓ y) = f(x) ⊓ f(y) f(x □ y) = f(x) □ f(y)

which we now see to be restatements of the homomorphism of relabelling.

Concealment There is a difficulty here. We do not have that

(F □ G)\a = F \a □ G\a

but rather have the following two equations (taken from [DeN85]):

((a → F) □ G)\a = F \a ⊓ ((F □ G)\a)  (3)

(□_{i=1}^{n}a_{i}F_{i})\a = □_{i=1}^{n}a_{i}(F_{i}\a)  (4)

where no a_{i} is a. Furthermore, there is no direct definition of concealment via an equational recursion, i.e., there is no suitable choice of algebra, □_{A} etc. For, if there were, we would have:

(F □ G)\a = F \a □_{A} G\a  (5)

So if a does not occur in any trace of F′or G′we would have:

F′□_{A} G′= F′\a □_{A} G′\a
= (F′□ G′)\a
= F′□ G′

but, returning to equation (5), a certainly does not occur in any trace of F \a or G\a and so we would have:

\begin{aligned}(F □ G)\a & = & F \a □_{A} G\a \\ & = & F \a □_{R_{f}} G\a \end{aligned}

which is false. It is conceivable that although there is no direct homomorphic definition of concealment, there may be an indirect one where other functions (possibly with parameters—see below) are defined homomorphically and concealment is definable as a combination of those.

4.1 Concurrency operators

Before trying to recover from the difficulty with concealment, we look at a further difficulty, that of accommodating binary deconstructors, particularly parallel operators. We begin with a simple example in a strong bisimulation context, but rather than a concurrency operator in the style of CCS we consider one analogous to CSP’s ||.

We take as signature a unary action prefix, a.−, for a ∈ A, a nullary NIL and a binary sum +. The axioms are that + is a semilattice with zero NIL; the initial algebra is then that of finite synchronisation trees ST. Every synchronisation tree τ has a finite depth and can be written as

∑_{i=1}^{n} a_{i}.τ_{i}

for some n ≥ 0, where the τ_{i} are also synchronisation trees (of strictly smaller depth), and where no pair (a_{i},τ_{i}) occurs twice. The order of writing the summands makes no difference to the tree denoted.

One can define a binary synchronisation operator || on synchronisation trees τ = ∑_{i}a_{i}.τ_{i} and τ′= ∑_{j} b_{j}.τ_{j} by induction on the depth of τ (or τ′):

τ || τ′= ∑_{a_{i}=b_{j}} a_{i}.(τ_{i} || τ′_{j})

Looking for an equational recursive definition of ||, one may try a ‘mutual (parametric) equational recursive definition’ of || and a certain family ||^{a} with x,y,z varying over ST:

\begin{aligned}NIL || z & = & NIL \\ (x + y) || z & = & (x || z) + (y || z) \\ a.x || z & = & x ||^{a} z \end{aligned}

and

                   z ||^{a} NIL = NIL

z ||^{a} (x + y) = (z ||^{a} x) + (z ||^{a} y)
z ||^{a} b.x = \{ \begin{matrix}a.(z || x) & (if b = a) \\ NIL & (if b ≠ a) \end{matrix}

Unfortunately, this definition attempt is not an equational recursion. Mutual (parametric) equational recursions are single ones to an algebra on a product. Here we wish a map: ST→ ST× ST. Informally we would write such clauses as:

⟨(x + y) || z , z ||^{a} (x + y)⟩ = ⟨(x || z) + (y || z) , (z ||^{a} x) + (z ||^{a} y)⟩

with the recursion variables, here x,y, on the left for || and on the right for ||^{a}. However:

⟨a.x || z , z ||^{a} b.x⟩ = \{ {⟨x ||^{a} z , a.(z || x)⟩ \atop (if b = a)} ; ⟨x ||^{a} z , NIL⟩ (if b ≠ a)

does not respect this discipline: the recursion variable, here x, (twice) switches places with the parameter z.

We are therefore caught in a dilemma. One can show, by induction on the depth of synchronisation trees, that the above definitions, viewed as equations for || and ||^{a} have a unique solution: the expected synchronisation operator ||, and the functions ||^{a} defined on synchronisation trees τ and τ′= ∑_{j} b_{j}.τ_{j} by:

τ ||^{a} τ′= ∑_{b_{j} =a} a.(τ || τ_{j})

So we have a correct definition not in equational recursion format. So we must either

• find a different correct definition in the equational recursion format

or else

• find another algebraic format into which the correct definition fits.

When we come to the CSP parallel operator we do not even get as far as we did with synchronisation trees. The problem is like that with concealment: the distributive equation:

(F □ F′) || G = (F || G) □ (F′|| G)

does not hold. One can show that there is no definition of || analogous to the above one for synchronisation trees, i.e., there is no suitable choice of algebra, □_{A} etc, and functions ||^{a}. The reason is that there is no binary operator □′on (finitary) failure sets such that, for all F,G,H we have:

(F □ F′) || G = (F || G) □′(F′|| G)

For suppose, for the sake of contradiction, that there is such an operator. Then, fixing F and F′, choose G such that F || G = F, F′|| G = F′and (F □F′) || G = (F □F′). Then, substituting into the above equation, we obtain that F □ F′= F □′F′and so the above equation yields distributivity, which, in fact, does not hold. As in the case of concealment, there may nonetheless be an indirect definition of ||.

A similar difficulty obtains for the CSP interleaving operator. It too does not commute with □, and it too does not have any direct definition (the argument is like that for the concurrency operator but a little simpler, taking G = Stop). As in the case of the concurrency operator, there may be an indirect definition.

5 Another choice of CSP effect constructors

Equations (3) and (4) do not immediately suggest a recursive definition of concealment. However, one can show that, for distinct actions a_{i} (i = 1,n), the following equation holds between refusal sets:

(□_{i=1}^{n}a_{i} → F_{i})\a_{j} = (F_{j}\a_{j}) ⊓ ((F_{j}\a_{j}) □ □_{i≠j}a_{i} → (F_{i}\a_{j}))

where 1 ≤ j ≤ n. Taken together with equation (4), this suggests a recursive definition in terms of deterministic external choice. We therefore now change our choice of constructors, replacing binary external choice, action prefix and deadlock by deterministic external choice.

So as our second signature for CSP we take a binary operation symbol ⊓ of internal choice and, for any deterministic action sequence a⃗ (i.e., any sequence of actions a_{i} (i = 1,n), with the a_{i} all different and n ≥ 0), an n-ary operation symbol □a⃗ of deterministic external choice. We write □a⃗(t_{1},...,t_{n}) as □_{i=1}^{n} a_{i}t_{i} although it is more usual to use Hoare’s notation (a_{1} → t_{1} | ···| a_{n} → t_{n}); we also use Stop to abbreviate □a⃗().

We have the usual semilattice axioms for ⊓. Deterministic external choice is commutative, in the sense that:

□_{i}a_{i}x_{i} = □_{i}a_{π(i)}x_{π(i)}

for any permutation π of {1,...,n}. Given this, we are justified in writing deterministic external choices over finite, possibly empty, sets of actions, □_{a∈I} at_{a}, assuming some standard ordering of pairs (a,t_{a}) without repetitions.

For the next axiom it is convenient to write (a_{1} → t_{1})□□_{i=2}^{n} a_{i}t_{i} for □_{i=1}^{n} a_{i}t_{i} (for n ≥ 0). The axiom states that deterministic external choice distributes over internal choice:

(a_{1} → (x ⊓ x′)) □ □_{i=2}^{n}a_{i}x_{i} = ( (a_{1} → x) □ □_{i=2}^{n}a_{i}x_{i}) ⊓ ( (a_{1} → x′) □ □_{i=2}^{n}a_{i}x_{i})

This implies that deterministic external choice is monotone with respect to ⊑.

We can regard a, possibly nondeterministic, external choice, in which the a_{i} need not be all different, as an abbreviation for a deterministic one, via:

□_{i}a_{i}t_{i} = □_{b∈{a_{1},...,a_{n}}}b( ⨅_{a_{i}=b} t_{i})  (6)

With that convention we may also write a_{1} → t_{1} □ □_{i=2}^{n} a_{i}t_{i} even when a_{1} is some a_{i}, for i > 1. We can now write our final axiom:

( □_{i}a_{i}x_{i}) ⊓ ( (b_{1} → y_{1}) □ □_{j=2}^{n}b_{j}y_{j} ) ⊑ (b_{1} → y_{1}) □ □_{i}a_{i}x_{i}  (7)

Restricting the external choice (b_{1} → y_{1}) □ □_{j} b_{j}y_{j} to be deterministic gives an equivalent axiom, as does restricting □_{i}a_{i}x_{i} (in the presence of the others).

Let us call this equational theory CSP(|). The finitary refusal sets form a CSP(|)- algebra R_{df} with the evident definitions:

\begin{aligned}F ⊓_{R_{df}} G & = & F ∪ G \\ (□a⃗)_{R_{df}} (F_{1},...,F_{n}) & = & \{(ε,W) | W ∩ \{a_{1},...,a_{n}\} = ∅\} ∪ \{(a_{i}w,W) | (w,W) ∈ F_{i}\} \end{aligned}

Theorem 5.1. The finitary refusal sets algebra R_{df} is complete for equations between closed CSP(|) terms.

Proof. De Nicola’s normal form can be regarded as written in the signature of CSP(|), and a straightforward induction proves that every CSP(|) term can be reduced to such a normal form using the above axioms. But two such normal forms have the same denotation whether they are regarded as CSP(□) or as CSP(|) terms, and in the former case, by Lemma 4.8 of [DeN85], they are identical. ⊓ ⊔

Theorem 5.2. The finitary refusal sets algebra R_{df} is the initial CSP(|) algebra.

Proof. Following the proof of Lemma 3.2 we see that every finitary refusal set is definable by a closed CSP(|) term. With that, initiality follows from the above completeness theorem, as in the proof of Theorem 3.4. ⊓ ⊔

Turning to the deconstructors, relabelling again has a straightforward homomorphic definition: given a relabelling function f : A → A, h_{Rl}: T_{CSP(|)}(∅) → T_{CSP(|)}(∅) is defined homomorphically by:

h_{Rl}(F ⊓ G) = h_{Rl}(F) ⊓ h_{Rl}(G)

h_{Rl}(□_{i}a_{i}F_{i}) = □_{i}f(a_{i})h_{Rl}(F_{i})

As always one has to check that the implied algebra satisfies the equations, here those of CSP(|).

There is also now a natural homomorphic definition of concealment, −\a, but, surprisingly perhaps, one needs to assume that □ is available. For every a ∈ A one defines h_{a}:T_{CSP(|)}(∅) → T_{CSP(|)}(∅) homomorphically by:

h_{a}(F ⊓ G) = h_{a}(F) ⊓ h_{a}(G)

h_{a}( □_{i=1}^{n}a_{i}F_{i}) = { h_{a}(F_{j}) ⊓ (h_{a}(F_{j}) □ □_{i≠j} a_{i}h_{a}(F_{i})) ; (if a = a_{j}, where1 ≤ j ≤ n) □_{i=1}^{n} a_{i}h_{a}(F_{i}) (if a ≠ any a_{i})

Verifying that the implicit algebra obeys satisfies the required equations is quite a bit of work. We record the result, but omit the calculations:

Proposition 5.3. One can define a CSP(|)-algebra Conon T_{CSP(|)}(∅) by:

F ⊓_{Con}G = F ⊓ G

(□a⃗)_{Con}(F_{1},...,F_{n}) = \{ \begin{matrix}F_{j} ⊓ (F_{j} □ □_{i≠j} a_{i}F_{i}) & (ifa = a_{j}) \\ □_{i}a_{i}F_{i} & (ifa ≠ any a_{i}) \end{matrix}

The operator □ is, of course, no longer available as a constructor. However, it can alternatively be treated as a binary deconstructor. While its treatment as such is no more successful than our treatment of parallel operators, it is also no less successful. We define it simultaneously with (n+1)-ary functions □^{a_{1}...a_{n}} on T_{CSP(|)}(∅), for n ≥ 0, where the a_{i} are all distinct. That we are defining infinitely many functions simultaneously arises from dealing with the infinitely many deterministic choice operators (there would be be infinitely many even if we considered them as parameterised on the a’s). However, we anticipate that this will cause no real difficulty, given that we have overcome the difficulty of dealing with binary deconstructors.

Here are the required definitions:

(F ⊓ F′) □ G= (F □ G) ⊓ (F′□ G)
(□_{i}a_{i}F_{i}) □ G= (F_{1},...,F_{n}) □^{a_{1}...a_{n}} G

(F_{1},...,F_{n}) □^{a_{1}...a_{n}} (G ⊓ G′)= ((F_{1},...,F_{n}) □^{a_{1}...a_{n}} G) ⊓ ((F_{1},...,F_{n}) □^{a_{1}...a_{n}} G′)
(F_{1},...,F_{n}) □^{a_{1}...a_{n}} (□_{j}b_{j}G_{j})= (a_{1} → F_{1}) □ (...((a_{n} → F_{n}) □ □_{j}b_{j}G_{j})...) (8)

where, in the last equation, the notational convention (a_{1} → t_{1}) □ □_{i=2}^{n} a_{i}t_{i} is used n times. It is clear that □ together with the functions

□^{a_{1}...a_{n}}:T_{CSP(|)}(∅)^{n+1} → T_{CSP(|)}(∅)

defined by:

□^{a_{1}...a_{n}}(F_{1},...,F_{n},G) = (□_{i}a_{i}F_{i}) □ G  (9)

satisfy the equations, and, using the fact that all finitary refusal sets are definable by normal forms, one sees that they are the unique such functions.

We can treat the CSP parallel operator || in a similar vein following the pattern given above for parallel merge operators in the case of synchronisation trees. We define it simultaneously with (n+1)-ary functions ||^{a_{1}...a_{n}} on T_{CSP(|)}(∅), for n ≥ 0, where the a_{i} are all distinct:

(F ⊓ F′) || G= (F || G) ⊓ (F′|| G)
(□_{i}a_{i}F_{i}) || G= (F_{1},...,F_{n}) ||^{a_{1}...a_{n}} G

(F_{1},...,F_{n}) ||^{a_{1}...a_{n}} (G ⊓ G′)= ((F_{1},...,F_{n}) ||^{a_{1}...a_{n}} G) ⊓ ((F_{1},...,F_{n}) □^{a_{1}...a_{n}} G′)
(F_{1},...,F_{n}) ||^{a_{1}...a_{n}} (□_{j}b_{j}G_{j})= □_{a_{i}=b_{j}} a_{i}(F_{i} || G_{j})  (10)

Much as before, || together with the functions ||^{a_{1}...a_{n}}: T_{CSP(|)}(∅)^{n+1} → T_{CSP(|)}(∅) defined by:

||^{a_{1}...a_{n}} (F_{1},...,F_{n},G) = (□_{i}a_{i}F_{i}) || G

are the unique functions satisfying the equations.

Finally we consider the CSP interleaving operator |||. We define this by following an idea, exemplified in the ACP literature [BK85, BK86], of splitting an associative operation into several parts. Here we split ||| into a left interleaving operator |||^{l} and a right interleaving operator |||^{r} so that:

F ||| G = (F |||^{l} G) □ (F |||^{r} G)

In ACP the parallel operator is split into three parts: a left merge, a right merge (defined in terms of the left merge), and a communication merge; in a subtheory, PA, there is no communication, and the parallel operator, now an interleaving one, is split into left and right parts [BK86]. The idea of splitting an associative operation into several operations can be found in a much wider context [EFG08] where the split into two or three parts is axiomatised by the respective notions of dendriform dialgebra and trialgebra.

Our left and right interleaving are defined by the following ‘binary deconstructor’ equations:

(F ⊓ F′) |||^{l} G= (F |||^{l} G) ⊓ (F′|||^{l} G)
(□_{i=1}^{n}a_{i}F_{i}) |||^{l} G= □_{i}a_{i}((F_{i} |||^{l} G) □ (F_{i} |||^{r} G))

G |||^{r} (F ⊓ F′)= (G |||^{r} F) ⊓ (G |||^{r} F′)
G |||^{r} (□_{i=1}^{n}a_{i}F_{i})= □_{i}a_{i}((G |||^{l} F_{i}) □ (G |||^{r} F_{i}))  (11)

As may be expected, these equations also have unique solutions, now given by:

\begin{aligned}F |||^{l} G & = & \{(ε,W) | (ε,W) ∈ F \} ∪ \{(w,W) | (u,W) ∈ F, (v,W) ∈ G, w ∈ u|^{l}v\} \\ F |||^{r} G & = & \{(ε,W) | (ε,W) ∈ G\} ∪ \{(w,W) | (u,W) ∈ F, (v,W) ∈ G, w ∈ u|^{r}v\} \end{aligned}

where u|^{l} v is the set of interleavings of u and v which begin with a letter of u, and u|^{r}v is defined analogously. It is interesting to note that:

F |||^{l} (G ⊓ G′) = (F |||^{l} G) ⊓ (F |||^{l} G′)

and similarly for |||^{r}.

6 Adding divergence

The treatment of CSP presented thus far dealt with finite divergence-free processes only. There are several ways to extend the refusal sets model of Section 3 to infinite processes with divergence. The most well-known model is the failures/divergences model of [Hoa85], further elaborated in [Ros98]. A characteristic property of this model is that divergence, i.e., an infinite sequence of internal actions, is modelled as Chaos, a process that satisfies the equation:

Chaos□ x = Chaos⊓ x = Chaos  (12)

So after Chaos no further process activity is discernible.

An alternative extension is the stable failures model proposed in [BKO87], and also elaborated in [Ros98]. This model equates processes that allow the same observations, where actions and deadlock are considered observable, but divergence does not give rise to any observations. A failure pair (w,W)—now allowing W to be infinite—records an observation in which w represents a sequence of actions being observed, and W represents the observation of deadlock under the assumption that the environment in which the observed process is running allows only the (inter)actions in the set W. Such an observation can be made if after engaging in the sequence of visible actions w, the observed process reaches a state in which no further internal actions are possible, nor any actions from the set W. Besides failure pairs, also traces are observable, and thus the observable behaviour of a process is given by a pair (T,F) where T is a set of traces and F is a set of failure pairs. Unlike the model R_{f} of Section 3, the traces are not determined by the failure pairs. In fact, in a process that can diverge in every state, the set of failure pairs is empty, yet the set of traces conveys important information.

In the remainder of this paper we add a constant Ω to the signature of CSP that is a zero for the semilattice generated by ⊓. This will greatly facilitate the forthcoming development. Intuitively, one may think of Ω as divergence in the stable failures model.

W.r.t. the equational theory CSP(□) of Section 3 we thus add the constant Ω and the single axiom:

x ⊓ Ω = x  (13)

thereby obtaining the theory CSP(□,Ω). We note two useful derived equations:

x ⊓ (Ω □ y) = x ⊓ (x □ y)
(Ω □ x) ⊓ (Ω □ y) = (Ω □ x) □ (Ω □ y)  (14)

Semantically, a process is now given by a pair (T,F), where T is a set of traces and F is a set of failure pairs that satisfy the following conditions:

1. ε ∈ T

2. wa ∈ T ⇒ w ∈ T

3. (w,W) ∈ F ⇒ w ∈ T

4. (w,W) ∈ F ∧ V ⊆ W ⇒ (w,V) ∈ F

5. (w,W) ∈ F ∧ ∀a ∈ V.wa ∉ T ⇒ (w,W ∪ V) ∈ F (where V ⊆ A)

The two components of such a pair P are denoted T_{P} and F_{P}, respectively, and for w ∈ T_{P} we define fut_{P}(w) := {a ∈ A | wa ∈ T_{P}}. We can define the CSP operators on processes by setting

P opQ = (P op_{T} Q,P op_{R} Q)

where op_{T} is given by:

\begin{aligned}Stop_{T} & = & \{ε\} \\ a →_{T} P & = & \{ε\} ∪ \{aw | w ∈ T_{P}\} \\ P ⊓_{T} Q & = & T_{P}∪ T_{Q} \\ P □_{T} Q & = & T_{P}∪ T_{Q} \\ f_{T} (P) & = & \{f(w) | w ∈ T_{P}\} \\ P\_{T} a & = & \{w\a | w ∈ T_{P}\} \\ P ||_{T} Q & = & \{w | w ∈ T_{P}, w ∈ T_{Q}\} \\ P |||_{T} Q & = & \{w | u ∈ T_{P}, v ∈ T_{Q}, w ∈ u|v\} \end{aligned}

and op_{R} is given as op_{R_{f}} was in Section 3, but without the restriction to finite sets W in defining Stop_{R}. For the new process Ω we set

Ω_{T} = {ε} and Ω_{R} = ∅

This also makes the collection of processes into a CSP(□,Ω)-algebra, F.

A process P is called finitary if T_{P} is finite. The finitary processes evidently form a subalgebra of F; we call it F_{f} .

Lemma 6.1. Let P be a finitary process. Then, for every w ∈ T_{P} there is an n ≥ 0 and V_{1},...,V_{n}⊆ fut_{F}(w) such that (w,W) ∈ F_{P} iff W ∩V_{i} = ∅ for some i ∈ {1,...,n}.

Proof. Closure conditions 4 and 5 above imply that (w,W) ∈ F_{P} if, and only if, (w,W ∩ fut_{P}(w)) ∈ F_{P}. Thus we only need to be concerned about pairs (w,W) with W ⊆ fut_{P}(w). Now, as fut_{P}(w) is finite, for any relevant (w,W) ∈ F, of which there are finitely many, we can take V to be fut_{P}(w)\W, and we obtain finitely many such sets. ⊓ ⊔

Note that it may happen that n = 0, in contrast with the case of Lemma 3.1.

Lemma 6.2. All finitary processes are definable by closed CSP(□,Ω) terms.

Proof. Let P be a finitary process. We proceed by induction on the length of the longest trace in T_{P}. By the previous lemma there are sets V_{1},...,V_{n}, for some n ≥ 0, such that (ε,W) ∈ F iff W ∩ V_{i} = ∅ for some i ∈ {1,...,n}. Define T_{a} and F_{a}, for a ∈ T_{P}, by:

T_{a} = {w | aw ∈ T_{P}} F_{a} = {(w,W) | (aw,W) ∈ F_{P}}

Then it is not hard to see that each P_{a} := (T_{a},F_{a}) is a finitary process, and that

P = ( ⨅_{i} □_{a∈V_{i}}a → P_{a}) ⊓ ( Ω □ □_{a∈T_{P}}a → P_{a})

As the longest trace in T_{a} is strictly shorter than the longest one in T_{P}, the proof concludes, employing the induction hypothesis. ⊓ ⊔

Proposition 6.3. CSP(□,Ω) is ground equationally complete with respect to both F and F_{f} .

Proof. This time we recursively define a normal form as a CSP(□,Ω)-term of the form

⨅_{L∈L} □_{a∈L}a → t_{a} or Ω □ □_{a∈K}a → t_{a}

where L is a finite non-empty saturated collection of finite sets of actions, K is a finite set of actions, and each term t_{a} is in normal form. Every term is provably equal in CSP(□,Ω) to a term in normal form; the proof proceeds as for Proposition 3.3, but now also using the derived equations (14). Next, by Lemma 7.2 below, if two normal forms have the same denotation in F then they are identical. So the result follows for F, and then for F_{f} too, as all closed terms denote finitary processes. ⊓ ⊔ Theorem 6.4. The algebra F_{f} of finitary processes is the initial CSP(□,Ω) algebra.

Proof. Let the initial such algebra be I. There is a unique homomorphism h:I → F_{f} . By Lemma 6.2, h is a surjection. By the previous proposition, F_{f} is complete for equations between closed terms, and so h is an injection. Hence h is an isomorphism, completing the proof. ⊓ ⊔

As in Section 5, in order to deal with deconstructors, particularly hiding, we replace external choice by deterministic external choice. The availability of Ω permits useful additional such operators. The equational theory CSP(|,Ω) has as signature the binary operation symbol ⊓, and for any deterministic action sequence a⃗, the n-ary operation symbols □a⃗ (as in Section 5), as well as the new n-ary operation symbols □Ω ; a⃗ , for n ≥ 0, which denote a deterministic external choice with Ω as one of the summands. We adopt conventions for □Ω ; a⃗ analogous to those previously introduced for □a⃗(t_{1},...,t_{n}). We write □Ω ; a⃗ (t_{1},...,t_{n})as Ω □ □_{i=1}^{n} a_{i}t_{i}. We also write Ω □ (c_{1} → t_{1}) □ □_{j=2}^{n} c_{j}t_{j} for Ω □ □_{j=1}^{n} c_{j}t_{j}, so that the c_{j} (j = 1,n) must all be distinct.

The first three groups of axioms of CSP(|,Ω) are:

• ⊓,Ω is a semilattice with a zero—here Ω is the 0-ary case of □Ω ; a⃗ ,

• both deterministic external choice operators □a⃗ and □Ω ; a⃗ are commutative, as explained in Section 5, and

• both deterministic external choice operators distribute over internal choice, as explained in Section 5,

Given commutativity, we are, as before, justified in writing deterministic external choices □_{a∈I} at_{a} or Ω □ □_{a∈I} at_{a}, over finite, possibly empty, sets of actions I, assuming some standard ordering of pairs (a,t_{a}) without repetitions. Next, using the analogous convention to (6) we can then also understand Ω □□_{j=1}^{n} c_{j}t_{j}, and so also Ω □ (c_{1} → t_{1}) □ □_{j=2}^{n} c_{j}t_{j}, even when the c_{j} are not all distinct. With these conventions established, we can now state the final group of axioms. These are all variants of Axiom (7) of Section 5, allowing each of the two deterministic external choices to have an Ω-summand:

( Ω □ □_{i}a_{i}x_{i}) ⊓ ( Ω □ (b_{1} → y_{1}) □ □_{j=2}^{n}b_{j}y_{j} ) ⊑ Ω □ (b_{1} → y_{1}) □ □_{i}a_{i}x_{i}

( Ω □ □_{i}a_{i}x_{i}) ⊓ ( (b_{1} → y_{1}) □ □_{j=2}^{n}b_{j}y_{j} ) ⊑ Ω □ (b_{1} → y_{1}) □ □_{i}a_{i}x_{i}

( □_{i}a_{i}x_{i}) ⊓ ( Ω □ (b_{1} → y_{1}) □ □_{j=2}^{n}b_{j}y_{j} ) ⊑ (b_{1} → y_{1}) □ □_{i}a_{i}x_{i}

( □_{i}a_{i}x_{i}) ⊓ ( (b_{1} → y_{1}) □ □_{j=2}^{n}b_{j}y_{j} ) ⊑ (b_{1} → y_{1}) □ □_{i}a_{i}x_{i}  (15)

As in the case of Axiom (7), restricting any of these choices to be deterministic results in an axiom of equivalent power. We note two useful derived equations:

□_{i}a_{i}x_{i}⊓ (Ω □ □_{j}b_{j}y_{j}) = □_{i}a_{i}x_{i}⊓ (□_{i}a_{i}x_{i}□ □_{j}b_{j}y_{j})
(Ω □ □_{i}a_{i}x_{i}) ⊓ (Ω □ □_{j}b_{j}y_{j}) = (Ω □ □_{i}a_{i}x_{i}) □ □_{j}b_{j}y_{j}  (16)

where two further notational conventions are employed: (□_{i=1}^{m} a_{i}t_{i}) □ (□_{j=1}^{n} b_{j}t′_{j}) stands for □_{k=1}^{m+n} c_{k}t′′_{k}where c_{k} = a_{k} and t′′_{k}= t_{k}, for k = 1,m, and c_{k} = b_{k−m}, and t′′_{k}= t′_{k−m}, for k = m+1,m+n; and (Ω □□_{i=1}^{m} a_{i}t_{i})□(□_{j=1}^{n} b_{j}t′_{j}) is understood analogously. In fact, the first three axioms of (15) are also derivable from (16), in the presence of the other axioms, and thus may be replaced by (16).

The collection of processes is turned into a CSP(|,Ω)-algebra F_{d} as before, writing:

P op_{F_{d}} Q = (P op_{T_{d}} Q,P op_{R_{d}} Q)

and defining op_{T_{d}} and op_{R_{d}} in the evident way:

\begin{aligned}P ⊓_{T_{d}} Q & = & T_{P}∪ T_{Q} \\ (□a⃗)_{T_{d}}(P_{1},...,P_{n}) & = & \{ε\} ∪ \{a_{i}w | w ∈ T_{P_{i}}\} \\ (□Ω ; a⃗ )_{T_{d}}(P_{1},...,P_{n}) & = & \{ε\} ∪ \{a_{i}w | w ∈ T_{P_{i}}\} \\ (□Ω ; a⃗ )_{R_{d}}(P_{1},...,P_{n}) & = & \{(a_{i}w,W) | (w,W) ∈ F_{P_{i}}\} \end{aligned}

with ⊓_{R_{d}} and (□a⃗)_{R_{d}} given just as in Section 5. Exactly as in Section 5, but now using the derived equations (16), we obtain:

Theorem 6.5. The algebra F_{d} is complete for equations between closed CSP(|,Ω) terms.

Theorem 6.6. The finitary subalgebra F_{df} of F_{d} is the initial CSP(|,Ω) algebra.

Turning to the deconstructors, relabelling and concealment can again be treated homomorphically. For relabelling by f one simply adds the equation:

h_{Rl}(Ω □ □_{i}a_{i}F_{i}) = Ω □ □_{i}f(a_{i})h_{Rl}(F_{i})

to the treatment in Section 5, and checks that the implied algebra satisfies the equations. Pleasingly, the treatment of concealment can be simplified in such a way that the deconstructor □ is no longer needed. For every a ∈ A one defines h_{a}:T_{CSP(|,Ω)} (∅) → T_{CSP(|,Ω)} (∅) homomorphically by:

h_{a}(P ⊓ Q) = h_{a}(P) ⊓ h_{a}(Q)

h_{a}( □_{i=1}^{n}a_{i}P_{i}) = \{ \begin{matrix}h_{a}(P_{j}) ⊓ (Ω □ □_{i≠j} a_{i}h_{a}(P_{i})) & (if a = a_{j}, where1 ≤ j ≤ n) \\ □_{i=1}^{n} a_{i}h_{a}(P_{i}) & (if a ≠ any a_{i}) \end{matrix}

h_{a}( Ω □ □_{i=1}^{n}a_{i}P_{i}) = \{ \begin{matrix}h_{a}(P_{j}) ⊓ (Ω □ □_{i≠j} a_{i}h_{a}(P_{i})) & (if a = a_{j}, where1 ≤ j ≤ n) \\ Ω □ □_{i=1}^{n} a_{i}h_{a}(P_{i}) & (if a ≠ any a_{i}) \end{matrix}

Note the use of the new form of deterministic choice here. One has again to verify that the implicit algebra obeys satisfies the required equations. The treatment of the binary deconstructors □, || and ||| is also a trivial adaptation of the treatment in Section 5. For □ one adds a further auxiliary operator □^{Ω,a_{1}...a_{n}} and the equations:

(Ω □ □_{i}a_{i}P_{i}) □ Q = (P_{1},...,P_{n}) □^{Ω,a_{1}...a_{n}} Q
(P_{1},...,P_{n}) □^{Ω,a_{1}...a_{n}} (Q ⊓ Q′)= \begin{matrix}((P_{1},...,P_{n}) □^{Ω,a_{1}...a_{n}} Q) ⊓ \\ ((P_{1},...,P_{n}) □^{Ω,a_{1}...a_{n}} Q′) \end{matrix}

(P_{1},...,P_{n}) □^{Ω,a_{1}...a_{n}} (□_{j}b_{j}Q_{j})= (Ω □ □_{i}a_{i}P_{i}) □ □_{j}b_{j}Q_{j}
(P_{1},...,P_{n}) □^{Ω,a_{1}...a_{n}} (Ω □ □_{j}b_{j}Q_{j})= (Ω □ □_{i}a_{i}P_{i}) □ □_{j}b_{j}Q_{j}
(P_{1},...,P_{n}) □^{a_{1}...a_{n}} (Ω □ □_{j}b_{j}Q_{j})= (Ω □ □_{i}a_{i}P_{i}) □ □_{j}b_{j}Q_{j}

For || one adds the auxiliary operator ||^{Ω,a_{1}...a_{n}} and the equations:

(Ω □ □_{i}a_{i}P_{i}) || Q = (P_{1},...,P_{n}) ||^{Ω,a_{1}...a_{n}} Q
(P_{1},...,P_{n}) ||^{Ω,a_{1}...a_{n}} (Q ⊓ Q′)= \begin{matrix}((P_{1},...,P_{n}) ||^{Ω,a_{1}...a_{n}} Q) ⊓ \\ ((P_{1},...,P_{n}) □^{Ω,a_{1}...a_{n}} Q′) \end{matrix}

(P_{1},...,P_{n}) ||^{Ω,a_{1}...a_{n}} (□_{j}b_{j}Q_{j})= Ω □ □_{a_{i}=b_{j}} a_{i}(P_{i} || Q_{j})

(P_{1},...,P_{n}) ||^{Ω,a_{1}...a_{n}} (Ω □ □_{j}b_{j}Q_{j})= Ω □ □_{a_{i}=b_{j}} a_{i}(P_{i} || Q_{j})

(P_{1},...,P_{n}) ||^{a_{1}...a_{n}} (Ω □ □_{j}b_{j}Q_{j})= Ω □ □_{a_{i}=b_{j}} a_{i}(P_{i} || Q_{j})

Finally, for ||| one simply adds extra equations:

(Ω □ □_{i=1}^{n}a_{i}P_{i}) |||^{l} Q = Ω □ □_{i}a_{i}((P_{i} |||^{l} Q) □ (P_{i} |||^{r} Q))

Q |||^{r} (Ω □ □_{i=1}^{n}a_{i}P_{i}) = Ω □ □_{i}a_{i}((Q |||^{l} P_{i}) □ (Q |||^{r} P_{i}))

7 Combining CSP and functional programming

To combine CSP with functional programming, specifically the computational λcalculus, we use the monad T_{CSP(|,Ω)} for the denotational semantics. As remarked above, CSP processes then become terms of type empty. However, as the constructors are polymorphic, it is natural to go further and look for polymorphic versions of the deconstructors. We therefore add polymorphic constructs to λ_{c} as follows:

Constructors

\frac{M:σ N:σ}{M ⊓ N:σ}  \frac{M:σ}{a → M:σ}  Ω:σ

Unary Deconstructors

\frac{M:σ}{f(M):σ}  \frac{M:σ}{M\a:σ}

for any relabelling function f, and any a ∈ A. (One should really restrict the allowable relabelling functions in order to keep the syntax finitary.)

Binary Deconstructors

\frac{M:σ N:σ}{M □ N:σ}  \frac{M:σ N:τ}{M || N:σ × τ}  \frac{M:σ N:τ}{M ||| N:σ × τ}

The idea of the two parallel constructs is to evaluate the two terms in parallel and then return the pair of the two values produced. We did not include syntax for the two deterministic choice constructors as they are definable from a → − and Ω with the aid of the □ deconstructor.

For the denotational semantics, the semantics of types is given as usual using the monad T_{CSP(|,Ω)} , which we know exists by the general considerations of Section 2. These general considerations also yield a semantics for the constructors. For example, for every set X we have the map:

⊓_{X}:T_{CSP(|,Ω)} (X)^{2} → T_{CSP(|,Ω)} (X)

which we can use for X = [[σ]] to interpret terms M ⊓ N:σ.

The homomorphic point of view also leads to an interpretation of the unary deconstructors, but using free algebras rather than just the initial one. For example, for relabelling by f we need a function:

h_{Rl}:T_{CSP(|,Ω)} (X) → T_{CSP(|,Ω)} (X)

We obtain this as the unique homomorphism extending the unit η_{X}:X→T_{CSP(|,Ω)} (X), equipping T_{CSP(|,Ω)} (X) with the algebra structure A = (T_{CSP(|,Ω)} (X),⊓_{A},□_{A},□_{A}^{Ω}) where

x ⊓_{A} y = x ⊓_{X}y

for x,y ∈ T_{CSP(|,Ω)} (X),

(□a⃗)_{A} (x_{1},...,x_{n}) = (□_{f(a⃗)})_{X}(x_{1},...,x_{n})

and

(□Ω ; a⃗ )_{A} (x_{1},...,x_{n}) = (□_{f(a⃗)}^{Ω})_{X}(x_{1},...,x_{n})

Concealment −\a can be treated analogously, but now following the treatment in the case of F_{df} , and defining A by:

x ⊓_{A} y = x ⊓_{X}y

for x,y ∈ T_{CSP(|,Ω)} (X),

(□a⃗)_{A} (x_{1},...,x_{n}) = \{ \begin{matrix}x_{j} ⊓ (Ω □ □_{i≠j} a_{i}x_{i}) & (if a = a_{j}, where1 ≤ j ≤ n) \\ □_{i=1}^{n} a_{i}x_{i} & (if a ≠ any a_{i}) \end{matrix}

and

(□Ω ; a⃗ )_{A} (x_{1},...,x_{n}) = \{ \begin{matrix}x_{j} ⊓ (Ω □ □_{i≠j} a_{i}x_{i}) & (if a = a_{j}, where1 ≤ j ≤ n) \\ Ω □ □_{i=1}^{n} a_{i}x_{i} & (if a ≠ any a_{i}) \end{matrix}

We here again make use of the deterministic choice operator made available by the presence of Ω.

However, we cannot, of course, carry this on to binary deconstructors as we have no general algebraic treatment of them. We proceed instead by giving a concrete definition of them (and the other constructors and deconstructors). That is, we give an explicit description of the free CSP(|,Ω)-algebra on a set X and define our operators in terms of that representation.

An X-trace is a pair (w,x), where w ∈ A^{∗} and x ∈ X; it is generally more suggestive to write (w,x) as wx. For any relabelling function f, we set f(wx) = f(w)x, and, for any a ∈ A, we set wx\a = (w\a)x. An X-process is a pair (T,F) with T a set of traces as well as X-traces, and F a set of failure pairs, satisfying the same five conditions as in Section 6, together with:

2′ wx ∈ T ⇒ w ∈ T (for x ∈ X)

The CSP operators are defined on X-processes exactly as before, except that the two parallel operators now have more general types:

||_{X,Y},|||_{X,Y}:T_{CSP(|,Ω)} (X) × T_{CSP(|,Ω)} (Y) → T_{CSP(|,Ω)} (X × Y)

We take fut_{P}(w) := {a ∈ A | wa ∈ T_{P}}, as before.

Ω_{T (X)}  = {ϵ}
Ω_{R(X)}  = ∅
Stop_{T (X)} = {ε}
Stop_{R(X)} = {(ε,W) | W ⊆ A}
a →_{T (X)}P = {ε} ∪ {aw | w ∈ T_{P}}
a →_{R(X)} P = {(ε,W) | a ∉ W } ∪ {(aw,W) | (w,W) ∈ F_{P}}
P ⊓_{T (X)}Q = T_{P}∪ T_{Q}
P ⊓_{R(X)}Q = F_{P}∪ F_{Q}
P □_{T (X)}Q = T_{P}∪ T_{Q}
P □_{R(X)}Q = {(ε,W) | (ε,W) ∈ F_{P}∩ F_{Q}} ∪ {(w,W) | w ≠ ε, (w,W) ∈ F_{P}∪ F_{Q}}
f_{T (X)}(P) = {f(w) | w ∈ T_{P}}
f_{R(X)}(P)  = {(f(w),W) | (w,f^{−1} (W) ∩ fut_{P}(w)) ∈ F_{P}}
P\_{T (X)}a  = {w\a | w ∈ T_{P}}
P\_{R(X)}a  = {(w\a,W) | (w,W ∪ {a}) ∈ F_{P}}
P ||_{T (X,Y)}Q = {w | w ∈ T_{P}∩ T_{Q}∩ A^{∗}} ∪ {w(x,y) | wx ∈ T_{P}, wy ∈ T_{Q}}
P ||_{R(X,Y)}Q = {(w,W ∪ V) | (w,W) ∈ F_{P}, (w,V) ∈ F_{Q}}
P |||_{T (X,Y)}Q = {w | u ∈ T_{P}∩ A^{∗}, v ∈ T_{Q}∩ A^{∗}, w ∈ u|v} ∪

{w(x,y) | ux ∈ T_{P}, vy ∈ T_{Q}, w ∈ u|v}

P |||_{R(X,Y)}Q = {(w,W) | (u,W) ∈ F_{P}, (v,W) ∈ F_{Q}, w ∈ u|v}

Here, much as before, we write P op_{F (X)} Q = (P op_{T (X)}Q,P op_{R(X)}Q) when defining the CSP operators on X-processes. The X-processes also form the carrier of a CSP(|,Ω)-algebra F_{d}(X), with the operators defined as follows:

P ⊓_{T_{d}(X)}Q  = T_{P}∪ T_{Q}
P ⊓_{R_{d}(X)}Q  = F_{P}∪ F_{Q}
(□Ω ; a⃗ )_{T_{d}(X)}(P_{1},...,P_{n}) = {ε} ∪ {a_{i}w | w ∈ T_{P_{i}}}
(□Ω ; a⃗ )_{R_{d}(X)}(P_{1},...,P_{n}) = {(a_{i}w,W) | (w,W) ∈ F_{P_{i}}}
(□a⃗)_{T_{d}(X)}(P_{1},...,P_{n}) = {ε} ∪ {a_{i}w | w ∈ T_{P_{i}}}
(□a⃗)_{R_{d}(X)}(P_{1},...,P_{n}) = {(ε,W) | W ∩ {a_{1},...,a_{n}} = ∅} ∪
{(a_{i}w,W) | (w,W) ∈ F_{P_{i}}}

The finitary X-processes are those with a finite set of traces and X-traces; they form the carrier of a CSP(|,Ω)-algebra F_{df}(X).

We now show that F_{df}(X) is the free CSP(|,Ω)-algebra over X. As is well known, the free algebra of a theory Thover a set X is the same as the initial algebra of the theory Th^{+} obtained by extending Thwith constants \underline{x} for each x ∈ X but without changing the axioms. The unit map η:X → T_{Th}(X) sends x ∈ X to the denotation of \underline{x}in the initial algebra. We therefore show that F_{df}(X), extended to a CSP(|,Ω)^{+} -algebra by taking

[[\underline{x}]] = (\{x\},∅) (for x ∈ X)

is the initial CSP(|,Ω)^{+} -algebra. We begin by looking at definability.

Lemma 7.1. The finitary X-processes are those definable by closed CSP(|,Ω)^{+} terms.

Proof. The proof goes just as the one for Lemma 6.2, using that Lemma 6.1 applies just as well to finitary X-processes, but this time we have

P = ⨅_{i} □_{a∈V_{i}}a → P_{a} ⊓ ( Ω □ □_{a∈T_{P}}a → P_{a}) ⊓ ⨅_{x∈T_{P}}\underline{x} ⊓ ⊔

Next, we say that a closed CSP(|,Ω)^{+} -term t is in normal form if it is has one of the following two forms:

⨅_{L∈L} □_{a∈L}at_{a}⊓ ⨅_{x∈J} \underline{x} or ( Ω □ □_{a∈K}at_{a}) ⊓ ⨅_{x∈J} \underline{x}

where, as appropriate, L is a finite non-empty saturated collection of finite sets of actions, J ⊆_{fin} X, K ⊆_{fin} A, and each term t_{a} is in normal form.

Lemma 7.2. Two normal forms are identical if they have the same denotation in F_{df}(X).

Proof. Consider two normal forms with the same denotation in F_{df}(X), say (T,F). As (ε,∅) ∈ F iff F is the denotation of a normal form of the first form (rather than the second), both normal forms must be of the same form. Thus, there are two cases to consider, the first of which concerns two forms:

⨅_{L∈L} □_{a∈L}at_{a}⊓ ⨅_{x∈J} \underline{x}  ⨅_{L′∈L′} □_{a′∈L′}a′t′_{a′}⊓ ⨅_{x∈J′}\underline{x}

We argue by induction on the sum of the sizes of the two normal forms. We evidently have that J = J′. Next, if a ∈ ⋃ L then a ∈ T and so a ∈ ⋃ L′; we therefore have that ⋃ L ⊆ ⋃ L′. Now, if L ∈ L then (ε,(⋃ L′)\L) ∈ F; so for some L′∈ L we have L′∩ ((⋃ L′)\L) = ∅, and so L′⊆ L. As L′ is saturated, it follows by the previous remark that L ∈ L′. So we have the inclusion L ⊆ L′ and then, arguing symmetrically, equality.

Finally, the denotations of t_{a} and t′_{a}, for a ∈ ⋃ L = ⋃ L′ are the same, as they are determined by T and F, being {w | aw ∈ T } and {(w,W) | (aw,W) ∈ F }, and the argument concludes, using the inductive hypothesis.

The other case concerns normal forms:

( Ω □ □_{a∈K}at_{a}) ⊓ ⨅_{x∈J} \underline{x} ( Ω □ □_{a′∈K′}a′t′_{a}) ⊓ ⨅_{x∈J′}\underline{x}

Much as before we find J = J′, K = K′, and t_{a} = t_{a} for a ∈ K. ⊓ ⊔ Lemma 7.3. CSP(|,Ω)^{+} is ground complete with respect to F_{df}(X).

Proof. As before, a straightforward induction shows that every term has a normal form, and then completeness follows by Lemma 7.2. ⊓ ⊔

Theorem 7.4. The algebra F_{df}(X) is the free CSP(|,Ω)-algebra over X.

Proof. It follows from Lemmas 7.1 and 7.3 that F_{df}(X)^{+} is the initial CSP(|,Ω)^{+} - algebra. ⊓ ⊔

As with any finitary equational theory, CSP(|,Ω) is equationally complete with respect to F_{df}(X) when X is infinite. It is not difficult to go a little further and show that this also holds when X is only required to be non-empty, and, even, if A is infinite, when it is empty.

Now that we have an explicit representation of the free CSP(|,Ω)-monad in terms of X-processes, we indicate how to use it to give the semantics of the computational λ-calculus. First we need the structure of the monad. As we know from the above, the unit η_{X}: X → T_{CSP(|,Ω)} (X) is the map x ↦ ({x},∅). Next, we need the homomorphic extension g^{†}: F_{df} (X) → F_{df} (Y) of a given map g:X → F_{df} (Y), i.e., the unique such homomorphism making the following diagram commute:

\begin{matrix}X \\ T_{CSP(|,Ω)} (X) & \begin{aligned}η_{X} \\ & \end{aligned} & \overline{\begin{matrix}g^{†} \\ \end{matrix}} & T_{CSP(|,Ω)} (Y) & ^{g} \end{matrix}

This is given by:

(g^{†}(P))_{T} = {v | v ∈ T_{P}∩ A^{∗}} ∪ {vw | vx ∈ T_{P}, w ∈ g(x)_{T} }
(g^{†}(P))_{R} = {(v,V) ∈ F_{P}} ∪ {(vw,W) | vx ∈ T_{P}, (w,W) ∈ g(x)_{R}}

As regards the constructors and deconstructors, we have already given explicit representations of them as functions over (finitary) X-processes. We have also already given homomorphic treatments of the unary deconstructors. We finally give treatments of the binary deconstructors as unique solutions to equations, along similar lines to their treatment in the case of F_{df} . Observe that:

(□a⃗)_{X}(P_{1},...,P_{n}) = a_{1}P_{1}□_{X}a_{2}P_{2}□_{X}...□_{X}a_{n}P_{n}

(□Ω ; a⃗ )_{X}(P_{1},...,P_{n}) = Ω □_{X}a_{1}P_{1}□_{X}a_{2}P_{2}□_{X}...□_{X}a_{n}P_{n}

Using this, one finds that □_{X}, □_{X}^{Ω,a_{1}...a_{n}} and □_{X}^{a_{1}...a_{n}}, the latter defined as in equation (9), are the unique functions which satisfy the evident analogues of equations (8) together with, making another use of the form of external choice made available by Ω:

η(x) □ P = η(x) ⊓_{X}(Ω □ P)

and

(P_{1},...,P_{n}) □^{a_{1}...a_{n}} η(x) = (□Ω ; a⃗ )_{X}(P_{1},...,P_{n}) ⊓_{X}η(x)

(P_{1},...,P_{n}) □^{Ω,a_{1}...a_{n}} η(x) = (□Ω ; a⃗ )_{X}(P_{1},...,P_{n}) ⊓_{X}η(x)

As regards concurrency, we define

||_{X,Y}:T_{CSP(|,Ω)} (X) × T_{CSP(|,Ω)} (Y) → T_{CSP(|,Ω)} (X × Y)

together with functions

||_{X,Y}^{a_{1}...a_{n}}:T_{CSP(|,Ω)} (X)^{n}× T_{CSP(|,Ω)} (Y) → T_{CSP(|,Ω)} (X × Y)
||_{X,Y}^{Ω,a_{1}...a_{n}}:T_{CSP(|,Ω)} (X)^{n}× T_{CSP(|,Ω)} (Y) → T_{CSP(|,Ω)} (X × Y)
||_{X,Y}^{x}:T_{CSP(|,Ω)} (Y) → T_{CSP(|,Ω)} (X × Y)

where the a_{i} ∈ A are all different, and x ∈ X, by the analogues of equations (10) above, together with:

\begin{aligned}η(x) || Q & = & ||^{x} (Q) \\ ||^{x} (P ⊓ Q) & = & ||^{x} (P)⊓ ||^{x} (Q) \\ ||^{x} (□_{i=1}^{n} a_{i}P_{i}) & = & Ω \\ ||^{x} (Ω □ □_{i=1}^{n} a_{i}P_{i}) & = & Ω \\ ||^{x} (η(y)) & = & η((x,y)) \\ (P_{1},...,P_{n}) ||^{a_{1}...a_{n}} η(x) & = & Ω \\ (P_{1},...,P_{n}) ||^{Ω,a_{1}...a_{n}} η(x) & = & Ω \end{aligned}

Much as before, the equations have a unique solution, with the || component being ||_{X,Y}.

As regards interleaving, we define

|||_{X,Y}^{l},|||_{X,Y}^{r}:T_{CSP(|,Ω)} (X) × T_{CSP(|,Ω)} (Y) → T_{CSP(|,Ω)} (X × Y)

by:

P |||_{T_{df}(X,Y)}^{l}Q= {ε} ∪ {w | u ∈ T_{P}∩ A^{∗}, v ∈ T_{Q}∩ A^{∗}, w ∈ u|^{l}v} ∪
{w(x,y) | ux ∈ T_{P}, vy ∈ T_{Q}, w ∈ u |^{l} v ∨ (u = v = w = ε)}
P |||_{R_{df}(X,Y)}^{l}Q= {(ε,W) | (ε,W) ∈ F_{P}} ∪
{(w,W) | (u,W) ∈ F_{P}, (v,W) ∈ F_{Q}, w ∈ u |^{l} v}
P |||_{X,Y}^{r}Q = Q |||_{Y,X}^{l}P

One has that:

P |||_{X,Y}Q = P |||_{X,Y}^{l}Q □ P |||_{X,Y}^{r}Q

and that |||_{X,Y}^{l},|||_{X,Y}^{r} are components of the unique solutions to the analogues of equations (11) above, together with:

\begin{aligned}η(x) |||^{l} Q & = & |||^{l,x} (Q) \\ |||^{l,x} (P ⊓ Q) & = & |||^{l,x} (P)⊓ |||^{l,x} (Q) \\ |||^{l,x} (□_{i=1}^{n} a_{i}P_{i}) & = & Ω \\ |||^{l,x} (Ω □ □_{i=1}^{n} a_{i}P_{i}) & = & Ω \\ |||^{l,x} (η(y)) & = & η(x,y) \end{aligned}

and corresponding equations for |||^{r} and |||^{r,y}.

It would be interesting to check more completely which of the usual laws, as found in, e.g., [BHR84, Hoa85, DeN85], the CSP operators at the level of free CSP(|,Ω)-algebras obey. Note that some adjustments need to be made due to varying types. For example, || is commutative, which here means that the following equation holds:

T_{CSP(|,Ω)} (γ_{X,Y})(P ||_{X,Y}Q) = Q ||_{Y,X}P

where γ:X × Y → Y × X is the commutativity map (x,y) ↦ (y,x).

7.1 Termination

As remarked in the introduction, termination and sequencing are available in a standard way for terms of type unit. Syntactically, we regard skip as an abbreviation for ∗ and M;N as one for (λx: unit.N)(M) where x does not occur free in N; semantically, we have a corresponding element of, and binary operator over, the free CSP(|,Ω) -algebra on the one-point set.

Let us use these ideas to treat CSP extended with termination and sequencing. We work with the finitary {✓}-processes representation of T_{CSP(|,Ω)} ({✓}). Then, following the above prescription, termination and sequencing are given by:

SKIP = {✓} P;Q = (x ∈ {✓} ↦ Q)^{†}(P)

For general reasons, termination and sequencing, so-defined, form a monoid and sequencing commutes with all constructors in its first argument. For example we have that:

□_{i=1}^{n}a_{i}(P_{i};Q) = (□_{i=1}^{n}a_{i}P_{i});Q

Composition further commutes with ⊓ in its second argument.

The deconstructors are defined as above except that in the case of the concurrency operators one has to adjust ||_{{✓},{✓}} and |||_{{✓},{✓}} so that they remain within the world of the {✓}-processes; this can be done by postcomposing them with the evident bijection between {✓} × {✓}-processes and {✓}-processes, and all this restricts to the finitary processes. Alternatively one can directly consider these adjusted operators as deconstructors over the (finitary) {✓}-processes.

The {✓}-processes are essentially the elements of the stable failures model of [Ros98]. More precisely, one can define a bijection from Roscoe’s model to our {✓}-processes by setting θ(T,F) = (T,F′) where

F′= {(w,W) ∈ A^{∗}× P(A) | (w,W ∪ {✓}) ∈ F }

The inverse of θ sends F′to the set:

{(w,W),(w,W ∪ {✓}) | (w,W) ∈ F′} ∪
{(w,W) | w✓ ∈ T ∧ W ⊆ A} ∪ {(w✓,W) | w✓ ∈ T ∧ W ∈ A ∪ {✓}}

and is a homomorphism between all our operators, whether constructors, deconstructors, termination, or sequencing (suitably defined), and the corresponding ones defined for Roscoe’s model.

8 Discussion

We have shown the possibility of a principled combination of CSP and functional programming from the viewpoint of the algebraic theory of effects. The main missing ingredient is an algebraic treatment of binary deconstructors, although we were able to partially circumvent that by giving explicit definitions of them. Also missing are a logic for proving properties of these deconstructors, an operational semantics, and a treatment that includes recursion.

As regards a logic, it may prove possible to adapt the logical ideas of [PPr08, PPr09] to handle binary deconstructors; the main proof principle would then be that of computation induction, that if a proposition holds for all ‘values’ (i.e., elements of a given set X) and if it holds for the applications of each constructor to any given ‘computations’ (i.e., elements of T (X)) for which it is assumed to hold, then it holds for all computations. We do not anticipate any difficulty in giving an operational semantics for the above combination of the computational λ-calculus and CSP and proving an adequacy theorem.

To treat recursion algebraically, one passes from equational theories to inequational theories Th(inequations have the form t ≤ u, for terms t, u in a given signature Σ); inequational theories can include equations, regarding an equation as two evident inequations. There is a natural inequational logic for deducing consequences of the axioms: one simply drops symmetry from the logic for equations [Blo76]. Then Σ-algebras and Th-algebras are taken in the category of ω-cpos and continuous functions, a free algebra monad always exists, just as in the case of sets, and the logic is complete for the class of such algebras. One includes a divergence constant Ω in the signature and the axiom

Ω ≤ x

so that Th-algebras always have a least element. Recursive definitions are then modelled by least fixed-points in the usual way. See [HPP06, Plo06] for some further explanations.

The three classical powerdomains: convex (aka Plotkin), lower (aka Hoare) and upper (aka Smyth) provide a useful illustration of these ideas [GHK03, HPP06]. One takes as signature a binary operation symbol ⊓, to retain notational consistency with the present paper (a more neutral symbol, such as ∪, is normally used instead), and the constant Ω; one takes the theory to be that ⊓ is a semilattice (meaning, as before, that associativity, commutativity and idempotence hold) and that, as given above, Ω is the least element with respect to the ordering ≤. This gives an algebraic account of the convex powerdomain.

If one adds that Ω is the zero of the semilattice (which is equivalent, in the present context, to the inequation x ≤ x ⊓ y) one obtains instead an algebraic account of the lower powerdomain. One then further has the notationally counterintuitive facts that x ≤ y is equivalent to y ⊑ x, with ⊑ defined as in Section 3, and that x ⊓ y is the supremum of x and y with respect to ≤; in models, ≤ typically corresponds to subset. It would be more natural in this case to use the dual order to ⊑ and to write ⊔ instead of ⊓, when we would be dealing with a join-semilattice with a least element whose order coincides with ≤.

If one adds instead that x ⊓ y ≤ x, one obtains an algebraic account of the upper powerdomain. One now has that x ≤ y is equivalent in this context to x ⊑ y, that x⊓y is the greatest lower bound of x and y, and that x ⊓ Ω = Ω (but this latter fact is not equivalent in inequational logic to x ⊓ y ≤ x); in models, ≤ typically corresponds to superset. The notations ⊓ and ⊑ are therefore more intuitive in the upper case, and there one has a meet-semilattice with a least element whose order coincides with ≤.

It will be clear from these considerations that the stable failures model fits into the pattern of the lower powerdomain and that the failures/divergences model fits into the pattern of the upper powerdomain. In the case of the stable failures model it is natural, in the light of the above considerations, to take Thto be CSP(|,Ω) together with the axiom Ω ≤ x. The X-processes with countably many traces presumably form the free algebra over X, considered as a discrete ω-cpo; one should also characterise more general cases than discrete ω-cpos.

One should also investigate whether a fragment of the failures/divergences model forms the initial model of an appropriate theory, and look at the free models of such a theory. The theory might well be found by analogy with our work on the stable failures model, substituting (12) for (13) and, perhaps, using the mixed-choice constructor, defined below, to overcome any difficulties with the deconstructors. One would expect the initial model to contain only finitely-generable processes, meaning those which, at any trace, either branch finitely or diverge (and see the discussion in [Ros98]).

Our initial division of our selection of CSP operators into constructors and deconstructors was natural, although it turned out that a somewhat different division, with ‘restricted’ constructors, resulted in what seemed to be a better analysis (we were not able to rule out the possibility that there are alternative, indirect, definitions of the deconstructors with the original choice of constructors). One of these restricted constructors was a deterministic choice operator making use of the divergence constant Ω. There should surely, however, also be a development without divergence that allows the interpretation of the combination of CSP and functional programming.

We were, however, not able to do this using CSP(|): the free algebra does not seem to support a suitable definition of concealment, whether defined directly or via a homomorphism. For example a straightforward extension of the homomorphic treatment of concealment in the case of the initial algebra (cf. Section 5) would give

(a.\underline{x}□ b.Stop)\a = \underline{x}⊓ (\underline{x}□ b.Stop)

However, our approach requires the right-hand side to be equivalent to a term built from constructors only, but no natural candidates came forward—all choices that came to mind lead to unwanted identifications.

We conjecture that, taking instead, as constructor, a mixed-choice operator of the form:

□_{i}α_{i}.x_{i}

where each α_{i} is either an action or τ, would lead to a satisfactory theory. This new operator is given by the equation:

□_{i}α_{i}.x_{i} = ⨅_{α_{i}=τ} x_{i} ⊓ ( □_{α_{i}=τ} x_{i} □ □_{α_{i}≠τ} α_{i}.x_{i})

and there is a homomorphic relationship with concealment:

(□_{i}α_{i}.x_{i})\a = □_{i}(α_{i}\a).(x_{i}\a)

(with the evident understanding of α_{i}\a). Note that in the stable failures model we have the equation:

□_{i}α_{i}.x_{i} = ⨅_{α_{i}=τ} x_{i} ⊓ ( Ω □ □_{α_{i}≠τ} α_{i}.x_{i})

which is presumably why the deterministic choice operator available in the presence of Ω played so central a rôle there.

In a different direction, one might also ask if there is some problem if we alternatively take an extended set of operators as constructors. For example, why not add relabelling with its equations to the axioms? As the axioms inductively determine relabelling on the finitary refusal sets model, that would still be the initial algebra, and the same holds if we add any of the other operators we have taken as deconstructors.

However, the X-refusal sets would not longer be the free algebra, as there would be extra elements, such as f(x) for x ∈ X, where f is a relabelling function. We would also get some undesired equations holding between terms of the computational λ-calculus. For any n-ary constructor op and evaluation context E[−], one has in the monadic semantics:

E[op(M_{1},...,M_{n})] = op(E[M_{1}],...,E[M_{n}])

So one would have E[f(M)] = f(E[M]) if one took relabelling as a constructor, and, as another example, one would have E[M || N] = E[M] || E[N] if one took the concurrency operator as a constructor.

It will be clear to the reader that, in principle, one can investigate other process calculi and their combination with functional programming in a similar way. For example for Milner’s CCS [Mil80] one could take action prefix (with names, conames and τ) together with NIL and the sum operator as constructors, and as axioms that we have a semilattice with a zero, for strong bisimulation, together with the usual τ-laws, if we additionally wish to consider weak bisimulation. The deconstructors would be renaming, hiding, and parallel, and all should have suitable polymorphic versions in the functional programming context. Other process calculi such as the π-calculus [SW03, Sta08], or even the stochastic π-calculus [Pri95, KS08], might be dealt with similarly. In much the same way, one could combine parallelism with a global store with functional programming, following the algebraic account of the resumptions monad [HPP06, AP09] where the constructors are the two standard ones for global store [PP02], a nondeterministic choice operation, and a unary ‘suspension’ operation.

A well-known feature of the monadic approach [HPP06] is that it is often possible to combine different effects in a modular way. For example, the global sideeffects monad is (S×−)^{S} where S is a suitable set of states. A common combination of it with another monad T is the monad T (S × −)^{S}. So, taking T = T_{CSP(|)}, for example, we get a combination of CSP with global side-effects.

As another example, given a monoid M, one has the M-action monad M × − which supports a unary M-action effect constructor m.−, parameterised by elements m of the monoid. One might use this monad to model the passage of time, taking M to be, for example, the monoid of the natural numbers IN under addition. A suitable combination of this monad with ones for CSP may yield helpful analyses of timed CSP [RR99, OS06], with Waitn;− given by the IN-action effect constructor. We therefore have a very rich space of possible combinations of process calculi, functional programming and other effects, and we hope that some of these prove useful.

Finally, we note that there is no general account of how the equations used in the algebraic theory of effects arise. In such cases as global state, nondeterminism or probability, there are natural axioms and monads already available, and it is encouraging that the two are equivalent [PP02, HPP06]. One could investigate using operational methods and behavioural equivalences to determine the equations, and it would be interesting to do so. Another approach is the use of ‘test algebras’ [SS06, KP09]. In the case of process calculi one naturally uses operational methods; however the resulting axioms may not be very modular, or very natural mathematically, and, all in all, in this respect the situation is not satisfactory.

References

AP09. M. Abadi & G. D. Plotkin, A model of cooperative threads, Proc. POPL 2009 (eds.

Z. Shao & B. C. Pierce), ACM Press, 29–40, 2009.

AGM95. S. Abramsky, D. M. Gabbay & T. S. E. Maibaum (eds), Handbook of Logic in Computer

Science (Vol. 1), Background: Mathematical Structures, Oxford University Press, 1995.

BHM02. N. Benton, J. Hughes & E. Moggi, Monads and effects, Proc. APPSEM 2000, LNCS

2395, 42–122, Springer, 2002.

BK85. J. A. Bergstra & J. W. Klop, Algebra of communicating processes with abstraction,

Theor. Comput. Sci. 37, 77–121, 1985.

BK86. J. A. Bergstra & J. W. Klop, Algebra of communicating processes, Proc. of the CWI Symp. Math. and Comp. Sci. (eds. J. W. de Bakker, M. Hazewinkel & J. K. Lenstra), 89–138, North-Holland, 1986.

BKO87. J. A. Bergstra, J. W. Klop, & E.-R. Olderog, Failures without chaos: a new process semantics for fair abstraction. Proc. of the 3^{th}IFIP WG 2.2 working conference on Formal Description of Programming Concepts (ed. M. Wirsing), 77–103, North-Holland, 1987.

Blo76. S. L. Bloom, Varieties of ordered algebras, J. Comput. Syst. Sci., 13(2), 200–212, 1976. Bor94. F. Borceux, Handbook of Categorical Algebra 2, Encyclopedia of Mathematics and its

Applications 51, Cambridge University Press, 1994.

BHR84. S. D. Brookes, C. A. R. Hoare & A. W. Roscoe, A theory of communicating sequential

processes, J. ACM 31(3), 560–599, 1984.

DeN85. R. De Nicola, Two complete axiom systems for a theory of communicating sequential

processes, Information and Control 64, 136–172, 1985.

EFG08. K. Ebrahimi-Fard & L. Guo, Rota-Baxter algebras and dendriform algebras, Journal of

Pure and Applied Algebra 212 (2), 320–33, 2008.

GHK03. G. Gierz, K. H. Hofmann, K. Keimel, J. D. Lawson, M. Mislove & D. S. Scott, Continuous Lattices and Domains, Encyclopedia of Mathematics and its Applications 93, Cambridge University Press, 2003.

Hoa85. C. A. R. Hoare, Communicating Sequential Processes, Prentice-Hall, 1985. HPP06. J. M. E. Hyland, G. D. Plotkin & A. J. Power, Combining effects: sum and tensor,

Clifford Lectures and the Mathematical Foundations of Programming Semantics, (eds. S. Artemov and M. Mislove), Theor. Comput. Sci. 357(1–3), 70–99, 2006.

KP09. K. Keimel & G. D. Plotkin, Predicate transformers for extended probability and nondeterminism, Mathematical Structures in Computer Science 19(3), 501–539, Cambridge University Press, 2009.

KS08. B. Klin & V. Sassone, Structural operational semantics for stochastic process calculi,

Proc. 11th. FoSSaCS (ed. R. M. Amadio), LNCS 4962, 428–442, Springer, 2008.

Mil80. A. J. R. G. Milner, A Calculus of Communicating Systems, Springer, 1980. Mog89. E. Moggi, Computational lambda-calculus and monads, Proc. 3rd. LICS, 14–23, IEEE

Press, 1989.

Mog91. E. Moggi, Notions of computation and monads, Inf. & Comp. 93(1), 55–92, 1991. OS06. J. Ouaknine & S. Schneider, Timed CSP: a retrospective, Proceedings of the Workshop

“Essays on Algebraic Process Calculi” (APC 25), Electr. Notes Theor. Comput. Sci., 162, 273–276, 2006.

Plo06. G. D. Plotkin, Some varieties of equational logic, Essays Dedicated to Joseph A. Goguen (eds. K. Futatsugi, J.-P. Jouannaud & J. Meseguer), LNCS 4060, 150–156, Springer, PP02. G. D. Plotkin & A. J. Power, Notions of computation determine monads, Proc. 5th.

FOSSACS, LNCS 2303, 342–356, Springer, 2002.

PP04. G. D. Plotkin & A. J. Power, Computational effects and operations: an overview, Proc. Workshop on Domains VI (eds. M. Escardó and A. Jung), Electr. Notes Theor. Comput. Sci. 73, 149–163, Elsevier, 2004.

PPr08. G. D. Plotkin & M. Pretnar, A logic for algebraic effects, Proc. 23rd. LICS, 118-129,

IEEE Press, 2008.

PPr09. G. D. Plotkin & M. Pretnar, Handlers of algebraic effects, Proc. 18th. ESOP, 80–94,

2009.

Pri95. C. Priami, Stochastic pi-calculus, Comput. J. 38 (7), 578–589, 1995. RR99. G. M. Reed & A. W. Roscoe, The timed failures-stability model for CSP, Theor. Comput.

Sci. 211 (1-2), 85-127, 1999.

Ros94. A. W. Roscoe, Model-checking CSP, A Classical Mind: Essays in Honour of

C. A. R. Hoare (ed. A. W. Roscoe), 353–337, Prentice-Hall, 1994.

Ros98. A. W. Roscoe, The Theory and Practice of Concurrency, Prentice Hall, 1998. SW03. D. Sangiorgi & D. Walker, The π-Calculus: A Theory of Mobile Processes, Cambridge

University Press, 2003.

Sca. B. Scattergood, The Semantics and Implementation of Machine-Readable CSP, D.Phil

Thesis, Oxford University, 1998.

SS06. M. Schröder & A. Simpson, Probabilistic observations and valuations (extended ab-

stract), Electr. Notes Theor. Comput. Sci. 155, 605–615, 2006.

Sta08. I. Stark, Free-algebra models for the pi -calculus, Theor. Comput. Sci. 390(2-3), 248– 270, 2008.

Appendix: The computational λ-calculus

In this appendix, we sketch (a slight variant of) the syntax and semantics of Moggi’s computational λ-calculus, or λ_{c}-calculus [Mog89, Mog91]. It has types given by:

σ ::= b | unit | σ × σ | empty | σ → σ

where b ranges over a given set of base types, e.g., nat; the type construction T σ may be defined to be unit → σ . The terms of the λ_{c}-calculus are given by:

M ::= x | g(M) | ∗ | inM | (M,M) | fstM | sndM | λx:σ.M | MM

where g ranges over given unary function symbols of given types σ → τ, such as 0 : unit → nat or succ : nat → nat, if we want the natural numbers, or op: T (σ)×...×T (σ) → T (σ) for some operation symbol from a theory for which T is the free algebra monad. There are standard notions of free and bound variables and of closed terms and substitution; there are also standard typing rules for judgements Γ ⊢ M: σ, that the term M has type σ in the context Γ (contexts have the form Γ = x_{1} : σ_{1},...,x_{n}: σ_{n}), including:

\frac{Γ ⊢ M:empty}{Γ ⊢ inM:σ}

A λ_{c}-model (on the category of sets—Moggi worked more generally) consists of a monad T, together with enough information to interpret basic types and the given function symbols. So there is a given set [[b]] to interpret each basic type b, and then every type σ receives an interpretation as a set [[σ]]; for example [[empty]] = ∅. There is also given a map [[σ]] → T ([[τ]]) to interpret every given unary function symbol g: σ → τ. A term Γ ⊢ M: σ of type σ in context Γ is modelled by a map [[M]] : [[Γ ]] → T [[σ]] (where [[x_{1}:σ_{1},...,x_{n}:σ_{n}]] = [[σ_{1}]] × ...× [[σ_{n}]] ). For example, if Γ ⊢ inM:σ then [[inM]] = 0_{[[σ]]}^{o}[[M]] (where, for any set X, 0_{X} is the unique map from ∅ to X).

We define values and evaluation contexts. Values can be thought of as (syntax for) completed computations, and are defined by:

V ::= x | ∗ | (V,V) | inV | λx:σ.M

together with clauses such as:

V ::= 0 | succ(V)

depending on the choice of basic types and given function symbols. We may then define evaluation contexts by:

E ::= [−] | inE | (E,M) | (V,E) | EM | V E | fst(E) | snd(E)

together with clauses such as:

E ::= succ(E)

depending on the choice of basic types and given function symbols. We write E[M] for the term obtained by replacing the ‘hole’ [−] in an evaluation term E by a term M. The computational thought behind evaluation contexts is that in a program of the form E[M], the first computational step arises within M.