Lec 09 BDD
Lec 09 BDD
IITB India
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 1
Retro technology
Commentary: SAT solving had become the focus of research by 90s. Many hard problems such as hardware verification naturally encode into SAT problem. There were
several algorithms and implementations. The first break through came in early 90’s.
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 2
Topic 9.1
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 3
First practical SAT solving
Binary Decision Diagram(BDD) is a data structure that enabled the first practical SAT solver.
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 4
Partial evaluation
Let us suppose a partial model m s.t. Vars(F ) ̸⊆ dom(m).
We can assign meaning to m(F ), which we will denote with F |m .
Definition 9.1
Let F be a formula and m = {p1 7→ b1 , ..} be a partial model.
(
F [⊤/xi ] if bi = 1
Let F |xi 7→bi ≜
F [⊥/xi ] if bi = 0.
The partial evaluation F |m be F |p1 7→b1 |p2 7→b2 | . . . after some simplifications.
For short hand, we may write F |p for F |p7→1 and F |¬p for F |p7→0 .
Exercise 9.1
Prove (F |p ∧ p) ∨ (F |¬p ∧ ¬p) ≡ F
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 5
Example : partial evaluation
Example 9.1
Consider F = (p ∨ q) ∧ r
F |p = ((p ∨ q) ∧ r )[⊤/p] = (⊤ ∨ q) ∧ r ≡ ⊤ ∧ r ≡ r
Exercise 9.2
Compute
▶ ((p ∨ q) ∧ r )|¬p
▶ ((p1 ⇔ q1 ) ∧ (p2 ⇔ q2 ))|p1 7→0,p2 7→0
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 6
Decision branch
Due to the theorem in exercise 9.1, the following tree may be viewed as representing F .
F |¬p F |p
q∧r r
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 7
Decision tree
We may further expand F |¬p and F |p until we are left with ⊤ and ⊥ at the leaves. The obtained
tree is called the decision tree for F .
Example 9.3
Consider (p ∨ q) ∧ r
q r
⊥ r ⊥ ⊤
⊥ ⊤
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 8
Binary decision diagram(BDD)
If two nodes represent same formula, we may rewire the incoming edges to only one of the nodes.
Definition 9.2
A BDD is a finite DAG such that
▶ each internal node is labeled with a propositional variable
▶ each internal node has a low (dashed) and a high child (solid)
▶ there are exactly two leaves one is labelled with ⊤ and the other with ⊥
Example 9.4
p
q
The following is a BDD for (p ∨ q) ∧ r r
r
⊥ ⊤
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 9
Topic 9.2
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 10
Optimize BDD representation
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 11
Ordered BDD (OBDD)
Definition 9.3
A BDD is ordered if there is an order < over variables including ⊤ and ⊥ such that for each node
v , v < low (v ) and v < high(v ).
Example 9.5
p
q r
The following BDD is not an ordered BDD
r q
⊥ ⊤
Exercise 9.3
a. Convert the above BDD into a formula
b. Give an ordered BDD of the formula
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 12
Reduced OBDD (ROBDD)
Definition 9.4
A OBDD is reduced if
▶ for any nodes u and v , if var (u) = var (v ), low (u) = low (v ), high(u) = high(v ) then u = v
▶ for each node u, low (u) ̸= high(u)
Example 9.6
OBDD ROBDD
p p
q q
r r
r
⊥ ⊤ ⊥ ⊤
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 13
Converting to ROBDD
Any OBDD can be converted into ROBDD by iteratively applying the following transformations.
1. If there are nodes u and v such that var (u) = var (v ), low (u) = low (v ), high(u) = high(v )
then remove u and connect all the parents of u to v .
2. If there is a node u such that low (u) = high(u) then remove u and connect all the parents of
u to low (u).
Exercise 9.4
Prove that the above iterations terminate.
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 14
Canonical ROBDD
Theorem 9.1
For a function f : B n → B there is unique ROBDD u with ordering p1 < · · · < pn such that u
represents f (p1 , . . . , pn ).
base (n=0): There are only two functions f () = 0 and f () = 1, which are represented by nodes ⊥
and ⊤ respectively.
step: We assume, there are unique ROBDDs for functions with less than equal to n parameters.
Consider a function f : B n+1 → B.
Proof(contd.)
case u0 = u1 :
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 16
Canonical ROBDD (cond.) III
Proof(contd.)
case u0 ̸= u1 :
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 17
Exercise
Exercise 9.5
a. How many nodes are there in a ROBDD of an unsatisfiable formula?
a. How many nodes are there in a ROBDD of a valid formula?
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 18
Satisfiablility via BDD
Benefits of ROBDD
▶ If intermediate ROBDDs are small then the satisfiability check will be efficient.
▶ Cost of computing ROBDDs vs sizes of BDDs
▶ Due to the canonicity property, ROBDD is used as a formula store
▶ Various operations on the ROBDDs are conducive to implementation
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 19
Issues with ROBDD
▶ BDDs are very sensitive to the variable ordering. There are formulas that have exponential
size ROBDDs for some orderings
▶ There is no efficient way to detect good variable orderings
Exercise 9.6
Draw the ROBDD for
(x1 ∧ x2 ) ∨ (x3 ∧ x4 )
with the following ordering on variables x1 < x3 < x2 < x4 .
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 20
Topic 9.3
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 21
Algorithms for BDDs
Next we will present algorithms for BDDs to illustrate the convenience of the data structure.
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 22
Global data structures
store = (Nodes, low , high, var ) := ({⊥, ⊤}, λx.null, λx.null, λx.null)
Commentary: λx.null stands for a map that takes any input and returns null. This notation is borrowed from λ calculus.
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 23
Constructing a BDD node
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 24
Constructing BDDs from a formula
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 25
Conjunction of BDDs
Algorithm 9.3: ConjBDDs(u, v )
Input: ROBDDs u and v with same variable ordering
if u = ⊥ or v = ⊤ then return u;
if u = ⊤ or v = ⊥ then return v ;
u0 := low (u);u1 := high(u);pu := var (u);
v0 := low (v );v1 := high(v );pv := var (v );
if pu = pv then
return MakeNode(pu ,ConjBDDs(u0 , v0 ),ConjBDDs(u1 , v1 ))
if pu < pv then
return MakeNode(pu ,ConjBDDs(u0 , v ),ConjBDDs(u1 , v ))
if pu > pv then
return MakeNode(pu ,ConjBDDs(u, v0 ),ConjBDDs(u, v1 ))
Exercise 9.7
Give an algorithm for computing disjunction of BDDs/not of a BDD.
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 26
Exercise: run ConjBDDs
Exercise 9.8
Consider order of variables p1 < p2 . a. Draw ROBDD for p1 ∧ p2 . Let us call the BDD u.
b. Draw ROBDD for ¬p1 . Let us call the BDD v .
c. Run ConjBDDs(u, v )
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 27
Restriction on a value
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 28
Impact of BDDs
▶ Later other methods were found that are much faster and the fall of BDD was marked by the
following paper,
A. Biere,A. Cimatti,E. Clarke,Y. Zhu,
Symbolic Model Checking without BDDs, TACAS 1999
Commentary: Maybe the methods that dominated the scene depend on the available computing power. The discoveries may have been predetermined. Once we reached
computation power of 90’s, we had BDDs. When we reached the computation power of 2000’s, we had CDCL and deep learning. Maybe when we will add a few more zeros
in our computing power, we may have entirely different methods that will dominate the computing scene.
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 29
Problems with BDDs
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 30
Topic 9.4
Problems
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 31
ROBDDs
Exercise 9.9
Construct ROBDD of the following formula for the order p < q < r < s.
F = (p ∨ (q ⊕ r ) ∨ (p ∨ s))
Let u be the ROBDD node that represents F . Give the output of Restrict(uF , p, b)
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 32
Variable reordering
Exercise 9.10
Let u be an ROBDD with variable ordering p1 < ... < pn . Give an algorithm for transforming u
into a ROBDD with ordering p1 < .. < pi−1 < pi+1 < pi < pi+2 < .. < pn .
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 33
BDD-XOR
Exercise 9.11
Write an algorithm for computing xor of BDDs
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 34
BDD encoding
Exercise 9.12
Consider a and b be 2 bit wide bit-vectors. Write BDD of each of three output bits in bit-vector
addition a + b.
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 35
BDD model counting
Exercise 9.13
a. Give an algorithm for counting models for a given ROBDD.
b. Does this algorithm work for any BDD?
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 36
End of Lecture 9
cbna CS 433 Automated Reasoning 2025 Instructor: Ashutosh Gupta IITB India 37