Functions: Metric spaces and continuity

The following question is from Fred H. Croom's book "Principles of Topology"

Let $X$ be a metric space with metric $d$ and $A$ a non-empty subset of $X$. Define $f:X\rightarrow \mathbb{R}$ by $$f(x) = d(x,A) , x\in X$$ Show that $f$ is continuous.

Now, we seek to show that $f$ is continuous. In order for it to be continuous, for every point $a$ in $X$, then for every $\epsilon>0$ there exists a $\delta>0$ such that if $x\in X$ and $d(x,a)<\delta$, then $d^{'}(f(x),f(a))<\epsilon$.

Now in this problem, $f(x)$ is defined to be the greatest lower bound of all distances between some point $x$ and the set $A$ (if I am not mistaken).

I am still a little confused on how to approach it from here. Would I just need to apply the definition of continuity? Any suggestion? How would I properly approach this problem?

I want to thank you for taking the time to read this question. I greatly appreciate any assistance you provide.

• $f(x)$ is the greatest lower bound of all distances between $x$ and a point $a\in A$. You have to show that for any $\epsilon>0$ there is a $\delta>0$ such that when $d(x,y)<\delta$ then $|d(y,A)-d(x,A)|<\epsilon$. Hint: You can choose $\delta$ as a very simple function of $\epsilon$, and $\delta$ does not depend on the particular $x$. – Stefan Hamcke Feb 18 '15 at 19:49

First prove that $f_p(x) = d(x,p)$ for a fixed point $p$ is a continuous function, then prove that $g_A(x) = d(x,A)$ is continuous for a given set $A \subset X$.
1. Let $x,y \in X$ such that $d(x,y) < \delta$ for some $\delta > 0$. Using a triangle inequality we have $f_p(x) \le f_p(y) + \delta$, as well as $f_p(y) \le f_p(x) + \delta$, from where $|f_p(x) - f_p(y)| \le \delta$. Choosing $\delta = \epsilon$ we prove that $f_p$ is continuous.
2. Furthermore, for every $\delta' > 0$ (by definition of infimum) there is $a \in A$ such that $d(x,a) < d(x,A) + \delta'$. Then $$d(y,a) \le d(y,x) + d(x,a) < \delta + d(x,A) + \delta'$$ Since $d(y,A) \le d(y,a)$, it follows that $g_A(y) < g_A(x) + \delta + \delta'$, that is $$g_A(y) - g_A(x) < \delta + \delta'$$ Analogously we have that $$g_A(x) - g_A(y) < \delta + \delta'$$ These two inequalities together give us $$|g_A(x) - g_A(y)| < \delta + \delta'$$ Choosing $\delta = \delta' = \epsilon/2$ we prove the claim. I hope this helps...