# Showing a set is open through an inverse

The question: Show that a set $$U$$ is open in the metric $$M$$ if and only if $$U = f^{-1}(V)$$ for some continuous function $$f: M \rightarrow \mathbb{R}$$ and some open set $$V$$ in $$\mathbb{R}$$

I have no idea how to even begin on either side of this proof My apologies if someone has answered this before but I could not find anything as such

• Note: $f^{-1}(V)$ is not an inverse, but the preimage of $V$ under $f$. – mrp Sep 27 '18 at 17:08

Take $$C$$ to be the complement of $$U$$, which is closed. Consider the function $$f(x) = \inf_{y \in C} d(x,y),$$ also known as "distance from C". Exercise: prove that it is a continuous function. Then $$U = \{x : f(x) > 0\} = f^{-1}((0,\infty))$$.