Presentation is loading. Please wait.

Presentation is loading. Please wait.

Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.

Similar presentations


Presentation on theme: "Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs."— Presentation transcript:

1 Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs

2 Decision Procedures An algorithmic point of view2 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 …

3 Decision Procedures An algorithmic point of view3 Alternate Approach Generate complete representation of function Canonicity: functions are equal iff representations are identical (A Æ C) Ç (C Æ B) (A Ç B) Æ (C) B 01C AB 01C A

4 Decision Procedures An algorithmic point of view4 Decision Structures Truth TableDecision Tree  Vertex represents decision  Follow green (dashed) line for value 0  Follow red (solid) line for value 1  Function value determined by leaf value.

5 Decision Procedures An algorithmic point of view5 Variable Ordering  Assign arbitrary total ordering to variables e.g., x 1 < x 2 < x 3  Variables must appear in ascending order along all paths OKNot OK x 3 x 2 x 1 x 1 x3x3

6 Decision Procedures An algorithmic point of view6 Reduction Rule #1 Merge equivalent leaves aa a

7 Decision Procedures An algorithmic point of view7 Reduction Rule #2 y x z x Merge isomorphic nodes y x z x y x z x

8 Decision Procedures An algorithmic point of view8 Reduction Rule #3 Eliminate Redundant Tests y x y

9 Decision Procedures An algorithmic point of view9 Example OBDD Initial GraphReduced Graph Canonical representation of Boolean functions 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. (x 1 Ç x 2 ) Æ x 3

10 Decision Procedures An algorithmic point of view10 Satisfiability etc. Constants Unique unsatisfiable function Unique tautology Conclusion: given a BDD it takes constant time to check:  Validity  Contradiction  Satisfiability Is this a free lunch ? …

11 Decision Procedures An algorithmic point of view11 Effect of Variable Ordering Good OrderingBad Ordering Linear GrowthExponential Growth

12 Decision Procedures An algorithmic point of view12 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 inputs

13 Decision Procedures An algorithmic point of view13 Building BDDs ‘from below’ Starting from a binary decision tree is too hard for formulas with many variables. Goal: construct the BDD ‘from below’.

14 Decision Procedures An algorithmic point of view14 Building BDDs ‘from below’ For this we will need a function called APPLY:  Given the BDDs for f 1 and f 2,  and a binary connective F 2 { Æ, Ç, !, $...} (any one of the 16 binary connectives),  Construct the BDD for f 1 F f 2.

15 Decision Procedures An algorithmic point of view15 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: f : (x 1 Ç x 2 ) Æ x 3 01 x 3 x 1 01 x 3 f | x2=1

16 Decision Procedures An algorithmic point of view16 Now, APPLY (1/3) Let v 1, v 2 denote that root nodes of f 1, f 2, respectively, with var( v 1 ) = x 1 and var( v 2 )= x 2. 1. If v 1 and v 2 are leafs, f 1 F f 2 is a leaf node with value val( v 1 ) F val( v 2 ) 0 1 1 Ç = 0 1 0 Æ =

17 Decision Procedures An algorithmic point of view17 Now, APPLY (2/3) 2. If x 1 = x 2 = x, apply Shanon expansion: f 1 F f 2 = ( : x Æ f 1 | x=0 F f 2 | x=0 Ç x Æ f 1 | x=1 F f 2 | x=1 ) x BDD for f 1 | x=0 BDD for f 1 | x=1 x BDD for f 2 | x=0 BDD for f 2 | x=1 Æ = x BDD for f 1 | x=1 Æ f 2 | x=1 BDD for f 1 | x=0 Æ f 2 | x=0

18 Decision Procedures An algorithmic point of view18 Now, APPLY (3/3) 3. else, suppose x 1 < x 2 in the variable order. f 1 F f 2 = ( : x 1 Æ f 1 | x=0 F f 2 Ç x 1 Æ f 1 | x=1 F f 2 ) x1x1 BDD for f 1 | x1=0 BDD for f 1 | x1=1 x2x2 BDD for f 2 | x2=0 BDD for f 2 | x2=1 Æ = x1x1 BDD for f 1 | x1=1 Æ f 2 BDD for f 1 | x1=0 Æ f 2

