1

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)
Leevi L
  • 1,538
  • 2
  • 13
  • 28

1 Answers1

0

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)
brocla
  • 123
  • 6
  • ok, but that's computationally expensive and not the same as propagating negation down to the literals – Leevi L Jan 31 '21 at 18:50