SMT and Its Application in Software Verification (Part II) Yu-Fang Chen IIS, Academia Sinica Based on the slides of Barrett, Sanjit, Kroening, Rummer,

Slides:



Advertisements
Similar presentations
Model Checking Base on Interoplation
Advertisements

A practical and complete approach to predicate abstraction Ranjit Jhala UCSD Ken McMillan Cadence Berkeley Labs.
Quantified Invariant Generation using an Interpolating Saturation Prover Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Consequence Generation, Interpolants, and Invariant Discovery Ken McMillan Cadence Berkeley Labs.
SAT, Interpolants and Software Model Checking Ken McMillan Cadence Berkeley Labs.
Quantified Invariant Generation using an Interpolating Saturation Prover Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
50.530: Software Engineering
50.530: Software Engineering Sun Jun SUTD. Week 10: Invariant Generation.
SSA.
A Separator Theorem for Graphs with an Excluded Minor and its Applications Paul Seymour Noga Alon Robin Thomas Lecturer : Daniel Motil.
Interpolation and Widening Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A.
Interpolants from Z3 proofs Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Software Verification with BLAST Tom Henzinger Ranjit Jhala Rupak Majumdar.
Proofs and Counterexamples Rupak Majumdar. In the good old days… Decision Procedure  yes no.
What Can the SAT Experience Teach Us About Abstraction? Ken McMillan Cadence Berkeley Labs.
BLAST-A Model Checker for C Developed by Thomas A. Henzinger (EPFL) Rupak Majumdar (UC Los Angeles) Ranjit Jhala (UC San Diego) Dirk Beyer (Simon Fraser.
SAT and Model Checking. Bounded Model Checking (BMC) A.I. Planning problems: can we reach a desired state in k steps? Verification of safety properties:
The Software Model Checker BLAST by Dirk Beyer, Thomas A. Henzinger, Ranjit Jhala and Rupak Majumdar Presented by Yunho Kim Provable Software Lab, KAIST.
Using Statically Computed Invariants Inside the Predicate Abstraction and Refinement Loop Himanshu Jain Franjo Ivančić Aarti Gupta Ilya Shlyakhter Chao.
CS5371 Theory of Computation
Interpolants [Craig 1957] G(y,z) F(x,y)
Program Verification by Lazy Abstraction Ranjit Jhala UC San Diego Lecture 1 With: Tom Henzinger, Rupak Majumdar, Ken McMillan, Gregoire Sutre.
Counter Example Guided Refinement CEGAR Mooly Sagiv.
Formal Verification Group © Copyright IBM Corporation 2008 IBM Haifa Labs SAT-based unbounded model checking using interpolation Based on a paper “Interpolation.
Lazy Abstraction with Interpolants Yakir Vizel (based on the work and slides of K. L. McMillan at CAV06)
Software Verification with BLAST Tom Henzinger Ranjit Jhala Rupak Majumdar.
Lazy Abstraction Tom Henzinger Ranjit Jhala Rupak Majumdar Grégoire Sutre.
Building Suffix Trees in O(m) time Weiner had first linear time algorithm in 1973 McCreight developed a more space efficient algorithm in 1976 Ukkonen.
Lazy Abstraction Lecture 3 : Partial Analysis Ranjit Jhala UC San Diego With: Tom Henzinger, Rupak Majumdar, Ken McMillan, Gregoire Sutre.
Program Verification by Lazy Abstraction Ranjit Jhala UC San Diego Lecture 1 With: Tom Henzinger, Rupak Majumdar, Ken McMillan, Gregoire Sutre, Adam Chlipala.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The trees.
50.530: Software Engineering
By: Pashootan Vaezipoor Path Invariant Simon Fraser University – Spring 09.
Verifiable Programming Reason about imperative sequential programs such as Java programs Imperative program –defines state space defined by collection.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
SMT and Its Application in Software Verification Yu-Fang Chen IIS, Academia Sinica Based on the slides of Barrett, Sanjit, Kroening, Rummer, Sinha, Jhala,
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
Quantified Invariant Generation using an Interpolating Saturation Prover Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Lazy Abstraction Jinseong Jeon ARCS, KAIST CS750b, KAIST2/26 References Lazy Abstraction –Thomas A. Henzinger et al., POPL ’02 Software verification.
Lazy Annotation for Program Testing and Verification Speaker: Chen-Hsuan Adonis Lin Advisor: Jie-Hong Roland Jiang November 26,
Discrete Structures Trees (Ch. 11)
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 12: Abstract Interpretation IV Roman Manevich Ben-Gurion University.
Automated Debugging with Error Invariants TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAA A A A AA A A Chanseok Oh.
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
Lazy Annotation for Program Testing and Verification (Supplementary Materials) Speaker: Chen-Hsuan Adonis Lin Advisor: Jie-Hong Roland Jiang December 3,
Great Theoretical Ideas in Computer Science for Some.
Counter Example Guided Refinement CEGAR Mooly Sagiv.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
#1 Having a BLAST with SLAM. #2 Software Model Checking via Counter-Example Guided Abstraction Refinement Topic: Software Model Checking via Counter-Example.
The software model checker BLAST Dirk Beyer, Thomas A. Henzinger, Ranjit Jhala, Rupak Majumdar Presented by Yunho Kim TexPoint fonts used in EMF. Read.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
Having a BLAST with SLAM
Modeling Arithmetic, Computation, and Languages
SS 2017 Software Verification Software Model Checking 2 - Parallelism
Abstraction Transformation & Heuristics
What is the next line of the proof?
Lifting Propositional Interpolants to the Word-Level
Abstractions from Proofs
Program Verification by Lazy Abstraction
Abstraction, Verification & Refinement
Software Verification with BLAST
Predicate Abstraction
Richard Anderson Lecture 5 Graph Theory
50.530: Software Engineering
Course: CS60030 Formal Systems
Presentation transcript:

SMT and Its Application in Software Verification (Part II) Yu-Fang Chen IIS, Academia Sinica Based on the slides of Barrett, Sanjit, Kroening, Rummer, Sinha, Jhala, and Majumdar, McMillan

Lazy abstraction -- an example do{ lock(); old = new; if(*){ unlock(); new++; } } while (new != old); program fragment L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph

Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T

1 L=0 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T Compute Post (T, L=0)= T[L/L’] Æ L=0[L/L’] = (L=0) Make Abstraction (L=0)  T Pass Replace all free occurrences of L in the formula with L’

1 L=0 T 2 [L!=0] Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T Compute Post (T, [L!=0])= T Æ (L!=0) = (L!=0) ERROR state reached!

1 L=0 T 2 [L!=0] Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T Compute Post (T, [L!=0])= T Æ (L!=0) = (L!=0) ERROR state reached! T TL=0 L!=0 [L!=0]

1 L=0 T 2 [L!=0] Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T Compute Post (T, [L!=0])= T Æ (L!=0) = (L!=0) ERROR state reached! T TL=0 L!=0 [L!=0] L!=0 WPre(L!=0, [L!=0]) = (L!=0)

1 L=0 T 2 [L!=0] Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T Compute Post (T, [L!=0])= T Æ (L!=0) = (L!=0) ERROR state reached! L=0 T L!=0 [L!=0] L!=0 WPre(L!=0, [L!=0]) = (L!=0) Compute Craig Interpolant: (L=0) 1. (L=0)  (L=0) 2. (L=0) Æ (L=0) is UNSAT 3. Use only share var. of (L=0) and (L!=0)

1 L=0 2 [L!=0] Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T Compute Post (T, [L!=0])= T Æ (L!=0) = (L!=0) ERROR state reached! L=0 T L!=0 [L!=0] L!=0 WPre(L!=0, [L!=0]) = (L!=0) Compute Craig Interpolant: (L=0) 1. (L=0)  (L=0) 2. (L=0) Æ (L=0) is UNSAT 3. Use only share var. of (L=0) and (L!=0) F

3 L=1; old=new L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Compute Post (L=0, L=1) = (L=0)[L/L’] Æ L=1[L/L’] = (L’=0 Æ L=1) Compute Post (L’=0 Æ L=1, old=new) = (L’=0 Æ L=1)[old/old’] Æ old=new[old/old’] = L’=0 Æ L=1 Æ old=new Make Abstraction (L’=0 Æ L=1 Æ old=new)  (L!=0) Pass (L’=0 Æ L=1 Æ old=new)  (L=0) Not Passed

4 L=0; new++ L=0 3 L=1; old=new L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Compute Post (L!=0, L=0) = (L!=0)[L/L’] Æ L=0[L/L’] = (L’!=0 Æ L=0) Compute Post (L’!=0 Æ (L=0), new=new+1) = (L’!=0 Æ L=0)[new/new’] Æ new=(new+1)[new/new’] = (L’!=0 Æ L=0 Æ new=new’+1) Make Abstraction (L’!=0 Æ L=0 Æ new=new’+1)  (L!=0) Not Passed (L’!=0 Æ L=0 Æ new=new’+1)  (L=0) Pass

5 [new!=old] L=0 4 L=0; new++ L=0 3 L=1; old=new L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Compute Post (L=0, [new!=old]) = (L=0 Æ new!=old) Make Abstraction (L=0 Æ new!=old)  (L!=0) Not Passed (L=0 Æ new!=old)  (L=0) Pass

5 [new!=old] L=0 4 L=0; new++ L=0 3 L=1; old=new L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Covering: state 5 is subsumed by state 1. L=1  L=1 Pass

L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T Compute Post (L=0, [new==old]) = (L=0 Æ new==old) Make Abstraction (L=0 Æ new!=old)  (L!=0) Not Passed (L=0 Æ new!=old)  (L=0) Pass

L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T No Actions 8 L!=0

Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] Compute Post (L!=0, [new==old]) = (L!=0 Æ new==old) Make Abstraction (L!=0 Æ new==old)  (L!=0) Pass (L!=0 Æ new==old)  (L=0) Not Passed

L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] Compute Post (L!=0, [new!=old]) = (L!=0 Æ new!=old) Make Abstraction (L!=0 Æ new!=old)  (L!=0) Pass (L!=0 Æ new!=old)  (L=0) Not Passed 10 [new!=old] L!=0

Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] Compute Post (L!=0, [L!=0]) = (L!=0 Æ L!0) ERROR state reached! 10 [new!=old] L!=0 11 [L!=0]

L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] 10 [new!=old] L!=0 11 [L!=0] L’=0 Æ L=1 Æ old=new L=0 T L=1 old=new L!=0 [new!=old] L!=0 Æ old!=new L!=0 [L!=0]

L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] 10 [new!=old] L!=0 11 [L!=0] L’=0 Æ L=1 Æ old=new L=0 T L=1 old=new L!=0 [new!=old] L!=0 Æ old!=new L!=0 [L!=0] L!=0 L!=0 Æ old!=new

L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] 10 [new!=old] L!=0 11 [L!=0] L’=0 Æ L=1 Æ old=new L=0 T L=1 old=new L!=0 [new!=old] L!=0 Æ old!=new L!=0 [L!=0] L!=0 L!=0 Æ old!=new

L!=0 Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] 10 [new!=old] L!=0 11 [L!=0] L’=0 Æ L=1 Æ old=new L=0 T L=1 old=new L!=0 [new!=old] L!=0 Æ old!=new L!=0 [L!=0] L!=0 L!=0 Æ old!=new

L!=0 Æ old =new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] 10 [new!=old] L!=0 11 [L!=0] L’=0 Æ L=1 Æ old=new L=0 T L=1 old=new L!=0 Æ old=new L!=0 [new!=old] L!=0 Æ old!=new L!=0 [L!=0] L!=0 L!=0 Æ old!=new

L!=0 Æ old =new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 7 [new==old] L=0 T 8 L!=0 9 [new==old] 10 [new!=old] L!=0 11 [L!=0] L’=0 Æ L=1 Æ old=new L=0 T L=1 old=new L!=0 Æ old=new L!=0 [new!=old] L!=0 Æ old!=new L!=0 [L!=0] L!=0 L!=0 Æ old!=new Remove all of its children

3 L=1; old=new L!=0 Æ old =new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T

4 L=0; new++ L=0 Æ old !=new 3 L=1; old=new L!=0 Æ old =new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Compute Post (L!=0 Æ old =new, L=0) = (L!=0 Æ old=new)[L/L’] Æ L=0[L/L’] = (L’!=0 Æ old=new Æ L=0) Compute Post (L’!=0 Æ old=new Æ (L=0), new=new+1) = (L’!=0 Æ old=new Æ L=0)[new/new’] Æ new=(new+1)[new/new’] = (L’!=0 Æ old=new’ Æ L=0 Æ new=new’+1) Make Abstraction (L’!=0 Æ old=new’ Æ L=0 Æ new=new’+1)  (L!=0) Not Passed (L’!=0 Æ old=new’ Æ L=0 Æ new=new’+1)  (L=0) Pass (L’!=0 Æ old=new’ Æ L=0 Æ new=new’+1)  (old=new) Not Passed (L’!=0 Æ old=new’ Æ L=0 Æ new=new’+1)  (old!=new) Pass

5 [new!=old] L=0 Æ old!=new 4 L=0; new++ L=0 Æ old =new 3 L=1; old=new L!=0 Æ old=new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Compute Post (L=0 Æ old!=new, [new!=old]) = (L=0 Æ new!=old) Make Abstraction (L=0 Æ new!=old)  (L!=0) Not Passed (L=0 Æ new!=old)  (L=0) Pass (L=0 Æ new!=old)  (old=new) Not Passed (L=0 Æ new!=old)  (old!=new) Pass

5 [new!=old] L=0 Æ old!=new 4 L=0; new++ L=0 Æ old =new 3 L=1; old=new L!=0 Æ old=new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Covering: state 5 is subsumed by state 1. L=1 Æ old!=new  L=1 Pass

L!=0 Æ old=new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 L=0 Æ old!=new L=0 Æ old =new 7 [new==old] L=0 Æ old=new T Compute Post (L=0, [new==old]) = (L=0 Æ new=old) Make Abstraction (L=0 Æ new=old)  (L!=0) Not Passed (L=0 Æ new=old)  (L=0) Pass (L=0 Æ new=old)  (new!=old) Not Passed (L=0 Æ new=old)  (new=old) Pass

L!=0 Æ old=new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 L=0 Æ old!=new L=0 Æ old =new 7 [new==old] L=0 Æ old=new T No Actions 8 L!=0 Æ old=new

Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 L=0 Æ old!=new L=0 Æ old =new 7 [new==old] L=0 Æ old=new T 8 L!=0 Æ old=new 9 L!=0 Æ old=new [new==old] Compute Post (L!=0 Æ new=old, [new==old]) = (L!=0 Æ new=old) Make Abstraction (L!=0 Æ new=old)  (L!=0) Pass (L!=0 Æ new=old)  (L=0) Not Passed (L!=0 Æ new=old)  (old=new) Pass (L!=0 Æ new=old)  (old!=new) Not Passed

L!=0 Æ old=new Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 L=0 Æ old!=new L=0 Æ old =new 7 [new==old] L=0 Æ old=new T 8 L!=0 Æ old=new 9 L!=0 Æ old=new [new==old] Compute Post (L!=0 Æ new=old, [new!=old]) = (L!=0 Æ new=old Æ new!=old ) = false 10 [new!=old] F

Another Approach: The IMPACT method Kenneth L. McMillan: Lazy Abstraction with Interpolants. CAV 2006:

Interpolation Lemma (Craig,57)

Interpolation Lemma Notation: L (  ) is the set of FO formulas over the symbols of  (Craig,57)

Interpolation Lemma Notation: L (  ) is the set of FO formulas over the symbols of  If A  B = false, there exists an interpolant A' for (A,B) such that: A  A' A'  B = false A' 2 L (A) Å L (B) (Craig,57)

Interpolation Lemma Notation: L (  ) is the set of FO formulas over the symbols of  If A  B = false, there exists an interpolant A' for (A,B) such that: A  A' A'  B = false A' 2 L (A) Å L (B) Example: – A = p  q, B =  q  r, A' = q (Craig,57)

Interpolation Lemma Notation: L (  ) is the set of FO formulas over the symbols of  If A  B = false, there exists an interpolant A' for (A,B) such that: A  A' A'  B = false A' 2 L (A) Å L (B) Example: – A = p  q, B =  q  r, A' = q Interpolants from proofs – in certain quantifier-free theories, we can obtain an interpolant for a pair A,B from a refutation in linear time. [McMillan 05] – in particular, we can have linear arithmetic,uninterpreted functions, and restricted use of arrays (Craig,57)

Interpolants for sequences

Let A 1...A n be a sequence of formulas

Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A’ 0...A’ n is an interpolant for A 1...A n when

Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A’ 0...A’ n is an interpolant for A 1...A n when – A’ 0 = True

Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A’ 0...A’ n is an interpolant for A 1...A n when – A’ 0 = True – A’ i -1 Æ A i ) A’ i, for i = 1..n

Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A’ 0...A’ n is an interpolant for A 1...A n when – A’ 0 = True – A’ i -1 Æ A i ) A’ i, for i = 1..n – A n = False

Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A’ 0...A’ n is an interpolant for A 1...A n when – A’ 0 = True – A’ i -1 Æ A i ) A’ i, for i = 1..n – A n = False – and finally, A’ i 2 L (A 1...A i ) Å L (A i+1...A n )

Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A’ 0...A’ n is an interpolant for A 1...A n when – A’ 0 = True – A’ i -1 Æ A i ) A’ i, for i = 1..n – A n = False – and finally, A’ i 2 L (A 1...A i ) Å L (A i+1...A n ) A1A1 A2A2 A3A3 AkAk...

Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A’ 0...A’ n is an interpolant for A 1...A n when – A’ 0 = True – A’ i -1 Æ A i ) A’ i, for i = 1..n – A n = False – and finally, A’ i 2 L (A 1...A i ) Å L (A i+1...A n ) A1A1 A2A2 A3A3 AkAk... A' 1 A' 2 A' 3 A' k-1... TrueFalse ))))

Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A’ 0...A’ n is an interpolant for A 1...A n when – A’ 0 = True – A’ i -1 Æ A i ) A’ i, for i = 1..n – A n = False – and finally, A’ i 2 L (A 1...A i ) Å L (A i+1...A n ) A1A1 A2A2 A3A3 AkAk... A' 1 A' 2 A' 3 A' k-1... TrueFalse )))) In other words, the interpolant is a structured refutation of A 1...A n

Interpolants as Floyd-Hoare proofs

x=y; y++; [x=y]

Interpolants as Floyd-Hoare proofs x=y; y++; [x=y] x 1 = y 0 y 1 =y 0 +1 x1y1x1y1

Interpolants as Floyd-Hoare proofs False x 1 =y 0 True y 1 >x 1 x=y; y++; [x=y] x 1 = y 0 y 1 =y 0 +1 x1y1x1y1

Interpolants as Floyd-Hoare proofs False x 1 =y 0 True y 1 >x 1 ) ) ) 1. Each formula implies the next x=y; y++; [x=y] x 1 = y 0 y 1 =y 0 +1 x1y1x1y1

Interpolants as Floyd-Hoare proofs False x 1 =y 0 True y 1 >x 1 ) ) ) 1. Each formula implies the next 2. Each is over common symbols of prefix and suffix x=y; y++; [x=y] x 1 = y 0 y 1 =y 0 +1 x1y1x1y1

Interpolants as Floyd-Hoare proofs False x 1 =y 0 True y 1 >x 1 ) ) ) 1. Each formula implies the next 2. Each is over common symbols of prefix and suffix 3. Begins with true, ends with false x=y; y++; [x=y] x 1 = y 0 y 1 =y 0 +1 x1y1x1y1

Interpolants as Floyd-Hoare proofs False x 1 =y 0 True y 1 >x 1 ) ) ) 1. Each formula implies the next 2. Each is over common symbols of prefix and suffix 3. Begins with true, ends with false Path refinement procedure SSA sequence Prover Interpolation Path Refinement proof structured proof x=y; y++; [x=y] x 1 = y 0 y 1 =y 0 +1 x1y1x1y1

Lazy abstraction -- an example do{ lock(); old = new; if(*){ unlock; new++; } } while (new != old); program fragment

Lazy abstraction -- an example do{ lock(); old = new; if(*){ unlock; new++; } } while (new != old); program fragment L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph

Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph

Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T

1 L=0 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T

1 L=0 T 2 [L!=0] T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T Interpolant for (L 0 =0) Æ (L 0 !=0) =?

1 L=0 T 2 [L!=0] T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T F L=0 Label error state with false, by refining labels on path T L 0 =0 F Interpolant for (L 0 =0) Æ (L 0 !=0) =?

Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T

3 L=1; old=new T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T

4 L=0; new++ T 3 L=1; old=new T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T

5 [new!=old] T 4 L=0; new++ T 3 L=1; old=new T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T

6 [L!=0] T 5 [new!=old] T 4 L=0; new++ T 3 L=1; old=new T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Interpolant for (L 0 =0) Æ (L 1 =1 Æ old 0 =new 0 ) Æ (L 2 =0 Æ new 1 =new 0 +1) Æ (new 1 !=old 0 ) Æ (L 2 !=0) =?

6 [L!=0] T 5 [new!=old] T 4 L=0; new++ T 3 L=1; old=new T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 T Interpolant for (L 0 =0) Æ (L 1 =1 Æ old 0 =new 0 ) Æ (L 2 =0 Æ new 1 =new 0 +1) Æ (new 1 !=old 0 ) Æ (L 2 !=0) =? T L 2 =0 T T F

