Problem: Let $(X,d)$ be a metric space and $Y$ be any subset of $X$. If $x\in X$, we define
\[
d(x,Y) \coloneqq \inf \{ d(x,y): y \in Y \} .
\]
Prove that the function
\[
f: X \to \mathbb{R} , \quad x \mapsto d(x,Y)
\]
is a continuous function.
Solution: Let $\epsilon > 0$ be given. We need to find $\delta > 0$ such that
\[
d(x_1, x_2) < \delta \implies \left\vert d(x_1, Y) - d(x_2, Y) \right\vert < \epsilon .
\]
Given $x_1 \in X$, the number $d(x_1, X) + \epsilon /2$ is not a lower bound of the set $\left\{ d(x,y): y \in Y \right\} $. Thus, there exists $y_1 \in Y$ such that
\begin{equation}\label{eq:15Aug2024-1}
d(x_1, y_1) < d(x_1, Y) + \frac{\epsilon}{2}.
\end{equation}
Therefore, given any $x_2 \in X$, with $d(x_1, x_2) < \frac{\epsilon}{2} $, we have
\begin{align*}
d\left( x_2, Y \right) & \leq d(x_2, x_1) + d\left( x_1, y_1 \right) \\
& < \frac{\epsilon}{2} + d(x_1, Y) + \frac{\epsilon}{2} \\
& < \epsilon + d(x_1, Y).
\end{align*}
Thus, $d(x_2, Y) - d(x_1, Y) < \epsilon $. Similarly, by changing the role of $x_1$ and $x_2$, we can obtain
\[
d(x_1, Y) - d(x_2, Y) < \epsilon.
\]
Therefore, we proved that
\[
d(x_1, x_2) < \frac{\epsilon}{2} \implies \left\vert d(x_1, Y) - d(x_2, Y) \right\vert < \epsilon .
\]