K. Rustan M. Leino RiSE, Microsoft Research, Redmond joint work with Peter Müller and Jan Smans Lecture 0 1 September 2009 FOSAD 2009, Bertinoro, Italy.

Slides:



Advertisements
Similar presentations
1 Lecture 5 Towards a Verifying Compiler: Multithreading Wolfram Schulte Microsoft Research Formal Methods 2006 Race Conditions, Locks, Deadlocks, Invariants,
Advertisements

Advanced programming tools at Microsoft
Joint work with Mike Barnett, Robert DeLine, Manuel Fahndrich, and Wolfram Schulte Verifying invariants in object-oriented programs K. Rustan M. Leino.
Checking correctness properties of object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 4 EEF summer school on Specification,
Checking correctness properties of object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 3 EEF summer school on Specification,
Object Invariants in Specification and Verification K. Rustan M. Leino Microsoft Research, Redmond, WA Joint work with: Mike Barnett, Ádám Darvas, Manuel.
Writing specifications for object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 21 Jan 2005 Invited talk, AIOOL 2005 Paris,
1 Towards a Verifying Compiler: The Spec# Approach Wolfram Schulte Microsoft Research Formal Methods 2006 Joint work with Rustan Leino, Mike Barnett, Manuel.
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 3 Summer school on Formal Models.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Challenges in increasing tool support for programming K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 23 Sep 2004 ICTAC Guiyang, Guizhou, PRC joint.
In this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and shows.
Verifying Executable Object-Oriented Specifications with Separation Logic Stephan van Staden, Cristiano Calcagno, Bertrand Meyer.
Constraint Semantics for Abstract Read Permissions 28 th July 2014, FTfJP, Uppsala John Tang Boyland (UW-Milwaukee/ETH Zurich) Peter Müller, Malte Schwerhoff,
Automated Verification with HIP and SLEEK Asankhaya Sharma.
Automated Software Verification with a Permission-Based Logic 20 th June 2014, Zürich Malte Schwerhoff, ETH Zürich.
Verification of Multithreaded Object- Oriented Programs with Invariants Bart Jacobs, K. Rustan M. Leino, Wolfram Schulte.
A simple sequential reasoning approach for sound modular verification of mainstream multithreaded programs Wolfram Schulte & Bart Jacobs Microsoft Research.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA, USA Invited talk Informatics Education in Europe (IEE III’08)
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA, USA 3 December 2008 U. Lugano Lugano, Switzerland.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Fractional Permissions without the Fractions Alex Summers ETH Zurich Joint work with: Stefan Heule, Rustan Leino, Peter Müller ETH Zurich MSR Redmond ETH.
Lecture 2 Towards a Verifying Compiler: Logic of Object oriented Programs Wolfram Schulte Microsoft Research Formal Methods 2006 Objects, references, heaps,
Copyright W. Howden1 Lecture 13: Programming by Contract.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 1 LASER.
K. Rustan M. Leino RiSE, Microsoft Research Typing, Analysis and Verification of Heap-Manipulating Programs Dagstuhl, Germany 20 July 2009.
Modular Verification of Multithreaded Software Shaz Qadeer Compaq Systems Research Center Shaz Qadeer Compaq Systems Research Center Joint work with Cormac.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 0 LASER.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 4 LASER.
Chapter 1 Principles of Programming and Software Engineering.
Well-cooked Spaghetti: Weakest-Precondition of Unstructured Programs Mike Barnett and Rustan Leino Microsoft Research Redmond, WA, USA.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 5 LASER.
Describing Syntax and Semantics
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 3 LASER.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Caltech Pasadena, CA 12 November 2009.
K. Rustan M. Leino RiSE, Joint work with: Peter Müller (ETH Zurich) Jan Smans (KU Leuven) Special thanks to Mike Barnett VMCAI, Madrid, Spain, 18 January.
Refinement, reusable libraries, instantiable classes K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Joint work.
CS510 Concurrent Systems Introduction to Concurrency.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
1 Concurrent Languages – Part 1 COMP 640 Programming Languages.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 3 Marktoberdorf.
Viper A Verification Infrastructure for Permission-Based Reasoning 1 st March 2015, ECOOP’15 PC Meeting, Zurich Uri Juhasz, Ioannis Kassios, Peter Müller,
Program Verification K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond University of Washington CSE P January.
Viper A Verification Infrastructure for Permission-Based Reasoning 24 th March 2015, JML Workshop, Leiden Uri Juhasz, Ioannis Kassios, Peter Müller, Milos.
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
Rustan Leino RiSE, Microsoft Research, Redmond MIT 5 June 2009 Joint work with: Peter Müller, ETH Zurich Jan Smans, KU Leuven.
A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 0 Marktoberdorf.
Semantics In Text: Chapter 3.
Lightweight Support for Magic Wands in an Automatic Verifier Malte Schwerhoff and Alexander J. Summers 10 th July 2015, ECOOP, Prague.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 2 International Summer School Marktoberdorf Marktoberdorf,
An Introduction to Automated Program Verification with Permission Logics 15 th May 2015, Systems Group, ETH Zurich Uri Juhasz, Ioannis Kassios, Peter Müller,
K. Rustan M. Leino RiSE, Microsoft Research, Redmond joint work with Peter Müller and Jan Smans Lecture 1 2 September 2009 FOSAD 2009, Bertinoro, Italy.
This Week Lecture on relational semantics Exercises on logic and relations Labs on using Isabelle to do proofs.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
ESOP 2010, Paphos, Cyprus, 22 March 2010 K. Rustan M. Leino (RiSE group, Microsoft Research) Peter Müller (ETH Zurich) Jan Smans (KU Leuven)
CS510 Concurrent Systems Jonathan Walpole. Introduction to Concurrency.
Spring 2017 Program Analysis and Verification
Dafny An automatic program verifier for functional correctness
Specification techniques for verifying object-oriented software
Deductive Verification Tools Tutorial for Dagstuhl Seminar 16201
A Verification Infrastructure for Permission-based Reasoning
Using and Building an Automatic Program Verifier
Verification of concurrent object-oriented programs
Reasoning about Loops, Conclusion
Semantics In Text: Chapter 3.
Dafny An automatic program verifier for functional correctness
Presentation transcript:

