Prove that the inverse image of an open set is open

Let $X \subset \mathbb{R}$ be a non-empty, open set and let $f: X \rightarrow \mathbb{R}$ be a continuous function. Show that the inverse image of an open set is open under f, i.e. show:

If $M \subset \mathbb{R}$ is open, then $f^{-1}(M)$ is open as well.

I think that this should basically follow from the definitions, but I'm still having some troubles with the proof.

Suppose $M \subset \mathbb{R}$ is open, then it follows that $\forall z \in M, \exists r > 0: K_r(z) \subseteq M$

Since f is continuous it follows for each $x_0 \in X$ that for each $\epsilon > 0 ,\exists \delta > 0 : |f(x)-f(x_0)|< \epsilon, \forall x \in X: |x-x_0|<\delta$

Now I need to show that $f^{-1}(M)$ is open, so that for each $z \in M, \exists r>0: K_r(f^{-1}(z_0)) \subseteq f^{-1}(M)$

I'm not sure how to prove this. I guess since $z = f(x)$ and since M is open we have that $\exists r>0:\{z:|z-z_0|<r\}\subseteq M$. And since f is continuous: $|f(x)-f(x_0)| = |z-z_0|< \epsilon$ for all $|x-x_0|<\delta$, but since $|x-x_0|=|f^{-1}(z)-f^{-1}(z_0)|<\delta$ it somehow follows from that that $f^{-1}(M)$ is open?!

Which is just horrible and probably completely wrong. But I'm really confused from all the definitions right now and need some help please.

• Note that $f^{-1}(z_0)$ is not well-defined; if anything it means the set given by the pre-image $f^{-1}(\{z_0\})$ of the singleton. To start off your proof properly, try taking $x_0 \in f^{-1}(M)$. – Dustan Levenstein Jun 22 '14 at 19:49
• Next, you can look to $f(x_0)\in M$, suppose that there exists a ball $B$ centered in $f(x_0)$ with radius $r$ such that $B\subset M$, then take $\varepsilon<r$. Complete the proof. – DiegoMath Jun 22 '14 at 19:52
• To complete the proof you have to show that $B_\delta(x_0)\in f^{-1}(M)$. – DiegoMath Jun 22 '14 at 19:54

Take $x_0\in f^{-1}(M)$, then $f(x_0)\in M$.
Since $M$ is open, there exists $r>0$ such that $B(f(x_0),r)\subset M$.
Now, choose any $0<\varepsilon\leq r$, since $f$ is continuous, there exists $\delta>0$ such that $f(x)\in B(f(x_0),\epsilon)$ whenever $x\in B(x_0,\delta)$.
Note that if $x\in B(x_0,\delta)$, then $f(x)\in B(f(x_0),\varepsilon)\subset M$, thus $f(x)\in M$, moreover, $x\in f^{-1}(M)$, thus $B(x_0,\delta)\subset f^{-1}(M)$, then $f^{-1}(M)$ is open.