binary decision diagrams (bdds)

22
1/20 Binary Decision Diagrams Charngki Hong @ PSWLAB Binary Decision Diagrams (BDDs) Daniel Kroening and Ofer Strichman

Upload: valentino-dawson

Post on 02-Jan-2016

41 views

Category:

Documents


2 download

DESCRIPTION

Binary Decision Diagrams (BDDs). Daniel Kroening and Ofer Strichman. Part I. Reminders - What is Logic Proofs by deduction Proofs by enumeration Decidability, Soundness and Completeness some notes on Propositional Logic Deciding Propositional Logic SAT tools BDDs. . . . . . - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Binary Decision Diagrams (BDDs)

1/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Binary Decision Diagrams (BDDs)

Daniel Kroening and Ofer Strichman

Page 2: Binary Decision Diagrams (BDDs)

2/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Part I Reminders -

What is Logic Proofs by deduction Proofs by enumeration Decidability, Soundness and Completeness some notes on Propositional Logic

Deciding Propositional Logic SAT tools BDDs

Page 3: Binary Decision Diagrams (BDDs)

3/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Next: Binary Decision Diagrams SAT looked for a satisfying solution to CNF We will now examine a graph-based data

structure called Binary Decision Diagrams. It has several advantages and disadvantages

comparing to SAT

Developed by Bryant [1986]. Next few slides are from the source …

Page 4: Binary Decision Diagrams (BDDs)

4/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Alternate Approach Generate complete representation of function

Canonicity: functions are equal iff representations are identical

A

C

B

O1

T1

T2

ABC

O2

T3

(A ∧ C) ∨ (C ∧ B)

(A Ç B) Æ (C)

B

0 1

C

A

B

0 1

C

A

Page 5: Binary Decision Diagrams (BDDs)

5/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Decision Structures

Truth Table Decision Tree

Vertex represents decision Follow green (dashed) line for value 0 Follow red (solid) line for value 1 Function value determined by leaf value.

0 0

x3

0 1

x3

x2

0 1

x3

0 1

x3

x2

x100001111

00110011

01010101

00010101

x1 x2 x3 f

Page 6: Binary Decision Diagrams (BDDs)

6/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Variable Ordering Assign arbitrary total ordering to variables

e.g., x1 < x2 < x3

Variables must appear in ascending order along all paths

OK Not OK

x1

x2

x3

x1

x3

x3

x2

x1

x1

x3

Page 7: Binary Decision Diagrams (BDDs)

7/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Reduction Rule #1

Merge equivalent leaves

a a

0 0

x3

0 1

x3

x2

0 1

x3

0 1

x3

x2

x1

x3 x3

x2

x3

0 1

x3

x2

x1

a

Page 8: Binary Decision Diagrams (BDDs)

8/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Reduction Rule #2

y

x

z

x

Merge isomorphic nodes

x3 x3

x2

x3

0 1

x3

x2

x1

x3

x2

0 1

x3

x2

x1

y

x

z

x

y

x

z

x

Page 9: Binary Decision Diagrams (BDDs)

9/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Reduction Rule #3

x3

x2

0 1

x3

x2

x1

Eliminate Redundant Tests

y

x

y

x2

0 1

x3

x1

Page 10: Binary Decision Diagrams (BDDs)

10/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Example OBDD

Initial Graph Reduced Graph

Canonical representation of Boolean functionso For a given variable ordering Two functions are equivalent iff graphs are isomorphic

Can be tested in linear time Desirable property: simplest form is canonical.

x2

0 1

x3

x1

0 0

x3

0 1

x3

x2

0 1

x3

0 1

x3

x2

x1(x1 Ç x2) Æ x3

Page 11: Binary Decision Diagrams (BDDs)

11/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Satisfiability etc.

Constants

Unique unsatisfiable function

Unique tautology1

0

Conclusion: given a BDD it takes constant time to check: Validity Contradiction Satisfiability

Is this a free lunch ? …

Page 12: Binary Decision Diagrams (BDDs)

12/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Effect of Variable Ordering

Good Ordering Bad Ordering

Linear Growth

0

b3

a3

b2

a2

1

b1

a1

Exponential Growth

a3 a3

a2

b1 b1

a3

b2

b1

0

b3

b2

