TITLE: Prove that the inverse image of an open set is open
QUESTION [30 upvotes]: 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.

REPLY [2 votes]: Consider a point $f(z)$ in $U$. For clarity, the theorem assumes $U$ is open.
Since all the points in U are mapped to the set $f^{-1}(U)$, now consider the equivalent point $z$ in $f^{-1}(U)$.
Remember, we know that $f(z)$ is in $U$. All points in $U$ have a ball around them of at least $\epsilon$. Since $f$ is continuous, there must exist a $\delta>0$ such that $z$ is in a ball of radius $\delta$, and that all points in that ball are mapped by $f$ to $U$, in fact, they end up within $\epsilon$ of $f(z)$. This is true for all $z$ such that $f(z)$ is in $U$. The fact that a ball exists of non-zero radius around each point $z$ in some set $X \subset \mathbb{R}$ is equivalent to that set being open. So it is done.