# Existence of a continuous function with prescribed support

Suppose $X$ is a topological space and $U\subset X$ is open. I want to find a continuous function $f : X \to \mathbb{R}$ such that $$\{ x\in X : f(x) \neq 0 \} = U$$ Can this always be done?

-

No. Note that $\{x \in X: f(x) \ne 0\} = \bigcup_{n=1}^\infty \{x \in X: |f(x)| \ge 1/n\}$. So if such an $f$ exists, $U$ is not only an open set but an $F_\sigma$ (the countable union of closed sets). Any open set that is not an $F_\sigma$ is a counterexample.

For example, take $X$ to be the set of ordinals $\le$ the first uncountable ordinal $\omega$ (considered as a topological space with the order topology), and $U = \{x \in X: x < \omega\}$. Any closed set contained in $U$ is countable but $U$ is uncountable, so $U$ is not an $F_\sigma$.

-

In the topological vernacular, a set of the form $f^{-1} [ \mathbb{R} \setminus \{ 0 \} ] = \{ x \in X : f(x) \neq 0 \}$ for a continuous function $f : X \to \mathbb{R}$ is called a co-zero set, and as Robert Israel mentions, such a set must not only be open, but also F$_\sigma$. Complements of a co-zero sets (i.e., sets of the form $f^{-1} [ \{ 0 \} ] = \{ x \in X : f(x) = 0 \}$ for some continuous $f : X \to \mathbb{R}$) are called a zero sets, and we have that zero sets must be closed G$_\delta$-sets. (Actually, you can replace $\mathbb{R}$ with $[0,1]$ in both of the above definitions.) It is somewhat easier (for me at least) to deal with zero sets, so the sequel will only mention them.

Note that even being a closed G$_\delta$-set may not be enough to guarantee that a set is a zero set: it depends on the topology in question. Consider the Niemytzki (or Moore) plane, and the family $F = \{ \langle x , 0 \rangle : x \in \mathbb{Q} \}$. It is not too difficult to show that $F$ is a closed G$_\delta$-set, and a category argument can determine that it is not a zero set.

However, if $X$ is a normal space, then it is true that every closed G$_\delta$-set is a zero set. This is essentially a consequence of Urysohn's Lemma: If $F \subseteq X$ is closed G$_\delta$, and $F = \bigcap_{i=1}^\infty U_i$ where each $U_i$ is open, then by Urysohn's Lemma for each $i$ there is a continuous $f_i : X \to [0,1]$ such that $F \subseteq f_i^{-1} [ \{ 0 \} ]$ and $X \setminus U_i \subseteq f_i^{-1} [ \{ 1 \} ]$. It follows that $$f(x) = \sum_{i=1}^\infty \frac{f_i(x)}{2^i}$$ is a continuous function, and not too difficult to show that $f^{-1} [ \{0\} ] = F$.

There is another class of topological spaces, called perfectly normal spaces which are characterised by being normal, plus having all closed sets G$_\delta$. In these spaces every closed set is a zero set. Examples of perfectly normal spaces include the real line (actually, every metric space) and the Sorgenfrey line.

-