an introduction to binary decision diagrams by henrik r. anderson

Upload: hasan-imam

Post on 07-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    1/37

    A n I n t r o d u c t i o n t o

    B i n a r y D e c i s i o n D i a g r a m s

    H e n r i k R e i f A n d e r s e n

    01

    x

    y

    y

    z

    L e c t u r e n o t e s f o r 4 9 2 8 5 A d v a n c e d A l g o r i t h m s E 9 7 , O c t o b e r 1 9 9 7 .

    M i n o r r e v i s i o n s , A p r . 1 9 9 8

    E - m a i l : h r a @ i t . d t u . d k . W e b : h t t p : w w w . i t . d t u . d k h r a

    D e p a r t m e n t o f I n f o r m a t i o n T e c h n o l o g y , T e c h n i c a l U n i v e r s i t y o f D e n m a r k

    B u i l d i n g 3 4 4 , D K - 2 8 0 0 L y n g b y , D e n m a r k .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    2/37

    1

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    3/37

    2

    P r e f a c e

    T h i s n o t e i s a s h o r t i n t r o d u c t i o n t o B i n a r y D e c i s i o n D i a g r a m s . I t p r o v i d e s s o m e b a c k -

    g r o u n d k n o w l e d g e a n d d e s c r i b e s t h e c o r e a l g o r i t h m s . M o r e d e t a i l s c a n b e f o u n d i n

    B r y a n t ' s o r i g i n a l p a p e r o n R e d u c e d O r d e r e d B i n a r y D e c i s i o n D i a g r a m s B r y 8 6 a n d t h e

    s u r v e y p a p e r B r y 9 2 . A r e c e n t e x t e n s i o n c a l l e d B o o l e a n E x p r e s s i o n D i a g r a m s i s d e s c r i b e d

    i n A H 9 7 .

    T h i s n o t e i s a r e v i s i o n o f a n e a r l i e r v e r s i o n f r o m f a l l 1 9 9 6 b a s e d o n v e r s i o n s f r o m

    1 9 9 5 a n d 1 9 9 4 . T h e m a j o r d i e r e n c e s a r e a s f o l l o w s : F i r s t l y , R O B D D s a r e n o w v i e w e d

    a s n o d e s o f o n e g l o b a l g r a p h w i t h o n e x e d o r d e r i n g t o r e e c t s t a t e - o f - t h e - a r t o f e c i e n t

    B D D p a c k a g e s . T h e a l g o r i t h m s h a v e b e e n c h a n g e d a n d s i m p l i e d t o r e e c t t h i s f a c t .

    S e c o n d l y , a p r o o f o f t h e c a n o n i c i t y l e m m a h a s b e e n a d d e d . T h i r d l y , t h e s e c t i o n s p r e s e n t i n g

    t h e a l g o r i t h m s h a v e b e e n c o m p l e t e l y r e s t r u c t u r e d . F i n a l l y , t h e p r o j e c t p r o p o s a l h a s b e e n

    r e v i s e d .

    A c k n o w l e d g e m e n t s

    T h a n k s t o t h e s t u d e n t s o n t h e c o u r s e s o f f a l l 1 9 9 4 , 1 9 9 5 , a n d 1 9 9 6 f o r h e l p i n g m e d e b u g

    a n d i m p r o v e t h e n o t e s . T h a n k s a r e a l s o d u e t o H a n s R i s c h e l , M o r t e n U l r i k S r e n s e n ,

    N i e l s M a r e t t i , J r g e n S t a u n s t r u p , K i m S k a k L a r s e n , H e n r i k H u l g a a r d , a n d v a r i o u s p e o p l e

    o n t h e I n t e r n e t w h o f o u n d t y p o s a n d s u g g e s t e d i m p r o v e m e n t s .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    4/37

    3

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    5/37

    C O N T E N T S 4

    C o n t e n t s

    1 B o o l e a n E x p r e s s i o n s 6

    2 N o r m a l F o r m s 7

    3 B i n a r y D e c i s i o n D i a g r a m s 8

    4 C o n s t r u c t i n g a n d M a n i p u l a t i n g R O B D D s 1 5

    4 . 1 M k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    4 . 2 B u i l d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 7

    4 . 3 A p p l y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 9

    4 . 4 R e s t r i c t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0

    4 . 5 S a t C o u n t , A n y S a t , A l l S a t . . . . . . . . . . . . . . . . . . . . . . . . 2 2

    4 . 6 S i m p l i f y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 5

    4 . 7 E x i s t e n t i a l Q u a n t i c a t i o n a n d S u b s t i t u t i o n . . . . . . . . . . . . . . . . . . 2 5

    5 I m p l e m e n t i n g t h e R O B D D o p e r a t i o n s 2 7

    6 E x a m p l e s o f p r o b l e m s o l v i n g w i t h R O B D D s 2 7

    6 . 1 T h e 8 Q u e e n s p r o b l e m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 7

    6 . 2 C o r r e c t n e s s o f C o m b i n a t i o n a l C i r c u i t s . . . . . . . . . . . . . . . . . . . . 2 9

    6 . 3 E q u i v a l e n c e o f C o m b i n a t i o n a l C i r c u i t s . . . . . . . . . . . . . . . . . . . . 2 9

    7 V e r i c a t i o n w i t h R O B D D s 3 1

    7 . 1 K n i g h t s t o u r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3

    8 P r o j e c t : A n R O B D D P a c k a g e 3 5

    R e f e r e n c e s 3 6

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    6/37

    C O N T E N T S 5

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    7/37

    1 B O O L E A N E X P R E S S I O N S 6

    1 B o o l e a n E x p r e s s i o n s

    T h e c l a s s i c a l c a l c u l u s f o r d e a l i n g w i t h t r u t h v a l u e s c o n s i s t s o f B o o l e a n v a r i a b l e s x ; y ; : : : ,

    t h e c o n s t a n t s t r u e 1 a n d f a l s e 0 , t h e o p e r a t o r s o f c o n j u n c t i o n , d i s j u n c t i o n _ , n e g a t i o n

    : , i m p l i c a t i o n , a n d b i - i m p l i c a t i o n w h i c h t o g e t h e r f o r m t h e B o o l e a n e x p r e s s i o n s .

    S o m e t i m e s t h e v a r i a b l e s a r e c a l l e d p r o p o s i t i o n a l v a r i a b l e s o r p r o p o s i t i o n a l l e t t e r s a n d t h e

    B o o l e a n e x p r e s s i o n s a r e t h e n k n o w n a s P r o p o s i t i o n a l L o g i c .

    F o r m a l l y , B o o l e a n e x p r e s s i o n s a r e g e n e r a t e d f r o m t h e f o l l o w i n g g r a m m a r :

    t : : = x j 0 j 1 j : t j t t j t _ t j t t j t t ;

    w h e r e x r a n g e s o v e r a s e t o f B o o l e a n v a r i a b l e s . T h i s i s c a l l e d t h e a b s t r a c t s y n t a x o f B o o l e a n

    e x p r e s s i o n s . T h e c o n c r e t e s y n t a x i n c l u d e s p a r e n t h e s e s t o s o l v e a m b i g u i t i e s . M o r e o v e r , a s

    a c o m m o n c o n v e n t i o n i t i s a s s u m e d t h a t t h e o p e r a t o r s b i n d a c c o r d i n g t o t h e i r r e l a t i v e

    p r i o r i t y . T h e p r i o r i t i e s a r e , w i t h t h e h i g h e s t r s t : : , , _ , , . H e n c e , f o r e x a m p l e

    : x

    1

    x

    2

    _ x

    3

    x

    4

    = : x

    1

    x

    2

    _ x

    3

    x

    4

    :

    A B o o l e a n e x p r e s s i o n w i t h v a r i a b l e s x

    1

    ; : : : ; x

    n

    d e n o t e s f o r e a c h a s s i g n m e n t o f t r u t h v a l u e s

    t o t h e v a r i a b l e s i t s e l f a t r u t h v a l u e a c c o r d i n g t o t h e s t a n d a r d t r u t h t a b l e s , s e e g u r e 1 .

    T r u t h a s s i g n m e n t s a r e w r i t t e n a s s e q u e n c e s o f a s s i g n m e n t s o f v a l u e s t o v a r i a b l e s , e . g . ,

    0 = x

    1

    ; 1 = x

    2

    ; 0 = x

    3

    ; 1 = x

    4

    w h i c h a s s i g n s 0 t o x

    1

    a n d x

    3

    , 1 t o x

    2

    a n d x

    4

    . W i t h t h i s p a r t i c u l a r

    t r u t h a s s i g n m e n t t h e a b o v e e x p r e s s i o n h a s v a l u e 1 , w h e r e a s 0 = x

    1

    ; 1 = x

    2

    ; 0 = x

    3

    ; 0 = x

    4

    y i e l d s

    0 .

    :

    0 1

    1 0

    0 1

    0 0 0

    1 0 1

    _ 0 1

    0 0 1

    1 1 1

    0 1

    0 1 1

    1 0 1

    0 1

    0 1 0

    1 0 1

    F i g u r e 1 : T r u t h t a b l e s .

    T h e s e t o f t r u t h v a l u e s i s o f t e n d e n o t e d B = f 0 ; 1 g . I f w e x a n o r d e r i n g o f t h e

    v a r i a b l e s o f a B o o l e a n e x p r e s s i o n t w e c a n v i e w t a s d e n i n g a f u n c t i o n f r o m B

    n

    t o B

    w h e r e n i s t h e n u m b e r o f v a r i a b l e s . N o t i c e , t h a t t h e p a r t i c u l a r o r d e r i n g c h o s e n f o r t h e

    v a r i a b l e s i s e s s e n t i a l f o r w h a t f u n c t i o n i s d e n e d . C o n s i d e r f o r e x a m p l e t h e e x p r e s s i o n

    x y . I f w e c h o o s e t h e o r d e r i n g x y t h e n t h i s i s t h e f u n c t i o n f x ; y = x y , t r u e i f

    t h e r s t a r g u m e n t i m p l i e s t h e s e c o n d , b u t i f w e c h o o s e t h e o r d e r i n g y x t h e n i t i s t h e

    f u n c t i o n f y ; x = x y , t r u e i f t h e s e c o n d a r g u m e n t i m p l i e s t h e r s t . W h e n w e l a t e r

    c o n s i d e r c o m p a c t r e p r e s e n t a t i o n s o f B o o l e a n e x p r e s s i o n s , s u c h v a r i a b l e o r d e r i n g s p l a y a

    c r u c i a l r o l e .

    T w o B o o l e a n e x p r e s s i o n s t a n d t

    0

    a r e s a i d t o b e e q u a l i f t h e y y i e l d t h e s a m e t r u t h

    v a l u e f o r a l l t r u t h a s s i g n m e n t s . A B o o l e a n e x p r e s s i o n i s a t a u t o l o g y i f i t y i e l d s t r u e f o r

    a l l t r u t h a s s i g n m e n t s ; i t i s s a t i s a b l e i f i t y i e l d s t r u e f o r a t l e a s t o n e t r u t h a s s i g n m e n t .

    E x e r c i s e 1 . 1 S h o w h o w a l l o p e r a t o r s c a n b e e n c o d e d u s i n g o n l y : a n d _ . U s e t h i s

    t o a r g u e t h a t a n y B o o l e a n e x p r e s s i o n c a n b e w r i t t e n u s i n g o n l y _ , , v a r i a b l e s , a n d :

    a p p l i e d t o v a r i a b l e s .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    8/37

    2 N O R M A L F O R M S 7

    E x e r c i s e 1 . 2 A r g u e t h a t t a n d t

    0

    a r e e q u a l i f a n d o n l y i f t t

    0

    i s a t a u t o l o g y . I s i t

    p o s s i b l e t o s a y w h e t h e r t i s s a t i s a b l e f r o m t h e f a c t t h a t : t i s a t a u t o l o g y ?

    2 N o r m a l F o r m s

    A B o o l e a n e x p r e s s i o n i s i n D i s j u n c t i v e N o r m a l F o r m D N F i f i t c o n s i s t s o f a d i s j u n c t i o n

    o f c o n j u n c t i o n s o f v a r i a b l e s a n d n e g a t i o n s o f v a r i a b l e s , i . e . , i f i t i s o f t h e f o r m

    t

    1

    1

    t

    1

    2

    ^ ^ t

    1

    k

    1

    _ _ t

    l

    1

    t

    l

    2

    ^ ^ t

    l

    k

    l

    1

    w h e r e e a c h t

    j

    i

    i s e i t h e r a v a r i a b l e x

    j

    i

    o r a n e g a t i o n o f a v a r i a b l e : x

    j

    i

    . A n e x a m p l e i s

    x ^ : y _ : x y

    w h i c h i s a w e l l - k n o w n f u n c t i o n o f x a n d y w h i c h o n e ? . A m o r e s u c c i n c t p r e s e n t a t i o n o f

    1 i s t o w r i t e i t u s i n g i n d e x e d v e r s i o n s o f a n d _ :

    l

    _

    j = 1

    0

    @

    k

    j

    i = 1

    t

    j

    i

    1

    A

    :

    S i m i l a r l y , a C o n j u n c t i v e N o r m a l F o r m C N F i s a n e x p r e s s i o n t h a t c a n b e w r i t t e n a s

    l

    j = 1

    0

    @

    k

    j

    _

    i = 1

    t

    j

    i

    1

    A

    w h e r e e a c h t

    j

    i

    i s e i t h e r a v a r i a b l e o r a n e g a t e d v a r i a b l e . I t i s n o t d i c u l t t o p r o v e t h e

    f o l l o w i n g p r o p o s i t i o n :

    P r o p o s i t i o n 1 A n y B o o l e a n e x p r e s s i o n i s e q u a l t o a n e x p r e s s i o n i n C N F a n d a n e x p r e s -

    s i o n i n D N F .

    I n g e n e r a l , i t i s h a r d t o d e t e r m i n e w h e t h e r a B o o l e a n e x p r e s s i o n i s s a t i s a b l e . T h i s i s

    m a d e p r e c i s e b y a f a m o u s t h e o r e m d u e t o C o o k C o o 7 1 :

    T h e o r e m 1 C o o k S a t i s a b i l i t y o f B o o l e a n e x p r e s s i o n s i s N P - c o m p l e t e .

    F o r r e a d e r s u n f a m i l i a r w i t h t h e n o t i o n o f N P - c o m p l e t e n e s s t h e f o l l o w i n g s h o r t s u m m a r y

    o f t h e p r a g m a t i c c o n s e q u e n c e s s u c e s . P r o b l e m s t h a t a r e N P - c o m p l e t e c a n b e s o l v e d

    b y a l g o r i t h m s t h a t r u n i n e x p o n e n t i a l t i m e . N o p o l y n o m i a l t i m e a l g o r i t h m s a r e k n o w n

    t o e x i s t f o r a n y o f t h e N P - c o m p l e t e p r o b l e m s a n d i t i s v e r y u n l i k e l y t h a t p o l y n o m i a l

    t i m e a l g o r i t h m s s h o u l d i n d e e d e x i s t a l t h o u g h n o b o d y h a s y e t b e e n a b l e t o p r o v e t h e i r

    n o n - e x i s t e n c e .

    C o o k ' s t h e o r e m e v e n h o l d s w h e n r e s t r i c t e d t o e x p r e s s i o n s i n C N F . F o r D N F s s a t i s -

    a b i l i t y i s d e c i d a b l e i n p o l y n o m i a l t i m e b u t f o r D N F s t h e t a u t o l o g y c h e c k i s h a r d c o - N P

    c o m p l e t e . A l t h o u g h s a t i s a b i l i t y i s e a s y f o r D N F s a n d t a u t o l o g y c h e c k e a s y f o r C N F s ,

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    9/37

    3 B I N A R Y D E C I S I O N D I A G R A M S 8

    t h i s d o e s n o t h e l p u s s i n c e t h e c o n v e r s i o n b e t w e e n C N F s a n d D N F s i s e x p o n e n t i a l a s t h e

    f o l l o w i n g e x a m p l e s h o w s .

    C o n s i d e r t h e f o l l o w i n g C N F o v e r t h e v a r i a b l e s x

    1

    0

    ; : : : x

    n

    0

    ; x

    1

    1

    ; : : : ; x

    n

    1

    :

    x

    1

    0

    _ x

    1

    1

    x

    2

    0

    _ x

    2

    1

    ^ ^ x

    n

    0

    _ x

    n

    1

    :

    T h e c o r r e s p o n d i n g D N F i s a d i s j u n c t i o n w h i c h h a s a d i s j u n c t f o r e a c h o f t h e n - d i g i t b i n a r y

    n u m b e r s f r o m 0 0 0 : : : 0 0 0 t o 1 1 1 : : : 1 1 1 | t h e i ' t h d i g i t r e p r e s e n t i n g a c h o i c e o f e i t h e r x

    i

    0

    f o r 0 o r x

    i

    1

    f o r 1 :

    x

    1

    0

    x

    2

    0

    ^ ^ x

    n , 1

    0

    x

    n

    0

    _

    x

    1

    0

    x

    2

    0

    ^ ^ x

    n , 1

    0

    x

    n

    1

    _

    .

    .

    .

    x

    1

    1

    x

    2

    1

    ^ ^ x

    n , 1

    1

    x

    n

    0

    _

    x

    1

    1

    x

    2

    1

    ^ ^ x

    n , 1

    1

    x

    n

    1

    :

    W h e r e a s t h e o r i g i n a l e x p r e s s i o n h a s s i z e p r o p o r t i o n a l t o n t h e D N F h a s s i z e p r o p o r t i o n a l

    t o n 2

    n

    .

    T h e n e x t s e c t i o n i n t r o d u c e s a n o r m a l f o r m t h a t h a s m o r e d e s i r a b l e p r o p e r t i e s t h a n

    D N F s a n d C N F s . I n p a r t i c u l a r , t h e r e a r e e c i e n t a l g o r i t h m s f o r d e t e r m i n i n g t h e s a t i s -

    a b i l i t y a n d t a u t o l o g y q u e s t i o n s .

    E x e r c i s e 2 . 1 D e s c r i b e a p o l y n o m i a l t i m e a l g o r i t h m f o r d e t e r m i n i n g w h e t h e r a D N F i s

    s a t i s a b l e .

    E x e r c i s e 2 . 2 D e s c r i b e a p o l y n o m i a l t i m e a l g o r i t h m f o r d e t e r m i n i n g w h e t h e r a C N F i s

    a t a u t o l o g y .

    E x e r c i s e 2 . 3 G i v e a p r o o f o f p r o p o s i t i o n 1 .

    E x e r c i s e 2 . 4 E x p l a i n h o w C o o k ' s t h e o r e m i m p l i e s t h a t c h e c k i n g i n - e q u i v a l e n c e b e t w e e n

    B o o l e a n e x p r e s s i o n s i s N P - h a r d .

    E x e r c i s e 2 . 5 E x p l a i n h o w t h e q u e s t i o n o f t a u t o l o g y a n d s a t i s a b i l i t y c a n b e d e c i d e d i f

    w e a r e g i v e n a n a l g o r i t h m f o r c h e c k i n g e q u i v a l e n c e b e t w e e n B o o l e a n e x p r e s s i o n s .

    3 B i n a r y D e c i s i o n D i a g r a m s

    L e t x ! y

    0

    ; y

    1

    b e t h e i f - t h e n - e l s e o p e r a t o r d e n e d b y

    x ! y

    0

    ; y

    1

    = x y

    0

    _ : x y

    1

    h e n c e , t ! t

    0

    ; t

    1

    i s t r u e i f t a n d t

    0

    a r e t r u e o r i f t i s f a l s e a n d t

    1

    i s t r u e . W e c a l l t t h e

    t e s t e x p r e s s i o n . A l l o p e r a t o r s c a n e a s i l y b e e x p r e s s e d u s i n g o n l y t h e i f - t h e n - e l s e o p e r a t o r

    a n d t h e c o n s t a n t s 0 a n d 1 . M o r e o v e r , t h i s c a n b e d o n e i n s u c h a w a y t h a t a l l t e s t s a r e

    p e r f o r m e d o n l y o n u n - n e g a t e d v a r i a b l e s a n d v a r i a b l e s o c c u r i n n o o t h e r p l a c e s . H e n c e

    t h e o p e r a t o r g i v e s r i s e t o a n e w k i n d o f n o r m a l f o r m . F o r e x a m p l e , : x i s x ! 0 ; 1 ,

    x y i s x ! y ! 1 ; 0 ; y ! 0 ; 1 . S i n c e v a r i a b l e s m u s t o n l y o c c u r i n t e s t s t h e B o o l e a n

    e x p r e s s i o n x i s r e p r e s e n t e d a s x ! 1 ; 0 .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    10/37

    3 B I N A R Y D E C I S I O N D I A G R A M S 9

    A n I f - t h e n - e l s e N o r m a l F o r m I N F i s a B o o l e a n e x p r e s s i o n b u i l t e n t i r e l y

    f r o m t h e i f - t h e n - e l s e o p e r a t o r a n d t h e c o n s t a n t s 0 a n d 1 s u c h t h a t a l l t e s t s a r e

    p e r f o r m e d o n l y o n v a r i a b l e s .

    I f w e b y t 0 = x d e n o t e t h e B o o l e a n e x p r e s s i o n o b t a i n e d b y r e p l a c i n g x w i t h 0 i n t t h e n

    i t i s n o t h a r d t o s e e t h a t t h e f o l l o w i n g e q u i v a l e n c e h o l d s :

    t = x ! t 1 = x ; t 0 = x : 2

    T h i s i s k n o w n a s t h e S h a n n o n e x p a n s i o n o f t w i t h r e s p e c t t o x . T h i s s i m p l e e q u a t i o n h a s

    a l o t o f u s e f u l a p p l i c a t i o n s . T h e r s t i s t o g e n e r a t e a n I N F f r o m a n y e x p r e s s i o n t . I f t

    c o n t a i n s n o v a r i a b l e s i t i s e i t h e r e q u i v a l e n t t o 0 o r 1 w h i c h i s a n I N F . O t h e r w i s e w e f o r m

    t h e S h a n n o n e x p a n s i o n o f t w i t h r e s p e c t t o o n e o f t h e v a r i a b l e s x i n t . T h u s s i n c e t 0 = x

    a n d t 1 = x b o t h c o n t a i n o n e l e s s v a r i a b l e t h a n t , w e c a n r e c u r s i v e l y n d I N F s f o r b o t h o f

    t h e s e ; c a l l t h e m t

    0

    a n d t

    1

    . A n I N F f o r t i s n o w s i m p l y

    x ! t

    1

    ; t

    0

    :

    W e h a v e p r o v e d :

    P r o p o s i t i o n 2 A n y B o o l e a n e x p r e s s i o n i s e q u i v a l e n t t o a n e x p r e s s i o n i n I N F .

    E x a m p l e 1 C o n s i d e r t h e B o o l e a n e x p r e s s i o n t = x

    1

    y

    1

    x

    2

    y

    2

    . I f w e n d a n

    I N F o f t b y s e l e c t i n g i n o r d e r t h e v a r i a b l e s x

    1

    ; y

    1

    ; x

    2

    ; y

    2

    o n w h i c h t o p e r f o r m S h a n n o n

    e x p a n s i o n s , w e g e t t h e e x p r e s s i o n s

    t = x

    1

    ! t

    1

    ; t

    0

    t

    0

    = y

    1

    ! 0 ; t

    0 0

    t

    1

    = y

    1

    ! t

    1 1

    ; 0

    t

    0 0

    = x

    2

    ! t

    0 0 1

    ; t

    0 0 0

    t

    1 1

    = x

    2

    ! t

    1 1 1

    ; t

    1 1 0

    t

    0 0 0

    = y

    2

    ! 0 ; 1

    t

    0 0 1

    = y

    2

    ! 1 ; 0

    t

    1 1 0

    = y

    2

    ! 0 ; 1

    t

    1 1 1

    = y

    2

    ! 1 ; 0

    F i g u r e 2 s h o w s t h e e x p r e s s i o n a s a t r e e . S u c h a t r e e i s a l s o c a l l e d a d e c i s i o n t r e e .

    A l o t o f t h e e x p r e s s i o n s a r e e a s i l y s e e n t o b e i d e n t i c a l , s o i t i s t e m p t i n g t o i d e n t i f y t h e m .

    F o r e x a m p l e , i n s t e a d o f t

    1 1 0

    w e c a n u s e t

    0 0 0

    a n d i n s t e a d o f t

    1 1 1

    w e c a n u s e t

    0 0 1

    . I f w e

    s u b s t i t u t e t

    0 0 0

    f o r t

    1 1 0

    i n t h e r i g h t - h a n d s i d e o f t

    1 1

    a n d a l s o t

    0 0 1

    f o r t

    1 1 1

    , w e i n f a c t s e e

    t h a t t

    0 0

    a n d t

    1 1

    a r e i d e n t i c a l , a n d i n t

    1

    w e c a n r e p l a c e t

    1 1

    w i t h t

    0 0

    .

    I f w e i n f a c t i d e n t i f y a l l e q u a l s u b e x p r e s s i o n s w e e n d u p w i t h w h a t i s k n o w n a s a

    b i n a r y d e c i s i o n d i a g r a m a B D D . I t i s n o l o n g e r a t r e e o f B o o l e a n e x p r e s s i o n s b u t a

    d i r e c t e d a c y c l i c g r a p h D A G .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    11/37

    3 B I N A R Y D E C I S I O N D I A G R A M S 1 0

    x

    1

    1 0 0 1 0

    y

    1

    x

    2

    y

    2

    y

    2

    0 11 00

    y

    1

    x

    2

    y

    2

    y

    2

    F i g u r e 2 : A d e c i s i o n t r e e f o r x

    1

    y

    1

    x

    2

    y

    2

    . D a s h e d l i n e s d e n o t e l o w - b r a n c h e s ,

    s o l i d l i n e s h i g h - b r a n c h e s .

    A p p l y i n g t h i s i d e a o f s h a r i n g , t c a n n o w b e w r i t t e n a s :

    t = x

    1

    ! t

    1

    ; t

    0

    t

    0

    = y

    1

    ! 0 ; t

    0 0

    t

    1

    = y

    1

    ! t

    0 0

    ; 0

    t

    0 0

    = x

    2

    ! t

    0 0 1

    ; t

    0 0 0

    t

    0 0 0

    = y

    2

    ! 0 ; 1

    t

    0 0 1

    = y

    2

    ! 1 ; 0

    E a c h s u b e x p r e s s i o n c a n b e v i e w e d a s t h e n o d e o f a g r a p h . S u c h a n o d e i s e i t h e r t e r m i n a l

    i n t h e c a s e o f t h e c o n s t a n t s 0 a n d 1 , o r n o n - t e r m i n a l . A n o n - t e r m i n a l n o d e h a s a l o w - e d g e

    c o r r e s p o n d i n g t o t h e e l s e - p a r t a n d a h i g h - e d g e c o r r e s p o n d i n g t o t h e t h e n - p a r t . S e e g u r e

    3 . N o t i c e , t h a t t h e n u m b e r o f n o d e s h a s d e c r e a s e d f r o m 9 i n t h e d e c i s i o n t r e e t o 6 i n

    t h e B D D . I t i s n o t h a r d t o i m a g i n e t h a t i f e a c h o f t h e t e r m i n a l n o d e s w e r e o t h e r b i g

    d e c i s i o n t r e e s t h e s a v i n g s w o u l d b e d r a m a t i c . S i n c e w e h a v e c h o s e n t o c o n s i s t e n t l y s e l e c t

    v a r i a b l e s i n t h e s a m e o r d e r i n t h e r e c u r s i v e c a l l s d u r i n g t h e c o n s t r u c t i o n o f t h e I N F o f t ,

    t h e v a r i a b l e s o c c u r i n t h e s a m e o r d e r i n g s o n a l l p a t h s f r o m t h e r o o t o f t h e B D D . I n t h i s

    s i t u a t i o n t h e b i n a r y d e c i s i o n d i a g r a m i s s a i d t o b e o r d e r e d a n O B D D . F i g u r e 3 s h o w s a

    B D D t h a t i s a l s o a n O B D D .

    F i g u r e 4 s h o w s f o u r O B D D s . S o m e o f t h e t e s t s e . g . , o n x

    2

    i n b a r e r e d u n d a n t ,

    s i n c e b o t h t h e l o w - a n d h i g h - b r a n c h l e a d t o t h e s a m e n o d e . S u c h u n n e c e s s a r y t e s t s c a n

    b e r e m o v e d : a n y r e f e r e n c e t o t h e r e d u n d a n t n o d e i s s i m p l y r e p l a c e d b y a r e f e r e n c e t o

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    12/37

    3 B I N A R Y D E C I S I O N D I A G R A M S 1 1

    y

    2

    y

    2

    y

    1

    y

    1

    x

    2

    x

    1

    0

    1

    F i g u r e 3 : A B D D f o r x

    1

    y

    1

    x

    2

    y

    2

    w i t h o r d e r i n g x

    1

    y

    1

    x

    2

    y

    2

    . L o w - e d g e s

    a r e d r a w n a s d o t t e d l i n e s a n d h i g h - e d g e s a s s o l i d l i n e s .

    1

    1

    0 1

    1

    x

    1

    x

    1

    x

    2

    x

    3

    x

    1

    x

    2

    dcba

    F i g u r e 4 : F o u r O B D D s : a A n O B D D f o r 1 . b A n o t h e r O B D D f o r 1 w i t h t w o r e d u n d a n t

    t e s t s . c S a m e a s b w i t h o n e o f t h e r e d u n d a n t t e s t s r e m o v e d . d A n O B D D f o r x

    1

    _ x

    3

    w i t h o n e r e d u n d a n t t e s t .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    13/37

    3 B I N A R Y D E C I S I O N D I A G R A M S 1 2

    x

    y z

    x y

    x z

    x x

    x

    F i g u r e 5 : T h e o r d e r i n g a n d r e d u c e d n e s s c o n d i t i o n s o f R O B D D s . L e f t : V a r i a b l e s m u s t

    b e o r d e r e d . M i d d l e : N o d e s m u s t b e u n i q u e . R i g h t : O n l y n o n - r e d u n d a n t t e s t s s h o u l d b e

    p r e s e n t .

    i t s s u b n o d e . I f a l l i d e n t i c a l n o d e s a r e s h a r e d a n d a l l r e d u n d a n t t e s t s a r e e l i m i n a t e d , t h e

    O B D D i s s a i d t o b e r e d u c e d a n R O B D D . R O B D D s h a v e s o m e v e r y c o n v e n i e n t p r o p e r t i e s

    c e n t e r e d a r o u n d t h e c a n o n i c i t y l e m m a b e l o w . O f t e n w h e n p e o p l e s p e a k a b o u t B D D s t h e y

    r e a l l y m e a n R O B D D s . T o s u m m a r i z e :

    A B i n a r y D e c i s i o n D i a g r a m B D D i s a r o o t e d , d i r e c t e d a c y c l i c g r a p h w i t h

    o n e o r t w o t e r m i n a l n o d e s o f o u t - d e g r e e z e r o l a b e l e d 0 o r 1 , a n d

    a s e t o f v a r i a b l e n o d e s u o f o u t - d e g r e e t w o . T h e t w o o u t g o i n g e d g e s

    a r e g i v e n b y t w o f u n c t i o n s l o w u a n d h i g h u . I n p i c t u r e s , t h e s e

    a r e s h o w n a s d o t t e d a n d s o l i d l i n e s , r e s p e c t i v e l y . A v a r i a b l e v a r u

    i s a s s o c i a t e d w i t h e a c h v a r i a b l e n o d e .

    A B D D i s O r d e r e d O B D D i f o n a l l p a t h s t h r o u g h t h e g r a p h t h e v a r i a b l e s

    r e s p e c t a g i v e n l i n e a r o r d e r x

    1

    x

    2

    x

    n

    . A n O B D D i s R e d u c e d

    R O B D D i f

    u n i q u e n e s s n o t w o d i s t i n c t n o d e s u a n d v h a v e t h e s a m e v a r i a b l e

    n a m e a n d l o w - a n d h i g h - s u c c e s s o r , i . e . ,

    v a r u = v a r v ; l o w u = l o w v ; h i g h u = h i g h v i m p l i e s u = v ;

    a n d

    n o n - r e d u n d a n t t e s t s n o v a r i a b l e n o d e u h a s i d e n t i c a l l o w - a n d

    h i g h - s u c c e s s o r , i . e . ,

    l o w u 6= h i g h u :

    T h e o r d e r i n g a n d r e d u c e d n e s s c o n d i t i o n s a r e s h o w n i n g u r e 5 .

    R O B D D s h a v e s o m e i n t e r e s t i n g p r o p e r t i e s . T h e y p r o v i d e c o m p a c t r e p r e s e n t a t i o n s o f

    B o o l e a n e x p r e s s i o n s , a n d t h e r e a r e e c i e n t a l g o r i t h m s f o r p e r f o r m i n g a l l k i n d s o f l o g i c a l

    o p e r a t i o n s o n R O B D D s . T h e y a r e a l l b a s e d o n t h e c r u c i a l f a c t t h a t f o r a n y f u n c t i o n

    f : B

    n

    ! B t h e r e i s e x a c t l y o n e R O B D D r e p r e s e n t i n g i t . T h i s m e a n s , i n p a r t i c u l a r , t h a t

    t h e r e i s e x a c t l y o n e R O B D D f o r t h e c o n s t a n t t r u e a n d c o n s t a n t f a l s e f u n c t i o n o n B

    n

    :

    t h e t e r m i n a l n o d e 1 a n d 0 i n c a s e o f f a l s e . H e n c e , i t i s p o s s i b l e t o t e s t i n c o n s t a n t t i m e

    w h e t h e r a n R O B D D i s c o n s t a n t l y t r u e o r f a l s e . R e c a l l t h a t f o r B o o l e a n e x p r e s s i o n s t h i s

    p r o b l e m i s N P - c o m p l e t e .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    14/37

    3 B I N A R Y D E C I S I O N D I A G R A M S 1 3

    T o m a k e t h i s c l a i m m o r e p r e c i s e w e m u s t s a y w h a t w e m e a n f o r a n R O B D D t o r e p r e s e n t

    a f u n c t i o n . F i r s t , i t i s q u i t e e a s y t o s e e h o w t h e n o d e s u o f a n R O B D D i n d u c t i v e l y d e n e s

    B o o l e a n e x p r e s s i o n s t

    u

    : A t e r m i n a l n o d e i s a B o o l e a n c o n s t a n t . A n o n - t e r m i n a l n o d e

    m a r k e d w i t h x i s a n i f - t h e n - e l s e e x p r e s s i o n w h e r e t h e c o n d i t i o n i s x a n d t h e t w o b r a n c h e s

    a r e t h e B o o l e a n e x p r e s s i o n s g i v e n b y t h e l o w - o r h i g h - s o n , r e s p e c t i v e l y :

    t

    0

    = 0

    t

    1

    = 1

    t

    u

    = v a r u ! t

    h i g h u

    ; t

    l o w u

    ; i f u i s a v a r i a b l e n o d e .

    M o r e o v e r , i f x

    1

    x

    2

    x

    n

    i s t h e v a r i a b l e o r d e r i n g o f t h e R O B D D , w e a s s o c i a t e

    w i t h e a c h n o d e u t h e f u n c t i o n f

    u

    t h a t m a p s b

    1

    ; b

    2

    ; : : : ; b

    n

    2 B

    n

    t o t h e t r u t h v a l u e o f

    t

    u

    b

    1

    = x

    1

    ; b

    2

    = x

    2

    ; : : : ; b

    n

    = x

    n

    . W e c a n n o w s t a t e t h e k e y l e m m a :

    L e m m a 1 C a n o n i c i t y l e m m a

    F o r a n y f u n c t i o n f : B

    n

    ! B t h e r e i s e x a c t l y o n e R O B D D u w i t h v a r i a b l e o r d e r i n g x

    1

    x

    2

    x

    n

    s u c h t h a t f

    u

    = f x

    1

    ; : : : ; x

    n

    .

    P r o o f : T h e p r o o f i s b y i n d u c t i o n o n t h e n u m b e r o f a r g u m e n t s o f f . F o r n = 0 t h e r e

    a r e o n l y t w o B o o l e a n f u n c t i o n s , t h e c o n s t a n t l y f a l s e a n d c o n s t a n t l y t r u e f u n c t i o n s . A n y

    R O B D D c o n t a i n i n g a t l e a s t o n e n o n - t e r m i n a l n o d e i s n o n - c o n s t a n t . W h y ? T h e r e f o r e

    t h e r e i s e x a c t l y o n e R O B D D f o r e a c h o f t h e s e : t h e t e r m i n a l s 0 a n d 1 .

    A s s u m e n o w t h a t w e h a v e p r o v e n t h e l e m m a f o r a l l f u n c t i o n s o f n a r g u m e n t s . W e

    p r o c e e d t o s h o w i t f o r a l l f u n c t i o n s o f n + 1 a r g u m e n t s . L e t f : B

    n + 1

    ! B b e a n y B o o l e a n

    f u n c t i o n o f n + 1 a r g u m e n t s . D e n e t h e t w o f u n c t i o n s f

    0

    a n d f

    1

    o f n a r g u m e n t s b y x i n g

    t h e r s t a r g u m e n t o f f t o 0 r e s p e c t i v e l y 1 :

    f

    b

    x

    2

    ; : : : ; x

    n + 1

    = f b ; x

    2

    ; : : : ; x

    n + 1

    f o r b 2 B .

    S o m e t i m e s f

    0

    a n d f

    1

    a r e c a l l e d t h e n e g a t i v e a n d p o s i t i v e c o - f a c t o r s o f f w i t h r e s p e c t t o

    x

    1

    . T h e s e f u n c t i o n s s a t i s f y t h e f o l l o w i n g e q u a t i o n :

    f x

    1

    ; : : : ; x

    n

    = x

    1

    ! f

    1

    x

    2

    ; : : : ; x

    n

    ; f

    0

    x

    2

    ; : : : ; x

    n

    : 3

    S i n c e f

    0

    a n d f

    1

    t a k e o n l y n a r g u m e n t s w e a s s u m e b y i n d u c t i o n t h a t t h e r e a r e u n i q u e

    R O B D D n o d e s u

    0

    a n d u

    1

    w i t h f

    u

    0

    = f

    0

    a n d f

    u

    1

    = f

    1

    .

    T h e r e a r e t w o c a s e s t o c o n s i d e r . I f u

    0

    = u

    1

    t h e n f

    u

    0

    = f

    u

    1

    a n d f

    0

    = f

    u

    0

    = f

    u

    1

    = f

    1

    =

    f . H e n c e u

    0

    = u

    1

    i s a n R O B D D f o r f . I t i s a l s o t h e o n l y R O B D D f o r f s i n c e d u e t o

    t h e o r d e r i n g , i f x

    1

    i s a t a l l p r e s e n t i n t h e R O B D D r o o t e d a t u , x

    1

    w o u l d n e e d t o b e t h e

    r o o t n o d e . H o w e v e r , i f f = f

    u

    t h e n f

    0

    = f

    u

    0 = x

    1

    = f

    l o w u

    a n d f

    1

    = f

    u

    1 = x

    1

    = f

    h i g h u

    .

    S i n c e f

    0

    = f

    u

    0

    = f

    u

    1

    = f

    1

    b y a s s u m p t i o n , t h e l o w - a n d h i g h - s o n o f u w o u l d b e t h e s a m e ,

    m a k i n g t h e R O B D D v i o l a t e t h e r e d u c e d n e s s c o n d i t i o n o f n o n - r e d u n d a n t t e s t s .

    I f u

    0

    6= u

    1

    t h e n f

    u

    0

    6= f

    u

    1

    b y t h e i n d u c t i o n h y p o t h e s i s u s i n g t h e n a m e s x

    2

    ; : : : ; x

    n + 1

    i n p l a c e o f x

    1

    ; : : : ; x

    n

    . W e t a k e u t o b e t h e n o d e w i t h v a r u = x

    1

    , l o w u = u

    0

    , a n d

    h i g h u = u

    1

    , i . e . , f

    u

    = x

    1

    ! f

    u

    1

    ; f

    u

    0

    w h i c h i s r e d u c e d . B y a s s u m p t i o n f

    u

    1

    = f

    1

    a n d f

    u

    0

    = f

    0

    t h e r e f o r e u s i n g 3 w e g e t f

    u

    = f . S u p p o s e t h a t v i s s o m e o t h e r n o d e

    w i t h f

    v

    = f . C l e a r l y , f

    v

    m u s t d e p e n d o n x

    1

    , i . e . , f

    v

    0 = x

    1

    6= f

    v

    1 = x

    1

    o t h e r w i s e a l s o

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    15/37

    3 B I N A R Y D E C I S I O N D I A G R A M S 1 4

    f

    0

    = f

    v

    0 = x

    1

    = f

    v

    1 = x

    1

    = f

    1

    , a c o n t r a d i c t i o n . D u e t o t h e o r d e r i n g t h i s m e a n s t h a t

    v a r v = x

    1

    = v a r u . M o r e o v e r , f r o m f

    v

    = f i t f o l l o w s t h a t f

    l o w v

    = f

    0

    = f

    u

    0

    a n d

    f

    h i g h v

    = f

    1

    = f

    u

    1

    , w h i c h b y t h e i n d u c t i o n h y p o t h e s i s i m p l i e s t h a t l o w v = u

    0

    = l o w u

    a n d h i g h v = u

    1

    = h i g h u . F r o m t h e r e d u c e d n e s s p r o p e r t y o f u n i q u e n e s s i t f o l l o w s t h a t

    u = v .

    A n i m m e d i a t e c o n s e q u e n c e i s t h e f o l l o w i n g . S i n c e t h e t e r m i n a l 1 i s a n R O B D D f o r a l l

    v a r i a b l e o r d e r i n g s i t i s t h e o n l y R O B D D t h a t i s c o n s t a n t l y t r u e . S o i n o r d e r t o c h e c k

    w h e t h e r a n R O B D D i s c o n s t a n t l y t r u e i t s u c e s t o c h e c k w h e t h e r i t i s t h e t e r m i n a l 1

    w h i c h i s d e n i t e l y a c o n s t a n t t i m e o p e r a t i o n . S i m i l a r l y , R O B D D s t h a t a r e c o n s t a n t l y

    f a l s e m u s t b e i d e n t i c a l t o t h e t e r m i n a l 0 . I n f a c t , t o d e t e r m i n e w h e t h e r t w o B o o l e a n

    f u n c t i o n s a r e t h e s a m e , i t s u c e s t o c o n s t r u c t t h e i r R O B D D s i n t h e s a m e g r a p h a n d

    c h e c k w h e t h e r t h e r e s u l t i n g n o d e s a r e t h e s a m e !

    T h e o r d e r i n g o f v a r i a b l e s c h o s e n w h e n c o n s t r u c t i n g a n R O B D D h a s a g r e a t i m p a c t o n

    t h e s i z e o f t h e R O B D D . I f w e c o n s i d e r a g a i n t h e e x p r e s s i o n x

    1

    y

    1

    x

    2

    y

    2

    a n d

    c o n s t r u c t a n R O B D D u s i n g t h e o r d e r i n g x

    1

    x

    2

    y

    1

    y

    2

    t h e R O B D D c o n s i s t s o f 9

    n o d e s g u r e 6 a n d n o t 6 n o d e s a s f o r t h e o r d e r i n g x

    1

    y

    1

    x

    2

    y

    2

    g u r e 3 .

    01

    y

    2

    y

    2

    y

    1

    y

    1

    y

    1

    y

    1

    x

    2

    x

    2

    x

    1

    F i g u r e 6 : T h e R O B D D f o r x

    1

    y

    1

    x

    2

    y

    2

    w i t h v a r i a b l e o r d e r i n g x

    1

    x

    2

    y

    1

    y

    2

    .

    E x e r c i s e 3 . 1 S h o w h o w t o e x p r e s s a l l o p e r a t o r s f r o m t h e i f - t h e n - e l s e o p e r a t o r a n d t h e

    c o n s t a n t s 0 a n d 1 .

    E x e r c i s e 3 . 2 D r a w t h e R O B D D s f o r x

    1

    y

    1

    x

    2

    y

    2

    x

    3

    y

    3

    w i t h o r d e r i n g s

    x

    1

    x

    2

    x

    3

    y

    1

    y

    2

    y

    3

    a n d x

    1

    y

    1

    x

    2

    y

    2

    x

    3

    y

    3

    .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    16/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 1 5

    E x e r c i s e 3 . 3 D r a w t h e R O B D D s f o r x

    1

    y

    1

    _ x

    2

    y

    2

    w i t h o r d e r i n g s x

    1

    x

    2

    y

    1

    y

    2

    a n d x

    1

    y

    1

    x

    2

    y

    2

    . H o w d o e s i t c o m p a r e w i t h t h e e x a m p l e i n g u r e s 3 a n d 6 ?

    B a s e d o n t h e e x a m p l e s y o u h a v e s e e n s o f a r , w h a t v a r i a b l e o r d e r i n g w o u l d y o u r e c o m m e n d

    f o r c o n s t r u c t i n g a s m a l l R O B D D f o r x

    1

    y

    1

    x

    2

    y

    2

    x

    3

    y

    3

    ^ ^ x

    k

    y

    k

    ?

    E x e r c i s e 3 . 4 G i v e a n e x a m p l e o f a s e q u e n c e o f R O B D D s u

    n

    ; 0 n w h i c h i n d u c e s e x p o -

    n e n t i a l l y b i g g e r d e c i s i o n t r e e s . I . e . , i f u

    n

    h a s s i z e n t h e n t h e d e c i s i o n t r e e s h o u l d h a v e

    s i z e 2

    n

    .

    E x e r c i s e 3 . 5 C o n s t r u c t a n R O B D D o f m a x i m u m s i z e o v e r s i x v a r i a b l e s .

    4 C o n s t r u c t i n g a n d M a n i p u l a t i n g R O B D D s

    I n t h e p r e v i o u s s e c t i o n w e s a w h o w t o c o n s t r u c t a n O B D D f r o m a B o o l e a n e x p r e s s i o n

    b y a s i m p l e r e c u r s i v e p r o c e d u r e . T h e q u e s t i o n a r i s e s n o w h o w d o w e c o n s t r u c t a r e d u c e d

    O B D D ? O n e w a y i s t o r s t c o n s t r u c t a n O B D D a n d t h e n p r o c e e d b y r e d u c i n g i t . A n -

    o t h e r m o r e a p p e a l i n g a p p r o a c h , w h i c h w e f o l l o w h e r e , i s t o r e d u c e t h e O B D D d u r i n g

    c o n s t r u c t i o n .

    T o d e s c r i b e h o w t h i s i s d o n e w e w i l l n e e d a n e x p l i c i t r e p r e s e n t a t i o n o f R O B D D s . N o d e s

    w i l l b e r e p r e s e n t e d a s n u m b e r s 0 ; 1 ; 2 ; : : : w i t h 0 a n d 1 r e s e r v e d f o r t h e t e r m i n a l n o d e s . T h e

    v a r i a b l e s i n t h e o r d e r i n g x

    1

    x

    2

    x

    n

    a r e r e p r e s e n t e d b y t h e i r i n d i c e s 1 ; 2 ; : : : ; n .

    T h e R O B D D i s s t o r e d i n a t a b l e T : u 7! i ; l ; h w h i c h m a p s a n o d e u t o i t s t h r e e

    a t t r i b u t e s v a r u = i , l o w u = l , a n d h i g h u = h . F i g u r e 7 s h o w s t h e r e p r e s e n t a t i o n o f

    t h e R O B D D f r o m g u r e 3 w i t h t h e v a r i a b l e n a m e s c h a n g e d t o x

    1

    x

    2

    x

    3

    x

    4

    .

    4 . 1 M k

    I n o r d e r t o e n s u r e t h a t t h e O B D D b e i n g c o n s t r u c t e d i s r e d u c e d , i t i s n e c e s s a r y t o d e t e r -

    m i n e f r o m a t r i p l e i ; l ; h w h e t h e r t h e r e e x i s t s a n o d e u w i t h v a r u = i ; l o w u = l , a n d

    h i g h u = h . F o r t h i s p u r p o s e w e a s s u m e t h e p r e s e n c e o f a t a b l e H : i ; l ; h 7! u m a p p i n g

    t r i p l e s i ; l ; h o f v a r i a b l e i n d i c e s i , a n d n o d e s l ; h t o n o d e s u . T h e t a b l e H i s t h e i n v e r s e "

    o f t h e t a b l e T , i . e . , f o r v a r i a b l e n o d e s u , T u = i ; l ; h , i f a n d o n l y i f , H i ; l ; h = u . T h e

    o p e r a t i o n s n e e d e d o n t h e t w o t a b l e s a r e :

    T : u 7! i ; l ; h

    i n i t T i n i t i a l i z e T t o c o n t a i n o n l y 0 a n d 1

    u a d d T ; i ; l ; h a l l o c a t e a n e w n o d e u w i t h a t t r i b u t e s i ; l ; h

    v a r u ; l o w u ; h i g h u l o o k u p t h e a t t r i b u t e s o f u i n T

    H : i ; l ; h 7! u

    i n i t H i n i t i a l i z e H t o b e e m p t y

    b m e m b e r H ; i ; l ; h c h e c k i f i ; l ; h i s i n H

    u l o o k u p H ; i ; l ; h n d H i ; l ; h

    i n s e r t H ; i ; l ; h ; u m a k e i ; l ; h m a p t o u i n H

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    17/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 1 6

    2 3

    4

    5 6

    7

    x

    4

    x

    4

    x

    2

    x

    3

    x

    1

    0

    1

    x

    2

    T : u 7! i ; l ; h

    u v a r l o w h i g h

    0 5

    1 5

    2 4 1 0

    3 4 0 1

    4 3 2 3

    5 2 4 0

    6 2 0 4

    7 1 5 6

    F i g u r e 7 : R e p r e s e n t i n g a n R O B D D w i t h o r d e r i n g x

    1

    x

    2

    x

    3

    x

    4

    . T h e n u m b e r s

    i n s i d e t h e v e r t i c e s a r e t h e i d e n t i t i e s u s e d i n t h e r e p r e s e n t a t i o n . T h e n u m b e r s 0 a n d 1

    a r e r e s e r v e d f o r t h e t e r m i n a l n o d e s . T h e n u m b e r s t o t h e r i g h t o f t h e R O B D D s h o w s t h e

    i n d e x o f t h e v a r i a b l e s i n t h e o r d e r i n g . T h e c o n s t a n t s a r e a s s i g n e d a n i n d e x w h i c h i s t h e

    n u m b e r o f v a r i a b l e s i n t h e o r d e r i n g p l u s o n e h e r e 4 + 1 = 5 . T h i s m a k e s s o m e s u b s e q u e n t

    a l g o r i t h m s e a s i e r t o p r e s e n t . T h e l o w - a n d h i g h - e l d s a r e u n u s e d f o r t h e t e r m i n a l n o d e s .

    M k T ; H i ; l ; h

    1 : i f l = h t h e n r e t u r n l

    2 : e l s e i f m e m b e r H ; i ; l ; h t h e n

    3 : r e t u r n l o o k u p H ; i ; l ; h

    4 : e l s e u a d d T ; i ; l ; h

    5 : i n s e r t H ; i ; l ; h ; u

    6 : r e t u r n u

    F i g u r e 8 : T h e f u n c t i o n m k T ; H i ; l ; h .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    18/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 1 7

    B u i l d T ; H t

    1 : f u n c t i o n b u i l d ' t ; i =

    2 : i f i n t h e n

    3 : i f t i s f a l s e t h e n r e t u r n 0 e l s e r e t u r n 1

    4 : e l s e v

    0

    b u i l d ' t 0 = x

    i

    ; i + 1

    5 : v

    1

    b u i l d ' t 1 = x

    i

    ; i + 1

    6 : r e t u r n m k i ; v

    0

    ; v

    1

    7 : e n d b u i l d '

    8 :

    9 : r e t u r n b u i l d ' t ; 1

    F i g u r e 9 : A l g o r i t h m f o r b u i l d i n g a n R O B D D f r o m a B o o l e a n e x p r e s s i o n t

    u s i n g t h e o r d e r i n g x

    1

    x

    2

    x

    n

    . I n a c a l l b u i l d ' t ; i , i i s t h e l o w e s t

    i n d e x t h a t a n y v a r i a b l e o f t c a n h a v e . T h u s w h e n t h e t e s t i n s u c c e e d s , t

    c o n t a i n s n o v a r i a b l e s a n d m u s t b e e i t h e r c o n s t a n t l y f a l s e o r t r u e .

    W e s h a l l a s s u m e t h a t a l l t h e s e o p e r a t i o n s c a n b e p e r f o r m e d i n c o n s t a n t t i m e , O 1 . S e c t i o n

    5 w i l l s h o w h o w s u c h a l o w c o m p l e x i t y c a n b e a c h i e v e d .

    T h e f u n c t i o n m k T ; H i ; l ; h s e e g u r e 8 s e a r c h e s t h e t a b l e H f o r a n o d e w i t h

    v a r i a b l e i n d e x i a n d l o w - , h i g h - b r a n c h e s l ; h a n d r e t u r n s a m a t c h i n g n o d e i f o n e e x i s t s .

    O t h e r w i s e i t c r e a t e s a n e w n o d e u , i n s e r t s i t i n t o H a n d r e t u r n s t h e i d e n t i t y o f i t . T h e

    r u n n i n g t i m e o f m k i s O 1 d u e t o t h e a s s u m p t i o n s o n t h e b a s i c o p e r a t i o n s o n T a n d H .

    T h e O B D D i s e n s u r e d t o b e r e d u c e d i f n o d e s a r e o n l y c r e a t e d t h r o u g h t h e u s e o f m k . I n

    d e s c r i b i n g m k a n d s u b s e q u e n t a l g o r i t h m s , w e m a k e u s e o f t h e n o t a t i o n T ; H t o i n d i c a t e

    t h a t m k d e p e n d s o n t h e g l o b a l d a t a s t r u c t u r e s T a n d H , b u t w e l e a v e o u t t h e a r g u m e n t s

    w h e n i n v o k i n g i t a s p a r t o f o t h e r a l g o r i t h m s .

    4 . 2 B u i l d

    T h e c o n s t r u c t i o n o f a n R O B D D f r o m a g i v e n B o o l e a n e x p r e s s i o n t p r o c e e d s a s i n t h e

    c o n s t r u c t i o n o f a n i f - t h e n - e l s e n o r m a l f o r m I N F i n s e c t i o n 2 . A n o r d e r i n g o f t h e v a r i a b l e s

    x

    1

    x

    n

    i s x e d . U s i n g t h e S h a n n o n e x p a n s i o n t = x

    1

    ! t 1 = x

    1

    ; t 0 = x

    1

    , a n o d e f o r t

    i s c o n s t r u c t e d b y a c a l l t o m k , a f t e r t h e n o d e s f o r t 0 = x

    1

    a n d t 1 = x

    1

    h a v e b e e n c o n s t r u c t e d

    b y r e c u r s i o n . T h e a l g o r i t h m i s s h o w n i n g u r e 9 . T h e c a l l b u i l d ' t ; i c o n s t r u c t s a n

    R O B D D f o r a B o o l e a n e x p r e s s i o n t w i t h v a r i a b l e s i n f x

    i

    ; x

    i + 1

    ; : : : ; x

    n

    g . I t d o e s s o b y r s t

    r e c u r s i v e l y c o n s t r u c t i n g R O B D D s v

    0

    a n d v

    1

    f o r t 0 = x

    i

    a n d t 1 = x

    i

    i n l i n e s 4 a n d 5 , a n d

    t h e n p r o c e e d i n g t o n d t h e i d e n t i t y o f t h e n o d e f o r t i n l i n e 6 . N o t i c e t h a t i f v

    0

    a n d v

    1

    a r e

    i d e n t i c a l , o r i f t h e r e a l r e a d y i s a n o d e w i t h t h e s a m e i , v

    0

    a n d v

    1

    , n o n e w n o d e i s c r e a t e d .

    A n e x a m p l e o f u s i n g b u i l d t o c o m p u t e a n R O B D D i s s h o w n i n g u r e 1 0 . T h e r u n n i n g

    t i m e o f b u i l d i s b a d . I t i s e a s y t o s e e t h a t f o r a v a r i a b l e o r d e r i n g w i t h n v a r i a b l e s t h e r e

    w i l l a l w a y s b e g e n e r a t e d o n t h e o r d e r o f 2

    n

    c a l l s .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    19/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 1 8

    0 , x

    2

    _ x

    3

    ; 2

    b u i l d ' x

    1

    , x

    2

    _ x

    3

    ; 1

    1 , x

    2

    _ x

    3

    ; 2

    1 , 1 _ x

    3

    ; 3 1 , 0 _ x

    3

    ; 3

    1 , 0 _ 0 ; 4 1 , 1 _ 0 ; 4

    1 , 0 _ 1 ; 4 1 , 1 _ 1 ; 4

    0 , 1 _ x

    3

    ; 3

    0 , 1 _ 0 ; 4

    0 , 0 _ x

    3

    ; 3

    0 , 0 _ 1 ; 4

    0 , 0 _ 0 ; 4

    0 , 1 _ 1 ; 4

    b c

    d

    e

    f

    g

    e

    a

    11 1 0

    1 1 1 0 00

    b c d

    0

    e f g

    x

    3

    x

    2

    x

    3

    x

    2

    x

    3

    x

    2

    x

    3

    x

    2

    x

    2

    x

    1

    x

    2

    x

    3

    F i g u r e 1 0 : U s i n g b u i l d o n t h e e x p r e s s i o n x

    1

    x

    2

    _ x

    3

    . a T h e t r e e o f c a l l s t o b u i l d .

    b T h e R O B D D a f t e r t h e c a l l b u i l d ' 0 0 _ x

    3

    ; 3 . c A f t e r t h e c a l l b u i l d ' 0 1 _

    x

    3

    ; 3 . d A f t e r t h e c a l l b u i l d ' 0 x

    2

    _ x

    3

    ; 2 . e A f t e r t h e c a l l s b u i l d ' 1 0 _ x

    3

    ; 3

    a n d b u i l d ' 1 1 _ x

    3

    ; 3 . f A f t e r t h e c a l l b u i l d ' 1 x

    2

    _ x

    3

    ; 2 . g T h e n a l

    r e s u l t .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    20/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 1 9

    4 . 3 A p p l y

    A p p l y T ; H o p ; u

    1

    ; u

    2

    1 : i n i t G

    2 :

    3 : f u n c t i o n a p p u

    1

    ; u

    2

    =

    4 : i f G u

    1

    ; u

    2

    6= e m p t y t h e n r e t u r n G u

    1

    ; u

    2

    5 : e l s e i f u

    1

    2 f 0 ; 1 g a n d u

    2

    2 f 0 ; 1 g t h e n u o p u

    1

    ; u

    2

    6 : e l s e i f v a r u

    1

    = v a r u

    2

    t h e n

    7 : u m k v a r u

    1

    ; a p p l o w u

    1

    ; l o w u

    2

    ; a p p h i g h u

    1

    ; h i g h u

    2

    8 e l s e i f v a r u

    1

    v a r u

    2

    t h e n

    9 u m k v a r u

    1

    ; a p p l o w u

    1

    ; u

    2

    ; a p p h i g h u

    1

    ; u

    2

    1 0 : e l s e v a r u

    1

    v a r u

    2

    1 1 : u m k v a r u

    2

    ; a p p u

    1

    ; l o w u

    2

    ; a p p u

    1

    ; h i g h u

    2

    1 2 : G u

    1

    ; u

    2

    u

    1 3 : r e t u r n u

    1 4 : e n d a p p

    1 5 :

    1 6 : r e t u r n a p p u

    1

    ; u

    2

    F i g u r e 1 1 : T h e a l g o r i t h m a p p l y T ; H o p ; u

    1

    ; u

    2

    .

    A l l t h e b i n a r y B o o l e a n o p e r a t o r s o n R O B D D s a r e i m p l e m e n t e d b y t h e s a m e g e n e r a l

    a l g o r i t h m a p p l y o p ; u

    1

    ; u

    2

    t h a t f o r t w o R O B D D s c o m p u t e s t h e R O B D D f o r t h e B o o l e a n

    e x p r e s s i o n t

    u

    1

    o p t

    u

    2

    . T h e c o n s t r u c t i o n o f a p p l y i s b a s e d o n t h e S h a n n o n e x p a n s i o n 2 :

    t = x ! t 1 = x ; t 0 = x :

    O b s e r v e t h a t f o r a l l B o o l e a n o p e r a t o r s o p t h e f o l l o w i n g h o l d s :

    x ! t

    1

    ; t

    2

    o p x ! t

    0

    1

    ; t

    0

    2

    = x ! t

    1

    o p t

    0

    1

    ; t

    2

    o p t

    0

    2

    4

    I f w e s t a r t f r o m t h e r o o t o f t h e t w o R O B D D s w e c a n c o n s t r u c t t h e R O B D D o f t h e r e s u l t b y

    r e c u r s i v e l y c o n s t r u c t i n g t h e l o w - a n d t h e h i g h - b r a n c h e s a n d t h e n f o r m t h e n e w r o o t f r o m

    t h e s e . A g a i n , t o e n s u r e t h a t t h e r e s u l t i s r e d u c e d , w e c r e a t e t h e n o d e t h r o u g h a c a l l t o

    m k . M o r e o v e r , t o a v o i d a n e x p o n e n t i a l b l o w - u p o f r e c u r s i v e c a l l s , d y n a m i c p r o g r a m m i n g

    i s u s e d . T h e a l g o r i t h m i s s h o w n i n g u r e 1 1 .

    D y n a m i c p r o g r a m m i n g i s i m p l e m e n t e d u s i n g a t a b l e o f r e s u l t s G . E a c h e n t r y i ; j i s

    e i t h e r e m p t y o r c o n t a i n s t h e e a r l i e r c o m p u t e d r e s u l t o f a p p i ; j . T h e a l g o r i t h m d i s t i n -

    g u i s h e s b e t w e e n f o u r d i e r e n t c a s e s , t h e r s t o f t h e m h a n d l e s t h e s i t u a t i o n w h e r e b o t h

    a r g u m e n t s a r e t e r m i n a l n o d e s , t h e r e m a i n i n g t h r e e h a n d l e t h e s i t u a t i o n s w h e r e a t l e a s t

    o n e a r g u m e n t i s a v a r i a b l e n o d e .

    I f b o t h u

    1

    a n d u

    2

    a r e t e r m i n a l , a n e w t e r m i n a l n o d e i s c o m p u t e d h a v i n g t h e v a l u e o f

    o p a p p l i e d t o t h e t w o t r u t h v a l u e s . R e c a l l , t h a t t e r m i n a l n o d e 0 i s r e p r e s e n t e d b y a n o d e

    w i t h i d e n t i t y 0 a n d s i m i l a r l y f o r 1 .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    21/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 2 0

    I f a t l e a s t o n e o f u

    1

    a n d u

    2

    a r e n o n - t e r m i n a l , w e p r o c e e d a c c o r d i n g t o t h e v a r i a b l e

    i n d e x . I f t h e n o d e s h a v e t h e s a m e i n d e x , t h e t w o l o w - b r a n c h e s a r e p a i r e d a n d a p p

    r e c u r s i v e l y c o m p u t e d o n t h e m . S i m i l a r l y f o r t h e h i g h - b r a n c h e s . T h i s c o r r e s p o n d s e x a c t l y

    t o t h e c a s e s h o w n i n e q u a t i o n 4 . I f t h e y h a v e d i e r e n t i n d i c e s , w e p r o c e e d b y p a i r i n g t h e

    n o d e w i t h l o w e s t i n d e x w i t h t h e l o w - a n d h i g h - b r a n c h e s o f t h e o t h e r . T h i s c o r r e s p o n d s

    t o t h e e q u a t i o n

    x

    i

    ! t

    1

    ; t

    2

    o p t = x

    i

    ! t

    1

    o p t ; t

    2

    o p t 5

    w h i c h h o l d s f o r a l l t . S i n c e w e h a v e t a k e n t h e i n d e x o f t h e t e r m i n a l s t o b e o n e l a r g e r

    t h a n t h e i n d e x o f t h e n o n - t e r m i n a l s , t h e l a s t t w o c a s e s , v a r u

    1

    v a r u

    2

    a n d v a r u

    1

    v a r u

    2

    , t a k e a c c o u n t o f t h e s i t u a t i o n s w h e r e o n e o f t h e n o d e s i s a t e r m i n a l .

    F i g u r e 1 2 s h o w s a n e x a m p l e o f a p p l y i n g t h e a l g o r i t h m o n t w o s m a l l R O B D D s . N o t i c e

    h o w p a i r s o f n o d e s f r o m t h e t w o R O B D D s a r e c o m b i n e d a n d c o m p u t e d .

    T o a n a l y z e t h e c o m p l e x i t y o f a p p l y w e l e t j u j d e n o t e t h e n u m b e r o f n o d e s t h a t c a n

    b e r e a c h e d f r o m u i n t h e R O B D D . A s s u m e t h a t G c a n b e i m p l e m e n t e d w i t h c o n s t a n t

    l o o k u p a n d i n s e r t i o n t i m e s . S e e s e c t i o n 5 f o r d e t a i l s o n h o w t o a c h i e v e t h i s . D u e t o

    t h e d y n a m i c p r o g r a m m i n g a t m o s t j u

    1

    j j u

    2

    j c a l l s t o A p p l y a r e g e n e r a t e d . E a c h c a l l t a k e s

    c o n s t a n t t i m e . T h e t o t a l r u n n i n g t i m e i s t h e r e f o r e O j u

    1

    j j u

    2

    j .

    4 . 4 R e s t r i c t

    T h e n e x t o p e r a t i o n w e c o n s i d e r i s t h e r e s t r i c t i o n o f a R O B D D u . T h a t i s , g i v e n a t r u t h

    a s s i g n m e n t , f o r e x a m p l e 0 = x

    3

    ; 1 = x

    5

    ; 1 = x

    6

    , w e w a n t t o c o m p u t e t h e R O B D D f o r t

    u

    u n d e r

    t h i s r e s t r i c t i o n , i . e . , n d t h e R O B D D f o r t

    u

    0 = x

    3

    ; 1 = x

    5

    ; 1 = x

    6

    . A s a n e x a m p l e c o n s i d e r t h e

    R O B D D o f g u r e 1 0 g r e p e a t e d b e l o w t o t h e l e f t r e p r e s e n t i n g t h e B o o l e a n e x p r e s s i o n

    x

    1

    x

    2

    _ x

    3

    . R e s t r i c t i n g i t w i t h r e s p e c t t o t h e t r u t h a s s i g n m e n t 0 = x

    2

    y i e l d s a n

    R O B D D f o r : x

    1

    _ x

    3

    . I t i s c o n s t r u c t e d b y r e p l a c i n g e a c h o c c u r r e n c e o f a n o d e w i t h

    l a b e l x

    2

    b y i t s l e f t b r a n c h y i e l d i n g t h e R O B D D a t t h e r i g h t :

    01

    x1

    x2 x2

    x3

    01

    x1

    x3

    T h e a l g o r i t h m a g a i n u s e s m k t o e n s u r e t h a t t h e r e s u l t i n g O B D D i s r e d u c e d . F i g u r e 1 3

    s h o w s t h e a l g o r i t h m i n t h e c a s e w h e r e o n l y s i n g l e t o n t r u t h a s s i g n m e n t s b = x

    j

    , b 2 f 0 ; 1 g

    a r e a l l o w e d . I n t u i t i v e l y , i n c o m p u t i n g r e s t r i c t u ; j ; b w e s e a r c h f o r a l l n o d e s w i t h

    v a r = j a n d r e p l a c e t h e m b y t h e i r l o w - o r h i g h - s o n d e p e n d i n g o n b . S i n c e t h i s m i g h t

    f o r c e n o d e s a b o v e t h e p o i n t o f r e p l a c e m e n t o b e c o m e e q u a l , i t i s f o l l o w e d b y a r e d u c t i o n

    t h r o u g h t h e c a l l s t o m k . D u e t o t h e t w o r e c u r s i v e c a l l s i n l i n e 3 , t h e a l g o r i t h m h a s a n

    e x p o n e n t i a l r u n n i n g t i m e , s e e e x e r c i s e 4 . 7 f o r a n i m p r o v e m e n t t h a t r e d u c e s t h i s t o l i n e a r

    t i m e .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    22/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 2 1

    x

    1

    x

    2

    x

    3

    x

    4

    x

    5

    2

    0

    0 1

    1

    1 0

    x

    1

    x

    2

    x

    3

    x

    4

    x

    5

    1 , 1 0 , 0 0 , 1 0 , 0

    0 , 0

    1 , 0 0 , 0

    0 , 0

    2 , 2 0 , 2

    3 , 2

    5 , 3

    4 , 0

    2 , 0

    6 , 3

    0 , 3

    0 , 2

    5 , 4

    7 , 4

    0 , 4

    0 , 20 , 1

    8 , 5

    4 , 2

    2 , 2

    3 , 0

    2 , 0 0 , 1 0 , 2

    2

    3

    4

    5

    6

    7

    8

    4

    5

    3

    2

    3 4

    5 6

    7 8

    9

    =

    F i g u r e 1 2 : A n e x a m p l e o f a p p l y i n g t h e a l g o r i t h m a p p l y f o r c o m p u t i n g t h e c o n j u n c t i o n

    o f t h e t w o R O B D D s s h o w n a t t h e t o p l e f t . T h e r e s u l t i s s h o w n t o t h e r i g h t . B e l o w t h e

    t r e e o f a r g u m e n t s t o t h e r e c u r s i v e c a l l s o f a p p . D a s h e d n o d e s i n d i c a t e t h a t t h e v a l u e o f

    t h e n o d e h a s p r e v i o u s l y b e e n c o m p u t e d a n d i s n o t r e c o m p u t e d d u e t o t h e u s e o f d y n a m i c

    p r o g r a m m i n g . T h e s o l i d e l l i p s e s s h o w c a l l s t h a t n i s h e s b y a c a l l t o m k w i t h t h e v a r i a b l e

    i n d e x i n d i c a t e d b y t h e v a r i a b l e s t o t h e r i g h t o f t h e t r e e .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    23/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 2 2

    R e s t r i c t T ; H u ; j ; b =

    1 : f u n c t i o n r e s u =

    2 : i f v a r u j t h e n r e t u r n u

    3 : e l s e i f v a r u j t h e n r e t u r n m k v a r u ; r e s l o w u ; r e s h i g h u

    4 : e l s e * v a r u = j * i f b = 0 t h e n r e t u r n r e s l o w u

    5 : e l s e * v a r u = j ; b = 1 * r e t u r n r e s h i g h u

    6 : e n d r e s

    7 : r e t u r n r e s u

    F i g u r e 1 3 : T h e a l g o r i t h m r e s t r i c t T ; H u ; j ; b w h i c h c o m p u t e s a n R O B D D

    f o r t

    u

    j = b .

    4 . 5 S a t C o u n t , A n y S a t , A l l S a t

    I n t h i s s e c t i o n w e c o n s i d e r o p e r a t i o n s t o e x a m i n e t h e s e t o f s a t i s f y i n g t r u t h a s s i g n m e n t s

    o f a n o d e u . A t r u t h a s s i g n m e n t s a t i s e s a n o d e u i f t

    u

    c a n b e e v a l u a t e d t o 1 u s i n g

    t h e t r u t h t a b l e s o f t h e B o o l e a n o p e r a t o r s . F o r m a l l y , t h e s a t i s f y i n g t r u t h a s s i g n m e n t s i s

    t h e s e t s a t u :

    s a t u = f 2 B

    f x

    1

    ; : : : ; x

    n

    g

    j t

    u

    i s t r u e g ;

    w h e r e B

    f x

    1

    ; : : : ; x

    n

    g

    d e n o t e s t h e s e t o f a l l t r u t h a s s i g n m e n t s f o r v a r i a b l e s f x

    1

    ; : : : ; x

    n

    g , i . e . ,

    f u n c t i o n s f r o m f x

    1

    ; : : : ; x

    n

    g t o t h e t r u t h v a l u e s B = f 0 ; 1 g . T h e r s t a l g o r i t h m , S a t -

    C o u n t , c o m p u t e s t h e s i z e o f s a t u , s e e g u r e 1 4 . T h e a l g o r i t h m e x p l o i t s t h e f o l l o w -

    i n g f a c t . I f u i s a n o d e w i t h v a r i a b l e i n d e x v a r u t h e n t w o s e t s o f t r u t h a s s i g n m e n t s

    c a n m a k e f

    u

    t r u e . T h e r s t s e t h a s v a r u e q u a l t o 0 , t h e o t h e r h a s v a r u e q u a l t o

    1 . F o r t h e r s t s e t , t h e n u m b e r i s f o u n d b y n d i n g t h e n u m b e r o f t r u t h a s s i g n m e n t s

    c o u n t l o w u m a k i n g l o w u t r u e . A l l v a r i a b l e s b e t w e e n v a r u a n d v a r l o w u i n

    t h e o r d e r i n g c a n b e c h o s e n a r b i t r a r i l y , t h e r e f o r e i n t h e c a s e o f v a r u b e i n g 0 , a t o t a l

    o f 2

    v a r l o w u , v a r u , 1

    c o u n t l o w u s a t i s f y i n g t r u t h a s s i g n m e n t s e x i s t s . T o b e e c i e n t ,

    d y n a m i c p r o g r a m m i n g s h o u l d b e a p p l i e d i n S a t C o u n t s e e e x e r c i s e 4 . 1 0 .

    T h e n e x t a l g o r i t h m A n y S a t i n g u r e 1 5 n d s a s a t i s f y i n g t r u t h a s s i g n m e n t . S o m e

    i r r e l e v a n t v a r i a b l e s p r e s e n t i n t h e o r d e r i n g m i g h t n o t a p p e a r i n t h e r e s u l t a n d t h e y c a n

    b e a s s i g n e d a n y v a l u e w h a t s o e v e r . A n y S a t s i m p l y n d s a p a t h l e a d i n g t o 1 b y a d e p t h -

    r s t t r a v e r s a l , p r e f e r i n g s o m e w h a t a r b i t r a r i l y l o w - e d g e s o v e r h i g h - e d g e s . I t i s p a r t i c u l a r l y

    s i m p l e d u e t o t h e o b s e r v a t i o n t h a t i f a n o d e i s n o t t h e t e r m i n a l 0 , i t h a s a t l e a s t o n e p a t h

    l e a d i n g t o 1 . T h e r u n n i n g t i m e i s c l e a r l y l i n e a r i n t h e r e s u l t .

    A l l S a t i n g u r e 1 6 n d s a l l s a t i s f y i n g t r u t h - a s s i g n m e n t s l e a v i n g o u t i r r e l e v a n t v a r i -

    a b l e s f r o m t h e o r d e r i n g . A l l S a t u n d s a l l p a t h s f r o m a n o d e u t o t h e t e r m i n a l 1 . T h e

    r u n n i n g t i m e i s l i n e a r i n t h e s i z e o f t h e r e s u l t m u l t i p l i e d w i t h t h e t i m e t o a d d t h e s i n g l e

    a s s i g n m e n t s x

    v a r u

    7! 0 a n d x

    v a r u

    7! 1 i n f r o n t o f a l i s t o f u p t o n e l e m e n t s . H o w e v e r ,

    t h e r e s u l t c a n b e e x p o n e n t i a l l y l a r g e i n j u j , s o t h e r u n n i n g t i m e i s t h e p o o r O 2

    j u j

    n .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    24/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 2 3

    S a t C o u n t T u

    1 : f u n c t i o n c o u n t u

    2 : i f u = 0 t h e n r e s 0

    3 : e l s e i f u = 1 t h e n r e s 1

    4 : e l s e r e s 2

    v a r l o w u , v a r u , 1

    c o u n t l o w u

    + 2

    v a r h i g h u , v a r u , 1

    c o u n t h i g h u

    5 : r e t u r n r e s

    6 : e n d c o u n t

    7 :

    8 : r e t u r n 2

    v a r u , 1

    c o u n t u

    F i g u r e 1 4 : A n a l g o r i t h m f o r d e t e r m i n i n g t h e n u m b e r o f v a l i d t r u t h a s s i g n -

    m e n t s . R e c a l l , t h a t t h e v a r i a b l e i n d e x " v a r o f 0 a n d 1 i n t h e R O B D D r e p r e -

    s e n t a t i o n i s n + 1 w h e n t h e o r d e r i n g c o n t a i n s n v a r i a b l e s n u m b e r e d 1 t h r o u g h

    n . T h i s m e a n s t h a t v a r 0 a n d v a r 1 a l w a y s g i v e s n + 1 .

    A n y S a t u

    1 : i f u = 0 t h e n E r r o r

    2 : e l s e i f u = 1 t h e n r e t u r n

    3 : e l s e i f l o w u = 0 t h e n r e t u r n x

    v a r u

    7! 1 ; A n y S a t h i g h u

    4 : e l s e r e t u r n x

    v a r u

    7! 0 ; A n y S a t l o w u

    F i g u r e 1 5 : A n a l g o r i t h m f o r r e t u r n i n g a s a t i s f y i n g t r u t h - a s s i g n m e n t . T h e

    v a r i a b l e s a r e a s s u m e d t o b e x

    1

    ; : : : ; x

    n

    o r d e r e d i n t h i s w a y .

    A l l S a t u

    1 : i f u = 0 t h e n r e t u r n h i

    2 : e l s e i f u = 1 t h e n r e t u r n h i

    3 : e l s e r e t u r n

    4 : h a d d x

    v a r u

    7! 0 i n f r o n t o f a l l

    5 : t r u t h - a s s i g n m e n t s i n A l l S a t l o w u ;

    6 : a d d x

    v a r u

    7! 1 i n f r o n t o f a l l

    7 : t r u t h - a s s i g n m e n t s i n A l l S a t h i g h u i

    F i g u r e 1 6 : A n a l g o r i t h m w h i c h r e t u r n s a l l s a t i s f y i n g t r u t h - a s s i g n m e n t s . T h e

    v a r i a b l e s a r e a s s u m e d t o b e x

    1

    ; : : : x

    n

    o r d e r e d i n t h i s w a y . W e u s e h i t o

    d e n o t e s e q u e n c e s o f t r u t h a s s i g n m e n t s . I n p a r t i c u l a r , h i i s t h e e m p t y s e q u e n c e

    o f t r u t h a s s i g n m e n t s , a n d h i i s t h e s e q u e n c e c o n s i s t i n g o f t h e s i n g l e e m p t y

    t r u t h a s s i g n m e n t .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    25/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 2 4

    S i m p l i f y d ; u

    1 : f u n c t i o n s i m d ; u

    2 : i f d = 0 t h e n r e t u r n 0

    3 : e l s e i f u 1 t h e n r e t u r n u

    4 : e l s e i f d = 1 t h e n

    5 : r e t u r n m k v a r u ; s i m d ; l o w u ; s i m d ; h i g h u

    6 : e l s e i f v a r d = v a r u t h e n

    7 : i f l o w d = 0 t h e n r e t u r n s i m h i g h d ; h i g h u

    8 : e l s e i f h i g h d = 0 t h e n r e t u r n s i m l o w d ; l o w u

    9 : e l s e r e t u r n m k v a r u ;

    1 0 : s i m l o w d ; l o w u ;

    1 1 : s i m h i g h d ; h i g h u

    1 2 : e l s e i f v a r d v a r u t h e n

    1 3 : r e t u r n m k v a r d ; s i m l o w d ; u ; s i m h i g h d ; u

    1 4 : e l s e

    1 5 : r e t u r n m k v a r u ; s i m d ; l o w u ; s i m d ; h i g h u

    1 6 : e n d s i m

    1 7 :

    1 8 : r e t u r n s i m d ; u

    F i g u r e 1 7 : A n a l g o r i t h m d u e t o C o u d e r t e t a l C B M 8 9 f o r s i m p l i f y i n g a n

    R O B D D b t h a t w e o n l y c a r e a b o u t o n t h e d o m a i n d . D y n a m i c p r o g r a m m i n g

    s h o u l d b e a p p l i e d t o i m p r o v e e c i e n c y e x e r c i s e 4 . 1 2

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    26/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 2 5

    m k i ; u

    0

    ; u

    1

    O 1

    B u i l d t O 2

    n

    A p p l y o p ; u

    1

    ; u

    2

    O j u

    1

    j j u

    2

    j

    R e s t r i c t u ; j ; b O j u j S e e n o t e

    S a t C o u n t u O j u j S e e n o t e

    A n y S a t u O j p j p = A n y S a t u , j p j = O j u j

    A l l S a t u O j r j n r = A l l S a t u , j r j = O 2

    j u j

    S i m p l i f y d ; u O j d j j u j S e e n o t e

    N o t e : T h e s e r u n n i n g t i m e s o n l y h o l d s i f d y n a m i c p r o g r a m m i n g i s

    u s e d e x e r c i s e s 4 . 7 , 4 . 1 0 , a n d 4 . 1 2 .

    T a b l e 1 : W o r s t - c a s e r u n n i n g t i m e s f o r t h e R O B D D o p e r a t i o n s . T h e r u n n i n g t i m e s a r e t h e

    e x p e c t e d r u n n i n g t i m e s s i n c e t h e y a r e a l l b a s e d o n a h a s h - t a b l e w i t h e x p e c t e d c o n s t a n t

    t i m e s e a r c h a n d i n s e r t i o n o p e r a t i o n s .

    4 . 6 S i m p l i f y

    T h e n a l a l g o r i t h m c a l l e d S i m p l i f y i s s h o w n i n g u r e 1 7 . T h e a l g o r i t h m i s u s e d t o

    s i m p l i f y a n R O B D D b y t r y i n g t o r e m o v e n o d e s . T h e s i m p l i c a t i o n i s b a s e d o n a d o m a i n

    d o f i n t e r e s t . T h e R O B D D u i s s u p p o s e d t o b e o f i n t e r e s t o n l y o n t r u t h a s s i g n m e n t s

    t h a t a l s o s a t i s f y d . T h i s o c c u r s w h e n u s i n g R O B D D s f o r f o r m a l v e r i c a t i o n . S e c t i o n

    7 s h o w s h o w t o d o f o r m a l v e r i c a t i o n w i t h R O B D D s , b u t c o n t a i n s n o e x a m p l e o f u s i n g

    S i m p l i f y .

    T o b e p r e c i s e , g i v e n d a n d u , S i m p l i f y n d s a n o t h e r R O B D D u

    0

    , t y p i c a l l y s m a l l e r

    t h a n u , s u c h t h a t t

    d

    t

    u

    = t

    d

    t

    u

    0

    . I t d o e s s o b y t r y i n g t o i d e n t i f y s o n s , a n d t h e r e b y

    m a k i n g s o m e n o d e s r e d u n d a n t . A m o r e d e t a i l e d a n a l y s i s i s l e f t t o t h e r e a d e r .

    T h e r u n n i n g t i m e o f t h e a l g o r i t h m s o f t h e p r e v i o u s s e c t i o n s i s s u m m a r i z e d i n t a b l e 1 .

    4 . 7 E x i s t e n t i a l Q u a n t i c a t i o n a n d S u b s t i t u t i o n

    W h e n a p p l y i n g R O B D D s o f t e n e x i s t e n t i a l q u a n t i c a t i o n a n d c o m p o s i t i o n i s u s e d . E x -

    i s t e n t i a l q u a n t i c a t i o n i s t h e B o o l e a n o p e r a t i o n 9 x : t . T h e m e a n i n g o f a n e x i s t e n t i a l

    q u a n t i c a t i o n o f a B o o l e a n v a r i a b l e i s g i v e n b y t h e f o l l o w i n g e q u a t i o n :

    9 x : t = t 0 = x _ t 1 = x : 6

    O n R O B D D s e x i s t e n t i a l q u a n t i c a t i o n c a n t h e r e f o r e b e i m p l e m e n t e d u s i n g t w o c a l l s t o

    R e s t r i c t a n d a s i n g l e c a l l t o A p p l y .

    C o m p o s i t i o n i s t h e R O B D D o p e r a t i o n p e r f o r m i n g t h e e q u i v a l e n t o f s u b s t i t u t i o n o n

    B o o l e a n e x p r e s s i o n . O f t e n t h e n o t a t i o n t t

    0

    = x i s u s e d t o d e s c r i b e t h e r e s u l t o f s u b s t i t u t i n g

    a l l f r e e o c c u r r e n c e s o f x i n t b y t

    0

    . A n o c c u r r e n c e o f a v a r i a b l e i s f r e e i f i t i s n o t w i t h i n

    t h e s c o p e o f a q u a n t i e r .

    1

    T o p e r f o r m t h i s s u b s t i t u t i o n o n R O B D D s w e o b s e r v e t h e

    1

    S i n c e R O B D D s c o n t a i n n o q u a n t i e r s w e s h a l l n o t b e c o n c e r n e d w i t h t h e p r o b l e m s o f f r e e v a r i a b l e s

    o f t

    0

    b e i n g b o u n d b y q u a n t i e r s o f t .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    27/37

    4 C O N S T R U C T I N G A N D M A N I P U L A T I N G R O B D D S 2 6

    f o l l o w i n g e q u a t i o n , w h i c h h o l d s i f t c o n t a i n s n o q u a n t i e r s :

    t t

    0

    = x = t t

    0

    ! 1 ; 0 = x = t

    0

    ! t 1 = x ; t 0 = x : 7

    S i n c e t

    0

    ! t 1 = x ; t 0 = x = t

    0

    t 1 = x _ : t

    0

    t 0 = x w e c a n c o m p u t e t h i s w i t h t w o

    a p p l i c a t i o n s o f r e s t r i c t a n d t h r e e a p p l i c a t i o n s o f a p p l y w i t h t h e o p e r a t o r s , : ,

    _ . H o w e v e r , b y e s s e n t i a l l y g e n e r a l i z i n g a p p l y t o o p e r a t o r s o p w i t h t h r e e a r g u m e n t s w e

    c a n d o b e t t e r s e e e x e r c i s e 4 . 1 3 .

    E x e r c i s e s

    E x e r c i s e 4 . 1 C o n s t r u c t t h e R O B D D f o r : x

    1

    x

    2

    : x

    3

    w i t h o r d e r i n g x

    1

    x

    2

    x

    3

    u s i n g t h e a l g o r i t h m B u i l d i n g u r e 9 .

    E x e r c i s e 4 . 2 S h o w t h e r e p r e s e n t a t i o n o f t h e R O B D D o f g u r e 6 i n t h e s t y l e o f g u r e 7 .

    E x e r c i s e 4 . 3 S u g g e s t a n i m p r o v e m e n t B u i l d C o n j t o f B u i l d w h i c h g e n e r a t e s o n l y a

    l i n e a r n u m b e r o f c a l l s f o r B o o l e a n e x p r e s s i o n s t t h a t a r e c o n j u n c t i o n s o f v a r i a b l e s a n d

    n e g a t i o n s o f v a r i a b l e s .

    E x e r c i s e 4 . 4 C o n s t r u c t t h e R O B D D s f o r x a n d x y u s i n g w h a t e v e r o r d e r i n g y o u

    w a n t . C o m p u t e t h e d i s j u n c t i o n o f t h e t w o R O B D D s u s i n g a p p l y .

    E x e r c i s e 4 . 5 C o n s t r u c t t h e R O B D D s f o r : x

    1

    x

    3

    a n d x

    2

    x

    3

    u s i n g b u i l d w i t h t h e

    o r d e r i n g x

    1

    x

    2

    x

    3

    . U s e a p p l y t o n d t h e R O B D D f o r : x

    1

    x

    3

    _ x

    2

    x

    3

    .

    E x e r c i s e 4 . 6 I s t h e r e a n y e s s e n t i a l d i e r e n c e i n r u n n i n g t i m e b e t w e e n n d i n g r e s t r i c t b ; 1 ; 0

    a n d r e s t r i c t b ; n ; 0 w h e n t h e v a r i a b l e o r d e r i n g i s x

    1

    x

    2

    x

    n

    ?

    E x e r c i s e 4 . 7 U s e d y n a m i c p r o g r a m m i n g t o i m p r o v e t h e r u n n i n g t i m e o f R e s t r i c t .

    E x e r c i s e 4 . 8 G e n e r a l i s e r e s t r i c t t o a r b i t r a r y t r u t h a s s i g n m e n t s x

    i

    1

    = b

    i

    1

    , x

    i

    2

    = b

    i

    2

    , : : : , x

    i

    n

    =

    b

    i

    n

    . I t m i g h t b e c o n v e n i e n t t o a s s u m e t h a t x

    i

    1

    x

    i

    2

    x

    i

    n

    .

    E x e r c i s e 4 . 9 S u g g e s t a s u b s t a n t i a l l y b e t t e r w a y o f b u i l d i n g R O B D D s f o r l a r g e B o o l e a n

    e x p r e s s i o n s t h a n b u i l d .

    E x e r c i s e 4 . 1 0 C h a n g e S a t C o u n t s u c h t h a t d y n a m i c p r o g r a m m i n g i s u s e d . H o w d o e s

    t h i s c h a n g e t h e r u n n i n g t i m e ?

    E x e r c i s e 4 . 1 1 E x p l a i n w h y d y n a m i c p r o g r a m m i n g d o e s n o t h e l p i n i m p r o v i n g t h e r u n -

    n i n g t i m e o f A l l S a t .

    E x e r c i s e 4 . 1 2 I m p r o v e t h e e c i e n c y o f S i m p l i f y w i t h d y n a m i c p r o g r a m m i n g .

    E x e r c i s e 4 . 1 3 W r i t e t h e a l g o r i t h m C o m p o s e u

    1

    ; x ; u

    2

    f o r c o m p u t i n g t h e R O B D D o f

    u

    1

    u

    2

    = x e c i e n t l y a l o n g t h e l i n e s o f a p p l y . F i r s t g e n e r a l i z e a p p l y t o o p e r a t o r s o p

    w i t h t h r e e a r g u m e n t s a s f o r e x a m p l e t h e i f - t h e n - e l s e o p e r a t o r , u t i l i z i n g o n c e a g a i n t h e

    S h a n n o n e x p a n s i o n . T h e n u s e e q u a t i o n 7 t o w r i t e t h e a l g o r i t h m .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    28/37

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    29/37

    6 E X A M P L E S O F P R O B L E M S O L V I N G W I T H R O B D D S 2 8

    g e n e r a l w e c o u l d a s k t h e q u e s t i o n f o r a r b i t r a r y N : I s i t p o s s i b l e t o p l a c e N q u e e n s s a f e l y

    o n a N N c h e s s b o a r d ?

    T o s o l v e t h e p r o b l e m u s i n g R O B D D s w e m u s t e n c o d e i t u s i n g B o o l e a n v a r i a b l e s . W e

    d o t h i s b y i n t r o d u c i n g a v a r i a b l e f o r e a c h p o s i t i o n o n t h e b o a r d . W e n a m e t h e v a r i a b l e s

    a s x

    i j

    ; 1 i ; j N w h e r e i i s t h e r o w a n d j i s t h e c o l u m n . A v a r i a b l e w i l l b e 1 i f a q u e e n

    i s p l a c e d o n t h e c o r r e s p o n d i n g p o s i t i o n .

    1 2 3 4 5 6 7 8

    1

    2

    3

    4

    5

    6

    7

    8

    T h e c a p t u r i n g r u l e s f o r q u e e n s r e q u i r e t h a t n o o t h e r q u e e n c a n b e p o s i t i o n e d o n t h e

    s a m e r o w , c o l u m n , o r a n y o f t h e d i a g o n a l s . T h i s w e c a n e x p r e s s a s B o o l e a n e x p r e s s i o n s :

    F o r a l l i ; j ,

    x

    i j

    1 l N ; l 6= j

    : x

    i l

    x

    i j

    1 k N ; k 6= i

    : x

    k j

    x

    i j

    1 k N ; 1 j + k , i N ; k 6= i

    : x

    k ; j + k , i

    x

    i j

    1 k N ; 1 j + i , k N ; k 6= i

    : x

    k ; j + i , k

    M o r e o v e r , t h e r e m u s t b e a q u e e n i n e a c h r o w : F o r a l l i ,

    x

    i 1

    _ x

    i 2

    _ _ x

    i N

    T a k i n g t h e c o n j u n c t i o n o f a l l t h e a b o v e r e q u i r e m e n t s , w e g e t a p r e d i c a t e S o l

    N

    ~x t r u e a t

    e x a c t l y t h e c o n g u r a t i o n s t h a t a r e s o l u t i o n s t o t h e N q u e e n s p r o b l e m .

    E x e r c i s e 6 . 1 8 Q u e e n s P r o b l e m W r i t e a p r o g r a m t h a t c a n n d a n R O B D D f o r

    S o l

    N

    ~x w h e n g i v e n N a s i n p u t . M a k e a t a b l e o f t h e n u m b e r o f s o l u t i o n s t o t h e N

    q u e e n s p r o b l e m f o r N = 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; : : : W h e n t h e r e i s a s o l u t i o n , g i v e o n e .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    30/37

    6 E X A M P L E S O F P R O B L E M S O L V I N G W I T H R O B D D S 2 9

    _

    x o r

    x o r

    x y

    c

    o

    c

    i

    s

    F i g u r e 1 8 : A f u l l - a d d e r

    6 . 2 C o r r e c t n e s s o f C o m b i n a t i o n a l C i r c u i t s

    A f u l l - a d d e r t a k e s a s a r g u m e n t s t w o b i t s x a n d y a n d a n i n c o m i n g c a r r y b i t c

    i

    . I t

    p r o d u c e s a s o u t p u t a s u m b i t s a n d a n o u t g o i n g c a r r y b i t c

    o

    . T h e r e q u i r e m e n t i s t h a t

    2 c

    o

    + s = x + y + c

    i

    , i n o t h e r w o r d s c

    o

    i s t h e m o s t s i g n i c a n t b i t o f t h e s u m o f x ; y , a n d

    c

    i

    , a n d s t h e l e a s t s i g n i c a n t b i t . T h e r e q u i r e m e n t c a n b e w r i t t e n d o w n a s a t a b l e f o r c

    o

    a n d a t a b l e f o r s i n t e r m s o f v a l u e s o f x ; y , a n d c

    i

    . F r o m s u c h a t a b l e i t i s e a s y t o w r i t e

    d o w n a D N F f o r c

    o

    a n d s .

    A t t h e n o r m a l l e v e l o f a b s t r a c t i o n a c o m b i n a t i o n a l c i r c u i t i s n o t h i n g e l s e t h a n a

    B o o l e a n e x p r e s s i o n . I t c a n b e r e p r e s e n t e d a s a n R O B D D , u s i n g B u i l d t o c o n s t r u c t

    t h e t r i v i a l R O B D D s f o r t h e i n p u t s a n d u s i n g a c a l l t o A p p l y f o r e a c h g a t e .

    E x e r c i s e 6 . 2 F i n d D N F s f o r c

    o

    a n d s . V e r i f y t h a t t h e c i r c u i t i n g u r e 1 8 i m p l e m e n t s a

    o n e b i t f u l l - a d d e r u s i n g t h e R O B D D - p a c k a g e a n d t h e D N F s .

    6 . 3 E q u i v a l e n c e o f C o m b i n a t i o n a l C i r c u i t s

    A s a b o v e w e c a n c o n s t r u c t a n R O B D D f r o m a c o m b i n a t i o n a l c i r c u i t a n d u s e t h e R O B D D s

    t o s h o w p r o p e r t i e s . F o r i n s t a n c e , t h e e q u i v a l e n c e w i t h o t h e r c i r c u i t s .

    E x e r c i s e 6 . 3 V e r i f y t h a t t h e t w o c i r c u i t s i n g u r e 1 9 a r e n o t e q u i v a l e n t u s i n g R O B D D s .

    F i n d a n i n p u t t h a t r e t u r n s d i e r e n t o u t p u t s i n t h e t w o c i r c u i t s .

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    31/37

    6 E X A M P L E S O F P R O B L E M S O L V I N G W I T H R O B D D S 3 0

    :

    :

    :

    _

    x

    1

    x

    2

    y

    2

    y

    1

    b

    x

    1

    y

    1

    x

    2

    y

    2

    a

    n o r

    n o r

    _

    _

    F i g u r e 1 9 : T w o c i r c u i t s u s e d i n e x e r c i s e 6 . 3

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    32/37

  • 8/6/2019 An Introduction to Binary Decision Diagrams by Henrik R. Anderson

    33/37

    7 V E R I F I C A T I O N W I T H R O B D D S 3 2

    T h e t r a n s i t i o n s a r e e n c o d e d b y a s i n g l e p r e d i c a t e o v e r t h e v a l u e o f t h e v a r i a b l e s b e f o r e

    t h e t r a n s i t i o n s t h e p r e - s t a t e a n d t h e v a l u e s a f t e r t h e t r a n s i t i o n t h e p o s t - s t a t e . T h e

    v a r i a b l e s i n t h e p r e - s t a t e a r e t h e t

    i

    ; h

    i

    ; c

    i

    ; 1 i N w h i c h w e s h a l l c o l l e c t i v e l y r e f e r t o a s

    ~x a n d i n t h e p o s t - s t a t e t

    0

    i

    ; h

    0

    i

    ; c

    0

    i

    ; 1 i N , w h i c h w e s h a l l r e f e r t o a s ~x

    0

    . E a c h t r a n s i t i o n

    i s a n a t o m i c a c t i o n t h a t e x c l u d e s a n y o t h e r a c t i o n . T h e r e f o r e i n t h e e n c o d i n g w e s h a l l

    o f t e n h a v e t o s a y t h a t a l o t o f v a r i a b l e s a r e u n c h a n g e d . A s s u m e t h a t S i s a s u b s e t o f t h e

    u n p r i m e d v a r i a b l e s ~x . W e s h a l l u s e a p r e d i c a t e u n c h a n g e d

    S

    o v e r ~ x ; ~ x

    0

    w h i c h e n s u r e s t h a t

    a l l v a r i a b l e s i n S a r e u n c h a n g e d . I t i s d e n e d a s f o l l o w s :

    u n c h a n g e d

    S

    =

    d e f

    x 2 S

    x = x

    0

    :

    I t i s s l i g h t l y m o r e c o n v e n i e n t t o u s e t h e p r e d i c a t e a s s i g n e d

    S

    0

    = u n c h a n g e d

    ~x n S

    0

    w h i c h

    e x p r e s s t h a t e v e r y v a r i a b l e n o t i n S

    0

    i s u n c h a n g e d . W e c a n n o w d e n e P

    i

    , t h e t r a n s i t i o n s

    o f c y c l e r i o v e r t h e v a r i a b l e s ~x ;

    ~

    x

    0

    a s f o l l o w s :

    P

    i

    =

    d e f

    c

    i

    ^ : t

    i

    t

    0

    i

    ^ : c

    0

    i

    h

    0

    i

    a s s i g n e d

    f c

    i

    ; t

    i

    ; h

    i

    g

    _ h

    i

    c

    0

    i m o d N + 1

    ^ : h

    0

    i

    a s s i g n e d

    f c

    i m o d N + 1

    ; h

    i

    g

    T h e s i g n a l l i n g o f t e r m i n a t i o n o f t a s k i , b y c h a n g i n g t

    i

    f r o m 1 t o 0 p e r f o r m e d b y t h e

    e n v i r o n m e n t i s m o d e l e d b y N t r a n s i t i o n s E