convert logical gates to cnf python

596 views Asked by At

i have an object-oriented logical circuit that's created from gate objects (similar to the second example here:

http://www.openbookproject.net/books/pythonds/Introduction/ObjectOrientedProgramminginPythonDefiningClasses.html )

I need to represent the circuit as CNF: for example https://ibb.co/W2Z4M3y

is there any library that can do it? or any other solution?

1

There are 1 answers

2
kinshukdua On

There's two libraries:

Sympy which has a to_cnf function as well as a to_dnf function.

Similiarly there's PyEDA which also has both the to_cnf and to_dnf function.

You should check both the documentations to see which one fits your need.

You can use Pysathq to convert the text to DIMACS CNF format