Several Questions on Smooth Urysohn's Lemma The smooth version of Urysohn's Lemma is 

Let $A,B$ be two disjoint closed subsets in $\mathbb{R}^n$ with one of them compact, then there exists a smooth function $f: \mathbb{R}^n\to [0,1]$ such that 
  $$f(A)=0\qquad f(B)=1$$

For a proof, for example , see the first answer of this question. 
I'am stuck on the following problems in the smooth version 


*

*How about the counterexamples without the condition that "one of them is compact"? 

*Can we make more strict conclusion that $f^{-1}(0)=A$ and $f^{-1}(1)=B$? Note that it implies $f(A)=0$ and $f(B)=1$. 


Without the requirement of smoothness, we can release the condition of compactness and make more strong requirement of inverse image, since we can simply take $f(x)=\frac{d(x,A)}{d(x,A)+d(x,B)}$. Clearly, it is not smooth in general. 
The idea of the above link does not holds even for the following regular figure. 

 A: I find a proof from Lee's Introduction to smooth manifold 2ed (page 47), the answer is positive. Briefly, it suffices for any closed subset $K$ to assign a smooth function $f:\mathbb{R}^n\to \mathbb{R}_{\geq 0}$ such that $f^{-1}(0)=K$. For any closed set $K$, $\mathbb{R}^n\setminus K$ is a union of countably many small balls $\{B_{r_i}(x_i)\}$.Then pick a common smooth function $\chi:\mathbb{R}^n\to \mathbb{R}_{\geq 0}$ which takes value $0$ when and only when $x\notin (-1,1)$. Then define
$$f(x)=\sum_{i=1}^\infty\frac{r_i^i}{2^i C_i}\chi\left(\frac{x-x_i}{r_i}\right)$$
where $r_i$ can be assumed to be $\leq 1$, and $C_i\geq 1$ such that $C_i\geq \max_{|\alpha|\leq i}||\partial^{\alpha} \chi||$. Then $\partial^{\alpha} f$ is bounded by $\frac{1}{2^i}$ when $i\geq |\alpha|+1$ so it converges uniformly, thus $f$ is smooth. It's not difficult to check that $f(x)=0\iff x\in A$. 
A: *

*None of $A$ and $B$ need be compact.

*Yes.

*Remarkably, the result is true in greater generality: namely, for Hausdorff, second-countable smooth manifolds. It is the fundamental result upon which smooth partitions of unity are constructed on smooth manifolds as above. A proof may be found in lemma 1.3.2 on pages 10-11 of Peter Petersen's "Manifold Theory"
