Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to CSP Alexandre Mota

Similar presentations


Presentation on theme: "Introduction to CSP Alexandre Mota"— Presentation transcript:

1 Introduction to CSP Alexandre Mota (acm@cin.ufpe.br)

2 Agenda Fundamental concepts Process Communication Alphabet Basic behaviour State Alternating behaviour

3 Fundamental Concepts

4 Process Basic unit to capture behaviour In general, we use a set of processes to get modularity It is defined by equation(s) P = (behaviour) Similar to functional programming [although it is not a function!!!] Process names denote interesting system states/modules

5 Process Processes …

6 Communication Term ‘communication’ comes from the notion of interaction/observation/synchronisation It occurs between at least two parts [Which are?] A sequence of communications tells us a history (possible behaviour of a system  trace) A communication can be: Event (no data communication  synchronisation) Channel (a typed value is communicated) data

7 Alphabet Each process has its own alphabet [Hoare 85] – (  P) The whole specification determines the alphabet [Roscoe 98] – (  ) Alphabet is the union of all communications present in the body of all processes Determines the abstraction level

8 Abstraction Level It depends on what one is interested in observing someDigit vs digit_0, digit_1, …, digit_9 Thus, a communication can represent a set of more basic observations It dictates the success of a tool-based analysis The problem of state explosion

9 STOP It is a terminal process The most basic non-communicating and non-progressing process Interaction is forbidden In general, it is only used to denote broken functionality Exercises (broken car and light) When it surprisingly appears we have a deadlock situation

10 STOP 

11 SKIP Similarly to STOP, SKIP is a terminal process However, its occurrence means a successful termination Exercises (Turning off car and light) It only communicates a special event (  ) After that, no communication and progress is possible Curiosity about FDR (STOP vs SKIP)

12 SKIP  

13 Useful Behaviour The most basic construct to model behaviour is the prefix operator (->) Communication -> Process The process a -> P waits indefinitely by a, and then behaves like P Example: TwoSteps = leftFoot -> rightFoot -> SKIP (Exercises) Turning off the light and light is broken…

14 Prefix (a -> P) P a

15 A Complete Specification It is a combination of Alphabet declarations channel up, down Function and set definitions Odd(n) = (n % 2 == 1) T = {0, 1, 2} And process definitions P = up -> down -> up -> down -> STOP And, in general, following this ordering

16 Continuous Behaviour Various systems have a series of repetitive behaviour And these repetitions can be infinite Infinite behaviour becomes recursion P = (sequence of communications) -> P Right-side process name is replaced by a left-side process definition The processes can be different

17 Channels Communications that carry data Declaration needs an associated type channel a: T And the correct use needs one of the three operators: ? (input), ! (output) and. (simple separator) Example: a?var, a!exp, a.exp

18 Events vs Channels They are conceptually distinct But, in practice, a channel is indeed a set of events Thus, the channel a:{0,1} is the set of events {a.0, a.1} Note the use of the. operator as a separator Channels simply have a more elegant and readable presentation than events

19 State When deadling with dynamic data structures It is captured by process parameters Parameters are not typed (Dynamic type checking occurs) This can yield polymorphic solutions Assignment is represented by recursive calls P(n) = addOne -> P(n + 1) Parametrised processes must be instantiated We need P(0), or P(10) to exploit P(n)

20 Conditional Behaviour Data can be used to exhibit different behaviours P(y) = a?x -> if x == y then equal -> P else diff -> P The process b & P (guard) is a shorthand of if b then P else STOP

21 Conditional (if b then P else Q) P b Q  b

22 Alternative Behaviour If the environment can interfere then we use P [ ] Q (Deterministic or external choice) Otherwise P |~| Q (Non-deterministic or internal choice)

23 External Choice P = a -> Q [ ] b -> R P ab ab OR

24 External Choice (P [ ] Q) P a Q b Provided that a is a starting event of P and b a starting event of Q

25 Input and External Choice c?x -> P c.e 0 -> P[e 0 / x] [ ] … [ ] c.e N -> P[e N / x] Let c be a channel of type {e 0, …, e N }

26 Exercise Present a CSP process which captures the first screen of an ATM machine

27 Internal Choice P = a -> Q |~| b -> R P ab

28 Internal Choice (P |~| Q) P  Q 

29 Exercise Present a CSP process which captures the first screen of an ATM machine After selecting one of the possible services, the process can succeed/fail to satisfy it

30 Tool Support ProBE CSP animator (Useful for self-learning) FDR CSP model-checker (Useful for property/refinement analysis) Casper CSP protocol design (Abstract protocol design)

31 References Roscoe, A.W. The Theory and Practice of Concurrency. Prentice-Hall, 1998. Hoare, C.A.R. Communicating Sequential Processes. Prentice-Hall, 1985.Communicating Sequential Processes


Download ppt "Introduction to CSP Alexandre Mota"

Similar presentations


Ads by Google