the calculus of communicating systems dr liam o connor
play

The Calculus of Communicating Systems Dr. Liam OConnor University - PowerPoint PPT Presentation

CCS The Calculus of Communicating Systems Dr. Liam OConnor University of Edinburgh LFCS (and UNSW) Term 2 2020 1 CCS Where we are at Last lecture we concluded our examination of proof methods for concurrency by examining compositional


  1. CCS The Calculus of Communicating Systems Dr. Liam O’Connor University of Edinburgh LFCS (and UNSW) Term 2 2020 1

  2. CCS Where we are at Last lecture we concluded our examination of proof methods for concurrency by examining compositional techniques. We also discussed how to prove properties of asynchronous systems. This lecture, we’ll take a brief detour into the world of process algebra , a high level formalism for describing concurrent systems. In particular we will examine CCS, but similar principles apply for other formalisms like CSP and ACP. Many of the resources for this lecture were borrowed from Graham Hutton. 2

  3. CCS CCS The Calculus of Communicating Systems : Is a process algebra , a simple formal language to describe concurrent systems. Is given semantics in terms of labelled transition systems . Was developed by Turing-award winner Robin Milner in the 1980s. Has an abstract view of synchronization that applies well to message passing. Why do we learn this? This gives us a symbolic way to describe our transition diagrams, and reason about them symbolically rather than diagramatically. 3

  4. CCS Processes Processes in CCS are defined by equations: Example The equation: CLOCK = tick defines a process CLOCK that simply executes the action “tick” and then terminates. This process corresponds to the first location in this labelled transition system (LTS): • tick • An LTS is like a transition diagram, save that our transitions are just abstract actions and we have no initial or final location. 4

  5. CCS Action Prefixing Example Definition CLOCK 2 = tick . tock If a is an action and P is a process, then x . P is a process that executes x defines a process called CLOCK 2 that before P . This brackets to the right, so: executes the action “tick” then the action “tock” and then terminates. x . y . z . P = x . ( y . ( z . P )) tick tock • • • Stopping More precisely, we should write: The process: CLOCK 3 = tock . tick CLOCK 2 = tick . tock . STOP has the same actions as CLOCK 2 but where STOP is the trivial process with arranges them in another order. no transitions. 5

  6. CCS Loops Up to now, all processes make a finite number of transitions and then terminate. Processes that can make a infinite number of transitions can be pictured by allowing loops: Example (Loops) • tick tick the process that diverges = the process that alternates tock tick = executing “tick” transitions “tick” and “tock” forever • • CLOCK 4 = tick . CLOCK 4 CLOCK 5 = tick . tock . CLOCK 5 We accomplish loops in CCS using recursion. 6

  7. CCS Equality of Processes These two processes are physically different: • tick tick tick tick • • CLOCK 4 = tick . CLOCK 4 CLOCK 6 = tick . tick . CLOCK 6 But they both have the same behaviour — an infinite sequence of “tick” transitions. Informal Definition We consider two process to be equal if an external observer cannot distinguish them by their actions. We will refine this definition later. 7

  8. CCS A Simple Vending Machine Vending Machines are very common examples for process algebra. Example (An inflexible machine) Suppose I define my vending machine as: in50 ¢ • • VM 1 = in50 ¢ . outCoke . in20 ¢ . outMars . VM 1 outMars outCoke • • in20 ¢ This machine is not very flexible: It only accepts exact money. The customer has no choice: The machine dispenses Coke and Mars bars alternately. 8

  9. CCS Choice To make a more flexible kind of vending machine, we need a (nondeterministic) choice operator. Example outMars outCoke • in20 ¢ in50 ¢ VM 2 = (in50 ¢ . outCoke . VM 2 ) + (in20 ¢ . outMars . VM 2 ) • • Here we have a process VM 2 that repeatedly either inputs 50 ¢ and outputs a coke, or inputs 20 ¢ and outputs a mars bar. Definition If P and Q are processes then P + Q is a process which can either behave as the process P or the process Q . 9

  10. CCS Choice Equalities Observe that we have the following identities about choice: P + ( Q + R ) = ( P + Q ) + R (associativity) P + Q = Q + P (commutativity) P + STOP = (neutral element) P P + P = P (idempotence) What about the equation: ? a . ( P + Q ) ( a . P ) + ( a . Q ) = • • a a a ? • • • = Q Q P P 10

  11. CCS Branching Time Example VM 3 = in50 ¢ . (outCoke + outPepsi) VM 4 = (in50 ¢ . outCoke) + (in50 ¢ . outPepsi) • • in50 ¢ in50 ¢ in50 ¢ • • • outPepsi outCoke outPepsi outCoke • • • • Or in pictures: Reactive Systems VM 3 allows the customer to choose which drink to vend after inserting 50 ¢ . In VM 4 however, the machine makes the choice when the customer inserts a coin. They different in this reactive view, but they have the same behaviours! 11

  12. CCS Equivalences The equation a . ( P + Q ) = ( a . P ) + ( a . Q ) is usually not admitted for this reason. Exercise It is possible to construct two processes that are equal assuming this equation but do not have the same set of behaviours (and thus do not satisfy the same LTL properties). If we do admit it, then our notion of equality is very coarse (it is called partial trace equivalence). This is enough if we want to prove safety properties, but progress is not guaranteed. Liam: Explain why on the board Terminology Our notion of equality without this equation is called (strong) bisimulation equivalence or (strong) bisimilarity. 12

  13. CCS Exercises A clock that can stop at any time. A clock that ticks or tocks at each cycle. A clock that ticks each cycle or tocks each cycle. A vending machine for Mars and Coke that gives change. 13

  14. CCS Parallel Composition Definition If P and Q are processes then P | Q is the parallel composition of their processes — i.e. the non-deterministic interleaving of their actions. Example (Clocks) ACLOCK = tick.beep | tock CCLOCK = TICLK | TOCLK beep tick • • • TICLK = tick . TICLK tock • • • TOCLK = tock . TOCLK Exercise : Express these processes without parallel composition. 14

  15. CCS Synchronization In CCS, every action a has an opposing coaction a (and a = a ): Actions: tick tock in50 ¢ outCoke . . . Coactions: tick tock in50 ¢ outCoke . . . It is a convention to think of an action as an output event and a coaction as an input event. If a system can execute both an action and its coaction, it may execute them both simultaneously by taking an internal transition marked by the special action τ . Example (Relay Race) start baton • • • RACE = RUN 1 | RUN 2 τ baton • • • RUN 1 = start . baton finish RUN 2 = baton . finish • • • 15

  16. CCS Expansion Theorem Let P and Q be processes. By expanding recursive definitions and using our existing equations for choice we can express P and Q as n-ary choices of action prefixes: P = � i ∈ I α i . P i and Q = � j ∈ J β j . Q j . Then, the parallel composition can be expressed as follows: � � � P | Q = α i . ( P i | Q ) + β j . ( P | Q j ) + τ. ( P i | Q j ) . i ∈ I j ∈ J i ∈ I , j ∈ J , α i = β j From this, many useful equations are derivable: P | Q = Q | P P | ( Q | R ) = ( P | Q ) | R P | STOP = P 16

  17. CCS Restriction We wish a way to say “these are all the processes that there are”, in other words, to force synchronization to happen and not allow certain actions to be taken alone. Definition If P is a process and a is an action (not τ ), then P \ a is the same as the process P except that the actions a and a may not be executed. We have ( a . P ) \ b = a . ( P \ b ) if a / ∈ { b , b } Example (Relay Race) start baton • • • RACE = ( RUN 1 | RUN 2 ) \ baton τ baton RUN 1 = start . baton • • • finish RUN 2 = baton . finish • • • 17

  18. CCS Another Example A man that eats every time a clock ticks: CLOCK 4 = tick . CLOCK 4 MAN = tick . eat . MAN EXAMPLE = ( MAN | CLOCK 4 ) \ tick After deriving the picture, we get: τ • • eat 18

  19. CCS Semantics Up until now, our semantics were given informally in terms of pictures. Now we will formalise our semantic intuitions. Our set of locations in our labelled transition system will be the set of all CCS processes. Locations can now be labelled with what process they are: 50 ¢ . (coke + pepsi) 50 ¢ coke + pepsi pepsi coke STOP STOP We will now define what transitions exist in our LTS by means of a set of inference rules . This technique is called operational semantics . 19

  20. CCS Inference Rules In logic we often write: A 1 A 2 · · · A n C To indicate that C can be proved by proving all assumptions A 1 through A n . For example, the classical logical rule of modus ponens is written as follows: A ⇒ B A Modus Ponens B 20

  21. CCS Operational Semantics Liam will incrementally draw these on the board. a a → P ′ → Q ′ − − P Q Act → P ′ Choice 1 → Q ′ Choice 2 a a a a . P − → P P + Q − P + Q − a a a a → P ′ → Q ′ → P ′ → Q ′ − − − − P Q P Q Par 1 → P | Q ′ Par 2 Sync → P ′ | Q → P ′ | Q ′ a a τ P | Q − P | Q − P | Q − a → P ′ P − a / ∈ { b , b } Restrict → P ′ \ b a P \ b − Bisimulation Equivalence Two processes (or locations) P and Q are bisimilar iff they can do the same actions and those actions themselves lead to bisimilar processes. All of our previous equalities can be proven by induction on the semantics here. 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend