Let $A$ and $B$ be closed sets in a metric space $(E,d)$ such that $A\cap B=\varnothing$ Prove that there exists a continuous function $f:E\to \Bbb{R}$ such that $f(x)=1$ if $x\in A$ and $f(x)=0$ if $x\in B.$
Here is what I have done:
Since $A$ and $B$ are closed sets of $(E,d)$ and $A\cap B=\varnothing$ , then $E=A\cup B\cup(A\cap B)^C$ is disconnected. Hence, $\exists$ a continuous function $f:E\to \{0,1\}$.
I'm stuck at this point! Please, I need some help! Thanks a lot!
Consider $f:E\to\mathbb{R}$ defined by $$f(x)=\dfrac{d(x,A)}{d(x,A)+d(x,B)}$$This function is well defined because $A\cap B=\emptyset$ and both are closed sets. If $x\in A$ then $d(x,A)=0$ but $d(x,B)>0$ and in the same way, if $x\in B$ then $d(x,B)=0$ and $d(x,A)>0$. In both cases the denominator is non-zero. And, if $x\in A$ then $f(x)=0$ and if $x\in B$ then $f(x)=1$. The function is continuous, because is the sum and quotient of continuous functions.