Carnegie Mellon University SAT-Based Decision Procedures for Linear Arithmetic and Uninterpreted Functions SAT-Based Decision Procedures for Linear Arithmetic.

Slides:



Advertisements
Similar presentations
Model Checking Lecture 4. Outline 1 Specifications: logic vs. automata, linear vs. branching, safety vs. liveness 2 Graph algorithms for model checking.
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
Representing Boolean Functions for Symbolic Model Checking Supratik Chakraborty IIT Bombay.
SMT Solvers (an extension of SAT) Kenneth Roe. Slide thanks to C. Barrett & S. A. Seshia, ICCAD 2009 Tutorial 2 Boolean Satisfiability (SAT) ⋁ ⋀ ¬ ⋁ ⋀
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Technion 1 Generating minimum transitivity constraints in P-time for deciding Equality Logic Ofer Strichman and Mirron Rozanov Technion, Haifa, Israel.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
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.
Carnegie Mellon University Boolean Satisfiability with Transitivity Constraints Boolean Satisfiability with Transitivity Constraints
Randal E. Bryant Carnegie Mellon University SRC ‘07 Word-Level Modeling and Verification of Systems Using Selective Term-Level Abstraction Sanjit A. Seshia.
Nikolaj Bjørner Microsoft Research Lecture 3. DayTopicsLab 1Overview of SMT and applications. SAT solving, Z3 Encoding combinatorial problems with Z3.
Carnegie Mellon University Decision Procedures Customized for Formal Verification Decision Procedures Customized for Formal Verification
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.
Bit Vector Decision Procedures A Basis for Reasoning about Hardware & Software Randal E. Bryant Carnegie Mellon University.
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.
SAT-Based Decision Procedures for Subsets of First-Order Logic
The Theory of NP-Completeness
Weizmann Institute Range Minimization O. Shtrichman The Weizmann Institute Joint work with A.Pnueli, Y.Rodeh, M.Siegel.
Sanjit A. Seshia and Randal E. Bryant Computer Science Department
Carnegie Mellon University Symbolic, Word-Level Hardware Verification Randal E. Bryant Contributions by graduate students:
Technion 1 Generating minimum transitivity constraints in P-time for deciding Equality Logic Ofer Strichman and Mirron Rozanov Technion, Haifa, Israel.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Technion 1 (Yet another) decision procedure for Equality Logic Ofer Strichman and Orly Meir Technion.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
Carnegie Mellon University SAT-Based Decision Procedures for Subsets of First-Order Logic Randal E. Bryant Part I: Equality.
1 A propositional world Ofer Strichman School of Computer Science, Carnegie Mellon University.
Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part II – Equality Logic and Uninterpreted Functions.
CS & ECE Departments Carnegie Mellon University Modeling and Verifying Systems using CLU Logic Randal E. Bryant Shuvendu Lahiri Sanjit A. Seshia.
*Carnegie Mellon University † IBM Exploiting Positive Equality in a Logic of Equality with Uninterpreted Functions Exploiting Positive Equality in a Logic.
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
Ofer Strichman, Technion Deciding Combined Theories.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Leonardo de Moura Microsoft Research. Many approaches Graph-based for difference logic: a – b  3 Fourier-Motzkin elimination: Standard Simplex General.
Is Bit-Vector Reasoning as Hard as NExpTime in Practice?
Deciding a Combination of Theories - Decision Procedure - Changki pswlab Combination of Theories Daniel Kroening, Ofer Strichman Presented by Changki.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
Binary Decision Diagrams (BDDs)
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic Range Allocation.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
Controller Synthesis for Pipelined Circuits Using Uninterpreted Functions Georg Hofferek and Roderick Bloem. MEMOCODE 2011.
Integrating high-level constructs into programming languages Language extensions to make programming more productive Underspecified programs –give assertions,
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
NP-Complete problems.
Part 1: Positive Equality for Uninterpreted functions in Eager Encoding.
Symbolic and Concolic Execution of Programs Information Security, CS 526 Omar Chowdhury 10/7/2015Information Security, CS 5261.
Verifying Programs with BDDs Topics Representing Boolean functions with Binary Decision Diagrams Application to program verification class-bdd.ppt
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
Random Interpretation Sumit Gulwani UC-Berkeley. 1 Program Analysis Applications in all aspects of software development, e.g. Program correctness Compiler.
Controller Synthesis for Pipelined Circuits Using Uninterpreted Functions Georg Hofferek and Roderick Bloem. MEMOCODE 2011.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
Selected Decision Procedures and Techniques for SMT More on combination – theories sharing sets – convex theory Un-interpreted function symbols (quantifier-free.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
Satisfiability Modulo Theories and DPLL(T) Andrew Reynolds March 18, 2015.
Daniel Kroening and Ofer Strichman 1 Decision Procedures for Equality Logic 1.
Decision Procedures in Equality Logic
SMT-Based Verification of Parameterized Systems
Satisfiability Modulo Theories
Georg Hofferek, Ashutosh Gupta, Bettina Könighofer, Jie-Hong Roland Jiang and Roderick Bloem Synthesizing Multiple Boolean Functions using Interpolation.
Automatic Abstraction of Microprocessors for Verification
Instructor: Aaron Roth
Presentation transcript:

Carnegie Mellon University SAT-Based Decision Procedures for Linear Arithmetic and Uninterpreted Functions SAT-Based Decision Procedures for Linear Arithmetic and Uninterpreted Functions Randal E. Bryant

– 2 – Decision Procedures in Formal Verification RTL/ Source Code + Specifi- cation Abstraction Verification OK Error Formal Model + Specifi- cation Decision Procedure for Decidable Fragment of First-Order Logic Applications: Out-of-order, Pipelined Microprocessors; Cache Coherence Protocols; Device Drivers; Compiler Validation; …

– 3 – SAT-based Decision Procedures Input Formula Boolean Formula satisfiable unsatisfiable Satisfiability-preserving Boolean Encoder SAT Solver EAGER ENCODING Input Formula Boolean Formula satisfiable unsatisfiable Approximate Boolean Encoder SAT Solver satisfying assignment satisfiable First-order Conjunctions SAT Checker unsatisfiable additional clause LAZY ENCODING

– 4 – Lazy Encoding Characteristics +Can be extended to handle wide variety of theories +Clean & modular design –Does not scale well Number of calls to conjunction checker typically exponential in formula size Each call independent: nothing learned in one call can be exploited by another First-order Conjunctions SAT Checker Uninterpreted Functions Linear Arithmetic Bit Vectors Theory N Theory Combiner

– 5 – Eager Encoding Characteristics –Must encode all information about domain properties into Boolean formula –Some properties can give exponential blowup +Lets SAT solver do all of the work Good Approach for Some Domains Modern SAT solvers have remarkable capacity Good at extracting relevant portions out of very large formulas Learns about formula properties as search proceeds  Focus of this talk Input Formula Boolean Formula satisfiable unsatisfiable Satisfiability-preserving Boolean Encoder SAT Solver

– 6 – x0x0 x1x1 x2x2 x n-1 Data and Function Abstraction ALUALU x  f  Bit-vectors to (unbounded) Integers Functional units to Uninterpreted Functions a = x  b = y  f(a,b) = f(x,y) Common Operations 1010 x y p ITE(p, x, y) If-then-else x y x = y = Test for equality

– 7 – Abstract Modeling of Microprocessor For any Block that Transforms or Evaluates Data: Replace with generic, unspecified function Also view instruction memory as function Reg. File IF/ID Instr Mem +4 PC ID/EX ALUALU EX/WB = = Rd Ra Rb Imm Op Adat Control F1F1 F2F2 F3F3

– 8 – EUF: Equality with Uninterp. Functs Decidable fragment of first order logic Formulas ( F ) Boolean Expressions  F, F 1  F 2, F 1  F 2 Boolean connectives T 1 = T 2 Equation P (T 1, …, T k ) Predicate application Terms ( T ) Integer Expressions ITE(F, T 1, T 2 ) If-then-else Fun (T 1, …, T k ) Function application Functions ( Fun ) Integer  Integer f Uninterpreted function symbol Read, Write Memory operations Predicates ( P ) Integer  Boolean p Uninterpreted predicate symbol

– 9 – EUF Decision Problem Circuit Representation of Formula Truth Values Dashed Lines Model Control Logical connectives Equations Integer Values Solid lines Model Data Uninterpreted functions If-Then-Else operationTask Determine whether formula F is universally valid True for all interpretations of variables and function symbols Often expressed as (un)satisfiability problem »Prove that formula  F is not satisfiable =   f T F T F f T F  = e 1 e 0 x 0 d 0 T F T F T F e 1 e 0 x 0 d 0 =   f f  =

– 10 – =   f T F T F f T F  = e 1 e 0 x 0 d 0 T F T F T F e 1 e 0 x 0 d 0 =   f f  = Finite Model Property for EUF Observation Any formula has limited number of distinct expressions Only property that matters is whether or not different terms are equal x0x0 d0d0 f (x0)f (x0) f (d0)f (d0)

– 11 – Boolean Encoding of Integer Values For Each Expression Either equal to or distinct from each preceding expression Boolean Encoding Use Boolean values to encode integers over small range EUF formula can be translated into propositional logic Logic circuit with multiplexors, comparators, logic gates Tautology iff original formula valid Expression Possible Values Bit Encoding x0x0{0}00 d0d0{0,1}0 b 10 f (x0)f (x0){0,1,2} b 21 b 20 f (d0)f (d0){0,1,2,3} b 31 b 30

– 12 – Some History of EUF Decision Procedures Ackermann, 1954 Quantifier-free decision problem can be decided based on finite instantiations Burch & Dill, CAV ‘94 Automatic decision procedure »Davis-Putnam enumeration »Congruence closure to enforce functional consistency Boolean approaches Goel, et al, CAV ‘98 »Attempted with BDDs, but didn’t get good results Bryant, German, Velev, CAV ‘99 »Could verify microprocessor using BDDs Velev & Bryant, DAC 2001 »Demonstrated power of modern SAT procedures

– 13 – Exploiting Positive Equality Bryant, German, Velev CAV ‘99 First successful use of Boolean methods for EUF Positive Equality Equations that appear in unnegated formExploiting Can greatly reduce number of cases required to show validity Only need to consider maximally diverse interpretations Reduce number of Boolean variables in bit-level encoding

– 14 – Diverse Interpretations: Illustration Task Verify someone’s obscure code for 4X4 array transpose void trans(int a[4][4]) { int t; for (t = 4; t < 15; t++) if (~t&2|| t&8 && ~t&1) { int r = t&0x3; int c = t>>2; int val = a[r][c]; a[r][c] = a[c][r]; a[c][r] = val; } Observation Array elements altered only by copying one to another Just need to make sure right set of copies performed Only operations on array elements

– 15 – Verifying Array Code Test for trans4 trans4 Single Test Adequate Unique value for each possible source element “Maximally Diverse” If a’[r][c] = a[c][r], then must have copied proper value a a’

– 16 – Characteristics of Array Verification Correctness Condition a’[0][0] = a[0][0]  a’[0][1] = a[1][0]  a’[0][2] = a[2][0]  … …  a’[3][2] = a[2][3]  a’[3][3] = a[3][3] Properties All equations are in positive form Worst case test is one that tends to make things unequal Maximally diverse interpretation: use as many different values as possible All maximally diverse interpretations isomorphic Only need to try one to prove all handled correctly

– 17 – Equations in Processor Verification Data TypesEquations Register IdsControl stalling & forwarding Instruction AddressOnly top-level verification condition Program DataOnly top-level verification condition Reg. File IF/ID Instr Mem +4 PC ID/EX ALUALU EX/WB = = Rd Ra Rb Imm Op Adat Control

– 18 – Exploiting Equation Structure Positive Equations In top-level verification condition Can use maximally diverse interpretation Negative Equations PIpeline control logic Between register IDs Operation depends on whether or not two IDs are equal Must use general encoding Encode with Boolean variables All possibility of IDs that match and/or don’t match

– 19 – =   f T F T F f T F  = e 1 e 0 x 0 d 0 T F T F T F e 1 e 0 x 0 d 0 =   f f  = Application of Positive Equality Observation All equations are positive in this formula Can consider single, diverse interpretation for terms x0x0 d0d0 f (x0)f (x0)f (d0)f (d0)

– 20 – ff vf 1 vf 2 Function Elimination: Ackermann’s Method Replace All Function Applications by Integer Variables Introduce new domain variable Enforce functional consistency by global constraints Unclear how to restrict evaluation to diverse interpretations x1x1 x2x2 F ==  

– 21 – fff x1x1 x2x2 x3x3 vf 1 vf 2 TFTF = = = TFTF vf 3 TFTF Function Elimination: ITE Method General Technique Introduce new domain variable Nested ITE structure maintains functional consistency

– 22 – fff x1x1 x2x2 x3x3 5 6 TFTF = = = TFTF 7 TFTF Generating Diverse Encoding Replacing Application Use fixed values rather than variables Application results equal iff arguments equal

– 23 – Benefits of Positive Equality Microprocessor Benchmarks 1xDLX: Single issue, RISC processor 2xDLX-EX-BP: Dual issue processor with exception handling & branch prediction 9VLIW-BP: 9-way VLIW processor with branch predictionMeasurements Using BerkMin SAT solver BenchmarkUsing Pos. Eq.No Pos. Eq 1xDLX buggy0.022 good xDLX-EX-BP buggy415 good15> 24hrs 9VLIW-BP buggy10> 24hrs good224> 24hrs Velev & Bryant, JSC ‘02

– 24 – Revisiting Encoding Techniques Small Domain (SD) Use bit-level encodings of bounded integers Implicitly encode properties of equality logic Per-Constraint Encoding (EIJ) Introduce explicit Boolean variable for each equation Additional transitivity constraints to express properties of equality logic x = y  y = z  z  x  x 1 x 0  =  y 1 y 0    y 1 y 0  =  z 1 z 0    z 1 z 0    x 1 x 0  e xy  e yz   e xz Satisfiable? e yz  e zx  e xy  e xy  e yz  e xz  e xy  e xz  e yz  Transitivity Constraints

– 25 – Per-Constraint Encoding Introduced by Goel et al., CAV ‘98 Exploiting sparse structure by Bryant & Velev, CAV 2000Procedure Initial formula F Want to prove valid Prove that  F is not satisfiable Replace each equation x = y by Boolean variable e xy Gives formula F sat Generate formula expressing transitivity constraints Gives formula F trans Use SAT solver to show that F sat  F trans not satisfiableMotivation Provides SAT solver with more direct representation of underlying problem

– 26 – Graph Interpretation of Transitivity Transitivity Violation Cycle in graph Exactly one edge has e i,j = false  === = == =

– 27 – Exploiting Chords Chord Edge connecting two non- adjacent vertices in cycle Property Sufficient to enforce transitivity constraints for all chord-free cycles If transitivity holds for all chord-free cycles, then holds for arbitrary cycles   

– 28 – Enumerating Chord-Free Cycles Strategy Enumerate chord-free cycles in graph Each cycle of length k yields k transitivity constraints 1 2k Problem Potentially exponential number of chord-free cycles 2 k +k chord-free cycles

– 29 – Adding Chords Strategy Add edges to graph to reduce number of chord-free cycles 1 2k 2 k +k chord-free cycles 2k+1 chord-free cycles Trade-Off Reduces formula size Increases number of relational variables

– 30 – Chordal Graph Definition Every cycle of length > 3 has a chordGoal Add minimum number of edges to make graph chordal Relation to Sparse Gaussian Elimination Choose pivot ordering that minimizes fill-in NP-hard Simple heuristics effective

– 31 – 1xDLX-C Equation Structure Vertices For each v i 13 different register identifiersEdges For each equation Control stalling and forwarding logic 27 relational variables Out of 78 possible

– 32 – Adding Chordal Edges to 1xDLX-C Original 27 relational variables 286 cycles 858 clauses Augmented 33 relational variables 40 cycles 120 clauses

– 33 – 2DLX-CCt Equation Structure Equations Between 25 different register identifiers 143 relational variables Out of 300 possible

– 34 – Adding Chordal Edges to 2xDLX-CCt Original 143 relational variables 2,136 cycles 8,364 clauses Augmented 193 relational variables 858 cycles 2,574 clauses

– 35 – Choosing Encoding Method Comparison Formula length n with m integer variables & function applications Worst-case complexity Per-Constraint Encoding Works Well in Practice Generates slightly larger formulas than small domain Better performance by SAT solver Small DomainPer-Constraint Boolean Variables O(m log m)O(m 2 ) Formula SizeO(n + m 2 log m)O(n + m 3 )

– 36 – Encoding Comparison Benchmarks Superscalar, out-of-order datapath 2–6 instructions issued in parallelMeasurements Using BerkMin SAT solver Issue Width Per-ConstraintSmall Domain VarsClausesTimeVarsClausesTime 21398, , , , , , , , ,243528,9621, ,7383,206 Velev & Bryant, JSC ‘02

– 37 – Extensions Difference logic Predicates of form x ≤ y + C Original logic of UCLID Use integer variables to represent pointers into buffers C =  1 Linear constraints Predicates of from a 1 x 1 + a 2 x 2 + … + a n x n ≤ b Used in applying UCLID to software verification and software security problems

– 38 – Difference Logic Predicates of form x ≤ y + C C generally a small integer Encoding Methods Small domain Range bound n · max |C| Per constraint encoding Variables of form e x,,y C Can have exponential blowup in number of variables Choosing Encoding Method Per constraint better, as long as it doesn’t blow up Predicting blowup Successfully used classifier trained by machine learning (Seshia, Lahiri & Bryant, DAC ’03)

– 39 – Linear Constraints Predicates of from a 1 x 1 + a 2 x 2 + … + a n x n ≤ b Common Case All but k predicates are difference predicates a i = +1, a j = –1, rest = 0 Rest are sparse At most w coefficients nonzero Coefficient values small n #variables w max #non-zero terms k #non-difference constraints b max max |constant| a max max |coefficient|

– 40 – Linear Constraints Small Domain Encoding (Seshia & Bryant, LICS ’04) Find value D such that only need to consider solutions with 0 ≤ x i < D, for all i Bounds on D: Encode as SAT problem with log(D) bits / integer variable Practical for real applications (n+2) ¢ n ¢ (b max  +1) ¢ ( w ¢ a max ) k n #variables w max #non-zero terms k #non-difference constraints b max max |constant| a max max |coefficient|

– 41 – Some Lessons We’ve Learned Preserve Boolean Structure Other approaches require collapsing to conjunctions of predicates Exploit Problem Characteristics Sparseness Tighten bounds and/or reduce number of constraints Polarity structure Positive equality Let SAT Solver Do the Work Eager encoding: provide sufficient set of constraints to prove / disprove formula They are good at digesting large volume of information