6 [L!=0] T 5 [new!=old] T 4 L=0; new++ T 3 L=1; old=new T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 F T Interpolant for (L 0 =0) Æ (L 1 =1 Æ old 0 =new 0 ) Æ (L 2 =0 Æ new 1 =new 0 +1) Æ (new 1 !=old 0 ) Æ (L 2 !=0) =? T L 2 =0 T T F Comes from L=0 Æ T

6 [L!=0] T 5 [new!=old] T 4 L=0; new++ T 3 L=1; old=new T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 F T Covering: state 5 is subsumed by state 1.

T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 T

T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T T

T 8 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T T

T 8 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T T 9 T

T 10 [new!=old] T 8 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T T 9 T

T 11 [L!=0] T 10 [new!=old] T 8 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T T 9 T

T 11 [L!=0] T 10 [new!=old] T 8 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T old=new F F T 9 T

T 11 [L!=0] T 10 [new!=old] T 8 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T old=new F F T Another cover. Unwinding is now complete. 9 T

Covering step If  (x) )  (y)... – add covering arc x B y – remove all z B w for w descendant of y

Covering step If  (x) )  (y)... – add covering arc x B y – remove all z B w for w descendant of y x · y x=y

Covering step If  (y) )  (x)... – add covering arc x B y – remove all w B z for w descendant of y x · y x=y X

Covering step x · y x=y X We restrict covers to be descending in a suitable total order on vertices. This prevents covering from diverging. If  (y) )  (x)... – add covering arc x B y – remove all w B z for w descendant of y

Refinement step Label an error vertex False by refining the path to that vertex with an interpolant for that path. By refining with interpolants, we avoid predicate image computation. T T T T T T T x = 0 [x=y] [x  y] y++ [y=0] y=2

Refinement step Label an error vertex False by refining the path to that vertex with an interpolant for that path. By refining with interpolants, we avoid predicate image computation. T T T T T T T x = 0 [x=y] [x  y] y++ [y=0] y=2 x=0 y=0 y0y0 F X

Refinement step Label an error vertex False by refining the path to that vertex with an interpolant for that path. By refining with interpolants, we avoid predicate image computation. T T T T T T T x = 0 [x=y] [x  y] y++ [y=0] y=2 x=0 y=0 y0y0 F X Refinement may remove covers

Forced cover Try to refine a sub-path to force a cover – show that path from nearest common ancestor of x,y proves  (x) at y T T T T T T T x = 0 [x=y] [x  y] y++ [y=0] y=2 x=0 y=0 y0y0 F Forced cover allow us to efficiently handle nested control structure

Forced cover Try to refine a sub-path to force a cover – show that path from nearest common ancestor of x,y proves  (x) at y T T T T T T T x = 0 [x=y] [x  y] y++ [y=0] y=2 x=0 y=0 y0y0 F refine this path y0y0 Forced cover allow us to efficiently handle nested control structure

Safe and complete An unwinding is – safe if every error vertex is labeled False – complete if every nonterminal leaf is covered T 10 [L!=0] T 9 [new!=old] T 8 T L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T old=new F F T... Theorem: A CFG with a safe complete unwinding is safe. 9 T

Unwinding steps Three basic operations: – Expand a nonterminal leaf – Cover: add a covering arc – Refine: strengthen labels along a path so error vertex labeled False

Overall algorithm 1.Do as much covering as possible 2.If a leaf can't be covered, try forced covering 3.If the leaf still can't be covered, expand it 4.Label all error states False by refining with an interpolant 5.Continue until unwinding is safe and complete

Interpolant Seqeunce in Princess 92 Interpolant for (L 0 =0) Æ (L 1 =1 Æ old 0 =new 0 ) Æ (L 2 =0 Æ new 1 =new 0 +1) Æ (new 1 !=old 0 ) Æ (L 2 !=0) \functions { int L0, L1, old0, new0, L2, new1; } \problem { \part[p1] (L0 =0) & \part[p2] (L1 =1 & old0=new0) & \part[p3] (L2=0 & new1 =new0+1) & \part[p4] (new1 != old0) & \part[p5] (L2!=0) -> false } \interpolant {p1; p2, p3, p4, p5} \interpolant {p1, p2; p3, p4, p5} \interpolant {p1, p2, p3; p4, p5} \interpolant {p1, p2, p3, p4; p5}

Homework Run the two versions of verification algorithms on the following control flow graph, using Princess for computing interpolants 93 L=0;Cnt=0 L=1; old=new [L=0] [new==old] [new!=old] control-flow graph [Cnt>3] [Cnt · 3] L=0; new++