Show that there exist a continuous function $f:X\to [0,1]$ such that $f^{-1}(\{0\})=A$ and $f(B)=\{1\}$. [duplicate]

Let $A,B$ disjoint closed subsets of a normal topological space $(X,\Gamma)$. Show that there exist a continuous function $f:X\to [0,1]$ such that $f^{-1}(\{0\})=A$ and $f(B)=\{1\}$ if and only if $A$ is a $G_{\delta}$ on $(X,\Gamma)$.

Recall that $A$ is a $G_{\delta}$ set in $X$, if $A$ is the intersection of a countable collection of open sets of $X$.

Let $A,B$ disjoint closed subsets of a normal topological space $(X,\Gamma)$, and suppose there exist a continuous function $f:X\to [0,1]$ such that $f^{-1}(\{0\})=A$ and $f(B)=\{1\}$, but note that $$\{0\}=\bigcap_{n=1}^{\infty}{\left[0,\dfrac{1}{n}\right)}$$

$$A=f^{-1}(\{0\})=f^{-1}\left(\bigcap_{n=1}^{\infty}{\left[0,\dfrac{1}{n}\right)}\right)=\bigcap_{n=1}^{\infty}{f^{-1}\left[0,\dfrac{1}{n}\right)}$$

Thus, $f^{-1}\left[0,\dfrac{1}{n}\right)$ is in $\Gamma$ for all $n\in\mathbb{N}^{+}$, so $A$ is a $G_{\delta}$ in $(X,\Gamma)$.

But, I really need help with the other part of the proof. Thanks!!

marked as duplicate by Martin R, Claude Leibovici, user91500, user370967, egregJun 29 '17 at 10:36

In this note I show that for a closed $G_\delta$ $A$ in a normal space $X$, we have continuous $f_A: X \to [0,1]$ with $A=f_A^{-1}[\{0\}]$.
Now if we have disjoint closed $G_\delta$ sets $A$ and $B$, the function $f=\frac{f_A}{f_A + f_B}$ has $f^{-1}[\{0\}]=A$ and $f^{-1}[\{1\}]=B$.
These ideas are easily modified for your case as well, we can make $f_A$ to work if you let the complement of $B$ be the first open set in the $G_\delta$ and write $A$ as decreasing intersection of open sets.
• Positive functions only $0$ in $A$ resp. $B$. – Henno Brandsma Jun 30 '17 at 13:30