Download presentation

Presentation is loading. Please wait.

1
© 2011 Carnegie Mellon University Binary Decision Diagrams Part 1 15-414 Bug Catching: Automated Program Verification and Testing Sagar Chaki September 12, 2011

2
2 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University BDDs in a nutshell Typically mean Reduced Ordered Binary Decision Diagrams (ROBDDs) Canonical representation of Boolean formulas Often substantially more compact than a traditional normal form Can be manipulated very efficiently Conjunction, Disjunction, Negation, Existential Quantification R. E. Bryant. Graph-based algorithms for boolean function manipulation. IEEE Transactions on Computers, C-35(8), 1986.

3
3 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Running Example: Comparator Comparator a1a1 a2a2 b1b1 b2b2 f = 1, a 1 = b 1 Æ a 2 = b 2

4
4 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Conjunctive Normal Form ( : a 1 Ç b 1 ) Æ ( : b 1 Ç a 1 ) Æ ( : a 2 Ç b 2 ) Æ ( : b 2 Ç a 2 ) a 1 = b 1 Æ a 2 = b 2 a 1 ) b 1 Æ b 1 ) a 1 Æ a 2 ) b 2 Æ b 2 ) a 2 ( : b 1 Ç a 1 ) Æ ( : a 1 Ç b 1 ) Æ ( : a 2 Ç b 2 ) Æ ( : b 2 Ç a 2 ) Not Canonical f

5
5 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Truth Table (1) a1a1 b1b1 a2a2 b2b2 f 00001 00010 00100 00111 01000 01010 01100 01110 10000 10010 10100 10110 11001 11010 11100 11111 Still Not Canonical

6
6 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Truth Table (2) a1a1 a2a2 b1b1 b2b2 f 00001 00010 00100 00110 01000 01011 01100 01110 10000 10010 10101 10110 11000 11010 11100 11111 Canonical if you fix variable order. But always exponential in # of variables. Let’s try to fix this.

7
7 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Representing a Truth Table using a Graph a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 0000 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001 0 0 0 01 1 10 Binary Decision Tree (in this case ordered)

8
8 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Binary Decision Tree: Formal Definition Balanced binary tree. Length of each path = # of variables Leaf nodes labeled with either 0 or 1 Internal node v labeled with a Boolean variable var(v) Every node on a path labeled with a different variable Internal node v has two children: low(v) and high(v) Each path corresponds to a (partial) truth assignment to variables Assign 0 to var(v) if low(v) is in the path, and 1 if high(v) is in the path Value of a leaf is determined by: Constructing the truth assignment for the path leading to it from the root Looking up the truth table with this truth assignment

9
9 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Binary Decision Tree a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 0000 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001 0 0 0 01 1 10 v low(v) high(v) var(v) = a 1

10
10 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Binary Decision Tree a1a1 b1b1 a2a2 b2b2 0 0 1 0 The truth assignment corresponding to the path to this leaf is: a 1 = ? b 1 = ? a 2 = ? b 2 = ?

11
11 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Binary Decision Tree a1a1 b1b1 a2a2 b2b2 0 0 1 0 The truth assignment corresponding to the path to this leaf is: a 1 = 0 b 1 = 0 a 2 = 1 b 2 = 0 a1a1 b1b1 a2a2 b2b2 f 00001 00010 00100 00111 01000 01010 01100 01110 10000 10010 10100 10110 11001 11010 11100 11111

12
12 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Binary Decision Tree a1a1 b1b1 a2a2 b2b2 0 0 1 0 The truth assignment corresponding to the path to this leaf is: a 1 = 0 b 1 = 0 a 2 = 1 b 2 = 0 a1a1 b1b1 a2a2 b2b2 f 00001 00010 00100 00111 01000 01010 01100 01110 10000 10010 10100 10110 11001 11010 11100 11111

13
13 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Binary Decision Tree a1a1 b1b1 a2a2 b2b2 0 0 0 1 0 The truth assignment corresponding to the path to this leaf is: a 1 = 0 b 1 = 0 a 2 = 1 b 2 = 0 a1a1 b1b1 a2a2 b2b2 f 00001 00010 00100 00111 01000 01010 01100 01110 10000 10010 10100 10110 11001 11010 11100 11111

14
14 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Binary Decision Tree (BDT) a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 0000 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001 0 0 0 01 1 10 Canonical if you fix variable order (i.e., use ordered BDT) But still exponential in # of variables. Let’s try to fix this.

15
15 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Reduced Ordered BDD Conceptually, a ROBDD is obtained from an ordered BDT (OBDT) by eliminating redundant sub-diagrams and nodes Start with OBDT and repeatedly apply the following two operations as long as possible: 1.Eliminate duplicate sub-diagrams. Keep a single copy. Redirect edges into the eliminated duplicates into this single copy. 2.Eliminate redundant nodes. Whenever low(v) = high(v), remove v and redirect edges into v to low(v). Why does this terminate? ROBDD is often exponentially smaller than the corresponding OBDT

16
16 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 0000 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001

17
17 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 0000 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001 Duplicate sub- diagram

18
18 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 000 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001

19
19 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 000 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001

20
20 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 00 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001

21
21 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 00 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001

22
22 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1001 b2b2 b2b2 0 a2a2 a2a2 b2b2 b2b2 0000 b2b2 b2b2 1001

23
23 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1 b2b2 b2b2 0 a2a2 a2a2 b2b2 b2b2 b2b2 b2b2

24
24 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1 b2b2 b2b2 0 a2a2 a2a2 b2b2 b2b2 b2b2 b2b2 Redundant node

25
25 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1 b2b2 0 a2a2 a2a2 b2b2 b2b2 b2b2 b2b2

26
26 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 1 b2b2 0 a2a2 a2a2 b2b2 b2b2 b2b2 b2b2

