<<

Binary Decision Diagrams

INF5140

1 Motivation Fig 1. Polynomial representation

● Boolean functions ○ Extremely useful ○ Some areas of application: ■ Cryptography ■ Propositional logic ■ Verification/model checking Fig 2. Binary decision and ● Hardware accompanying ● Software ○ Often modelled with truth tables or polynomials ■ State space explosion ● Symbolic model checking!

Fig 3. Binary decision diagram Fig 4. PDAG

2 Differences between BDTs and BDDs

BDDs BDTs

● Between 1 and 2 terminal nodes ● An arbitrary number of terminal ○ (a can be such that it nodes depending on the function only maps to true or only maps to ● Size scales with complexity of false) ● Can be a tree, usually isn’t function ● ● (more) Compact representation Easy to make ● NP-Hard to find a good representation

3 Binary Decision Diagrams 101

● Decision nodes ● Terminal nodes ● Ordered (OBDD) ● Reduced (RBDD) ● (Well-) Ordered, reduced (ROBDD) ● Satisfiability ● Validity ● Equivalence ● Brief mention about notation: ○ hi(n) leads to 1, lo(n) leads to 0

4 Binary Decision Diagrams: Ordering

● Finding the “correct” ordering is a difficult problem! ● Big differences in OBDDs for the same function ● Necessary to choose an order to obtain a (unique) reduced ordered BDD

5 Binary Decision Diagram: Ordering, example 2

6 Ordered Binary Decision Diagrams: Reduction

● Starting with a BDT: a. Remove all duplicate terminal nodes b. Remove all duplicate decision nodes c. Remove all redundant decision nodes ● If you have two reduced BDDs, and order them the same, they will be canonical/unique ● Some boolean functions are exponential and cannot be reduced to a linear form

7 Algorithms: Reduce

Bottom up id(n) assigns an integer label to the node n

1. 0-terminals are assigned 0, 1-terminals are assigned 1 ○ Given then a non-terminal node, integers are given based on the following: 2. If id(lo(n)) == id(hi(n)), then id(n) == id(lo(n)) 3. If nodes n and m exist such that id(lo(n)) == id(lo(m)) and id(hi(n)) == id(lo(m)) then id(n) == id(m) 4. Else id(n) is the next unused integer 5. Finally: Collapse nodes with the same label, redirect edges accordingly

8 Boole’s expansion theorem

● Example: ○ f = xyz + xy’z + x’y’z + x’yz + x’y’z ○ f = x(yz + y’z) + x’(y’z + yz + y’z)

○ f = xgx + x’gx’ ● Used in the construction of the BDD ● A op B = x’ (A [0/x] op B[0/x]) + x(A [1/x] op B[1/x]

9 Algorithms: Apply

● Used to build an ROBDD from apply(op, Bpsi, Bphi): two OBDDs Bpsi Bphi 1. If r , r are terminal nodes: ● Based on Boole’s expansion psi phi ○ apply(op, Bpsi,Bphi) = B(rpsi op rphi) theorem (Shannon’s expansion) 2. If both roots are decision nodes, create a dashed line to apply(op, Blo(rpsi), Blo(rphi)) and a solid line to apply(op,

● Recursive (roots down) Bhi(rpsi), Bhi(rphi))

3. If rpsi is a decision node but rphi is a terminal node, or a node higher in the order, create a node with a dashed line to apply(op, Blo(rpsi), Bphi)

4. If rphi is a decision node but rpsii is a terminal node, it is handled in the same way as in 3

10 Algorithms: Apply, example

11 Algorithms: Restrict

restrict(T, x, Bpsi): ● Used to restrict a boolean for each node n labelled with x: 1. Incoming edges are redirected to lo(n) function Bf in a BDD by some 2. n is removed variable, either to true or false.

● For boolean quantification, restrict(F, x, Bpsi): same as above, but redirect to hi(n) creating exists function for generating ROBDDs

12 Algorithms: Restrict, example

13 Algorithms: Exists

● Boolean quantification ● Combination of known algorithms

14 Algorithms: Exists, example

15 Sources

● https://www.inf.unibz.it/~artale/FM/slide7.pdf ● http://www.nptel.ac.in/courses/106103016/module4/lec3/1.html ● An Investigation of the Laws of Thought: On which are Founded the Mathematical Theories of Logic and Probabilities, George Boole (1854) ● Images shamelessly stolen from Wikimedia

16