$C^\infty$ version of Urysohn Lemma in $\Bbb R^n$

I'm trying to solve an exercise which its conclusion seems to be the title of this post. The exercise is:

  1. Show that the function $h:\Bbb R\to [0,1[$ given by $$h(t)=\begin{cases} e^{-1/t^2} &\text{if } t\neq 0\\ 0 &\text{otherwise} \end{cases}$$ is $C^\infty$.
  2. Show that the functions $$h_+(t)=\begin{cases} e^{-1/t^2} &\text{if } t\gt 0\\ 0 &\text{otherwise} \end{cases}\quad\text{and}\quad h_{-}(t)=\begin{cases} e^{-1/t^2} &\text{if } t\lt 0\\ 0 &\text{otherwise} \end{cases}$$ are $C^\infty$.
  3. Show that the function $k:\Bbb R\to [0,1[$ given by $k(t)=h_-(t-b)h_+(t-a)$ is $C^\infty$ and positive for $t\in ]a,b[$.
  4. Let $R$ the rentangle $]a_1,b_1[\times\cdots\times]a_n,b_n[$. Show that there is a $C^\infty$ function $g:\Bbb R^n\to [0,1[$ strictly positive on $R$.
  5. Conclude that if $K$ is a compact subset of $\Bbb R^n$ and $U$ is an open neighborhood of $K$, there is a $C^\infty$ function $f:\Bbb R^n\to [0,1]$ such that $f_{|K}\equiv 1$ and its support is contained in $U$.

From 1.-4. I can prove that for any open and bounded set $O\subset \Bbb R^n$, there is a $C^\infty$ function with its support contained in $O$. So my first attempt was apply this to the open $U\setminus K$. Then I get a $C^\infty$ function $f$ that is $0$ (in particular) over $K$. If I just consider $\chi_K+f$ that function can fail to be $C^\infty$.

In a discussion on the chat, robjohn suggest this. It works fine, but then my question is:

Can 5. be proved by using 1.-4.? If yes, how?


Since $K$ is compact and $U^C$ is closed, there is a positive distance, $\Delta$, from $K$ to $U^C$.

We can cover each point $k\in K$ with an open cube $Q_k(\Delta/\sqrt{n})$ centered at $k$ and side $\Delta/\sqrt{n}$. Note that the entire cube is within $\frac\Delta2$ of $k$. Since $K$ is compact, choose a finite subcover of these cubes $\{Q_{k_j}(\Delta/\sqrt{n}):1\le j\le N\}$. For each cube in this subcover, define the function $f_j$ mentioned in step 4 above on $Q_{k_j}(2\Delta/\sqrt{n})$ but divide it by its minimum on $\overline{Q}_{k_j}(\Delta/\sqrt{n})$. Thus, $f_j$ is supported in $Q_{k_j}(2\Delta/\sqrt{n})$ and is $\ge1$ on $Q_{k_j}(\Delta/\sqrt{n})$.

$\sum\limits_{j=1}^Nf_j$ is supported in $U$ and is $\ge1$ on $K$. Then $\phi\circ\sum\limits_{j=1}^Nf_j$ is supported in $U$ and is $1$ on $K$, where

$$\phi(x)=\frac{h_+(x)}{h_+(x)+h_+(1-x)}$$

Note that $\phi\in C^\infty$, and $\phi(x)=0$ for $x\le0$ and $\phi(x)=1$ for $x\ge1$.


$\newcommand{\d}{\mathrm d}\newcommand{\supp}{\operatorname{supp}}$ This is just the end of the Section 2.6: Constructions of Smooth Functions, in Differentiable Manifolds by Lawrence Conlon.

Let $a\lt b$, and consider the function $k:\Bbb R\to [0,1[$ as in 3. Now, let $l:\Bbb R\to[0,1[$ defined by $$l(x)=\frac{\int_a^x k(t)\d t}{\int_a^b k(t)\d t}.$$ Notice that $l$ is no decreasing, $l\equiv 0$ in $]-\infty,a]$, $l\equiv 1$ in $[b,\infty[$, and $0\lt l(x)\lt 1$ for $x\in ]a,b[$.

Now, as in @robjohn's answer, it's possible to cover $K$ by a finite number of open intervals, say $\{I_j\}_1^N$, so that $\bar{I_j}\subset U$ for each $j\in\{1,\ldots,N\}$.

For each $j\in\{1,\ldots,N\}$, pick a soft function $g_j:\Bbb R^n\to [0,1[$ as in 4. Then the function $g:\Bbb R^n\to [0,1[$ given by $$g=g_1+\cdots+g_N$$ is $C^\infty$, positive over $K$ and with $$\supp(g)\subseteq U.$$ Now, $g$ attains its minimum over $K$, say in $x_\ast\in K$, thus $g(x_\ast)\gt 0$. Let $\delta=g(x_\ast)$.

Take an $l$ as the one discussed at the beginning with $a=0$ and $b=\delta$. The function $f=l\circ g$ have the desired properties.