Reputation: 47
Suppose DdManager
has four variables: x, y, x', y'
and I have a BDD built by x
and y
.
Now I want to change x
to x'
, y
to y'
, namely, get an identical BDD built by x'
and y'
.
How can I get this using the CUDD package? I encountered this problem when I wanted to implement a model checking algorithm. I want to know how to implement this operation or whether I misunderstand the symbolic model checking algorithm? Thank you very much!
Upvotes: 2
Views: 598
Reputation: 11464
Example of variable substitution using the Cython bindings to CUDD that are included in the package dd
:
from dd import cudd
bdd = cudd.BDD() # instantiate a shared BDD manager
bdd.declare("x", "y", "x'", "y'")
u = bdd.add_expr(r"x \/ y") # create the BDD for the disjunction of x and y
rename = dict(x="x'", y="y'")
v = bdd.let(rename, u) # substitution of x' for x and y' for y
s = bdd.to_expr(v)
print(s) # outputs: "ite(x', TRUE, y')"
# another way to confirm that the result is as expected
v_ = bdd.add_expr(r"x' \/ y'")
assert v == v_
Upvotes: 0
Reputation: 1056
You do this with the function Cudd_bddSwapVariables
. It gets the following parameters:
Cudd_bddNewVar
would return)You will need to allocate and free the arrays yourself.
Upvotes: 3