Programming Paradigms for Concurrency Lecture 11 Part III – Message Passing Concurrency TexPoint fonts used in EMF. Read the TexPoint manual before you.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Substitution & Evaluation Order cos 441 David Walker.
Computational Privacy. Overview Goal: Allow n-private computation of arbitrary funcs. –Impossible in information-theoretic setting Computational setting:
10 October 2006 Foundations of Logic and Constraint Programming 1 Unification ­An overview Need for Unification Ranked alfabeths and terms. Substitutions.
1 PROPERTIES OF A TYPE ABSTRACT INTERPRETATER. 2 MOTIVATION OF THE EXPERIMENT § a well understood case l type inference in functional programming à la.
Applying Petri Net Unfoldings for Verification of Mobile Systems Apostolos Niaouris Joint work with V. Khomenko, M. Koutny MOCA ‘06.
Formal Semantics of Programming Languages 虞慧群 Topic 6: Advanced Issues.
1.6 Behavioral Equivalence. 2 Two very important concepts in the study and analysis of programs –Equivalence between programs –Congruence between statements.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Recap 1.Programmer enters expression 2.ML checks if expression is “well-typed” Using a precise set of rules, ML tries to find a unique type for the expression.
1 Formalizing Web Service Choreographies Antonio Brogi, Carlos Canal, Ernesto Pimentel, Antonio Vellecillo presented by Axel Polleres
01/05/2015 Agay Spring School, March'02 Mobility 1 : the Pi Calculus Cédric Fournet Microsoft Research Cambridge.
Course on Probabilistic Methods in Concurrency (Concurrent Languages for Probabilistic Asynchronous Communication) Lecture 1 The pi-calculus and the asynchronous.
Foundations of Interaction ETAPS `05 0 Ex nihilo: a reflective higher- order process calculus The  -calculus L.G. Meredith 1 & Matthias Radestock.
Catriel Beeri Pls/Winter 2004/5 functional-language 1 Substitution Semantics of FL – a simple functional language FL is EL + (non-recursive) function creation.
Foundations of Programming Languages: Introduction to Lambda Calculus
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
An Introduction to Input/Output Automata Qihua Wang.
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 Roberto Bruni Computer Science Department University of Pisa A mobile calculus with parametric.
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
Syntax With Binders COS 441 Princeton University Fall 2004.
1 Formal Models for Distributed Negotiations Concurrent Languages Translation Roberto Bruni Dipartimento di Informatica Università di Pisa XVII Escuela.
Bridging the gap between Interaction- and Process-Oriented Choreographies Talk by Ivan Lanese Joint work with Claudio Guidi, Fabrizio Montesi and Gianluigi.
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.
Formal Modeling of Concurrent Processes: PI and API Calculi Shahram Rahimi.
1 Ivan Lanese Computer Science Department University of Bologna Italy Concurrent and located synchronizations in π-calculus.
Mobile Ambients Luca Cardelli Digital Equipment Corporation, Systems Research Center Andrew D. Gordon University of Cambridge, Computer Laboratory Presented.
Chapter 4: A Universal Program 1. Coding programs Example : For our programs P we have variables that are arranged in a certain order: Y 1 X 1 Z 1 X 2.
CS3773 Software Engineering
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
Aquinas Hobor and Cristian Gherghina (National University of Singapore) TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Programming Paradigms for Concurrency Lecture 10 Part III – Message Passing Concurrency.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
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.
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.
CS5204 – Operating Systems 1  -Calculus Reasoning about concurrency and communication (Part 1).
CSC321 §6 Modelling Processes using FSP 1 Chapter 6 Modelling Processes using FSP.
An Ontological Framework for Web Service Processes By Claus Pahl and Ronan Barrett.
Programming Paradigms for Concurrency Pavol Cerny Vasu Singh Thomas Wies Part III – Message Passing Concurrency.
Internal Talk, Oct Executable Specifications using Message Sequence Charts Abhik Roychoudhury School of Computing National University of Singapore.
UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine1 CSE 503 – Software Engineering Lecture 7: Process calculi and refinement Rob DeLine 19 Apr.
11/19/20151 Metodi formali nello sviluppo software a.a.2013/2014 Prof.Anna Labella.
Weak Bisimilarity Coalgebraically Andrei Popescu Department of Computer Science University of Illinois.
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.
MPRI – Course on Concurrency Lectures 11 and 12 The pi-calculus expressiveness hierarchy Catuscia Palamidessi INRIA Futurs and LIX
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.
CS3773 Software Engineering Lecture 06 UML State Machines.
Several sets of slides by Prof. Jennifer Welch will be used in this course. The slides are mostly identical to her slides, with some minor changes. Set.
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
COMP 3438 – Part II-Lecture 5 Syntax Analysis II Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
CSE-321 Programming Languages -Calculus (II) POSTECH March 26, 2007 박성우.
Agenda  Quick Review  Finish Introduction  Java Threads.
1 Theoretical Foundations of Concurrency A formal study of concurrency enables: understanding the essential nature of concurrency reasoning about the behavior.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Types and Programming Languages Lecture 16 Simon Gay Department of Computing Science University of Glasgow 2006/07.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
6/21/20161 Programming Languages and Compilers (CS 421) Reza Zamani Based in part on slides by Mattox Beckman,
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Sequence Diagram.
Reasoning about concurrency and communication (Part 1).
Programming Languages and Compilers (CS 421)
Formal Methods in software development
Expressive Power of CCS
Presentation transcript:

Programming Paradigms for Concurrency Lecture 11 Part III – Message Passing Concurrency TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A A A A A AA A A

Formal Semantics for MP Programs: The ¼ -Calculus

The ¼ -Calculus developed by Milner, Parrow, and Walker in the early 1990’s as a generalization of value-passing CCS. provides computational model for concurrent and mobile systems many applications: formal models for – Message passing programs – Web services – Business Processes – Security protocols – Biological systems

Reading Material Introductory Reading: Communication and Mobile Systems: the ¼ - calculus. Milner, Cambridge University Press, 1999 Advanced Reading: The ¼ -calculus: a Theory of Mobile Processes. Sangiorigi and Walker, Cambridge University Press, A Calculus of Mobile Processes, Parts I and II. Milner, Parrow, and Walker, Information and Computation 100:1, 1992.

Ping Pong sender Msg Ping Pong Actors

Ping Pong Msg sender Msg

Ping Pong Actors Ping Pong sender Msg

Ping Pong Actors in Scala val pingTd = actor { loop { react { case Msg(sender) => sender ! Msg(self) } } val pongTd = actor { loop { react { case Msg(sender) => sender ! Msg(self) } } val initTd = actor { pongTd ! Msg(pingTd) } pingTd.start; pongTd.start; initTd.start

Ping Pong Actors in CML datatype msg = MSG of msg chan fun pongTd (pong : msg chan) = case recv pong of MSG(sender) => send (sender, MSG(pong)); pongTd (pong) end fun pingTd (ping : msg chan) = case recv ping of MSG(sender) => send (sender, MSG(ping)); pongTd (ping) end fun initTd (ping, pong) = send(pong, MSG(ping))

Ping Pong Actors in CML let val ping = channel () val pong = channel () in spawn (fn () => initTd(ping, pong)); spawn (fn () => pingTd(ping)); spawn (fn () => pongTd(pong)) end

Ping Pong Actors in the ¼ -calculus behavior of threads is defined by parametric equations of process IDs and process terms behavior of threads is defined by parametric equations of process IDs and process terms equations can be (mutually) recursive system is given by a process term referring to the defined process IDs

fun pongTd (pong : msg chan) = case recv pong of MSG(sender) => send (sender, MSG(pong)); pongTd (pong) end Ping Pong Actors in the ¼ -calculus receive channel on pong and bind it to sender receive channel on pong and bind it to sender

fun pongTd (pong : msg chan) = case recv pong of MSG(sender) => send (sender, MSG(pong)); pongTd (pong) end Ping Pong Actors in the ¼ -calculus send pong back on sender

fun pongTd (pong : msg chan) = case recv pong of MSG(sender) => send (sender, MSG(pong)); pongTd (pong) end Ping Pong Actors in the ¼ -calculus and recurse

let val ping = channel () val pong = channel () in spawn (fn () => initTd(ping, pong)); spawn (fn () => pongTd(pong)); spawn (fn () => pingTd(ping)) end Ping Pong Actors in the ¼ -calculus create two fresh private channels and bind them to ping and pong pronounced “new”

let val ping = channel () val pong = channel () in spawn (fn () => initTd(ping, pong)); spawn (fn () => pongTd(pong)); spawn (fn () => pingTd(ping)) end Ping Pong Actors in the ¼ -calculus spawn all threads

Ping Pong Actors in the ¼ -calculus

The ¼ -Calculus There exist many different variants of the ¼ - calculus using different notations and slightly different semantics. We use one particular variant and stick to it.

Names In the ¼ -calculus channels are called names. Names serve both as communication channels and as the data that is sent when threads synchronize. We assume an infinite set of names:

Syntax of Process Terms nil process (termination) parallel composition of P and Q nondeterministic choice between P and Q generation of fresh name x with scope P reception of y on x with continuation P sending of y on x with continuation P replication of P Notational conventions: restriction input prefix output prefix

Bound and Free Names Restriction and input prefix bind names in a process term. Occurrences of names in a process term that are not bound are called free. The function fn returns the set of free names of a process term: If fn ( P ) = ; then P is called closed.

® -Equivalence We consider process terms P and Q equivalent if they are equal up to consistent renaming of bound names (denoted by P ´ ® Q ) For example: Can we replace x with z ? But we have

Name Substitution We write P [ y / x ] for the process obtained from P by replacing all free occurrences of name x by name y. We call [ y / x ] a name substitution. Substitutions use implicit ® -renaming to avoid capturing of free occurrences of names. For instance: We write [ y 1,…, y n / x 1,…, x n ] for [ y 1 / x 1 ]…[ y n / x n ]

Labeled Transition System A labeled transition system (LTS) is a tuple M = h S, L, !, I i with S a nonempty set of states L a nonempty set of labels I µ S the set of initial states ! µ S £ L £ S the transition relation For a transition we write

Executions and Traces An execution ± of an LTS M = h S, L, !, I i is a sequence of consecutive transitions starting in an initial state s 0 2 I If ± is finite then its final state s f has no outgoing transitions. A trace ¾ is the projection of an execution to its labels We denote by Traces( M ) the set of all traces of M.

Semantics of Process Terms The semantics of a process term P is defined operationally by associating a labeled transition system M P with P. M P captures the behavior of P in all possible process contexts. the initial state of M P is P itself the states of M P are process terms describing the continuations of partial executions the transition relation is defined in terms of transition rules that capture synchronization between threads the labels of M P are actions that encode whether a process synchronizes internally or with the environment

Structural Congruence The behavior of two ® -equivalent processes P and Q should be indistinguishable, i.e., ´ ® should be a congruence for the transition relation: There are other such structural equivalences. For instance, one would expect that the following processes behave equally: P | Q and Q | P We capture all these cases in a structural congruence relation ´.

Structural Congruence Rules

Structural Congruence Rules (cont’d)

Structural Congruence Example

Actions Transitions of process terms are labeled with actions. Actions describe what kind of synchronization the process term performed. Actions:

Silent Action means P synchronizes internally resulting in Q Example:

Input Action means P can receive a w over x resulting in Q [ w / y ] Example:

Free Output Action means P can send the free (i.e., publicly known) name y over x to the environment, resulting in Q Example: note that there is also a silent action possible:

Bound Output Action means P can send the bound name y over x to the environment, resulting in Q (i.e., y is leaked to the environment and no longer private to P ) Example: again there is an alternative silent action possible:

Free and Bound Names of Actions We denote by n ( ® ), fn ( ® ), and bn ( ® ) the names, free names, and bound names of action ® :

Transition Rules

Transition Rules (cont’d)

Example Execution

Ping Pong Actors in the ¼ -calculus Can we express recursive equations in our calculus?

Polyadic ¼ -Calculus Multiple names can be communicated in one step

Monadic Encoding of Polyadic Calculus We can encode the polyadic calculus in the monadic one using serialization: for some fresh name z Why is the following encoding incorrect?

Encoding Recursive Equations Given a recursive definition of a process identifier A and a process term P that uses this definition. We can encode the behavior of A in P as follows: 1.choose a fresh name y not occuring in P or Q 2.let P y and Q y be P and Q, where each occurrence of process identifier A is replaced by 3.replace P by

Monadic Ping Pong Actors

Outlook: Behavioral Equivalence PongTd ( x ) and PingTd ( x ) are ® -equivalent for all names x, so we can safely replace one by the other in any context. Next week: In general, when can we safely replace one process term by another one? They should surely have the same set of traces, but is that enough?