Processes communicate only via named communication (session) channels by synchronizing send and receive actions or synchronizing select and branch events (as in standard session typedπ-calculus). The session typing rules presented in the next session guarantees that there is always at most one active send and receive action for a given channel. To distinguish dual ends of communication channels, we employpolarised names [10,20]: Ifc is a channel name,c+ andc−
are the dual ends of the channelc. We call thesepolarised channel names, with “+” and “-” polarities. Ifkis a polarised channel name, we writekfor its dual, e.g.,c+=c−. In generalcranges or channel names;pover polarities +,−;k, h
over polarised channel names; xover data variables; i over recursion variables (explained below); v over data values including numbers, strings and booleans;
eover data expressions; and finallyX, Y over process variables.
P ::=k!hei.P | k?(x).P | k!l.P | k?{li.Pi}i∈I | 0 | P|Q
| recX.P | (receX(i).P;Q) | X[˜k] | if ethen P elseQ
The first four process constructors are prefixes taking part in a communica- tion. These are standard for session typed π-calculi, except we allow only data and not channel names to be sent. The processk!hei.P sends datav over chan- nelkwhene⇓v, and proceeds asP. Dually,k?(x).P receives a data value over channelkand substitutes it for thexbinding inP. Abranchprocessk?{li.Pi}i∈I
offers a choice between labelsli, proceeding toPiif thei’th label is chosen. The
process0is the standard inactive process (termination), andP|Qis the parallel composition of processesP andQ.
Recursion comes in two forms: a general, potentially non-terminating recur- sion recX.P, where X binds in P; and a primitive recursion, guaranteed to terminate, with syntax (receX(i).P;Q). The latter process, when e
⇓ n+ 1,
executes P{n/i} and repeats, and when e ⇓ 0, evolves to Q. By convention in (receX(i).P;Q) neither of 0, recY.Q, (recQY(i).R;) and P
| Q occurs as subterms ofP. These conventions ensure that the process (receX(i).P;Q) will
eventually terminate the loop and executeQ. Process variables X[˜k] mentions the channel names ˜kactive at unfolding time for technical reasons.
We define the free polarised names fn(P) of P as usual, withfn(X[˜k]) = ˜k; substitution of process variables fromX[˜k]{P/X}=P; and finally value substi- tution P{v/x} in the obvious way, e.g., k!hei.P{v/x} = k!he{v/x}i.(P{v/x}). Variable substitution can never affect channels.
Example 2.1. We now show how to model the example BPMN process given in the introduction. To illustrate the possibility of type checking infinite state systems, we use a persistent data object. As our calculus does not contain such a primitive, a data object will be represented by a process DATA(o) communi- cating on a session channelo.
DATA(o) = recX. o+?(x). recY. o+? read. o+!hxi. Y[o+] write. X[o+] quit.0
After having received its first initial value, this process repeatedly accepts com- mandsreadandwriteon the session channelofor respectively reading and writing the value of the variable, or the commandquitfor discarding the data object.
To make examples more readable, we employ the following shorthands. We write init(o, v).P foro−!hvi.P, which initializes the data object; we writefreeo
for o−!quit. 0, the process which terminates the data object session; we write reado(x).P foro−!read. o−?(x).P., the process which loads the value of the data
object o into the process-local variable x; and finally, we write o := e.P for
o−!w.o−!hei.P, the process which sets the value of a data-object.
The shopping cart process can then be modelled as
P(Q) = DATA(o) | init(o, ). recX.k
AI. k?(x).reado(y). o:=add(y, x). X[ko−] RI. k?(x).reado(y). o:=rem(y, x). X[ko−] CO. k?(x).reado(y). o:=add(y, x). Q .
Herekis the session channel for communicating with the customer andois the session channel for communicating with the data object modelling order data. We assume our expression language has suitable operators “add” and “rem”, adding an removing items from the order. Finally, the process Q is a stand-in for either the (non live) delivery part of the BPMN process in Fig. A or the live delivery part shown in Fig. B.
The non-live delivery loop can be represented by the process
D0= recY.reado(y).ifn(y)>0
(
thenk!DI. k!hnext(y)i. o:=update(y). Y[ko−] elsek!SI. k!hinv(y)i.freeo
where n(y) is the integer expression computing from the order y the number of items to send, next(y), update(y) andinv(y) are, respectively, the the next item(s) to be sent; an update of the order to mark that these items have indeed been sent; and the invoice from the order. Note that whether or not this process terminates is entirely dependent on the data operations.
The live delivery with the bounded iteration can be represented by a process using the bounded recursion
D=reado(y).(recn(y)Y(i).
k!DI.reado(y). k!hpickitem(y, i)i.Y[ko−];
k!SI.reado(y). k!hinv(y)i.freeo) (The second line is the body of the loop; the third line is the continuation.) Here
pickitem(y, i) is the expression extracting theith item from the order y. ut