This question is a bit long; please bear with me.
I have a data structure with elements like this {x1, x2, x3, x4, x5}:
{0 0 0 0 0, 0 0 0 1 0, 1 1 1 1 0,.....}
They represent all the TRUEs in the truth table. Of course, the 5-bit string elements not present in this set correspond to FALSEs in the truth table. But I don't have the boolean function corresponding to the said set data structure.
I see this question but here all the answers assume the boolean function is given, which is not true.
I need to build a ROBDD and then to ZDD from the given set data structure. Preferably with available python packages like these.
Any advice from experts? I am sure a lot has been done along the line of this.
With the Python package
dd, which can be installed using the package managerpipwithpip install dd, it is possible to convert the set of variable assignments where the Boolean function isTRUEto a binary decision diagram.The following example in Python assumes that the assignments where the function is
TRUEare given as a set of strings.For a faster implementation of BDDs, and for an implementation of ZDDs using the C library CUDD, the Cython module extensions
dd.cuddanddd.cudd_zddcan be installed as following:For this (small) example there is no practical speed difference between the pure Python module
dd.autorefand the Cython moduledd.cudd.The above binary decision diagram (BDD) can be copied to a zero-suppressed binary decision diagram (ZDD) with the following code:
The module
dd.cudd_zddwas added indd == 0.5.6, so the above installation requires downloading the distribution ofdd >= 0.5.6, either from PyPI, or from the GitHub repository.