K. Rustan M. Leino RiSE, Microsoft Research, Redmond joint work with Peter Müller and Jan Smans Lecture 0 1 September 2009 FOSAD 2009, Bertinoro, Italy

Prove program correctness for all possible inputs and behaviors

Prove parts of a program separately Correctness of every part implies correctness of whole program

Record programmer design decisions Describe usage of program constructs Provide redundancy Enable modular verification

Specification and verification methodology Describes properties of the heap Active area of research Ownership Spec#, Java+JML, vcc, type systems, … Dynamic frames VeriCool, Dafny Permissions (capabilities) Effect systems, separation logic, VeriCool 3, Chalice, …

Interleaving of thread executions Unbounded number of: threads, locks, … We need some basis for doing the reasoning A way of thinking!

Concurrent programs Features like: threads, monitors, abstraction as well as: objects, methods, loops, … Avoid errors like: race conditions, deadlocks Specifications with permissions Building a program verifier

Pre- and postconditions

Loop invariants

Chalice

Helps testing find bugs more quickly Optional, they can be treated as ghosts If they are to be ghosted, specifications must have no side effects (on non-ghost state)

Access to a memory location requires permission Permissions are held by activation records Syntax for talking about permission to y: acc(y)

Permissions

method Main() { var c := new Counter; call c.Inc(); } method Main() { var c := new Counter; call c.Inc(); } method Inc() requires acc(y) ensures acc(y) { y := y + 1; } method Inc() requires acc(y) ensures acc(y) { y := y + 1; } acc(c.y)

A specification expression can mention a memory location only if it also entails the permission to that location acc(y) && y < 100 y < 100  acc(x) && y < 100  acc(o.y) && p.y < 100  o == p && acc(o.y) && p.y < 100 x / y < 20  y ≠ 0 && x / y < 20

