Prove that a function between metric spaces $(X,d_{X})$ and $(Y,d_{Y})$ is continuous iff the pre-image of open sets is open Let $(X,d_{X})$ be a metric space, and let $(Y,d_{Y})$ be another metric space. Let $f:X\to Y$ be a function. Then the following two statements are logically equivalent:
(a) $f$ is continuous.
(b) Whenever $V$ is an open set in $Y$, the set $f^{-1}(V) = \{x\in X: f(x)\in V\}$ is an open set in $X$.
I know this problem is pretty standard, but I am not able to prove any of the two directions.
Since I am studying real analysis at the moment (metric spaces, in fact), could someone provide a proof or at least a hint as how to prove it? It is not homework. Any comment or contributions are welcome.
 A: Assume b)
Let $\epsilon\gt 0$ and $x\in X$. The ball $B(f(x),\epsilon)\subset Y$ is an open subset. Its reciprocal image $f^{-1}\left(B(f(x),\epsilon\right)$ is open. But $x\in f^{-1}\left(B(f(x),\epsilon\right)$ so there is an open ball centred at $x$ included in this open subset. This means there is a $\delta\gt 0$ such that $B(x,\delta)\subset f^{-1}\left(B(f(x),\epsilon\right)$. We have just proved that
$$\forall x\in X\,\forall \epsilon\gt 0\,\exists \delta\gt 0,\,d_X(x,y)\leq \delta\Rightarrow d_Y(f(x),f(y)\leq \epsilon$$
For the other implication assume a) $f$ continuous
Consider $V\subset Y$ an open subset. Let $x\in f^{-1}(V)$; this means $f(x)\in V$. Take $\epsilon \gt 0$ such that $B(f(x),\epsilon)\in V$. Because of the assumption there exists $\delta\gt 0$ such that 
$$y\in B(x,\delta)\Rightarrow f(y)\in B(f(x),\epsilon)$$
This means
$$B(x,\delta)\subset f^{-1}\left(B(f(x),\epsilon\right)\subset f^{-1}(V)$$
And we have juste proved that $f^{-1}(V)$ is open
A: Suppose $f$ is continuous on $X$. If $V$ is open in $Y$, $f^{-1}(V)$ is in X. Given a point $x \in f^{-1}(V)$, $f(x) \in V$. By continuity of $f$, there is a neighborhood of $x$, say $U$, such that $f(U) \subseteq V$ since $V$ is a neighborhood of $f(x)$. We get $x\in U \subseteq f^{-1}(f(U))\subseteq f^{-1}(V)$. Since $x\in f^{-1}(V)$ is arbitrary, $f^{-1}(V)$ is open in X.
$$$$
Suppose the inverse mapping of open set is open.
If $V\in Y$ is open and $f^{-1}(V)$ is open in $X$. Given $p\in X$ and $\varepsilon >0$. $B(f(p),\varepsilon) \subseteq Y$ is open.
So $f^{-1}(B(f(p),\varepsilon))$ is open in $X$ and $p \in f^{-1}(B(f(p),\varepsilon))$. There is a positive number $\delta$ such that $B(p,\delta) \subseteq f^{-1}(B(f(p),\varepsilon))$. We get $$f(B(p,\delta)) \subseteq f(f^{-1}(B(f(p),\varepsilon))) \subseteq B(f(p),\varepsilon)$$ Since such $p$ is arbitrary, f is continuous on X.
A: Let us assume b) prove a) first.
Let take $\epsilon\gt 0$ and $x\in X$. We have the ball $B(f(x),\epsilon)\subset Y$ is an open subset. Its inverse image $f^{-1}\left(B(f(x),\epsilon\right)$ is open. Clearly $x\in f^{-1}\left(B(f(x),\epsilon\right)$ so there exist a $\delta\gt 0$ such that $B(x,\delta)\subset f^{-1}\left(B(f(x),\epsilon\right)$.
We have 
$$\forall x\in X\,\forall \epsilon\gt 0\,\exists \delta\gt 0,\,d_X(x,y)\leq \delta\Rightarrow d_Y(f(x),f(y)\leq \epsilon$$
Now the other direction.
Suppose $f$ is continuous on $X$. Let $V$ be an open subset of $Y$, $f^{-1}(V)$ is in X we are to show that it is open. Given a point $x \in f^{-1}(V)$, $f(x) \in B(f(x),\epsilon) V$. By continuity of $f$, there is an open ball of $x$, $B(x,\delta)$, such that $f(B(x,\delta))\subseteq B(f(x),\epsilon) \subseteq V$ (as $V$ is a neighborhood of $f(x)$). So we get $$x\in B(x,\delta) \subseteq f^{-1}(f(B(x,\delta)))\subseteq f^{-1}( B(f(x),\epsilon)) \subseteq f^{-1}(V).$$ Since $x\in f^{-1}(V)$ is arbitrary, $f^{-1}(V)$ is open in X.
