Presentation is loading. Please wait.

Presentation is loading. Please wait.

IT University of Copenhagen Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations 2. If-then-else Normal Form (INF) 3. Binary.

Similar presentations


Presentation on theme: "IT University of Copenhagen Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations 2. If-then-else Normal Form (INF) 3. Binary."— Presentation transcript:

1 IT University of Copenhagen Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations 2. If-then-else Normal Form (INF) 3. Binary Decision Diagrams

2 IT University of Copenhagen 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 2

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

4 IT University of Copenhagen Boolean Expressions 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 4  2007 Rune M. Jensen

5 IT University of Copenhagen Boolean functions Definition An n-variable function f : B n  B is called a Boolean function if it is induced by a Boolean expression E. B = {0,1} E represents the Boolean function 5  2007 Rune M. Jensen

6 IT University of Copenhagen Order of arguments matter f(x,y) = x  y  f(y,x) = x  y Several expressions may represent a function f(x,y) = x  y =  x  y = (  x  y)  (  x  x) = … Equality f = g iff  x. f(x) = g(x) Number of Boolean functions f : B n  B PropertiesProperties 6  2007 Rune M. Jensen

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

8 IT University of Copenhagen The curse of Boolean function representation Boolean functions in n variables… – How do we find a single compact representation for all of them? Ex. Boolean circuits : how many Boolean circuits of size g with n inputs and 1 output? – Choice of gates: 16 g – Choice of connections: (2g+1) (n+g) – Total: 16 g (2g+1) (n+g) … Out 1 In 1 In 2 In n 16 12 8  2007 Rune M. Jensen

9 IT University of Copenhagen The curse of Boolean function representation Assume g = O(n k ) 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! 9  2007 Rune M. Jensen

10 IT University of Copenhagen Truth tables Compact table size 2 n Equality check easy canonical Easy to evaluate the truth-value of an assignment linear Boolean operations efficient linear SAT check efficient linear Tautology check efficient linear Easy to implement e.g., DBs 10  2007 Rune M. Jensen xyz xyzxyz 0000 0011 0100 0111 1000 1011 1101 1111

11 IT University of Copenhagen One level normal forms Two level normal Forms Two Level Normal Forms 11  2007 Rune M. Jensen OP 1 Lit … OP 1 … OP 2 Lit OP 2 Lit OP 2 Lit … … …

12 IT University of Copenhagen Two-level normal forms: DNF CNF  -monomials : x 1   x 2   x 3  x 4  -monomials : x 1   x 2  x 3   x 4 ( ,  )-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) 12  2007 Rune M. Jensen

13 IT University of Copenhagen 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? xyz xyzxyz 0000 0011 0100 0111 1000 1011 1101 1111 13  2007 Rune M. Jensen

14 IT University of Copenhagen Two-level normal forms: DNF CNF Example DNF of x  y  z xyz xyzxyz 0000 0011 0100 0111 1000 1011 1101 1111  x   y  z   x  y  z  x   y  z  x  y   z  x  y  z 14  2007 Rune M. Jensen

15 IT University of Copenhagen Two-level normal forms: DNF CNF Example CNF of x  y  z xyz xyzxyz 0000 0011 0100 0111 1000 1011 1101 1111  (  x   y   z)   (  x  y   z)   (x   y   z)  15  2007 Rune M. Jensen

16 IT University of Copenhagen Two-level normal forms: DNF CNF Example CNF of x  y  z xyz xyzxyz 0000 0011 0100 0111 1000 1011 1101 1111 (x  y  z)  (x   y  z)  (  x  y  z) 16  2007 Rune M. Jensen

17 IT University of Copenhagen 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 17  2007 Rune M. Jensen

18 IT University of Copenhagen Two-level normal forms: DNF CNF Properties of DNF and CNF Problem: conversion between CNFs and DNFs is exponential SATTautology CNFNP completePolynomial (exercise) DNFPolynomial (exercise) Co-NP complete 18  2007 Rune M. Jensen

19 IT University of Copenhagen Two-level normal forms: DNF CNF Example – CNF – Corresponding DNF 19  2007 Rune M. Jensen

