Let $f: [0,\infty) \rightarrow \Bbb R$, $f=x^{1/2}$, $f$ is continuous. But if $S=\Bbb R$, then $f^{-1}(S)=[0,\infty)$, this is saying the preimage of open set is not open, which seems to contradict the definition of continuity, what is wrong over here?
2 Answers
$f$ is continue, when you check if it satisfies the definition of continuity, you have to consider the induced topology on $[0,\infty)$. For $U$ open subset of $R$, you have to check if $f^{-1}(U)$ is open for the induced topology. An open subset for this topology is the intersection of an open subset of $R$ with $[0,\infty)$. So $[0,\infty)$ is an open subset of $[0,\infty)$ since $[0,\infty)= R\cap [0,\infty)$.
Your Mistake is to think that $[0, +\infty) is not open... that's PARTIALLY true, and it's not true in this case.
The reason is that sets aren't just "open" or "closed" or whatever, but are "open with respect to $X$" where $X$ is a sets that contains said sets.
When you usually say that a set $S$ is open, it's a convention for saying "open with respect to $\mathbb{R}$; but for continuity what is required is to be open with respect to the domain of $f$.
This, and the fact that every Set is open with respect to itself, gives you the answer.
see https://en.wikipedia.org/wiki/Open_set , properties (topological ones)