27
27 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 10 a2a2 a2a2 b2b2 b2b2 b2b2 b2b2

28
28 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 a2a2 b2b2 b2b2 10 a2a2 a2a2 b2b2 b2b2 b2b2 b2b2

29
29 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 b2b2 b2b2 10 a2a2 a2a2 b2b2 b2b2 b2b2 b2b2 If a 1 = 0 and b 1 = 1 then f = 0 irrespective of the values of a 2 and b 2

30
30 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 b2b2 b2b2 10 a2a2 b2b2 b2b2

31
31 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 b2b2 b2b2 10 a2a2 b2b2 b2b2

32
32 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 b2b2 10 a2a2 b2b2 b2b2

33
33 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 b2b2 10 a2a2 b2b2 b2b2

34
34 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 b2b2 10 a2a2 b2b2

35
35 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 a2a2 b2b2 10 a2a2 b2b2

36
36 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 b2b2 10 a2a2 b2b2 Let’s move things around a little bit so that the BDD looks nicer.

37
37 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University OBDT to ROBDD a1a1 b1b1 b1b1 b2b2 10 a2a2 b2b2 Bryant gave a linear-time algorithm (called Reduce) to convert OBDT to ROBDD. In practice, BDD packages don’t use Reduce directly. They apply the two reductions on-the-fly as new BDDs are constructed from existing ones. Why? Bryant gave a linear-time algorithm (called Reduce) to convert OBDT to ROBDD. In practice, BDD packages don’t use Reduce directly. They apply the two reductions on-the-fly as new BDDs are constructed from existing ones. Why?

38
38 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD (a.k.a. BDD) Summary BDDs are canonical representations of Boolean formulas f 1 = f 2, ?

39
39 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD (a.k.a. BDD) Summary BDDs are canonical representations of Boolean formulas f 1 = f 2, BDD(f 1 ) and BDD(f 2 ) are isomorphic f is unsatisfiable, ?

40
40 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD (a.k.a. BDD) Summary BDDs are canonical representations of Boolean formulas f 1 = f 2, BDD(f 1 ) and BDD(f 2 ) are isomorphic f is unsatisfiable, BDD(f) is the leaf node “0” f is valid, ?

41
41 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD (a.k.a. BDD) Summary BDDs are canonical representations of Boolean formulas f 1 = f 2, BDD(f 1 ) and BDD(f 2 ) are isomorphic f is unsatisfiable, BDD(f) is the leaf node “0” f is valid, BDD(f) is the leaf node “1” BDD packages do these operations in constant time Logical operations can be performed efficiently on BDDs Polynomial in argument size More details in next lecture BDD size depends critically on the variable ordering Some formulas have exponentially large sizes for all ordering Others are polynomial for some ordering and exponential for others

42
42 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 a2a2 a2a2 b1b1 b1b1 b2b2 b2b2 1000 b2b2 b2b2 0100 b1b1 b1b1 b2b2 b2b2 0010 b2b2 b2b2 0001

43
43 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 a2a2 a2a2 b1b1 b1b1 b2b2 b2b2 b2b2 b2b2 10 b1b1 b1b1 b2b2 b2b2 b2b2 b2b2

44
44 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 a2a2 a2a2 b1b1 b1b1 b2b2 b2b2 10 b1b1 b1b1 b2b2 b2b2

45
45 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 a2a2 a2a2 b1b1 b1b1 b2b2 b2b2 10 b1b1 b1b1 b2b2 b2b2

46
46 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 a2a2 a2a2 b1b1 b1b1 b2b2 10 b1b1 b1b1 b2b2 b2b2

47
47 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 a2a2 a2a2 b1b1 b1b1 b2b2 10 b1b1 b1b1 b2b2 b2b2

48
48 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 a2a2 a2a2 b1b1 b1b1 b2b2 10 b1b1 b1b1 b2b2 Let’s move things around a little bit so that the BDD looks nicer.

49
49 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 a2a2 a2a2 b1b1 b1b1 b2b2 10 b1b1 b1b1 b2b2 a1a1 b1b1 b1b1 b2b2 10 a2a2 b2b2 11 nodes 8 nodes a 1 < a 2 < b 1 < b 2 a 1 < b 1 < a 2 < b 2

50
50 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 anan anan b1b1 b1b1 bnbn 10 b1b1 b1b1 bnbn a1a1 b1b1 b1b1 bnbn 10 anan bnbn ? £ 2 n – 1 nodes ? £ n + 2 nodes a 1 < … < a n < b 1 < … < b n a 1 < b 1 < … < a n < b n

51
51 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University ROBDD and variable ordering a1a1 anan anan b1b1 b1b1 bnbn 10 b1b1 b1b1 bnbn a1a1 b1b1 b1b1 bnbn 10 anan bnbn 3 £ 2 n – 1 nodes 3 £ n + 2 nodes a 1 < … < a n < b 1 < … < b n a 1 < b 1 < … < a n < b n

52
52 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Next Class BDD recap BDD operations BDD applications Next homework See you then …

53
53 Binary Decision Diagrams – Part 1 Sagar Chaki, Sep 12, 2011 © 2011 Carnegie Mellon University Questions? Sagar Chaki Senior Member of Technical Staff RTSS Program Telephone: +1 412-268-1436 Email: chaki@sei.cmu.educhaki@sei.cmu.edu U.S. Mail Software Engineering Institute Customer Relations 4500 Fifth Avenue Pittsburgh, PA 15213-2612 USA Web www.sei.cmu.edu/staff/chaki Customer Relations Email: info@sei.cmu.edu Telephone: +1 412-268-5800 SEI Phone: +1 412-268-5800 SEI Fax: +1 412-268-6257

Similar presentations

© 2020 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google