Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close

Similar documents
Official Survey. Cunning Plan: Focus On Objects. The Need for a Calculus. Object Calculi Summary. Why Not Use λ-calculus for OO?

Symmetry in Type Theory

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

COS 320. Compiling Techniques

Harvard School of Engineering and Applied Sciences Computer Science 152

The Polymorphic Blame Calculus and Parametricity

(Refer Slide Time: 4:00)

Dependent Object Types - A foundation for Scala s type system

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy

Calculus of Inductive Constructions

Tracing Ambiguity in GADT Type Inference

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE

Gradual Parametricity, Revisited

Tradeoffs. CSE 505: Programming Languages. Lecture 15 Subtyping. Where shall we add useful completeness? Where shall we add completeness?

l e t print_name r = p r i n t _ e n d l i n e ( Name : ^ r. name)

The Typed λ Calculus and Type Inferencing in ML

Lexicografie computationala Feb., 2012

Programming Languages

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17

CLF: A logical framework for concurrent systems

A Canonical 1 Locally Named Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh

Ideas over terms generalization in Coq

Distributed Systems Programming (F21DS1) Formal Verification

7. Introduction to Denotational Semantics. Oscar Nierstrasz

Implementing Interfaces. Marwan Burelle. July 20, 2012

Functional Logic Programming: From Theory to Curry

Chapter 10 Classes Continued. Fundamentals of Java

Verifying Program Invariants with Refinement Types

Let Arguments Go First

Compilers and computer architecture: Semantic analysis

Lambda Calculus. Variables and Functions. cs3723 1

Introduction. chapter Functions

CSE-321 Programming Languages 2011 Final

Formal Systems and their Applications

Lecture Outline. Type systems and their expressiveness. Type Checking in COOL (II) Type checking with SELF_TYPE in COOL

Lists. Michael P. Fourman. February 2, 2010

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

Applications of Program analysis in Model-Based Design

Type Systems COMP 311 Rice University Houston, Texas

Com S 541. Programming Languages I

Object-Oriented Concepts and Design Principles

CS 540: Introduction to Artificial Intelligence

Lambda Calculi With Polymorphism

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Simplifying and Improving Qualified Types

Lecture slides & distribution files:

Pierce Ch. 3, 8, 11, 15. Type Systems

Let Arguments Go First

Inheritance and Overloading in Agda

1: Introduction to Object (1)

JOURNAL OF OBJECT TECHNOLOGY

Introduction to System F. Lecture 18 CS 565 4/20/09

Applying Machine Learning to Real Problems: Why is it Difficult? How Research Can Help?

What s different about Factor?

Context-free Grammars

From Types to Sets in Isabelle/HOL

Programming Languages Assignment #7

CS-XXX: Graduate Programming Languages. Lecture 23 Types for OOP; Static Overloading and Multimethods. Dan Grossman 2012

6.001 Notes: Section 4.1

CS 151 Complexity Theory Spring Final Solutions. L i NL i NC 2i P.

Once Upon a Polymorphic Type

Recursive Types and Subtyping

Some Applications of Graph Bandwidth to Constraint Satisfaction Problems

COMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland

Type Inference with Inequalities

Visitors Unchained. Using visitors to traverse abstract syntax with binding. François Pottier. Inria Paris May 22, 2017

Math 5320, 3/28/18 Worksheet 26: Ruler and compass constructions. 1. Use your ruler and compass to construct a line perpendicular to the line below:

HIGHER-ORDER ABSTRACT SYNTAX IN TYPE THEORY

CSE 505: Concepts of Programming Languages

Object-Oriented Systems Analysis and Design Using UML

Object-oriented Programming. Object-oriented Programming

the application rule M : x:a: B N : A M N : (x:a: B) N and the reduction rule (x: A: B) N! Bfx := Ng. Their algorithm is not fully satisfactory in the

The 10 Minute Guide to Object Oriented Programming

Goal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler.

λ calculus is inconsistent

Combined Modeling and Programming with State Machines

On the Relevance of Programming Language Theory

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

6.001 Notes: Section 6.1

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

Pure (Untyped) λ-calculus. Andrey Kruglyak, 2010

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

COMP 382: Reasoning about algorithms

INF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes

AADL Graphical Editor Design

A CALCULUS WITH LAZY MODULE OPERATORS

System Description: Twelf A Meta-Logical Framework for Deductive Systems

Continuations provide a novel way to suspend and reexecute

