Simplifying/negating propcalc formula

asked 2022-01-07 19:04:32 +0100

StevenClontz gravatar image

I have some code to generate randomized boolean formulas involving AND, OR, and IMPLIES for use in student assessments:

props = [propcalc.formula(l) for l in "PQRS"]
ops = ["&","|","->"]
for _ in range(3):
    p = props.pop()
    q = props.pop()
statement = props[0]

It's okay, but it has some superfluous parentheses I'd like to simplify. I also would like to compute the denial of these formulas. Is there an easy recipe for this I'm overlooking?

edit retag flag offensive close merge delete