16. Sets

The concept of set, introduced in the late nineteenth century by Georg Cantor, has had such clarifying power that it occurs everywhere in mathematics. Informally, a set is a collection of items. An example is the set of all integers, which is traditionally denoted $\mathrm{Z}$.

We give a formal specification for sets in 21.1.

16.1.1 Example Any data type determines a set — the set of all data of that type. Thus there is a set of integers, a set of natural numbers, a set of letters of the English alphabet, and so on.

16.1.2 Usage The items which constitute a set are called the elements or members of the set.

16.2 Standard notations

The following notation for sets of numbers will be used throughout the book.

a) $\mathrm{N}$ is the set of all nonnegative integers

b) $\mathrm{N}^{+}$ is the set of all positive integers.

c) $\mathrm{Z}$ is the set of all integers.

d) $\mathrm{Q}$ is the set of all rational numbers.

e) $\mathrm{R}$ is the set of all real numbers.

f) $\mathrm{R}^{+}$ is the set of all nonnegative real numbers.

g) $\mathrm{R}^{++}$ is the set of all positive real numbers.

16.2.1 Usage Most authors adhere to the notation of the preceding table, but some use $\mathrm{N}$ for $\mathrm{N}^{+}$ or $\mathrm{I}$ for $\mathrm{Z}$.

16.3 Definition: “$\in$”

If $x$ is a member of the set $A$, one writes “$x \in A$”; if it is not a member of $A$, “$x \notin A$”.

16.3.1 Example $4\in\mathrm{Z}$, $-5\in\mathrm{Z}$, but $4/3\notin\mathrm{Z}$.

16.4 Sets, types and quantifiers

When using the symbol $\forall$, as in Section 13.1, the type of the variable can be exhibited explicitly with a colon followed by the name of a set, as is done in Pascal and other computer languages. Thus to make it clear that $x$ is an integer, one could write $(\forall x{:}\mathrm{Z})P(x)$.

16.4.1 Worked Exercise Which of these statements is true?

a) $(\forall x{:}\mathrm{Z})x \geq 0$

b) $(\forall x{:}\mathrm{N})x \geq 0$

Answer Part (a) says that every integer is nonnegative. That is false; for example, $-3$ is negative. On the other hand, part (b) is true.

Pages 25–26 of the book (PDF).