Boolean equation representation

19 views
Skip to first unread message

Dan Sirgey

unread,
Jan 29, 2015, 3:40:44 PM1/29/15
to sy...@googlegroups.com
I'm trying to use the sympy logic module for some operations on boolean equations. My operations need to operate on the equation as given, not in a standard form (the number of functions is important). However, sympy seems to modify the function as it seems fit. Is there any way to operate on equations without modifying them?

As an example:
If I do
$ A, B, C = symbols('A B C')
$ expr = Not(Or(And(A, B), C)
$ print expr
I get: And(Not(C), Or(Not(A), Not(B))) - 5 functions
I want: Not(Or(And(A, B), C) - 3 functions

Thanks,
Dan

Aaron Meurer

unread,
Jan 29, 2015, 4:41:19 PM1/29/15
to sy...@googlegroups.com
Try this in the latest version of SymPy. We got rid of the automatic application of deMorgan's law. It will still automatically remove duplicates, and remove or reduce to True and False when a literal True or False is encountered, however.

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/a8ca0e43-6751-4774-8e16-0334b5026ad3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Sirgey

unread,
Jan 29, 2015, 6:11:30 PM1/29/15
to sy...@googlegroups.com
Ah, thank you. I think the deMorgan's application was the only thing I was running into. The equations should already have the rest of those reductions applied.
Reply all
Reply to author
Forward
0 new messages