Communication and Concurrency: CCS

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

Automata Theory Part 1: Introduction & NFA November 2002.
Process Algebra Book: Chapter 8. The Main Issue Q: When are two models equivalent? A: When they satisfy different properties. Q: Does this mean that the.
Tintu David Joy. Agenda Motivation Better Verification Through Symmetry-basic idea Structural Symmetry and Multiprocessor Systems Mur ϕ verification system.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Lecture 24 MAS 714 Hartmut Klauck
Process Algebra (2IF45) Abstraction in Process Algebra Suzana Andova.
1 Model checking. 2 And now... the system How do we model a reactive system with an automaton ? It is convenient to model systems with Transition systems.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
PROTOCOL VERIFICATION & PROTOCOL VALIDATION. Protocol Verification Communication Protocols should be checked for correctness, robustness and performance,
Game-theoretic simulation checking tool Peter Bulychev, Vladimir Zakharov, Igor Konnov Moscow State University.
1.6 Behavioral Equivalence. 2 Two very important concepts in the study and analysis of programs –Equivalence between programs –Congruence between statements.
Programming Paradigms for Concurrency Lecture 11 Part III – Message Passing Concurrency TexPoint fonts used in EMF. Read the TexPoint manual before you.
Behavioral Equivalence Hossein Hojjat Formal Lab University of Tehran.
1 Towards formal manipulations of scenarios represented by High-level Message Sequence Charts Loïc Hélouet Claude Jard Benoît Caillaud IRISA/PAMPA (INRIA/CNRS/Univ.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
Course on Probabilistic Methods in Concurrency (Concurrent Languages for Probabilistic Asynchronous Communication) Lecture 1 The pi-calculus and the asynchronous.
Introduction to Computability Theory
Ordering and Consistent Cuts Presented By Biswanath Panda.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
1 Ivan Lanese Computer Science Department University of Bologna Roberto Bruni Computer Science Department University of Pisa A mobile calculus with parametric.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
1 Ivan Lanese Computer Science Department University of Bologna Italy Behavioural Theory for SSCC Joint work with Luis Cruz-Filipe, Francisco Martins,
Bridging the gap between Interaction- and Process-Oriented Choreographies Talk by Ivan Lanese Joint work with Claudio Guidi, Fabrizio Montesi and Gianluigi.
1 IFM 2005 – November 30, 2005 EXP.OPEN 2.0 A flexible tool integrating partial order, compositional, and on-the-fly verification methods Frédéric Lang.
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
Bridging the gap between Interaction- and Process-Oriented Choreographies Talk by Ivan Lanese Joint work with Claudio Guidi, Fabrizio Montesi and Gianluigi.
1 Ivan Lanese Computer Science Department University of Bologna Italy Concurrent and located synchronizations in π-calculus.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
1 Ivan Lanese Computer Science Department University of Bologna Italy Behavioural Theory at Work: Program Transformations in a Service-centred Calculus.
Describing Syntax and Semantics
Complete Axioms for Stateless Connectors joint work with Roberto Bruni and Ugo Montanari Dipartimento di Informatica Università di Pisa Ivan Lanese Dipartimento.
Regular Model Checking Ahmed Bouajjani,Benget Jonsson, Marcus Nillson and Tayssir Touili Moran Ben Tulila
Process Algebra (2IF45) Probabilistic Branching Bisimulation: Exercises Dr. Suzana Andova.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
SDS Foil no 1 Process Algebra Process Algebra – calculating with behaviours.
Advanced Topics in SE Spring Process Algebra Hossein Hojjat Formal Methods Lab University of Tehran.
Semantic Formalisms 1: An Overview Eric Madelaine INRIA Sophia-Antipolis Oasis team UNICE – EdStic Mastère Réseaux et Systèmes.
Reactive systems – general
2G1516 Formal Methods2005 Mads Dam IMIT, KTH 1 CCS: Operational Semantics And Process Algebra Mads Dam Reading: Peled 8.3, 8.4, 8.6 – rest of ch. 8.
“Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
1 Bisimulations as a Technique for State Space Reductions.
Semantic Formalisms: an overview Eric Madelaine INRIA Sophia-Antipolis Oasis team Mastère Réseaux et Systèmes Distribués.
11/19/20151 Metodi formali nello sviluppo software a.a.2013/2014 Prof.Anna Labella.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Syntax and Semantics CIS 331 Syntax: the form or structure of the expressions, statements, and program units. Semantics: the meaning of the expressions,
Laws of concurrent design Tony Hoare Microsoft ResearchCambridge FMCAD October.
Formal Methods for Software Engineering Part II: Modelling & Analysis of System Behaviour.
MPRI 3 Dec 2007Catuscia Palamidessi 1 Why Probability and Nondeterminism? Concurrency Theory Nondeterminism –Scheduling within parallel composition –Unknown.
CS 5204 Spring 99 1 A Simple Agent A CCS agent is described both by a structural diagram and one or more algebraic equations. The diagram is for readability.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
MPRI – Course on Concurrency Lectures 11 and 12 The pi-calculus expressiveness hierarchy Catuscia Palamidessi INRIA Futurs and LIX
2G1516 Formal Methods2005 Mads Dam IMIT, KTH 1 CCS: Processes and Equivalences Mads Dam Reading: Peled 8.5.
2G1516/2G1521 Formal Methods2004 Mads Dam IMIT, KTH 1 CCS: Processes and Equivalences Mads Dam Reading: Peled 8.1, 8.2, 8.5.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Concurrency 5 The theory of CCS Specifications and Verification Expressive Power Catuscia Palamidessi
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
Process Algebra (2IF45) Expressiveness of BPArec
Formal Methods in software development
Presentation transcript:

Communication and Concurrency: CCS R. Milner, “A Calculus of Communicating Systems”, 1980

Why calculi? Prove properties on programs and languages Principle: tiny syntax, small semantics, to be handled on paper or mechanically Prove properties on the principles of a language or a programming paradigm Examples: lambda calculus, sigma calculus, …

Static semantics : examples Checks non-syntactic constraints compiler front-end : declaration and utilisation of variables, typing, scoping, … static typing => no execution errors ??? or back-ends : optimisers defines legal programs : Java byte-code verifier JavaCard: legal acces to shared variables through firewall What can we do/know about a program without executing it? Mastère RSD - TC4 oct-nov 2007

Mastère RSD - TC4 oct-nov 2007 Dynamic semantics Gives a meaning to the program (a semantic value) Describes the behaviour of a (legal) program Defines a language interpreter |- e -> e ’ let i=3 in 2*i -> 6 Objective = to prove properties on Program execution (determinacy, subject reduction, …) Mastère RSD - TC4 oct-nov 2007

The different semantic families Denotational semantics mathematical model, high level, abstract Axiomatic semantics provides the language with a theory for proving properties / assertions of programs Operational semantics computation of the successive states of an abstract machine used to build evaluators, simulators. Mastère RSD - TC4 oct-nov 2007

What about concurrency and communication? Different timing (synchronous/asynchronous …) Different programming models (what is the unit of concurrency? What is sufficient to characterize an execution?...?) Interaction between communication/concurrency/shared memory! Through CCS, this course is a simple study of synchronous communications

SEMANTICS

Operational Semantics Describes the computation States and configuration of an abstract machine: Stack, memory state, registers, heap... Abstract machine transformation steps Transitions: current state -> next state Several different operational semantics

Natural Semantics : big steps (Kahn 1986) Defines the results of evaluation. Direct relation from programs to results env |- prog => result env: binds variables to values result: value given by the execution of prog Reduction Semantics : small steps describes each elementary step of the evaluation rewriting relation : reduction of program terms stepwise reduction: <prog, s> -> <prog’, s ’> infinitely, or until reaching a normal form.

Labelled Transition Systems (LTS) Basic model for representing reactive, concurrent, parallel, communicating systems. Definition: < S, s0, L, T> S = set of states S0  S = initial state L = set of labels (events, communication actions, etc) T  S x L x S = set of transitions Notation: s1  s2 = (s1, a, s2)  T a Mastère RSD - TC4 oct-nov 2007

An example

Deduction Rules

CCS – SYNTAX AND SEMANTICS

CCS syntax Channel names: a, b, c , . . . Co-names: Silent action: τ Actions: Processes:

A tiny example Labelled graph vertices: process expressions labelled edges: transitions Each derivable transition of a vertex is depicted Abstract from the derivations of transitions

CCS : behavioural semantics (1) Operators and rules Action prefix: Communication: Parallelism

CCS : behavioural semantics (2) Operators and rules Non-deterministic choice Scope restriction Recursive definition

Derivations (construction of each transition step) Prefix a.P Par-L Prefix a R a P | Q Par-2 a.P | Q a .R  (P | Q) | R (a.P | Q) | a.R One amongst 3 possible derivations Par-2(Par_L(Prefix), Prefix) Another one : Par-L(Par_L(Prefix)) (a.P | Q) | a.R a (P | Q) | a.R

equivalences

Behavioural Equivalences Intuition: Same possible sequences of observable actions Finite / infinite sequences Various refinements of the concept of observation Definition: Trace Equivalence For a LTS (S, s0, L, T) its Trace language T is the set of finite sequences {(t = t1, …, tn such that s0,…,sn  Sn+1, and (sn-1,tn,sn)  T} Two LTSs are Trace equivalent iff their Trace languages are equal. Corresponding Ordering: Trace inclusion

Trace Languages, Examples Those 2 systems are trace equivalent: A trace language can be an infinite set: ≡ a b c T = {(), (a), (a,b), (a,c)} b a T = {(), (a), (a,a), (a,…,a),… (a,b), (a,a,b), (a,a,…,a,b), …}

~ Bisimulation Behavioural Equivalence Bisimulations non distinguishable states by observation: two states are equivalent if for all possible transitions labelled by the same action, there exist equivalent resulting states. Bisimulations R  SxS is a simulation iff It is a equivalence relation (p,q)  R, (p,l,p’)  T =>  q’/ (q,l,q’)  T and (p’,q’)  R R is a bisimulation if the same condition hold with q too: (p,q)  R, (q,l,q’)  T =>  q’/ (q,l,q’)  T and (p’,q’)  R ~ is the coarsest bisimulation 2 LTS are bisimilar iff their initial states are in ~ quotients = canonical normal forms ~ act

Transitivity If R, S are bisimulations, then so is their composition RS = {(P, P’) | ∃ Q. P R Q and Q S P’} In particular, ∼∼ ⊆ ∼, i.e., bisimilarity is transitive.

~ Bisimulation More precise than trace equivalence : a Preserves deadlock properties. Can be built by adding elements in the equivalence relation Coinductive definition (biggest set verifying …) ~ a b c A0 A1 A2 A3 B0 B1 B3 B2 B4 No state in B is equivalent to A1

~ is a congruence for all CCS operators : Bisimulation Congruence laws: P1~P2 => a.P1 ~ a:.2 ( P1,P2,a) P1~P2, Q1~Q2 => P1+Q1 ~ P2+Q2 P1~P2, Q1~Q2 => P1|Q1 ~ P2|Q2 Etc… ~ is a congruence for all CCS operators : Basis for compositional proof methods Maximal trace is not an equivalence for any CCS context C[.], C[P] ~ C[Q] <=> P~Q

Observational Equivalences Weak bisimulation Abstraction: hidden actions allows for arbitrary many internal actions μ ⇒  * * act

Weak bisimulation The following def is a tractable version of weak bisimulation: A weak bisimulation is a relation R such that P R Q ⇒ ∀μ, P, P’ (P →P’ ⇒ ∃Q’. Q ⇒Q’ and P’ R Q’) and conversely Note the dissymetry between the use of →on the left and of ⇒ on the right Two processes are weakly bisimilar if (notation P ≈ Q) if there exists a weak bisimulation R such that P R Q. μ μ

Branching bisimulation only staying in equivalent states Still existence of a canonical minimal automata Computation is polynomial  a

Additional notations and constructs

Alternative Notations a little more complex for several definitions -> exercise? Input/output: a=?a ; a = !a | or ||

Extension: Parameterized actions input of data at port a, a(x ).E a(x ) binds free occurrences of x in E . Port a represents {a(v ) : v ∈ D } where D is a family of data values Output of data at port a, a(e ).E where e is a data expression. Transition Rules: depend on extra machinery for expression evaluation. Let Val(e ) be data value in D (if there is one) to which e evaluates R (in) a(x ).E → E {v /x } if v ∈ D where {v /x } is substitution R (out) a(e ).E → E if Val(e ) = v a(v ) a (v )

Regi = read(i ).Regi + write(x ).Reg x Example: a register Regi = read(i ).Regi + write(x ).Reg x

EXAMPLES

Example: dining philosophers chopstick Take_left Take_right Drop_left! Drop_left Drop_right! Drop_right Idle Eat Drop? Take? (recidling,eating. (idle.idling + take_left.take_right.eating + take_right.take_left.eating, eat.eating + drop_left.drop_right.idling + drop_right.drop_left.idling) Deadlock or not ? Mutual exclusion ?

(trivial) example: Milner’s Scheduler Processes iteratively start and finish executing tasks (one task per process) Task starts are cyclically ordered cycler = .start.(.0 || end.cycler) scheduler_3 = local 1, 2, 3 in ( [1/ , 2/, start1/start, end1/end] cycler || [2/ , 3/, start2/start, end2/end] cycler || [3/ , 1/, start3/start, end3/end] cycler || 1.0) vérification des propriétés ?

Scheduler_2 expanded tau start1 end2 end1 tau end2 end2 start1 end1

Scheduler_2 reduced tau start1 end2 end1 tau end2 end2 start1 end1

Scheduler_2 reduced end1 start1 end2 end2 start1 end1 start2 end2 end1

CONCLUSION A synchronous communication language A (complex but) efficient notion of equivalence on processes What is missing? Channel communication (like in pi-calculus) -> much more complex No computational construct by nature

exercises

Example: Alternated Bit Protocol ?imss !omss Fwd_channel !in0 ?out0 ?ack1 ?imss !ack1 ?out0 ?ack0 !omss ?ack1 !omss ?imss ?out1 !in1 ?ack0 Bwd_channel ?out1 !ack0 emitter receiver Hypotheses: channels can loose messages Requirement: the protocol ensures no loss of messages Write in CCS ?

Example: Alternated Bit Protocol (2) emitter = let rec {em0 = ?ack1 :em0 + ?imss:em1 and em1 = !in0 :em1 + ?ack0 :em2 and em2 = ?ack0 :em2 + ?imss :em3 and em3 = !in1 :em3 + ?ack1 :em0 } in em0 ABP = local {in0, in1, out0, out1, ack0, ack1, …} in emitter || Fwd_channel || Bwd_channel || receiver Mastère RSD - TC4 oct-nov 2007

Example: Alternated Bit Protocol (3) Channels that loose and duplicate messages (in0 and in1) but preserve their order ? Exercise : 1) Draw an LTS describing the loosy channel behaviour 2) Write the same description in CCS Mastère RSD - TC4 oct-nov 2007

Exercise 2

Exercice 3 : Bisimulations ?in0 Are those 3 LTSs equivalent by: Strong bisimulation? Weak bisimulation ? In each case, give a proof.  !out0 !out0 ?in0  !out0   !out0 ?in1 ?in0

Exercice 3 : Bisimulation !out0  ?in0 A1 Exercice : Compute the strong minimal automaton for A1. Compute the weak minimal automaton for A1.

Exercise 5 Compare the construct = and recK : def Compare the construct = and recK : Let us start by a simple pair of processes Suppose rec can accept several variables: rec (K=P,L=Q) express the same term Is it possible to express the same thing with a single variable K? Here are some possible hints: Define a recursive process All that contains A and B and can trigger each of them by the reception of a message on channel cA or cB (we suppose cA and cB cannot be used elsewhere) What kind of equivalence between the two expressions do you have?

Correction

Exercice: Alternated Bit Protocol Correction (1): Channels that loose and duplicate messages (in0 and in1) but preserve their order ? 1) Draw an automaton describing the loosy channel behaviour !out0 !out1 ?in1  ?in0 It is a symmetric system, receiving ?in0 and ?in1 messages, then delivering 0 , 1 or more times the corresponding !out0 or !out1 message. On each side (bit 0 or 1), the initial state has a single transition for the reception. In the next state, it can either : return silently to the initial state (= lose the message), deliver the message and return to the initial state (exactly one delivery), or deliver the message and stay in the same state (thus enabling duplication).

