You are on page 1of 38

Reduce Ordered Binary Decision Diagram

Model checking & Problem solving

Steve Hostettler

Université de Genève

2 novembre 2007

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 1 / 38
Summary

Introduction
Binary Decision Diagrams
ROBDD Example
OBDD & ROBDD : Definition
Operations on ROBDD
Solving problems
Model checking
ROBDD & Petri nets
Conclusion
Q&A

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 2 / 38
Introduction

Reduced Ordered Binary Decision Diagrams provide a compact


representation of Boolean functions solutions space.
ROBDD are based on BDD.
Mostly used in problem solving and model checking.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 3 / 38
Binary Decision Diagrams
Is a DAG which represents both a Boolean expression and its
solutions. Based on the Shannon Expansion theorem :
F (x1, x2, .., xn) = x1.F (x2, .., xn) + x1.F (x2, .., xn)

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 4 / 38
ROBDD Example : Build the BDD

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 5 / 38
ROBDD Example : Factorize nodes

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 6 / 38
ROBDD Example : Factorize nodes

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 7 / 38
ROBDD Example : Factorize nodes

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 8 / 38
ROBDD Example : Remove useless nodes

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 9 / 38
ROBDD Example : Remove useless nodes

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 10 / 38
ROBDD Example : Remove useless nodes

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 11 / 38
ROBDD Example : The result

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 12 / 38
Reduce BDD on the fly

Isomorphic subgraphs are factorized.


Remove node n if low(n) = high(n), i.e left child = right child.
Use an expression hashtable in order to known whether an expression
has been computed already.
Can be built by ROBDD composition.
Complement function can be built in O(1).

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 13 / 38
OBDD : Definition

Let X be a set of boolean variables and < a total order on X .


Let N be the set of nodes in the OBDD.
Ordered Binary Decision diagrams are directed graph with :
I Let L be the set of leafes, l ∈ L is labeled with a boolean value
val(l) ∈ {0, 1}.
I Let NL be the set of non-leafes, nl ∈ NL is labeled with a boolean
variable var (nl) ∈ X .
I ∀ni , ni+1 ∈ N :
ni+1 ∈ {low (ni ), high(ni )} =⇒ (ni+1 is a leaf ∨ var (n) < var (ni+1 ))
An OBDD is acyclic.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 14 / 38
ROBDD : Definition

An OBDD is called reduced (ROBDD) iff :


∀v , w ∈ L, val(v ) = val(w ) =⇒ v = w .
=⇒ Identical leafes are factorized.
∀v ∈ NL, low (v ) 6= high(v )
=⇒ Non-leafs may not have identical children.
∀v , w ∈ NL :
(var (v ) = var (w )∧low (v ) ∼
= low (w )∧high(v ) ∼
= high(w )) =⇒ v = w
=⇒ Nodes may not have isomorphic subgraphs.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 15 / 38
ROBDD (cont’d)

Given a variable ordering, ROBDD are canonical (demonstration by


induction on the size of the variable set) :
f , g : Bn −→ B, f ∼
= g ⇐⇒ ROBDD(f ) ∼ = ROBDD(g ).
Complexity, let K be the number of variables in the ROBDD :
I Best case complexity : O(K ).
I Worst case complexity : O(2K ).
I Test whether a function is constantly true or false in O(1).
Ordering
I Is a NP complete problem.
I Dynamic optimization :
F Reorganized the variable order on the fly.
F Sifting algorithm.
I Heuristics.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 16 / 38
Operations on ROBDD

Shannon expansion theorem (Reloaded).