1

b1

a3

a2

a1

)()()( 332211 bababa

Page 13: Binary Decision Diagrams (BDDs)

13/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Selecting Good Variable Ordering Intractable Problem

Even when problem represented as OBDD i.e., to find optimum improvement to current ordering

Application-Based Heuristics Exploit characteristics of application e.g., Ordering for functions of combinational circuit

Traverse circuit graph depth-first from outputs to in-puts

Page 14: Binary Decision Diagrams (BDDs)

14/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Building BDDs ‘from below’ Starting from a binary decision tree is too hard

for formulas with many variables. Goal: construct the BDD ‘from below’.

Page 15: Binary Decision Diagrams (BDDs)

15/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Building BDDs ‘from below’ For this we will need a function called APPLY:

Given the BDDs for f1 and f2, and a binary connective F 2 {Æ, Ç, !, $...} (any

one of the 16 binary connectives), Construct the BDD for f1 F f2,

Page 16: Binary Decision Diagrams (BDDs)

16/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Building BDDs ‘from below’ Def: a restriction of a function f to x=d, denoted f|

x=d where x 2 vars(f), d 2 {0,1}, is equal to f after assigning x=d.

Given the BDD of f, deriving the BDD of f|x=0 is simple:

x2

0 1

x3

x1

f: (x1 Ç x2) Æ x3

0 1

x 3

x1

0 1

x 3

f|x2=1

Page 17: Binary Decision Diagrams (BDDs)

17/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Now, APPLY (1/3) Let v1,v2 denote that root nodes of f1, f2, re-

spectively, with var(v1) = x1 and var(v2)=x2.

1. If v1 and v2 are leafs, f1 F f2 is a leaf node with value val(v1) F val(v2)

0 1 1Ç =

0 1 0Æ =

Page 18: Binary Decision Diagrams (BDDs)

18/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Now, APPLY (2/3)

2. If x1 = x2 = x, apply Shanon expansion:f1 F f2 = (:x Æ f1|x=0 F f2|x=0 Ç x Æ f1|x=1 F f2|x=1)

x

BDD for f1|x=0

BDD for f1|x=1

x

BDD for f2|x=0

BDD for f2|x=1

Æ =x

BDD for f1|x=1 Æ f2|x=1

BDD for f1|x=0 Æ f2|x=0

Page 19: Binary Decision Diagrams (BDDs)

19/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Now, APPLY (3/3)3. else, suppose x1 < x2 in the variable order.

f1 F f2 = (:x1 Æ f1|x=0 F f2 Ç x1 Æ f1|x=1 F f2)

x1

BDD for f1|x1=0

BDD for f1|x1=1

x2

BDD for f2|x2=0

BDD for f2|x2=1

Æ =x1

BDD for f1|x=1 Æ f2

BDD for f1|x=0 Æ f2

Page 20: Binary Decision Diagrams (BDDs)

20/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

BDDs from below: example.

x2

0 1

x1

x2

f1: x1 $ x2

x2

10

Ç

f2: :x2

=

x1

BDD for f1|x1=0 Ç f2

BDD for f1|x1=1 Ç f2

BDD for f1|x1=0 Ç f2

= x2

0 1

Çx2

10

=x2

0 1

0 Ç 0 = 0 1 Ç 1 = 1

Page 21: Binary Decision Diagrams (BDDs)

21/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

BDDs from below: example.

x2

0 1

x1

x2

f1: x1 $ x2

x2

10

Ç

f2: :x2

=x1

BDD for f1|x=0 Ç f2

BDD for f1|x=1 Ç f2

=

x1

x2

10

x2

1

=

x1

x2

10

x2

f1 Ç f2 = x1 Ç (:x1 Æ :x2)

Page 22: Binary Decision Diagrams (BDDs)

22/20 Binary Decision Diagrams Charngki Hong @ PSWLAB

Comparing SAT to BDDs BDD is a canonical data structure that repre-

sents the semantic of a function, i.e. all its so-lutions Some applications (e.g. symbolic model checking)

need canonicity to detect when two sets are equivalent.

Can require exponential space & time (highly sen-sitive to variable ordering)

SAT searches through CNF for a single solution CNF is not canonical. Poly-space algorithms exists. Time can be expo-

nential.