A loop iteration is like its own activation record is like Before; while (B) invariant J { S; } After; Before; while (B) invariant J { S; } After; Before;method MyLoop(…) call MyLoop(…);requires J After; ensures J { if (B) { S; call MyLoop(…); } } Before;method MyLoop(…) call MyLoop(…);requires J After; ensures J { if (B) { S; call MyLoop(…); } }

method M() requires acc(x) && acc(y) && x <= 100 && y <= 100 { while (y < 100) invariant acc(y) && y <= 100 { y := y + 1; x := x + 1; // error: no permission to access x } assert x <= y; } method M() requires acc(x) && acc(y) && x <= 100 && y <= 100 { while (y < 100) invariant acc(y) && y <= 100 { y := y + 1; x := x + 1; // error: no permission to access x } assert x <= y; }

method M() requires acc(x) && acc(y) && x <= 100 && y <= 100 { while (y < 100) invariant acc(y) && y <= 100 { y := y + 1; } assert x <= y; } method M() requires acc(x) && acc(y) && x <= 100 && y <= 100 { while (y < 100) invariant acc(y) && y <= 100 { y := y + 1; } assert x <= y; }

Loop invariants with permissions

Threads run concurrently A new thread of control is started with the fork statement A thread can wait for another to complete with the join statement Permissions are transferred to and from a thread via the starting method’s pre- and postconditions

Fork and join

call == fork + join is semantically like … but is implemented more efficiently call x,y := o.M(E, F); fork tk := o.M(E, F); join x,y := tk; fork tk := o.M(E, F); join x,y := tk;

Parallel computation

Recall: A specification expression can mention a memory location only if it also entails some permission to that location Example: acc(y) && y < 100 Without any permission to y, other threads may change y, and then y would not be stable

acc(y)write permission to y rd(y)read permission to y At any one time, at most one thread can have write permission to a location

Parallel reads

acc(y)100% permission to y acc(y, p)p% permission to y rd(y)read permission to y Write access requires 100% Read access requires >0% = +  acc(y)acc(y,69) acc(y,31) rd(y) acc(y,  )

method M() requires acc(y) ensures acc(y) can change y Can method P() requires rd(y) ensures rd(y) change y? That is, can we prove: method Q() requires rd(y) && y == 5 { call P(); assert y == 5; } method Q() requires rd(y) && y == 5 { call P(); assert y == 5; } Demo: NoPerm

What if two threads want write access to the same location? method A() … { y := y + 21; } method A() … { y := y + 21; } method B() … { y := y + 34; } method B() … { y := y + 34; } class Fib { var y: int; method Main() { var c := new Fib; fork c.A(); fork c.B(); } class Fib { var y: int; method Main() { var c := new Fib; fork c.A(); fork c.B(); } acc(c.y)

method A() … { acquire this; y := y + 21; release this; } method A() … { acquire this; y := y + 21; release this; } method B() … { acquire this; y := y + 34; release this; } method B() … { acquire this; y := y + 34; release this; } class Fib { var y: int; invariant acc(y); method Main() { var c := new Fib; share c; fork c.A(); fork c.B(); } class Fib { var y: int; invariant acc(y); method Main() { var c := new Fib; share c; fork c.A(); fork c.B(); } acc(c.y) acc(y)

Like other specifications, can hold both permissions and conditions Example: invariant acc(y) && 0 <= y acc(y)

thread local shared, available shared, locked new share acquire release

Monitors

The concepts holding a lock, and having permissions are orthogonal to one another In particular: Holding a lock does not imply any right to read or modify shared variables Their connection is: Acquiring a lock obtains some permissions Releasing a lock gives up some permissions

Server-side locking “safer” (requires less thinking) Client-side locking more efficient invariant acc(y); method M() requires true { acquire this; y := …; release this; } invariant acc(y); method M() requires true { acquire this; y := …; release this; } method M() requires acc(y) { y := …; } method M() requires acc(y) { y := …; }