VS 3 : Verification and Synthesis using SMT Solvers SMT Solvers for Program Verification Saurabh Srivastava * Sumit Gulwani ** Jeffrey S. Foster * * University.

Slides:



Advertisements
Similar presentations
Assertion Checking over Combined Abstraction of Linear Arithmetic and Uninterpreted Functions Sumit Gulwani Microsoft Research, Redmond Ashish Tiwari SRI.
Advertisements

Logical Abstract Interpretation Sumit Gulwani Microsoft Research, Redmond.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Constraint-based Invariant Inference over Predicate Abstraction Sumit Gulwani Ramarathnam Venkatesan Microsoft Research, Redmond Saurabh Srivastava University.
From Verification to Synthesis Sumit Gulwani Microsoft Research, Redmond August 2013 Marktoberdorf Summer School Lectures: Part 1.
SORTING Lecture 12B CS2110 – Spring InsertionSort 2 pre: b 0 b.length ? post: b 0 b.length sorted inv: or: b[0..i-1] is sorted b 0 i b.length sorted.
February 26, 2015Applied Discrete Mathematics Week 5: Mathematical Reasoning 1 Addition of Integers Example: Add a = (1110) 2 and b = (1011) 2. a 0 + b.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Inferring Disjunctive Postconditions Corneliu Popeea and Wei-Ngan Chin School of Computing National University of Singapore - ASIAN
Discussion #33 Adjacency Matrices. Topics Adjacency matrix for a directed graph Reachability Algorithmic Complexity and Correctness –Big Oh –Proofs of.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 5.
Program Analysis as Constraint Solving Sumit Gulwani (MSR Redmond) Ramarathnam Venkatesan (MSR Redmond) Saurabh Srivastava (Univ. of Maryland) TexPoint.
Technology from seed Weakest Precondition Synthesis for Compiler Optimizations Nuno Lopes and José Monteiro.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
Predicate Transformers
Technology from seed Automatic Synthesis of Weakest Preconditions for Compiler Optimizations Nuno Lopes Advisor: José Monteiro.
Sorting Algorithms. Motivation Example: Phone Book Searching Example: Phone Book Searching If the phone book was in random order, we would probably never.
Lifting Abstract Interpreters to Quantified Logical Domains Sumit Gulwani, MSR Bill McCloskey, UCB Ashish Tiwari, SRI 1.
Program Verification as Probabilistic Inference Sumit Gulwani Nebojsa Jojic Microsoft Research, Redmond.
Sorting. Input: A sequence of n numbers a 1, …, a n Output: A reordering a 1 ’, …, a n ’, such that a 1 ’ < … < a n ’
Simple Sorting Algorithms
Fall 2008 Insertion Sort – review of loop invariants.
Program Verification using Templates over Predicate Abstraction Saurabh Srivastava University of Maryland, College Park Sumit Gulwani Microsoft Research,
Analysis of Algorithms CS 477/677
Lecture 4 Discrete Mathematics Harper Langston. Algorithms Algorithm is step-by-step method for performing some action Cost of statements execution –Simple.
CS 202, Spring 2003 Fundamental Structures of Computer Science II Bilkent University1 Sorting CS 202 – Fundamental Structures of Computer Science II Bilkent.
Value Iteration 0: step 0. Insertion Sort Array index67 Iteration i. Repeatedly swap element i with.
Simple Sorting Algorithms. 2 Bubble sort Compare each element (except the last one) with its neighbor to the right If they are out of order, swap them.
Simple Sorting Algorithms. 2 Outline We are going to look at three simple sorting techniques: Bubble Sort, Selection Sort, and Insertion Sort We are going.
Lecture 2 MAS 714 Hartmut Klauck
From Program Verification to Program Synthesis Saurabh Srivastava * Sumit Gulwani ♯ Jeffrey S. Foster * * University of Maryland, College Park ♯ Microsoft.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Part 2. Searching Arrays Looking for a specific element in an array E.g., whether a certain score (85) is in a list of scores Linear search Binary search.
Jessie Zhao Course page: 1.
26 Sep 2014Lecture 3 1. Last lecture: Experimental observation & prediction Cost models: Counting the number of executions of Every single kind of command.
Searching. The process used to find the location of a target among a list of objects Searching an array finds the index of first element in an array containing.
Examples using Arrays. Summing Squares Problem: To compute the sum of the squares of N numbers N is given N values are also given These should be read.
September 17, 2001 Algorithms and Data Structures Lecture II Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Data Structure Introduction.
Program Verification and Synthesis using Templates over Predicate Abstraction Saurabh Srivastava # Sumit Gulwani * Jeffrey S. Foster # # University of.
September 9, Algorithms and Data Structures Lecture II Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Review 1 Selection Sort Selection Sort Algorithm Time Complexity Best case Average case Worst case Examples.
1/6/20161 CS 3343: Analysis of Algorithms Lecture 2: Asymptotic Notations.
1 UNIT-I BRUTE FORCE ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 3:
2IS80 Fundamentals of Informatics Fall 2015 Lecture 6: Sorting and Searching.
1 Ch. 2: Getting Started. 2 About this lecture Study a few simple algorithms for sorting – Insertion Sort – Selection Sort (Exercise) – Merge Sort Show.
Lecture 2 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Cs7100(Prasad)L18-9WP1 Axiomatic Semantics Predicate Transformers.
Computer Science 1620 Sorting. cases exist where we would like our data to be in ascending (descending order) binary searching printing purposes selection.
CSC317 1 So far so good, but can we do better? Yes, cheaper by halves... orkbook/cheaperbyhalf.html.
1/20 Arrays Changki PSWLAB Arrays Daniel Kroening and Ofer Strichman Decision Procedure.
1 Computer Algorithms Tutorial 2 Mathematical Induction Some of these slides are courtesy of D. Plaisted et al, UNC and M. Nicolescu, UNR.
September 18, Algorithms and Data Structures Lecture II Simonas Šaltenis Aalborg University
Formal Verification – Robust and Efficient Code Lecture 1
CS6045: Advanced Algorithms Sorting Algorithms. Sorting Input: sequence of numbers Output: a sorted sequence.
ALGORITHMS PROVING ALGORITHMS (PROGRAMS) CORRECT WITH AND WITHOUT INDUCTION.
Lecture 2 Algorithm Analysis
Growth of Functions & Algorithms
CS 3343: Analysis of Algorithms
Analysis of Algorithms CS 477/677
Analysis of Bubble Sort and Loop Invariant
CS 220: Discrete Structures and their Applications
Sorting … and Insertion Sort.
Predicate Transformers
Simple Sorting Algorithms
Analysis of Algorithms
Simple Sorting Algorithms
Algorithms.
Discrete Mathematics CS 2610
Algorithms and Data Structures Lecture II
Presentation transcript:

