Motivation. CS389L: Automated Logical Reasoning. Lecture 5: Binary Decision Diagrams. Historical Context. Binary Decision Trees

Similar documents
Binary Decision Diagrams (BDD)

Boolean Representations and Combinatorial Equivalence

Binary Decision Diagrams

Behavior models and verification Lecture 6

Model Checking I Binary Decision Diagrams

ECE 5775 (Fall 17) High-Level Digital Design Automation. Binary Decision Diagrams Static Timing Analysis

Formal Verification. Lecture 7: Introduction to Binary Decision Diagrams (BDDs)

Unit 4: Formal Verification

EECS 219C: Formal Methods Binary Decision Diagrams (BDDs) Sanjit A. Seshia EECS, UC Berkeley

CS357 Lecture: BDD basics. David Dill

Symbolic Model Checking

Binary Decision Diagrams (BDDs) Pingqiang Zhou ShanghaiTech University

Lecture Notes on Binary Decision Diagrams

Binary Decision Diagrams

Chapter 8: Data Abstractions

Binary Decision Diagrams and Symbolic Model Checking

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

8.1 Polynomial-Time Reductions

Synthesis 1. 1 Figures in this chapter taken from S. H. Gerez, Algorithms for VLSI Design Automation, Wiley, Typeset by FoilTEX 1

Solving 3-SAT. Radboud University Nijmegen. Bachelor Thesis. Supervisors: Henk Barendregt Alexandra Silva. Author: Peter Maandag s

Binary Decision Diagrams

Normal Forms for Boolean Expressions

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Logic Synthesis & Optimization Lectures 4, 5 Boolean Algebra - Basics

Formal Verification Methods 2: Symbolic Simulation

Symbolic Manipulation of Boolean Functions Using a Graphical Representation. Abstract

1/28/2013. Synthesis. The Y-diagram Revisited. Structural Behavioral. More abstract designs Physical. CAD for VLSI 2

Lecture1: Symbolic Model Checking with BDDs. Edmund M. Clarke, Jr. Computer Science Department Carnegie Mellon University Pittsburgh, PA 15213

Motivation. CS389L: Automated Logical Reasoning. Lecture 17: SMT Solvers and the DPPL(T ) Framework. SMT solvers. The Basic Idea.

L4: Binary Decision Diagrams. Reading material

Array Dependence Analysis as Integer Constraints. Array Dependence Analysis Example. Array Dependence Analysis as Integer Constraints, cont

ABC basics (compilation from different articles)

Graph-Based Algorithms for Boolean Function Manipulation

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

Advanced VLSI Design Prof. Virendra K. Singh Department of Electrical Engineering Indian Institute of Technology Bombay

A Firewall Application Using Binary Decision Diagram

NP and computational intractability. Kleinberg and Tardos, chapter 8

4.1 Review - the DPLL procedure

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

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

2009 Haskell January Test Binary Decision Diagrams

Symbolic Boolean Manipulation with Ordered Binary Decision Diagrams

Program verification. Generalities about software Verification Model Checking. September 20, 2016

BDDC v2 A basic bdd-based logical calculator

BDDC v2 A basic bdd-based logical calculator

Discrete Optimization. Lecture Notes 2

Theory of Integers. CS389L: Automated Logical Reasoning. Lecture 13: The Omega Test. Overview of Techniques. Geometric Description

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

Small Formulas for Large Programs: On-line Constraint Simplification In Scalable Static Analysis

On the Relation between SAT and BDDs for Equivalence Checking

L3: Representations of functions

Announcements. CS243: Discrete Structures. Strong Induction and Recursively Defined Structures. Review. Example (review) Example (review), cont.

SAT-CNF Is N P-complete

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

On Proof Systems Behind Efficient SAT Solvers. DoRon B. Motter and Igor L. Markov University of Michigan, Ann Arbor

The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Local Two-Level And-Inverter Graph Minimization without Blowup

Boolean Functions (Formulas) and Propositional Logic

A Relational View of Subgraph Isomorphism

Chapter 8. NP-complete problems

Some Hardness Proofs

VLSI System Design Part II : Logic Synthesis (1) Oct Feb.2007

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Lecture 14: Lower Bounds for Tree Resolution

A purely functional implementation of ROBDDs in Haskell

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

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

