Top Banner
1 Semantics Q1 2007 SEMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student [email protected]
57

1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student [email protected].

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

1

Semantics Q1 2007

SEMANTICS (Q1,’07)Week 5

Jacob AndersenPhD student

[email protected]

Page 2: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

2

Semantics Q1 2007

News…

• Exam Date & Time (Preliminary):– Wednesday October 31st 9.00 – 13.00

• Page on CCS tools.

Page 3: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

3

Semantics Q1 2007

Outline• Type Checking (from last week)• Concurrency vs. Sequentiality• CCS: "Calculus of Communicating Systems"

• By-example (one construction at a time)

• Syntax of CCS• 7 linguistic constructions(!)

• Semantics of CCS• 1 page(!)

• Describing processes with CCS• CCS tools

Page 4: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

4

Semantics Q1 2007

TYPE CHECKING DEFINITIONS

Page 5: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

5

Semantics Q1 2007

Adding Boolean Variables: LetB++

• Consider language LetB++:

– Mixed Expressions (e Exp):•

– Definitions (d Def):•

– Note: The type of a var is now context dependent• I.e. a context-free (grammar) approach will not suffice

– Examples: ? ? …

e ::= n | t | x | ~ e | e e’ | e ? e’ : e” | let d in e

d ::= nil | x = e | d ; d’ | d and d’ | d in d’

{ +, -, * , =, or }…where:

x or tt x * x

type definition (annotation) { bool, int }…where:

Page 6: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

6

Semantics Q1 2007

Static Semantics: LetB++

• FVE, DVD and FVD as before• …adding:

• We now need type environments:• Type = { bool, int }

• Define static semantics (type checking rel’s):• “e has type (given type environment )”

• “d yields type env. (given type env. )”

FVE(e ? e’: e”) = FVE(e) FVE(e’) FVE(e”)

TEnvV = Var Type

|- e :

|- d :

Page 7: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

7

Semantics Q1 2007

Static Semantics (expressions)• Expressions:[NUM]E |- n : int |- t : bool[TVL]E

[VAR]E |- x : (x)

[VAR]E |- ~ e : bool

|- e : bool[LET]E |- let d in e :

|- d : [] |- e :

[IFE]E |- e0 ? e1 : e2 :

|- e0 : bool |- e1 : 1 |- e2 : 2 = 1 =2

[BOP]E |- e0 e1 : type(0,1)

|- e0 : 0 |- e1 : 1

Page 8: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

8

Semantics Q1 2007

Static Semantics (definitions)• Definitions:

[NIL]D |- nil : [] [DEF]D |- x = e : [x]

|- e : ’ = ’

[SEQ]D |- d0 ; d1 : 0[1]

|- d0 : 0 [0] |- d1 : 1

[AND]D |- d0 and d1 : 01

|- d0 : 0 |- d1 : 1

[IN]D |- d0 in d1 : 1

|- d0 : 0 [0] |- d1 : 1

DV(d0) DV(d1) = Ø

Note:combined environment

Note:only last environment

Note:disjointenvironment

Note: type check

Page 9: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

9

Semantics Q1 2007

Dynamic Semantics: LetB++

• Type Environment (Compile-time):• Type = { bool, int }

• Environment (Runtime):• Val = B Z, B = { tt, ff }

– Define type correspondence relation ‘~’:

– Note:

TEnv = Var Type

Env = Var Val

~ x V: (x) = bool (x) B (x) = int (x) Z

( 0 ~ 0 1 ~ 1 ) 0[1] ~ 0[1]

Page 10: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

10

Semantics Q1 2007

Exp. Transition System for LetB++

• Let++ Expression Configurations:• •

• LetB++ Expression Configurations: Var Type:

• Env := » i.e., “only type corresponding runtime environments”

= { <e, > | |-wfe e }

T = { <z, > | z Z } only well-formed exps

= { <e, > | Env : |- e : }

T = { <r, > | Env r B Z }

{ ( Var B Z ) | ~ }

Page 11: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

11

Semantics Q1 2007

Def. Transition System for LetB++

• Let++ Definition Configurations:• •

• LetB++ Definition Configurations: Var Type:

• Env := » i.e., “only type corresponding runtime environments”

V = { <d, > | |-wfd d }

only well-formed defsTV = { <0, ’> }

= { <d, > | Env : |-V d : }

T = { <0, > | Env }

{ ( Var B Z ) | ~ }

Page 12: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

12

Semantics Q1 2007

Exp. Dynamic Semantics: LetB++

• SOS of Expressions for LetB++:

– E.g. [LET]:•

[LET2]

[LET3]

[LET1]

Env

|- let d in e let d’ in e

|- d d’

|- let 0 in r r

|- let 0 in e let 0 in e’

