Types and Programming Languages Lecture 16 Simon Gay Department of Computing Science University of Glasgow 2006/07.

Slides:



Advertisements
Similar presentations
Types and Programming Languages Lecture 13 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Advertisements

Types and Programming Languages Lecture 15 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Types and Programming Languages Lecture 7 Simon Gay Department of Computing Science University of Glasgow 2006/07.
COMMUNICATING SEQUENTIAL PROCESSES C. A. R. Hoare The Queen’s University Belfast, North Ireland.
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Formal Semantics of Programming Languages 虞慧群 Topic 6: Advanced Issues.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Programming Paradigms for Concurrency Lecture 11 Part III – Message Passing Concurrency TexPoint fonts used in EMF. Read the TexPoint manual before you.
Principles of programming languages 4: Parameter passing, Scope rules Department of Information Science and Engineering Isao Sasano.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 11: An introduction to CSP.
Course on Probabilistic Methods in Concurrency (Concurrent Languages for Probabilistic Asynchronous Communication) Lecture 1 The pi-calculus and the asynchronous.
Catriel Beeri Pls/Winter 2004/5 functional-language 1 Substitution Semantics of FL – a simple functional language FL is EL + (non-recursive) function creation.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
1 Ivan Lanese Computer Science Department University of Bologna Roberto Bruni Computer Science Department University of Pisa A mobile calculus with parametric.
Concurrency CS 510: Programming Languages David Walker.
1 Ivan Lanese Computer Science Department University of Bologna Italy Behavioural Theory for SSCC Joint work with Luis Cruz-Filipe, Francisco Martins,
1212 Models of Computation: Automata and Processes Jos Baeten.
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.
Lesson 1: Generating Equivalent Expressions
Ch 4.3 Transversals and Corresponding Angles
Concept.
Equivalent Fractions Equivalent Fractions Using Cross-Multiplication.
Advances in Language Design
Board Race/Splat December 5, Choose the best answer that uses the distributive property to rewrite the following expression. 7(y + z) A.7y + z.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
A Theory of Hygienic Macros David Herman, Mitchell Wand Northeastern University.
CS5204 – Operating Systems 1  -Calculus Reasoning about concurrency and communication (Part 1).
GOAL: MULTIPLY TWO POLYNOMIALS TOGETHER USING THE DISTRIBUTIVE PROPERTY ELIGIBLE CONTENT: A Multiplying Polynomials.
Simple Factoring Objective: Find the greatest common factor in and factor polynomials.
Hop Operational Semantics
SCHEME Scheme is elegant, clear, small, and powerful programming language. It is a dialect of LISP and can be classified as a semi-functional programming.
CS 603: Programming Languages Lecture 25 Spring 2004 Department of Computer Science University of Alabama Joel Jones.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Types and Programming Languages Lecture 6 Simon Gay Department of Computing Science University of Glasgow 2006/07.
1 Formal Semantics. 2 Why formalize? ML is tricky, particularly in corner cases generalizable type variables? polymorphic references? exceptions? Some.
Principles of programming languages 9: Lambda calculus Isao Sasano Department of Information Science and Engineering.
12/2/20151 GC16/3011 Functional Programming Lecture 2 The Lambda Calculus: A Simple Introduction.
CSE-321 Programming Languages -Calculus (II) POSTECH March 27, 2006 박성우.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Just Enough Type Theory or, Featherweight Java A Simple Formal Model of Objects Jonathan Aldrich
Types and Programming Languages Lecture 11 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Concurrency 5 The theory of CCS Specifications and Verification Expressive Power Catuscia Palamidessi
Types and Programming Languages
1 Programming Languages (CS 550) Lecture 2 Summary Mini Language Interpreter Jeremy R. Johnson.
Types and Programming Languages Lecture 14 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Types and Programming Languages Lecture 10 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L04Ext-1 September 21, 2006http:// Some more thoughts.
CSE-321 Programming Languages -Calculus (II) POSTECH March 26, 2007 박성우.
CSE-321 Programming Languages Abstract Machine E POSTECH May 1, 2006 박성우.
Splash Screen. Then/Now You named angle pairs formed by parallel lines and transversals. Use theorems to determine the relationships between specific.
1 Theoretical Foundations of Concurrency A formal study of concurrency enables: understanding the essential nature of concurrency reasoning about the behavior.
Aims: To understand what a polynomial is To be able to add and subtract polynomials To be able to multiply polynomials Polynomials/Factorisation Lesson.
LESSON 3-2 ANGLES AND PARALLEL LINES. Concept Example 1 Use Corresponding Angles Postulate A. In the figure, m  11 = 51. Find m  15.
1 Math I can create equivalent expressions. By Combining Like Terms 1.
Distributive Property, Combining Like Terms (1-4) Objective: Use the Distributive Property to evaluate and simplify expressions. Combine like terms.
6/21/20161 Programming Languages and Compilers (CS 421) Reza Zamani Based in part on slides by Mattox Beckman,
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Representation, Syntax, Paradigms, Types
Principles of programming languages 4: Parameter passing, Scope rules
CS 611: Lecture 9 More Lambda Calculus: Recursion, Scope, and Substitution September 17, 1999 Cornell University Computer Science Department Andrew Myers.
Mini Language Interpreter Programming Languages (CS 550)
Programming Languages and Compilers (CS 421)
Representation, Syntax, Paradigms, Types
Announcements Quiz 6 HW7 due Tuesday, October 30
Representation, Syntax, Paradigms, Types
Theory of Computation Lecture #
Representation, Syntax, Paradigms, Types
CSE S. Tanimoto Lambda Calculus
Presentation transcript:

