1

I am using the CUDD library on C for making Binary Decision Diagrams. I was wondering if there is some way to convert a Boolean expression given as a string to a Binary Decision Diagram.

Thank you!

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
ashishbaghudana
  • 389
  • 2
  • 4
  • 13
  • I don't have a direct answer, but you might want to have a look at Sean Weaver's [BDD Visualizer](http://www.cs.uc.edu/~weaversa/BDD_Visualizer.html). – Axel Kemper Jul 10 '15 at 17:45

2 Answers2

1

There are a couple of projects around in which the functionality to parse a string to a BDD is already contained.

For an example, at https://github.com/LTLMoP/slugs/blob/master/src/synthesisContextBasics.cpp, lines 22-64, you can find a simple parser for polish normal form boolean formulas in C++. At assumes that the variables have already been allocated and BDD references for nodes representing the variables are stored in the arrays "variables[..]" and their respective names are stored in "variabeNames[...]" Adapting the general idea to C is relatively simple. The class "BF" in that code is a wrapper for "DdNode*" references.

If you want infix notation, you can always use yacc/lex to build a simple parser that will do that for you.

DCTLib
  • 1,016
  • 8
  • 22
1

Another possibility is to work in Python, using Cython bindings to CUDD:

from dd import cudd

bdd = cudd.BDD()
bdd.declare('a', 'b')
u = bdd.add_expr(r'a /\ ~ b')
expr = bdd.to_expr(u)
print(expr)

As of dd == 0.5.6, wheel files are available from PyPI that include a compiled version of CUDD. So in any Linux environment with Python version that matches that of the wheels, pip install dd will also install dd.cudd, linked to CUDD.

Note: I am an author of the package dd.

0 _
  • 10,524
  • 11
  • 77
  • 109