[0] |- e [0] e’ 0 ~ 0

Page 13: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

13

Semantics Q1 2007

Def. Dynamic Semantics: LetB++

• SOS of Definitions for LetB++:

– E.g [SEQ]:•

[SEQ2]

[SEQ3]

[SEQ1]

|- d0 ; d1 d0’ ; d1

|- d0 d0’

|- 0 ; 1 0[1]

|- 0 ; d1 0 ; d1’

[0] |- d1 [0] d1’

Env

0 ~ 0

Page 14: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

14

Semantics Q1 2007

CONCURRENCY VS.

SEQUENTIALITY

Page 15: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

15

Semantics Q1 2007

Concurrency vs. Sequentiality• Sequential programming:

• Describe computation as a “reduction” of expressions to values

• Inherently deterministic

• Termination often desirable

• Resulting value is of primary interest and focus

• Concurrent programming:• Describe execution as “process evolution”

• Inherently non-deterministic

• Non-termination often desirable (Op.Sys., Control sys, Cell-phone, …)

• Describe possible executions (aka. execution traces)

• Describe possible interactions during execution

• Describe interaction with an environment

• Resulting “value” is not (necessarily) interesting

Page 16: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

16

Semantics Q1 2007

Concurrency is much Harder• Harder than sequential programming:

• Huge number of possible executions• Inherently non-deterministic• Parallelism conceptually harder

• Consequences:• Programs are harder to write!• Programs are harder to debug!• Errors are not always reproducible• New kinds of errors possible:

» Deadlock, starvation, priority inversion, interference, …

Page 17: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

17

Semantics Q1 2007

Concurrency Problems• Therac-25 Radiation Therapy

– ’85-’87• Massive overdoses (6 deaths / amputations)!

• Mars Pathfinder– July ’97

• Periodic resets (on mars)!

• Windows 95/98 w/ Device Drivers– late ’90es

• Dysfunction (“blue screen of death”)!

Page 18: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

18

Semantics Q1 2007

Concurrency Problems (cont’d)• Mobile Phones

– ’00-…• Freeze and odd behaviors (really annoying)!

• Cruise Control System Model– ’86 [Grady Booch]

• Accellerated after car ignition (car crashes)!

• …

Page 19: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

19

Semantics Q1 2007

Problem: System Development?• In the presence of all these errors:

• deadlock, starvation, priority inversion, interference, anti-cooperation, un-intended execution traces, un-fairness, …

• How to…:• 1. …design a system that “works” ?• 2. …verify that the system is “safe” ?• 3. …verify that the system “meets its specification” ?…and: What does “works”, “safe”, and “to meet a specification” mean ?!?

Page 20: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

20

Semantics Q1 2007

Solution: Modelling• “Models come to the rescue”:

• Create models (~ architecture, bridge construction, …)

Note: “Errors are much cheaper to commit in models than in implementations”

Page 21: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

21

Semantics Q1 2007

Dictionary: “model”

• In this course (we use):• 3+4 : as in “Model-based design” (designing a model of a concurrent system)• 12 : as in “Model-checking” (checking implementation against declarative (logic)

specification)

Main Entry: 1mod·el Pronunciation: 'mä-d&lFunction: nounEtymology: Middle French modelle, from Old Italian modello, from (assumed) Vulgar Latin modellus, from Latin modulus small measure, from modus1 obsolete : a set of plans for a building2 dialect British : COPY, IMAGE3 : structural design <a home on the model of an old farmhouse>4 : a usually miniature representation of something; also : a pattern of something to be made5 : an example for imitation or emulation6 : a person or thing that serves as a pattern for an artist; especially : one who poses for an artist7 : ARCHETYPE8 : an organism whose appearance a mimic imitates9 : one who is employed to display clothes or other merchandise : MANNEQUIN10 a : a type or design of clothing / b : a type or design of product (as a car)11 : a description or analogy used to help visualize something (as an atom) that cannot be directly observed12 : a system of postulates, data, and inferences presented as a mathematical description of an entity or state of affairs13 : VERSION

Webster’s(“model”):

Page 22: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

22

Semantics Q1 2007

Modelling: Level of Abstraction• Consider a client/server system:

• Extremely abstract (high level of abstraction):»

• Appropriate (level of abstraction) for … :»

• Extremely concrete (low level of abstraction):»

Universe = event.Universedef

NAND_Gate = ...Transistor = ...Accumulator = ......Client = ...

def

def

def

Server = request.process.reply.ServerClient = calc.request.wait.reply.ClientDatabase = ...

high

er le

vel o

f ab

stra

ctio

n

def

def

def

def

Page 23: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

23

Semantics Q1 2007

Solution: Modelling• “Models come to the rescue”:

• Create models (~ architecture, bridgeconstruction, …)