20 IT University of Copenhagen 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) 20  2007 Rune M. Jensen

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

22 IT University of Copenhagen CircuitsCircuits 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 22  2007 Rune M. Jensen

23 IT University of Copenhagen FormulasFormulas 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)) 23  2007 Rune M. Jensen

24 IT University of Copenhagen FormulasFormulas 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 24  2007 Rune M. Jensen

25 IT University of Copenhagen 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! 25  2007 Rune M. Jensen

26 IT University of Copenhagen Binary Decision Diagrams 26  2007 Rune M. Jensen

27 IT University of Copenhagen 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 27  2007 Rune M. Jensen

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

29 IT University of Copenhagen 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 29  2007 Rune M. Jensen

30 IT University of Copenhagen 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 30  2007 Rune M. Jensen

31 IT University of Copenhagen ExampleExample Example: t = (x 1  y 1 )  (x 2  y 2 ) Shannon expansion of t in order x 1,y 1,x 2,y 2 t = x 1  t 1, t 0 31  2007 Rune M. Jensen

32 IT University of Copenhagen ExampleExample Example: t = (x 1  y 1 )  (x 2  y 2 ) Shannon expansion of t in order x 1,y 1,x 2,y 2 t = x 1  t 1, t 0 t 0 = y 1  t 01, t 00 t 1 = y 1  1, t 10 32  2007 Rune M. Jensen

33 IT University of Copenhagen ExampleExample Example: t = (x 1  y 1 )  (x 2  y 2 ) Shannon expansion of t in order x 1,y 1,x 2,y 2 t = x 1  t 1, t 0 t 0 = y 1  t 01, t 00 t 1 = y 1  1, t 10 t 01 = x 2  t 011, 0 t 00 = x 2  t 001, 0 t 10 = x 2  t 101, 0 33  2007 Rune M. Jensen

34 IT University of Copenhagen ExampleExample Example: t = (x 1  y 1 )  (x 2  y 2 ) Shannon expansion of t in order x 1,y 1,x 2,y 2 t = x 1  t 1, t 0 t 0 = y 1  t 01, t 00 t 1 = y 1  1, t 10 t 01 = x 2  t 011, 0 t 00 = x 2  t 001, 0 t 10 = x 2  t 101, 0 t 011 = y 2  1,0 t 001 = y 2  1,0 t 101 = y 2  1,0 34  2007 Rune M. Jensen

35 IT University of Copenhagen Decision tree Example: t = (x 1  y 1 )  (x 2  y 2 ) Shannon expansion of t in order x 1,y 1,x 2,y 2 t = x 1  t 1, t 0 t 0 = y 1  t 01, t 00 t 1 = y 1  1, t 10 t 01 = x 2  t 011, 0 t 00 = x 2  t 001, 0 t 10 = x 2  t 101, 0 t 011 = y 2  1,0 t 001 = y 2  1,0 t 101 = y 2  1,0 1 x1x1 y1y1 y1y1 x2x2 x2x2 x2x2 y2y2 y2y2 t t0t0 t1t1 t 00 t 01 t 10 t 001 t 011 t 101 0 0 y2y2 0 0 0 0 1 1 1 35  2007 Rune M. Jensen

36 IT University of Copenhagen Reduction I: substitute identical subtrees Example: t = (x 1  y 1 )  (x 2  y 2 ) Shannon expansion of t in order x 1,y 1,x 2,y 2 t = x 1  t 1, t 0 t 0 = y 1  t 01, t 01 t 1 = y 1  1, t 01 t 01 = x 2  t 011, 0 t 011 = y 2  1,0 x1x1 y1y1 y1y1 x2x2 y2y2 t t0t0 t1t1 t 01 t 011 0 1 Result: an Ordered Binary Decision Diagram (OBDD) 36  2007 Rune M. Jensen