Exercice: Alternated Bit Protocol Correction (2): Channels that loose and duplicate messages (in0 and in1) but preserve their order ? 2) Write it in CCS !out0 !out1 ?in1  ?in0 Lousy channel = let rec {ch0 = ?in0 :ch1 + ?in1:ch2 and ch1 =  :ch1 +  :ch0 + !out0 :ch1 + !out0 :ch0 and ch2 =  :ch2 +  :ch0 + !out0 :ch2 + !out0 :ch0 } in ch0

Exercice: Alternated Bit Protocol Correction (3): ?in0 Channels that loose and duplicate messages (in0 and in1) but preserve their order ? Other Solutions: More generally, parameterized model :  !out0 !out0 ?in0  !out0 !out(x)  ?in(x) x

Exercice 2 : Bisimulations ?in0 Are those 3 LTSs equivalent by: Strong bisimulation? NO ! Need find non equivalent states. E.g. counter example for 1 ≠ 2: States 1.0 and 1.1 are different because 1.0 can do ?in0 and 1.1 cannot. Then 1.1 and 2.1 are different because 1.1 can do !out0 -> 1.0, while no 2.1 !out0 transitions can go to a state equivalent to 1.0. Weak bisimulation ? YES. Exhibit a partition of equivalent states: 1={1.0,2.0}, 2={1.1, 2.1} Check all possible (*a*) transitions: 1 - !in0 -> 2, … , 2 - !out0.* -> 1 Remark: this transition set defines the minimal representant modulo weak bisimulation…  1.1 1.0 !out0 !out0 ?in0  2.1 2.0 !out0   !out0 ?in1 ?in0

Exercice 4 : Produit synchronisé Compute the synchronized product of the LTS representing the ABP emitter with the (forward) Channel: local {in0, in1} in (Emitter || Channel) ?imss ?ack0 ?ack1 !in0 !in1 1 !out0 !out1 ?in1  ?in0 3 2 1 2

Exercice 4 : Produit synchronisé Correction ? partially… local {in0, in1} in (Emitter || Channel) !out0   ?ack1 ?imss  !out0 0,0 1,0 1,1 ?ack0 ?ack0  ?ack1 2,1  2,0 !out0 !out0  !in1 ?ack0 3,0 3,1 ?imss ?imss  !out1

Exercice 4 : Produit synchronisé Correction ? Tool generated LTS…