Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 11: An introduction to CSP.

Slides:



Advertisements
Similar presentations
Vered Gafni – Formal Development of Real Time Systems 1 Statecharts Semantics.
Advertisements

Formal Semantics of Programming Languages 虞慧群 Topic 6: Advanced Issues.
Chair of Software Engineering The alias calculus Bertrand Meyer ITMO Software Engineering Seminar June 2011.
CSC321 §6 Modelling Processes using FSP 1 Section 6 Modelling Processes using FSP.
Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
1 Lecture 3 The CSP approach to the specification and analysis of Security protocols Communicating Sequential Processes [Hoare 78] Mathematical framework.
1 FLACOS Malta October 2008 Service Oriented Architectures: The new Software Paradigm W. Reisig Humboldt-Universität zu Berlin Theory of Programming.
1 Software Architecture Bertrand Meyer ETH Zurich, March-May 2009 Lecture 15: Designing for concurrency & real-time.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Introduction to Computability Theory
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
Checking correctness properties of object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 1 EEF summer school on Specification,
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Exercise Session 2: Introduction.
Software Engineering, COMP201 Slide 1 Protocol Engineering Protocol Specification using CFSM model Lecture 30.
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
1 Ivan Lanese Computer Science Department University of Bologna Italy Concurrent and located synchronizations in π-calculus.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 11: An introduction to CSP.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 5 Slide 1 Requirements engineering l The process of establishing the services that the.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Introduction to Formal Methods Based on Jeannette M. Wing. A Specifier's Introduction to Formal Methods. IEEE Computer, 23(9):8-24, September,
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
SDS Foil no 1 Process Algebra Process Algebra – calculating with behaviours.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Managing XML and Semistructured Data Lecture 13: XDuce and Regular Tree Languages Prof. Dan Suciu Spring 2001.
Introduction to CSP Alexandre Mota
CSP: Communicating Sequential Processes. Overview Computation model and CSP primitives Refinement and trace semantics Automaton view Refinement checking.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
Internet Security CSCE 813 Communicating Sequential Processes.
UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine1 CSE 503 – Software Engineering Lecture 7: Process calculi and refinement Rob DeLine 19 Apr.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Discrete Mathematical Structures 4 th Edition Kolman, Busby, Ross © 2000 by Prentice-Hall, Inc. ISBN
MPRI 3 Dec 2007Catuscia Palamidessi 1 Why Probability and Nondeterminism? Concurrency Theory Nondeterminism –Scheduling within parallel composition –Unknown.
CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay 2 The D FlipFlop The RS flipflop stores one bit of information.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Modelling Reactive Systems 4 Professor Muffy Calder Dept. of Computing Science University of Glasgow
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Properties as Processes : FORTE slide Properties as Processes: their Specification and Verification Joel Kelso and George Milne School of Computer.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Agenda  Quick Review  Finish Introduction  Java Threads.
Types and Programming Languages Lecture 16 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Internet Security CSCE 813 Communicating Sequential Processes.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
1 Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Theory of Computation Automata Theory Dr. Ayman Srour.
Formal Methods in software development
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
ISA 763 Security Protocol Verification
COSC 3340: Introduction to Theory of Computation
Chapter Five: Nondeterministic Finite Automata
Formal Methods in software development
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Presentation transcript:

Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 11: An introduction to CSP

2 Origin Communicating Sequential Processes: C.A.R. Hoare 1978 paper, based in part on ideas of E.W. Dijkstra (guarded commands, 1978 paper and “A Discipline of Programming” book) Revised with help of S. D. Brooks and A.W. Roscoe 1985 book, revised 2004 Complete reference: The Theory and Practice of Concurrency, A. W. Roscoe, Prentice Hall 1997 (2005) (used extensively in the present slides)

3 CSP purpose Concurrency formalism  Expresses many concurrent situations elegantly  Influenced design of several concurrent programming languages, in particular Occam (Transputer) Calculus  Formally specified: laws  Makes it possible to prove properties of systems

4 Traces A trace is a sequence of events, for example Many traces of interest are infinite, for example (Can be defined formally, e.g by regular expressions, but such traces definition are not part of CSP; they are descriptions of CSP process properties.) Events come from an alphabet. The alphabet of all possible events is written  in the following.

5 Processes and their traces A CSP process is characterized (although not necessarily defined fully) by the set of its traces. For example a process may have the trace set {<>,, } The special process STOP has a trace set consisting of a single, empty trace: {<>}

6 Basic CSP syntax P ::= STOP|-- Does not engage in any events a  Q |-- Engages in a, then acts like P Q П R|-- Internal choice Q  R|-- External choice Q || R|-- Concurrency (E: subset of alphabet) Q || R|-- Lock-step concurrency (same as P || P) Q \ E|-- Hiding  Q f (Q)-- Recursion E 

7 Generalization of  notation Basic: a  P Generalization: x: E  P (x) Accepts any event from E, then executes P (x) where x is that event Also written ? x: E  P (x)