VS 3 : Verification and Synthesis using SMT Solvers SMT Solvers for Program Verification Saurabh Srivastava * Sumit Gulwani ** Jeffrey S. Foster * * University of Maryland, College Park ** Microsoft Research, Redmond Saurabh Srivastava * Sumit Gulwani ** Jeffrey S. Foster * * University of Maryland, College Park ** Microsoft Research, Redmond

What VS 3 will let you do! A. Discover invariants with arbitrary quantification and boolean structure – ∀ : E.g. Sortedness – ∀∃ : E.g. Permutation.. ∀ k 1,k 2 k1k1 k2k2 j j.. A old ∀k∃j∀k∃j A new k Selection Sort: for i = 0…n { for j = i…n { find min index } if (min ≠ i) swap A[min], A[i] } for i = 0…n { for j = i…n { find min index } if (min ≠ i) swap A[min], A[i] }

Selection Sort: What VS 3 will let you do! A. Discover invariants with arbitrary quantification and boolean structure – ∀ : E.g. Sortedness – ∀∃ : E.g. Permutation.. ∀ k 1,k 2 k1k1 k2k2 j j.. A old ∀k∃j∀k∃j A new k Output array i<n j<n Find min index if (min != i) swap A[i], A[min] i:=0 j:=i

Selection Sort: Output array i<n j<n Find min index if (min != i) swap A[i], A[min] i:=0 j:=i Verification: Proving Programs Correct I outer I inner Sortedness Permutation Sortedness Permutation Output state true Input state The difficult task is program state (invariant) inference: I inner, I outer, Input state, Output state

Selection Sort: Output array i<n j<n Find min index if (min != i) swap A[i], A[min] i:=0 j:=i Verification: Proving Programs Correct Sortedness Permutation Sortedness Permutation Output state true Input state The difficult task is program state (invariant) inference: I inner, I outer, Input state, Output state ∀ k 1,k 2 : 0≤k 1 A[k 1 ] ≤A[k 2 ] i < j i ≤ min < n ∀ k 2 : 0≤k 2 ∧ i≤k 2 A[min] ≤A[k 2 ] ∀ k 1,k 2 : 0≤k 1 A[k 1 ] ≤A[k 2 ]

Selection Sort: Output array i<n j<n Find min index if (min != i) swap A[i], A[min] i:=0 j:=i Verification: Proving Programs Correct Sortedness Permutation Sortedness Permutation Output state true Input state The difficult task is program state (invariant) inference: I inner, I outer, Input state, Output state ∀ k 1,k 2 : 0≤k 1 A[k 1 ] ≤A[k 2 ] i < j i ≤ min < n ∀ k 1,k 2 : 0≤k 1 A[k 1 ] ≤A[k 2 ] ∀ k 2 : 0≤k 2 ∧ i≤k 2 A[min] ≤A[k 2 ] ∀ k 2 : ( ) => A[min] ≤A[k 2 ] ∀ k 1,k 2 : ( ) => A[k 1 ] ≤A[k 2 ] ( ) ∀ k 1,k 2 : ( ) => A[k 1 ] ≤A[k 2 ]

