0

I'm using CUDD library to analyze boolean expressions. After the expression is created, I have to determine if a given variable is present in the given expression. If the expression f = AB + CD where A, B, C, D are boolean variables, I need to find if variable A is present in f's expression.

The CUDD API I have been using, which seemed to work fine for most cases is Cudd_bddVarIsDependent, where it should return 1 if the variable is dependent on the expression, but I now find a case that even if the variable is actually present in the expression, Cudd_bddVarIsDependent returns 0. So apprently, Cudd_bddVarIsDependent is not the way to do this and "dependency" doesn't mean "contains".

Consider the BDD diagram of the expression shown below.

BDD expression

And the BDD of the variable I need to check if it is contained in the above expression is below (variable index 5).variable to search for

int ret = Cudd_bddVarIsDependent(ddMgr, expr, Cudd_Regular(var))

ret is 0, even though the expression contains variable index 5.

Can anyone please let me know if there's already an API to do this, or should I traverse the expression find this out ?

Thanks

susiriss
  • 83
  • 1
  • 5
  • You could check if existentially abstracting the variable out of the BDD yields the same BDD. If that is the case, the BDD does not depend on the variable. – DCTLib Jul 07 '23 at 20:34
  • Apart from that, you can call "Cudd_SupportIndex", which returns an int array with the variable numbers in the support of the BDD. – DCTLib Jul 07 '23 at 20:37
  • Hi @DCTLib , I have already tested support index and it gives the expected results. So I suppose Cudd_SupportIndex is the answer ! I'm not sure why you didn't post that as an answer :) Thanks a lot. – susiriss Jul 09 '23 at 04:30
  • Great that it worked! I didn't post it as an answer because I wasn't sure if it actually solved your problem *and* it solves a slightly different problem, namely getting the list of all variables in a BDD rather than checking if a *given* variable is in the BDD. – DCTLib Jul 10 '23 at 08:20
  • Yes, since I already have the index of the index I'm looking for, it's just an O(1) lookup in the returned array. – susiriss Jul 10 '23 at 17:57

0 Answers0