Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks

Process Algebras

Jason Jaskolka

Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada [email protected]

October 20, 2011

Jason Jaskolka Process Algebras 1 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Outline

1 Introduction and Motivation

2 A Brief Overview of Process Algebras Calculus of Communicating Systems (CCS)

3 Process Algebras and Petri Nets

4 A Comparative Example

5 A Comment on Bisimilarity

6 Concluding Remarks

Jason Jaskolka Process Algebras 2 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Outline

1 Introduction and Motivation

2 A Brief Overview of Process Algebras Calculus of Communicating Systems (CCS)

3 Process Algebras and Petri Nets

4 A Comparative Example

5 A Comment on Bisimilarity

6 Concluding Remarks

Jason Jaskolka Process Algebras 3 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks What Are Process Algebras?

Definition (Process) A process refers to any behaviour of a system.

Definition (Behaviour) A behaviour refers to the total of events or actions that a system can perform, the order in which they can be executed and possibly other aspects of these executions such as probabilities or timings.

Definition (Algebra) An algebra is a set A together with a collection of operations on A.

Jason Jaskolka Process Algebras 4 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks What Are Process Algebras?

When dealing with interacting systems, we say we are studying concurrency theory Concurrency theory is the theory of interacting, parallel and/or distributed systems Process algebras are considered an approach to concurrency theory Process algebras aim at defining algebraic calculi for concurrency and concurrent processes

Jason Jaskolka Process Algebras 5 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks What Are Process Algebras?

Process algebra is the study of the behaviour of parallel or distributed systems by algebraic means Offers means to describe or specify such systems, i.e., it has a means to talk about parallel composition sequential composition alternative composition Allows us to reason about such systems using algebra, i.e., equational reasoning By means of this equational reasoning, we can do verification, i.e. we can establish that a system satisfies certain properties

Jason Jaskolka Process Algebras 6 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks What Are Process Algebras?

Definition (Process Algebra) A process algebra is (usually) minimally defined as the mathematical structure A = A, +, ; , ||, where A is a set of processes + is a binary operator denoting alternative composition ; is a binary operator denoting sequential composition || is a binary operator denoting parallel composition By using the axioms of the mathematical structure, we can perform calculations with processes.

Jason Jaskolka Process Algebras 7 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Origins of Process Algebras

Origins of process algebras can be traced back to the 1970’s At that time, concurrency theory consisted primarily of the theory of Petri nets (1962) By 1970, three main styles of formal reasoning about computer programs could be distinguished, 1 Operational Semantics: programs modelled as an execution of an abstract machine 2 : programs modelled by a function transforming input to output 3 Axiomatic Semantics: emphasis on proof methods proving programs correct How to give semantics to programs containing a parallel operator?

Jason Jaskolka Process Algebras 8 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Origins of Process Algebras

Two breakthroughs were needed: 1 Abandoning the I/O Paradigm Programs could still be modelled as an automaton Notion of language equivalence is no longer appropriate Process interaction between input and output influences the outcome 2 Replacing Global Variables with Independent execution of parallel processes makes it difficult to determine the values of global variables at a given moment Simpler to let each process have its own local variables, and to denote exchange of information explicitly

Jason Jaskolka Process Algebras 9 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets Calculus of Communicating Systems (CCS) A Comparative Example A Comment on Bisimilarity Concluding Remarks Outline

1 Introduction and Motivation

2 A Brief Overview of Process Algebras Calculus of Communicating Systems (CCS)

3 Process Algebras and Petri Nets

4 A Comparative Example

5 A Comment on Bisimilarity

6 Concluding Remarks

Jason Jaskolka Process Algebras 10 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets Calculus of Communicating Systems (CCS) A Comparative Example A Comment on Bisimilarity Concluding Remarks Common Process Algebras

Robin Milner (1973-1980) Calculus of Communicating Systems (CCS) C.A.R. Hoare (1978) Communicating Sequential Processes (CSP) Jan Bergstra and Jan Willem Klop (1982) Algebra of Communicating Processes (ACP)

Jason Jaskolka Process Algebras 11 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets Calculus of Communicating Systems (CCS) A Comparative Example A Comment on Bisimilarity Concluding Remarks CCS

