Let $F$ be a closed subset of a metric space $X$. Does there exist a continuous function $g : X \to R$ such that $F = g^{-1}({0})$? Let $F$ be a closed subset of a metric space $X$. Does there exist a continuous function
$g : X \to \mathbb{R}$ such that $F = g^{-1}({0})$? I am trying to produce a counterexample to this. Any ideas would be really helpful

For $F=\emptyset$ we can take $g: x \to \Bbb R$ to be a constant function with value $1$, so that $g^{-1}[\{0\}] = \emptyset = F$. So we can assume that $F \neq \emptyset$.
Let $f(x) = \inf \{d(x,y): y \in F\}$, which is well-defined as the infimum of a non-emptys set that is bounded below (by $0$) in $\Bbb R$.
Then it's not too hard to see that $$\forall x,x' \in X: |f(x)-f(x')| \le d(x,x')$$ which makes $f$ uniformly continuous.
And it's also clear that any $x$ which is a limit point of $F$ obeys $d(x,F)=0$ and the same holds for all $x \in F$, so that $F= f^{-1}[\{0\}]$. So use $g=f$, the distance to the set function.
