How to propagate negation down to literals?

54 views Asked by At

I would like to transform an expression so that all negation operators are propagated down to the literals. So ~(a | b) becomes ~a & ~b. Does anyone have a solution for this?

from pyeda.boolalg.expr import expr

formula = "~(a | b)"
e = expr(formula, simplify=False)
1

There are 1 answers

1
brocla On

There are a pair of methods to switch back and forth between the conjunction and disjunctive normal forms.

.to_dnf()

.to_cnf()

try,

>>> e.to_dnf()
And(~a, ~b)