Selection Sort: Output array i<n j<n Find min index if (min != i) swap A[i], A[min] i:=0 j:=i Verification: Proving Programs Correct Sortedness Permutation Sortedness Permutation Output state true Input state The difficult task is program state (invariant) inference: I inner, I outer, Input state, Output state ∀ k 1,k 2 : 0≤k 1 A[k 1 ] ≤A[k 2 ] ∀ k 2 : ( ) => A[min] ≤A[k 2 ] ∀ k 1,k 2 : ( ) => A[k 1 ] ≤A[k 2 ] ( ) ∀ k 1,k 2 : ( ) => A[k 1 ] ≤A[k 2 ] ∀ k 2 : ( ) => A[min] ≤A[k 2 ] ( )

Bubble Sort: Output array i>0 j<i if (a[j] > a[j+1]) swap A[j], A[j+1] i:=n-1 j:=0 Verification: Proving Programs Correct ∀ k 1,k 2 : 0≤k 1 A[k 1 ] ≤A[k 2 ] ∀ k 1,k 2 : ( ) => A[k 1 ] ≤A[k 2 ] ∀ k 1,k 2 : ( ) => A[k 1 ] ≤A[k 2 ] ( ) ∀ k 1,k 2 : ( ) => A[k 1 ] ≤A[k 2 ] ∀ k 1,k 2 : ( ) => A[k 1 ] ≤A[k 2 ] ( )

User Input:Templates and Predicates Templates – Intuitive and simple Depending on the property being proved; form straight-forward Limited to the quantification and disjunction Unknown holes Relational operator, ≥ … Relational operator, ≥ … Program variables, array elements Program variables, array elements – E.g., {i j, i≤j, i≥j… } – Enumerate predicates of the form Predicate Abstraction

Tool architecture C Program Templates for invariants Predicate Sets CFG Cut-Set Preconditions Postconditions Invariants Preconditions Postconditions Invariants Microsoft’s Phoenix Compiler VS3 SMT Solver Verification Conditions Iterative Fixed-point GFP/LFP Constraint- based Fixed-Point Candidate Solutions Boolean Constraint SAT Solver

Fixed-point Computation Constraint-based (VMCAI’09) – Separately encode each VC as SAT constraint Local constraints  SAT clauses – Use SAT solver to do fixed-point computation – Compare against trivial approach: 1.6e14 minutes Iterative (PLDI’09) – Facts do not form a lattice, but power-set does – We ensure that if there exists an invariant we find it – Intelligent lattice search: SMT solver for tx-functions

Weakest Preconditions k1k1 k2k2 < Weakest conditions on input? Output array i<n j<n Find min index if (min != i) swap A[i], A[min] i:=0 j:=i Worst case behavior: swap every time it can

Example analyses Tool can verify: – Sorting algorithms: Selection, Insertion, Bubble, Quick, Merge Sort – Properties Output is Sorted Output contains all and only elements from the input Tool can infer preconditions: – Worst case input (precondition) for sorting: Reverse sorted array, all but Selection Sort Selection Sort: sorted array except last elem is smallest – Inputs for functional correctness: Binary search requires sorted array Merge in merge sort expect sorted inputs Missing initializers

Selection Sort: Output array i<n j<n Find min index if (min != i) swap A[i], A[min] i:=0 j:=i Demo: Selection Sort Sortedness Permutation Sortedness Permutation Output state true Input state The difficult task is program state (invariant) inference: I inner, I outer, Input state, Output state ∀ k 1,k 2 : 0≤k 1 A[k 1 ] ≤A[k 2 ] i < j i ≤ min < n ∀ k 2 : 0≤k 2 ∧ i≤k 2 A[min] ≤A[k 2 ] ∀ k 1,k 2 : 0≤k 1 A[k 1 ] ≤A[k 2 ]

Demo: Program

Demo: Output

Conclusions VS 3 : Verification tool over predicate abstraction Verification – Can infer quantified invariants Maximally-weak preconditions Builds on SMT Solvers, so exploits their power Project Webpage Future work

Recent extension: Synthesis Verification tool for quantified invariants – Reasoning about full functional specifications possible What if we had missing program fragments? – Still possible to verify if we allow the tool to plug-in equality predicates over program variables – Equality predicates translated to statements We can synthesize – Strassen’s Matrix Multiplication! – Sorting algorithms!