Binary Decision Diagrams BDDs Daniel Kroening and Ofer
Binary Decision Diagrams (BDDs) Daniel Kroening and Ofer Strichman 1/20 Binary Decision Diagrams Charngki Hong @ PSWLAB
� Reminders - Part I � What is Logic � Proofs by deduction � Proofs by enumeration � Decidability, Soundness and Completeness � some notes on Propositional Logic Deciding � Propositional Logic � SAT tools � BDDs 2/20 Binary Decision Diagrams Charngki Hong @ PSWLAB
Next: Binary Decision Diagrams � SAT looked for a satisfying solution to CNF � We will now examine a graph-based data structure called Binary Decision Diagrams. � It has several advantages and disadvantages comparing to SAT � Developed by Bryant [1986]. Next few slides are from the source … 3/20 Binary Decision Diagrams Charngki Hong @ PSWLAB
Alternate Approach � Generate complete representation of function (A ∧ C) ∨ (C ∧ B) � A Canonicity: functions are equal iff representations are identical B C 0 1 (A Ç B) Æ (C) A B C 0 4/20 Binary Decision Diagrams 1 Charngki Hong @ PSWLAB
Decision Structures Truth Table Decision Tree � Vertex represents decision � Follow green (dashed) line for value 0 � Follow red (solid) line for value 1 � Function value determined by leaf value. 5/20 Binary Decision Diagrams Charngki Hong @ PSWLAB
Variable Ordering � Assign � arbitrary total ordering to variables e. g. , x 1 < x 2 < x 3 � Variables must appear in ascending order along all paths OK Not OK x 3 x 1 x 2 x 1 6/20 Binary Decision Diagrams x 3 Charngki Hong @ PSWLAB
Reduction Rule #1 Merge equivalent leaves a 7/20 a Binary Decision Diagrams a Charngki Hong @ PSWLAB
Reduction Rule #2 Merge isomorphic nodes 8/20 x x x y z y z Binary Decision Diagrams Charngki Hong @ PSWLAB
Reduction Rule #3 Eliminate Redundant Tests x y 9/20 y Binary Decision Diagrams Charngki Hong @ PSWLAB
Example OBDD Initial Graph Reduced Graph (x 1 Ç x 2) Æ x 3 � Canonical representation of Boolean functions For a given variable ordering � Two functions are equivalent iff graphs are isomorphic o � Can be tested in linear time � Desirable 10/20 property: simplest form is canonical. Binary Decision Diagrams Charngki Hong @ PSWLAB
Satisfiability etc. Constants Unique unsatisfiable function Unique tautology � Conclusion: given a BDD it takes constant time to check: � Validity � Contradiction � Satisfiability � Is this a free lunch ? … 11/20 Binary Decision Diagrams Charngki Hong @ PSWLAB
Effect of Variable Ordering Good Ordering Linear Growth 12/20 Bad Ordering Exponential Growth Binary Decision Diagrams Charngki Hong @ PSWLAB
Selecting Good Variable Ordering � Intractable Problem � Even when problem represented as OBDD � i. e. , � to find optimum improvement to current ordering Application-Based Heuristics � Exploit characteristics of application � e. g. , Ordering for functions of combinational circuit � Traverse 13/20 circuit graph depth-first from outputs to inputs Binary Decision Diagrams Charngki Hong @ PSWLAB
Building BDDs ‘from below’ � Starting from a binary decision tree is too hard formulas with many variables. � Goal: construct the BDD ‘from below’. 14/20 Binary Decision Diagrams Charngki Hong @ PSWLAB
Building BDDs ‘from below’ � For this we will need a function called APPLY: � Given the BDDs for f 1 and f 2, � and a binary connective F 2 {Æ, Ç, !, $. . . } (any one of the 16 binary connectives), � Construct the BDD for f 1 F f 2, 15/20 Binary Decision Diagrams Charngki Hong @ PSWLAB
Building BDDs ‘from below’ � Def: a restriction of a function f to x=d, denoted f|x=d where x 2 vars(f), d 2 {0, 1}, is equal to f after assigning x=d. � Given the BDD of f, deriving the BDD of f|x=0 is simple: f|x 2=1 f: (x 1 Ç x 2) Æ x 3 x 1 x 3 0 16/20 1 Binary Decision Diagrams 0 1 Charngki Hong @ PSWLAB
Now, APPLY (1/3) � 1. Let v 1, v 2 denote that root nodes of f 1, f 2, respectively, with var(v 1) = x 1 and var(v 2)=x 2. If v 1 and v 2 are leafs, f 1 F f 2 is a leaf node with value val(v 1) F val(v 2) 17/20 0 Ç 1 = 1 0 Æ 1 = 0 Binary Decision Diagrams Charngki Hong @ PSWLAB
Now, APPLY (2/3) 2. If x 1 = x 2 = x, apply Shanon expansion: f 1 F f 2 = (: x Æ f 1|x=0 F f 2|x=0 Ç x Æ f 1|x=1 F f 2|x=1) x x x Æ BDD for f 1|x=0 18/20 BDD for f 1|x=1 = BDD for f 2|x=0 BDD for f 2|x=1 Binary Decision Diagrams BDD for f 1|x=0 Æ f 2|x=0 BDD for f 1|x=1 Æ f 2|x=1 Charngki Hong @ PSWLAB
Now, APPLY (3/3) 3. else, suppose x 1 < x 2 in the variable order. f 1 F f 2 = (: x 1 Æ f 1|x=0 F f 2 Ç x 1 Æ f 1|x=1 F f 2) x 1 BDD for f 1|x 1=0 19/20 Æ BDD for f 1|x 1=1 x 2 BDD for f 2|x 2=0 = BDD for f 2|x 2=1 Binary Decision Diagrams BDD for f 1|x=0 Æ f 2 BDD for f 1|x=1 Æ f 2 Charngki Hong @ PSWLAB
BDDs from below: example. x 1 x 2 x 2 Ç 1 0 = 1 BDD for f 1|x 1=0 Ç f 2 BDD for f 1|x 1=1 Ç f 2: : x 2 0 20/20 = 0 f 1 : x 1 $ x 2 BDD for f 1|x 1=0 Ç f 2 x 1 x 2 Ç 1 x 2 = 0 1 0 Ç 0 = 0 Charngki Hong 1@ÇPSWLAB 1=1 Binary Decision Diagrams
BDDs from below: example. x 1 x 2 Ç 1 0 x 2 = 0 1 f 2: : x 2 f 1 : x 1 $ x 2 x 1 BDD for f 1|x=0 Ç f 2 f 1 Ç f 2 = x 1 Ç (: x 1 Æ : x 2) x 1 = x 2 0 21/20 x 2 1 BDD for f 1|x=1 Ç f 2 = 1 Binary Decision Diagrams x 2 0 x 2 1 Charngki Hong @ PSWLAB
Comparing SAT to BDDs � BDD is a canonical data structure that represents the semantic of a function, i. e. all its solutions � Some applications (e. g. symbolic model checking) need canonicity to detect when two sets are equivalent. � Can require exponential space & time (highly sensitive to variable ordering) � SAT searches through CNF for a single solution � CNF is not canonical. � Poly-space algorithms exists. Time can be exponential. 22/20 Binary Decision Diagrams Charngki Hong @ PSWLAB
- Slides: 22