Introduction
Definition
A set is a collection of things. The things that make up the collection are called elements. We can describe some sets pretty easily with natural, everyday language.
- The set of all even numbers.
- The set of all high school students in Philadelphia.
- The set of all high school students in Philadelphia who play an instrument.
- The set of my pets: Padme, Leia, and Muppet.
More often, we want to use more precise language and notation. This is where math comes in.
Properties
A set is not just a collection. It’s also unordered and free of any repeated elements. By unordered we mean that whether I say “Padme, Leia, and Muppet” or “Muppet, Padme, and Leia,” I’m referring to the same set of pets.
Set Notation
Curly Braces
If we want to list the elements in a set, we can write them out as a comma-separated list enclosed within curly braces $\{\}$. Here are a few examples:
- The ten digits: $\{0,1,2,3,4,5,6,7,8,9\}$
- My pets: $\{$Muppet, Padme, Leia$\}$
- The first five prime numbers: $\{2,3,5,7,11\}$
As we said above, sets are unordered, so $$ \{1,2,3,4\} = \{2,1,3,4\} = \{4,1,3,2\} $$ Similarly, repeated elements don’t “count” in the sense that they don’t change the set, so $$ \{1,1,1,2,2,3,3,3,3,4,4,4\} = \{1,2,3,4\} $$
Ellipses
When describing really large or infinite sets, we can use ellipses to say “on and on like this” so long as the pattern is clear. Here are a few examples:
- The set of all even numbers: $\{\dots, -6,-4,-2,0,2,4,6,\dots\}$
- The set of all positive odd numbers: $\{1,3,5,7,9,\dots\}$
- The set of all positive multiples of 5: $\{0,5,10,15,20,25,\dots\}$
There’s no rule about how many elements you need to list in order to use ellipses, but it’s best to err on the side of caution and use a couple more than needed to convey the pattern.
Naming Sets
We can name sets using letters, just like how we use variables in algebra. So, we might say $A = \{1,2,3\}$. Then we can refer to the set by name rather than listing it’s elements.
Some sets get special names and characters because they come up all the time.
- The set of all integers: $\mathbb{Z} = \{\dots,-3,-2,-1,0,1,2,3,\dots$
- The set of all positive whole numbers (the natural numbers): $\mathbb{N} = \{1,2,3,4,\dots\}$
- The set of all real numbers: $\mathbb{R}$.
- The set of all rational numbers: $\mathbb{Q}$
Set-Builder Notation
Ellipses are a great tool for communicating sets, but they have their limitations. For example,
the pattern in the set $X=\{\dots, 3, 2, 3, 6, 11, 18, 27, 38, 51\dots\}$ might not be obvious. So, we might want to explicitly state what the pattern is. To form this set, I evaluated the quadratic expression $n^2 -2n + 3$ for integer values of $n$. We can capture this with set-builder notation. The basic format is like this:
$$
\{\text{what each element looks like } | \text{ conditions}\}
$$
Here, the vertical bar | stands for the phrase “such that.” Often, the conditions will refer other sets. We use the symbol $\in$ to mean “is in” or “is an element of.”
We can write the set $X$ in set-builder notation as follows: $$ X = \{n^2 - 2n + 3 \ | \ n \in \mathbb{Z}\} $$ We can, and should, translate all of this notation into natural language:
“$X$ is the set of all elements/numbers of the form $n^2 - 2n + 3$, such that $n$ is an integer.”
Every curve, line, or region you’ve ever plotted has been a set of points, most of which can be easily written in set-builder notation in the form
$$\{(x,y) \ | \ \text{conditions}\}$$
For example, the parabola we associate with $y = x^2$ is the plot of the following set of points
$$\{(x,y) \ | \ x\in \mathbb{R}, y = x^2\}$$
Say you wanted to plot just the integer-valued points on the graph. You could specify that easily: $\{(x,y) \ | \ x\in\mathbb{Z}, y = x^2\}$
Example
List the elements of the set
$$ A = \{ (x, y) \ | \ x \in \{1,2\}, y\in\{3,4\} \} $$
$$ \boxed{A = \{(1, 3), (1, 4), (2,3), (2,4) \}} $$
Exercise
List the elements in the set
$$ B = \{ x \ | \ x \in \mathbb{N}, x < 6\} $$
Solution
Exercise
List the elements of the set
$$ C = \{ n \ | \ n \in \mathbb{Z}, n^2 = 9\} $$
Solution
Exercise
List the elements of the set
$$ D = \{ (x, y) \ | \ x \in \{1,2,3\}, y = x^2\} $$
Solution
Cardinality
The cardinality of a set is the number of elements in that set, which can be infinite. We denote the cardinality of the set $X$ with absolute value bars: $|X|$. Here are some examples:
- $|\{1,2,3,4,5\}| = 5$
- $|\{1, 2, 3, \dots, 100\}| = 100$
- This set is the integers 1 through 100.
- $|\{n\in\mathbb{N} : n \leq 20\}| = 20$
- This set is the natural numbers 1 through 20
- $|\{x : x = 3n \text{ for } n \in \mathbb{N} \text{ where } x \lt 20\}| = 6$
- Here we have the set of all numbers $x$ such that $x$ is a multiple of $3$ and is less than 20.
- $\{x : x = 3n \text{ for } n \in \mathbb{N} \text{ where } x \lt 20\} = \{3,6,9,12,15,18\}$
- Here we have the set of all numbers $x$ such that $x$ is a multiple of $3$ and is less than 20.
Many Infinities
We probably all agree that there are infinitely many natural numbers. There’s no greatest or largest number. Still, infinity is a hard concept to grasp. Consider the Infinite Hotel:
The Infinite Hotel at the End of the Universe contains infinitely many rooms, numbered $1, 2, 3, 4, \dots$ Suppose the hotel is a maximum occupancy, that is, every room is occupied. What happens when a new guest arrives?
The hotel manager moves the person in Room 1 to Room 2, the person in Room 2 to Room 3, the person in Room 3 to Room 4, so and and so forth. He never runs out of rooms to move guests to, and now Room 1 is empty.
As it turns out, there’s more than one kind of infinity that we can define.
- We say that a set is countably infinite if we can match up each of its elements with an element of the natural numbers, $\mathbb{N}$.
- We say that a set is uncountably infinite if it is not countably infinite.
Each of the following sets is countable infinite:
- The natural numbers.
- The integers.
- The even integers.
- The odd integers.
- The rational numbers.
Let’s show that each of these is true.
The Empty Set and Sets of Sets
The empty set is a set with no elements. It is written one of two ways: $\{\}$ or $\emptyset$. Its cardinality is zero. But, what is the cardinality of $\{\emptyset\}$ - i.e., the set containing the empty set? It’s $1$!
We can have sets of set of different sizes. For example, $$ A = \{\{1,2\},\{0,5,\{7,11,13\}\},\{9\}\} $$ In this case, $A$ is a set of sets, so $|A| = 3$ because it contains $3$ sets: $\{1,2\}$, $\{0,5,\{7,11,13\}\}$ and $\{9\}.$ Notice, it’s not $8$. It’s like how asking “how many elementary schools are there in Philadelphia?” is not asking “how many students are there in the elementary schools in Philadelphia?”
In the same way, we can say $\{1,2\} \in A$ but $1\notin A$. Or, $\{9\} \in A$ but $9\notin A$.
Example
The cardinality of the set $\{\{1,2\}, \{3,4,5,6,7\}\}$ is $2$ because its elements are sets: $\{1,2\}$ and $\{3,4,5,6,7\}$.
Exercise
Let $A = \{1, \{1,2,3,4\}, \{\}, \{9\}\}$. Compute $|A|$.
Solution
Operations on Sets
Unions and Intersections
The first two operations we’ll define are union ($\cup$) and intersection ($\cap$)
- Union: $A \cup B = \{x : x\in A \text{ or } x \in B\}$
- The union of $A$ and $B$ is the set of all elements that are in either $A$ or in $B$.
- Intersection: $A \cap B = \{x : x\in A \text{ and } x \in B\}$
- The intersection of $A$ and $B$ is the set of all elements that are in both $A$ and $B$
Venn Diagrams
Union

Intersection

Example
- Let $A = \{1,2,3,4,5\}$ and $B = \{2,4,6, 8\}$
- $A \cup B = \{1,2,3,4,5,6,8\}$
- Each of these elements is in either $A$ or $B$.
- $A\cap B = \{2,4\}$
- Each of these elements is in both $A$ and $B$
Example
- Let $A = \{x \in \mathbb{N} : x \leq 20\}$ and $B = \{x \in \mathbb{N} : x \text{ is prime}\}$
- What is $|A\cap B|$?
- $A$ is the set of all natural numbers less than or equal to $20$: $\{0,1,2,\dots, 20\}$
- $B$ is the set of all natural numbers that are prime.
- The intersection of $A$ and $B$ is all natural numbers that are less than or equal to $20$ AND are also prime.
- $A \cap B = \{2, 3, 7, 11, 13, 17, 19\}$
Set Difference
- The set difference, $A\setminus B$ is the set of all elements that are in $A$ but not in $B$.
- $A\setminus B = \{x\in A : x\notin B\}$
- Say we have sets $A = \{1,2,3,4,5\}$ and $B = \{1,3,5,7,9\}$.
- $A\setminus B = \{2,4\}$
- We start with $A$ and take away any elements that are in $B$.
- $B \setminus A = \{7,9\}$
- We start with $B$ and take away any elements that are in $A$.
Complement
- This operation only works if we have a universal set, often denoted $\mathcal{U}$.
- In this case, the complement of $A$ is written $\overline{A}$, where
- $\overline{A} = \mathcal{U} \setminus A$
- Example: Suppose $\mathcal{U} = \{1,2,3,4,5,6,7,8,9\}$ and $A = \{1,3,5,7,9\}$
- $\overline{A} = \{2,4,6,8\}$
- We can think of the complement of a set as all the elements outside the set. But again, this only makes sense if the outside is clearly defined
Exercise
Consider the universal set $\mathcal{U} = \{1,2,3,4,5,6,7,8,9\}$ and the sets $A = \{1,2,3,5,7\}$ and $B = \{1, 4,6,8,9\}$. Compute each of the following:
(a) $A \cup B$
(b) $A \cap B$
(c) $A \setminus B$
(d) $\overline{A}$
Solution
(b) $A \cap B = \{1\}$
(c) $A \setminus B = \{2,3,5,7\}$
(d) $\overline{A} = \{4,6,8,9\}$
Principle of Inclusion-Exclusion (PIE)
Consider the sets $A = \{1,2,3,4,5\}$ and $B = \{2,4,6,8\}$. How do we compute $|A \cup B|$? Notice that we can’t just add $|A| + |B|$ because we’ll double-count the intersection!
$$ | A \cup B | = |A| + |B| - |A \cap B| $$
Example
Suppose there are 30 students in Math 239, 40 students in Chem 103, and 12 students currently taking both. Let’s use sets:
- $M:$ set of students in Math 239
- $|M| = 30$
- $C:$ set of students in Chem 103
- $|C| = 40$.
- And $|M \cap C| = 12$.
How many students are there total?
$$ \begin{aligned} |M \cup C| &= |M| + |C| - |M\cap C| \cr &= 30 + 40 - 12 \cr &= \boxed{58} \end{aligned} $$
Exercise
We polled 80 people on their ice cream preferences. Out of the 80, 50 like vanilla and 70 like chocolate. How many like both flavors?
Solution
Define sets:
- $V:$ People who like vanilla
- $C:$ People who like chocolate
$$ \begin{aligned} |C \cup V| &= |C| + |V| - |C \cap V| \cr 80 &= 50 + 70 - |C \cap V| \cr -40 &= - |C \cap V| \cr |C\cap V| &= 40 \end{aligned} $$
We conclude that $40$ people like both flavors.
Exercise
A group of college students were asked about their TV watching habits. Of those surveyed, 30 students watch The The Office, 23 watch Parks and Rec, and 18 watch Superstore. Additionally, 14 watch The Office and Parks and Rec, 12 watch Parks and Rec and Superstore, and 11 watch The Office and Superstore. There are 7 students who watch all three shows. How many students surveyed watched at least one of the shows?
This is another inclusion-exclusion problem.
Solution
Let’s define our sets:
- $O$: Office watchers
- $P$: Parks and Rec watchers
- $S$: Superstore watchers
- $|O| = 30$
- $|P| = 23$
- $|S| = 18$
- $|O\cap P| = 14$
- $|P\cap S| = 12$
- $|O\cap S| = 11$
- $|O \cap P \cap S| = 7$
Putting it all together:
$$ |O \cup P \cup S| = 30 + 23 + 18 - 14 - 12 - 11 + 7 = 41 $$
So, 41 students watch at least one.
Exercise
We polled 82 students and found that…
- 50 love math
- 30 love physics
- 30 love chemistry
- 15 love math and physics
- 10 love physics and chemistry
- 20 love math and chemistry
- 5 love all three
How many students don’t like any of these subjects?
Solution
$$ \begin{aligned} |M \cup P \cup C| &= |M| + |P| + |C| - |M \cap P| - |M \cap C| - |P \cap C| + |M \cap P \cap C| \cr &= 50 + 30 + 30 - 15 - 10 - 20 + 5 \cr &= 70 \end{aligned} $$
Since 82 were polled in total, there are 12 students who don’t like any of these subjects (82 - 70).
Conclusion
- Most of this material is about the language of mathematics, and sets more specifically
- Make sure you’re comfortable reading set notation, especially set-builder notation
- Draw Venn diagrams to make sense of more complicated set operations when that seems useful
More exercises
Exercise
Consider the sets $A = \{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 \}$ and $B = \{2, 3, 4, 12, 13, 14\}$
Write out each of the following sets:
(a) $A \cup B$
(b) $A \cap B$
(c) $A \cap \overline{B}$
(d) $\overline{A} \cap B$
Solution
(a) $A \cup B = \{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14 \}$
(b) $A \cap B = \{2, 3, 4\}$
(c) $A \cap \overline{B} = \{1,5, 6, 7, 8, 9, 10\}$
(d) $\overline{A} \cap B = \{12, 13, 14\}$
Exercise
In a survey of 50 coffee drinkers, 35 drink their coffee with sugar, 30 drink their coffee with cream, and 20 drink their coffee with cream and sugar. How many people drink their coffee black and unsweetened (as it should be)?
Solution
Events:
- $S$: coffee drinkers who add sugar
- $C$: coffee drinkers who add cream
$$ |C \cup S| = |C| + |S| - |C \cap S| = 35 + 30 - 20 = 45 $$
Since there where 50 coffee drinkers surveyed, we conclude that 5 of them (50 - 45) drink their coffee black and unsweetened.
Exercise
A group of 100 students were surveyed on which genres of movie they’d watched in the last year. Of those surveyed, 40 had seen a science fiction movie, 50 had seen a romantic comedy, and 35 had seen a drama. 25 had seen a science fiction movie and a rom-com, 10 had seen a science fiction move and a drama, and 15 had seen a drama and a rom-com. Only 5 people had seen movies from all three categories. How people didn’t see any movies from those three categories?