« funbyjohn.com — 6 august 2017
# Set theory basics

In modern mathematics, almost everything (if not everything) is a set. So what is a set? A set is simply a collection of elements
$$A = \{1, 2, 3\}$$
in which no element is repeated. Sets don't have any order, for example the set $\{1, 2\}$ is the same set as $\{2, 1\}$. Sets don't necessarily contain numbers. They can consist of many things, like $S = \{\clubsuit, \diamondsuit, \spadesuit, \heartsuit\}$. Some important sets include:
$$\mathbb{N} = \{1, 2, 3, ...\}$$
which are the natural numbers. Notice the "...", this describes that this set continues infinitely. That is, $\mathbb{N}$ is an infinite set.
$$\mathbb{Z} = \{..., -3, -2, -1, 0, 1, 2, 3, ...\}$$
which are the integers.
$$\mathbb{R}$$
which is the set of all real numbers.
## $\in$ relation

If an element $a$ is in a set $A$, we can write $a \in A$, and we say that $a$ is an element of $A$. For example if $A =\{1, 2, 3\}$, then $1 \in A$.
## $\cup$ operation

This is called the union operation. What it does is zipping two sets together. For example if $A = \{1, 3, 5\}$ and $B = \{2, 4, 6\}$ then $A \cup B = \{1, 2, 3, 4, 5, 6\}$. If two sets contain some of the same elements, that element is only included once, so $\{1, 2\} \cup \{2, 3\} = \{1, 2, 3\}$.
## $\cap$ operation

This is called the intersection operation. It constructs a new set from sets $A$ and $B$ such that only elements that are contained in both sets will be in the new set. For example $\{1, 2, 3\} \cap \{2, 3, 4\} = \{2, 3\}$.
## $\emptyset$ - the empty set

If a set doesn't contain any elements, it is the empty set $\emptyset$. This occurs for example if you take the intersection of two non-intersecting sets. For example $\{1, 3, 5\} \cap \{2, 4, 6\} = \emptyset$.
## $\subseteq$ relation

This is the subset relation. If every element of a set $A$ is contained in another set $B$, then we can write $A \subseteq B$. If it also happens to be the case that every element in $B$ is contained in $A$, then $B \subseteq A$, and therefore $A = B$. For example if $E$ is the set of all even numbers, and $A = \{2, 6, 10, 20, 22\}$, then $A \subseteq E$, since every number in $A$ is an even number. A property of the empty set $\emptyset$, is that it's always true that $\emptyset \subseteq A$, for any set $A$.
## Set difference

Written $A - B$ or $A \setminus B$, is the elements of $A$ in which every element that also occurs in $B$ is removed. For example $\{1,2,3\}\setminus\{2,3\} = \{1\}$.
## Complement

Let $B \subseteq A$. Then $A \setminus B$ is the complement of $B$, which is the set of all elements of $A$ that are not contained in $B$. For example if $A = \{1, 2, 3, 4\}$ and $B = \{1, 2\}$, then the complement is $A \setminus B = \{3, 4\}$.
## $\times$ operation

The cartesian product $\times$ is a way of constructing ordered tuples, that is an ordered list of elements in which each element is part of a particular set. For example the elements of $\mathbb{N} \times \mathbb{N}$ are written as $(a, b)$ where $a, b \in \mathbb{N}$. If $a$ and $b$ are different elements, then $(a, b)$ and $(b, a)$ are NOT equal.
When you use the cartesian product on the same set multiple times, it can be written as exponentiation, for example:
$$\mathbb{R}^n = \underbrace{\mathbb{R} \times \mathbb{R} \times \dots \times \mathbb{R}}_{n\textrm{ times}}$$
The different sets need not be the same. For example $\mathbb{N} \times \mathbb{R}$ is a set with elements of the form $(n, x)$, where $n \in \mathbb{N}$ and $x \in \mathbb{R}$.
## Set builder notation

It is possible to construct sets in other ways than simply listing its elements. This can be done through the set builder notation:
$$\{x \in \underbrace{X}_{\textrm{parent set}} \,|\, \underbrace{P(x)}_{\textrm{condition that must hold true}}\}$$
Here is an example of constructing the even numbers:
$$\{x \in \mathbb{Z} \,|\, x = 2k \textrm{ for } k \in \mathbb{Z}\} = \{..., -4, -2, 0, 2, 4, ...\}$$
The set builder notation may look different some places, but the core essence is that you give a condition that must be true for the elements of the set, rather than listing the elements.
## Intervals

A subset of $\mathbb{R}$ that lies between two numbers $a$ and $b$ is called an interval. For example:
$$[a, b] = \{x \in \mathbb{R} \, | \, a \leq x \leq b\}$$
There are some different kinds of intervals. Here are the other three:
$$\begin{align}
]a, b[ &= \{x \in \mathbb{R} \, | \, a < x < b\} \\
]a, b] &= \{x \in \mathbb{R} \, | \, a < x \leq b\} \\
[a, b[ &= \{x \in \mathbb{R} \, | \, a \leq x < b\}
\end{align}$$