The continuity of a distance function Let $(X,d)$ be a metric space $A\subset X$ be a nonempty subset.
The distance function $f : X \to\mathbb R$ by $f(x)=d(x,A)$ where $d(x,A) = \inf_{a\in A} d(x,a)$ and $\mathbb{R}$ denotes the set of real numbers.
I have already proved the continuity of this function by using epsilon-delta.
But I can't prove it by using this property :
"The inverse image of an open set is also open in the domain of definition"
I think, from the fact that any open set is the union of open balls in the metric space, that the given statement can be proved.
 A: For all $a \in A$ we have  $f(y) \le d(y,a) \le d(x,y)+d(x,a)$, taking the infimum over $a$ gives $f(y) \le d(x,y) + f(x)$. The same argument applies, mutatis mutandis, with $x,y$ interchanged. Hence we have $|f(x)-f(y)| \le d(x,y)$.
Now suppose $U$ is open, and let $V = f^{-1}(U)$. Let $v \in V$, we need to show that there is some open ball containing $v$ contained in $V$. We have $f(v) \in U$, hence since $U$ is open we have some $\epsilon>0$ such that $f(v) \in (f(v)-\epsilon, f(v)+\epsilon) \subset U$.
Now suppose $d(w,v) < \epsilon$, then the above shows that $|f(w)-f(v)| \le d(w,v) < \epsilon$, and so $f(w) \in U$. Hence $f(B(v,\epsilon)) \subset (f(v)-\epsilon, f(v)+\epsilon) \subset U$. Hence $V$ is open.
A: Suppose $f\colon X\rightarrow Y$ where $X$ and $Y$ are metric spaces.
The metric topology for $X$ is
$$
\tau_{X}\equiv\left\{ U\subset X\mid\forall x\in U\colon\exists\delta>0\colon b_{X}^{\delta}\left(x\right)\subset U\right\} 
$$
where $b_{X}^{\delta}\left(x\right)\equiv\left\{ x^{\prime}\in X\mid d_{X}\left(x,x^{\prime}\right)\right\} $
is an open ball around $x$. $\tau_{Y}$ is defined similarly. Suppose
$f$ is continuous in the metric space sense at $x$. That is,
$$
\forall\varepsilon>0\colon\exists\delta>0\colon\forall x^{\prime}\in X\colon d_{X}\left(x,x^{\prime}\right)<\delta\Rightarrow d_{Y}\left(f\left(x\right),f\left(x^{\prime}\right)\right)<\varepsilon.
$$
Now, let's show that this means that it is continuous in the topological
sense. That is,
$$
\forall V\in\tau_{Y}\colon f^{-1}\left(V\right)\in\tau_{X}.
$$
Take $V\in\tau_{Y}$ arbitrary. Note that by the definition of the
metric space topology on $Y$, $V$ is open implies that $\exists\varepsilon>0$
s.t. $b_Y^{\varepsilon}\left(f\left(x\right)\right)\subset V$. Note
that
$$
f^{-1}\left(V\right)=\left\{ x\in X\mid f\left(x\right)\in V\right\} 
$$
and that by the continuity of the metric space, $\exists\delta>0$
s.t.
$$
b_X^{\delta}\left(x\right)\subset f^{-1}\left(V\right),
$$
which is exactly what we need for $f^{-1}\left(V\right)$ to be open!
(Recall the definition of the metric space topology).
Note that this holds for any two metric spaces $X$ and $Y$. So if
you have shown your original problem to be true for $Y=\left(\mathbb{R},d_{\mathbb{R}}\right)$,
then you are done! That is, assuming that you are defining your topologies using
the notion of a metric space topology.
