Sets and Functions

Last modified: 2026-09-28 23:45:45 (PDT)

Remark. Probability and statistics describe events, outcomes, and parameters as sets, and random variables, densities, and measures as functions. This page collects the definitions of sets and functions that the Morrison Lab’s probability and statistics notes build on.

1 Sets

Definition 1 (Set) A set is a collection of distinct objects, called its elements. We write \(a \in A\) when \(a\) is an element of the set \(A\), and \(a \notin A\) when it is not. Two sets are equal when they have exactly the same elements.

Example 1 (Sets of die rolls) The possible results of rolling a six-sided die form the set \(\mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{}\), with \(3 \in \mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{}\) and \(7 \notin \mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{}\). The sets \(\mathopen{}\left\{1, 2, 3\right\}\mathclose{}\) and \(\mathopen{}\left\{3, 2, 1\right\}\mathclose{}\) are equal, because they have the same elements; the order in which the elements are listed does not matter.

Definition 2 (Set-builder notation) For a set \(A\) and a statement \(P(x)\) about an element \(x\), set-builder notation \(\mathopen{}\left\{x \in A : P(x)\right\}\mathclose{}\) denotes the set of elements \(x\) of \(A\) for which \(P(x)\) is true.

Example 2 (Even die rolls in set-builder notation) \(\mathopen{}\left\{x \in \mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{} : x \text{ is even}\right\}\mathclose{} = \mathopen{}\left\{2, 4, 6\right\}\mathclose{}\), and \(\mathopen{}\left\{x \in \mathbb{R}: x > 0\right\}\mathclose{}\) is the set of positive real numbers.

Definition 3 (Subset) A set \(A\) is a subset of a set \(B\), written \(A \subseteq B\), if every element of \(A\) is an element of \(B\).

Example 3 (Even die rolls) The even die rolls form a subset of the possible rolls: \(\mathopen{}\left\{2, 4, 6\right\}\mathclose{} \subseteq \mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{}\), because each of \(2\), \(4\), and \(6\) is a possible roll. The set \(\mathopen{}\left\{2, 4, 7\right\}\mathclose{}\) is not a subset of \(\mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{}\), because \(7\) is not a possible roll.

Theorem 1 (Every set is a subset of itself) For every set \(A\), \(A \subseteq A\).

Proof. Every element of \(A\) is an element of \(A\), which is Definition 3 with \(B = A\).

Definition 4 (Strict subset) A set \(A\) is a strict subset of a set \(B\), written \(A \subsetneq B\), if \(A\) is a subset of \(B\) and \(A \neq B\).

Definition 5 (Superset) A set \(B\) is a superset of a set \(A\), written \(B \supseteq A\), if \(A\) is a subset of \(B\).

Definition 6 (Strict superset) A set \(B\) is a strict superset of a set \(A\), written \(B \supsetneq A\), if \(A\) is a strict subset of \(B\).

Example 4 (Strict subsets and supersets of die rolls) For the even rolls \(A = \mathopen{}\left\{2, 4, 6\right\}\mathclose{}\) and the possible rolls \(B = \mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{}\):

  • \(A \subsetneq B\), because \(A \subseteq B\) (Example 3) and \(1 \in B\) but \(1 \notin A\), so \(A \neq B\);
  • \(B \supseteq A\) and \(B \supsetneq A\), for the same reasons;
  • \(B \subseteq B\), but \(B\) is not a strict subset of itself, because \(B = B\).

Definition 7 (Empty set) The empty set, denoted \(\emptyset\), is the set that has no elements.

Example 5 (Impossible die rolls) No roll of a six-sided die is greater than 6, so \(\mathopen{}\left\{x \in \mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{} : x > 6\right\}\mathclose{} = \emptyset\).

Theorem 2 (There is only one empty set) If \(E_1\) and \(E_2\) are sets with no elements, then \(E_1 = E_2\).

Proof. Neither set has any elements, so every element of \(E_1\) is an element of \(E_2\) and vice versa, vacuously. Sets with the same elements are equal (Definition 1).

Theorem 3 (The empty set is a subset of every set) For every set \(A\), \(\emptyset \subseteq A\).

Proof. By Definition 3, \(\emptyset \subseteq A\) fails only if some element of \(\emptyset\) is not in \(A\). The empty set has no elements, so no such element exists.

2 Combining sets

Definition 8 (Union) The union of sets \(A\) and \(B\), written \(A \cup B\), is the set of elements that are in \(A\), in \(B\), or in both:

\[A \cup B \stackrel{\text{def}}{=}\mathopen{}\left\{x : x \in A \text{ or } x \in B\right\}\mathclose{}\]

More generally, the union of sets \(A_1, A_2, \ldots\), written \(\bigcup_{i} A_i\), is the set of elements that are in at least one \(A_i\).

