K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 0 Summer School on Logic and Theorem-Proving in Programming.

Slides:



Advertisements
Similar presentations
Automatic verification of summations K. Rustan M. Leino IFIP WG 2.3 meeting 46 Sydney, Australia 11 January 2007.
Advertisements

Hoare-style program verification K. Rustan M. Leino Guest lecturer Rob DeLines CSE 503, Software Engineering University of Washington 26 Apr 2004.
Joint work with Mike Barnett, Robert DeLine, Manuel Fahndrich, and Wolfram Schulte Verifying invariants in object-oriented programs K. Rustan M. Leino.
Demand-driven inference of loop invariants in a theorem prover
Checking correctness properties of object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 3 EEF summer school on Specification,
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 2 Summer school on Formal Models.
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 1 Summer school on Formal Models.
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 0 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.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA, USA 15 January 2009 Séminaire Digiteo Orsay, France.
Using SMT solvers for program analysis Shaz Qadeer Research in Software Engineering Microsoft Research.
Synthesis, Analysis, and Verification Lecture 04c Lectures: Viktor Kuncak VC Generation for Programs with Data Structures “Beyond Integers”
Automated Software Verification with a Permission-Based Logic 20 th June 2014, Zürich Malte Schwerhoff, ETH Zürich.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA, USA 3 December 2008 U. Lugano Lugano, Switzerland.
Axiomatic Semantics The meaning of a program is defined by a formal system that allows one to deduce true properties of that program. No specific meaning.
1 Discrete Structures Lecture 29 Predicates and Programming Read Ch
Predicate Transformers
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 0 International Summer School Marktoberdorf Marktoberdorf,
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
ECI 2007: Specification and Verification of Object-Oriented Programs Lecture 2 Courtesy: K. Rustan M. Leino and Wolfram Schulte.
Lecture 2 Towards a Verifying Compiler: Logic of Object oriented Programs Wolfram Schulte Microsoft Research Formal Methods 2006 Objects, references, heaps,
Contracts, tools, verification K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Keynote, ASWEC 2010; Auckland, NZ;
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 1 LASER.
Hoare-style program verification K. Rustan M. Leino Guest lecturer Rob DeLine’s CSE 503, Software Engineering University of Washington 26 Apr 2004.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 0 LASER.
ECI 2007: Specification and Verification of Object- Oriented Programs Lecture 1.
Building a program verifier K. Rustan M. Leino Microsoft Research, Redmond, WA 10 May 2006 Guest lecture, Shaz Qadeer’s cse599f, Formal Verification of.
Well-cooked Spaghetti: Weakest-Precondition of Unstructured Programs Mike Barnett and Rustan Leino Microsoft Research Redmond, WA, USA.
Chair of Software Engineering Automatic Verification of Computer Programs.
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
K. Rustan M. Leino Microsoft Research, Redmond, WA 10 Oct 2007 IFIP WG 2.3 meeting Santa Fe, NM.
Floyd Hoare Logic. Semantics A programming language specification consists of a syntactic description and a semantic description. Syntactic description:symbols.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Caltech Pasadena, CA 12 November 2009.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 1 Summer School on Logic and Theorem-Proving in Programming.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 3 Marktoberdorf.
Program Verification K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond University of Washington CSE P January.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 0 Marktoberdorf.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
Specifying and verifying programs in Spec# K. Rustan M. Leino Microsoft Research, Redmond, WA, USA Invited talk, PSI 2006 Novosibirsk, Russia 27 June 2006.
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 2 International Summer School Marktoberdorf Marktoberdorf,
K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 15 Nov 2007 Chalmers Göteborg, Sweden.
Cs7100(Prasad)L18-9WP1 Axiomatic Semantics Predicate Transformers.
Boolean Programs: A Model and Process For Software Analysis By Thomas Ball and Sriram K. Rajamani Microsoft technical paper MSR-TR Presented by.
Dafny An automatic program verifier for functional correctness
Specification techniques for verifying object-oriented software
Auto-active verification
Weakest Precondition of Unstructured Programs
Program Verification via an Intermediate Verification Language
Formal Methods in Software Engineering 1
Hoare-style program verification
Auto-active verification
Lecture 5 Floyd-Hoare Style Verification
Reasoning about Loops, Conclusion
Programming Languages 2nd edition Tucker and Noonan
Hoare-style program verification
Dafny An automatic program verifier for functional correctness
Predicate Transformers
Auto-active verification
Programming Languages and Compilers (CS 421)
Programming Languages 2nd edition Tucker and Noonan
COP4020 Programming Languages
Presentation transcript:

K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 0 Summer School on Logic and Theorem-Proving in Programming Languages Eugene, OR 28 July 2008

Theory and techniques for building a basic program verifier for an object-based language Specification style and encoding thereof

Verification condition (logical formula) Source language Intermediate verification language

Static program verifier (Boogie) MSIL SMT solver (Z3) V.C. generator Inference engine verification condition “correct” or list of errors Spec# compiler Spec# Boogie C Bytecode translator vcc C HAVOC Dafny verifier Dafny

… terminates diverges goes wrong

State Cartesian product of variables Execution trace Nonempty finite sequence of states Infinite sequence of states Nonempty finite sequence of states followed by special error state … (x: int, y: int, z: bool)

A command describes a set of execution traces A command is deterministic if it describes at most one trace from every initial state Java, ML, Haskell otherwise, it is nondeterministic C, Modula-3, Erlang, Occam A command is total if it describes at least one trace from every initial state Dijkstra’s Law of the Excluded Miracle otherwise, it is partial Juno-2, LIM

x := E x := x + 1 x := 10 havoc x assert P assume P P ¬P¬P P

… x := E x := x + 1 x := 10 havoc x S ; T assert P assume P P ¬P¬P P …

x := E x := x + 1 x := 10 havoc x S ; T assert P assume P S  T P ¬P¬P P …

An array is a map from indices to values array update is map update: a[ j ] := E means a := a[ j  E ] Apply/select/get and update/store/set follow the familiar properties: (  a,j,k,x  j = k  a[ j  x ][ k ] = x ) (  a,j,k,x  j ≠ k  a[ j  x ][ k ] = a[ k ] )

Hoare triple{ P } S { Q } says that every terminating execution trace of S that starts in a state satisfying P does not go wrong, and terminates in a state satisfying Q Given P and Q, what is the largest S’ satisfying {P} S’ {Q} ? to check {P} S {Q}, check S  S’

Hoare triple{ P } S { Q } says that every terminating execution trace of S that starts in a state satisfying P does not go wrong, and terminates in a state satisfying Q Given S and Q, what is the weakest P’ satisfying {P’} S {Q} ? P' is called the weakest precondition of S with respect to Q, written wp(S, Q) to check {P} S {Q}, check P  P’

Hoare triple{ P } S { Q } says that every terminating execution trace of S that starts in a state satisfying P does not go wrong, and terminates in a state satisfying Q Given P and S, what is the strongest Q’ satisfying {P} S {Q’} ? to check {P} S {Q}, check Q'  Q 

wp( x := E, Q ) = wp( havoc x, Q ) = wp( assert P, Q ) = wp( assume P, Q ) = wp( S ; T, Q ) = wp( S  T, Q ) = Q[ E / x ] (  x  Q ) P  Q P  Q wp( S, wp( T, Q )) wp( S, Q )  wp( T, Q )

if E then S else T end = assume E; S  assume ¬ E; T

if E  S | F  T fi = assert E  F; ( assume E; S  assume F; T )

assign x such that P = havoc x; assume P assign x such that x*x = y P ¬P¬P ;=

A procedure is a user-defined command procedure M(x, y, z) returns (r, s, t) requires P modifies g, h ensures Q

procedure Inc(n) returns (b) requires 0 ≤ n modifies g ensures g = old(g) + n  b = (g even)

A procedure is a user-defined command procedure M(x, y, z) returns (r, s, t) requires P modifies g, h ensures Q call a, b, c := M(E, F, G) =x’ := E; y’ := F; z’ := G; assert P’; g0 := g; h0 := h; havoc g, h, r’, s’, t’; assume Q’; a := r’; b := s’; c := t’ where x’, y’, z’, r’, s’, t’, g0, h0 are fresh names P’ is P with x’,y’,z’ for x,y,z Q’ is Q with x’,y’,z’,r’,s’,t’,g0,h0 for x,y,z,r,s,t, old(g), old(h)

procedure M(x, y, z) returns (r, s, t) requires P modifies g, h ensures Q implementation M(x, y, z) returns (r, s, t) is S = assume P; g0 := g; h0 := h; S; assert Q’ where g0, h0 are fresh names Q’ is Q with g0,h0 for old(g), old(h) syntactically check that S assigns only to g,h

while E invariant J do S end = ? Homework H o m e w o r k

Spec# is a programming language/system with specifications and a static program verifier To engineer a program verifier or define the semantics of a source language, use an intermediate verification language An intermediate language can be very small The semantics of the intermediate language can be defined using weakest preconditions Tomorrow: Application to programs with objects and references