\chapter{Metric spaces}

\section{Metric space}


The notion of distance is extremely powerful and intuitive; it is the basis of many ideas in analysis such as limits and continuous functions. However, it is possible to generalize these interesting properties to topological spaces; spaces where distance may not be defined, but closeness is represented by neighborhoods. To begin our journey in topology, we first study the basics of \emph{metric spaces}; spaces where we can take distance for granted.


\begin{definition}
A \emph{metric space}is an ordered pair $(X,d)$.
\begin{itemize}
	\item $X$ is a set
	\item $ d : X \times X \to \mathbb{R}^{+} $ is a \emph{distance function} or \emph{metric} that defines the notion of distance.
\end{itemize}
The metric must satisfy the following properties.
\begin{itemize}
	\item $ d(x,y) \in [0,\infty ) $
	\item $ d(x,y)=0 \iff x=y $
	\item $ d(x,y)= d(y,x) $
	\item $ d(x,y) \leq d(x,z) + d(z,y) $
\end{itemize}
\end{definition}

When the metric is apparent, one may denote the metric space $(X,d)$ as just $X$.

This last condition for the distance function is known as \emph{the triangle inequality}; it is an incredibly useful tool in proofs.

Here are some examples to familiarize us with metrics; the first of which is already known to us.

\begin{example}
The \emph{Euclidean metric} is the following metric defined on $\mathbb{R}^n$.
\[d(\mathbf{x},\mathbf{y}) = \sqrt{ \sum^{n}_{i=1} (\mathbf{x}_i - \mathbf{y}_i)^2 } \]
Notice that for $\mathbb{R}$, this is just $d(x,y)=|x-y|$, and higher dimensions are variations of the Pythagorean theorem.
\end{example}

\begin{example}
The \emph{Chebyshev metric} is the following metric defined on $\mathbb{R}^n$.
\[d(\mathbf{x},\mathbf{y})= \max_{i} ( |\mathbf{x}_i-\mathbf{y}_i | )\]
This metric represents the largest difference between two points on an axis. 
\end{example}

\begin{example}
The \emph{taxicab metric} is the following metric defined on $\mathbb{R}^n$.
\[d(\mathbf{x},\mathbf{y})=\sum^{n}_{i=1} |\mathbf{x}_i-\mathbf{y}_i | \]
This metric represents the distance of the smallest path between the points if one could only 'walk' along the axises.
\end{example}

Many definitions of topology will make much more sense once we see how they generalize and relate to metric spaces. Admittedly, topology seems kind of strange without the context of how it was derived.

Furthermore, metric spaces generally follow nicer conditions than a generic topological space.

\section{Topological space induced by a metric space}

We now introduce a useful tool in the analysis of metric spaces; the open ball. Since we can measure distance, we can construct sets with everything within a certain distance of some element. One decision we will have to make is whether or not to include elements that are exactly the specified distance away; this decision will indeed change many properties of these special sets. Open balls are defined not to include elements with exactly the specified distance.
\subsection{Open balls}
\begin{definition}[Open ball]
Let $(X,d)$ be a metric space, $p$be an element in $X$ and $r \in (0,\infty)$ a nonnegative real number. An \emph{open ball centered at $p$ with radius $r$} is a set $B(p,r)$ defined as such.
\[ B(p,r) = \{x \in X : d(x,p) < r \} \]
\end{definition}

It is called a 'ball' because open balls made with the $\mathbb{R}^3$ Euclidean metric happens to look like a ball. As mentioned, the idea is that these sets cover any points strictly closer than $r$ units away. The 'open' part of the name corresponds to the strict inequality $<$ rather than $\leq$, so that the ball doesn't contain the boundary points of the ball. 

It is only because open balls exclude these boundary points that we can prove the following fundamental result.

\begin{proposition}
If $x \in B(p,r)$, then there exists some $B(x,s)$ such that $B(x,s)$ is contained completely in $B(p,r)$. Elements in open balls of $p$ have their own open balls completely contained in that open ball of $p$.
\[ x\in B(p,r) \implies \exists s \in (0,\infty) [ B(x,s) \subseteq B(p,r)  ] \]
\end{proposition}



