Bit Vector Decision Procedures A Basis for Reasoning about Hardware & Software Randal E. Bryant Carnegie Mellon University.

Slides:



Advertisements
Similar presentations
Exploiting SAT solvers in unbounded model checking
Advertisements

Finding bugs: Analysis Techniques & Tools Symbolic Execution & Constraint Solving CS161 Computer Security Cho, Chia Yuan.
Satisfiability Modulo Theories (An introduction)
SMT Solvers (an extension of SAT) Kenneth Roe. Slide thanks to C. Barrett & S. A. Seshia, ICCAD 2009 Tutorial 2 Boolean Satisfiability (SAT) ⋁ ⋀ ¬ ⋁ ⋀
P-Optimal CSP Solvers Applied to Software Security P-Optimal CSP Solvers Applied to Software Security Ahmed Abdel Mohsen and Karl Lieberherr College of.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
1 Backdoor Sets in SAT Instances Ryan Williams Carnegie Mellon University Joint work in IJCAI03 with: Carla Gomes and Bart Selman Cornell University.
Panel on Decision Procedures Panel on Decision Procedures Randal E. Bryant Lintao Zhang Nils Klarlund Harald Ruess Sergey Berezin Rajeev Joshi.
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:
Weizmann Institute Deciding equality formulas by small domain instantiations O. Shtrichman The Weizmann Institute Joint work with A.Pnueli, Y.Rodeh, M.Siegel.
Department of Electrical and Computer Engineering M.A. Basith, T. Ahmad, A. Rossi *, M. Ciesielski ECE Dept. Univ. Massachusetts, Amherst * Univ. Bretagne.
Randal E. Bryant Carnegie Mellon University SRC ‘07 Word-Level Modeling and Verification of Systems Using Selective Term-Level Abstraction Sanjit A. Seshia.
Interpolants [Craig 1957] G(y,z) F(x,y)
1 Satisfiability Modulo Theories Sinan Hanay. 2 Boolean Satisfiability (SAT) Is there an assignment to the p 1, p 2, …, p n variables such that  evaluates.
Modeling Data in Formal Verification Bits, Bit Vectors, or Words Randal E. Bryant Carnegie Mellon University.
1 Optimisation Although Constraint Logic Programming is somehow focussed in constraint satisfaction (closer to a “logical” view), constraint optimisation.
1 Predicate Abstraction of ANSI-C Programs using SAT Edmund Clarke Daniel Kroening Natalia Sharygina Karen Yorav (modified by Zaher Andraus for presentation.
Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part III – Decision Procedures for Equality Logic and Uninterpreted Functions.
1 Deciding separation formulas with SAT Ofer Strichman Sanjit A. Seshia Randal E. Bryant School of Computer Science, Carnegie Mellon University.
Modeling Data in Formal Verification Bits, Bit Vectors, or Words Randal E. Bryant Carnegie Mellon University.
SAT-Based Decision Procedures for Subsets of First-Order Logic
Sanjit A. Seshia and Randal E. Bryant Computer Science Department
Technion 1 Generating minimum transitivity constraints in P-time for deciding Equality Logic Ofer Strichman and Mirron Rozanov Technion, Haifa, Israel.
Formal Verification Group © Copyright IBM Corporation 2008 IBM Haifa Labs SAT-based unbounded model checking using interpolation Based on a paper “Interpolation.
1 Backdoors To Typical Case Complexity Ryan Williams Carnegie Mellon University Joint work with: Carla Gomes and Bart Selman Cornell University.
Technion 1 (Yet another) decision procedure for Equality Logic Ofer Strichman and Orly Meir Technion.
Introduction to Satisfiability Modulo Theories (SMT) Clark Barrett, NYU Sanjit A. Seshia, UC Berkeley ICCAD Tutorial November 2, 2009.
Computing Over­Approximations with Bounded Model Checking Daniel Kroening ETH Zürich.
1 A propositional world Ofer Strichman School of Computer Science, Carnegie Mellon University.
Describing Syntax and Semantics
Word Level Predicate Abstraction and Refinement for Verifying RTL Verilog Himanshu Jain Daniel Kroening Natasha Sharygina Edmund Clarke Carnegie Mellon.
Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part II – Equality Logic and Uninterpreted Functions.
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
Farzan Fallah Srinivas Devadas Laboratory for Computer Science MIT Farzan Fallah Srinivas Devadas Laboratory for Computer Science MIT Functional Vector.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
Daniel Kroening and Ofer Strichman Decision Procedure
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Deciding a Combination of Theories - Decision Procedure - Changki pswlab Combination of Theories Daniel Kroening, Ofer Strichman Presented by Changki.
Carnegie Mellon 1 This Week: Integers Integers  Representation: unsigned and signed  Conversion, casting  Expanding, truncating  Addition, negation,
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic Range Allocation.
Introduction to Satisfiability Modulo Theories
Inferring Specifications to Detect Errors in Code Mana Taghdiri Presented by: Robert Seater MIT Computer Science & AI Lab.
1 MVD 2010 University of Iowa New York University Comparing Proof Systems for Linear Real Arithmetic Using LFSC Andrew Reynolds September 17, 2010.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
© 2014 Carnegie Mellon University Synthesizing Safe Bit-Precise Invariants Arie Gurfinkel (SEI / CMU) Anton Belov (UCD / Synopsys) Joao Marques-Silva (UCD)
Modeling Data in Formal Verification Bits, Bit Vectors, or Words Karam AbdElkader Based on: Presentations form Randal E. Bryant - Carnegie Mellon University.
Author: Alex Groce, Daniel Kroening, and Flavio Lerda Computer Science Department, Carnegie Mellon University Pittsburgh, PA Source: R. Alur and.
Verification & Validation By: Amir Masoud Gharehbaghi
Symbolic and Concolic Execution of Programs Information Security, CS 526 Omar Chowdhury 10/7/2015Information Security, CS 5261.
February 22-25, 2010 Designers Work Less with Quality Formal Equivalence Checking by Orly Cohen, Moran Gordon, Michael Lifshits, Alexander Nadel, and Vadim.
© 2006 Carnegie Mellon University Introduction to CBMC: Part 1 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie Gurfinkel,
Error Explanation with Distance Metrics Authors: Alex Groce, Sagar Chaki, Daniel Kroening, and Ofer Strichman International Journal on Software Tools for.
1/20 Arrays Changki PSWLAB Arrays Daniel Kroening and Ofer Strichman Decision Procedure.
1 A framework for eager encoding Daniel Kroening ETH, Switzerland Ofer Strichman Technion, Israel (Executive summary) (submitted to: Formal Aspects of.
© 2006 Carnegie Mellon University Introduction to CBMC: Part 1 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie Gurfinkel,
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
© Anvesh Komuravelli Spacer Model Checking with Proofs and Counterexamples Anvesh Komuravelli Carnegie Mellon University Joint work with Arie Gurfinkel,
On the Relation Between Simulation-based and SAT-based Diagnosis CMPE 58Q Giray Kömürcü Boğaziçi University.
SAT for Software Model Checking Introduction to SAT-problem for newbie
Automatic Test Generation
Solving Linear Arithmetic with SAT-based MC
Introduction to Software Verification
Satisfiability Modulo Theories
Lifting Propositional Interpolants to the Word-Level
Over-Approximating Boolean Programs with Unbounded Thread Creation
A Progressive Approach for Satisfiability Modulo Theories
Modeling Data in Formal Verification Bits, Bit Vectors, or Words
Automatic Abstraction of Microprocessors for Verification
Faster Extraction of High-Level Minimal Unsatisfiable Cores
Presentation transcript:

Bit Vector Decision Procedures A Basis for Reasoning about Hardware & Software Randal E. Bryant Carnegie Mellon University

– 2 – Collaborators Sanjit Seshia, Bryan Brady UC Berkeley Daniel Kroening ETH Zurich Joel Ouaknine Oxford University Ofer Strichman Technion Randy Bryant Carnegie Mellon 3 continents 4 countries 5 institutions 6 authors

– 3 – Motivating Example #1 Do these functions produce identical results? Strategy Represent and reason about bit-level program behavior Specific to machine word size, integer representations, and operations int abs(int x) { int mask = x>>31; return (x ^ mask) + ~mask + 1; } int test_abs(int x) { return (x < 0) ? -x : x; }

– 4 – Motivating Example #2 Is there an input string that causes value 234 to be written to address a 4 a 3 a 2 a 1 ? void fun() { char fmt[16]; fgets(fmt, 16, stdin); fmt[15] = '\0'; printf(fmt); } Answer Yes: " a 1 a 2 a 3 a 4 %230g%n" Depends on details of compilation But no exploit for buffer size less than 8 [Ganapathy, Seshia, Jha, Reps, Bryant, ICSE ’05]

– 5 – Motivating Example #3 Is there a way to expand the program sketch to make it match the spec? bit[W] popSpec(bit[W] x) { int cnt = 0; for (int i=0; i<W; i++) { if (x[i]) cnt++; } return cnt; } Answer W=16: [Solar-Lezama, et al., ASPLOS ‘06] bit[W] popSketch(bit[W] x) { loop (??) { x = (x&??) + ((x>>??)&??); } return x; } x = (x&0x5555) + ((x>>1)&0x5555); x = (x&0x3333) + ((x>>2)&0x3333); x = (x&0x0077) + ((x>>8)&0x0077); x = (x&0x000f) + ((x>>4)&0x000f);

– 6 – Motivating Example #4 Is pipelined microprocessor identical to sequential reference model? Strategy Automatically generate abstraction function from pipeline to program state [Burch & Dill, CAV ’94] Represent machine instructions, data, and state as bit vectors Compatible with hardware description language representation Pipelined Microprocessor Sequential Reference Model

– 7 – Task Bit Vector Formulas Fixed width data words Arithmetic operations E.g., add/subtract/multiply/divide & comparisons Two’s complement, unsigned, … Bit-wise logical operations E.g., and/or/xor, shift/extract and equality Boolean connectives Reason About Hardware & Software at Bit Level Formal verification Security analysis Test & program generation What function arguments will cause program to take specified branch?

– 8 – Decision Procedures Core technology for formal reasoning Boolean SAT Pure Boolean formula SAT Modulo Theories (SMT) Support additional logic fragments Example theories Linear arithmetic over reals or integers Functions with equality Bit vectors Combinations of theories Formula Decision Procedure Satisfying solution Unsatisfiable (+ proof)

– 9 – Recent Progress in SAT Solving

– 10 – BV Decision Procedures: Some History B.C. (Before Chaff) String operations (concatenate, field extraction) Linear arithmetic with bounds checking Modular arithmetic SAT-Based “Bit Blasting” Generate Boolean circuit based on bit-level behavior of operations Convert to Conjunctive Normal Form (CNF) and check with best available SAT checker Handles arbitrary operations Effective in many applications CBMC [Clarke, Kroening, Lerda, TACAS ’04] Microsoft Cogent + SLAM [Cook, Kroening, Sharygina, CAV ’05] CVC-Lite [Dill, Barrett, Ganesh], Yices [deMoura, et al], STP

– 11 – Research Challenge Is there a better way than bit blasting? Requirements Provide same functionality as with bit blasting Find abstractions based on word-level structure Improve on performance of bit blasting A New Approach [Bryant, Kroening, Ouaknine, Seshia, Stichman, Brady, TACAS ’07] Use bit blasting as core technique Apply to simplified versions of formula Successive approximations until solve or show unsatisfiable

– 12 – Approximating Formula Example Approximation Techniques Underapproximating Restrict word-level variables to smaller ranges of values Overapproximating Replace subformula with Boolean variable  Original Formula   +  + Overapproximation ++ More solutions: If unsatisfiable, then so is  Underapproximation  −   −− Fewer solutions: Satisfying solution also satisfies 

– 13 – Starting Iterations Initial Underapproximation (Greatly) restrict ranges of word-level variables Intuition: Satisfiable formula often has small-domain solution  1−1−

– 14 – First Half of Iteration SAT Result for SAT Result for  1 − Satisfiable Then have found solution for  Unsatisfiable Use UNSAT proof to generate overapproximation  1 + (Described later)  1−1− If SAT, then done 1+1+ UNSAT proof: generate overapproximation

– 15 – Second Half of Iteration SAT Result for SAT Result for  1 + Unsatisfiable Then have shown  unsatisfiable Satisfiable Solution indicates variable ranges that must be expanded Generate refined underapproximation  1−1− If UNSAT, then done 1+1+ SAT: Use solution to generate refined underapproximation 2−2−

– 16 – Iterative Behavior Underapproximations Successively more precise abstractions of  Allow wider variable rangesOverapproximations No predictable relation UNSAT proof not unique  1−1− 1+1+ 2−2−      k−k− 2+2+ k+k+     

– 17 – Overall Effect Soundness Only terminate with solution on underapproximation Only terminate as UNSAT on overapproximationCompleteness Successive underapproximations approach  Finite variable ranges guarantee termination In worst case, get  k −    1−1− 1+1+ 2−2−      k−k− 2+2+ k+k+      SAT UNSAT

– 18 – Generating Overapproximation Given Underapproximation  1 − Bit-blasted translation of  1 − into Boolean formula Proof that Boolean formula unsatisfiableGenerate Overapproximation  1 + If  1 + satisfiable, must lead to refined underapproximation Generate  2 − such that  1 −   2 −    1−1− 1+1+ UNSAT proof: generate overapproximation 2−2−

– 19 – Bit-Vector Formula Structure DAG representation to allow shared subformulas x + 2 z  1 x % 26 = v w & 0xFFFF = x x = y a 

– 20 – Structure of Underapproximation Linear complexity translation to CNF Each word-level variable encoded as set of Boolean variables Additional Boolean variables represent subformula values x + 2 z  1 x % 26 = v w & 0xFFFF = x x = y a −− Range Constraints w x y z Æ

– 21 – Encoding Range Constraints Explicit View as additional predicates in formulaImplicit Reduce number of variables in encoding ConstraintEncoding 0  w  ··· 0 w 2 w 1 w 0 −4  x  4x s x s x s ··· x s x s x 1 x 0 Yields smaller SAT encodings Range Constraints w x −4  x  4 0  w  8  −4  x  4

– 22 – UNSAT Proof Subset of clauses that is unsatisfiable Clause variables define portion of DAG Subgraph that cannot be satisfied with given range constraints x + 2 z  1 x % 26 = v w & 0xFFFF = x x = y a Ç Æ Æ Ç Ç: Range Constraints w x y z Æ

– 23 – Generated Overapproximation Identify subformulas containing no variables from UNSAT proof Replace by fresh Boolean variables Remove range constraints on word-level variables Creates overapproximation Ignores correlations between values of subformulas x + 2 z  1 x = y a Æ Æ Ç Ç: b1b1 b2b2 1+1+

– 24 – Refinement Property Claim  1 + has no solutions that satisfy  1 −’s range constraints Because  1 + contains portion of  1 − that was shown to be unsatisfiable under range constraints x + 2 z  1 x = y a Æ Æ Ç Ç: b1b1 b2b2 Range Constraints w x y z Æ UNSAT 1+1+

– 25 – Refinement Property (Cont.) Consequence Solving  1 + will expand range of some variables Leading to more exact underapproximation  2 − x + 2 z  1 x = y a Æ Æ Ç Ç: b1b1 b2b2 1+1+

– 26 – Effect of Iteration Each Complete Iteration Expands ranges of some word-level variables Creates refined underapproximation  1−1− 1+1+ SAT: Use solution to generate refined underapproximation 2−2− UNSAT proof: generate overapproximation

– 27 – Approximation Methods So Far Range constraints Underapproximate by constraining values of word-level variables Subformula elimination Overapproximate by assuming subformula value arbitrary General Requirements Systematic under- and over-approximations Way to connect from one to another Goal: Devise Additional Approximation Strategies

– 28 – Function Approximation Example Motivation Multiplication (and division) are difficult cases for SAT : Prohibited §: Prohibited Gives underapproximation Restricts values of (possibly intermediate) terms : f (x,y) §: f (x,y) Overapproximate as uninterpreted function f Value constrained only by functional consistency * x y x 01else y x 0y§

– 29 – Results: UCLID BV vs. Bit-blasting UCLID always better than bit blasting Generally better than other available procedures SAT time is the dominating factor [results on 2.8 GHz Xeon, 2 GB RAM]

– 30 – UCLID BV run-time analysis w i : Maximum word-level variable size s i : Maximum word-level variable instantiation Generated abstractions are small Few iterations of refinement loop needed

– 31 – Why This Work is Worthwhile Realistic Semantic Model for Hardware and Software Captures all details of actual operation Detects errors related to overflow and other artifacts of finite representation Allows mixing of integer and bit-level operations Can capture many abstractions that are currently applied manually SAT-Based Methods Are Only Logical Choice Bit blasting is only way to capture full set of operations SAT solvers are good & getting better Abstraction / Refinement Allows Better Scaling Take advantage of cases where formula easily satisfied or disproven

– 32 – Future Work Lots of Refinement & Tuning Selecting under- and over-approximations Iterating within under- or over-approximation E.g., attempt to control variable ranges when overapproximating Reusing portions of bit-blasted formulas Take advantage of incremental SAT Additional Abstractions More general use of functional abstraction Subsume use of uninterpreted functions in current verification methods