37 IT University of Copenhagen Reduction II: remove redundant tests Example: t = (x 1  y 1 )  (x 2  y 2 ) Shannon expansion of t in order x 1,y 1,x 2,y 2 t = x 1  t 1, t 01 t 1 = y 1  1, t 01 t 01 = x 2  t 011, 0 t 011 = y 2  1,0 x1x1 y1y1 x2x2 y2y2 t t1t1 t 01 t 011 01 Result: a Reduced Ordered Binary Decision Diagram (ROBDD) [often called a BDD] 37  2007 Rune M. Jensen

38 IT University of Copenhagen ReductionsReductions x Uniqueness requirement Non-redundant tests requirement x x 38  2007 Rune M. Jensen

39 IT University of Copenhagen Another reduction example x z yy z z 0 1 39  2007 Rune M. Jensen

40 IT University of Copenhagen Another reduction example x z yy z z 0 1 Equal subtrees Redundant test 40  2007 Rune M. Jensen

41 IT University of Copenhagen Another reduction example x z yy z 0 1 Equal subtrees 41  2007 Rune M. Jensen

42 IT University of Copenhagen Another reduction example x z yy 0 1 42  2007 Rune M. Jensen

43 IT University of Copenhagen Another reduction example x z yy 0 1 Equal subtrees 43  2007 Rune M. Jensen

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

45 IT University of Copenhagen Another reduction example z y 0 1 45  2007 Rune M. Jensen

46 IT University of Copenhagen Another reduction example z y 0 1 y  z 46  2007 Rune M. Jensen

47 IT University of Copenhagen Definition of ROBDDs 47  2007 Rune M. Jensen

48 IT University of Copenhagen Canonicity of ROBDDs Canonicity Lemma: for any function f : B n  B there is exactly one ROBDD u with a variable ordering x 1 < x 2 < … < x n such that f u = f(x 1,…,x n ) Proof (by induction on n) 48  2007 Rune M. Jensen

49 IT University of Copenhagen Canonicity of ROBDDs The canonicity of ROBDDs simplifies – Equality check – Tautology check – Satisfiability check Why? 49  2007 Rune M. Jensen

50 IT University of Copenhagen What are the ROBDDs of – 1 – 0 – x  y order x, y – (x  y)  z order x, y, z PracticePractice 50  2007 Rune M. Jensen

51 IT University of Copenhagen Size of ROBDDs ROBDDs of many practically important Boolean functions are small – E.g., Adders have polynomial sized ROBDDs Have all functions polynomial ROBDD size? NO – ROBDDs do not escape the curse of Boolean function representation – E.g., Multipliers have exponential ROBDD size 51  2007 Rune M. Jensen

52 IT University of Copenhagen Size of ROBDDs The set of nodes of a ROBDD of f is equal to the set of different subfunctions of f (in an INF expansion) Example: 4 subfunctions = 4 nodes in the ROBDD f(x,y,z) = y  z f(0,y,z) = y  z f(1,y,z) = y  z f(0,0,z) = z f(0,1,z) = 1 f(1,0,z) = z f(1,1,z) = 1 f(0,0,0) = 0 f(0,0,1) = 1 f(0,1,0) = 1 f(0,1,1) = 1 f(1,0,0) = 0 f(1,0,1) = 1 f(1,1,0) = 1 f(1,1,1) = 1 z y 0 1 y  zy  z z 0 1 This property can be used to find upper bounds on the ROBDD size 52  2007 Rune M. Jensen

53 IT University of Copenhagen Size Of ROBDDs The size of an ROBDD depends heavily on the variable ordering Example: t = (x 1  y 1 )  (x 2  y 2 ) Build ROBDD of t in order x 1,x 2,y 1,y 2 53  2007 Rune M. Jensen

54 IT University of Copenhagen Size of ROBDDs The size of an ROBDD depends heavily on the variable ordering (x 1  y 1 )  (x 2  y 2 )  …  (x n  y n ) x 1 < y 1 < x 2 < y 2 < … < x n < y n x 1 < x 2 < … < x n < y 1 < x 2 < …< y n 54  2007 Rune M. Jensen


Download ppt "IT University of Copenhagen Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations 2. If-then-else Normal Form (INF) 3. Binary."

Similar presentations


Ads by Google