Does subclassing from Boolean make sense for ConditionSet and AppliedPredicate?

13 views
Skip to first unread message

Chris Smith

unread,
Oct 16, 2017, 9:23:07 PM10/16/17
to sympy
Can someone comment on whether it makes sense to think of ConditionSet and AppliedPredicate as being instances of Boolean? Or does it make more sense to think, for example, of ConditionSet as a function that returns a Boolean result? In the work that I am doing on Piecewise, Relational and BooleanFunction, it has struck me as odd to have to deal with these in some of the same ways that I would have to deal with And, Or and Not. What features do we gain that are useful by subclassing from Boolean?

Thanks for any insights,
/c

Aaron Meurer

unread,
Oct 18, 2017, 8:01:01 PM10/18/17
to sy...@googlegroups.com
ConditionSet no. Sets are not the same thing as booleans. A set is a
collection of objects. A boolean should be replaceable with true or
false. ConditionSet(x, x > 1, {1, 2, 3}) is the same thing as {2, 3},
which does not make sense as true or false. Sets can be constructed
from booleans and visa versa, but it's cleanest to keep them as
separate types.

AppliedPredicate yes (and it appears that it does), since something
like Q.positive(x) is indeed a boolean that can be used in boolean
contexts.

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 https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/3542cabe-a6b4-4ad2-908d-bd294c468192%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages