1 / 54

Lecture 8: Binary Decision Diagrams

Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations 2. If-then-else Normal Form (INF) 3. Binary Decision Diagrams. Today’s Program. [13:00-13:55 ] Computation based representations Boolean expressions and Boolean functions

Download Presentation

Lecture 8: Binary Decision Diagrams

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations2. If-then-else Normal Form (INF)3. Binary Decision Diagrams

  2. Today’s Program • [13:00-13:55] Computation based representations • Boolean expressions and Boolean functions • Classical representations of Boolean expressions • Truth tables • Two-level normal forms: CNF, DNF • Multi-level representations: circuits and formulas • [14:05-15:00] Evaluation based representations • If-then-else normal form • Decision trees • Ordered Binary Decision Diagrams (OBDDs) • Reduced Ordered Binary Decision Diagrams (ROBDDs or just BDDs) 2007 Rune M. Jensen

  3. Classical Representations of Boolean Expressions 2007 Rune M. Jensen

  4. Boolean Expressions • BooleanExpressions t ::= x | 0 | 1 | t | t  t | t t | t t | t  t • Literals l ::= x | x • Precedence , , ,  , (obs. two last swapped in HRA notes) • Terminology • Boolean expression = Boolean formula, Propositional formula, Sentence in propositional logic • Boolean variable = Propositional symbol/letter/variable 2007 Rune M. Jensen

  5. Boolean functions • DefinitionAn n-variable function f : Bn Bis called a Boolean function if it is induced by a Boolean expression E. • B = {0,1} • E represents the Boolean function 2007 Rune M. Jensen

  6. Properties • Order of arguments matterf(x,y) = x y  f(y,x) = x y • Several expressions may represent a functionf(x,y) = x y = x y = (x y)  (x x) = … • Equalityf = giff x . f(x) = g(x) • Number of Boolean functions f : Bn B 2007 Rune M. Jensen

  7. Desirable properties of a representation • Compact • Equality check easy (true for canonical representations) • Easy to evaluate the truth-value of an assignment • Boolean operationsefficient • SAT checkefficient • Tautology checkefficient • Easy to implement 2007 Rune M. Jensen

  8. The curse of Boolean function representation • Boolean functions in nvariables… • How do we find a single compact representation for all of them? Ex. Boolean circuits : how many Boolean circuits of size gwith n inputs and 1 output? • Choice of gates: 16g • Choice of connections: (2g+1)(n+g) • Total: 16g (2g+1)(n+g) In1 In2 Inn … 1 2 16 Out1 2007 Rune M. Jensen

  9. The curse of Boolean function representation • Assume g = O(nk) • Thus the fraction of Boolean functions of n variables with a polynomial circuit size in n is Curse of Boolean function representation: This problem exists for all representations we know! 2007 Rune M. Jensen

  10. Truth tables • Compact table size2n • Equality check easy canonical • Easy to evaluate the truth-value of an assignmentlinear • Boolean operations efficient linear • SAT check efficient linear • Tautology check efficient linear • Easy to implement e.g., DBs 2007 Rune M. Jensen

  11. Two Level Normal Forms OP1 • One level normal forms • Two level normal Forms … Lit Lit Lit OP1 … OP2 OP2 OP2 … … … Lit Lit Lit Lit Lit Lit Lit Lit Lit 2007 Rune M. Jensen

  12. Two-level normal forms: DNF CNF • -monomials : x1  x2  x3  x4 • -monomials : x1  x2  x3  x4 • ( ,)-polynomials: -product of -monomials disjunctive normal form (DNF): • Ex: x  y  x   y • (, )-polynomials: -product of -monomials conjunctive normal form (CNF): • Ex: (x   y)  (x  y) 2007 Rune M. Jensen

  13. Two-level normal forms: DNF CNF • Is there a DNF and CNF of every expression? • Given a truth table representation of a Boolean formula, can we easily define a DNF and CNF of the formula? 2007 Rune M. Jensen

  14. Two-level normal forms: DNF CNF • Example DNF of xyz x  y  z  x y  z  x   y  z  x y  z  x y  z 2007 Rune M. Jensen

  15. Two-level normal forms: DNF CNF • Example CNF of xyz  ( x  y  z)  (x y  z)  (x   y  z) 2007 Rune M. Jensen

  16. Two-level normal forms: DNF CNF • Example CNF of xyz (x y  z) (x   y  z)  (x y  z) 2007 Rune M. Jensen

  17. Two-level normal forms: DNF CNF • The special version DNF and CNF representations produced from on and off-tuples are canonical and called cDNF and cCNF • Are cDNF and cCNF minimum size DNF and CNF representations? Every Boolean formula has a DNF and CNF representation 2007 Rune M. Jensen

  18. Two-level normal forms: DNF CNF • Properties of DNF and CNF • Problem: conversion between CNFs and DNFs is exponential 2007 Rune M. Jensen

  19. Two-level normal forms: DNF CNF • Example • CNF • Corresponding DNF 2007 Rune M. Jensen

  20. Two-level normal forms: DNF CNF • Compact Translating a formula to either CNF or DNF may cause an exponential blow-up in expression size • Equality check easy ”compact” CNF and DNF formulas are not canonical • Easy to evaluate the truth-value of an assignment linear • Boolean operations efficient disjunction e.g. efficient for DNF • SAT check efficient Not for CNF • Tautology check efficient Not for DNF • Easy to implement programmable logic arrays (PLAs) 2007 Rune M. Jensen

  21. Circuits • Circuits are multi-level representations • CNF and DNF are special circuits with depth 3 • Thus, circuits are not canonical x y z    Out 2007 Rune M. Jensen

  22. Circuits • Compact But still suffers from the curse of Booelan function representation. • Equality check easy Not canonical • Easy to evaluate the truth-value of an assignment linear • Boolean operations efficient constant • SAT check efficient (NP-Hard) • Tautology check efficient Not canonical • Easy to implement Integrated circuits 2007 Rune M. Jensen

  23. Formulas • Formulas are circuits where each node has out-degree 1 • Multiple use of intermediate functions is not allowed ((x y)  (z  y)) ((x y)  (z  x)) 2007 Rune M. Jensen

  24. Formulas • Compact At least as large as a circuit • Equality check easy Not canonical • Easy to evaluate the truth-value of an assignment linear • Boolean operations efficient constant • SAT check efficient (Circuit-SAT ≤p Formula-SAT) • Tautology check efficient Not canonical • Easy to implement Simpler algorithmic handling than circuits 2007 Rune M. Jensen

  25. Classical Representations • Observations • There is a trade off between the size of a representation and the efficiency of operations and checks • Truthtables: very large, but all checks and Boolean operations can be carried out efficiently • Circuits: quite compact, but SAT and equality checks are very hard • Next: Binary decision diagrams, probably the best known balance between size and efficiency! 2007 Rune M. Jensen

  26. Binary Decision Diagrams 2007 Rune M. Jensen

  27. Computation and Evaluation Based Representation • Computation Process Representation • Representation gives a way to compute the expression value • Truth-tables, DNF, CNF, circuits and formulas • Evaluation Process Representation • Representation gives a way to classify the expression value by means of tests • Decision trees 2007 Rune M. Jensen

  28. If-then-else operator • The if-then-else Boolean operator is defined by xy1 , y0 = ( x  y1 )  ( x  y0 ) • We have (xy1 , y0) [1/x] = ( 1  y1 )  ( 0  y0 ) = y1 (xy1 , y0) [0/x] = ( 0  y1 )  ( 1  y0 ) = y0 2007 Rune M. Jensen

  29. If-then-else operator • All operators can be expressed using • only  operators and the constants 0 and 1 • tests on un-negated variables • What are if-then-else expressions for • x, x • x  y, x y • x y 2007 Rune M. Jensen

  30. INF normal form • Proposition: any Boolean expression t is equivalent to an expression in INF Proof:t = x t[1/x], t[0/x](Shannon expansion of t)Apply the Shannon expansion recursively on t. The recursion must terminate in 0 or 1, since the number of variables is finite An if-then-else Normal Form (INF) is a Boolean expression build entirely from the if-then-else operator and the constants 0 and 1 such that all test are performed only on variables 2007 Rune M. Jensen

  31. Example • Example: t = (x1 y1)  (x2 y2) • Shannon expansion of t in order x1,y1,x2,y2 t = x1  t1, t0 2007 Rune M. Jensen

  32. Example • Example: t = (x1 y1)  (x2 y2) • Shannon expansion of t in order x1,y1,x2,y2 t = x1  t1, t0 t0 = y1  t01, t00 t1 = y1  1, t10 2007 Rune M. Jensen

  33. Example • Example: t = (x1 y1)  (x2 y2) • Shannon expansion of t in order x1,y1,x2,y2 t = x1  t1, t0 t0 = y1  t01, t00 t1 = y1  1, t10 t01 = x2  t011, 0 t00 = x2  t001, 0 t10 = x2  t101, 0 2007 Rune M. Jensen

  34. Example • Example: t = (x1 y1)  (x2 y2) • Shannon expansion of t in order x1,y1,x2,y2 t = x1  t1, t0 t0 = y1  t01, t00 t1 = y1  1, t10 t01 = x2  t011, 0 t00 = x2  t001, 0 t10 = x2  t101, 0 t011 = y2  1,0 t001 = y2  1,0 t101 = y2  1,0 2007 Rune M. Jensen

  35. 0 1 0 0 0 0 1 0 1 1 Decision tree • Example: t = (x1 y1)  (x2 y2) • Shannon expansion of t in order x1,y1,x2,y2 t = x1  t1, t0 t0 = y1  t01, t00 t1 = y1  1, t10 t01 = x2  t011, 0 t00 = x2  t001, 0 t10 = x2  t101, 0 t011 = y2  1,0 t001 = y2  1,0 t101 = y2  1,0 t x1 t0 t1 y1 y1 t01 t10 t00 x2 x2 x2 t001 t011 t101 y2 y2 y2 2007 Rune M. Jensen

  36. 0 1 Reduction I: substitute identical subtrees • Example: t = (x1 y1)  (x2 y2) • Shannon expansion of t in order x1,y1,x2,y2 t = x1  t1, t0 t0 = y1  t01, t01 t1 = y1  1, t01 t01 = x2  t011, 0 t011 = y2  1,0 t x1 t0 t1 y1 y1 t01 x2 t011 y2 Result: an Ordered Binary Decision Diagram (OBDD) 2007 Rune M. Jensen

  37. 0 1 Reduction II: remove redundant tests • Example: t = (x1 y1)  (x2 y2) • Shannon expansion of t in order x1,y1,x2,y2 t = x1  t1, t01 t1 = y1  1, t01 t01 = x2  t011, 0 t011 = y2  1,0 t x1 t1 y1 t01 x2 Result: a Reduced Ordered Binary Decision Diagram (ROBDD) [often called a BDD] t011 y2 2007 Rune M. Jensen

  38. Reductions x x x Uniqueness requirement Non-redundant tests requirement 2007 Rune M. Jensen

  39. x y y z z z 0 1 Another reduction example 2007 Rune M. Jensen

  40. x y y z z z 0 1 Another reduction example Redundant test Equal subtrees 2007 Rune M. Jensen

  41. x y y z z 0 1 Another reduction example Equal subtrees 2007 Rune M. Jensen

  42. x y y z 0 1 Another reduction example 2007 Rune M. Jensen

  43. x y y z 0 1 Another reduction example Equal subtrees 2007 Rune M. Jensen

  44. x y z 0 1 Another reduction example Redundant test 2007 Rune M. Jensen

  45. y z 0 1 Another reduction example 2007 Rune M. Jensen

  46. z 0 1 Another reduction example y  z y 2007 Rune M. Jensen

  47. Definition of ROBDDs 2007 Rune M. Jensen

  48. Canonicity of ROBDDs • Canonicity Lemma: for any function f : Bn B there is exactly one ROBDD u with a variable ordering x1 < x2 < … < xn such that fu = f(x1,…,xn) Proof (by induction on n) 2007 Rune M. Jensen

  49. Canonicity of ROBDDs • The canonicity of ROBDDs simplifies • Equality check • Tautology check • Satisfiability check Why? 2007 Rune M. Jensen

  50. Practice • What are the ROBDDs of • 1 • 0 • xyorder x, y • (x y)  zorder x, y, z 2007 Rune M. Jensen

More Related