• Formal modelling (e.g., CCS) permits:• (Offline) Reasoning understanding• (Runtime) Testing confidence• (C-time) Property Verification safety• (C-time) Specification Verification correctness

“Never send a human to do a machine’s job”-- A.Smith (’99)

auto-mate

Note: “Errors are much cheaper to commit in models than in implementations”

Page 24: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

24

Semantics Q1 2007

Methodology: Model-based Design

• Design abstract model

• Decompose model

• Reason/Test/Verify model» individual parts and whole

• Recompose insights» make model safe

• Impl. concrete program

concretize

REAL PROBLEM

SAFE MODEL

SAFE PROGRAM

abstract

? ?

?

?

MODEL

testreason

verify

Page 25: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

25

Semantics Q1 2007

CCS: Why a Calculus (pl. Calculi)

• Compositional:• ||

» Break things into (several) smaller things

• Algebraic:• , , …

» Intuitive ideal (also eases automated verification)

• Syntactic:• and …

» Provide basis for programming languages

P | Q P Q

big

P + Q Q + P P | Q Q | P

P P’P | Q P’ | Q

Q Q’P | Q P | Q’[PAR1] [PAR2]

Page 26: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

26

Semantics Q1 2007

Parallel- vs. Concurrent Programming

• Strategy:– Optimal strategy for a particular goal– Use available resources efficiently

• Safety:– Conceptually independent players– Control interaction and “rules”

The Football Match Analogy:“An analogy that one can make is with football*; - the coach of the team is a parallel programmer while - the referee is a concurrent programmer” -- [P.Panangaden, ’96]

The Referee (~ the concurrent programmer):-- Make sure what is happening is a soccer match

The Trainer (~ the parallel programmer):-- Make sure my agents are performing “optimally”

*/ interpret appropriately on either side of the Atlantic

Page 27: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

27

Semantics Q1 2007

CALCULUS OF COMMUNICATING

SYSTEMS

CCS: Calculus of Communicating Systems

[ Robin Milner, ’89 ]

Page 28: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

28

Semantics Q1 2007

Concurrency and Communication• Concurrency:

• Parallel processes (construction ‘P|Q’)» Abstract away (physical) processors» Abstract away diff. in real- vs pseudo-parallelism

• Communication:• Process synchronization (aka. hand-shaking)

» Abstract away communication protocol » Abstract away actual values passed

Page 29: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

29

Semantics Q1 2007

• Example: a process modelling a CS student:

Interface:

• Process name: CS• Input action(s): { coke }• Output action(s): { coin, exercise }

Behavior of the process described by a CCS program

Process Interface

exercise

coin

coke

Page 30: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

30

Semantics Q1 2007

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

Page 31: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

31

Semantics Q1 2007

Action Prefixing: “.P”• Action Prefixing:

• Can perform action, , after which it behaves like process, P

• Example(s):

• Match:

• Complex match

.P

strike.0

take.strike.0

Page 32: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

32

Semantics Q1 2007

Named Process: “K”• Named Process:

• Behaves just like the (statically named) process, K

• Example(s):

K

Match = strike.0

SingleCokeDisp = coin.coke.0

def

def

Page 33: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

33

Semantics Q1 2007

Recursive Processes• Recursive Processes (though naming)

• Example:•

• Expanding the definition we get:»

Clock = tick.Clockdef

Clock

= tick.Clock

= tick.tick.Clock

= tick.tick.tick. … .tick.Clock

Page 34: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

34

Semantics Q1 2007

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

spriteor

Page 35: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

35

Semantics Q1 2007

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.Studdef

CokeM = coin.coke.CokeMdef

CokeM | Stud

Page 36: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

36

Semantics Q1 2007

Parallel Composition (cont’d)

Stud | CokeM

(Stud | CokeM) | Stud

(Stud | CokeM) | CokeM

Stud CokeM

[ << ? >> ]

[ << ? >> ]

read

coke

coin

coin

coke

Page 37: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

37

Semantics Q1 2007

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

Page 38: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

38

Semantics Q1 2007

Action Relabelling: “P[f]”• Action Relabelling:

• 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

def

Page 39: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

39

Semantics Q1 2007

SYNTAX FOR CCS

Page 40: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

40

Semantics Q1 2007

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)

• Metavariables:• •

a A

a A

a = a

a L = A A

Act = L { }

Page 41: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

41

Semantics Q1 2007

CCS Syntax• CCS Syntax:

• “0” // inaction• “.P” // action prefix, Act• “P+P” // non-deterministic choice• “P|P” // parallel composition

• “P\L” // restriction (private name), L ⊆ L• “P[f]” // action relabelling

• “K” // process variable, K K

P ::= 0 | .P | P+P | P|P | P\L | P[f] | K