I F (x) ◦ G (x) = [F (x) ◦ G (x)] + [F (x) ◦ (G (x)].
I Requires the same variable ordering on both operand.
I Closure operations.
I Apply any boolean operator :
F Disjunction.
F Conjonction.
F Exclusion.
F Restriction.
I Variable Quantification
F ∀x, F (x) ⇐⇒ F (x) ∧ F (x).
F ∃x, F (x) ⇐⇒ F (x) ∨ F (x).
I Those operators a very useful for model checking.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 17 / 38
Solving problems
Define the problem as a set of boolean equations.
Build a ROBDD of the equation and then check if there is a solution.
The N-Queens problem : How to put n queens on a standard n x n
chess board ?

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 18 / 38
Solving problems (cont’d)
Let Ci,j be the constraint for the position i,j and Qi,j the presence of
a queen at position i,j :
^ ^
C 1i,j = Qi,j . ¬Qk,j .¬Qk,j+i−k .¬Qk,j+k−i . ¬Qi,l
1≤k≤n,k6=i 1≤l≤n,l6=j
^ _
Ci,j = C 1i,j . ( C 1k,j )
1≤l≤n 1≤k≤n

N Variables Nodes ROBDD size


4 16 216 30
5 25 225 195
.
6 36 236 133
7 49 249 1449
8 64 264 3887
.
Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 19 / 38
Model checking

Problem : state space explosion ! ! !

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 20 / 38
Encoded state machines

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 21 / 38
Encoding states

Code states on 3 bits :


closed.started.warming +
closed.started.warming +
closed.started.warming +
closed.started.warming

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 22 / 38
Encoding transitions

Transitions are encoded with the intersection of the start-state, the


final-state and the alphabet :
τ = closed.closed 0 .started.started 0 .warming .warming 0 +
closed.closed 0 .started.started 0 .warming .warming 0 +
closed.closed 0 .started.started 0 .warming .warming +
closed.closed 0 .started.started 0 .warming .warming 0 +
closed.closed 0 .started.started 0 .warming .warming 0 +
closed.closed 0 .started.started 0 .warming .warming 0 +
closed.closed 0 .started.started 0 .warming .warming 0
The best variable ordering for transitions is :
x1 Old < x1 New < x2 Old < x2 New < · · · < xi Old < yi New <
alpha1 < · · · < alphai .

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 23 / 38
The τ and the τ −1 functions

The τ ( resp. τ −1 )
function is build using
the transition (resp.
reverse transition)
relation.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 24 / 38
CTL

Only need algorithms for EX, EU, EG since :


I AX φ ⇐⇒ ¬EX (¬φ)
I AF φ ⇐⇒ ¬EG (¬φ)
I AG φ ⇐⇒ ¬EF (¬φ)
I EF φ ⇐⇒ E [true ∪ φ]
I A[φ ∪ θ] ⇐⇒ ¬E [¬θ ∪ (¬φ ∧ ¬θ)] ∧ ¬EG (¬θ)

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 25 / 38
EX (φ)

Let F be the set of states satisfying φ :


I S := τ −1 (F)
I Return S

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 26 / 38
E (φUntilθ)

Let F(resp. G) be the set of states satisfying φ (resp. θ) :


I S := G
I N := ∅
I While( N 6= S)
I do
F N := S ;
F S := S ∪ (F ∩ τ −1 (S))
I done
I Return S

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 27 / 38
EG (φ)

Let F be the set of states satisfying φ :


I S := F
I N := ∅
I While( N 6= S)
I do
F N := S ;
F S := S ∩ τ −1 (S)
I done
I Return S

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 28 / 38
EX (¬warming )
Let’s compute the set of states that satisfy EX (¬warming ) :

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 29 / 38
EX (¬warming ) τ −1 ∩ ¬warning

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 30 / 38
EX (¬warming ) The result

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 31 / 38
ROBDD & safe Petri nets

One place, one variable (one hot encoding)


Binary encoding
Safeness can be check on the fly.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 32 / 38
ROBDD for bounded & weighted Petri nets

If the place is k-bounded it can be encoded as log2(k+1)-1.


Implements the transistion as a binary substraction.
Check boundness by checking for overfow.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 33 / 38
Another example

C0 : a = 1 ∧ b = 1 ; C1 : a ≤ 2 ∧ b ≥ 2 ; C2 : a = 3 ∧ b = 2 ; C3 : a ≤ 2

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 34 / 38
Another example cont’d

x1 x10 x0 x00 m a1 a0 b1 b0
0 0 0 1 1 0 1 0 1
0 0 0 1 1 1 1 1 0
0 1 0 0 1 1 0 0 1
0 1 0 0 1 1 1 0 1
0 1 0 1 1 1 0 1 0
0 1 0 1 1 1 1 1 0
1 0 0 1 0 0 1 - -
1 0 0 1 0 0 0 - -
1 0 1 0 0 0 1 - -

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 35 / 38
Parallelism

BDD computation is highly parallelizable..


Several Parallel BDD packages exists for diverse kind of architectures.
Speedup 10x using 16 processors.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 36 / 38
Conclusion

Very powerful for particular classes of problem or model.


Must use heuristics in order to determine a good variable ordering.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 37 / 38
Q&A

Thank you for your attention.

Steve Hostettler (Université de Genève) Reduce Ordered Binary Decision Diagram 2 novembre 2007 38 / 38

You might also like