\begin{theorem}
A metric space $(X,d)$ naturally induces a topological space by the basis $\mathcal{B}_d = \{ B(p,r) \subseteq X : p\in X \land r \in \mathbb{R}^{+} \}$.
\end{theorem}

So all metric spaces induce a topological space, however for which  topological spaces does there exist a metric space that generates said topology? This is the class of \emph{metrizable topological spaces}; topological spaces that can be reformulated as metric spaces.

\begin{proposition}
Let $(X,d)$ be a metric space. The open balls of $(X,d)$ are a basis for a topological space $(X,\mathcal{T})$. The resulting topological space is called the \emph{topological space induced by $(X,d)$}.
\end{proposition}

I may often refer (as an abuse of notation) to the metric space as its induced topological space. 

\begin{definition}
A \emph{metrizable topological space} is a topological space $(X,\mathcal{T})$ such that there exists a metric $d : X\times X \to [0,\infty)$ such thatthe topology induced by $d$ is $\mathcal{T}$.
\end{definition}

Different metrics on the same set can possibly induce the same topology; they are said to be equivalent metrics if they both form the same topology.
-equivalent metrics











\section{Convergence in metric spaces}

\subsection{Convergent sequences}

Though convergence of sequences may be established without a metric space, metric spaces provide a more intuitive definition for convergence.


\begin{definition}[Convergent sequence]
In a metric space $(X,d)$, a \emph{limit} of a sequence is a point $p \in X$ that is arbitrarily close all remaining terms of a sequence. A \emph{convergent sequence} is a sequence with a limit.
\[ (X,d) \]
\[ x_n \to p  \iff \forall \varepsilon \in (0,\infty) [ \exists N \in \mathbb{N} [ n > N \implies d(x_n , p) < \varepsilon  ]  ]\]
\[ x_n \to p  \iff \forall \varepsilon \in (0,\infty) [ \exists N \in \mathbb{N} [ n > N \implies x_n \in B(p,\varepsilon )  ]  ]\]
\end{definition}


Unlike in a general topological space, sequences in metric spaces (and Hausdorff spaces) have unique limits; same sequence converging to x and y means x=y


\begin{proposition}
\[ (X,d) \]
\[x_n \to x \land x_n \to y \implies x = y \]
\end{proposition}

Due to the uniqueness of limits of convergent sequences in Metric spaces, we introduce the following notation for limits.
\[x_n \to x \iff \lim_{n \to \infty} x_n = x\]

The following proposition offers a way to view convergent sequences with open balls.
\begin{proposition}
\[ \lim_{n \to \infty} x_n = p  \iff \forall \varepsilon \in (0,\infty) [ \exists N \in \mathbb{N} [ n > N \implies x_n \in B(p,\varepsilon )  ]  ]\]
\end{proposition}


\begin{proposition}
\[ \exists x_n \subseteq A ( \lim_{n \to \infty} x_n = p  ) \iff p \in \mathrm{cl}(A)\]
\end{proposition}


\subsection{Cauchy sequences}

Imagine we're considering an embedded space not containing its boundary (like $\mathbb{Q}$ in $\mathbb{R}$, an open interval in $\mathbb{R}$, etc.); we can construct sequences that limit towards something outside the space. We can't call them convergent sequences since it requires that the limit be in the space, however we now recognise another (actually more general) class of sequences with 'convergent-like' behaviour.

\begin{definition}[Cauchy sequence]
In a metric space $(X,d)$, a \emph{Cauchy sequence} is a sequence where the absolute difference of terms are eventually bounded by any arbitrary positive number.
\[ (X,d) \]
\[  (x_n)_{n \in \mathbb{N}} \text{ is Cauchy} \iff \forall \varepsilon \in (0,\infty) [ \exists N \in \mathbb{N} [ n,m > N \implies d(x_n , x_m) < \varepsilon  ]  ]\]
\[  (x_n)_{n \in \mathbb{N}} \text{ is Cauchy} \iff \forall \varepsilon \in (0,\infty) [ \exists N \in \mathbb{N} [ n,m > N \implies x_n \in B_{X}(x_m , \varepsilon)   ]  ]\]
\end{definition}


