1

I'm trying to use Cudd_bddIte to implement simple BDDs. The following code works as expected, giving the diagram in the picture (which represents node bdd):

DdNode *v1 = Cudd_bddNewVar(gbm);
Cudd_Ref(v1);

DdNode *v2 = Cudd_bddNewVar(gbm);
Cudd_Ref(v2);

DdNode *v3 = Cudd_bddNewVar(gbm);
Cudd_Ref(v3);

DdNode *tmp1 = Cudd_bddIte(gbm, v1, Cudd_ReadLogicZero(gbm), Cudd_ReadOne(gbm));
Cudd_Ref(tmp1);

DdNode *tmp2 = Cudd_bddIte(gbm, v2, tmp1, Cudd_ReadOne(gbm));
Cudd_Ref(tmp2);
Cudd_RecursiveDeref(gbm,tmp1);

DdNode *bdd = Cudd_bddIte(gbm, v3, tmp2, Cudd_ReadOne(gbm));
Cudd_Ref(bdd);
Cudd_RecursiveDeref(gbm,tmp2);

enter image description here

However, if I change the ITE statement for tmp2 to the following

DdNode *tmp2 = Cudd_bddIte(gbm, v2, tmp1, Cudd_ReadLogicZero(gbm));

I get this unexpected graph:

enter image description here

To me, this is wrong, as I would expect the topmost variable still immediately yielding 1 if false, as in the first picture. What am I doing wrong?

0x5C91
  • 3,360
  • 3
  • 31
  • 46

1 Answers1

2

In a (RO)BDD, all variables appear in a certain order. In your case, the order seems to be "v1, v2, v3" as you allocated then in this order and no variable reordering seems to have occurred.

The Cudd_bddIte function does not require that you respect the order when you build the BDD. When you use bddIte function in your code, you make use of this functionality: For building "bdd", you apply the bddIte function to variable v3 using two sub-trees over v1 and v2. However, v3 is at the end of the variable order, so the whole tree gets restructured.

And in fact the second tree that you show has the property that you expect: whenever v3 has a TRUE value, the BDD maps the variable valuation to TRUE. This can be seen from the fact that the only way to reach the "0" sink is via node 0x2e, which is for variable v3, and the "0" sink can only be reached when the then-successor of the node is taken.

DCTLib
  • 1,016
  • 8
  • 22