18

8

I have a terribly short question:

Is there a way to define a pure mathematical set?

I tried a bit of googling, but the word "set" has two meanings and the other one (as in setting) as by far more dominant and I couldn't find any reference to mathematical sets in *Mathematica*.

As for the application, I would like to be able to define two sets `A`

, `B`

and test whether the two sets are the same or not, namely have the same elements.

There is no set data structure in Mathematica, but there are functions that treat lists as sets: they sort them and remove duplicates. – Szabolcs – 2012-05-08T12:14:10.490

What happens is sorting is not possible? For example when the set's members are real valued functions? – Dror – 2012-05-08T12:32:35.127

2

Sorting is always possible. Sorting is not by numerical value, but using the

– Szabolcs – 2012-05-08T12:36:57.497`OrderedQ`

function. Two distinct Mathematica expressions will always have a well defined, though possibly surprising ordering based on this built-in comparison function. Please see here.@Dror Infinite sets are represented symbolically e.g.

`Reals`

and it concerns also numbers or solutions of equations. You can of course make some mapping to enumerate functions, but only countable sets of functions (e.g. series of functions), uncountable ones are basically impossible to enumarate. See my answer for more details and some useful links. – Artes – 2012-05-08T23:18:23.757