K1 = P1, K2 = P2, … def def

a: f(a) = f(a)

f() =

f:ActAct

… where

Note: restrictions on f

Page 42: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

42

Semantics Q1 2007

Alternative Syntax• Alternative Syntax (that we will also use):

– Parameterized sum:iI Pi for P0 + P1 + … + Pn

– Inactive process (as empty sum):iØ Pi for 0

– Restriction (by element):•P \ a for P \ {a}

Page 43: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

43

Semantics Q1 2007

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

Page 44: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

44

Semantics Q1 2007

SOS FOR CCS

Page 45: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

45

Semantics Q1 2007

SOS for CCS• Structural Operational Semantics:

Q: why (tau) in communication “P|Q” (instead of propagating a or a) ?

~ “the unobservable hand-shake”

[RES][REL]

[COM1] [COM2] [COM3]

[ACT] [SUMj][CON]

Page 46: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

46

Semantics Q1 2007

DESCRIBING PROCESSES WITH CCS

Page 47: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

47

Semantics Q1 2007

Transition Diagram• Transition Diagram:

• A visualization of a Labelled Transition System:» Configurations annotated with processes (e.g. )» Transitions annotated with actions (e.g. )

a.0 | a.0

0 | a.0 a.0 | 0

0 | 0

a a

aa

a.0 | 0

a

Page 48: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

48

Semantics Q1 2007

Traces• Definition:

• A “trace”, ω=[α1,…, αk]Act* (k ≥ 0), of a process P is a sequence of actions such that the following sequence of configurations can be derived from P:

• A trace can be the empty sequence []• We use the constant ε ≝ []

• traces(P): The set of all traces of P.• The set of traces, traces(P), of a process P is

”closed under prefix”, i.e. if ωtraces(P) then this is also the case for any prefix of ω.

P → P1 → … → Pk α1 α2 αk

Page 49: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

49

Semantics Q1 2007

Example: Traces

• traces( ) = {ε,a,a,,aa,aa}• For more complex traces use regular expressions

a.0 | a.0

0 | a.0 a.0 | 0

0 | 0

a a

aa

a.0 | a.0

Page 50: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

50

Semantics Q1 2007

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)) [REL]

(A | a.0) [COM2]

A

a.A

[COM1]

[CON]

[ACT]

A = a.Adef

c

a

a

a

a

[RES][REL]

[COM1] [COM2] [COM3]

[ACT] [SUMj][CON]

c

(b.0 | (A | a.0)) [c/a]

(b.0 | (A | a.0))

(A | a.0)

A

A

Page 51: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

51

Semantics Q1 2007

Example: Lock ("Mutual Exclusion")

• Example: ("mutex") Lock• • •

• •

• Q: How are the critical enters and exits related ?» A: never two enters without exit in between

Mutex = (User | Lock) \ {acq,rel}

User = acq.enter.exit.rel.User

Lock = acq.rel.Lockdef

def

def

System = (User | Lock | User’) \ {acq,rel}def

User’ = User[enter’/enter,exit’/exit]def

// critical regionaka. a

"semaphore"

acq

rel

Sema = p.v.Sema"Probeer te verlagen" (Dutch: try to decrease)

"Verhoog" (Dutch: increase)E. Dijkstra

Historically:

Lock

def

Page 52: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

52

Semantics Q1 2007

CCS TOOLS

Page 53: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

53

Semantics Q1 2007

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 ]

[ /users/courses/dSem/bin/cwb ]

Page 54: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

54

Semantics Q1 2007

The Concurrency Workbench• CWB:

• Recommendation: try it out (before the exam)!

Command: input “PandQ.ccs”;

Command: sim(P); // run the built-in simulator

Command: output “P.graph”; // name output fileCommand: graph(P); // output for CCS visualizer and simulator

Command: strongeq(P,Q); // strong bisimilarityCWB’s answer

Command: eq(P,Q); // weak bisimilarityCWB’s answer

Page 55: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

55

Semantics Q1 2007

CCS Visualizer and Simulator• [ CCS Visualizer and Simulator ]

[ http://www.brics.dk/bisim/ ]

[ /users/courses/dSem/bin/cv ]

[ /users/courses/dSem/bin/tbgg ]

Page 56: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

56

Semantics Q1 2007

"Three minutes paper"• Please spend three minutes writing down the

most important things that you have learned today (now).

After 1 dayAfter 1 week

After 3 weeksAfter 2 weeks

Right away

Page 57: 1 Semantics Q1 2007 S EMANTICS (Q1,’07) Week 5 Jacob Andersen PhD student andersen@daimi.au.dk.

57

Semantics Q1 2007

Next week: Equivalences,

Bisimulation, and Games

Any Questions?