CCS is action-based, i.e., built upon A set of (atomic) observable actions A = {a, a, b, b, c, c,... } A distinct unobservable (silent) action τ Every observable action a is coupled with another observable action called its conjugate, denoted by a, i.e., a = a CCS provides a method for structuring a collection of actions to describe, in order, some overall coordinated behaviour

Jason Jaskolka Process Algebras 12 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets Calculus of Communicating Systems (CCS) A Comparative Example A Comment on Bisimilarity Concluding Remarks CCS Syntax

BNF Syntax for CCS

E ::= nil (empty process) | X (process variable) | z.E (action) | E + E (choice) | E|E (parallel composition) | E\a (restriction)

Jason Jaskolka Process Algebras 13 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets Calculus of Communicating Systems (CCS) A Comparative Example A Comment on Bisimilarity Concluding Remarks CCS Syntax

The syntax defines CCS process expressions E In the syntax of CCS, a ∈ A and z ∈ A ∪ {τ} Single basic process (constant) nil without any operator Infinite family of prefix unary operators, parameterized by actions z.E Family of postfix unary operators, defined by the restrictions E\a (one for each a ∈ A) Two infix binary operators, + and composition | Process variables, such as X , associated with a unique defining expression of the form X = E Process variables provide support for recursion, e.g., X = a.X

Jason Jaskolka Process Algebras 14 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets Calculus of Communicating Systems (CCS) A Comparative Example A Comment on Bisimilarity Concluding Remarks CCS Behaviours

Every process has an associated set of behaviours Often given in terms of “can make a move” statements, similar to “a transition can occur” statements for Petri nets nil can make no move at all E + F behaves either like E or like F z.E can make the move z and then behaves like E E|F behaves like both E and F , together with some further (synchronized) activities E\a behaves like E, except that actions a and a are blocked X behaves like the process E in the equation X = E

Jason Jaskolka Process Algebras 15 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets Calculus of Communicating Systems (CCS) A Comparative Example A Comment on Bisimilarity Concluding Remarks Structural Operational Semantics (SOS)

Gordon Plotkin (1981) Concept of inference rules of formal logic is applied to processes If a process E makes a move, then the “remaining” behaviour of E after making this move can be described by another process expression E 0 Formally E −−→z E 0 denotes the statement “E makes a move z and becomes E 0”

Jason Jaskolka Process Algebras 16 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets Calculus of Communicating Systems (CCS) A Comparative Example A Comment on Bisimilarity Concluding Remarks Structural Operational Semantics (SOS)

SOS Rule Format If some expression E can make a move and become E 0 (the premise), then some expression D (syntactically related to E) can also make a move and become D0 (the conclusion). A rule is divided by a horizontal bar, above which its premise, and below which its conclusion are given.

Example (Rules for Choice) E −−→z E 0 F −−→z F 0 and E + F −−→z E 0 E + F −−→z F 0

Jason Jaskolka Process Algebras 17 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Outline

1 Introduction and Motivation

2 A Brief Overview of Process Algebras Calculus of Communicating Systems (CCS)

3 Process Algebras and Petri Nets

4 A Comparative Example

5 A Comment on Bisimilarity

6 Concluding Remarks

Jason Jaskolka Process Algebras 18 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Sequential Composition (Action): z.E

CCS generates sequential behaviour is through the action operator

Example a.b.nil can “make an a-move”, thereafter “make a b-move”, and then terminate a.b.nil −−→a b.nil −−→b nil

Jason Jaskolka Process Algebras 19 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Sequential Composition (Action): z.E

e a b x

Figure: A Petri net for a.b.nil before the occurrence of a

e a b x

Figure: A Petri net for a.b.nil before the occurrence of a, i.e., b.nil

Jason Jaskolka Process Algebras 20 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Sequential Composition (Action): z.E

Conceptual discrepancy in thinking about structure and behaviour in CCS and in Petri nets After a has occurred in the net, the transition labelled a is still visible, though it cannot be activated anymore Expression a.b.nil changes to b.nil after the occurrence of a, and thus the a is “lost” Particular to the standard SOS semantics rather than to process algebras CCS explicitly disallows anything more complicated than just an action as the parameter for the action operator, e.g., (a + b).nil is forbidden Emulated using parallel composition and restriction

Jason Jaskolka Process Algebras 21 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Alternative Composition (Choice): E + E

Seems to be a rather innocent operation Care needs to be taken when it is applied in combination with other constructs

Jason Jaskolka Process Algebras 22 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Alternative Composition (Choice): E + E

