★ Countable and uncountable sets [00AN]
- March 12, 2026
Motivation: matching vs counting [00AO]
- March 12, 2026
You are in a large room with thousands of people. Each person is wearing either a red shirt or a blue shirt. You want to know whether there are more people wearing red shirts, more with blue shirts, or an equal number. You have only five minutes and a microphone. What should you do?
There are many outside-the-box answers to this riddle, but one idea that works well is to tell everyone to pair up: if you have a blue shirt, look for someone with a red shirt, and vice versa. Once you have paired up with an opposite-color shirt, sit down. Pretty soon it should be clear whether the people still standing up have blue shirts or red shirts.
Another similar puzzle is the following: you have a bunch of sheep and want to make sure you still have all of your sheep at the end of the day. However, your language has no words for numbers. What should you do?
One idea is to use a bunch of pebbles. As your sheep leave to pasture at the start of the day, place one pebble in a pile for each sheep. When the sheep return, move one pebble from the pile to a different pile for each sheep.
These examples illustrate that in some sense, matching things up is more fundamental than counting.
Motivation: infinite cardinality is weird [00AP]
- March 12, 2026
Previously we considered the function h : \mathbb {N} \to \mathbb {N}, h(n) = 2n; it is not onto. However, if we define 2\mathbb {N} as the set of all even natural numbers, then h : \mathbb {N} \to 2\mathbb {N} defined in the same way is indeed a bijection. This is a bit strange though, because 2\mathbb {N} \subseteq \mathbb {N}, yet there can be a bijection between them, i.e. their elements can be matched up.
Infinity really messes with our intuition! With finite sets, if A \subseteq B and they are not equal, then |A| < |B| and their elements can’t be matched up. But infinite sets don’t work that way. In fact, we have been using the notation |A| for the cardinality of sets, but we don’t even know what that should mean for infinite sets.
However, matching things up is even more fundamental than counting. It’s probably how people started counting in the first place. Let’s see if this can guide us to some ideas about the cardinality of infinite sets.
Countable sets [00AQ]
- March 12, 2026
Definition Matching set cardinalities [00AR]
- March 12, 2026
Let A, B be sets. If there exists a bijection f : A \to B then we say A and B have the same cardinality, and write |A| = |B|.
If there is an injection f : A \to B then we say |A| \leq |B|.
Remark [00AS]
- March 12, 2026
Note that this definition makes sense for finite sets and the intuition we already have for what the cardinality of a finite set is. If there is a bijection between two finite sets, then they definitely have the same (natural number) size; if there is an injection from A to B, then B definitely has to be at least as big as A.
Definition Countable and countably infinite sets [00AT]
- March 12, 2026
A set A is countable if it has the same cardinality as (i.e. can be put into bijection with) a subset of \mathbb {N}. Note that \mathbb {N} is a subset of itself: in particular, we say A is countably infinite if |A| = |\mathbb {N}|.
Remark Finite sets are countable [00AU]
- March 12, 2026
Clearly every finite set is countable, since we can match up the elements of a finite set with, say, some finite prefix of the natural numbers \{0, 1, 2, 3, \dots , n\}.
\begin {array}{ccccccc} A: & a_0 & a_1 & a_2 & a_3 & \dots & a_n \\ & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow \\ \mathbb {N}: & 0 & 1 & 2 & 3 & \dots & n \end {array}Example Shapes are countable [00AW]
- March 12, 2026
The set of shapes \{\triangle , \square , \diamond \} is countable since we can make a bijection to the set \{0,1,2\}: \begin {array}{ccc} \triangle & \square & \diamond \\ \updownarrow & \updownarrow & \updownarrow \\ 0 & 1 & 2 \end {array}
Remark Countably infinite sets [00AV]
- March 12, 2026
For countably infinite sets, the situation looks the same, but there is no endpoint:
\begin {array}{cccccc} A: & a_0 & a_1 & a_2 & a_3 & \dots \\ & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow \\ \mathbb {N}: & 0 & 1 & 2 & 3 & \dots \end {array}We can think of this scenario in several equivalent ways:
A is countable if it has a bijection to (a subset of) \mathbb {N}. (definition)
A is countable if all its elements can be put in a list. (We can always number the elements of a list 0, 1, 2, \dots .)
A is countable if we can write (or imagine) a program that prints the elements of A one after another, in such a way that any given element of A will eventually be printed after some finite amount of time (if we are willing to wait long enough).
Example Even integers are countable [00AX]
- March 12, 2026
The set 2\mathbb {N} of all even natural numbers is countably infinite, since f(n) = 2n is a bijection between \mathbb {N} and 2\mathbb {N}: \begin {array}{cccccc} \mathbb {N}: & 0 & 1 & 2 & 3 & \dots \\ & \updownarrow & \updownarrow & \updownarrow & \updownarrow \\ 2\mathbb {N}: & 0 & 2 & 4 & 6 & \dots \end {array}
Example The integers are countable [00AY]
- March 12, 2026
Is the set of integers \Z countable? At first glance it might seem like it’s not, since it is infinite in two directions and \mathbb {N} is only infinite in one direction. And indeed, if we try to list all the elements of \Z in a naive way, it fails: “First list 0, then all the positive integers, then all the negative integers” is not a valid list, since it would take infinitely long to list all the positive integers and we would never get around to any of the negative integers.
But \Z is countable, which we can show by reordering the elements in a clever way, for example: \begin {array}{ccccccccc} \mathbb {N}: & 0 & 1 & 2 & 3 & 4 & 5 & 6 & \dots \\ & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \\ \Z : & 0 & 1 & -1 & 2 & -2 & 3 & -3 & \dots \end {array} This will eventually get to any integer we want after some finite amount of time, whether positive or negative. We could figure out an explicit formula for a bijection following this pattern, something like f(n) = \begin {cases} -(n/2) & \text {if $n$ is even} \\ (n+1)/2 & \text {if $n$ is odd} \end {cases} but we don’t necessarily need to; just demonstrating the pattern and arguing why it will reach every integer is enough.
Example \N \times \N is countable [00AZ]
- March 12, 2026
Is \mathbb {N} \times \mathbb {N} countable?
The elements of \mathbb {N} \times \mathbb {N} are ordered pairs of two natural numbers, for example, (3,5). We can imagine them in a 2D grid: \begin {array}{cccc} \vdots & & & ⋰ \\ (2,0) & (2,1) & (2,2) & \\ (1,0) & (1,1) & (1,2) & \\ (0,0) & (0,1) & (0,2) & \dots \end {array}
At first it seems like the answer should be no. Each row of the 2D grid is the same size as a complete copy of \mathbb {N}; and we have infinitely many rows! How could infinitely many copies of \mathbb {N} be the same size as \mathbb {N}?
And indeed, if we try listing the elements by row or column it definitely doesn’t work. “First, list all the elements in row 0; then, list all the elements in row 1; then row 2; and so on”—we will spend an infinitely long time just listing elements of the form (0,n) and never even get around to pairs starting with anything other than 0.
However, surprisingly, \mathbb {N} \times \mathbb {N} is countable! Again, we can show this by listing the pairs in a clever order that guarantees we will reach any specific pair in a finite amount of time. The key idea is to list them by diagonals, that is, we list the pairs (x,y) in order of the sum x+y. First we list all the pairs with sum 0 (there’s only one, (0,0)), then all the pairs with sum 1 (there are two of them, (1,0) and (0,1)), then the pairs with sum 2, and so on. We end up with a list that looks like this: \begin {array}{ccccccccc} \mathbb {N}: & 0 & 1 & 2 & 3 & 4 & 5 & 6 & \dots \\ & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \updownarrow & \\ \mathbb {N} \times \mathbb {N}: & (0,0) & (1,0) & (0,1) & (2,0) & (1,1) & (0,2) & (3,0) & \dots \end {array}
\N \times \N \times \N is countable [00HV]
- July 16, 2026
Once we have this idea, we can see that \mathbb {N} \times \mathbb {N} \times \mathbb {N} must also be countable: we can either explicitly list them by “diagonal slices” through the corner of the infinite 3D cube; or we can just observe that we can do the \mathbb {N} \times \mathbb {N} \to \mathbb {N} bijection twice to get a bijection (\mathbb {N} \times \mathbb {N}) \times \mathbb {N} \to \mathbb {N} \times \mathbb {N} \to \mathbb {N}.
Challenge [00HW]
- July 16, 2026
Work out the details of showing that this is valid. For example, we need to know that if f : A \to B is a bijection then we can use it to make a bijection between A \times C and B \times C; we also need to know that chaining two bijections together will give another bijection.
Likewise, \mathbb {N}^4, \mathbb {N}^5, and any finite Cartesian product of \mathbb {N} with itself is also countable.
Uncountable sets [00HX]
- July 16, 2026
Is everything countable? [00HY]
- July 16, 2026
At this point you might wonder if every infinite set is countable. (But if so, why is there a name for it?) In fact, there are some infinite sets that are not countable!
The rationals are countable! [00HZ]
- July 16, 2026
Let’s think about \mathbb {Q}, the set of rational numbers. There are a lot, right? In between any two integers there are infinitely many rational numbers. If you pick two rational numbers that are really close together, there are infinitely many rational numbers between those. No matter how far you zoom in there will always be infinitely many rational numbers in the part of the number line you are looking at! It is like infinitely fuzzy fuzz. Surely there are more rational numbers than there are natural numbers, right?
Wrong! A rational number is just a pair of integers: a numerator and a denominator. The function f : \mathbb {Q} \to \Z \times \Z that sends the rational number p/q to the pair (p,q) is injective: if two rational numbers are not the same, p/q \neq r/s, then certainly the pairs (p,q) and (r,s) are not the same. So |\mathbb {Q}| \leq |\Z \times \Z | = |\mathbb {N}|! If you weren’t weirded out by the fact that |\mathbb {N} \times \mathbb {N}| = |\mathbb {N}| before, you should be now.
Proving a set uncountable [00I0]
- July 16, 2026
Are there any non-countable sets? How would we prove it if there were? Let’s use our superpower:
\begin {align*} &\phantom {\equiv } \neg \mathrm {Countable}(A) \\ &\equiv \neg \exists f:\mathbb {N} \to A .\; \mathrm {Bijective}(f) \\ &\equiv \neg \exists f:\mathbb {N} \to A .\; \mathrm {Injective}(f) \land \mathrm {Surjective}(f) \\ &\equiv \forall f:\mathbb {N} \to A .\; \neg \mathrm {Injective}(f) \lor \neg \mathrm {Surjective}(f) \end {align*}So to prove that a set A is not countable, we must show that for every possible function f from \mathbb {N} to A, either f is not injective or it is not surjective. Note that a function from \mathbb {N} to A is the same as an infinite list of values from the set A. So we have to show that every possible infinite list of A either has repeated elements, or leaves some elements out.
Our first uncountable set [00I1]
- July 16, 2026
Consider the set I of real numbers between 0 (inclusive) and 1 (exclusive). Each such real number can be written as an infinite decimal, 0.d_1 d_2 d_3 d_4 \dots (Note this even works for things with finite decimal expansions because we can stick an infinite number of zeros on the end, like 1/2 = 0.500000000\dots . There is also a finicky issue with some real numbers having multiple representations as infinite decimals, for example, 0.5000000000\dots = 0.4999999999\dots , but we’re not going to worry about this for now. It’s annoying but not too hard to deal with this.)
Now, suppose we have a list of real numbers. It might start something like this: \begin {align*} r_1 &= 0.d_{11}d_{12}d_{13}d_{14}\dots \\ r_2 &= 0.d_{21}d_{22}d_{23}d_{24}\dots \\ r_3 &= 0.d_{31}d_{32}d_{33}d_{34}\dots \\ r_4 &= 0.d_{41}d_{42}d_{43}d_{44}\dots \\ &\vdots \end {align*} Remember that this list represents a function \mathbb {N} \to I. We claim that no matter what this function is, it is not surjective, that is, there is at least one real number in the interval I that gets left out. We’re going to build a real number 0.c_1 c_2 c_3 c_4 \dots by specifying it digit-by-digit.
For the first digit, c_1, pick any digit which is not equal to d_{11}, the first digit of the first number in the list.
For the second digit, c_2, pick any digit which is not equal to d_{22}, the second digit of the second number in the list.
…and so on: for digit c_i pick any digit which is not equal to d_{ii}, the ith digit of the ith number in the list.
We now claim that the resulting number c = 0.c_1c_2c_3c_4\dots is nowhere on the list! It cannot be equal to r_1, because c and r_1 have different first digits. It cannot be equal to r_2, because they differ in their second digits. It cannot be equal to any r_i, because the ith digit of c was chosen in such a way that it is different than the corresponding digit of r_i.
We assumed nothing about our list of real numbers other than the fact that it was a list; we have therefore shown that any list of real numbers in the interval I must necessarily be incomplete. Therefore, it is not possible to create a bijection between \mathbb {N} and I, so the set of real numbers in the interval I is uncountable. (Of course, this means the entire set of real numbers \mathbb {R} is uncountable too.)