2 COPY = COPY COPY
4.1 TRACE SEMANTICS
The extraction of trace information from the process transition rules provides an explanation of the relationship between the executions of a process and its traces. However, the operational characterization is too low level for reasoning about processes, since the level of abstraction remains that of process executions, with the set of traces supervenient. The traces model for CSP considers processes directly in terms of their traces, and lifts the entire analysis of CSP processes to this more abstract level. All of the operators of the language can be understood at this level: the traces of a composite process are dependent only on the traces of its components.
This allows a compositional semantic model, where all processes are considered only in terms of their sets of traces, and at no stage do the underlying executions need to be considered explicitly.
In the traces model, each CSP process is associated with a set of traces—the set of all possible sequences of events that may be observed of some execution. Processes will be trace equivalent when they have exactly the same set of possible traces. This particular form of equality will be denoted
=
T, and its definition is thatP1
=
TP2=
traces(
P1) =
traces(
P2)
In the traces model, processes are equal when they have exactly the same traces. Traces equality gives rise to algebraic laws for individual operators, and also concerning the relationships between various operators. These laws allow manipulation of CSP process descriptions from one form to another while keeping the associated set of traces unchanged. Many laws are concerned with general algebraic properties such as associativity and commutativity of operators (which allow components to be composed in any order), idempotence, and the identification of units and zeros for particular operators (which may allow process descriptions to be simplified). Other laws are concerned with the relationships between different operators, which allow for example the expansion of a parallel combination into a prefix choice process.
In Chapters 6, 8 and 11 more detailed views of process executions will be used to characterize processes in different ways. Some process laws may be concerned only with traces, but others may be true in any of these models. If a law holds in any of these models, as in fact most of those given in this chapter will, then the subscript will be dropped from the equality. Hence P1
=
P2means not only that P1=
T P2, but also that P1=
SFP2, P1=
FDIP2and P1
=
TF P2, corresponding to the equalities that will be defined later, under the more detailed views (stable failures, failures/divergences/infinite traces and timed failures) given in Chapters 6, 8 and 11 respectively. If a law is valid in all of the untimed models, then the equality symbol will be subscripted with a U. For example, the associativity of external choice is true in all models, since the executions of P12(
P22P3)
match those of(
P12P2)
2P3,so all views of executions of these processes, no matter how detailed, will not distinguish them. The fact that it will be true in any of these models is indicated by the lack of a subscript on the equality symbol.
P12
(
P22P3) = (
P12P2)
2P3On the other hand, although the traces of P1 2 P2 and P1 u P2will be the same, a more sophisticated view of process executions will distinguish them. This law will be written as
P12P2
=
T P1uP2since it is true only in the traces model.
Any set of traces S associated with some process must contain the empty trace: any process can be observed to do nothing. It will also be prefix closed: if a process can perform a sequence of events, then it can also be observed to perform any prefix of that sequence. These properties are formalized as T
1
and T2
on set S:T
1
hi2ST
2
8tr1;tr2:
TRACE(
tr16tr2^tr22S)tr12S) STOP
There is only one trace associated with the process STOP, and that is the empty trace. The semantics of STOP is given directly as
traces
(
STOP) =
fhigPrefixing
In an observation of the process a!P, there are two possibilities: either the event a has not occurred, in which case the observation must behi, or else the event a has occurred and the rest of the trace derives from process P.
traces
(
a!P) =
fhig[
fhaiatrjtr2traces
(
P)
gPrefix choice
An observation of the process x
:
A!P(
x)
is again one of two possibilities. Either no event has yet occurred, or else an event a in A has occurred, and the subsequent behaviour is that of the corresponding process P(
a)
.traces
(
x:
A!P(
x)) =
fhig[
fhaiatrja2A^tr2traces
(
P(
a))
gx
:
fg!P(
x) =
STOP hSTOP-stepix
:
fbg!P(
x) =
b!P(
b)
hprefixiFig. 4.1 Laws for prefix choice
Example 4.4
The process BUS1
of Example 1.24 is described as follows:BUS
1 =
board:A!(
pay:90
!alight:B!STOPjalight:A!STOP
)
This process has the following traces:
traces
(
BUS1) =
f hi;hboard:Ai;
hboard:A;pay:
90
i;hboard:A;pay:
90
;alight:Bi;hboard:A;alight:Aig
It initially allows board:A, after which either the fare is paid and the journey made, or else the
journey is not made and the passenger alights again. 2
The definition oftraces
(
x:
A ! P(
x))
has two special cases: where A contains no elements (A=
fg) and where A contains but a single element (A=
fbg).In the case where A
=
fg, the second clause of the definition cannot be met, since there is no event a for which a2A. The semantics is thus equal tofhig, which is the semantics of STOP. In the case where A=
fbg, the second clause of the definition is equivalent tofhbiatrjtr2traces
(
P(
b))
gwhich is the second clause of the event prefix definition for b!P
(
b)
. These observations support two laws concerning equality of process expressions, given in Figure 4.1.Output and input
The output and input constructors are special cases of the prefix and prefix choice operators.
The definition of their trace semantics follows the same pattern.
traces
(
c!
v!P) =
fhig[fhc:viatrjtr2traces
(
P)
gtraces
(
c?
m:
T!P(
m)) =
fhig[fhc:viatrjv2T^tr2traces
(
P(
v))
gExample 4.5
The traces of the process in?
x:
Z!out!
x!STOP are given as follows:traces
(
in?
x:
Z!out!
x!STOP) =
fhig[fhin:vijv2Zg
[fhin:v;out:vijv2Zg
An observation of this process might contain no events, or a single input, or an input of a
particular value followed by output of that same value. 2