Content
3: Sets & more
Countability

Countability

Countability is a fundamental concept in set theory and mathematics that deals with the size and nature of sets. The idea that there are different kinds of infinities can be quite counterintuitive at first. However, understanding these distinctions is crucial. It helps us determine whether a set is finite, countably infinite, or countably infinite, providing insight into concepts like discrete and continuous (after all this course is called discrete mathematics). This understanding significantly influences how we can classify and think about different problems, particularly in computer science.

This chapter is one where you can truly get creative with proofs, and sometimes you have to. That's what makes proofs so rewarding — sometimes it's just about finding that neat idea. It requires a lot of practice to build up intuition and ideas that you can adapt to different cases. But this is what makes it so enjoyable - really, trust us :). Every problem is more or less unique. That's what makes proofs really rewarding - sometimes it's just this neat idea. Oftentimes people think this makes this chapter harder because, after all, there is no recipe to approach every problem. It's just a lot of practice that builds up some intuition and ideas you might be able to use and alter in different cases. But this really makes it super fun. Because every problem is really different. Not unlike the basics of set theory, where proofs always go by showing double-sided inclusion.

Definition 3.42:

  1. Two sets AA and BB are equinumerous, denoted ABA \sim B, if there exists a bijection ABA \to B.
  2. The set BB dominates the set AA, denotes ABA \preccurlyeq B, if ACA \sim C for some subset CBC \subseteq B or, equivalently if there exists an injective function ABA \to B.
  3. A set AA is called countable if ANA \preccurlyeq \mathbb{N}, and uncountable otherwise.

The central aspect of this chapter is to decide whether a given set AA is countable or uncountable. More precisely you need to find an injection/bijection NA\mathbb{N} \to A or find some other way to show that there is none.

Theory

The proofs for the following theorems can be found in the script and won't be recited here.

Lemma 3.15:

  1. The relation \sim is an equivalence relation.
  2. The relation \preccurlyeq is transitive: ABBCACA \preccurlyeq B \land B \preccurlyeq C \Rightarrow A \preccurlyeq C.
  3. ABABA \subseteq B \Rightarrow A \preccurlyeq B.

The first point provides us with major intuition about countability. The proof follows quite immediately from composing two bijections and obtaining a new one. This is a central idea. These properties can be combined with proof-patterns to prove uncountability or countability.

Theorem 3.16: If ABA \preccurlyeq B and BAB \preccurlyeq A, then ABA \sim B.

This is a rather extra theorem. Though, it's sort of intuitive. It somehow captures a notion of antisymmetry (however not in the sense that A=BA = B, but only ABA \sim B). It will probably be rarely or might never be the case in this course that it is easier to show that these two injections exist than that a bijection ABA \to B exists.

Theorem 3.17: A set AA is countable if and only if it is finite or if ANA \sim \mathbb{N}. This implies there is no cardinality level between finite and countably infinite sets.

Important Countable Sets

Theorem 3.18: The set {0,1}\{0, 1\}^*, defined as {ϵ,0,1,00,01,10,11,000,001,}\{\epsilon, 0, 1, 00, 01, 10, 11, 000, 001, \ldots\} of finite binary sequences, is countable.

This is a goto set to prove countability. Finding an injection to {0,1}\{0,1\}^* is often the base of a proof and combining this with Lemma 3.15 (Transitivity), we quickly obtain countability.

Theorem 3.19: The set N×N\mathbb{N} \times \mathbb{N} of ordered pairs of natural numbers is countable.

Corollary 3.20: The Cartesian product A×BA \times B of two countable sets AA and BB is countable, i.e., ANBNA×BNA \preccurlyeq \mathbb{N} \land B \preccurlyeq \mathbb{N} \Rightarrow A \times B \preccurlyeq \mathbb{N}.

Corollary 3.21: The set of rational numbers Q\mathbb{Q} is countable.

Theorem 3.22: Let AA and AiA_i for iNi \in \mathbb{N} be countable sets.

  1. For any nNn \in \mathbb{N}, the set AnA^n of nn-tuples over AA is countable.
  2. The union iNAi\bigcup_{i \in \mathbb{N}} A_i of a countable list A0,A1,A2,A_0, A_1, A_2, \ldots of countable sets is countable.
  3. The set AA^* of finite sequences of elements from AA is countable.

This is another very central theorem and in the case of certain involved set operations, should be considered as a starting point for proving that some complicated set is countable.

Definition 3.43: Let {0,1}\{0, 1\}^\infty denote the set of semi-infinite binary sequences or, equivalently, the set of functions N{0,1}\mathbb{N} \to \{0, 1\}.

Just in case you are wondering: Why are they called semi-infinite? This is because they go on infinitely in one direction. This is often super useful. We can think about functions as infinite

⚠️

There is a major difference between the set of semi-infinite bitstrings {0,1}\{0,1\}^{\infty} and {0,1}\{0,1\}^*.