8 Some laws of concurrency 1. P || Q = Q || P 2. P || (Q || R)) = ((P || Q) || R) 3. P || STOP = STOP 4. (c  P) || (c  Q) = (c  (P || Q)) 5. (c  P) || (d  Q) = STOP-- If c ≠ d 6. (x: A  P (x)) || (y: B  Q (y)) = (z: (A  B)  (P (z) || Q (z))

9 Basic notions Processes engage in events Example of basic notation: CVM = (coin  coffee  coin  coffee  STOP) Right associativity: the above is an abbreviation for CVM = (coin  (coffee  (coin  (coffee  STOP)))) Trace set of CVM: { } The events of a process are taken from its alphabet:  (CVM) = {coin, coffee} STOP can engage in no events

10 Traces traces (e  P) = { + s | s  traces (P)}

11 Exercjses: determine traces P ::= STOP|-- Does not engage in any events a  Q |-- Engages in a, then acts like P Q П R|-- Internal choice Q  R|-- External choice Q || R|-- Concurrency (E: subset of alphabet) Q || R|-- Lock-step concurrency (same as P || P) Q \ E|-- Hiding  Q f (Q)-- Recursion E 

12 Recursion CLOCK = (tick  CLOCK) This is an abbreviation for CLOCK =  P (tick  P) A recursive definition is a fixpoint equation. The  notation denotes the fixpoint.

13 Accepting one of a set of events; channels Basic notation: ? x: A  P (x) Accepts any event from A, then executes P (x) where x is that event Example: ? y: c.A  d.y’ (where c.A denotes {c.x | x  A} and y’ denotes y deprived of its initial channel name, e.g. (c.a)’ = a) More convenient notation for such cases involving channels: c? x: A  d!x Channel names

14 A simple buffer COPY = c? x: A  d!x  COPY

15 External choice COPYBIT = (in.0  out.0  COPYBIT  in.1  out.1  COPYBIT)

16 External choice COPY1 = in? x: A  out1!x  COPY1 COPY2 = in? x: B  out2!x  COPY2 COPY3 = COPY1  COPY2

17 External choice Consider CHM1 = (in1f  out50rp  out20rp  out20rp  out10rp) CHM2 = (in1f  out50rp  out50rp) CHM = CHM1  CHM2

18 More examples VMC = (in2f  ((large  VMC)  (small  out1f  VMC))  (in1f  ((small  VMC)  (in1f  large  VMC)) FOOLCUST = (in2f  large  FOOLCUST  in1f  large  FOOLCUST) FV = FOOLCUST || VMC =  P (in2f  large  FV  in2f  STOP)

19 Hiding Consider P = a  b  Q Assuming Q does not involve b, then P \ {b} = a  Q More generally: (a  P) \ E =  P \ E if a  E  a  (P\ E) if a  E

20 Hiding introduces internal non-determinism Consider R = (a  P)  (b  Q) Then R \ {a, b} = P П Q

21 Internal non-deterministic choice CH1F = (in1f  ((out20rp  out20rp  out20rp  out20rp  out20rp  CH1F) П (out50rp  out50rp  CH1F)))

22 Non-deterministic internal choice: another application TRANSMIT (x) = in?x  LOSSY (x) LOSSY (x)= out!x  TRANSMIT (x) П out!x  LOSSY (x) П TRANSMIT (x)

23 The general concurrency operator Consider P = ?x: A  P’ Q = ?x: B  Q’ Then P || Q = ? x   (P’ || Q’) if x  E  A  B  (P’ || Q) if x  A-B-E  (P || Q’) if x  B-A-E  (P’ || Q) П (P || Q’) if x  (A  B) - E E E E E

24 Special cases of concurrency Lock-step concurrency: P || Q= || Q Interleaving: P ||| Q= || Q  

25 Laws of non-deterministic internal choice P П P = P P П Q = Q П P P П ( Q П R) = (P П Q) П R x  (P П Q) = (x  P) П ( x  Q) P || ( Q П R) = (P || Q) П (P || R ) (P П Q) || R = (P || R) П (Q || R ) The recursion operator is not distributive; consider: P =  X ((a  X) П ( b  X)) Q = (  X (a  X)) П (  X (b  X))

26 Refinement Process Q refines (specifically, trace-refines) process P if traces (Q)  traces (P) For example: P refines P П Q

27 Traces traces (e  P) = { + s | s  traces (P)}

28 Exercise: determine traces P ::= STOP|-- Does not engage in any events a  Q |-- Engages in a, then acts like P Q П R|-- Internal choice Q  R|-- External choice Q || R|-- Concurrency (E: subset of alphabet) Q || R|-- Lock-step concurrency (same as P || P) Q \ E|-- Hiding  Q f (Q)-- Recursion E 

29 The trace model is not enough The traces of and are the same: traces (P  Q) = traces (P)  traces (Q) traces (P П Q) = traces (P)  traces (Q) But the processes can behave differently if for example: P = a  b  STOP Q = b  a  STOP Traces define what a process may do, not what it may refuse to do

30 Refusals For a process P and a trace t of P:  An event set es  P (  ) is a refusal set if P can forever refuse all events in es  Refusals (P) is the set of P’s refusal sets  Convention: keep only maximal refusal sets (if X is a refusal set and Y  X, then Y is a refusal set) This also leads to a notion of “failure”:  Failures (P, t) is Refusals (P / t) where P/t is P after t: traces (P / t) = {u | t + u  traces (p))

31 Comparing failures Compare  P = a  STOP  b  STOP  Q = a  STOP П b  STOP Same traces, but:  Refusals (P) =   Refusals (Q) = {{a}, {b}}

32 Refusal sets (from labeled transition diagram)  a b  = { a, b, c} ({b, c}} {{a, c}} {}{} a  STOP П b  STOP {{a, c}, {b, c}} {}{} {}{} {}{} a  STOP  b  STOP {{ c}} a b

33 A more complete notion of refinement Process Q failures-refines process P if both traces (Q)  traces (P) failures (Q)  failures (P) Makes it possible to distinguish between  and П

34 Divergence A process diverges if it is not refusing all events but not communicating with the environment This happens if a process can engage in an infinite sequence of  transitions Another example of diverging process: (μ p.a → p) \ a

35 CSP: Summary A calculus based on mathematical laws Provides a general model of computation based on communication Serves both as specification of concurrent systems and as a guide to implementation One of the most influential models for concurrency work