bdd-lecture - Lecture 12: Binary Decison Diagrams in Detail...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture 12: Binary Decison Diagrams in Detail Binary Decision Trees Ordered Binary Decision Diagrams Variable Ordering Problem Logical Operations on OBDDs Quantified Boolean Formulas 1 Binary Decision Diagrams Ordered binary decision diagrams (OBDDs) are a canonical form for boolean formulas. OBDDs are often substantially more compact than traditional normal forms. Moreover, they can be manipulated very efficiently. R. E. Bryant. Graph-based algorithms for boolean function manipulation. IEEE Transactions on Computers, C-35(8), 1986. 2 Binary Decision Trees To motivate our discussion of binary decision diagrams, we first consider binary decision trees. ¡ ¢ £ is assigned 0, and and has two successors: A binary decision tree is a rooted, directed tree with two types of vertices, terminal vertices and nonterminal vertices. Each nonterminal vertex is labeled by a variable corresponding to the case where the variable ¥¦ § ¨© £ ¨  ¤ £ ¤ ¤ which is either 0 or 1. corresponding to the case where the variable is assigned 1. Each terminal vertex is labeled by 3 ¡ ¥  £ ¤ Binary Decision Trees (Cont.) 0 ¡ ¡ £ ¤ ¥¢ £ 1 £ 0 1 a 1 0 b 1 §£ 1 ¤ 0 £ ¤ 1 ¤ ¤ ¡ £ 1 1 a aa 2 22 ¤ a aa 2 2 2 ¢ ¤ ¥¢ ¡ ¦ ¡ £ 1 a aa 2 22 0 01 0 1 0 0 1 1 1 0 b b2 1 0 2 0 b b2 1 0 0 2 0 1 b b2 1 1 2 0 b ¢ b 0 ¨ © ¡ a aa 2 22 1 b 1 0 b b2 1 0 10 1 b §¡ 0 2 1 0 0 ¡ b 0 0 0 A binary decision tree for the two-bit comparator, given by the formula 0 is shown in the figure below: 1 4 . Binary Decision Trees (Cont.) We can decide if a truth assignment satisfies the formula as follows: Traverse the tree from the root to a terminal vertex. If variable is assigned , the next vertex on the path will be If variable is assigned , the next vertex on the path will be . ¡ ¥¦ § ¨© ¨  £ ¤ £ ¤ The value that labels the terminal vertex will be the value of the function for this assignment. In the comparator example, the assignment ¡ ¡ ¢ ¡ ¡ ¡ ¢ ¢ £ ¤ ¢ ¢ ¡ ¡ ¤ ¢ ¢ £ leads to a leaf vertex labeled , so the formula is false for this assignment. 5 A More Concise Representation , but only three are Binary decision trees do not provide a very concise representation for boolean functions. However, there is usually a lot of redundancy in such trees. In the comparator example, there are eight subtrees with roots labeled by distinct. ¤ £ Thus, we can obtain a more concise representation by merging isomorphic subtrees. This results in a directed acyclic graph (DAG) called a binary decision diagram. 6 Binary Decision Diagrams and has two successors, ¨© ¨  ¡ ¢ £ ¤ ¥¦ £ ¤ in the ¤ £ ¡¢ £ £ ¤¢ £ ¡ £ ¡ ¢ § ¥ ¤ is given by and More precisely, a binary decision diagram is a rooted, directed acyclic graph with two types of vertices, terminal vertices and nonterminal vertices. Each nonterminal vertex is labeled by a variable . . . then determines a boolean function Each terminal vertex is labeled by either 0 or 1. is a terminal vertex: A binary decision diagram with root following manner: 1. If then then £ ¦ ¡ ¡ ¥ ¥   £ ¡ ¡ £ ¡ ¥ £ ¦ ¤ ¦ ¤ ¡ £ ¡ ¢ £ ¢ £ ¡ ¤ £ ¡ £ £ ¢ ¥ ¦ is a nonterminal vertex with (a) If (b) If 2. If ¢ ¡ ¡ ¡ ¥ § ¡ ¢ £ ¤ ¤ ¦ ¡  £ £ ¢ ¤ 7 ¨ ©¦ ¡   £ ¡¢   ¡ £ £ ¤¢ £ ¡ ¢ ¦ ¥ ¡ £ ¤¢ ¡ ¥ ¤ ¡ £ ¨¦  ¦  ¡¢   £ ¡ £ ¤¢ £ £ ¢ ¤ Canonical Form Property In practical applications, it is desirable to have a canonical representation for boolean functions. This simplifies tasks like checking equivalence of two formulas and deciding if a given formula is satisfiable or not. Such a representation must guarantee that two boolean functions are logically equivalent if and only if they have isomorphic representations. 8 between the graphs such Canonical Form Property (Cont.) Two binary decision diagrams are isomorphic if there exists a bijection that ¨ , and terminals are mapped to terminals and nonterminals are mapped to nonterminals, for every terminal vertex , ¡ ¥ ¨ £ £ ¤ ¤ , ¦ ¦ ¢ . , and for every nonterminal vertex : – – – 9 ¡ ¨ £ ¨ ¢ ¥¦ ¨© £ £ ¤ § £ ¨  ¤ ¤ £ ¡ ¤ ¦ ¤ ¨ £ ¥¦ £ § ¨© ¤ ¨ £ ¨  ¤ £ ¨ £ ¤ ¤ £ ¤ ¤  £ ¦ ¤ ¡ ¥  Canonical Form Property (Cont.) Bryant showed how to obtain a canonical representation for boolean functions by placing two restrictions on binary decision diagrams: First, the variables should appear in the same order along each path from the root to a terminal. Second, there should be no isomorphic subtrees or redundant vertices in the diagram. 10 Canonical Form Property (Cont.) We impose total ordering has a nonterminal successor , then on the variables in the formula. The first requirement is easy to achieve: We require that if vertex ¡ ¢  £ ¤ ¡ ¢ £ ¤ 11 .  Canonical Form Property (Cont.) The second requirement is achieved by repeatedly applying three transformation rules that do not alter the function represented by the diagram: Remove duplicate terminals: Eliminate all but one terminal vertex with a given label and redirect all arcs to the eliminated vertices to the remaining one. Remove duplicate nonterminals: If nonterminals and have , and , then eliminate one of the two vertices and redirect all incoming arcs to the other vertex. ¥¦ §    ¦ ¤ ¥¦ § £ ¤ ¨© ¨   ¡ ¢ £ ¤ £ ¦ ¤ ¨©  ¨ £ ¤ , then eliminate and ¦ £ Remove redundant tests: If nonterminal vertex has redirect all incoming arcs to . ¥¦ § £ ¦ ¤ ¡ ¨© ¢ £ ¨  ¤ £ ¤ 12 ¥¦ § £ ¤ Canonical Form Property (Cont.) The canonical form may be obtained by applying the transformation rules until the size of the diagram can no longer be reduced. Bryant shows how this can be done by a procedure called Reduce in linear time. 13 Ordered Binary Decision Diagrams The term ordered binary decision diagram (OBDD) will be used to refer to the graph obtained in this manner. If OBDDs are used as a canonical form for boolean functions, then checking equivalence is reduced to checking isomorphism between OBDDs, and satisfiability can be determined by checking equivalence with the trivial OBDD that consists of only one terminal labeled by 0. 14 If we use the ordering ¤ 1 0 £ 2 2 a 1 1 1 1 1 1 b 2 1 b 0 0 1 0 for the comparator function, we obtain the OBDD below: OBDD for Comparator Example b 0 a 0 b 0 1 15 ¡ ¡ ¤ ¡ ¡ £ Variable Ordering Problem 0 a 0 2 0 1 ¤ b 1 , we get £ 1 0 1 0 a a1 1 1 b 0 0 1 1 0 0 1 a a 22 1 1 b 2 0 b 1 1 The size of an OBDD depends critically on the variable ordering. With the ordering b 1 b 2 1 1 16 ¡ ¡ ¡ £ ¤ ¡ ¡ . ¢  , the number of vertices is , the number of vertices will be Variable Ordering Problem (Cont.) For an -bit comparator: if we use the ordering if we use the ordering ¡ ¡ ¡ ¤ ¡ £ £ £ £ £ ¡ £ ¥ ¡ ¤ ¥ ¤ £ £ £¡ ¥ ¤ ¥ ¡ ¨ ¥ ¡ ¢ £ ¡ In general, finding an optimal ordering is known to be NP-complete. output) of a combinational circuit to multiply two . bit Moreover, there are boolean functions that have exponential size OBDDs for any variable ordering. An example is the middle output ( integers. 17 ¤ ¥  Heuristics for Variable Ordering Heuristics have been developed for finding a good variable ordering when such an ordering exists. The intuition for these heuristics comes from the observation that OBDDs tend to be small when related variables are close together in the ordering. The variables appearing in a subcircuit are related in that they determine the subcircuit’s output. Hence, these variables should usually be grouped together in the ordering. This may be accomplished by placing the variables in the order in which they are encountered during a depth-first traversal of the circuit diagram. 18 Dynamic Variable Ordering A technique, called dynamic reordering appears to be useful if no obvious ordering heuristic applies. When this technique is used, the OBDD package internally reorders the variables periodically to reduce the total number of vertices in use. 19 Logical Operations on OBDDs of the boolean function ¤ ¡ ¦ ¡ ¡ £ ¤¢ ¥ £ £ ¡ ¥ £ ¦¢ ¡ ¥ £ ¡ £ ¢ £ ¡ ¢ ¥ ¦ ¤ ¡ £ £ ¤¢ ¡ £ £ ¡ ¢ § ¨ ¦ ¡ ¤¢ ¡ ¢ ¦ © ¡ £ ¤¢ ¡ £ ¥ £ ¢ ¤ ¥¦ § § ¤ ¨© ¨  § ¤ § ¡ ¢ § £ £ ¦¢ ¦ ¤ ¡ ¦ ¤ £ ¤ £ to obtain the OBDD for to a constant . , we replace the pointer by is computed by a depth-first and satisfies the identity We begin with the function that restricts some argument value . This function is denoted by such that If is represented as an OBDD, the OBDD for the restriction traversal of the OBDD. For any vertex which has a pointer to a vertex if is and by if is 1. When the graph is not in canonical form, we apply ¡ ¥ 20       £ ¦¢ Logical Operations (Cont.) All 16 two-argument logical operations can be implemented efficiently on boolean functions that are represented as OBDDs. In fact, the complexity of these operations is linear in the size of the argument OBDDs. The key idea for efficient implementation of these operations is the Shannon expansion §¨ ¨ £ ¡  ¡ £ ¡ 21 ¦ ¡ ¡ £ ¥ ¡¡ ¢ and be two boolean functions. for computing all 16 logical operations. Logical Operations (Cont.) Bryant gives a uniform algorithm called Let be an arbitrary two argument logical operation, and let £ ¤ ¥ ¤ and . ¤ . are the roots of the OBDDs for To simplify the explanation of the algorithm we introduce the following notation: and and ¤ ¤ 22 ¡ ¦ ¡ ¢ £ ¤ ¡ ¦ ¡ ¢ £ ¤ ¦ and . . Logical Operations OBDDs (Cont.) are both terminal vertices, then ¤ ¤ ¤ £ ¥ £ ¥  £ , then we use the Shannon expansion ¤ If We consider several cases depending on the relationship between and If ¡ ¤ ¡ ¤ £ §¨ ¡ ¨ ¡ ¦ ¡ £ ¡ £ ¦ ¤£ ¡ ¤£ ¡ £  ¤  £ £ ¤ ¡ £ ¡ ¡ ¤ ¡ £ ¤ with . . . to break the problem into two subproblems. The subproblems are solved recursively. The root of the resulting OBDD will be ¢ £ ¦ ¤ ¡ will be the OBDD for £ £ ¡ ¤£ ¡ £ ¡ ¤ will be the OBDD for £ ¡ ¤£ £ ¡ ¡ ¤ 23 ¦ ¡ § © £ ¨  ¤ £ ¤ £ ¡ If , then does not depend on . Logical Operations OBDDs (Cont.) since ¡ ¤ ¡ ¤ ¡ £ ¦ ¤ ¡ ¦ ¤ £ ¡ ¤ ¡ In this case the Shannon Expansion simplifies to ¤ ¤ £ §¨ ¨ ¤£ ¡ ¦ ¡ £ ¡ £ ¤£  ¤ £ ¡ £ ¡ ¤ is computed recursively as in the second case. £ , then the required computation is similar to the previous case. and the OBDD for If ¤ 24 ¡ ¡ Logical Operations (Cont.) By using dynamic programming, it is possible to make the algorithm polynomial. A hash table is used to record all previously computed subproblems. Before any recursive call, the table is checked to see if the subproblem has been solved. If it has, the result is obtained from the table; otherwise, the recursive call is performed. The result must be reduced to ensure that it is in canonical form. 25 OBDD Extensions Several extensions have been developed to decrease the space requirements for OBDDs. A single OBDD can be used to represent a collection of boolean functions: The same variable ordering is used for all of the formulas in the collection. As before, the graph contains no isomorphic subgraphs or redundant vertices. Two functions in the collection are identical if and only if they have the same root. Consequently, checking whether two functions are equal can be implemented in constant time. 26 OBDD Extensions (Cont.) Another useful extension adds labels to the arcs in the graph to denote boolean negation. This makes it unnecessary to use different subgraphs to represent a formula and its negation. OBDDs with hundreds of thousands of vertices can be manipulated efficiently. 27 OBDDs and Finite Automata OBDDs can also be viewed as deterministic finite automata. An -argument boolean function can be identified with the set of strings in 1. that evaluate to ¡ ¢ ¥ ¡ This is a finite language. Finite languages are regular. Hence, there is a minimal DFA that accepts the language. The DFA provides a canonical form for the original boolean function. Logical operations on boolean functions can be implemented by standard constructions from elementary automata theory. 28 ...
View Full Document

Ask a homework question - tutors are online