It is well known that every closed set $A \subset \mathbb{R}^{n}$ is the zero level set of some smooth function. It follows that every closed set is also the zero sublevel set of some smooth function, i.e.
\begin{align\*}
A &= \{x \in \mathbb{R}^{n} : f(x) \le 0 \}.
\end{align\*}
I am wondering if one can easily characterize closed sets for which there exist a smooth function $f$ such that the following stronger conditions hold
\begin{align\*}
\partial A &= \{x \in \mathbb{R}^{n} : f(x) = 0 \}, \text{ and}\\
A^{\circ} &= \{x \in \mathbb{R}^{n} : f(x) < 0 \}? 
\end{align\*}



Existence of smooth function that characterizes boundary and interior of set
I think every closed set $A \subset \mathbb{R}^{n}$ has this property. Let $\{\phi\_k\}\_{k\in\mathbb{N}}\subset C^\infty\_c(\mathbb{R}^{n})$ a countable collection of non-negative smooth functions with compact support such that $A^\circ=\bigcup\_{k\in\mathbb{N}}\{\phi\_k>0\}$ (for instance, $\{\phi\_k>0\}$ may be balls of some countable covering of $A^\circ$). Then the series
$$ \sum\_{k=0}^\infty\, {2^{-k}\| \phi\_k\|\_{C^k}^{-1}}\,\, \phi\_k$$


normally converges with derivatives of any order to a smooth function $f\_-$ with $\{f\_->0\}=A^\circ$. Here $\displaystyle\| \phi \|\_{C^k}=\max\_{ \alpha\in\mathbb{N}^n\atop |\alpha|\le k }\|\partial^\alpha\phi \|\_{\infty,\mathbb{R}^{n}}$ is the standard ${C^k}$-norm. The same construction for $A^c$ produces a smooth $f\_+$ with $\{f\_+>0\}=\mathbb{R}^{n}\setminus \overline{A}$; then $f:=f\_+-f\_-$ has the required properties, that is $\{f<0\}=A^\circ$, $\{f>0\}=\mathbb{R}^{n}\setminus \overline{A}$, and $\{f=0\}=\partial A$.