1. Write two major differences between Object-oriented programming and procedural programming?

Intro to: Design Principles

Type checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39

Part III Chapter 15: Subtyping

Simply-Typed Lambda Calculus

Programming Language Concepts: Lecture 19

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53

Week. Lecture Topic day (including assignment/test) 1 st 1 st Introduction to Module 1 st. Practical

Type Checking in COOL (II) Lecture 10

Meta-programming with Names and Necessity p.1

Transcription:

Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close Henning Makholm and Joe Wells Heriot-Watt University ESOP 05 April 8, 2005 Work supported by EU/IST/FET grant 2001-33477 (DART) Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.1/29

Mobile process calculi Mobility and process calculi are used to model and reason about systems with mobile devices, mobile code, dynamically changing networks,... and to model biological systems and business processes. Many such calculi exist: The π-calculus and variants Mobile Ambients and variants Safe Ambients, Boxed Ambients, Seal and variants Dπ, Higher-order π-calculus and variants Join calculus and variants There is no obvious best calculus. For different purposes one may need different calculi, and needs are likely to change. Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.2/29

Types for process calculi Any process and mobility calculus can benefit from having a type system. For pinpointing programming errors To prove that programs or systems are safe To provide flow information for automatic analyses Traditionally each new calculus has a type system designed specifically for it. We present the re-targetable type system Poly which automatically adapts to new calculi or variants. Allows easy experimentation with calculus variants Just write down your reduction rules. Poly does the rest. Experimenting with type system features: Which features do I need to handle this kind of code? Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.3/29

Poly example Plan Case study: Evolution of calculi Spatial polymorphism Theoretical properties Conclusion Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.4/29

An example Poly type for an ambient term Term: (x). b in x.0 a.0 a b0 b in a.0 a b0 a b0 b 0 Type: (x) b[] in x x:={a} x:={a} ROOT <{a}> x:={a} b[] in a a[] b[] Black edges with labels define the possible term structure. Red edges encode flow, which is the same as subtyping. Green edges encode flow/subtyping with substitutions. Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.5/29

Drawing the type graph more compactly (x) b[] in x x:={a} x:={a} ROOT <{a}> x:={a} b[] in a a[] b[] When all black edges leading to a node have the same label, we write the label inside the target node: (x) b[] in x ROOT <{a}> x:={a} b[] x:={a} x:={a} a[] b[] in a Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.6/29

Poly example Plan Case study: Evolution of calculi Spatial polymorphism Theoretical properties Conclusion Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.7/29

R ewriting, and their The siege of Troy Term: horse in Troy Ulysses in horse.out horse Troy 0 Input to Poly type inference tool:! " Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.8/29

The siege of Troy Term: horse in Troy Ulysses in horse.out horse Troy 0 Inferred type: Troy[] horse[] Ulysses[] ROOT horse[] in Troy in horse out horse Ulysses[] Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.9/29

R ewriting, and their Safe Ambients, first try What if one needed permission to enter and exit ambients?! " Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.10/29

Safe Ambients, first try What if one needed permission to enter and exit ambients? Inferred type: co-in Troy Ulysses[] Troy[] horse[] co-in horse in horse out horse ROOT horse[] in Troy Ulysses[] Hmm. This seems to work. Or does it? Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.11/29

R ewriting, and their The first try did not work Unfortunately, Ulysses is rather clever. If the horse can use the co-in Troy, then so can he.! " Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.12/29

The first try did not work Unfortunately, Ulysses is rather clever. If the horse can use the co-in Troy, then so can he. Inferred type: Ulysses[] Troy[] co-in Troy horse[] Ulysses[] co-in horse ROOT horse[] in Troy in horse out horse Ulysses[] in Troy Ulysses[] Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.13/29

R ewriting, and their Modern Safe Ambients It would be better if the permissions say who can enter instead of where the permission itself is located.!! " Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.14/29

Modern Safe Ambients It would be better if the permissions say who can enter instead of where the permission itself is located. Inferred type: horse[] in Troy Troy[] co-in horse co-in Ulysses ROOT horse[] Ulysses[] in Troy Ulysses[] in horse out horse This works! Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.15/29

Poly example Plan Case study: Evolution of calculi Spatial polymorphism Theoretical properties Conclusion Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.16/29

