I have been faced with the following problem while studying some notes on $\mathbb{R}^{n}$ analysis:
Let $D \subset \mathbb{R}^{n}$ be a set and $f: D \rightarrow \mathbb{R}$ be a function. Prove that $f$ is continuous if and only if the inverse image of every open set under $f$ is the intersection of $D$ with an open set.
Now, I am very familiar with the case where $D \subset \mathbb{R}^{n}$ is $\mathbb{R}^{n}$ itself or an open subset of it and one must prove that $f$ is continuous iff the inverse image of open sets under $f$ is also open, however I cannot seem to figure out the difference between these cases and the one that I am tasked with solving.
There is a remark that mentions that the proof is very similar to the latter case, and that all it takes is to notice where in the proof of such case was the fact that $D$ is an open set used, but I have been thinking about this problem for a while and have been unable to spot where that hypothesis is utilized.
Any help is greatly appreciated.
Best Answer
From a topological point of view, your question is precisely the definition of a continuous function.
However, you only asked about metric spaces, so let's revert to the $\varepsilon-\delta$ definition.
Suppose that $f:D\to \mathbb{R}$ is continuous, then the $\varepsilon-\delta$ condition is satisfied. Let $V$ be open in $\mathbb{R}$, we show that $f^{-1}(V)$ is the intersection of $D$ with an open subset of $X=\mathbb R^n$. Take any $x\in f^{-1}(V)$ (if $f^{-1}(V)$ is empty then it is open). Since $f(x) \in V$, there is an $\varepsilon$-ball $B(f(x), \varepsilon) \subseteq V$. By $\varepsilon-\delta$, there exists some $\delta >0$ such that whenever $|y-x|<\delta$,$$|f(x)-f(y)|<\varepsilon \implies f(y) \in B(f(x), \varepsilon).$$ Therefore, $$f(B(x, \delta)\cap D) \subseteq B(f(x), \varepsilon) \subseteq V \implies (B(x, \delta)\cap D) \subseteq f^{-1}(V)$$ where $B(x, \delta)$ is an open ball of radius $\delta$ centered at $x$, and it may contain points not in $D$. Then we can express $f^{-1}(V)$ as a union of open balls $$f^{-1}(V)=\bigcup_{x \in f^{-1}(V)} \{x\} \subseteq \bigcup_{x \in f^{-1}(V)} (B(x, \delta)\cap D) \\=\left(\bigcup_{x \in f^{-1}(V)}B(x, \delta)\right) \cap D \subseteq f^{-1}(V)$$ Since $\bigcup_{x \in f^{-1}(V)}B(x, \delta)$ is open in $X=\mathbb{R}^n$ (arbitrary union of open sets is open), $f^{-1}(V)$ is the intersection of $D$ with an open subset of $X$. The converse can be proven in the same way.