The set {0,1}\{0,1\}^* represents all finite sequences (or strings) of bits, including the empty string. Each string in {0,1}\{0,1\}^* has a finite length, and the set is countably infinite because we can list all possible finite bitstrings in a sequence.

On the other hand, the set of semi-infinite bitstrings consists of all sequences of bits that extend infinitely in one direction. Each bitstring in this set has an infinite length, and the set is uncountably infinite.

For example we have 0{0,1}0 \in \{0,1\}^* but 0{0,1}0 \notin \{0,1\}^{\infty}. But 000{0,1}000\dots \in \{0,1\}^{\infty} (the semi-infinite string of 00's).

Theorem 3.23: The set {0,1}\{0, 1\}^\infty is uncountable.

This theorem is central and a thought about the uncountability of {0,1}\{0,1\}^{\infty} should be a possible starting point for any uncountability proof.

Computability

Definition 3.44: A function f:N{0,1}f : \mathbb{N} \to \{0,1\} is called computable if there is a program that, for every nNn\in \mathbb{N}, when given nn as input, outputs f(n)f(n).

Corollary 3.24: There are uncomputable functions N{0,1}\mathbb{N} \to \{0,1\}

How to approach problems?

Countable or Uncountable

Determine whether the set you have is countable or uncountable. This requires you to first really understand what's going on in your set. Think about similar examples and similarities to known sets (often finding these similarities will directly lead you to the injection, which you have to find anyway).

Uncountablility Proofs

You can only start once you more or less understand what's going on in your set.

The following pattern is a common pattern and surely cannot be used in every case. However, oftentimes when having an uncountable set, you can find an injection from the set {0,1}\{0,1\}^{\infty}, which is known to be uncountable. You could of course also use something like R\mathbb{R} or [0,1][0,1], which might be easier sometimes. Also, the order below is not fixed and the proofs can look way different than the form below and still be correct. The purpose of these steps below is more to give you a structure of how one could approach problems involving proofs of uncountability.

Let AA be the set you want to prove to be uncountable.

1. Finding the injection

The first and probably most difficult step is to find an injection:

f:{0,1}Af: \{0,1\}^{\infty} \to A

The intuition here is that you somehow have to encode all the information of a bitstring bb in its image f(b)f(b). We want to sort of be able to reconstruct bb from f(b)f(b) uniquely. More formally this is exactly the definition of an injection. Namely, for arbitrary b,b{0,1}b, b' \in \{0,1\}^{\infty} we want to have:

bb    f(b)f(b)b \neq b' \implies f(b) \neq f(b')

This is just the definition of injectivity. You have to carefully think about this when choosing ff, to then later prove that it is indeed the case. In this first step, the most important thing is, that you really precisely write down the definition of your function ff and how it maps the bitstring to elements of AA.

2. Proving that your function is a function

Now that you thought about your function it should be clear to you that you have constructed something that is indeed a function. However you still have to prove or at least write some justification for why the following properties are fulfilled, because this is not obvious in many cases:

  1. Does your function actually map to elements from AA and not something else? You defined your function to be a map from {0,1}\{0,1\}^{\infty} however, is it actually the case that for each b{0,1}b\in \{0,1\}^{\infty}, f(b)Af(b) \in A?

  2. Is your function actually a function? Argue why it is well-defined and totally-defined (definition of a function).

This step can in some cases already be quite demanding, in other cases it can also be quite short.

3. Proving injectivity

This is more or less the central part of your proof. Here you have to show that what you defined is actually injective. To do this, the definition of injectivity is basically everything we have to show. Two common ways are:

  1. Let b,b{0,1}b, b' \in \{0,1\}^{\infty} be arbitrary such that bbb \neq b'. Then we have
bb            f(b)f(b)\begin{aligned} b \neq b' &\overset{\cdot}{\implies} \dots \\ &\overset{\cdot}{\implies} \dots \\ &\overset{\cdot}{\implies} f(b) \neq f(b') \end{aligned}

Therefore, ff is injective.
As you can see, this is just the direct method of proving that ff fulfills the definition.

  1. Let b,b{0,1}b, b' \in \{0,1\}^{\infty} be arbitrary such that f(b)=f(b)f(b) = f(b'). Then we have
f(b)=f(b)            b=b\begin{aligned} f(b) = f(b') &\overset{\cdot}{\implies} \dots \\ &\overset{\cdot}{\implies} \dots \\ &\overset{\cdot}{\implies} b=b' \end{aligned}

Therefore, we have proven indirectly that ff is injective.
As you can see, this is just the contraposition of the definition of the injectivity of ff (see proof pattern of indirect proof).

The difficulty in this step is to provide precise and detailed justifications.

4. Punchline

Now we can actually apply definition 3.42 to obtain {0,1}A\{0,1\}^{\infty} \preceq A. However, it is not immediate how this implies that AA is uncountable, as we need to show that not ANA \preceq \mathbb{N}. There are multiple ways how one could argue this. An easy way is to assume that AA is countable (ANA \preceq \mathbb{N}) and that {0,1}A\{0,1\}^{\infty} \preceq A. Then we obtain with Lemma 3.15 (Transitivity) that {0,1}N\{0,1\}^{\infty} \preceq \mathbb{N}, which is false as proven in lecture via Cantor's diagonalization argument (we obtain a contradiction). Therefore, AA must be uncountable.


See the exercise "This seems odd" for an application of this pattern.

Tricks

Often you can try out some handy tricks when tackling countability exercises. Many students think that you should skip countability problems in the exam, but if you have a good overview over the theorems, lemmas and corollaries, equipped with some techniques, experience and tricks, the idea to some of those problems can get to you pretty fast. Often you can combine those with constructing a specific injection.

The Complement Trick

To prove that a given set AA is uncountable, find an uncountable set BB such that ABA \subseteq B and prove that BAB \setminus A is countable.

Intuitively this corresponds to, instead of directly proving that a set AA is uncountable, proving that it is part of a huge set, in which the complement of AA is very small (countable). Then this means AA is very big, because if it was not BB would not be very big. Translating this into a more formal language:

In the following we prove the validity of this pattern: Assume towards a contradiction that AA is countable. A(BA)A \cup (B \setminus A) is countable by Theorem 3.22. But notice that A(BA)=BA \cup (B \setminus A) = B. Hence we have that BB is countable, a contradiction.

For a simple application of this pattern we prove that [0,1]Q[0,1] \setminus \mathbb{Q} is uncountable. Consider [0,1][0,1] (which we know is uncountable). By definition we have [0,1]Q[0,1][0,1] \setminus \mathbb{Q} \subseteq [0,1]. We have that [0,1]([0,1]Q)=Q[0,1][0,1] \setminus ([0,1] \setminus \mathbb{Q}) = \mathbb{Q} \cap [0,1]. Now we know that Q[0,1]Q\mathbb{Q} \cap [0,1] \subseteq \mathbb{Q} and by Lemma 3.15 (iii) hence Q[0,1]Q\mathbb{Q} \cap [0,1] \preceq \mathbb{Q} and by transitivity of \preceq we have that Q[0,1]N\mathbb{Q} \cap [0,1] \preceq \mathbb{N} which means that Q[0,1]\mathbb{Q} \cap [0,1] is countable. Now we can directly use the complement trick (which you would have to prove in an exam) to conclude that [0,1]Q[0,1] \setminus \mathbb{Q} is uncountable.

If you see a countability problem where a direct proof of uncountability doesn't come to mind, you can think about the complement, at many times this is much easier :)

Fundamental Theorem of Arithmetic

Often when working with natural numbers, one can apply the fundamental theorem of arithmetic (i.e. that every natural number 1\geq 1 can be uniquely factored into a product of prime powers).

For example, one can very easily create an injection f:N×NN,(a,b)2a3bf : \mathbb{N} \times \mathbb{N} \to \mathbb{N}, (a,b) \mapsto 2^a3^b. If we have f((a,b))=f((c,d))f((a,b)) = f((c,d)), then 2a3b=2c3d2^a3^b = 2^c3^d. Since for every number the exponents of primes in the prime factorization are unique we have that (a,b)=(c,d)(a,b) = (c,d) which means that ff is injective.

This can expedite many injection constructions, but can also lead to some problems if applied incorrectly as shown in the following:

One could allege that the following is an injection: f:{0,1}N,bnf : \{0,1\}^\infty \to \mathbb{N}, b \mapsto n where n=ipibin = \prod_{i} {p_i}^{b_i} where where pip_i corresponds to the ii'th prime. Now we could "prove" the same way as above that this is an injection. But this would mean that {0,1}\{0,1\}^\infty is countable which is not the case, right? The issue here is that ipibi\prod_i {p_i}^{b_i} does not necessarily converge. If bi=1b_i = 1 for distinctly infinite iNi \in \mathbb{N} the product will be infinity which is not in N\mathbb{N}, so ff is not a function. Often this can constitute a trap when using the fundamental theorem of arithmetic to construct an injection to N\mathbb{N}.

Exercises

Points in the PlaneDifficulty: 1/5Relevance: 🎓🎓🎓Source:  Tobias Steinbrecher

Prove that the set of all points in the plane with rational coordinates is countable.

This seems oddDifficulty: 2/5Relevance: 🎓🎓🎓🎓Source:  Tobias Steinbrecher

Prove or disprove that the following set is uncountable

A={f{0,1}Nf(k)=0 if k20 } A = \{f \in \{0,1\}^{\mathbb{N}} \mid f(k) = 0 \text{ if $k \equiv_2 0$ }\}
Classy CountingDifficulty: 2/5Relevance: 🎓🎓🎓🎓Source:  Philipp Barski

Prove the following. Let AA be an uncountable set. Let θ\theta be an equivalence relation over AA. Prove that A/θA/\theta or [a]θ[a]_\theta for some aAa \in A are uncountable.