Definition 9 (Intersection) The intersection of sets \(A\) and \(B\), written \(A \cap B\), is the set of elements that are in both \(A\) and \(B\):

\[A \cap B \stackrel{\text{def}}{=}\mathopen{}\left\{x : x \in A \text{ and } x \in B\right\}\mathclose{}\]

More generally, the intersection of sets \(A_1, A_2, \ldots\), written \(\bigcap_{i} A_i\), is the set of elements that are in every \(A_i\).

Definition 10 (Set difference) The set difference of sets \(A\) and \(B\), written \(A \setminus B\), is the set of elements of \(A\) that are not in \(B\):

\[A \setminus B \stackrel{\text{def}}{=}\mathopen{}\left\{x \in A : x \notin B\right\}\mathclose{}\]

Example 6 (Combining sets of die rolls) Let \(A = \mathopen{}\left\{2, 4, 6\right\}\mathclose{}\) (the even rolls) and \(B = \mathopen{}\left\{1, 2, 3\right\}\mathclose{}\) (the rolls of at most 3). Then:

  • \(A \cup B = \mathopen{}\left\{1, 2, 3, 4, 6\right\}\mathclose{}\), the rolls that are even or at most 3;
  • \(A \cap B = \mathopen{}\left\{2\right\}\mathclose{}\), the only roll that is both;
  • \(A \setminus B = \mathopen{}\left\{4, 6\right\}\mathclose{}\), the even rolls greater than 3;
  • \(\mathopen{}\left\{2, 4, 6\right\}\mathclose{} \cap \mathopen{}\left\{1, 3, 5\right\}\mathclose{} = \emptyset\): no roll is both even and odd.

3 Countable sets

Definition 11 (Countable set) A set is countable if it is finite, or if its elements can be listed as a sequence \(a_1, a_2, a_3, \ldots\) in which every element appears.

Definition 12 (Countably infinite set) A set is countably infinite if it is countable and not finite.

Example 7 (Countable and uncountable sets)  

  • \(\mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{}\) is countable, because it is finite.
  • The non-negative integers \(\mathopen{}\left\{0, 1, 2, \ldots\right\}\mathclose{}\) are countably infinite: the sequence \(0, 1, 2, \ldots\) lists them.
  • The integers are countably infinite too: the sequence \(0, 1, -1, 2, -2, 3, -3, \ldots\) lists every one of them.

Theorem 4 (The unit interval is not countable) The interval \([0, 1]\) is not countable.

4 Functions

Definition 13 (Function) A function \(f\) from a set \(A\) to a set \(B\), written \(f : A \to B\), assigns to each element \(a \in A\) exactly one element \(f(a) \in B\), called the value of \(f\) at \(a\).

Example 8 (Doubling a die roll) The rule \(f(a) = 2a\) defines a function \(f : \mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{} \to \mathbb{R}\), because it assigns exactly one real number to each possible roll; for example, \(f(3) = 6\). A rule that assigned both \(2\) and \(-2\) to the roll \(1\) would not be a function, because a function assigns exactly one value to each element.

Definition 14 (Domain) The domain of a function \(f : A \to B\) is the set \(A\) of elements that \(f\) assigns values to.

Definition 15 (Codomain) The codomain of a function \(f : A \to B\) is the set \(B\) that its values are required to lie in.

Definition 16 (Image) The image of a function \(f : A \to B\) is the set of values that \(f\) actually takes:

\[f(A) \stackrel{\text{def}}{=}\mathopen{}\left\{f(a) : a \in A\right\}\mathclose{}\]

Example 9 (Domain, codomain, and image of the doubled die roll) For the function \(f : \mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{} \to \mathbb{R}\) with \(f(a) = 2a\) from Example 8:

  • the domain is \(\mathopen{}\left\{1, 2, 3, 4, 5, 6\right\}\mathclose{}\);
  • the codomain is \(\mathbb{R}\);
  • the image is \(\mathopen{}\left\{2, 4, 6, 8, 10, 12\right\}\mathclose{}\).

The image is a subset of the codomain, and here a much smaller one: most real numbers, such as \(3\) and \(-1\), are not values of \(f\).

5 Extended non-negative real numbers

Definition 17 (Extended non-negative real numbers) The extended non-negative real numbers, written \([0, \infty]\), are the non-negative real numbers together with an extra element \(\infty\) that is greater than every real number:

\[[0, \infty] \stackrel{\text{def}}{=}[0, \infty) \cup \mathopen{}\left\{\infty\right\}\mathclose{}\]

Addition extends to \([0, \infty]\) by setting \(x + \infty = \infty + x = \infty\) for every \(x \in [0, \infty]\).

Example 10 (Adding with \(\infty\)) In \([0, \infty]\), \(2 + 3 = 5\) as usual, while \(2 + \infty = \infty\) and \(\infty + \infty = \infty\).