Spatial polymorphism The core of Poly descends from earlier work on PolyA for Mobile Ambients [Amtoft, Makholm, Wells]. It inherits the notion of spatial polymorphism: A single process can have multiple future type descriptions, depending on where it moves. Example. Consider the Boxed Ambients term b c a x y in b in c in a.in y. out q in a.(m) x.out m If x and y were to enter a simultaneously, out q and (m) x.out m would communicate, causing a run-time error. This term s Poly type verifies this does not happen. Spatial polymorphism allows a type to express that a can contain x when found inside one b, or y when found inside the other, but never both. Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.17/29

R ewriting, and their Spatial polymorphism example Term: a in b in c b xin a.in y. out q c y in a.(m) x.out m Input to type inference tool: (4 other communication rules go here) Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.18/29

Spatial polymorphism example Term: a in b in c b x in a.in y. out q c y in a.(m) x.out m Inferred type: y[] y[] in a (m)^x out m c[] a[] in c ROOT a[] in b b[] a[] in a in y <out q> x[] x[] Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.19/29

R ewriting, and their Turning off spatial polymorphism Input to type inference tool: (4 other communication rules go here) Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.20/29

Turning off spatial polymorphism Inferred type: x[] in a in y ROOT b[] a[] in b m:=out q <out q> c[] in c (m)^x out m y[] in a out(!!!) The form out (!!!) in the red circle (which would be out in the paper s notation) indicates that Poly has detected a possible run-time error, namely an ill-formed substitution result. Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.21/29

History polymorphism History polymorphism allows having multiple type descriptions for possible processes at a location, depending on where they came from. History polymorphism is built on top of spatial polymorphism using origin marks. Unfortunately we don t have time to describe it now. Feel free to ask us after the session for a demonstration! Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.22/29

Poly example Plan Case study: Evolution of calculi Spatial polymorphism Theoretical properties Conclusion Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.23/29

The metacalculus Meta A single syntax that allows one to write process terms from many concrete calculi. Processes: P, Q ::= (P Q) 0!P ν(x).p F.P Forms: F ::= E 1 E 2... E k Elements: E ::= x (x 1,..., x k ) <M 1,..., M k > Messages: M ::= 0 F 1..F k Key concept: the form F. Examples: in Troy, open x, out a.in b, k, c(z), a[], q. Where are keywords? E.g., in or out? They are names. Punctuation? out a.in b, k. Ambients? Sugar E[P] E[].P Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.24/29

The usual nice properties of types Straightforward subject reduction result holds for a large class of closed type graphs. In a narrower class, defined by width and depth restrictions, principal typings exist: Each process term has a best type that is a stronger predicate on terms than any of its other types. Our type inference algorithm infers principal typings. Typing derivations are easily checkable by purely local rules. It may be difficult to compute a type, but it is easy to check whether a purported type is good for a term. In contrast, for non-type-based program analyses, validating analysis results typically costs as much as computing them from scratch. All properties also hold for interesting restrictions that give smaller types or faster inference. Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.25/29

Answers to common questions This seems more like program analysis than types. Answer: There is no clean division between type systems and other forms of program analysis. Types must become more detailed to obtain principal typings. The types seem large compared to the terms they describe. Answer: Our examples show the most precise version of our system. Our system can be fine-tuned to trade space for expressive strength. There are versions of our system with smaller types that are as crude as previous type systems. More questions and answers are at http://www.macs.hw.ac.uk/dart/software/polystar/faq (or Google for PolyStar type inference FAQ ). Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.26/29

Poly example Plan Case study: Evolution of calculi Spatial polymorphism Theoretical properties Conclusion Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.27/29

Lift restrictions on calculi Future work Eliminate current invariant: Names bound by forms never need to be α-renamed. Reduction rules that risk breaking this (by moving binders into each other) are rejected by the system. Allow more structured messages than just names and flat forms. (This would allow spi-calculus). Make type-system core stronger Add some form of single-threadedness tracking. Incorporate the form of polymorphism commonly used for the π-calculus. (c(x).ν(k). ) Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.28/29

Conclusion The metacalculus Meta can be instantiated to many proposed process calculi The type system Poly applies to each instantiation...... and provides spatial polymorphism (or not)... and history polymorphism (or not) The strength of Poly is adjustable in many orthogonal dimensions. A very flexible implementation of type inference is available: http://www.macs.hw.ac.uk/dart/software/polystar/ (or http://henning.makholm.net/ software Poly ) Thank you Instant Polymorphic Type Systems for Mobile Process Calculi: Just Add Reduction Rules and Close p.29/29