# Does continuity of $f$ imply $f^{-1}(\bar A)\subset\overline{f^{-1}(A)}$?

I'm struggling to prove or disprove that the continuity of $f$ implies $f^{-1}(\bar A)\subset\overline{f^{-1}(A)}$.

$f:X\to Y$ is a map between metric spaces $(X,d),(Y,d')$ while $\bar M$ denotes the closure of $M$.

The definition of continuity I'm supposed to use for this exercise is:

$f$ is continuous$\ \Leftrightarrow\ f^{-1}(M)$ is open if $M\subset Y$ is open$\ \Leftrightarrow\ f^{-1}(M)$ is closed if $M\subset Y$ is closed.

• This is true if $f$ is an open map. Proof: Let $x\in f^{-1}(\overline{A})$ and take $U$ an arbitrary neighborhood of $x$. Then $f(x)\in f(U)\cap \overline{A}$ so $f(U)\cap A\neq \emptyset$ and then $U\cap f^{-1}(A)\neq \emptyset$. As $U$ was arbitrary we have $x\in \overline{f^{-1}(A)}$. – yamete kudasai Oct 31 '18 at 15:24

Let $Y = \mathbb{R}$ with usual metric and $X = (0,1) \cup \{2\}$ with metric inherited from the standard metric on $\mathbb{R}$. let $f(x) = x$ on $(0,1)$ and $f(2) = 1$ and take $A = (0,1)$. it is then easy to see that for this particular case your statement doesn't hold
Since $A\subseteq\bar{A}$ you know that $f^{-1}(A)\subseteq f^{-1}(\bar{A})$, so $$\overline{f^{-1}(A)}\subseteq f^{-1}(\bar{A})$$ because $f^{-1}(\bar{A})$ is closed by continuity of $f$.
Now, if your claim is true, you'd conclude that $\overline{f^{-1}(A)}= f^{-1}(\bar{A})$ for every $A\subseteq Y$. Can you?
Let $X=\mathbb{R}$ with the discrete metric. Then any function is continuous. Let $Y=\mathbb{R}$ with the standard metric. Define $f:X\rightarrow Y$ to be $f(1)=1$ and $f(x)=\sqrt{2}$ for all $x\neq 1$. Finally set $A=\mathbb{Q}$. Then $\overline{\mathbb{Q}}=\mathbb{R}$ and $f^{-1}(\mathbb{R})=\mathbb{R}$. But, $f^{-1}(\mathbb{Q})=\{1\}$.