Property Directed Reachability

Slides:



Advertisements
Similar presentations
The behavior of SAT solvers in model checking applications K. L. McMillan Cadence Berkeley Labs.
Advertisements

Exploiting SAT solvers in unbounded model checking
A practical and complete approach to predicate abstraction Ranjit Jhala UCSD Ken McMillan Cadence Berkeley Labs.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Satisfiability Modulo Theories (An introduction)
A Program Transformation For Faster Goal-Directed Search Akash Lal, Shaz Qadeer Microsoft Research.
50.530: Software Engineering Sun Jun SUTD. Week 10: Invariant Generation.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
© Anvesh Komuravelli Spacer Automatic Abstraction in SMT-Based Unbounded Software Model Checking Anvesh Komuravelli Carnegie Mellon University Joint work.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
© Anvesh Komuravelli IC3/PDR Overview of IC3/PDR Anvesh Komuravelli Carnegie Mellon University.
© 2015 Carnegie Mellon University The SeaHorn Verification Framework Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie.
© 2012 Carnegie Mellon University UFO: Verification with Interpolants and Abstract Interpretation Arie Gurfinkel and Sagar Chaki Software Engineering Institute.
© 2015 Carnegie Mellon University Property Directed Polyhedral Abstraction Nikolaj Bjørner and Arie Gurfinkel VMCAI 2015.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
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:
Nikolaj Bjørner Microsoft Research Lecture 3. DayTopicsLab 1Overview of SMT and applications. SAT solving, Z3 Encoding combinatorial problems with Z3.
4/25/08Prof. Hilfinger CS164 Lecture 371 Global Optimization Lecture 37 (From notes by R. Bodik & G. Necula)
CS 412/413 Spring 2007Introduction to Compilers1 Lecture 29: Control Flow Analysis 9 Apr 07 CS412/413 Introduction to Compilers Tim Teitelbaum.
Well-cooked Spaghetti: Weakest-Precondition of Unstructured Programs Mike Barnett and Rustan Leino Microsoft Research Redmond, WA, USA.
Describing Syntax and Semantics
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
© 2015 Carnegie Mellon University Building Program Verifiers from Compilers and Theorem Provers Software Engineering Institute Carnegie Mellon University.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
© 2015 Carnegie Mellon University Interpolating Property Directed Reachability Software Engineering Institute Carnegie Mellon University Pittsburgh, PA.
© 2015 Carnegie Mellon University Building Program Verifiers from Compilers and Theorem Provers Software Engineering Institute Carnegie Mellon University.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
© 2015 Carnegie Mellon University Algorithmic Logic-Based Verification with SeaHorn Software Engineering Institute Carnegie Mellon University Pittsburgh,
CS 363 Comparative Programming Languages Semantics.
Incremental formal verification of hardware Hana Chockler Alexander Ivrii Arie Matsliah Shiri Moran Ziv Nevo IBM Research - Haifa.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
Lazy Annotation for Program Testing and Verification Speaker: Chen-Hsuan Adonis Lin Advisor: Jie-Hong Roland Jiang November 26,
© 2014 Carnegie Mellon University Synthesizing Safe Bit-Precise Invariants Arie Gurfinkel (SEI / CMU) Anton Belov (UCD / Synopsys) Joao Marques-Silva (UCD)
Semantics In Text: Chapter 3.
Predicate Abstraction. Abstract state space exploration Method: (1) start in the abstract initial state (2) use to compute reachable states (invariants)
© 2015 Carnegie Mellon University Parametric Symbolic Reachability Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie.
SAT-Based Model Checking Without Unrolling Aaron R. Bradley.
© 2006 Carnegie Mellon University Introduction to CBMC: Part 1 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie Gurfinkel,
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
© 2006 Carnegie Mellon University Introduction to CBMC: Part 1 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie Gurfinkel,
© Anvesh Komuravelli Spacer Model Checking with Proofs and Counterexamples Anvesh Komuravelli Carnegie Mellon University Joint work with Arie Gurfinkel,
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 8: Static Analysis II Roman Manevich Ben-Gurion University.
Horn Clauses mc(x) = x-10 if x > 100 mc(x) = mc(mc(x+11)) if x  100 assert (x ≤
The NP class. NP-completeness
Building Program Verifiers from Compilers and Theorem Provers
SS 2017 Software Verification Bounded Model Checking, Outlook
Weakest Precondition of Unstructured Programs
Further with Hoare Logic Sections 6.12, 6.10, 6.13
Solving Constrained Horn Clauses by Property Directed Reachability
Interpolating Property Directed Reachability
Reasoning About Code.
Reasoning about code CSE 331 University of Washington.
SMT-Based Verification of Parameterized Systems
Solving Linear Arithmetic with SAT-based MC
Parametric Symbolic Reachability
Automating Induction for Solving Horn Clauses
Introduction to Software Verification
Securing A Compiler Transformation
Property Directed Reachability with Word-Level Abstraction
Lecture 5 Floyd-Hoare Style Verification
Over-Approximating Boolean Programs with Unbounded Thread Creation
Semantics In Text: Chapter 3.
Chapter 34: NP-Completeness
Predicate Transformers
Producing short counterexamples using “crucial events”
CSE 589 Applied Algorithms Spring 1999
Presentation transcript:

Property Directed Reachability Author Software Engineering Institute 9/13/2018 Property Directed Reachability Software Engineering Institute Carnegie Mellon University Pittsburgh, PA 15213 Arie Gurfinkel Title Slide Title and Subtitle text blocks should not be moved from their position if at all possible.

Constrained Horn Clauses

Constrained Horn Clauses (CHC) A Constrained Horn Clause (CHC) is a FOL formula of the form 8 V . (Á Æ p1[X1] Æ…Æ pn[Xn] ) h[X]), where A is a background theory (e.g., Linear Arithmetic, Arrays, Bit-Vectors, or combinations of the above) Á is a constrained in the background theory A p1, …, pn, h are n-ary predicates pi[X] is an application of a predicate to first-order terms

Rule Query Fact Linear CHC Non-Linear CHC head body constraint CHC Terminology Rule h[X] à p1[X1],…, pn[Xn], Á. Query false à p1[X1],…, pn[Xn], Á. Fact h[X] à Á. Linear CHC h[X] à p[X1], Á. Non-Linear CHC h[X] à p1[X1],…, pn[Xn], Á. for n > 1

Example Horn Encoding

CHC Satisfiability A model of a set of clauses ¦ is an interpretation of each predicate pi that makes all clauses in ¦ valid A set of clauses is satisfiable if it has a model, and is unsatisfiable otherwise A model is A-definable, it each pi is definable by a formula Ãi in A In the context of program verification a program satisfies a property iff corresponding CHCs are satisfiable verification certificates correspond to models counterexamples correspond to derivations of false

From Programs to Clauses

Hoare Triples A Hoare triple {Pre} P {Post} is valid iff every terminating execution of P that starts in a state that satisfies Pre ends in a state that satisfies Post Inductive Loop Invariant Function Application Recursion Pre ) Inv {InvÆC} Body {Inv} InvÆ:C ) Post {Pre} while C do Body {Post} (PreÆp=a) ) P {P} BodyF {Q} (QÆp,r=a,b) ) Post {Pre} b = F(a) {Post} {Pre} b = F(a) {Post} ` {Pre} BodyF {Post} {Pre} b = F(a) {Post}

Weakest Liberal Pre-Condition Validity of Hoare triples is reduced to FOL validity by applying a predicate transformer Dijkstra’s weakest liberal pre-condition calculus [Dijkstra’75] wlp (P, Post) weakest pre-condition ensuring that executing P ends in Post {Pre} P {Post} is valid , Pre ) wlp (P, Post)

A Simple Programming Language Prog ::= def Main(x) { bodyM }, …, def P (x) { bodyP } body ::= stmt (; stmt)* stmt ::= x = E | assert (E) | assume (E) | while E do S | y = P(E) | E := expression over program variables

Horn Clauses by Weakest Liberal Precondition Prog ::= def Main(x) { bodyM }, …, def P (x) { bodyP } wlp (x=E, Q) = let x=E in Q wlp (assert(E) , Q) = E Æ Q wlp (assume(E), Q) = E → Q wlp (while E do S, Q) = I(w) Æ 8w . ((I(w) Æ E) → wlp (S, I(w))) Æ ((I(w) Æ :E) → Q)) wlp (y = P(E), Q) = ppre(E) Æ (8 r. p(E, r) → Q[r/y]) ToHorn (def P(x) {S}) = wlp (x0=x;assume(ppre(x)); S, p(x0, ret)) ToHorn (Prog) = wlp (Main(), true) Æ 8{P 2 Prog} . ToHorn (P)

Example of a WLP Horn Encoding {Pre: y¸ 0} xo = x; yo = y; while y > 0 do x = x+1; y = y−1; {Post: x=xo+yo} ToHorn C1: I(x,y,x,y) à y>=0. C2: I(x+1,y-1,xo,yo) à I(x,y,xo,yo), y>0. C3: false à I(x,y,xo,yo), y·0, x != xo+yo {y ¸ 0} P {x = xold+yold} is true iff the query C3 is satisfiable

From CFG to Cut Point Graph A Cut Point Graph hides (summarizes) fragments of a control flow graph by (summary) edges Vertices (called, cut points) correspond to some basic blocks An edge between cut-points c and d summarizes all finite (loop-free) executions from c to d that do not pass through any other cut-points

Cut Point Graph Example CFG CPG 1 2 3 4 5 6 1 6

From CFG to Cut Point Graph A Cut Point Graph hides (summarizes) fragments of a control flow graph by (summary) edges Cut Point Graph preserves reachability of (not-summarized) control location. Summarizing loops is undecidable! (Halting program) A cutset summary summarizes all location except for a cycle cutset of a CFG. Computing minimal cutset summary is NP-hard (minimal feedback vertex set). A reasonable compromise is to summarize everything but heads of loops. (Polynomial-time computable).

Single Static Assignment SSA == every value has a unique assignment (a definition) A procedure is in SSA form if every variable has exactly one definition SSA form is used by many compilers explicit def-use chains simplifies optimizations and improves analyses PHI-function are necessary to maintain unique definitions in branching control flow x = PHI ( v0:bb0, …, vn:bbn) ) (phi-assignment) “x gets vi if previously executed block was bbi”

Single Static Assignment: An Example val:bb Single Static Assignment: An Example 0: goto 1 1: x_0 = PHI(0:0, x_3:5); y_0 = PHI(y:0, y_1:5); if (x_0 < N) goto 2 else goto 6 2: if (y_0 > 0) goto 3 else goto 4 3: x_1 = x_0 + y_0; goto 5 4: x_2 = x_0 – y_0; goto 5 5: x_3 = PHI(x_1:3, x_2:4); y_1 = -1 * y_0; goto 1 6: int x, y, n; x = 0; while (x < N) { if (y > 0) x = x + y; else x = x – y; y = -1 * y; }

Large Step Encoding 0: goto 1 1: x_0 = PHI(0:0, x_3:5); y_0 = PHI(y:0, y_1:5); if (x_0 < N) goto 2 else goto 6 2: if (y_0 > 0) goto 3 else goto 4 3: x_1 = x_0 + y_0; goto 5 4: x_2 = x_0 – y_0; goto 5 5: x_3 = PHI(x_1:3, x_2:4); y_1 = -1 * y_0; goto 1 6: Problem: Generate a compact verification condition for a loop-free block of code

Large Step Encoding: Extract all Defs 1: x_0 = PHI(0:0, x_3:5); y_0 = PHI(y:0, y_1:5); if (x_0 < N) goto 2 else goto 6 2: if (y_0 > 0) goto 3 else goto 4 3: x_1 = x_0 + y_0; goto 5 4: x_2 = x_0 – y_0; goto 5 5: x_3 = PHI(x_1:3, x_2:4); y_1 = -1 * y_0; goto 1 x1 = x0 + y0 x2 = x0 – y0 y1 = -1 * y0

Example: Encode Control Flow x1 = x0 + y0 x2 = x0 – y0 y1 = -1 * y0 1: x_0 = PHI(0:0, x_3:5); y_0 = PHI(y:0, y_1:5); if (x_0 < N) goto 2 else goto 6 2: if (y_0 > 0) goto 3 else goto 4 3: x_1 = x_0 + y_0; goto 5 4: x_2 = x_0 – y_0; goto 5 5: x_3 = PHI(x_1:3, x_2:4); y_1 = -1 * y_0; goto 1 B2 → x0 < N B3 → B2 ∧ y0 > 0 B4 → B2 ∧ y0 <=0 B5 → (B3 ∧ x3=x1)∨ (B4 ∧ x3=x2) B5 ∧ x’0=x3 ∧ y’0=y1 p1(x’0,y’0) Ã p1 (x0, y0), Á.

Solving chc with smt

IC3, PDR, and Friends (1) IC3: A SAT-based Hardware Model Checker Incremental Construction of Inductive Clauses for Indubitable Correctness A. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 PDR: Explained and extended the implementation Property Directed Reachability N. Eén, A. Mishchenko, R. K. Brayton: Efficient implementation of property directed reachability. FMCAD 2011 PDR with Predicate Abstraction (easy extension of IC3/PDR to SMT) A. Cimatti, A. Griggio, S. Mover, St. Tonetta: IC3 Modulo Theories via Implicit Predicate Abstraction. TACAS 2014 J. Birgmeier, A. Bradley, G. Weissenbacher: Counterexample to Induction-Guided Abstraction-Refinement (CTIGAR). CAV 2014

IC3, PDR, and Friends (2) GPDR: Non-Linear CHC with Arithmetic constraints Generalized Property Directed Reachability K. Hoder and N. Bjørner: Generalized Property Directed Reachability. SAT 2012 SPACER: Non-Linear CHC with Arithmetic fixes an incompleteness issue in GPDR and extends it with under-approximate summaries A. Komuravelli, A. Gurfinkel, S. Chaki: SMT-Based Model Checking for Recursive Programs. CAV 2014 PolyPDR: Convex models for Linear CHC simulating Numeric Abstract Interpretation with PDR N. Bjørner and A. Gurfinkel: Property Directed Polyhedral Abstraction. VMCAI 2015

Programs, Cexs, Invariants A program P = (V, Init, Tr, Bad) Notation: F(X) = 9 u . (X Æ Tr) Ç Init P is UNSAFE if and only if there exists a number N s.t. P is SAFE if and only if there exists a safe inductive invariant Inv s.t. Inductive Safe

Cormac Flanagan, K. Rustan M Cormac Flanagan, K. Rustan M. Leino: Houdini, an Annotation Assistant for ESC/Java. FME 2001: 500-517

Program Verification by Houdini Inductive Invariant Lemma2 Lemma1 Lemma3 guess new lemmas No Yes Safe?

Guessing Lemmas by Evolving Approximations Inductive Invariant Lemma2 Lemma1 Lemma3 Safe? Inductive Invariant Lemma2 Lemma1 Lemma3 Safe? Inductive Invariant Lemma2 Lemma1 Lemma3 Safe? verifier verifier verifier No No No

Linear CHC Satisfiability Satisfiability of a set of linear CHCs is reducible to satisfiability of THREE clauses of the form where, X’ = {x’ | x 2 X}, P a fresh predicate, and Init, Bad, and Tr are constraints Proof: add extra arguments to distinguish between predicates ! Q(y) Æ Á → W(y, z) P(id=‘Q’, y) Æ Á → P(id=‘W’, y, z)

IC3/PDR Algorithm Overview bounded safety strengthen result

PdrMkSafe IC3/PDR in Pictures

IC3/PDR in Pictures PdrMkSafe cex Cex Queue Trace lemma Frame F0

PdrPush IC3/PDR in Pictures Inductive

IC3/PDR in Pictures PdrPush PDR Invariants Fi  : Bad Init  Fi Inductive PDR Invariants Fi  : Bad Init  Fi Fi  Fi+1 Fi Æ Tr  Fi+1

Author Program 9/13/2018 IC3/PDR Invariant of PDR

IC3 Data-Structures A trace F = F0, …, FN is a sequence of frames. A frame Fi is a set of clauses. Elements of Fi are called lemmas. Invariants: Bounded Safety: 8 i < N . Fi → :Bad Monotonicity: 8 i < N . Fi+1 µ Fi Inductiveness: 8 i < N . Fi Æ Tr → F’i+1 A priority queue Q of counterexamples to induction (CTI) (m, i) 2 Q is a pair, where m is a cube and i a level if (m, i) 2 Q then there exists a path of length (N-i) from a state in m to a state in Bad Q is ordered by level (m, i) < (k, j) iff i < j

Inductive Trace in Pictures …FN F2 F1 Bad INIT

Termination and Progress

Inductive Generalization A clause φ is inductive relative to F iff Init → φ (Initialization) and φ Æ F Æ Tr → φ (Inductiveness) Implemented by first letting φ = :m and generalizing φ by iteratively dropping literals while checking the inductiveness condition Theorem: Let F0, F1, …, FN be a valid IC3 trace. If φ is inductive relative to Fi, 0 · i < N, then, for all j · i, φ is inductive relative to Fj. Follows from the monotonicity of the trace if j < i then Fj → Fi if Fj → Fi then (φ Æ Fi Æ Tr → φ) → (φ Æ Fj Æ Tr → φ’)

Prime Implicants A formula φ is an implicant of a formula psi iff φ ) à A propositional implicant of à is a conjunction of literals φ such that φ is an implicant of à φ is a conjunction of literals φ ) à φ is a partial assignment that makes à true A propositonal implicant φ of à is called prime if no subset of φ is an implicant of Ã

Generalizing Predecessors Decide rule chooses a (generalized) predecessor m0 of m that is consistent with the current frame Simplest implementation is to extract a predecessor mo from a satisfying assignment of M ² FiÆTrÆm’ m0 cab be further generalized using ternary simulation by dropping literals and checking that m’ remains forced An alternative is to let m0 be an implicant (not necessarily prime) of FiÆ9 X’.(Tr Æ m’) finding a prime implicant is difficult because of the existential quantification we settle for an arbitrary implicant. The side conditions ensure it is not trivial

Strengthening a trace Also known as Push or Propagate Bounded safety proofs are usually very weak towards the end not much is needed to show that error will not happen in one or two steps This tends to make them non-inductive a weakness of interpolation-based model checking, like IMPACT in IMPACT, this is addressed by forced covering heuristic Induction “applies” forced cover one lemma at a time whenever all lemmas are pushed Fi+1 is inductive (and safe) (optionally) combine strengthening with generalization Implementation Apply Induction from 0 to N whenever Conflict and Decide are not applicable

Inductive Trace in Pictures …FN F2 F1 Bad INIT

Long Counterexamples Whenever a counterexample m is blocked at level i, it is known that there is no path of length i from Init to m (because got blocked) there is a path of length (N-i) from m to Bad Can check whether there exists a path of length (i+1) from Init to m (Leaf) check eagerly by placing the CTI back into the queue at a higher level (No Leaf) check lazily by waiting until the same (or similar) CTI is discovered after N is increased by Unfold Leaf allows IC3 to discover counterexamples much longer than the current unfolding depth N each CTI re-enqueued by Leaf adds one to the depth of the longest possible counterexample found a real counterexample might chain through multiple such CTI’s

Queue Management for Long Counterexamples A queue element is a triple (m, i, d) m is a CTI, i a level, d a depth Decide sets m and i as before, and sets d to 0 Leaf increases i and d by one i determines how far the CTI can be pushed back d counts number of times the CTI was pushed forward Queue is ordered first by level, then by depth (m, i, d) < (k, j, e) , i < j Ç (i=j Æ d < e) Overall exploration mimics iterative deepening with non-uniform exploration depth go deeper each time before backtracking

Author Software Engineering Institute 9/13/2018 Contact Information Arie Gurfinkel, Ph. D. Sr. Researcher CSC/SSD Telephone: +1 412-268-5800 Email: info@sei.cmu.edu U.S. Mail Software Engineering Institute Customer Relations 4500 Fifth Avenue Pittsburgh, PA 15213-2612 USA Web www.sei.cmu.edu www.sei.cmu.edu/contact.cfm Email: info@sei.cmu.edu Telephone: +1 412-268-5800 SEI Phone: +1 412-268-5800 SEI Fax: +1 412-268-6257