Presentation is loading. Please wait.

Presentation is loading. Please wait.

C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 C LAUS B RABRAND © 2005, University of Aarhus [ ] [

Similar presentations


Presentation on theme: "C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 C LAUS B RABRAND © 2005, University of Aarhus [ ] ["— Presentation transcript:

1 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 C LAUS B RABRAND © 2005, University of Aarhus [ brabrand@daimi.au.dk ] [ http://www.daimi.au.dk/~brabrand/ ] C ONCURRENCY (Q3,’06) W EEK 7: ”CCS AND PROCESS EQUIVALENCE”

2 C LAUS B RABRAND [ 2 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Outline Calculus of Communicating Systems (CCS) Syntax Semantics CCS  LTS (via Semantics) [ Tool Demo ] Process Equivalence Equivalences: Equivalence Relation and Congruence Trace-Equivalence Bisimulation Specification The Bisimulation Game Game TM [ Tool Demo ]

3 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 C ALCULUS OF C OMMUNICATING S YSTEMS CCS: Calculus of Communicating Systems [ Robin Milner, ’89 ]

4 C LAUS B RABRAND [ 4 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 The Inactive Process: “ 0 ” The inactive process: (aka. “the zero process” or “the nil process”) Performs no action whatsoever! Note that it offers: the prototypical behavior of a deadlocked process (that cannot proceed any further in its execution) Example: 0 0

5 C LAUS B RABRAND [ 5 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Action Prefixing: “ .P ” Action Prefixing: Can perform action, , after which it behaves like process, P Example(s): Match: Complex match: Complex match 2: .P strike.0 take.strike.0 strike.burn.0 output action (convention: over-bar)

6 C LAUS B RABRAND [ 6 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Named Process: “ K ” Named Process: Behaves just like the (statically named) process, K Example(s): K Match = strike.0 ComplexMatch = take.Match def

7 C LAUS B RABRAND [ 7 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Recursive Processes Recursive Processes (though naming) Example: Expanding the definition we get: Clock = tick.Clock def Clock = tick.Clock = tick.tick.Clock = tick.tick.tick. ….tick.Clock … …

8 C LAUS B RABRAND [ 8 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Non-deterministic Choice: “ P+Q ” Non-deterministic choice: Non-deterministic choice between processes P and Q Initially has the capabilities of both P and Q ; but performing an action from P, say, will pre-empt further execution of Q. Example: P+Q Disp = coin.(coke.Disp + sprite.Disp) def coke sprite or

9 C LAUS B RABRAND [ 9 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Parallel Composition: “ P|Q ” Parallel Composition: Any independent interleavings of processes P and Q Also: may communicate (hand-shake): process P using input action, a; process Q corresponding output action, a (or vice versa) Example: Student: Coke Machine: P|Q Stud = read.coin.coke.Stud def CokeM = coin.coke.CokeM def CokeM | Stud

10 C LAUS B RABRAND [ 10 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Parallel Composition (cont’d) Stud | CokeM (Stud | CokeM) | Stud (Stud | CokeM) | CokeM StudCokeM [ > ] read coke coin coke

11 C LAUS B RABRAND [ 11 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Restriction: “ P\a ” Restriction (private name): Behaves just like P, except cannot make a or a actions (except within P ) Reminiscent of local variables (in private scope) Example: P\a (Stud | CokeM) \ coin \ coke ((Stud | CokeM) \ coin \ coke) | Stud

12 C LAUS B RABRAND [ 12 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Action Relabeling: “ P[f] ” Action Relabeling: Behaves like P, except that actions are renamed according to action renaming function, f Permits parameterized reuse of processes Examples: P[f] VendingMachine = coin.item.VendingMachine CokeMachine = VendingMachine[coke/item] MarsMachine = VendingMachine[mars/item] def Note: relabel inputs to inputs (and corresponding outputs to outputs) def

13 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 S YNTAX FOR CCS

14 C LAUS B RABRAND [ 14 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Input, output (and internal) action Actions: Set of Channel Names (input) Set of Channel Co-Names (output) Special silent (invisible/internal) action tau Note: inputs and outputs are complementary: Communication: hand-shake on a and a only (no values) Metavariable,  : a  A  a = a   Act = A  A  {  }

15 C LAUS B RABRAND [ 15 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 CCS Syntax CCS Syntax: “0”// inaction “ .P ”// action prefix “ P+P ”// non-deterministic choice “ P|P ”// parallel composition “ P\a ”// restriction (private name) “ P[f] ”// action relabeling “ K ”// process variable P ::= 0 | .P | P+P | P|P | P\a | P[f] | K X = P, Y = Q, … def  a: f(a) = f(a)  f(  ) =  f:Act  Act … where Note: restrictions on f

16 C LAUS B RABRAND [ 16 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Alternative Syntax Alternative Syntax (that we will use): Abbreviate inaction termination: P for P.0 // obvious from context Parameterized sum:  i  I P i for P 0 + P 1 + … + P n Inactive process (as empty sum):  i  Ø P i for 0 Restriction (by set): P \ L for P \ a 1 \ … \ a n L={a 1,…,a n }

17 C LAUS B RABRAND [ 17 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Algebraic Operator Precedence 1. Restriction and relabelling “ P\L ” “ P[f] ” 2. Action prefixing “ .P ” 3. Parallel composition “ P|Q ” 4. Summation “ P+Q ” Q: How is “ R+a.P|b.Q\L ” then to be read ? A: “ R+((a.P)|(b.(Q\L))) ” ! tightest

18 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 SOS FOR CCS

19 C LAUS B RABRAND [ 19 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 CCS Semantics Structural Operational Semantics: Q: why  (tau) in communication “ P|Q ” (instead of propagating a or a ) ?  ~ “the unobservable hand-shake” [ RES ] [ REN ] [ COM 1 ] [ COM 2 ] [ COM 3 ] [ ACT ] [ SUM ][ DEF ]

20 C LAUS B RABRAND [ 20 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Example Derivation Assume: Consider: A = a.A (b.0|(A|a.0))[c/a] def (b.0 | (A | a.0)) [c/a]  (b.0 | (A | a.0)) [c/a] (b.0 | (A | a.0))  (b.0 | (A | a.0)) [ REN ] (A | a.0)  (A | a.0) [ COM 2 ] A  A a.A  A [ COM 1 ] [ DEF ] [ ACT ] A = a.A def c a a a a [ RES ] [ REN ] [ COM 1 ] [ COM 2 ][ COM 3 ] [ ACT ] [ SUM ][ DEF ]

21 C LAUS B RABRAND [ 21 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Transition Diagram Transition Diagram: A visualization of a Labeled Transition System: Configurations annotated with processes (e.g. ) Transitions annotated with actions (e.g. ) a.0 | a.0 0 | a.0a.0 | 0 0 | 0 a a a a  a.0 | 0 a

22 C LAUS B RABRAND [ 22 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Example: Semaphore Example: Semaphore and mutual exclusion: Mutex = (User | Sema) \ p \ v User = p.enter.exit.v.User Sema = p.v.Sema def // critical region

23 C LAUS B RABRAND [ 23 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Concurrency Workbench [ Concurrency Workbench ]Concurrency Workbench P   testing (interactive simulation)  verification (via logic formulae)  dump transition graph (NFA) ... [ http://homepages.inf.ed.ac.uk/perdita/cwb/summary.html ] http://homepages.inf.ed.ac.uk/perdita/cwb/summary.html

24 C LAUS B RABRAND [ 24 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 CCS Visualizer [ CCS Visualizer ]CCS Visualizer

25 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 P ROCESS E QUIVALENCE

26 C LAUS B RABRAND [ 26 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Equal vs. Equivalent Equal (concrete): 3 = 3 Equivalent (abstract): 3  003 3 10  0x03 16  \003 8  0011 2 3  three 3  3  1+2 3  let n=2 in n*(n-1)+(n-2)  i i i=0 2 more abstract

27 C LAUS B RABRAND [ 27 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 CCS: “Single-Language Formalism” CCS is a so-called “Single-lang. formalism”; i.e. one may specify both: implementation( ) and specification( ) We would like to check via some (reasonable) equivalence, R, that: “The implementation has the intended behavior”: R the spec. and impl. are “equivalent” IMPL = def... SPEC = def... IMPL SPEC We would also like to reason about process equivalence in general

28 C LAUS B RABRAND [ 28 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Equivalence Relation Let R be a binary relation over set A: R  A  A Definition: R is an equivalence relation iff: Reflexive: Symmetric: Transitive:  x  A: x R x  x,y  A: x R y  x R y  x,y,z  A: x R y  y R z  x R z  

29 C LAUS B RABRAND [ 29 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 We would like R to be an equiv.rel. …and we would like ( R to be an equiv. rel.): reflexitivity : SYS R SYS (same behavior as itself) ! transitivity (for stepwise modelling/refinement) !!! : S 0 R S 1 R... R S n R IMPL => S 0 R IMPL symmetry (just a nice property to have in that): S R S’  S’ R S

30 C LAUS B RABRAND [ 30 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 …and satisfy properties: Furthermore, we would like these properties: P+Q R Q+P // ‘ + ’ commutative (P+Q)+R R P+(Q+R) // ‘ + ’ associative i.e. we can drop the parentheses (as in "1+2+3") P|Q R Q|P // ‘ | ’ commutative (P|Q)|R R P|(Q|R) // ‘ | ’ associative i.e. we can drop the parentheses 0+P R P // ‘ 0 ’ is neutral wrt. ‘+’ 0|P R P // ‘ 0 ’ is neutral wrt. ‘ | ’...

31 C LAUS B RABRAND [ 31 ] C ONCURRENCY (Q3,’06) M AR 13, 2006...and be a congruence Definition: “ R ” congruence: P R Q => C[P] R C[Q], for all contexts C[] “relation is preserved under contextual substitution” A context = a process with a gap: Examples: P R Q  P+R R Q+R P R Q  P|S R P|S P R Q  a.P R a.Q P R Q  ((a.P|R)+S)\x R ((a.Q|R)+S)\x []+R []|S a.[] ? C : .[] | []+P | P+[] | []|P | P|[] | [][f] | []\a

32 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 T RACE- E QUIVALENCE "A Tale of Two Coca-Cola Machines"

33 C LAUS B RABRAND [ 33 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Two Dispensers Dispenser: Dispenser’: ’ ’ Would you consider them equal ‘=’ ? coin. (coke + sprite) coin.coke + coin.sprite Would you consider them equivalent ‘  ’ ? What does it mean for them to be equivalent ‘  ’ ? trace equivalence

34 C LAUS B RABRAND [ 34 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Trace Equivalence Definition: Trace Equivalence: Two processes P and Q are trace equivalent “  tr ” iff: they can produce the same traces Example: Traces( ) = { , coin, coin;coke, coin;sprite } Traces( ) = { , coin, coin;coke, coin;sprite } coin. (coke + sprite) coin.coke + coin.sprite ’ ’ ’ ’  tr Hence:

35 C LAUS B RABRAND [ 35 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Trace Equivalence (cont'd) Equivalence Relation? Expected Properties? Congruence?

36 C LAUS B RABRAND [ 36 ] C ONCURRENCY (Q3,’06) M AR 13, 2006...but are they "observably equivalent"? Recall: Coke-only-drinker observer: Contextual composition: coin. (coke + sprite) coin.coke + coin.sprite ’ ’ ’ ’  tr What the.. !? coin. coke. drink The coke drinker is certainly able to to "distinguish" the two dispensers !! Can we put the two dispensers in a context where they can be differentiated by some observer? problematic equality

37 C LAUS B RABRAND [ 37 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Trace Equiv. ~ DFM Acceptance P  tr Q iff they can produce the same traces This point of view is totally justified and natural if we view our LTSs as non- deterministic devices that may generate or accept sequences of actions. However, is it still a reasonable one if we view our automata as reactive machines that interact with their environment ? -- [ Aceto, Larsen, Ingólfsdóttir ] ‘  tr ’ doesn’t take communication capabilities of intermediate states into account; can make a big difference when made to interact w/ another system! 

38 C LAUS B RABRAND [ 38 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Trace Equivalence On sale… Trace Equivalence Special offer: 5 for only $0.85 This week only! “On sale: 5 for only $0.85!” “ Trace Equivalence ” 5 for $0.85  tr

39 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 (S TRONG ) B ISIMULATION: ( ~ )

40 C LAUS B RABRAND [ 40 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Def: A Bisimulation Let (Proc, Act,  ) be a LTS Def: a bin. rel. R  Proc  Proc is a bisimulation iff whenever ( s, t )  R :  a  Act : if s  s’ then t  t’ for some t’ such that ( s’, t’ )  R if t  t’ then s  s’ for some s’ such that ( s’, t’ )  R Note: Definition on LTS (not necessarily on processes) a a a a a Intuition: “Only equate as consistently allowed by the semantics”

41 C LAUS B RABRAND [ 41 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Def: Bisimilarity ( ~ ) A Bisimulation: Def: a bin. rel. R  Proc  Proc is a bisimulation iff whenever ( s, t )  R :  a  Act : if s  s’ then t  t’ for some t’ such that ( s’, t’ )  R if t  t’ then s  s’ for some s’ such that ( s’, t’ )  R The Bisimilarity relation ( ~ ): Def: two (processes) s and t are bisimilar ( s ~ t ) iff  bisimulation R : ( s, t )  R. i.e. a a a a ‘ ~ ’ :=  { R | R is a bisimulation }

42 C LAUS B RABRAND [ 42 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Basic Properties of ( ~ ) Theorem: ‘ ~ ’ is an equivalence relation Theorem: ‘ ~ ’ is the largest bisimulation i.e. for any bisimulation R we have that: R  ‘ ~ ’ Theorem: s ~ t iff  a  Act : if s  s’ then t  t’ for some t’ such that s’ ~ t’ if t  t’ then s  s’ for some s’ such that s’ ~ t’ a a a a

43 C LAUS B RABRAND [ 43 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 How to Prove Bisimilarity ? How to prove bisimilarity for two processes ? i.e. ?: Exhibit a (any) bisimulation R, for which: By definition we get that: since ‘ ~ ’ was the largest bisimulation ( s, t )  R  ‘ ~ ’ ( s, t )  R p ~ qp ~ q

44 C LAUS B RABRAND [ 44 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Example Proof of Bisimilarity Example: Buffer (capacity 1): Buffer (capacity 2): Show that: A 0 = def in. A 1 A 1 = def out. A 0 B 0 = def in. B 1 B 1 = def in. B 2 + out. B 0 B 2 = def out. B 1 B 0 ~ A 0 |A 0 B0B0 B1B1 B2B2 A 0 |A 0 A 1 |A 0 A 0 |A 1 A 1 |A 1 R = { ( B 0, A 0 |A 0 ), ( B 1, A 1 |A 0 ), ( B 1, A 0 |A 1 ), ( B 2, A 1 |A 1 ) }

45 C LAUS B RABRAND [ 45 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 How to Prove Non-Bisimilarity ? How to prove non-bisimilarity ? i.e. ? Enumerate all binary relations: Check that none are bisimulations and contain (p,q) However: extremely expensive O(2 |p||q| ) Use “Feynman Problem-Solving Algorithm”: (1). Write down the problem; (2). Think very hard; (3). Write down the answer. Or… s ~ ts ~ t

46 C LAUS B RABRAND [ 46 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 The Bisimulation Game It’s Amazing… The Bisimulation Game ® Special Family Edition (w/ TV cables & remote control) Beat your sister at Process Algebra simulation… “Special Family Edition!” “ The Bisimulation Game ” Only $31,95 The Bisimulation Game

47 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 ( ~ ) B ISIMULATION G AMES

48 C LAUS B RABRAND [ 48 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 The (Strong) Bisimulation Game Let (Proc, Act,  ) be a LTS and s, t  Proc Define 2-player game: [ attacker v defender ] The game is played in “rounds” and the configurations of the game are (Proc  Proc); The game starts (first round) in ( s, t )  Proc  Proc Intuition (objectives): The defender wants to show that: The attacker wants to show that: a s ~ ts ~ t s ~ ts ~ t

49 C LAUS B RABRAND [ 49 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Rules of the Bisimulation Game In round k the players change the current configuration ( s k, t k ) as follows: First, the attacker chooses: 1) one of the processes (e.g. t k ); i.e., left or right; 2) a legal action from that process: a  Act; 3) a legal transition according to the LTS: t k  t k+1 Then, the defender chooses: -) a “counter-move” using same action, a: s k  s k+1 ( s k+1, t k+1 ) becomes the next round’s configuration… Winning: If (only) one player cannot move, the other player wins If the game is infinite, the defender wins a a

50 C LAUS B RABRAND [ 50 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Game Characterization of ( ~ ) Theorem: States (processes) s and t are not strongly bisimilar iff the attacker has a universal winning strategy States (processes) s and t are strongly bisimilar iff the defender has a universal winning strategy ( s ~ t ) basically means that: “the ‘perfect attacker’ always wins” ( s ~ t ) basically means that: “the ‘perfect defender’ always wins”

51 C LAUS B RABRAND [ 51 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Let’s Play… Let’s play…: ~ / ~ ? show of hands… ~ ’ ’ ? coin. (coke + sprite) coin.coke + coin.sprite ’ ’ coin ’ ’ sprite coke

52 C LAUS B RABRAND [ 52 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Another Game… Are the following two LTS(/processes) s and t strongly bisimilar: s ~ t ? There’s a universal attack strategy  hence, they are not strongly bisimilar : s ~ t

53 C LAUS B RABRAND [ 53 ] C ONCURRENCY (Q3,’06) M AR 13, 2006 Tool Demos... [ CCS Visualizer/Simulator ]: [ The Bisimulation Game Game ]: By: - Martin Mosegaard - Claus Brabrand By: - Martin Mosegaard - Claus Brabrand

54 C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 Good luck with the exams


Download ppt "C LAUS B RABRAND C ONCURRENCY (Q3,’06) M AR 13, 2006 C LAUS B RABRAND © 2005, University of Aarhus [ ] ["

Similar presentations


Ads by Google