e e e

a b a b a b

x x x x x x (a) (b) (c) Figure: Petri nets representing alternative composition: (a.nil) + (b.nil)

Jason Jaskolka Process Algebras 23 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Alternative Composition (Choice): E + E

Given (a.nil) + (b.nil), should the corresponding net have only one end, or two, or even three? Cases can be made for each (a) Treats choice as a forward/backward symmetric sequential construct, i.e, like an if-fi statement (b) Seems to be the closest Petri net correspondent to the expression, since there are two nil’s (c) Has strong category theoretical arguments in its favour (not to be discussed here)

Jason Jaskolka Process Algebras 24 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Parallel Composition: E|E

Putting processes in parallel for performance reasons, or for architectural reasons, has long been a challenge for theoreticians and practitioners Behaviour of such compound processes seems is much more difficult to describe and master than sequential behaviour Numerous programming constructs have been invented in order to manage the interaction between parallel processes One is the concept of a handshake communication; a form of a symmetric synchronization much like in Petri net theory, where a transition with n input places can occur only if all of these places carry a token

Jason Jaskolka Process Algebras 25 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Parallel Composition: E|E

CCS has a two-partnered (i.e., n = 2) handshake that always results in an internal action Handshakes can occur only between a actions and their conjugates, a actions Two conjugates fit together like two hands about shake The resulting τ synchronization describes the handshake itself

Example (SOS Rules for Parallel Composition)

E −−→a E 0 F −−→a F 0 E −−→a E 0, F −−→a F 0 E|F −−→a E 0|F E|F −−→a E|F 0 E|F −−→τ E 0|F 0

Jason Jaskolka Process Algebras 26 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Parallel Composition: E|E

What are the interleavings, that the process a.a.nil|a.a.nil could make? Using the first two rules: aaaa, aaaa, aaaa, aaaa, aaaa, aaaa (and all prefixes) Considering the third rule as well: τaa, τaa, aaτ, aaτ, aτa, aτa, ττ What is so bewildering about this is not the sheer size of the set of potential interleavings, but the wide variety of possible interferences at unpredictable points in time

Jason Jaskolka Process Algebras 27 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Parallel Composition: E|E

e a a x

e a a x Figure: A Petri net representing parallel composition: a.a.nil|a.a.nil

Jason Jaskolka Process Algebras 28 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Parallel Composition: E|E

e a a x

τ τ τ τ

e a a x Figure: A Petri net representing parallel composition: a.a.nil|a.a.nil

Jason Jaskolka Process Algebras 29 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Restriction: E\a

Consider the process b.a.nil\a The process can make a b-move and then no further move, since a has been restricted away Note that the same is true for the process b.nil There is a fundamental difference between these two processes: b.nil “terminates properly” b.a.nil\a without reaching its final state This difference is not visible in terms of the behavioural sequences of the two terms, unless we add some information about termination

Jason Jaskolka Process Algebras 30 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Restriction: E\a

e b s x

(a)

e b x

(b) Figure: Petri nets for b.a.nil\a and b.nil

Jason Jaskolka Process Algebras 31 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Restriction: E\a

Restriction is typically used in combination with composition | A pair of conjugated actions is used in order to create a desired synchronization, after which the pair is no longer needed and can be restricted away

Example Consider the process (a.(a.nil))|(a.(a.nil))\a.

Restricting away the a’s and a’s implies that only the τ-behaviour still remains possible; i.e., the process can make two τ moves, and that is all.

Jason Jaskolka Process Algebras 32 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Restriction: E\a

e x

τ τ τ

e x Figure: A Petri net representing restriction: (a.(a.nil))|(a.(a.nil))\a

Jason Jaskolka Process Algebras 33 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Outline

1 Introduction and Motivation

2 A Brief Overview of Process Algebras Calculus of Communicating Systems (CCS)

3 Process Algebras and Petri Nets

4 A Comparative Example

5 A Comment on Bisimilarity

6 Concluding Remarks

Jason Jaskolka Process Algebras 34 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Producer/Consumer Problem

Example A Producer and Consumer communicate through a buffer that can hold one item. A Producer produces items and delivers them to the buffer. A Consumer removes items from the buffer and consumes them.

Jason Jaskolka Process Algebras 35 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Producer/Consumer Problem A Petri Net Solution

ready to deliver ready to consume

