Let $A,B \subset \mathbb{R}^n$ open sets, $A\subset B$. How can I set a function $f:\mathbb{R}^n\longrightarrow\mathbb{R}$, $C^{\infty}$ Let $A,B \subset \mathbb{R}^n$ open sets, $A\subset B$. How can I set a function $f:\mathbb{R}^n\longrightarrow\mathbb{R}$, $C^{\infty}$, such that:
\begin{equation*} f(x)=0, \textrm{ if } x\in A\textrm{, and }f(x)>0, \textrm{ if }x\in Ext(B),\end{equation*}
where $Ext(B)$ is the exterior of $B$?
 A: If $E \subset \mathbb {R}^n$ is closed, then there exists $f\in C^\infty(\mathbb {R}^n)$ such that $f= 0$ on $E,f>0$ on $\mathbb {R}^n \setminus E.$ Just take $E = \bar {A}$ for your problem.

Added two days later: Let's see if I can get rid of this negative score.
Theorem: If $E \subset \mathbb {R}^n$ is closed, then there exists $f\in C^\infty(\mathbb {R}^n)$ such that $f= 0$ on $E,$ and $f>0$ on $\mathbb {R}^n \setminus E.$
Proof: Start with a basic fact: If $B(a,r) \subset \mathbb {R}^n,$ then there exists $f\in C^\infty(\mathbb {R}^n)$ with $f> 0$ on $B(a,r)$ and $f= 0$ on $\mathbb {R}^n\setminus B(a,r).$ (Here $B(a,r)$ is the open ball of radius $r>0$ centered at $a.$)
We need a few norms to think about. For $k=0,1,\dots$ and $f\in C^k(\mathbb {R}^n),$ set
$$\|f\|_k = \sup_{x\in \mathbb {R}^n} \sum_{|\alpha| \le k}|D^\alpha f(x)|.$$
Here $\alpha $ is a multi-index and above I am using standard multi-index notation for the partial derivatives of $f.$ Then $\|f\|_k$ is well defined as a number in $[0,\infty].$ Here is another basic fact: If $f_m\in C^k(\mathbb {R}^n), m=1,2,\dots$ and $\sum_m \|f_m\|_k <\infty,$ then $\sum f_m(x)$ converges uniformly on $\mathbb {R}^n$ to a function in $C^k(\mathbb {R}^n).$
Let $U=\mathbb {R}^n \setminus E.$ For each $a\in U,$ set $r(a) = d(a,E).$ Let $a_1,a_2, \dots$ be dense in $U.$ For each $B(a_m,r(a_m)),$ choose $f_m \in C^\infty(\mathbb {R}^n)$ with $f_m> 0$ on $B(a_m,r(a_m))$ and $f_m= 0$ on $\mathbb {R}^n\setminus B(a_m,r(a_m)).$ By multiplying by a small positive constant, we can choose such an $f_m$ with $\|f_m\|_m < 1/2^m.$
For any fixed $k\in \{0,1,\dots \},$ we have
$$\sum_m \|f_m\|_k = \sum_{m=1}^{k}  \|f_m\|_k  + \sum_{m\ge k}\|f_m\|_k  \le \sum_{m=1}^{k}  \|f_m\|_k  + \sum_{m\ge k}^{k}\|f_m\|_m \le \sum_{m=1}^{k}  \|f_m\|_k  + \sum_{m\ge k}^{k}1/2^m < \infty.$$
Thus we can define $f(x) = \sum f_m(x), x\in \mathbb {R}^n.$ The above shows $f\in C^k$ for each $k,$ hence $f\in C^\infty.$ If $x\in U,$ then there is a sequence in our dense set that converges to $x.$ By the choice of the accompanying radii, it's clear that $x\in B(a_m,r(a_m))$ for some $m,$ hence $f(x) >0.$ If $x\in E,$ then all $f_m(x) = 0,$ hence $f(x) = 0.$ The proof is done!
