% This is lecture no. 3 of MH3100/: Real Analysis I.

\chapter{Countability}%
\label{cha:countability}

\section{Countable \& Uncountable Sets}%
\label{sec:countable_&_uncountable_sets}

It is trivial to compare the cardinality of finite sets, but for sets which appear to be infinite, we must compare their cardinalities in a different manner.
Specifically we see if there is a function that can map elements of one set to the other.

\begin{definition}
	One-to-One \& Onto Functions.
	A function $f\vcentcolon A\mapsto B$ is said to be \textbf{one-to-one} (a.k.a \textbf{injective}) if
	\[
	\forall a_1,a_2\in A\quad f(a_1) = f(a_2) \implies a_1=a_2
	.\]
	The function $f$ is said to be \textbf{onto} (a.k.a \textbf{surjective}) if
	\[
	\forall b\in B,\ \exists a\in A\backepsilon f(a) = b
	.\]
	The funciton $f$ is said to be \textbf{bijective} if it is both \textbf{injective} and \textbf{surjective}.
\end{definition}

\begin{definition}
	Cardinality.
	A set $A$ is said to have the same \textbf{cardinality} as a set $B$ if there is a bijection $f\vcentcolon A\mapsto B$.
	We write $A\sim B$ to mean that $A$ has the same \textbf{cardinality} as $B$.
\end{definition}

Note that the relation $\left\{(A,B)\vcentcolon A\sim B\right\}$ is an equivalence relation.

\begin{definition}
	Finite Set.
	A set $A$ is said to be  \textbf{finite} if there is some $n\in\mathbb{N}$ for which
	\[
	\left\{1,2,3,\dotsc,n\right\}\sim A
	.\]
	Otherwise, the set $A$ is said to be infinite.
\end{definition}

Note that a finite set is always bounded, but a bounded set may not be finite.

\begin{definition}
	Countable \& Uncountable Sets.
	A set $A$ is said to be \textbf{countable} (a.k.a \textbf{countably infinite}) if $\mathbb{N}\sim A$.
	A set $A$ is said to be \textbf{uncountable} if it is infinite and not \textbf{countable}.
\end{definition}

\section{Cardinality of $\mathbb{Q}$ \& $\mathbb{R}$}%
\label{sec:cardinality_of_q_&_r_}

\begin{thrm}
	Countability of $\mathbb{Q}$.
	The set $\mathbb{Q}$ is countable.
\end{thrm}

\begin{proof}
	First, we define the function $f\vcentcolon \mathbb{N}\mapsto\mathbb{Q}^{+}$ recursively as follows:
	\[
	f(1) = 1\quad
	f(n + 1) =
	\begin{cases}
		\frac{p+i}{q-i} & \text{if } f(n) = \frac{p}{q}\notin\mathbb{N}\text{ in the lowest terms},\\
				&\text{where }i = \min\left\{i\in\mathbb{N}\vcentcolon\gcd(p + i, q-i) = 1\right\},\\
		\frac{1}{p+1} & \text{if }f(n) = p\in\mathbb{N}.
	\end{cases}
	\]
	Then $f$ is a bijection.
	Secondly, we define the function $g\vcentcolon\mathbb{N}\mapsto\mathbb{Q}$ as
	\[
	g(n) =
	\begin{cases}
		0 & \text{if } n = 1,\\
		-f(k) & \text{if } n = 2k\text{ for }k\in\mathbb{N},\\
		f(k) & \text{if } n = 2k+1\text{ for }k\in\mathbb{N}.
	\end{cases}
	\]
	Then $g$ is a bijection, which shows that $\mathbb{N}\sim\mathbb{Q}$.
\end{proof}
\begin{thrm}
	Uncountability of $\mathbb{R}$.
	The set $\mathbb{R}$ is uncountable.
\end{thrm}
\begin{proof}
	Let $f\vcentcolon\mathbb{N}\mapsto\mathbb{R}$ be a fixed but arbitrary function.
	For each $n\in\mathbb{N}$, define a closed and bounded interval recursively as follows:
	\[
	I_1 = [f(1) + 1, f(1) + 2]
	.\]
	\[
	I_{n+1} =
	\begin{cases}
		\left[\frac{a+2b}{3},b\right] & \text{if } f(n+1)\leqslant \frac{a+b}{2},\\
		\left[a,\frac{2a+b}{3}\right] & \text{if } f(n+1)> \frac{a+b}{2},
	\end{cases}
	\quad
	\text{where }
	I_n = [a,b]
	.\]
	Then $I_1\supseteq I_2\supseteq \dotsb$ is a nested sequence of nonempty close and bounded intervals satisfying $f(n)\notin I_n$ for each $n\in\mathbb{N}$.
	The Nested Interval Property gives some number $r\in\mathbb{R}$ satisfying
	\[
	\forall n\in\mathbb{N}\quad r\in I_n
	.\]
	Therefore for each $n\in\mathbb{N}$,
	\[
	f(n)\notin I_n\text{ and }r\in I_n\implies f(n)\neq r
	.\]
	This shows that $f$ is not onto.
	Since $f$ is arbitrary, there is not bijection $f\vcentcolon\mathbb{N}\mapsto\mathbb{R}$.
\end{proof}