buffer full produce deliver remove consume

ready to produce ready to remove buffer empty

Figure: A Petri net solution to the Producer/Consumer problem

Jason Jaskolka Process Algebras 36 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Producer/Consumer Problem A CCS Solution

B ::= deliver.B0 B0 ::= remove.B + deliver.B P ::= deliver.P C ::= remove.C PC ::= (P|B|C)\{deliver, remove}

Figure: A CCS solution to the Producer/Consumer problem

Jason Jaskolka Process Algebras 37 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Outline

1 Introduction and Motivation

2 A Brief Overview of Process Algebras Calculus of Communicating Systems (CCS)

3 Process Algebras and Petri Nets

4 A Comparative Example

5 A Comment on Bisimilarity

6 Concluding Remarks

Jason Jaskolka Process Algebras 38 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks A Comment on Bisimilarity

It is clear that processes like E + F and F + E should be semantically the same Easy to defend with Petri nets (nets are isomorphic) No such notion of isomorphism suggests itself easily for expressions A behavioural, rather than a structural, equivalence relation is sought for One of the fundamental contributions of early CCS is the development bisimulation

Jason Jaskolka Process Algebras 39 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks A Comment on Bisimilarity

Relate sets of states of the two processes that are subject to comparison, in such a way that from two related states, if one of them can make a move, the other one can make a similar move such that the new states are again related A “state” of a process should interpreted as any process that can be reached after a number of moves The initial process can be reached after zero moves Process are generally represented through transition systems or reachability graphs

Jason Jaskolka Process Algebras 40 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks A Comment on Bisimilarity

0 s1 s1 a a a 0 0 s21 s22 s2 b c b c

0 0 s3 s4 s3 s4 (a) (b) Figure: Transition systems for a.(b.nil + c.nil) and a.b.nil + a.c.nil

Jason Jaskolka Process Algebras 41 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks A Comment on Bisimilarity

Definition (Bisimulation)

Suppose (S1, →1) and (S2, →2) are two transition systems with initial states s01 and s02, respectively. Then a relation β ⊆ S1 × S2 is called a bisimulation if and only if the initial states are related by β (i.e., (s01, s02) ∈ β), and whenever two states are related, then the moves in (S1, →1) can be mirrored by moves in (S2, →2) and vice versa, i.e., for each pair (s1, s2) ∈ β we have: z 0 0 z 0 If s1 −−→ s1, then there is s2 ∈ S2 such that s2 −−→ s2 and 0 0 (s1, s2) ∈ β z 0 0 z 0 If s2 −−→ s2, then there is s1 ∈ S1 such that s1 −−→ s1 and 0 0 (s1, s2) ∈ β

Jason Jaskolka Process Algebras 42 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Outline

1 Introduction and Motivation

2 A Brief Overview of Process Algebras Calculus of Communicating Systems (CCS)

3 Process Algebras and Petri Nets

4 A Comparative Example

5 A Comment on Bisimilarity

6 Concluding Remarks

Jason Jaskolka Process Algebras 43 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Current Research in Process Algebras

Developing new process calculi for better modelling of computational phenomena Logics for processes that allow one to reason about arbitrary properties of processes Behavioural theory: what does it mean for two processes to be the same? Using process algebras to model biological systems

Jason Jaskolka Process Algebras 44 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Summary

Defined process algebras Briefly looked at the origins of process algebras Examined Milner’s Calculus of Communicating Systems (CCS) Explored the relationship between process algebras and Petri nets Producer/Consumer Example Discussed the notion of bisimilarity

Jason Jaskolka Process Algebras 45 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks References

J.C.M. Baeten A Brief History of Process Algebra In Theoretical , 335(2-3):131-146. 2005. E. Best and M. Koutny Process Algebra: A Petri-net-oriented tutorial In Lectures on Concurrency and Petri Nets, 3098:180-209. 2003. R. Milner Communication and Concurrency Prentice Hall, International Series in Computer Science, 1989. Wikipedia Process calculus Available: http://en.wikipedia.org/wiki/Process_algebra

Jason Jaskolka Process Algebras 46 / 47 Outline Introduction and Motivation A Brief Overview of Process Algebras Process Algebras and Petri Nets A Comparative Example A Comment on Bisimilarity Concluding Remarks Questions

Questions?

Jason Jaskolka Process Algebras 47 / 47