\begin{proposition}
Convergent sequences are Cauchy sequences.
\end{proposition}


\subsection{Complete spaces}


A natural follow up question is whether Cauchy sequences are convergent sequences; in general this is not the case! Though this does occur for $\mathbb{R}^n$ with the Euclidean metric (as real analysis students are aware of), it is not true for any metric space.
Consider the Euclidean metric with $\mathbb{Q}$; the sequence $x_n = \sum^{n}_{k=0} \frac{(-1)^k 4}{2k+1}$ is Cauchy but not convergent since its limit $\pi$ is not in the space $\mathbb{Q}$.


\begin{definition}[Complete space]
A \emph{complete space} is a metric space $(X,d)$ where all Cauchy sequences are convergent.
\end{definition}

The real numbers are sometimes synthetically defined as a totally ordered field with the least upper bound property. From this, one can prove that the Euclidean space $\mathbb{R}$ is complete.

Another equivalent way of constructing the real numbers is by defining them as the completion of $\mathbb{Q}$; in this case $\mathbb{R}$ is complete by definition!



\begin{proposition}
A set $S$ is closed in the induced topology of a metric spaces iff any sequence in $S$ converges to some $p \in S$
\end{proposition}


\subsection{Subsequences}

-subsequence
-bolzano weierstrass therem topology



\section{Continuous function (Metric space)}

%Like limits, a topological space is also sufficient grounds to develop a general definition of a continuous function! To build up intuition, we once again commence our study in the realm of metric spaces.


\begin{definition}
	Let $(X,d_X)$ and $(Y,d_{Y})$ A function $f : X \to Y$ is \emph{continuous at $p \in X$} iff for any $\varepsilon$, there is a $\delta$ such that if $d_X (p,q) < \delta$ then $d_Y ( f(p) , f(q) ) < \varepsilon$.
\end{definition}


Let's try to derive the general topological definition of a continuous function from these insights.

As always, we have to strip away that metric to generalize our definition to topological spaces. We can start by reformulating this definition in terms of open balls, and then generalize to neighborhoods to get the final result.

