EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving III & Binary Decision Diagrams. Sanjit A. Seshia EECS, UC Berkeley

Similar documents
Binary Decision Diagrams

Formal Verification Methods 1: Propositional Logic

An instance of SAT is defined as (X, S)

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)

On the Relative Efficiency of DPLL and OBDDs with Axiom and Join

Decision Procedures for Satisfiability and Validity in Propositional Logic

Symbolic Model Checking with ROBDDs

Tutorial 1: Modern SMT Solvers and Verification

Reduced Ordered Binary Decision Diagrams

Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel

Binary Decision Diagrams Boolean Functions

Reduced Ordered Binary Decision Diagrams

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 3: Practical SAT Solving

SAT Solvers: Theory and Practice

Binary Decision Diagrams and Symbolic Model Checking

SAT-Solving: From Davis- Putnam to Zchaff and Beyond Day 3: Recent Developments. Lintao Zhang

Boolean decision diagrams and SAT-based representations

Foundations of Artificial Intelligence

COMPRESSED STATE SPACE REPRESENTATIONS - BINARY DECISION DIAGRAMS

Basing Decisions on Sentences in Decision Diagrams

1 Algebraic Methods. 1.1 Gröbner Bases Applied to SAT

Binary Decision Diagrams

Clause/Term Resolution and Learning in the Evaluation of Quantified Boolean Formulas

Propositional Logic: Methods of Proof (Part II)

Binary Decision Diagrams

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Part 1: Propositional Logic

Binary Decision Diagrams

Combinational Equivalence Checking using Boolean Satisfiability and Binary Decision Diagrams

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011

QuIDD-Optimised Quantum Algorithms

CSE507. Introduction. Computer-Aided Reasoning for Software. Emina Torlak courses.cs.washington.edu/courses/cse507/17wi/

Computational Boolean Algebra. Pingqiang Zhou ShanghaiTech University

Binary Decision Diagrams. Graphs. Boolean Functions

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

Binary Decision Diagrams

VLSI CAD: Lecture 4.1. Logic to Layout. Computational Boolean Algebra Representations: Satisfiability (SAT), Part 1

BDD Based Upon Shannon Expansion

Topics in Model-Based Reasoning

CDM. Algorithms for Propositional Logic

Propositional and Predicate Logic. jean/gbooks/logic.html

LOGIC PROPOSITIONAL REASONING

Satisfiability Modulo Theories

Logic in AI Chapter 7. Mausam (Based on slides of Dan Weld, Stuart Russell, Dieter Fox, Henry Kautz )

Introduction to SAT (constraint) solving. Justyna Petke

CS156: The Calculus of Computation

The complexity of SPP formula minimization

Planning as Satisfiability

Reduced Ordered Binary Decision Diagram with Implied Literals: A New knowledge Compilation Approach

Propositional Logic: Methods of Proof (Part II)

Propositional Logic: Evaluating the Formulas

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Propositional Logic: Methods of Proof (Part II)

Sums of Products. Pasi Rastas November 15, 2005

Logic in AI Chapter 7. Mausam (Based on slides of Dan Weld, Stuart Russell, Subbarao Kambhampati, Dieter Fox, Henry Kautz )

From SAT To SMT: Part 1. Vijay Ganesh MIT

Propositional and First Order Reasoning

Lecture Notes on SAT Solvers & DPLL

Equivalence Checking of Sequential Circuits

Logical Agents. Chapter 7

Lecture 9: Search 8. Victor R. Lesser. CMPSCI 683 Fall 2010

Verification using Satisfiability Checking, Predicate Abstraction, and Craig Interpolation. Himanshu Jain THESIS ORAL TALK

Lecture 2 Propositional Logic & SAT

Finite-State Model Checking

Towards Understanding and Harnessing the Potential of Clause Learning

Part 1: Propositional Logic

Foundations of Artificial Intelligence

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Lecture 9: The Splitting Method for SAT

Price: $25 (incl. T-Shirt, morning tea and lunch) Visit:

A New Look at BDDs for Pseudo-Boolean Constraints

A Logically Complete Reasoning Maintenance System Based on a Logical Constraint Solver

Backdoor Sets for DLL Subsolvers

