\section{Metrics}
\label{section:metric}

\begin{definition}[Metric Space]
\label{definition:metric}
    Let $X$ be a set and $d: X \times X \to [0, \infty]$, then $d$ is a \textbf{metric} if:
    \begin{enumerate}
        \item[(PM1)] For any $x \in X$, $d(x, x) = 0$.
        \item[(M)] For any $x, y \in X$ with $x \ne y$, $d(x, y) > 0$.
        \item[(PM2)] For any $x, y \in X$, $d(x, y) = d(y, x)$.
        \item[(PM3)] For any $x, y, z \in X$, $d(x, z) \le d(x, y) + d(y, z)$.
    \end{enumerate}

    The pair $(X, d)$ is a \textbf{metric space}, which comes with the metric uniformity induced by $d$, and the corresponding topology.
\end{definition}

\begin{proposition}
\label{proposition:separable-metric-space}
    Let $(X, d)$ be a metric space, then the following are equivalent:
    \begin{enumerate}
        \item $X$ is second countable. 
        \item $X$ is Lindelöf.
        \item $X$ is separable.
    \end{enumerate}

    In particular, since second countability is hereditary, separability and the Lindelöf property are both hereditary in metric spaces. 
    
\end{proposition}
\begin{proof}
    (1) $\Rightarrow$ (2): Let $\seqi{U} \subset 2^X$ be an open cover of $X$. Let $\seq{V_n} \subset 2^X$ be a countable base for the topology on $X$, and
    \[
    K = \bracs{n \in \natp| \exists i \in I: V_n \subset U_i}
    \]

    For any $x \in X$, there exists $i \in I$ such that $x \in U_i$, and $n \in \natp$ such that $x \in V_n \in U_i$. Therefore $\bigcup_{k \in K}V_k = X$. 

    Let $J \subset I$ be countable such that for each $k \in K$, there exists $j \in J$ with $V_n \subset U_j$, then $X = \bigcup_{k \in K}V_k = \bigcup_{j \in J}V_j$.

    (2) $\Rightarrow$ (3): Let $n \in \nat$, then $\bracs{B(x, 1/n)|x \in X}$ is an open cover of $X$, so there exists $\seq{x_{n, k}} \subset X$ such that $X = \bigcup_{k \in \natp}B(x_k, 1/n)$. Let $D = \bracs{x_{n, k}| n, k \in \natp}$, then for any $x \in X$ and $n \in \natp$, there exists $k \in \natp$ such that $x \in B(x_{n, k}, 1/n)$, so $x_{n, k} \in B(x, 1/n)$. Therefore $D$ is dense in $X$, and $X$ is separable. 

    (3) $\Rightarrow$ (1): Let $\seq{x_n} \subset X$ be a countable dense subset. Let $x \in X$ and $k \in \natp$, then there exists $x_n \in \natp$ such that $d(x, x_n) < 1/(2k)$. In which case, $x \in B(x_n, 1/(2k)) \subset B(x_n, 1/k)$. Therefore $\bracs{B(x_n, 1/k)|n, k \in \natp}$ forms a countable basis for $X$. 
\end{proof}

\begin{proposition}
\label{proposition:countable-metric}
    Let $\seq{(X_n, d_n)}$ be metrisable spaces, then $\prod_{n \in \natp}X_n$ is also metrisable. 
\end{proposition}
\begin{proof}
    For each $n \in \natp$, let
    \[
    d_n': \braks{\prod_{n \in \natp}X_n}^2 \to [0, \infty] \quad (x, y) \mapsto d_n(\pi_n(x), \pi_n(y))
    \]

    then $d_n'$ is a pseudometric on $X$, and $\bracsn{d_n'}_1^\infty$ induces the product uniformity on $\prod_{n \in \natp}X_n$. By \autoref{theorem:uniform-metrisable}, $\prod_{n \in \natp}X_n$ is also metrisable. 
\end{proof}


\begin{theorem}[Banach's Fixed Point Theorem]
\label{theorem:banach-fixed-point}
    Let $(X, d)$ be a complete metric space and $f: X \to X$. If there exists $C \in (0, 1)$ such that
    \[
    d(f(x), f(y)) \le Cd(x, y) \quad \forall x, y \in X
    \]

    then:
    \begin{enumerate}
        \item There exists a unique $x \in X$ such that $f(x) = x$. 
        \item For any $y \in X$, $\limv{n}f^n(y) = x$. 
    \end{enumerate}
\end{theorem}
\begin{proof}
    Let $x_0 \in X$ be arbitrary, and $x_n = f^n(x_0)$, then for ecah $n \in \natp$,
    \[
    d(x_n, x_{n+1}) \le C d(x_{n-1}, x_n) \le C^n d(x_0, x_1)
    \]

    Thus $\seq{x_n} \subset X$ is Cauchy, and converges to a point $x \in X$. 

    (2): For any $y_0 \in X$, let $y_n = f^n(y_0)$, then $d(x_n, y_n) \to 0$ as $n \to \infty$, so $\limv{n}f^n(y_0) = x$. 

    (1): Since $f$ is Lipschitz continuous, 
    \[
    f(x) = f\braks{\limv{n}f^n(x)} = \limv{n}f^{n+1}(x) = x
    \]
\end{proof}

