17. List notation for sets
There are two common methods for defining sets: list notation, discussed here, and setbuilder notation, discussed in the next chapter.
17.1 Definition: list notation
A set with a small number of members may be denoted by listing them inside curly brackets.
17.1.1 Example The set $\{ 2, 5, 6\}$ contains the numbers 2, 5 and 6 as elements, and no others. So $2\in \{ 2, 5, 6\}$ but $7\notin \{ 2, 5, 6\}$.
17.1.2 Remark
a) In list notation, the order in which the elements are given is irrelevant: $\{ 2, 5, 6\}$ and $\{ 5, 2, 6\}$ are the same set.
b) Repetitions don’t matter, either: $\{ 2, 5, 6\}, \{ 2, 2, 5, 6\}$ and $\{ 2, 5, 5, 5, 6, 6\}$ are all the same set. Note that $\{ 2, 5, 5, 6, 6\}$ has three elements.
17.1.3 Remark The preceding remarks indicate that the symbols $\{ 2, 5, 6\}$ and $\{ 2, 2, 5, 6\}$ are different representations of the same set. We discussed different representations of numbers in Section 10.2. Many mathematical objects have more than one representation.
17.1.4 Exercise How many elements does the set $\{ 1, 1, 2, 2, 3, 1\}$ have? (Answer on page 243.)
17.2 Sets in Mathematica
In Mathematica, an expression such as
{2,2,5,6}
denotes a list rather than a set. (Lists are treated in detail in Chapter 109.) Both order and repetition matter. In particular, {2,2,5,6} is not the same as {2,5,6} and neither are the same as {2,6,5}.
A convenient way to list the first $n$ integers is Table[k,{k,1,n}]. For example, Table[k,{k,1,10}] returns {1,2,3,4,5,6,7,8,9,10}.
17.3 Sets as elements of sets
A consequence of Specification 21.1 is that a set, being a “single entity”, can be an element of another set. Furthermore, if it is, its elements are not necessarily elements of that other set.
17.3.1 Example Let $A =\{\{ 1, 2\},\{ 3\}, 2, 6\}$. It has four elements, two of which are sets.
Observe that $1\in \{ 1, 2\}$ and $\{ 1, 2\} \in A$, but the number 1 is not an element of $A$. The set $\{ 1, 2\}$ is distinct from its elements, so that even though one of its elements is 1, the set $\{ 1, 2\}$ itself is not 1. On the other hand, 2 is an element of $A$ because it is explicitly listed as such.
17.3.2 Exercise Give an example of a set that has $\{ 1, 2\}$ as an element and 2 as an element but which does not have 1 as an element.
Pages 26–27 of the book (PDF).