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

Similar documents
Binary Decision Diagrams (BDD)

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

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

Symbolic Model Checking

Unit 4: Formal Verification

Boolean Representations and Combinatorial Equivalence

Binary Decision Diagrams

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

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

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

Model Checking I Binary Decision Diagrams

Boolean Functions (Formulas) and Propositional Logic

On the Relation between SAT and BDDs for Equivalence Checking

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

CS357 Lecture: BDD basics. David Dill

Binary Decision Diagrams (BDDs) Pingqiang Zhou ShanghaiTech University

Binary Decision Diagrams and Symbolic Model Checking

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

Behavior models and verification Lecture 6

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

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

EECS 219C: Formal Methods Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley

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

Binary Decision Diagrams

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

Lecture Notes on Binary Decision Diagrams

ABC basics (compilation from different articles)

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

L4: Binary Decision Diagrams. Reading material

Binary Decision Diagrams

Binary Decision Diagram with Minimum Expected Path Length

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

Synthesis of 2-level Logic Heuristic Method. Two Approaches

A Relational View of Subgraph Isomorphism

Lower Bound on Comparison-based Sorting

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

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

Logic Synthesis and Verification

EECS 219C: Formal Methods Syntax-Guided Synthesis (selected/adapted slides from FMCAD 13 tutorial by R. Alur) Sanjit A. Seshia EECS, UC Berkeley

QUESTION BANK FOR TEST

Solving Boolean Equations with BDDs and Clause Forms. Gert Smolka

K-terminal Network Reliability Evaluation Using Binary Decision Diagram

A Satisfiability Procedure for Quantified Boolean Formulae

Formal Equivalence Checking. Logic Verification

Chapter 6: Multilevel Combinational Circuits. Name: Lương Văn Minh No. :

Boolean Satisfiability Solving Part II: DLL-based Solvers. Announcements

On the Use of Autocorrelation Coefficients in the Identification of Three-Level Decompositions

L3: Representations of functions

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

Representations of Terms Representations of Boolean Networks

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

Standard Boolean Forms

Reasoning about Timed Systems Using Boolean Methods

Voting Machines and Automotive Software: Explorations with SMT at Scale

Binary Decision Diagrams and Beyond: Enabling Technologies for Formal Verification

Cofactoring-Based Upper Bound Computation for Covering Problems

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

A purely functional implementation of ROBDDs in Haskell

Introduction to Embedded Systems

Binary Heaps in Dynamic Arrays

Finite Model Generation for Isabelle/HOL Using a SAT Solver

BoolTool: A Tool for Manipulation of Boolean Functions

CS 267: Automated Verification. Lecture 13: Bounded Model Checking. Instructor: Tevfik Bultan

DISCRETE MATHEMATICS

Lazy Group Sifting for Efficient Symbolic State Traversal of FSMs

Lecture 14: Lower Bounds for Tree Resolution

On Resolution Proofs for Combinational Equivalence Checking

Symbolic Boolean Manipulation with Ordered Binary Decision Diagrams

Combinational Circuits

Quantitative Verification and Synthesis of Systems

HECTOR: Formal System-Level to RTL Equivalence Checking

IMPLEMENTATION OF SWITCHING CIRCUIT MODELS AS VECTOR SPACE TRANSFORMATIONS

Symbolic Manipulation of Boolean Functions Using a Graphical Representation. Abstract

Chapter 8: Data Abstractions

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

(Refer Slide Time 3:31)

NO WARRANTY. Use of any trademarks in this presentation is not intended in any way to infringe on the rights of the trademark holder.

Fast Boolean Matching for Small Practical Functions

Reference Sheet for CO142.2 Discrete Mathematics II

Fast Generation of Lexicographic Satisfiable Assignments: Enabling Canonicity in SAT-based Applications

Parameterized Reductions

CS521 \ Notes for the Final Exam

NP-Completeness. Algorithms

Combinational Equivalence Checking

IMPLEMENTATION OF HYBRID EVOLUTIONARY ALGORITHM FOR BDD OPTIMIZATION BY FINDING OPTIMUM VARIABLE ORDERING

Formal Verification Methods 2: Symbolic Simulation

Application of Binary Decision Diagram in digital circuit analysis.

IEEE Transactions on computers

An Annotated Language

Layout-Driven Synthesis For Submicron Technology : Mapping Expansions To Regular Lattices. High Level Synthesis Homework # /10/08 SeonPil Kim

Reductions and Satisfiability

Scan and its Uses. 1 Scan. 1.1 Contraction CSE341T/CSE549T 09/17/2014. Lecture 8

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Design of Framework for Logic Synthesis Engine

EECS Components and Design Techniques for Digital Systems. Lec 07 PLAs and FSMs 9/ Big Idea: boolean functions <> gates.

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

On Resolution Proofs for Combinational Equivalence

Summary of Course Coverage

Algorithms and Data Structures: Lower Bounds for Sorting. ADS: lect 7 slide 1

structure syntax different levels of abstraction

Transcription:

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

Boolean Function Representations Syntactic: e.g.: CNF, DNF (SOP), Circuit Semantic: e.g.: Truth table, Binary Decision Tree, BDD S. A. Seshia 2

Reduced Ordered BDDs Introduced 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 logic synthesis, verification, program analysis, AI planning, Commonly known simply as BDDs Lee [1959] and Akers [1978] also presented BDDs, but not ROBDDs Many variants of BDDs have also proved useful Links to coding theory (trellises), etc. 3

RoadMap for this Lecture Cofactor of a Boolean function From truth table to BDD Properties of BDDs Operating on BDDs Variants 4

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 xi and F xi are called cofactors of F. F xi is the positive cofactor, and F xi is the negative cofactor 5

Shannon Expansion F(x 1,, x n ) = x i. F xi + x i. F xi Proof? 6

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 7

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? 8

Very Useful Property Cofactor of NOT is NOT of cofactors Cofactor of AND is AND of cofactors Works for any binary operator 9

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) 10

Example: Odd Parity Function a b c d Edge labels along a rootleaf path form an assignment to a,b,c,d Binary Decision Tree 11

Nodes & Edges 12

Ordering: variables appear in same order from root to leaf along any path Each node is some cofactor of the function 13

Reduction Identify Redundancies 3 Rules: 1. Merge equivalent leaves 2. Merge isomorphic nodes 3. Eliminate redundant tests 14

Merge Equivalent Leaves 15

Merge Isomorphic Nodes 16

Eliminate Redundant Tests 17

Example 18

Example 19

Final ROBDD for Odd Parity Function 20

Example of Rule 3 21

What can BDDs be used for? Uniquely representing a Boolean function And a Boolean function can represent sets Symbolic simulation of a combinational (or sequential) circuit Equivalence checking and verification Satisfiability (SAT) solving Finding / counting all solutions to a SAT (combinatorial) problem Operations on quantified Boolean formulas 22

(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. 23

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 1 2 3 4 5 6 0 1 x 1 < x 4 < x 5 < x 2 < x 3 < x 6 1 5 4 5 5 4 2 3 3 5 2 2 2 6 0 1 24

Constructing BDDs in Practice Strategy: Define how to perform basic Boolean operations 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 25

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 26

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) 27

The ITE Function ITE( I(x), T(x), E(x) ) = I(x). T(x) + I (x). E(x) 28

What good is the ITE? How do we express NOT? OR? AND? 29

How do we implement ITE? Divide and conquer! Use Shannon cofactoring Recall: Operator of cofactors is Cofactor of operators 30

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; // R.low is 0-child of R R.high = PosFactor; // R.high is 1-child of R Reduce(R); return R; } 31

Terminal Cases (complete these) ITE(1, T, E) = ITE(0, T, E) = ITE(I, T, T) = ITE(I, 1, 0) = 32

General Case Still need to do cofactor (Restrict) w.r.t. a variable v What if v is the top-most variable? If not? 33

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 34

Sharing: Multi-Rooted DAG BDD for 4-bit adder: 5 output bits 5 Boolean functions Each output bit (of the sum & carry) is a distinct rooted BDD But they share sub- DAGs 35

More on BDDs Circuit width and bounds on BDD size (reading exercise slide summary posted) Dynamically changing variable ordering Some BDD variants 36

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? 37

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}) 38

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 39

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 40

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 41

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 42

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? smaller BDD Is it canonical? NO 43

Some BDD Variants MTBDD (Multi-Terminal BDD) Terminal (leaf) values are not just 0 or 1, but some finite set of numerical values 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 44

Some BDD packages CUDD from Colorado University, Fabio Somenzi s group Front-ends to CUDD in various languages including Perl and Python BuDDy from IT Univ. of Copenhagen 45

Reading Bryant s 1992 survey paper is required reading (posted on bcourses) Optional reading: Don Knuth s chapter on BDDs (posted on bcourses) 46