Types and Programming Languages Lecture 16 Simon Gay Department of Computing Science University of Glasgow 2006/07

Types and Programming Languages Lecture 16 - Simon Gay2 Beyond Sequential Programming To illustrate that static type systems can be of use in other contexts, we will move on from sequential programming and look at two areas: concurrent programming and security. First, concurrent programming. There are many ways of formulating concurrent programming. We will look at the pi calculus (  calculus), which is a core concurrent programming language with the following distinctive features: Point-to-point communication between concurrent processes. Channels as first class values. Dynamic creation of channels.

2006/07Types and Programming Languages Lecture 16 - Simon Gay3 Pi Calculus Syntax The syntax of processes is defined by this grammar: P ::= stopinactive process | out x(e,...,f)asynchronous output | inp x(y,...,z);Pinput (y,...,z bound with scope P) | new(x);Pchannel creation (x is bound with scope P) | P | Pparallel | repeat Preplication x,y stand for channel names or variables (no need to distinguish) e stands for an expression of SEL (say), so that we have some values and operations (this is useful for examples, although it is possible to encode all computation by means of channels)

2006/07Types and Programming Languages Lecture 16 - Simon Gay4 Example: Simple Messages (out a(1) | inp b(x); P(x) ) | (inp a(y); out b(y+1) ) (inp b(x); P(x) ) | out b(1+1) P(2) Abbreviation: write out x(e,...,e); P for out x(e,...,e) | P

2006/07Types and Programming Languages Lecture 16 - Simon Gay5 Example: Client/Server Server = repeat inp a(x); inp x(y); out x(y+1) Client1 = new (c); out a(c); out c(2); inp c(x); C(x) Client2 = new (d); out a(d); out d(3); inp d(x); D(x) Server | Client1 | Client2 repeat (inp a(x); inp x(y); out x(y+1)) | new (c); out a(c); out c(2); inp c(x); C(x) | new (d); out a(d); out d(3); inp d(x); D(x) repeat (inp a(x); inp x(y); out x(y+1)) | inp a(x); inp x(y); out x(y+1) | new (c); out a(c); out c(2); inp c(x); C(x) | new (d); out a(d); out d(3); inp d(x); D(x)

2006/07Types and Programming Languages Lecture 16 - Simon Gay6 Example: Client/Server repeat (inp a(x); inp x(y); out x(y+1)) | inp a(x); inp x(y); out x(y+1) | new (c); out a(c); out c(2); inp c(x); C(x) | new (d); out a(d); out d(3); inp d(x); D(x) inp c(y); out c(y+1) | out c(2); inp c(x); C(x) (several steps) C(3) repeat (inp a(x); inp x(y); out x(y+1)) | inp a(x); inp x(y); out x(y+1) | new (d); out a(d); out d(3); inp d(x); D(x) | inp c(y);... | out c(2);... reducing inp d(y); out d(y+1) | out d(3); inp d(x); D(x) (several steps) D(4)