Optimization Bounds from Binary Decision Diagrams

CS 188: Artificial Intelligence Spring 2007

Chapter 2 Combinational Logic Circuits

Intelligent Agents. Pınar Yolum Utrecht University

Classical Propositional Logic

Propositional Logic: Methods of Proof. Chapter 7, Part II

Overview. Discrete Event Systems Verification of Finite Automata. What can finite automata be used for? What can finite automata be used for?

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

Logic. proof and truth syntacs and semantics. Peter Antal

CTL Model Checking. Wishnu Prasetya.

Anand Raghunathan MSEE 348

Binary Decision Diagrams

LUTMIN: FPGA Logic Synthesis with MUX-Based and Cascade Realizations

CS:4420 Artificial Intelligence

Introduction to Artificial Intelligence. Logical Agents

WHAT IS AN SMT SOLVER? Jaeheon Yi - April 17, 2008

Fundamental Algorithms for System Modeling, Analysis, and Optimization

13th International Conference on Relational and Algebraic Methods in Computer Science (RAMiCS 13)

Polynomial Methods for Component Matching and Verification

Multi-Terminal Multi-Valued Decision Diagrams for Characteristic Function Representing Cluster Decomposition

A Tool for Measuring Progress of Backtrack-Search Solvers

Propositional Calculus

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Mathematical Logic Part Three

Propositional Logic: Models and Proofs

Transcription:

EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving III & Binary Decision Diagrams Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: Lintao Zhang Announcement Project proposals due Feb 16 If you have a project topic (or area) in mind, discuss it with me in the next week Selected suggested project topics will be discussed in class/posted by next week. Homework 1 will be out ~ Feb 10. S. A. Seshia 2 1

DLL Algorithm Pseudo-code Preprocess Branch Propagate implications of that branch and deal with conflicts S. A. Seshia 3 DLL Algorithm Pseudo-code Main Steps: Pre-processing Branching Unit propagation (apply unit rule) Conflict Analysis & Backtracking S. A. Seshia 4 2

A Classification of SAT Algorithms Davis-Putnam (DP) Based on resolution Davis-Logemann-Loveland (DLL/DPLL) Search-based Basis for current most successful solvers Stalmarck s algorithm More of a breadth first search, proprietary algorithm Stochastic search Local search, hill climbing, etc. Unable to prove unsatisfiability (incomplete) S. A. Seshia 5 Stalmarck s algorithm: described on whiteboard (see reading for more details) Note: Stalmarck s algorithm is for tautology (validity) checking: Is formula F always 1 (on any input assignment)? S. A. Seshia 6 3

Proof Generation If the SAT solver returns satisfiable, we can check that solution by evaluating the circuit If it returns unsatisfiable, what then? S. A. Seshia 7 Proof Starting from facts (clauses), the SAT solver has presumably derived unsatisfiable (the empty clause) So there must be a way of going step-bystep from input clauses to the empty clause using rules In fact, there s only one rule: resolution S. A. Seshia 8 4

Resolution as a Cut in Implication Graph S. A. Seshia 9 Resolution Graph Nodes are clauses Edges are applications of resolution S. A. Seshia 10 5

Proof Checker Given resolution graph, how to check it? Traverse it, checking that each node is correctly obtained from its predecessor nodes using resolution S. A. Seshia 11 Unsatisfiable Core S. A. Seshia 12 6

Incremental SAT Solving Suppose you have not just one SAT problem to solver, but many slightly differing problems over the same variables Can we re-use the search over many problems? i.e. perform only incremental work S. A. Seshia 13 Operations Needed 1. Adding clauses 2. Deleting clauses Which is easy and which is hard? If previous problem is unsat, how does an operation change it? If previous is sat? S. A. Seshia 14 7

Deleting Clauses S. A. Seshia 15 Deleting Clauses S. A. Seshia 16 8

Engineering Issues Too expensive to traverse graph Instead, group original clauses into groups Each derived clause belongs to all groups that it is resolved from Implement with bit-vector S. A. Seshia 17 Binary Decision Diagrams S. A. Seshia 18 9