19 Decision Procedures An algorithmic point of view19 BDDs from below: example. x 2 01 x 1 x 2 f 1 : x 1 $ x 2 x 2 10 Ç f 2 : : x 2 = x 1 BDD for f 1 | x1=0 Ç f 2 BDD for f 1 | x1=1 Ç f 2 BDD for f 1 | x1=0 Ç f 2 = x2x2 0 1 Ç x 2 10 = x 2 01 0 Ç 0 = 0 1 Ç 1 = 1

20 Decision Procedures An algorithmic point of view20 BDDs from below: example. x 2 01 x 1 x 2 f 1 : x 1 $ x 2 x 2 10 Ç f 2 : : x 2 = x 1 BDD for f 1 | x=0 Ç f 2 BDD for f 1 | x=1 Ç f 2 = x 1 x 2 10 x 2 1 = x 1 x 2 10 x 2 f 1 Ç f 2 = x 1 Ç ( : x 1 Æ : x 2 )

21 Decision Procedures An algorithmic point of view21 BDD’s are compact truth tables pqrp Ç (q Æ r) 1111 1101 1011 1001 0111 0100 0010 0000

22 Decision Procedures An algorithmic point of view22 BDD’s are compact truth tables pqrp Ç (q Æ r) 11*1 10*1 0111 0100 00*0

23 Decision Procedures An algorithmic point of view23 BDD’s are compact truth tables pqrp Ç (q Æ r) 1**1 0111 0100 00*0 How would the BDD look like in the order p,q,r ?

24 Decision Procedures An algorithmic point of view24 BDD’s are compact truth tables pqrp © (q © r) 1111 1100 1010 1001 0110 0101 0011 0000 Rows 5,6 have the same dependence on r, as do rows 3,4. Rows 7,8 have the same dependence on r, as do rows 1,2.

25 Decision Procedures An algorithmic point of view25 BDD’s are compact truth tables pqrp © (q © r) 1111 1100 1010 1001 01*see rows 3,4 00*see rows 1,2 Which reduction rule makes the BDD recognize this fact ?

26 Decision Procedures An algorithmic point of view26 Now with BDD’s p qq rrrr 01 p © (q © r) Nodes with the same dependence on r are isomorphic, and are hence united.

27 Decision Procedures An algorithmic point of view27 Now with BDD’s p qq r r 01 p © (q © r)

28 Decision Procedures An algorithmic point of view28 Comparing SAT to BDDs BDD is a canonical data structure that represents the semantic of a function, i.e. all its solutions  Some applications (e.g. symbolic model checking) need canonicity to detect when two sets are equivalent.  Can require exponential space & time (highly sensitive to variable ordering) SAT searches through CNF for a single solution  CNF is not canonical.  Poly-space algorithms exists. Time can be exponential.

29 Decision Procedures An algorithmic point of view29 Other uses of BDDs – Model counting Model counting – how many solutions does a formula have ? With SAT – O(SAT time £ # solutions). With BDDs – Linear!

30 Decision Procedures An algorithmic point of view30 Model counting Denote by  level(n) – location of node n in the order  left(n), right(n) – left and right child nodes of n For a node n, compute recursively:  if n is the ‘1’ node then count(n) = 1  if n is the ‘0’ node then count(n) = 0  otherwise: count(n) = Lcount(n) + Rcount(n) where: Lcount(n) = count(left(n)) * 2 level(left(n)) - level(n) – 1 // # solutions on left Rcount(n) = count(right(n)) * 2 level(right(n)) - level(n) – 1 // # solutions on right

31 Decision Procedures An algorithmic point of view31 Model Counting Model counting – how many solutions does a formula have ? (a Ç b Ç c) Æ d a c b d 01 1 1 2 4 1 3 7 0 0

32 Decision Procedures An algorithmic point of view32 Other uses of BDDs – random solutions A propositional formula has many solutions Suppose we need to choose one/some of them with a uniform distribution  i.e., every solution has equal chance A sample application: random test generation Try to do that with SAT...

33 Decision Procedures An algorithmic point of view33 Other uses of BDDs – random solutions Given Lcount(n) and Rcount(n) for each n:  Starting from the top: Choose left with probability Lcount(n) / count(n) Choose right with probability Rcount(n) / count(n)  Give even probability to variables missing from the path.

34 Decision Procedures An algorithmic point of view34 Other uses of BDDs – random solutions (a Ç b Ç c) Æ d a c b d 01 1 1 2 4 1 3 0 0 4/7 3/7 1/3 2/3


Download ppt "Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs."

Similar presentations


Ads by Google