2006/07Types and Programming Languages Lecture 16 - Simon Gay7 Client/Server: Structure Server (replicated thread) a Client1Client2 Client 1 creates channel c, Server spawns a thread Server thread Client1 c Server (replicated thread) a Client2 Server thread Client1 c Server thread Client2 d

2006/07Types and Programming Languages Lecture 16 - Simon Gay8 The Reduction Relation The reduction relation on processes is defined by a few rules: (R-Comm) Values v are channel names or values of SEL. P[v/y,...] is capture-avoiding substitution (rename bound vars if necessary) (R-Par)(R-New) Reduction takes place within parallel combinations and within the scope of new, but not within an input.

2006/07Types and Programming Languages Lecture 16 - Simon Gay9 Structural Equivalence To factor out inessential aspects of the way processes are written, introduce the structural equivalence relation. (E-Refl) (E-Symm)(E-Trans) Freely rearrange parallel processes: (E-Com)(E-Assoc) Garbage collection: (E-ParStop)(E-NewStop)

2006/07Types and Programming Languages Lecture 16 - Simon Gay10 Structural Equivalence Order of channel creation: (E-NewNew) Scope expansion: (E-NewPar) fn(P) is the set of free names in P Replication: (E-RepPar)

2006/07Types and Programming Languages Lecture 16 - Simon Gay11 Structural Equivalence The following rules make structural equivalence into a congruence: equivalence is preserved by all the syntactic constructions. So we refer to structural congruence. (E-Inp)(E-New) (E-Par)(E-Rep)

2006/07Types and Programming Languages Lecture 16 - Simon Gay12 Structural Equivalence and Reduction Finally we add a rule which makes the connection between structural equivalence and the reduction relation. (R-Struct) This allows structural equivalence to be used to rewrite a process before or after a reduction step. Structural equivalence allows us to rewrite until an output and a matching input are adjacent; then (R-Comm) gives us a reduction, often inside a parallel collection of processes (using rule (R-Par)) or within the scope of a new channel (using rule (R-New)).

2006/07Types and Programming Languages Lecture 16 - Simon Gay13 Example: Client/Server repeat (inp a(x); inp x(y); out x(y+1)) | new (c); out a(c); out c(2); inp c(x); C(x) Server | Client1 =  inp a(x); inp x(y); out x(y+1) | repeat (inp a(x); inp x(y); out x(y+1)) | new (c); out a(c); out c(2); inp c(x); C(x) (E-Rep) (E-Com)  repeat (inp a(x); inp x(y); out x(y+1)) | inp a(x); inp x(y); out x(y+1) | new (c); out a(c); out c(2); inp c(x); C(x)

2006/07Types and Programming Languages Lecture 16 - Simon Gay14 Example: Client/Server (E-NewPar)  repeat (inp a(x); inp x(y); out x(y+1)) | new (c); (inp a(x); inp x(y); out x(y+1) | out a(c); out c(2); inp c(x); C(x)) repeat (inp a(x); inp x(y); out x(y+1)) | new (c); (inp c(y); out c(y+1) | out c(2); inp c(x); C(x)) R-Comm, R-New, R-Par repeat (inp a(x); inp x(y); out x(y+1)) | new (c); (out c(2+1) | inp c(x); C(x)) R-Comm, R-New, R-Par

2006/07Types and Programming Languages Lecture 16 - Simon Gay15 Example: Client/Server repeat (inp a(x); inp x(y); out x(y+1)) | new (c); (out c(3) | inp c(x); C(x)) reductions in SEL repeat (inp a(x); inp x(y); out x(y+1)) | new (c); C(3) R-Comm, R-New, R-Par  (if c  fn(C)) repeat (inp a(x); inp x(y); out x(y+1)) | C(3)

2006/07Types and Programming Languages Lecture 16 - Simon Gay16 Exercise One of the reductions in the example is labelled “reductions in SEL”. How should we formally include reductions in SEL into the definition of reductions in pi calculus?

2006/07Types and Programming Languages Lecture 16 - Simon Gay17 Facts about Pi Calculus Even without including SEL (so we just have channel names and pure communication), pi calculus is able to express all computation. Data can be represented by the use of channels. Recursive process definitions can be encoded by using replication (repeat). Theories of behavioural equivalence can be developed, supporting reasoning about correctness of systems. Numerous variations of pi calculus exist, including concepts such as locations and distribution, failure of processes or locations, time, …