Boolean Function Representations Syntactic: e.g.: CNF, DNF, Circuit Semantic: e.g.: Truth table, Binary Decision Tree, BDD S. A. Seshia 19 Reduced Ordered BDDs Invented by Randal E. Bryant in mid-80s IEEE Transactions on Computers 1986 paper is one of the most highly cited papers in EECS Useful data structure to represent Boolean functions Applications in synthesis, verification, program analysis, planning, Commonly known simply as BDDs Many variants of BDDs have proved useful in other tasks Links to coding theory (trellises), etc. S. A. Seshia 20 10

Cofactors A Boolean function F of n variables x 1, x 2,, x n F : {0,1} n {0,1} Suppose we define new Boolean functions of n-1 variables as follows: F x1 (x 2,, x n ) = F(1, x 2, x 3,, x n ) F x1 (x 2,, x n ) = F(0, x 2, x 3,, x n ) F x1 and F x1 are called cofactors of F. F x1 is the positive cofactor, and F x1 is the negative cofactor S. A. Seshia 21 Shannon Expansion F(x 1,, x n ) = x i. F xi + x i. F xi Proof? S. A. Seshia 22 11

Shannon expansion with many variables F(x, y, z, w) = xy F xy + x y F x y + xy F xy + x y F x y S. A. Seshia 23 Properties of Cofactors Suppose you construct a new function H from two existing functions F and G: e.g., H = F H = F.G H = F + G Etc. What is the relation between cofactors of H and those of F and G? S. A. Seshia 24 12

Very Useful Property Cofactor of NOT is NOT of cofactors Cofactor of AND is AND of cofactors Works for any binary operator S. A. Seshia 25 BDDs from Truth Tables Truth Table Binary Decision Tree Binary Decision Diagram (BDD) Ordered Binary Decision Diagram (OBDD) Reduced Ordered Binary Decision Diagram (ROBDD, simply called BDD) S. A. Seshia 26 13

Example: Odd Parity Function a b c d Binary Decision Tree S. A. Seshia 27 Nodes & Edges S. A. Seshia 28 14

Ordering S. A. Seshia 29 Reduction Identify Redundancies 3 Rules: 1. Merge equivalent leaves 2. Merge isomorphic nodes 3. Eliminate redundant tests S. A. Seshia 30 15

Merge Equivalent Leaves S. A. Seshia 31 Merge Isomorphic Nodes S. A. Seshia 32 16

Eliminate Redundant Tests S. A. Seshia 33 Example S. A. Seshia 34 17

Example S. A. Seshia 35 Final ROBDD for Odd Parity Function S. A. Seshia 36 18

Example of Rule 3 S. A. Seshia 37 What can BDDs be used for? Uniquely representing a Boolean function And a Boolean function can represent sets Satisfiability solving! S. A. Seshia 38 19

(RO)BDDs are canonical Theorem (R. Bryant): If G, G are ROBDD s of a Boolean function f with k inputs, using same variable ordering, then G and G are identical. S. A. Seshia 39 Sensitivity to Ordering Given a function with n inputs, one input ordering may require exponential # vertices in ROBDD, while other may be linear in size. Example: f = x 1 x 2 + x 3 x 4 + x 5 x 6 x 1 < x 2 < x 3 < x 4 < x 5 < x 6 x 1 < x 4 < x 5 < x 2 < x 3 < x 6 3 5 1 6 2 4 0 1 S. A. Seshia 40 5 3 4 5 1 2 3 5 4 2 5 2 6 0 1 2 20

Creating BDDs Idea: Build a few core operators and define everything else in terms of those Advantage: Less programming work Easier to add new operators later by writing wrappers S. A. Seshia 41 Core Operators Just two of them! 1. Restrict(Function F, variable v, constant k) Shannon cofactor of F w.r.t. v=k 2. ITE(Function I, Function T, Function E) if-then-else operator S. A. Seshia 42 21

Just like: ITE if then else in a programming language A mux in hardware ITE(I(x), T(x), E(x)) If I(x) then T(x) else E(x) T(x) E(x) 1 0 ITE(I(x), T(x), E(x)) I(x) S. A. Seshia 43 The ITE Function ITE( I(x), T(x), E(x) ) = I(x). T(x) + I (x). E(x) S. A. Seshia 44 22

