DTU Informatics
Department of Informatics and Mathematical Modelling
Formal Specification of Distributed Systems:
Communicating Sequential Processes (CSP)
Nicola Dragoni
Embedded Systems Engineering DTU Informatics
Pipes
DTU Informatics
Department of Informatics and Mathematical Modelling
Pipes
• Processes with only two channels in their alphabet, namely an input channel left and an output channel right are called pipes.
2
DTU Informatics
Department of Informatics and Mathematical Modelling
Joining Pipes
• The processes P and Q may be joined together (P >> Q) so that
‣ the right channel of P is connected to the left channel of Q, and
‣ the sequence of messages output by P and input by Q on this internal channel is concealed from their common environment.
DTU Informatics
Department of Informatics and Mathematical Modelling
Connection Diagram
• This connection diagram represents the concealment of the connecting channel by not giving it a name.
• It also shows that
‣ all messages input on the left channel of (P>>Q) are input by P
‣ all messages output on the right channel of (P>>Q) are output by Q.
• Finally (P>>Q) is itself a pipe, and may again be placed in series with other pipes: (P>>Q)>>R, (P>>Q)>>(R>>S), etc.
4
DTU Informatics
Department of Informatics and Mathematical Modelling
Constraints for Piping
• The validity of chaining processes by >> depends on the obvious alphabet constraints:
• A further constraint states that the connected channels are capable of transmitting the same kind of message:
DTU Informatics
Department of Informatics and Mathematical Modelling
Example
6
DTU Informatics
Department of Informatics and Mathematical Modelling
Example
• Every number input is doubled before it is output:
αleft(DOUBLE) = αright(DOUBLE) = N (natural numbers)
DOUBLE = left?x ➝ right!(x + x) ➝ DOUBLE
DTU Informatics
Department of Informatics and Mathematical Modelling
Example
6
• Every number input is doubled before it is output:
αleft(DOUBLE) = αright(DOUBLE) = N (natural numbers)
DOUBLE = left?x ➝ right!(x + x) ➝ DOUBLE
• A pipe which outputs each input value multiplied by four:
αleft(QUADRUPLE) = αright(QUADRUPLE) = N
QUADRUPLE = DOUBLE>>DOUBLE
DTU Informatics
Department of Informatics and Mathematical Modelling
Laws
DTU Informatics
Department of Informatics and Mathematical Modelling
Laws (cont.)
8