The Mezzo case. Jonathan Protzenko. François Pottier FSFMA'13. Why design a new programming language?

Size: px
Start display at page:

Download "The Mezzo case. Jonathan Protzenko. François Pottier FSFMA'13. Why design a new programming language?"

Transcription

1 Why design a new programming language? The Mezzo case François Pottier francois.pottier@inria.fr Jonathan Protzenko jonathan.protzenko@inria.fr INRIA FSFMA'13 Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 1 / 43

2 6. Conclusion Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 1 / 43 Plan. Some background 1. Some background 2. Going beyond type-checking 3. The story about state 4. Designing a type system with state 5. A glimpse of Mezzo

3 Type-checking: a way to reason about your programs

4 Some background How do we see type-checking? a way of assigning types to objects, thus gaining static information about the memory shape of objects, while enabling the programmer to reason about their programs. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 3 / 43

5 These properties are static. You can deduce them by analyzing your program before running it.

6 Some background How do we sell type-checking? The ability for the programmer to avoid bugs. The ability for the compiler to emit better code. Guarantees about safety (e.g. the program won't crash): C#, ML, Java Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 5 / 43

7 Type-checking occupies a sweet spot in our landscape.

8 Some background Why do we love typing so much? Requires no user input; the system can automatically deduce properties. Good properties: decidable, reasonable computational complexity. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 7 / 43

9 6. Conclusion Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 7 / 43 Plan. Going beyond type-checking 1. Some background 2. Going beyond type-checking 3. The story about state 4. Designing a type system with state 5. A glimpse of Mezzo

10 Going beyond type-checking How does one push a type system further? extend type-check more programs; refine provide stronger guarantees about programs. Here are some directions that have been explored already. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 8 / 43

11 Going beyond type-checking Direction #1: the proof assistant One may want to extend the theoretical power of the type system; and lose automation; the user has to painfully write types by hand; these types are actually proofs. Example:. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 9 / 43

12 Going beyond type-checking Direction #2: automated theorem provers One may want to keep a simple type system; have a language of pre- and post-conditions on the side; delegate the task of proving to SMT-solvers; only semi-automated; SMT-solvers are unpredictable and not very robust. Example:. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 10 / 43

13 Going beyond type-checking Direction #3: Abstract interpretation One may want to design a framework to analyze the range of possible values; either in compilers (flags) or external tools (static analyzers). Example: the Astrée static analyzer.. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 11 / 43

14 There's a whole range of possible directions. There are some design choices that we do not wish to reproduce. What's our «business model»? Refine the type system of ML to talk about state.

15 6. Conclusion Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 12 / 43 Plan. The story about state 1. Some background 2. Going beyond type-checking 3. The story about state 4. Designing a type system with state 5. A glimpse of Mezzo

16 The story about state A pervasive notion Most programs carry an inherent notion of state. A socket may move from «valid socket» to «invalid socket». Yet, no mainstream type system offers facilities for reasoning about state. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 13 / 43

17 The story about state Reasoning about state let x = create_socket () in (* socket (valid) *) let y = x in (* socket (valid), socket (valid) *)... (* socket (valid), socket (valid) *) destroy_socket x; (* socket (invalid), socket (valid) *) destroy_socket y; (* apocalypse! *) Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 14 / 43

18 The story about state Reasoning about state is hard Are x and y the same thing? This is the aliasing problem, which is not decidable in general. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 15 / 43

19 Question The story about state Can we design a better type system that would: help the programmer reason about state, thus ruling out incorrect behaviors, while enabling new programming idioms? This is the Mezzo project. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 16 / 43

20 6. Conclusion Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 16 / 43 Plan. Designing a type system with state 1. Some background 2. Going beyond type-checking 3. The story about state 4. Designing a type system with state 5. A glimpse of Mezzo

21 Permissions Designing a type system with state A variable does not have a fixed type. Instead, we may possess a permission t, allowing us to use x in certain ways, depending on t. This permission may disappear, to be replaced by a different one. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 17 / 43

22 Designing a type system with state Immutable vs. mutable The system maintains the following invariant: if x is a mutable object, there exists at most one permission to read and write x if x is an immutable object, there exists arbitrarily many permissions to read x Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 18 / 43

23 Designing a type system with state Why the distinction? This distinction is central in the design of Mezzo. State changes become type changes. Since mutable objects have a unique owner, it is now safe for the type of an object to change. This enables us to track the state of objects. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 19 / 43

24 Designing a type system with state Why the distinction? In a concurrent context, the unique-owner property statically guarantees that the program is data-race free. In terms of reasoning, I can now state that no other part of the program may access my mutable memory. This is a separation property. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 20 / 43

25 6. Conclusion Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 20 / 43 Plan. A glimpse of Mezzo 1. Some background 2. Going beyond type-checking 3. The story about state 4. Designing a type system with state 5. A glimpse of Mezzo

26 A simple example: concatenation of immutable lists.

27 xs Cons head tail Cons head tail... Cons head tail Nil x₁ x₂ xₙ ys Cons head tail Cons head tail... Cons head tail Nil y₁ y₂ yₙ

28 What happens when one concatenates two immutable lists xs and ys?

29 zs Cons head tail Cons head tail... Cons head tail ys Cons head tail Cons head tail... Cons head tail Nil xs x₁ x₂ xₙ y₁ y₂ yₙ Cons head tail Cons head tail... Cons head tail Nil

30 This creates sharing.

31 A glimpse of Mezzo Harmless sharing let xs : list int =... in let ys : list int =... in let zs : list int = append(xs, ys) in... This is harmless. We would like to accept this code. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 26 / 43

32 A glimpse of Mezzo Potentially harmful sharing What if the lists have mutable elements? let xs : list (ref int) =... in let ys : list (ref int) =... in let zs : list (ref int) = append(xs, ys) in... Some elements are accessible via xs and zs, or via ys and zs. This is potentially dangerous. We would like to accept this code yet prevent the programmer from using (say) xs and zs as if they were physically disjoint. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 27 / 43

33 A glimpse of Mezzo Reasoning with permissions In Mezzo, the first code snippet gives rise to three permissions: list int list int list int All three lists can be freely used in the code that follows. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 28 / 43

34 A glimpse of Mezzo Reasoning with permissions The first two lines of the second code snippet give rise to: list (ref int) list (ref int) These permissions are consumed at line three, which gives rise to: list (ref int) At the end, zs can be used, but xs and ys have been invalidated. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 29 / 43

35 A glimpse of Mezzo How does this work? The type of the function append is: [a] (consumes list a, consumes list a) -> list a so a call is in principle type-checked as follows: (* list t * list t *... must exist here *) let zs = append(xs, ys) in (* list t *... exist here *) The available permissions vary with time. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 30 / 43

36 A glimpse of Mezzo How does this work? The system knows that list int is a duplicable permission, whereas list (ref int) is not: it is an affine permission. A caller of append can give up one copy of list int and keep one copy. The permission is effectively not consumed. No such trick is possible with list (ref int). Thus, append is type-checked once, but behaves differently at different call sites. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 31 / 43

37 A glimpse of Mezzo Still how do we type-check this? let x = create_socket () in (*? *) let y = x in (*? *)... (*? *) destroy_socket x; (*? *) destroy_socket y; (*? *) Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 32 / 43

38 A glimpse of Mezzo Still how do we type-check this?. let x = create_socket () in (*? *) let y = xkeep in track of local aliasing relationships. (*? *) Declare types valid_socket and... invalid_socket (*? *) destroy_socket Declare x; destroy_socket: (consumes x: (*? *) valid_socket) -> ( invalid_socket) destroy_socket y; (*? *) Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 32 / 43

39 A glimpse of Mezzo Still how do we type-check this? let x = create_socket () in (* valid_socket *) let y = x in (* valid_socket * =y *)... (* valid_socket * =y *) destroy_socket x; (* invalid_socket * =y *) destroy_socket y; (* Error: could not find permission valid_socket; the only permissions available for it are: invalid_socket *) Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 33 / 43

40 A glimpse of Mezzo An escape mechanism The mechanisms presented so far remain relatively rigid. We offer a mechanism, called adoption/abandon, that: allows one to gain the freedom to alias objects, at the expense of paying runtime checks whenever they want to use the object. The runtime checks guarantee that only one person owns the object. If the programmer makes a mistake, the program aborts. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 34 / 43

41 A glimpse of Mezzo An escape mechanism (2) All type systems are a tradeoff between complexity and dynamic checks (Java, C++, C# ). We drew a line: non-tree-shaped ownership patterns cannot be treated statically. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 35 / 43

42 6. Conclusion Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 35 / 43 Plan. Conclusion 1. Some background 2. Going beyond type-checking 3. The story about state 4. Designing a type system with state 5. A glimpse of Mezzo

43 Conclusion The Mezzo language Mezzo is a language that: takes the usual ingredients of a type system, but provides stronger guarantees, while still retaining some key properties: automated reasoning, predictability This is achieved through a careful blending of runtime tests / static guarantees. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 36 / 43

44 Conclusion The Mezzo language Programs written in Mezzo enjoy strong guarantees: the type system rules out representation exposure; avoids unwanted sharing; guarantees data-race freedom. Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 37 / 43

45 Conclusion The Mezzo language We also believe that: writing a program in Mezzo force the programmer to have a clear understanding of ownership, thus giving better guarantees about the program, as well as making it more amenable to program proof (long-term goal). Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 38 / 43

46 Conclusion The state of Mezzo The type system has been proved sound using the Coq proof assistant. We have a prototype type-checker that successfully type-checks our library as well as numerous examples (several thousand lines). Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 39 / 43

47 Conclusion Future direction #1 Concurrency. There are several concurrency patterns. How can we axiomatize them? (What is their type?) Is it sound? (Can we add these to our proof?) Shall we add new concurrency patterns in Mezzo? Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 40 / 43

48 Conclusion Future direction #2 Inference. Inference is a challenge; we want to limit manual intervention from the programmer, but: some situations require type annotations; can we predict which situations will require manual hints? can we improve our prototype with a better type-checking algorithm? Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 41 / 43

49 Conclusion Future direction #3 Arithmetic. Like in ML, there are bounds-check on array accesses. Can we extend the permission mechanism to also talk about arithmetic? Can we have the type-checker perform arithmetic reasoning? (SMT-Solver) How viable is this approach, can we extend it beyond arithmetic? Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 42 / 43

50 Conclusion More information You can visit the Mezzo website F. Pottier and J. Protzenko, Programming with permissions in Mezzo, to appear in International Conference on Functional Programming (ICFP), Sep Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 43 / 43

51 Conclusion The implementation of append data list a = Nil Cons { head: a; tail: list a } val rec append [a] ( consumes xs: list a, consumes ys: list a ) : list a = if xs then Cons { head = xs.head; tail = append (xs.tail, ys) } else ys Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 43 / 43

52 Conclusion The (other) implementation of append data mutable cell a = Cell { head: a; tail: () } Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 43 / 43

53 Conclusion The (other) implementation of append val rec appendaux [a] ( consumes dst: cell a, consumes xs: list a, consumes ys: list a) : ( list a) = if xs then begin let dst' = Cell { head = xs.head; tail = () } in freeze (dst, dst'); appendaux (dst', xs.tail, ys) end else freeze (dst, ys) Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 43 / 43

54 Conclusion The (other) implementation of append val append [a] ( consumes xs: list a, consumes ys: list a ) : list a = if xs then begin let dst = Cell { head = xs.head; tail = () } in appendaux (dst, xs.tail, ys); dst end else ys Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 43 / 43

55 Conclusion The implementation of append (mutable) data mutable mlist a = MNil MCons { head: a; tail: mlist a } Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 43 / 43

56 Conclusion The implementation of append (mutable) val rec append1 [a] (xs: MCons { head: a; tail: mlist a }, consumes ys: mlist a) : () = match xs.tail with MNil -> xs.tail <- ys MCons -> append1 (xs.tail, ys) end val append [a] (consumes xs: mlist a, consumes ys: mlist a) : mlist a = match xs with MNil -> ys MCons -> append1 (xs, ys); xs end Jonathan Protzenko (INRIA) The Mezzo language FSFMA'13 43 / 43

Type Soundness and Race Freedom for Mezzo

Type Soundness and Race Freedom for Mezzo Type Soundness and Race Freedom for Mezzo Thibaut Balabonski François Pottier Jonathan Protzenko INRIA FLOPS 2014 1 / 42 Mezzo in a few words Mezzo is a high-level programming language, equipped with:

More information

Jonathan Protzenko (INRIA)

Jonathan Protzenko (INRIA) Mezzo a typed language for safe and effectful concurrent programs Jonathan Protzenko (INRIA) jonathan.protzenko@inria.fr Jonathan Protzenko INRIA Mezzo: the defense Sept. 29th, 2014 1 / 59 This defense:

More information

An overview of Mezzo

An overview of Mezzo An overview of Mezzo François Pottier INRIA Bertinoro, June 2015 1 / 91 Acknowledgements Jonathan Protzenko, Thibaut Balabonski, Henri Chataing, Armaël Guéneau, Cyprien Mangin 2 / 91 What is Mezzo? An

More information

The practice of Mezzo

The practice of Mezzo The practice of Mezzo François Pottier INRIA IHP, April 2014 1 / 83 Acknowledgements Jonathan Protzenko, Thibaut Balabonski, Henri Chataing, Armaël Guéneau, Cyprien Mangin 2 / 83 Overview Two lectures

More information

Adam Chlipala University of California, Berkeley ICFP 2006

Adam Chlipala University of California, Berkeley ICFP 2006 Modular Development of Certified Program Verifiers with a Proof Assistant Adam Chlipala University of California, Berkeley ICFP 2006 1 Who Watches the Watcher? Program Verifier Might want to ensure: Memory

More information

ML Type Inference and Unification. Arlen Cox

ML Type Inference and Unification. Arlen Cox ML Type Inference and Unification Arlen Cox Research Goals Easy to use, high performance parallel programming Primary contributions in backend and runtime Need a front end to target backend ML offers ease

More information

Static program checking and verification

Static program checking and verification Chair of Software Engineering Software Engineering Prof. Dr. Bertrand Meyer March 2007 June 2007 Slides: Based on KSE06 With kind permission of Peter Müller Static program checking and verification Correctness

More information

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes Chapter 13: Reference Why reference Typing Evaluation Store Typings Safety Notes References Computational Effects Also known as side effects. A function or expression is said to have a side effect if,

More information

Guaranteeing memory safety in Rust

Guaranteeing memory safety in Rust Guaranteeing memory safety in Rust Nicholas D. Matsakis Mozilla Research 1 Hashtable in C / C++ template struct Hashtable { Bucket *buckets; unsigned num_buckets; template

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information

The theory of Mezzo. François Pottier. IHP, April 2014 INRIA

The theory of Mezzo. François Pottier. IHP, April 2014 INRIA The theory of Mezzo François Pottier INRIA IHP, April 2014 1 / 94 Acknowledgements Jonathan Protzenko, Thibaut Balabonski, Henri Chataing, Armaël Guéneau, Cyprien Mangin. 2 / 94 Outline Introduction The

More information

CS6202: Advanced Topics in Programming Languages and Systems Lecture 0 : Overview

CS6202: Advanced Topics in Programming Languages and Systems Lecture 0 : Overview CS6202: Advanced Topics in Programming Languages and Systems Lecture 0 : Overview Advanced Language Features and Foundations Lecturer : Chin Wei Ngan Email : chinwn@comp.nus.edu.sg Office : S15 06-01 CS6202

More information

Why3 where programs meet provers

Why3 where programs meet provers Why3 where programs meet provers Jean-Christophe Filliâtre CNRS KeY Symposium 2017 Rastatt, Germany October 5, 2017 history started in 2001, as an intermediate language in the process of verifying C and

More information

Mutation. COS 326 David Walker Princeton University

Mutation. COS 326 David Walker Princeton University Mutation COS 326 David Walker Princeton University Mutation? 2 Thus far We have considered the (almost) purely functional subset of Ocaml. We ve had a few side effects: printing & raising exceptions. Two

More information

Advanced Type System Features Tom Schrijvers. Leuven Haskell User Group

Advanced Type System Features Tom Schrijvers. Leuven Haskell User Group Advanced Type System Features Tom Schrijvers Leuven Haskell User Group Data Recursion Genericity Schemes Expression Problem Monads GADTs DSLs Type Type Families Classes Lists and Effect Free Other Handlers

More information

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context Types 1 / 15 Outline Introduction Concepts and terminology The case for static typing Implementing a static type system Basic typing relations Adding context 2 / 15 Types and type errors Type: a set of

More information

Type Checking and Type Equality

Type Checking and Type Equality Type Checking and Type Equality Type systems are the biggest point of variation across programming languages. Even languages that look similar are often greatly different when it comes to their type systems.

More information

Witnessing Purity, Constancy and Mutability APLAS Ben Lippmeier Australian National University 2009/12/14

Witnessing Purity, Constancy and Mutability APLAS Ben Lippmeier Australian National University 2009/12/14 Witnessing Purity, Constancy and Mutability APLAS 2009 Ben Lippmeier Australian National University 2009/12/14 The hidden cost of state monads map :: (a -> b) -> List a -> List b map f xs = case xs of

More information

Language Techniques for Provably Safe Mobile Code

Language Techniques for Provably Safe Mobile Code Language Techniques for Provably Safe Mobile Code Frank Pfenning Carnegie Mellon University Distinguished Lecture Series Computing and Information Sciences Kansas State University October 27, 2000 Acknowledgments:

More information

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent

More information

Introduction to ML. Based on materials by Vitaly Shmatikov. General-purpose, non-c-like, non-oo language. Related languages: Haskell, Ocaml, F#,

Introduction to ML. Based on materials by Vitaly Shmatikov. General-purpose, non-c-like, non-oo language. Related languages: Haskell, Ocaml, F#, Introduction to ML Based on materials by Vitaly Shmatikov slide 1 ML General-purpose, non-c-like, non-oo language Related languages: Haskell, Ocaml, F#, Combination of Lisp and Algol-like features (1958)

More information

Chapter 1. Introduction

Chapter 1. Introduction 1 Chapter 1 Introduction An exciting development of the 21st century is that the 20th-century vision of mechanized program verification is finally becoming practical, thanks to 30 years of advances in

More information

Formally Certified Satisfiability Solving

Formally Certified Satisfiability Solving SAT/SMT Proof Checking Verifying SAT Solver Code Future Work Computer Science, The University of Iowa, USA April 23, 2012 Seoul National University SAT/SMT Proof Checking Verifying SAT Solver Code Future

More information

Deductive Verification in Frama-C and SPARK2014: Past, Present and Future

Deductive Verification in Frama-C and SPARK2014: Past, Present and Future Deductive Verification in Frama-C and SPARK2014: Past, Present and Future Claude Marché (Inria & Université Paris-Saclay) OSIS, Frama-C & SPARK day, May 30th, 2017 1 / 31 Outline Why this joint Frama-C

More information

The design of a programming language for provably correct programs: success and failure

The design of a programming language for provably correct programs: success and failure The design of a programming language for provably correct programs: success and failure Don Sannella Laboratory for Foundations of Computer Science School of Informatics, University of Edinburgh http://homepages.inf.ed.ac.uk/dts

More information

TYPE INFERENCE. François Pottier. The Programming Languages Mentoring ICFP August 30, 2015

TYPE INFERENCE. François Pottier. The Programming Languages Mentoring ICFP August 30, 2015 TYPE INFERENCE François Pottier The Programming Languages Mentoring Workshop @ ICFP August 30, 2015 What is type inference? What is the type of this OCaml function? let f verbose msg = if verbose then

More information

Why. an intermediate language for deductive program verification

Why. an intermediate language for deductive program verification Why an intermediate language for deductive program verification Jean-Christophe Filliâtre CNRS Orsay, France AFM workshop Grenoble, June 27, 2009 Jean-Christophe Filliâtre Why tutorial AFM 09 1 / 56 Motivations

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

TRELLYS and Beyond: Type Systems for Advanced Functional Programming

TRELLYS and Beyond: Type Systems for Advanced Functional Programming TRELLYS and Beyond: Type Systems for Advanced Functional Programming Aaron Stump Computer Science The University of Iowa Joint work with Tim Sheard, Vilhelm Sjöberg, and Stephanie Weirich. Supported by

More information

COMP 105 Homework: Type Systems

COMP 105 Homework: Type Systems Due Tuesday, March 29, at 11:59 PM (updated) The purpose of this assignment is to help you learn about type systems. Setup Make a clone of the book code: git clone linux.cs.tufts.edu:/comp/105/build-prove-compare

More information

A Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant

A Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant A Practical Optional Type System for Clojure Ambrose Bonnaire-Sergeant Statically typed vs. Dynamically typed Traditional distinction Dynamically typed Statically typed eg. Java, C, Haskell eg. Javascript,

More information

Logic Programming. CITS 3242 Programming Paradigms. Topic 16: Part IV: Advanced Topics

Logic Programming. CITS 3242 Programming Paradigms. Topic 16: Part IV: Advanced Topics CITS 3242 Programming Paradigms Part IV: Advanced Topics Topic 16: Logic Programming Logic Programming is a paradigm for programming by declaring facts and rules. Programs are executed by querying whether

More information

Shared Variables and Interference

Shared Variables and Interference Solved Shared Variables and Interference CS 536: Science of Programming, Fall 2018 A. Why Parallel programs can coordinate their work using shared variables, but it s important for threads to not interfere

More information

Types and Type Inference

Types and Type Inference CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of

More information

Synchronization SPL/2010 SPL/20 1

Synchronization SPL/2010 SPL/20 1 Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST.2011.3.1 COMPUTER SCIENCE TRIPOS Part IB Monday 6 June 2011 1.30 to 4.30 COMPUTER SCIENCE Paper 3 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet.

More information

Advances in Programming Languages

Advances in Programming Languages O T Y H Advances in Programming Languages APL8: ESC/Java2 David Aspinall (including slides by Ian Stark and material adapted from ESC/Java2 tutorial by David Cok, Joe Kiniry and Erik Poll) School of Informatics

More information

Aaron Turon! Mozilla Research

Aaron Turon! Mozilla Research Aaron Turon Mozilla Research C/C++ ML/Haskell Rust Safe systems programming Why Mozilla? Browsers need control. Browsers need safety. Servo: Next-generation browser built in Rust. C++ What is control?

More information

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dk The most popular purely functional, lazy programming language Functional programming language : a program

More information

Rely-Guarantee Protocols for Safe Interference over Shared Memory

Rely-Guarantee Protocols for Safe Interference over Shared Memory Rely-Guarantee Protocols for Safe Interference over Shared Memory Thesis Defense Filipe Militão December 15, 2015. Co-advised by Jonathan Aldrich (CMU) and Luís Caires (UNL). Software Defects Our over

More information

Why3 A Multi-Prover Platform for Program Verification

Why3 A Multi-Prover Platform for Program Verification Why3 A Multi-Prover Platform for Program Verification Jean-Christophe Filliâtre CNRS joint work with Andrei Paskevich, Claude Marché, and François Bobot ProVal team, Orsay, France IFIP WG 1.9/2.14 Verified

More information

An introduction introduction to functional functional programming programming using usin Haskell

An introduction introduction to functional functional programming programming using usin Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dkau Haskell The most popular p purely functional, lazy programming g language Functional programming language : a program

More information

Lecture 9: Control Flow

Lecture 9: Control Flow Programming Languages Lecture 9: Control Flow Benjamin J. Keller Department of Computer Science, Virginia Tech Programming Languages Control Flow 2 Command Overview Assignment Control Structures Natural

More information

The Hack programming language:

The Hack programming language: The Hack programming language: Types for PHP Andrew Kennedy Facebook Facebook s PHP Codebase 350,000 files >10,000,000 LoC (www.facebook.com & internally) 1000s of commits per day, 2 releases per day Anecdotally,

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 4a Andrew Tolmach Portland State University 1994-2017 Semantics and Erroneous Programs Important part of language specification is distinguishing valid from

More information

Matching Logic. Grigore Rosu University of Illinois at Urbana-Champaign

Matching Logic. Grigore Rosu University of Illinois at Urbana-Champaign Matching Logic Grigore Rosu University of Illinois at Urbana-Champaign Joint work with Andrei Stefanescu and Chucky Ellison. Started with Wolfram Schulte at Microsoft Research in 2009 Question could it

More information

Deductive Program Verification with Why3

Deductive Program Verification with Why3 Deductive Program Verification with Why3 Jean-Christophe Filliâtre CNRS Mathematical Structures of Computation Formal Proof, Symbolic Computation and Computer Arithmetic Lyon, February 2014 definition

More information

Towards efficient, typed LR parsers

Towards efficient, typed LR parsers roduction An automaton An ML implementation Beyond ML Conclusion 1 rançois Pottier and Yann Régis-Gianas June 2005 rançois Pottier and Yann Régis-Gianas roduction An automaton An ML implementation Beyond

More information

Type Theory meets Effects. Greg Morrisett

Type Theory meets Effects. Greg Morrisett Type Theory meets Effects Greg Morrisett A Famous Phrase: Well typed programs won t go wrong. 1. Describe abstract machine: M ::= 2. Give transition relation: M 1 M 2

More information

Tracing Ambiguity in GADT Type Inference

Tracing Ambiguity in GADT Type Inference Tracing Ambiguity in GADT Type Inference ML Workshop 2012, Copenhagen Jacques Garrigue & Didier Rémy Nagoya University / INRIA Garrigue & Rémy Tracing ambiguity 1 Generalized Algebraic Datatypes Algebraic

More information

BOOGIE. Presentation by Itsik Hefez A MODULAR REUSABLE VERIFIER FOR OBJECT-ORIENTED PROGRAMS MICROSOFT RESEARCH

BOOGIE. Presentation by Itsik Hefez A MODULAR REUSABLE VERIFIER FOR OBJECT-ORIENTED PROGRAMS MICROSOFT RESEARCH BOOGIE A MODULAR REUSABLE VERIFIER FOR OBJECT-ORIENTED PROGRAMS MICROSOFT RESEARCH Presentation by Itsik Hefez Introduction Boogie is an intermediate verification language, intended as a layer on which

More information

Lecture 8: Summary of Haskell course + Type Level Programming

Lecture 8: Summary of Haskell course + Type Level Programming Lecture 8: Summary of Haskell course + Type Level Programming Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense October 31, 2017 Principles from Haskell

More information

OCaml. ML Flow. Complex types: Lists. Complex types: Lists. The PL for the discerning hacker. All elements must have same type.

OCaml. ML Flow. Complex types: Lists. Complex types: Lists. The PL for the discerning hacker. All elements must have same type. OCaml The PL for the discerning hacker. ML Flow Expressions (Syntax) Compile-time Static 1. Enter expression 2. ML infers a type Exec-time Dynamic Types 3. ML crunches expression down to a value 4. Value

More information

CS4215 Programming Language Implementation

CS4215 Programming Language Implementation CS4215 Programming Language Implementation You have 45 minutes to complete the exam. Use a B2 pencil to fill up the provided MCQ form. Leave Section A blank. Fill up Sections B and C. After finishing,

More information

Typed Assembly Language for Implementing OS Kernels in SMP/Multi-Core Environments with Interrupts

Typed Assembly Language for Implementing OS Kernels in SMP/Multi-Core Environments with Interrupts Typed Assembly Language for Implementing OS Kernels in SMP/Multi-Core Environments with Interrupts Toshiyuki Maeda and Akinori Yonezawa University of Tokyo Quiz [Environment] CPU: Intel Xeon X5570 (2.93GHz)

More information

Compilation and Program Analysis (#11) : Hoare triples and shape analysis

Compilation and Program Analysis (#11) : Hoare triples and shape analysis Compilation and Program Analysis (#11) : Hoare triples and shape analysis Laure Gonnord http://laure.gonnord.org/pro/teaching/capm1.html Laure.Gonnord@ens-lyon.fr Master 1, ENS de Lyon dec 2017 Inspiration

More information

Part VI. Imperative Functional Programming

Part VI. Imperative Functional Programming Part VI Imperative Functional Programming Chapter 14 Mutable Storage MinML is said to be a pure language because the execution model consists entirely of evaluating an expression for its value. ML is

More information

Recursive Types and Subtyping

Recursive Types and Subtyping Recursive Types and Subtyping #1 One-Slide Summary Recursive types (e.g., list) make the typed lambda calculus as powerful as the untyped lambda calculus. If is a subtype of then any expression of type

More information

Run-Time Data Structures

Run-Time Data Structures Run-Time Data Structures Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers, it is used for:

More information

CSE341: Programming Languages Lecture 11 Type Inference. Dan Grossman Spring 2016

CSE341: Programming Languages Lecture 11 Type Inference. Dan Grossman Spring 2016 CSE341: Programming Languages Lecture 11 Type Inference Dan Grossman Spring 2016 Type-checking (Static) type-checking can reject a program before it runs to prevent the possibility of some errors A feature

More information

Types and Type Inference

Types and Type Inference Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on the course homepage Outline General discussion

More information

Modular specification of frame properties in JML

Modular specification of frame properties in JML CONCURRENCY PRACTICE AND EXPERIENCE Concurrency: Pract. Exper. 2002; 1:1 [Version: 2001/03/05 v2.01] Modular specification of frame properties in JML Peter Müller 1, Arnd Poetzsch-Heffter 2, and Gary T.

More information

Combining Static and Dynamic Contract Checking for Curry

Combining Static and Dynamic Contract Checking for Curry Michael Hanus (CAU Kiel) Combining Static and Dynamic Contract Checking for Curry LOPSTR 2017 1 Combining Static and Dynamic Contract Checking for Curry Michael Hanus University of Kiel Programming Languages

More information

It turns out that races can be eliminated without sacrificing much in terms of performance or expressive power.

It turns out that races can be eliminated without sacrificing much in terms of performance or expressive power. The biggest two problems in multi-threaded programming are races and deadlocks. Races reached new levels with the introduction of relaxed memory processors. It turns out that races can be eliminated without

More information

Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC. hapter 1 INTRODUTION SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Objectives You will learn: Java features. Java and its associated components. Features of a Java application and applet. Java data types. Java

More information

Deductive Program Verification with Why3, Past and Future

Deductive Program Verification with Why3, Past and Future Deductive Program Verification with Why3, Past and Future Claude Marché ProofInUse Kick-Off Day February 2nd, 2015 A bit of history 1999: Jean-Christophe Filliâtre s PhD Thesis Proof of imperative programs,

More information

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures Dan Grossman Fall 2014 Hi! I m not Hal J I love this stuff and have taught

More information

Static Use-Based Object Confinement. Christian Skalka and Scott Smith The Johns Hopkins University

Static Use-Based Object Confinement. Christian Skalka and Scott Smith The Johns Hopkins University Static Use-Based Object Confinement Christian Skalka and Scott Smith The Johns Hopkins University Object confinement: what is it? Object confinement is concerned with the encapsulation, or protection,

More information

6.005 Elements of Software Construction Fall 2008

6.005 Elements of Software Construction Fall 2008 MIT OpenCourseWare http://ocw.mit.edu 6.005 Elements of Software Construction Fall 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 6.005 elements

More information

Object Ownership in Program Verification

Object Ownership in Program Verification Object Ownership in Program Verification Werner Dietl 1 and Peter Müller 2 1 University of Washington wmdietl@cs.washington.edu 2 ETH Zurich peter.mueller@inf.ethz.ch Abstract. Dealing with aliasing is

More information

Ruby: Objects and Dynamic Types

Ruby: Objects and Dynamic Types Ruby: Objects and Dynamic Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 5 Primitive vs Reference Types Recall Java type dichotomy: Primitive: int, float,

More information

Introduction to OCaml

Introduction to OCaml Fall 2018 Introduction to OCaml Yu Zhang Course web site: http://staff.ustc.edu.cn/~yuzhang/tpl References Learn X in Y Minutes Ocaml Real World OCaml Cornell CS 3110 Spring 2018 Data Structures and Functional

More information

Introduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples

Introduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Introduction to Typed Racket The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Getting started Find a machine with DrRacket installed (e.g. the

More information

Reminder of the last lecture. Aliasing Issues: Call by reference, Pointer programs. Introducing Aliasing Issues. Home Work from previous lecture

Reminder of the last lecture. Aliasing Issues: Call by reference, Pointer programs. Introducing Aliasing Issues. Home Work from previous lecture Reminder of the last lecture Aliasing Issues: Call by reference, Pointer programs Claude Marché Cours MPRI 2-36-1 Preuve de Programme 18 janvier 2017 Additional features of the specification language Abstract

More information

Uniqueness and Reference Immutability for Safe Parallelism

Uniqueness and Reference Immutability for Safe Parallelism Uniqueness and Reference Immutability for Safe Parallelism Colin Gordon (UW), Matt Parkinson (MSR), Jared Parsons (MS), Aleks Bromfield (MS), Joe Duffy (MS) OOPSLA 2012 A Prototype Extension to C# Extend

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 21 March 2 nd, 2016 GUI: notifiers Transition to Java What is the type of xs? let r = {contents = 3} let xs = [(fun () -> r.contents

More information

Implementing nml: Hindley-Milner Type Inference

Implementing nml: Hindley-Milner Type Inference Implementing nml: Hindley-Milner Type Inference Due Friday, April 10 at 5:59PM. In this assignment you will implement Hindley-Milner type inference, which represents the current ``best practice'' for flexible

More information

Asynchronous Liquid Separation Types

Asynchronous Liquid Separation Types Asynchronous Liquid Separation Types Johannes Kloos, Rupak Majumdar, and Viktor Vafeiadis Max Planck Institute for Software Systems, Germany {jkloos,rupak,viktor}@mpi-sws.org Abstract We present a refinement

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques () Lecture 20 February 28, 2018 Transition to Java Announcements HW05: GUI programming Due: THURSDAY!! at 11:59:59pm Lots of TA office hours today Thursday See Piazza

More information

News. Programming Languages. Complex types: Lists. Recap: ML s Holy Trinity. CSE 130: Spring 2012

News. Programming Languages. Complex types: Lists. Recap: ML s Holy Trinity. CSE 130: Spring 2012 News CSE 130: Spring 2012 Programming Languages On webpage: Suggested HW #1 PA #1 (due next Fri 4/13) Lecture 2: A Crash Course in ML Please post questions to Piazza Ranjit Jhala UC San Diego Today: A

More information

Objects as Session-Typed Processes

Objects as Session-Typed Processes Objects as Session-Typed Processes Stephanie Balzer and Frank Pfenning Computer Science Department, Carnegie Mellon University AGERE! 2015 The essence of object-orientation 2 The essence of object-orientation

More information

Turning proof assistants into programming assistants

Turning proof assistants into programming assistants Turning proof assistants into programming assistants ST Winter Meeting, 3 Feb 2015 Magnus Myréen Why? Why combine proof- and programming assistants? Why proofs? Testing cannot show absence of bugs. Some

More information

Practical Affine Types and Typestate-Oriented Programming

Practical Affine Types and Typestate-Oriented Programming Practical Affine Types and Typestate-Oriented Programming Philipp Haller KTH Royal Institute of Technology Stockholm, Sweden Dagstuhl Seminar 17051 Theory and Applications of Behavioural Types Schloss

More information

Shared Variables and Interference

Shared Variables and Interference Illinois Institute of Technology Lecture 24 Shared Variables and Interference CS 536: Science of Programming, Spring 2018 A. Why Parallel programs can coordinate their work using shared variables, but

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.

More information

Ornaments in ML. Thomas Williams, Didier Rémy. April 18, Inria - Gallium

Ornaments in ML. Thomas Williams, Didier Rémy. April 18, Inria - Gallium Ornaments in ML Thomas Williams, Didier Rémy Inria - Gallium April 18, 2017 1 Motivation Two very similar functions let rec add m n = match m with Z n S m S (add m n) let rec append ml nl = match ml with

More information

A Verified Implementation of the Bounded List Container

A Verified Implementation of the Bounded List Container A Verified Implementation of the Bounded List Container Raphaël Cauderlier, Mihaela Sighireanu March 26, 2018 1 / 32 Outline 1 Introduction 2 Bounded Doubly-Linked Lists 3 Verification 4 Conclusion 2 /

More information

Idris: Implementing a Dependently Typed Programming Language

Idris: Implementing a Dependently Typed Programming Language Idris: Implementing a Dependently Typed Programming Language Edwin Brady University of St Andrews ecb10@st-andrews.ac.uk @edwinbrady Type Inference and Automated Proving, Dundee, 12th May 2015 1 / 25 Idris

More information

Cover Page. The handle holds various files of this Leiden University dissertation

Cover Page. The handle   holds various files of this Leiden University dissertation Cover Page The handle http://hdl.handle.net/1887/22891 holds various files of this Leiden University dissertation Author: Gouw, Stijn de Title: Combining monitoring with run-time assertion checking Issue

More information

Manifest Safety and Security. Robert Harper Carnegie Mellon University

Manifest Safety and Security. Robert Harper Carnegie Mellon University Manifest Safety and Security Robert Harper Carnegie Mellon University Collaborators This work is, in part, joint with Lujo Bauer, Karl Crary, Peter Lee, Mike Reiter, and Frank Pfenning at Carnegie Mellon.

More information

Lightweight Verification of Array Indexing

Lightweight Verification of Array Indexing Lightweight Verification of Array Indexing Martin Kellogg*, Vlastimil Dort**, Suzanne Millstein*, Michael D. Ernst* * University of Washington, Seattle ** Charles University, Prague The problem: unsafe

More information

CSE 130: Programming Languages. Polymorphism. Ranjit Jhala UC San Diego

CSE 130: Programming Languages. Polymorphism. Ranjit Jhala UC San Diego CSE 130: Programming Languages Polymorphism Ranjit Jhala UC San Diego Q: What is the value of res? let f g = let x = 0 in g 2 let x = 100 let h y = x + y let res = f h (a) 0 (b) 2 (c) 100 (d) 102 (e) 12

More information

Static Program Analysis Part 1 the TIP language

Static Program Analysis Part 1 the TIP language Static Program Analysis Part 1 the TIP language http://cs.au.dk/~amoeller/spa/ Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Questions about programs Does the program terminate

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST.0.. COMPUTER SCIENCE TRIPOS Part IA NATURAL SCIENCES TRIPOS Part IA (Paper CS/) POLITICS, PSYCHOLOGY, AND SOCIOLOGY TRIPOS Part I (Paper 9) Monday June 0.0 to 4.0 COMPUTER SCIENCE Paper Answer five

More information

Mini-ML. CS 502 Lecture 2 8/28/08

Mini-ML. CS 502 Lecture 2 8/28/08 Mini-ML CS 502 Lecture 2 8/28/08 ML This course focuses on compilation techniques for functional languages Programs expressed in Standard ML Mini-ML (the source language) is an expressive core subset of

More information

cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides.

cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides. cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides. We are looking for homework graders. If you are interested, send mail to cs242cs.stanford.edu

More information

Advances in Programming Languages

Advances in Programming Languages T O Y H Advances in Programming Languages APL4: JML The Java Modeling Language David Aspinall (slides originally by Ian Stark) School of Informatics The University of Edinburgh Thursday 21 January 2010

More information

Hoare triples. Floyd-Hoare Logic, Separation Logic

Hoare triples. Floyd-Hoare Logic, Separation Logic Hoare triples Floyd-Hoare Logic, Separation Logic 1. Floyd-Hoare Logic 1969 Reasoning about control Hoare triples {A} p {B} a Hoare triple partial correctness: if the initial state satisfies assertion

More information

Rely-Guarantee References for Refinement Types over Aliased Mutable Data

Rely-Guarantee References for Refinement Types over Aliased Mutable Data Rely-Guarantee References for Refinement Types over Aliased Mutable Data Colin S. Gordon, Michael D. Ernst, and Dan Grossman University of Washington PLDI 2013 Static Verification Meets Aliasing 23 x:ref

More information

Static Use Based Object Confinement. Christian Skalka and Scott Smith The Johns Hopkins University

Static Use Based Object Confinement. Christian Skalka and Scott Smith The Johns Hopkins University Static Use Based Object Confinement Christian Skalka and Scott Smith The Johns Hopkins University Object confinement: what is it? Object confinement is concerned with the encapsulation, or protection,

More information