What good is the ITE? How do we express NOT? OR? AND? S. A. Seshia 45 How do we implement ITE? Divide and conquer! Use Shannon cofactoring Recall: Operator of cofactors is Cofactor of operators S. A. Seshia 46 23

ITE Algorithm ITE (bdd I, bdd T, bdd E) { if (terminal case) { return computed result; } else { // general case Let x be the topmost variable of I, T, E; PosFactor = ITE(I x, T x, E x ) ; NegFactor = ITE(I x, T x, E x ); R = new node labeled by x; R.low = NegFactor; // set 0-child R.high = PosFactor; // set 1-child Reduce(R); // apply reduction rules return R; } S. A. Seshia 47 Terminal Cases ITE(1, T, E) = ITE(0, T, E) = ITE(I, T, T) = ITE(I, 1, 0) = S. A. Seshia 48 24

General Case Still need to do cofactor (Restrict) Easy operation in the case of ITE We are cofactoring w.r.t. the top variable only Cofactoring w.r.t. an internal variable is trickier S. A. Seshia 49 Practical Issues Previous calls to ITE are cached memoization Every BDD node created goes into a unique table Before creating a new node R, look up this table Avoids need for reduction S. A. Seshia 50 25

Sharing: Multi-Rooted DAG BDD for 4-bit adder Each output bit (of the sum & carry) is a distinct rooted BDD But they share sub- DAGs S. A. Seshia 51 More on BDDs Circuit width and bounds on BDD size Dynamically changing variable ordering Some BDD variants S. A. Seshia 52 26

Bounds on BDD Size: Warm-up Suppose the number of nodes at any level in a BDD is bounded above by B Then, what is an upper bound on the total number of nodes in the BDD? S. A. Seshia 53 Cross-section of a BDD at level i Suppose a BDD represents Boolean function F(x 1, x 2,, x n ) with variable order x 1 < x 2 < < x n Size of cross section of the BDD at level i is the number of distinct Boolean functions F that depend on x i given by F (x i, x i+1,, x n ) = F(v 1, v 2,, v i-1, x i,, x n ) for some Boolean constants v i s (in {0,1}) S. A. Seshia 54 27

Circuit Width Consider a circuit representation of a Boolean function F Impose a linear order on the gates of the circuit Primary inputs and outputs are also considered as gates and primary output is at the end of the ordering Forward cross section at a gate g: set of wires going from output of g 1 to input of g 2 where g 1 g < g 2 Similarly define reverse cross section: set of wires going from output of g 1 to input of g 2 where g 2 g < g 1 Forward width (w f ): maximum forward cross section size Similarly, reverse width w r S. A. Seshia 55 BDD Upper Bounds from Circuit Widths Theorem: Let a circuit representing F with n variables have forward width w f and reverse width w r for some linear order L on its gates. Then, there is a BDD representing F of size bounded above by S. A. Seshia 56 28

BDD Ordering in Practice If we can derive a small upper bound using circuit width, then that s fine Use the corresponding linear order on the variables What if we can t? There are many BDD variable ordering heuristics around, but the most common way to deal with variable ordering is to start with something reasonable and then swap variables around to improve BDD size DYNAMIC VARIABLE REORDERING SIFTING S. A. Seshia 57 Sifting Dynamic variable re-ordering, proposed by R. Rudell Based on a primitive swap operation that interchanges x i and x i+1 in the variable order Key point: the swap is a local operation involving only levels i and i+1 Overall idea: pick a variable x i and move it up and down the order using swaps until the process no longer improves the size A hill climbing strategy S. A. Seshia 58 29

Some BDD Variants Free BDDs (FBDDs) Relax the restriction that variables have to appear in the same order along all paths How can this help? Is it canonical? S. A. Seshia 59 Some BDD Variants MTBDD (Multi-Terminal BDD) Represents function of Boolean variables with non-boolean value (integer, rational) E.g., input-dependent delay in a circuit, transition probabilities in a Markov chain Similar reduction / construction rules to BDDs S. A. Seshia 60 30

Some BDD packages CUDD from Colorado University, Fabio Somenzi s group BuDDy from IT Univ. of Copenhagen S. A. Seshia 61 31