Lossless Compression Algorithms

Read-Once Functions (Revisited) and the Readability Number of a Boolean Function. Martin Charles Golumbic

LOGIC SYNTHESIS AND VERIFICATION ALGORITHMS. Gary D. Hachtel University of Colorado. Fabio Somenzi University of Colorado.

ALGORITHMS EXAMINATION Department of Computer Science New York University December 17, 2007

PROPOSITIONAL LOGIC (2)

Decision Procedures. An Algorithmic Point of View. Decision Procedures for Propositional Logic. D. Kroening O. Strichman.

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 9 Normal Forms

A Satisfiability Procedure for Quantified Boolean Formulae

Unification in Maude. Steven Eker

ACKNOWLEDGEMENTS. my thesis committee and for their input on this document. effort. This research was funded under NSF contract MIP

VLSI Logic Test, Validation and Verification Lecture 7 Properties & Applications of Binary Decision Diagrams

Combinatorial Optimization

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

A New Algorithm to Create Prime Irredundant Boolean Expressions

Where Can We Draw The Line?

Solving Boolean Equations with BDDs and Clause Forms. Gert Smolka

Advanced Digital Logic Design EECS 303

Simplified Digital Logic Circuits Using Binary Decision Tree

EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley

Representations of Terms Representations of Boolean Networks

Computability Theory

NP-Completeness. Algorithms

Reference Sheet for CO142.2 Discrete Mathematics II

Research Collection. Formal background and algorithms. Other Conference Item. ETH Library. Author(s): Biere, Armin. Publication Date: 2001

POWR IP PZ1/17

Algorithms Dr. Haim Levkowitz

Binary Decision Diagram with Minimum Expected Path Length

COMP combinational logic 1 Jan. 18, 2016

Treewidth and graph minors

Some Applications of Graph Bandwidth to Constraint Satisfaction Problems

Discrete mathematics

Chapter 9 Graph Algorithms

Transcription:

Motivation CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams Işıl Dillig Previous lectures: How to determine satisfiability of propositional formulas Sometimes need to efficiently represent all solutions (i.e., satisfying assignments) to the formula Binary decision diagrams (BDDs): compact representation of all satisfying assignments of formula Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 1/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 2/39 Historical Context Binary Decision Trees Invented by Randal Bryant from CMU; introduced in very influential 1986 paper BDDs have many applications: hardware and software verification, computer aided design of circuits, relational databases,... Don Knuth in 2008: One of the really fundamental data structures that came out in the last 25 years Before talking about BDDs, let us first consider a simpler data structure called binary decision tree Binary decision tree: A tree data strcuture with two kinds of vertices, terminal and non-terminal Terminal vertices: boolean constants (1) and (0) Non-terminal vertex labeled v corresponds to boolean variable v in propositional formula Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 3/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 4/39 Binary Decision Trees, cont. Each non-terminal vertex has two successors (i.e., edges) Example: Binary Decision Tree Binary decision tree for formula with variables x 1, x 2, x 3 : Low successor of non-terminal vertex v (labeled with dashed edge) corresponds to assigning 0 to v High successor of vertex v (labeled with solid edge) corresponds to assigning 1 to v Each path from root to a terminal node corresponds to an interpretation for the formula Paths ending in 1 correspond to satisfying interpretations Paths ending in 0 correspond to falsifying interpretations Question: Is interpretation x 1 =, x 2 =, x 3 = satisfying? Question: What about x 1 =, x 2 =, x 3 =? This BDT is ordered: Any path from the root to a terminal contains variables in the same order (order: x 1 < x 2 < x 3 ) Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 5/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 6/39 1

Binary Decision Tree vs. Truth Table Reduced Ordered Binary Decision Diagram Binary decision tree encodes all satisfying assignments, but how does it compare to truth tables? Good news: Not as bad as it looks; there is a lot of redundancy! (e.g., different subparts of the tree are isomorphic) Idea: Merge redundant subparts and compress BDT into a much more space-efficient DAG representation! To understand how to generate more compact representation, start with a ordered binary decision tree and apply a set of reduction rules There are three reduction rules; we apply these rules until none of them can be further applied The resulting data structure is called a reduced ordered binary decision diagram (ROBDD) When we talk about BDDs, we really mean ROBDDs (and so does everyone else) Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 7/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 8/39 Reduction Rule #1 Reduction Rule #2 Reduction rule #1: Merge all terminal nodes 1 into one node, and merge all terminal nodes 0 into one node. Reduction rule #2: Merge isomorphic subgraphs Two subgraphs are isomorphic if: 1. Their root represents the same variable 2. The subgraphs rooted at their low successors are isomorphic 3. The subgraphs rooted at their high successors are also isomorphic Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 9/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 10/39 Example: Merging Isomorphic Subtrees Reduction Rule #3 Reduction rule #3: Remove redundant nodes. Node v is redundant if its low and high successors are the same. Why? Which subgraphs are isomorphic? Eliminating redundant node v: Remove v from the graph, and redirect incoming edge to v to v s children Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 11/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 12/39 2

Example: Removing Redundant Nodes Exposing New Reductions Question: Can removing redundant nodes expose new isomorphic subtrees? (i.e., do we need to apply reduction 2 again after reduction 3?) Example: Are there any isomorphic subparts in this graph? Which nodes are redundant? x3 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 13/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 14/39 Exposing New Reductions, cont. Question: Can merging isomorphic subgraphs expose new redundant nodes? (i.e., do we need to apply reduction 3 again after reduction 2?) Example: Are there any redundant nodes in this graph? Applying Reductions As examples illustrate, we may need to apply reduction rules again after each reduction Thus, have to apply reductions 2 and 3 until no isomorphic subgraphs and no redundant nodes left Resulting data structure after exhaustive application of reduction rules is a ROBDD. ROBDD is more space efficient compared to the binary decision tree because it eliminates redundancies. Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 15/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 16/39 Building ROBDDs Building BDDs directly from Formulas Starting with BDT and applying reduction rule useful way to understand BDD invariants But no one builds BDDs this way. Why? Idea: Build the ROBDD for a formula directly without building the binary decision tree! Consider a formula φ of the form φ 1 φ 2 where is any boolean connective To construct the ROBDD for φ, first recursively construct the ROBDDs for φ 1 and φ 2 Then, combine BDDs for φ 1 and φ 2 to form the BDD for φ To combine BDDs for φ 1 and φ 2, will use a technique called Shannon s decomposition Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 17/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 18/39 3

Cofactoring and Shannon s Decomposition Shannon s decomposition involves an operation called cofactoring. Cofactoring a boolean formula restricts the formula to a particular value of a variable. Example: What is the resulting formula when we restrict x 1 to in x 1 x 2? The positive cofactor φ x i is the resulting formula when x i is replaced by The negative cofactor φ x i is φ with x i replaced by Cofactoring Using BDDs If we have a BDD for φ, it is easy to build BDD for positive and negative cofactors of φ with respect to x Given BDD for φ, how do we build BDD for φ x? How do we build BDD for φ x? Example: What is (x 1 ( x 2 x 3 )) x 2? Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 19/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 20/39 Cofactoring Example Shannon s Decomposition What is the BDD representing φ x 2? Can now define Shannon s decomposition using cofactors. Shannon s decomposition: φ (x φ x) ( x φ x) Basically a case analysis on x s truth value If x is, then the positive cofactor must be true If x is, then the negative cofactor must be true Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 21/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 22/39 Using Shannon s Decomposition to Build BDD Apply: Case #1 Now, we can directly build BDD for a formula φ 1 φ 2 using Shannon s decomposition First, build BDD for subformulas φ 1 and φ 2 Then, use operation called Apply to build BDD for φ from BDDs for φ 1 and φ 2 The Apply operation considers three cases Case #1: Suppose that the BDDs for φ 1 and φ 2 have root nodes x and x and both are boolean constants Then, what is the BDD for φ 1 φ 2? This is the base case for our Apply procedure. Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 23/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 24/39 4

Apply: Case #2 Case #2: Root nodes x and x are not boolean constants, and either x = x or x preeceds x in the variable order. Since x comes first in variable order, we ll first do a case analysis on x using Shannon s decomposition Using Shannon s decomp., what is φ 1 φ 2 equivalent to? Cofactoring distributes over connectives, so rewrite as: (x (φ 1 x φ 2 x) ( x (φ 1 x φ 2 x)) Apply: Case #2, continued Thus, we need to build BDD for: (x (φ 1 x φ 2 x) ( x (φ 1 x φ 2 x)) We know how to build BDDs for φ i x and φ i x How do we build BDDs for (φ 1 x φ 2 x) and (φ 1 x φ 2 x)? What is the progress/termination argument? Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 25/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 26/39 Apply: Case #2, continued Now, assume we have the BDDs for (φ 1 x φ 2 x) and (φ 1 x φ 2 x). Using these, how do we build BDD for the whole formula? (x (φ 1 x φ 2 x) ( x (φ 1 x φ 2 x)) 1. Make a new non-terminal node for variable x 2. The low successor of this node is the BDD for the negative cofactor (φ 1 x φ 2 x) 3. The high successor of this node is the BDD for the positive cofactor (φ 1 x φ 2 x) Apply: Case #3 Case #3: Root nodes x and x are not boolean constants, and x preceeds x in the variable order. This case is completely symmetric to previous case, and we again handle it using Shannon s decomposition. Only difference: perform Shannon s decomposition using x instead of x Note: We still need to apply the three reduction rules to ensure no redundancies. Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 27/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 28/39 An Example Example, continued Consider formula φ 1 φ 2 where φ 1 is x 1 x 2, and φ 2 is x 2 Suppose x 1 preceeds x 2 in variable order Assume we have BDDs for φ 1 and φ 2 : Since x 1 preeceds x 2 in variable order, what do we perform case split on? How do we decompose φ 1 φ 2 using Shannon s decomposition? Thus, we recursively compute BDDs for (φ 1 x 1 φ 2 x 1 ) and (φ 1 x 1 φ 2 x 1 ). We want to use Apply to compute BDD for φ 1 φ 2 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 29/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 30/39 5

Example, continued Example, continued Assuming we computed the BDDs for negative and positive cofactors, BDD for φ 1 φ 2 looks like: Final BDD: BDD for negative cofactor BDD for positive cofactor Here, the positive cofactor is just 1 Negative cofactor is: What is the final BDD? Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 31/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 32/39 Example 2 Rest Of Lecture Give the BDD representing the negation of the following BDD: So far: talked about what BDDs are and how to construct them In addition to compactly representing all satisfying interpretations, BDDs have some other useful properties Rest of lecture: Talk about some interesting properties of BDDs Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 33/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 34/39 Important Property of BDDs: Canonicity Consequences of Canonicity BDDs are a canonical representation of boolean formulas. Canonical means two equivalent formulas have same representation Thus, if we construct BDDs for two equivalent formulas using same variable order, resulting BDDs are the same! Are any of the normal forms we talked about (NNF, CNF, DNF) canonical? Example: Corollary 1: Given BDDs for φ 1 and φ 2 constructed with same variable order, equivalence of φ 1 and φ 2 just syntactic check Corollary 2: Given BDD for formula φ, φ is unsatisfiable if and only if its BDD respresentation is the boolean constant 0. How does this corollary follow from canonicity? Corollary 3: Given BDD for formula φ, φ is valid if and only if its BDD respresentation is the boolean constant 1. Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 35/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 36/39 6

BDD Size and Variable Order Choosing Variable Order Another important BDD property: Size of a BDD for a given formula φ is very sensitive to variable order! For some variable orders, the size of the BDD may be only polynomial in the number of variables For some other variable orders, the size of the BDD for same formula may be exponential. Furthermore, there are boolean formulas for which any variable order causes an exponential blow-up Since size of BDD is so sensitive to variable order, we would like to construct BDD using a good variable order Unfortunately, NP-complete to decide whether a given order is optimal Typically, heuristics are used to predict good variable order Heuristics for finding good variable order can be either static (i.e., determined up-front) or dynamic (i.e., change as BDD operations proceed) Dynamic orders typically yield more compact BDDs, but slower Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 37/39 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 38/39 Summary BDDs can be used to compactly represent all satisfying assignments to a boolean formula Pros: + Canonical representation checking equivalence, validity, satisfiability constant time operations once BDD is built + If we have good variable order, can yield a compact representation of all satisfying assignments of formula Cons: - Compactness very sensitive to variable order - Can cause an exponential blow-up in the representation of the formula Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 5: Binary Decision Diagrams 39/39 7