\begin{proposition}
Let $(X,d_X)$ and $(Y,d_{Y})$ A function $f : X \to Y$ is \emph{continuous at $p \in X$} iff for any $B_{Y}(f(p),\varepsilon)$, there is a $B_{X}(p,\delta)$ such that if $q \in B_{X}(p,\delta)$ then $f(q) \in B_{Y}(f(p),\varepsilon)$.
Equivalently we have that $f(B_{X}(p,\delta) \subseteq B_{Y}(f(p),\varepsilon)$
\end{proposition}

If we try and define globally continuous functions by considering continuity at every point in the metric space, we are lead back to the general topological definition of a continuous function.



Limits can be used to express continuous functions between metric spaces.

\begin{theorem}[Continuous function]
A function $f : X \to Y$ between 2 metric spaces $(X,d_X),(Y,d_Y)$ is continuous iff for any sequence $x_n$ in $(X,d)$ converging to $x$, the following holds.
\[ \lim_{n \to \infty} f(x_n) = f(x) \]
\end{theorem}

\begin{corollary}[Continuous function]
A function $f : X \to Y$ between 2 metric spaces $(X,d_X),(Y,d_Y)$ is continuous iff for each $x_0\in X$ and $\varepsilon > 0$, there  is some $\delta$ where the following holds for all $x \in X$.
\[ d(x,x_0) < \delta \implies d(f(x),f(x_0)) < \varepsilon \]
\end{corollary}

\begin{corollary}[Continuous function]
A function $f : X \to Y$ between 2 metric spaces $(X,d_X),(Y,d_Y)$ is continuous iff the following holds for any $x_0 \in X$.
\[ \lim_{x \to x_0} f(x) = f(x_0)\]
\end{corollary}



\subsection{Uniform continuity}


Metric spaces are so nice that we can define stronger, nicer classes of continuity. The real analysis student may be familiar with uniform continuity; which is a property of a function that is sufficient to permit swapping the order of taking limits and integrals.

\begin{definition}[Uniformly continuous function]
\[ f : X \to Y \text{ is uniformly continuous } \iff \forall \varepsilon [ \exists \delta [ \forall p \in X [ q \in B_{X}(p,\delta) \implies f(q) \in B_{Y}(f(p),\varepsilon) ]  ] ] \]
\end{definition}


\begin{definition}[Lipschitz continuous function]
\[ f: X \to Y \text{ is Lipschitz continuous } \iff \exists K\in \mathbb{R}_{+} [ d_{Y}(f(p),f(q)) \leq K d_{X} (p,q) ]\]
\end{definition}


\begin{definition}[$\alpha$-Hölder continuous function]
\[  f: X \to Y \text{ is } \alpha \text{-Hölder continuous }  \iff \exists K\in \mathbb{R}_{+} [ d_{Y}(f(p),f(q)) \leq K d_{X}^{\alpha} (p,q) ]\]
\end{definition}

Hölder continuity for certain $\alpha$ characterizes concepts already familiar to us.
\begin{proposition}
\[f \text{ is bounded } \iff f \text{ is 0-Hölder continuous}\]
\[f \text{ is Lipschitz continuous } \iff f \text{ is 1-Hölder continuous}\]
\end{definition}
















\section{Isometries}

Topological properties are conserved under homeomorphisms; metric properties are conserved under isometries.

\begin{definition}[Isometry]
Let $X,Y$ be two metric spaces. An \emph{isometry} is a function $f : X \to Y$ such that distance is preserved in the following way.
\[d_{X}(x,y) = d_{Y}(f(x),f(y))\]
If there exists an isometry between two metric spaces, then they are said to be \emph{isometric}.
\end{definition}


\begin{proposition}
Isometries are injective functions.
Isometries under composition from a group.
Isometries of $\mathbb{R}^n$ are rotations and reflections
\end{proposition}

\section{Banach fixed-point theorem}

One of my favourite objects in mathematics as a youth were convergent recursive sequences.
I had derived the sequence $x_{n+1} =x_n + \frac{a-x_{n}^2}{a} $ to calculate $\sqrt{a}$ by using the fact that $\lim_{n \to \infty} x_n = \sqrt{a}$.

I relied on heuristic arguments, however the theory of metric spaces allows us to prove the correctness of this claim.

\begin{definition}[Contraction mapping]
Given a metric space $(X,d)$, a \emph{contraction mapping} is a function $f : X \to X$ such that there exists some $r \in (0,1)$ where the following holds for any $x,y \in X$.
\[d(f(x),f(y)) \leq r d (x,y)\]
\end{definition}

It is easily seen that contraction mappings are a very special case of Lipschitz continuous functions that map to the same metric space and with a factor in $(0,1)$. Since Lipschitz functions are continuous, we have the following lemma.

\begin{lemma}
Contraction mappings are continuous functions.
\end{lemma}

\begin{theorem}[Banach fixed-point theorem]
Let $(X,d)$ be a complete metric space and $f: X \to X$ a contraction mapping then $f$ has a unique fixed point.
Furthermore, $x_{n+1}=f(x_n)$ converges to this fixed point.
\end{theorem}


The Banach fixed-point theorem was precisely the theory of why my sequence converged, specifically, the contraction mapping was $f(x)=x+\frac{a-x^2}{a}=x+1-\frac{x^2}{a}$ and it indeed had a unique fixed point $\sqrt{a}$ and convergent sequence as I had derived from philosophically concerning techniques.


\section{Baire spaces}

\begin{theorem}[Baire category theorem]
For a complete metric space $(X,d)$, let $X_n$ be a sequence of open dense subsets of $X$, then $\bigcap^{\infty}_{n=1}X_n$ is dense in $X$.
\end{theorem}


\section{Metrizations}

Metric spaces are much nicer to work with than topological spaces, so given a topolgical space, mathematicians often want to see if it is metrizable.

We search for a set of minimal properties that a topological space can obey that can be used to construct a metric. Such results are called \emph{metrization theorems}; sufficient conditions for a topological space to be metrizable.

Note that this study makes use of the separation properties.


\begin{theorem}[Urysohn Metrization theorem]
\end{theorem}




























































\section{Open and closed sets}


We may be acutely aware that open balls exclude the 'endpoints' and closed balls keep them, this is essentially the notion of a \emph{boundary}.

\begin{definition}
Let $(X,d)$ be a metric space. The \emph{boundary of $S$} is the set of all elements $p\in X$ such that all their open and closed balls have intersections with $S$ and $X \setminus S$. We denote the boundary of $S$ as $\partial S$, and elements of $\partial S$ are called boundary points of $S$.
\end{definition}

Due to those 2 findamental resulds, we can translate what they mean using the language of boundaries.

\begin{proposition}
Open balls are disjoint from their boundary. Closed balls contain their boundary.
\end{proposition}


There a more types of sets that don't contain their boundary rather than just open balls, so let's consider them.

\begin{definition}
Let $(X,d)$ be a metric space. A \emph{open set of $X$} is a set $U$ that is disjoint to $\partial U$. We say that $U$ \emph{ is open in $X$}.
\end{definition}

The same can be said about sets completely containing their boundary.

\begin{definition}
Let $(X,d)$ be a metric space. A \emph{closed set of $X$} is a set $F$ that completely contains $\partial F$. We say that $F$ \emph{ is closed in $X$}.
\end{definition}





Noting that $\partial S = \partial (X \setminus S)$, we can prove the following curious proposition.

\begin{proposition}
$F$ is closed iff $X \setminus F$ is open.
\end{proposition}

This gives us a nice set theoretic representation for closed sets that doesn't include a metric; we'll make this the prime definition once we've defined what topologies are!


\begin{theorem}
Let $(X,d)$ be a metric space. If $U$ is open in $X$ then any element in $U$ has an open ball completely contained in $U$.
\end{theorem}


This brings us 2 intuitive corollaries.
\begin{corollary}
Let $(X,d)$ be a metric space. Open balls are open sets. 
\end{corollary}

\begin{corollary}
Let $(X,d)$ be a metric space. open sets are unions of open balls. 
\end{corollary}


\section{Origins of topologies}

We'll now use our theory of metric spaces to understand how the set algebra laws for a topology were derived.

\begin{proposition}
Let $(X,d)$ be a metric space.
\begin{itemize}
	\item $X$ and $\emptyset$ are open sets 
	\item Open sets are closed under countable unions
	\item Open sets are closed under finite intersections
\end{itemize}
\end{proposition}

If we can't define a metric on a space, we can at least ensure it has a notion of open sets defined in this way. These set algebraic laws give a neat way to define open sets without any resort to a metric function; this is what we base the definition of a topology on.

Since a family of open sets must obey these 3 properties, if we define open sets by a family of sets that satisfy these 3 properties rather than the open balls, we generalize the idea of a metric space to a topological space.




\section{Bounded sets}

Given a metrc, we can introduce the concept of bounded sets, which is otherwise undefinable in more general topological spaces.

\begin{definition}[Bounded set]
Let $(X,d)$ be a metric space, a \emph{bounded set of $X$} is some set $A$ such that for any points $p,q\in S$ we have $d(p,q) < M$.
\[ A \text{ is bounded } \iff \exists r [\forall p, q \in A [ d(p,q) \leq M ] ]\]
\end{definition}

\begin{proposition}
A set is bounded iff it is covered by a single open ball.
\end{proposition}


This will be very useful when we study compactness.
