Removing the UniversalSet

84 views
Skip to first unread message

Harsh Gupta

unread,
May 10, 2014, 2:03:12 PM5/10/14
to sy...@googlegroups.com, Sergey Kirpichev
This comes from the discussions on this PR

We have a class called UniversalSet which is supposed to be *set* which contains all the sets which we can define in Sympy. The problem is that we really don't "know" what our defined Universal Set is. It has been proposed by Sergey that we wipe out the Universal Set class. We can explicitly provide the the known defined universal set when situation asks for it, that set can be complex, real or real*real or anything. I'm +1 to the proposal. I guess this goes with "Explicit is better than Implicit" from the Zen of Python.  At places we are implicitly assuming UniversalSet to Interval(-oo, oo) which is clearly wrong. Then we cannot define operations like PowerSet and cardinality on such sets. We can avoid the problem by leaving PowerSet or cardinality undefined for UniversalSet, but not having an UniversalSet will be a better way to avoid unknown inconsistencies.

I want to know the views of the community on this matter.

Sergey B Kirpichev

unread,
May 10, 2014, 2:35:03 PM5/10/14
to Harsh Gupta, sy...@googlegroups.com
btw, some statistics:
$ fgrep -R UniversalSet sympy/|wc -l
22
$ fgrep -R UniversalSet sympy/ 2>/dev/null|grep -v 'core/sets.py'|grep -v 'core/tests/test_sets.py'|wc -l
8

Aaron Meurer

unread,
May 12, 2014, 1:35:34 AM5/12/14
to sy...@googlegroups.com, Harsh Gupta
I am -1 to remove it. As I explained in the issue, universal set is
analogous to infinity for regular numerical arithmetic. Not all
mathematical operations make sense for it, but there are some that do,
and they are useful to have. Of course, sometimes you do want to
specify your domain. It is similar with numbers: sometimes you want to
specify explicitly that you are working with the reals or the
rationals or whatever. But it is annoying to have to do this all the
time.

We should just fix code that assumes that the reals are the universal set.

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/20140510183503.GB18695%40debian.
> For more options, visit https://groups.google.com/d/optout.

Aaron Meurer

unread,
May 12, 2014, 3:31:53 PM5/12/14
to sy...@googlegroups.com, Harsh Gupta
Another argument for keeping it is that it works nicely with the
assumptions system. In the assumptions system, ~Q.positive means "not
positive", whereas Q.nonpositive means "real and not positive". The
former item means *anything* that is not a positive real number. It
could be a negative number, a complex number, a matrix, a set, etc. In
other words, negation in the assumptions implicitly means universal
complement. Therefore if we want there to be a one-to-one mapping
between assumptions and sets (and I think we do), we need to allow the
universal set, because that is the corresponding set to Q.is_true (or
more simply, S.true).

Aaron Meurer

Kalevi Suominen

unread,
Jun 2, 2014, 1:11:09 AM6/2/14
to sy...@googlegroups.com, gupta....@gmail.com, Aaron Meurer
The correspondence between assumptions and sets may not be
quite straightforward to implement. In the original set theory of
Cantor and Frege any condition (or statement) would define a set.
After Russell remarked that "the set of all sets that do not belong
to themselves" (if it exists) has contradictory properties, all later
axiomatic set theories have restricted the correspondence
between sets and statements in one way or another.

Kalevi Suominen

Richard Fateman

unread,
Jun 8, 2014, 10:08:06 AM6/8/14
to sy...@googlegroups.com, gupta....@gmail.com, asme...@gmail.com
Here are some comments on sets in CAS


I think that if you want to deal with subsets of the real numbers you should look
at the literature from interval arithmetic to see how you can get your
underwear in knots, even with such a simple domain when you add infinity
and NaN.   And then beyond reals (etc) there are sets that include enumerated
types, indexed infinite sets, etc.
RJF

Harsh Gupta

unread,
Jun 27, 2014, 2:33:31 PM6/27/14
to sy...@googlegroups.com, skirp...@gmail.com
MatLab also have something similar to our UniversalSet
Reply all
Reply to author
Forward
0 new messages