Automated Verification with HIP and SLEEK Asankhaya Sharma.

Slides:



Advertisements
Similar presentations
A Framework for describing recursive data structures Kenneth Roe Scott Smith.
Advertisements

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
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.
Linked Lists CSE 2451 Matt Boggus. Dynamic memory reminder Allocate memory during run-time malloc() and calloc() – return a void pointer to memory or.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 8.
Introduction to Algorithms Quicksort
Automated Verification with HIP and SLEEK Asankhaya Sharma.
Synthesis, Analysis, and Verification Lecture 04c Lectures: Viktor Kuncak VC Generation for Programs with Data Structures “Beyond Integers”
Gennaro Parlato (LIAFA, Paris, France) Joint work with P. Madhusudan Xiaokang Qie University of Illinois at Urbana-Champaign.
Gennaro Parlato (LIAFA, Paris, France) Joint work with P. Madhusudan Xiaokang Qie University of Illinois at Urbana-Champaign.
Introduction to Linked Lists In your previous programming course, you saw how data is organized and processed sequentially using an array. You probably.
Verification of Functional Programs in Scala Philippe Suter (joint work w/ Ali Sinan Köksal and Viktor Kuncak) ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE,
Automated Verification with HIP and SLEEK Asankhaya Sharma.
HIP/SLEEK11 HIP/SLEEK :Automatic Verification and Specification Inference System Wei-Ngan Chin & Asankhaya Sharma Dept of Computer Science National University.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
1 Symbolic Execution for Model Checking and Testing Corina Păsăreanu (Kestrel) Joint work with Sarfraz Khurshid (MIT) and Willem Visser (RIACS)
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
(c) 2007 Mauro Pezzè & Michal Young Ch 7, slide 1 Symbolic Execution and Proof of Properties.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 1 LASER.
The Pointer Assertion Logic Engine Anders Møller Michael I. Schwartzbach CMSC 631 presentation: Nikolaos Frangiadakis.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 13 Pointers and Linked Lists.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Automating Separation Logic with Trees and Data Ruzica Piskac Yale University Thomas Wies New York University Damien Zufferey MIT CSAIL CAV, ,
Extensible Untrusted Code Verification Robert Schneck with George Necula and Bor-Yuh Evan Chang May 14, 2003 OSQ Retreat.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
Proving termination conditions Name Country, City, University Omer Subasi Turkey, Istanbul, Koc University Anton Dergunov
Cristian Gherghina Joint work with: Wei-Ngan Chin, Razvan Voicu, Quang Loc Le Florin Craciun, Shengchao Qin TexPoint fonts used in EMF. Read the TexPoint.
Pre/Post Condition Logic 03/06/2013. Agenda Hoare’s Logic Overview Application to Pre/Post Conditions.
CUTE: A Concolic Unit Testing Engine for C Technical Report Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
Review Binary Tree Binary Tree Representation Array Representation Link List Representation Operations on Binary Trees Traversing Binary Trees Pre-Order.
From Program Verification to Program Synthesis Saurabh Srivastava * Sumit Gulwani ♯ Jeffrey S. Foster * * University of Maryland, College Park ♯ Microsoft.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
CS261 – Recitation 5 Fall Outline Assignment 3: Memory and Timing Tests Binary Search Algorithm Binary Search Tree Add/Remove examples 1.
Extended Static Checking for Java  ESC/Java finds common errors in Java programs: null dereferences, array index bounds errors, type cast errors, race.
1 Dependable Software via Automated Verification Huu Hai Nguyen(NUS) Cristina David(NUS) Shengchao Qin(Durham, UK) Wei-Ngan Chin(NUS)
CS 363 Comparative Programming Languages Semantics.
Refinements to techniques for verifying shape analysis invariants in Coq Kenneth Roe GBO Presentation 9/30/2013 The Johns Hopkins University.
Cristian Gherghina 1, Cristina David 1, Shengchao Qin 2, Wei-Ngan Chin 1 1 National University of Singapore 2 University of Teesside Structured Specifications.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 0 Marktoberdorf.
Symbolic Execution with Abstract Subsumption Checking Saswat Anand College of Computing, Georgia Institute of Technology Corina Păsăreanu QSS, NASA Ames.
1 Automated Verification via Separation Logic Cristian Gherghina (NUS, Singapore) Cristina David(NUS, Singapore) Shengchao Qin(Durham, UK) Wei-Ngan Chin(NUS,
Automated Verification with HIP and SLEEK Asankhaya Sharma.
Lightweight Support for Magic Wands in an Automatic Verifier Malte Schwerhoff and Alexander J. Summers 10 th July 2015, ECOOP, Prague.
List Interface and Linked List Mrs. Furman March 25, 2010.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
CSE Winter 2008 Introduction to Program Verification for-loops; review.
CUTE: A Concolic Unit Testing Engine for C Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
1 Proving program termination Lecture 5 · February 4 th, 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Linked Lists Outline Introduction Self-Referential Structures.
Putting Static Analysis to Work for Verification A Case Study Tal Lev-Ami Thomas Reps Mooly Sagiv Reinhard Wilhelm.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Cooperative Integration of an Interactive Proof Assistant and an Automated Prover Adam Chlipala and George C. Necula University of California, Berkeley.
Dafny An automatic program verifier for functional correctness
“<Fill in your definition here.>”
Formal Methods in Software Engineering 1
Kenneth Roe Scott F. Smith 9/30/2017 The Johns Hopkins University
A Framework for describing recursive data structures
Review & Lab assignments
Verified Subtyping with Traits and Mixins
Dafny An automatic program verifier for functional correctness
Predicate Transformers
CSE 1002 Fundamentals of Software Development 2 More Linked Structures
CUTE: A Concolic Unit Testing Engine for C
Presentation transcript:

Automated Verification with HIP and SLEEK Asankhaya Sharma

Goal Design and build software that is correct by construction Needed: Automatic tools for establishing software correctness Such tools can – Search for standard problems like memory access violations or array index out of bounds – Check if a program does what it is supposed to do with respect to a specification

Why a Need for Automatic Tools?

Let the tool fill in the details

A Tale of Two Tools HIP – Automatically applies a given set of Hoare rules SLEEK – Discharges the proof obligations resulting from the rule of consequence and the frame rule Under development since 2006 – 180k lines of OCaml – Currently 6 PhD students; 3 graduated

Overview code verifier (HIP) separation logic prover (SLEEK) Pre/Post PredicatesLemmas Code range of pure provers … Omega, MONA, Isabelle, Coq, SMT, Redlog, MiniSAT, Mathematica

An Example – List Length struct node{ int val; struct node* next; }; int length(struct node* p) { if(p == NULL) return 0; else return 1 + length(p->next); }

List Predicate Example of Acyclic List : list(x ) x null pointer to memoryspatial conjunction

Syntactic Abbreviation (ASCII) list  == self=null or self::node  _, r   r::list  implicit existential instantiation

Verify with Shape Property struct node{ int val; struct node* next; }; list<> == self=null or self::node *q::list<>; */ int length(struct node* p) requires p::list<> ensures p::list<>; */ { if(p == NULL) return 0; else return 1 + length(p->next); } Predicate Definition Method Pre and Post condition Memory Safety

With Size list  n  == self=null & n=0 or self::node  _, r   r::list  n-1  inv n >= 0 parameter on length of linked list predicate invariant x::ll  5  x null

Verify with Shape and Size int length(struct node* p) requires p::list ensures p::list & res=n; */ { if(p == NULL) return 0; else return 1 + length(p->next); } Memory Safety Length of the List

With Size and Bag list  n,B  == self=null & n=0 & B={} or self::node  v, r   r::list  n-1,B1  & B = B1 U {v} inv n >= 0 & n=|B|

Verify with Shape, Size and Bag int length(struct node* p) requires p::list ensures p::list & res=n; */ { if(p == NULL) return 0; else return 1 + length(p->next); } Memory Safety Length of the List Bag of Values

Automated Verification int length(struct node* p) requires p::list ensures p::list & res=n; */ { if(p == NULL) return 0; // p=null & n = 0 & res = 0 |- p::list & res = n // p::ll & p!=null |- p::node // p::node * q::ll & p!=null & q = r |- r::ll else return 1 + length(p->next); // p::node * q::ll & x!=null & res = 1 + n – 1 |- p::ll & res = n } Pre condition Checking Post condition Checking Memory dereference Checking

SLEEK Automatic Checking of Entailment Custom decision procedure for the spatial fragment (Separation Logic) – Handles user-defined data structures and inductive predicates Uses off-the-shelf provers to discharge: – Linear Arithmetic (using Omega) Also available as a tactic in Coq – Bag Expressions (using MONA) Sound but incomplete

Numerical Examples for SLEEK Checking implications with integer constraints: checkentail x > 5 |- x > 0. checkentail x > 5 |- x < 0. checkentail x > 5 |- x > 6. checkentail x > 1 & y > 1 & r = x + y |- r > 3. SLEEK uses Omega for these examples Valid. InValid. Valid.

List Examples for SLEEK checkentail x::node |- x::list. checkentail x::node |- x::list & B = {17}. checkentail x::node * y::list. checkentail x::list |- x::node. Valid. InValid. Valid.

HIP Automatic checking of pre/post for methods – Handle conditional, loops, methods – With arrays, data structures, dynamic memory allocation – Supports Multiple pre/post specifications, structured specifications, termination specifications Sound but incomplete Automated with the help of SLEEK

Append Example with HIP What should be the specification for the following method ? void append(node* x, node* y) requires ? ensures ? { if(x->next==NULL) x->next=y; else append(x->next,y); }

Append Example with HIP Is the following specification which aims to guarantee memory safety correct? void append(node* x, node* y) requires x::list<> * y::list<> ensures x::list<> { if(x->next==NULL) x->next=y; else append(x->next,y); } No, null pointer dereference possible

Append Example with HIP Correct specification for safety void append(node* x, node* y) requires x::list<> * y::list<> & x!=null ensures x::list<> { if(x->next==NULL) x->next=y; else append(x->next,y); }

Append Example with HIP With size and bag properties void append(node* x, node* y) requires x::list * y::list & x!=null ensures { if(x->next==NULL) x->next=y; else append(x->next,y); } x::list

Multiple Specifications Same method may be called in different calling contexts Verify using different specifications for each scenario Which sorting algorithm may require an append function for two sorted lists ? – Quick Sort (and Merge Sort)

With Bag and Sortedness

Verify with Multiple Specifications void append(node* x, node* y) requires x::list * y::list & x!=null ensures x::list requires x::lsort * y::lsort & x!=null & ∀ a ∈ B1. ∀ b ∈ B2. a { if(x->next==NULL) x->next=y; else append(x->next,y); }

List Segment with Size lseg  p,n  == self=p & n=0 or self::node  _, r   r::lseg  p,n-1  inv n >= 0 x y x::lseg  y,3  y::lseg  x,2 

Circular List with Size x r::lseg  x,2  r x::clist  3  clist  n  == self::node  _, r   r::lseg  self,n-1  inv n >= 1

Use of Multiple Pre/Post void append(node* x, node* y) requires x::list & x != null & x = y ensures requires x::list & x != null ensures { if(x->next==NULL) x->next=y; else append(x->next,y); } x::clist x::lseg

Binary Search Tree How do we express a binary search tree ? tree<> == self=null or self::node * l::tree<> * r::tree<> Shape Property for Tree

Binary Search Tree bst == self=null & B = {} or self::node * l::bst * r::bst & B = {v} U B1 U B2 & ∀ w ∈ B1. v>=w & ∀ w ∈ B2. v<=w Sortedness property

AVL Tree How do we specify height balanced trees ? avl == self=null & B = {} & h = 0 or self::node * l::avl * r::avl & B={v}UB1UB2 & ∀ w ∈ B1.v>=w & ∀ w ∈ B2.v<=w & h = 1 + max(h1,h2) & h2<=h1+1 & h1<=h2+1

Conclusions HIP and SLEEK Verification System – Automated Given pre/post and loop invariants – Modular and scalable Each method verified independently – Expressive From shape, size, bag properties towards functional correctness Total correctness with Termination and Non- Termination proving

Perspectives Hardware community has accepted verification in their design phase Verified software is the future for guarantying high assurance and reliability Many challenges remain on scalability, automation, expressivity, concurrency, inference and higher order programs

Questions? We will try out some examples in Lab tomorrow using TeachHIP TeachHIP is a Web Interface to – Try out HIP and SLEEK without installing any software – Available at Contact –

Further Reading Chin, Wei-Ngan, Cristina David, Huu Hai Nguyen, and Shengchao Qin. "Automated verification of shape, size and bag properties via user-defined predicates in separation logic." Science of Computer Programming 77, no. 9 (2012):