I'm working with the following problem:
Let $M$ be a manifold and $\varphi : S \to M$ be an injective immersion. Show that $\varphi$ is an embedding if and only if every smooth function $f : S \to R$ has an extension to a neighborhood $U$ of $\varphi(S)$.
I proved the one-sided part using a partition of unity. My difficulty is the other side that is, if every smooth function $f : S \to R$ has an extension to a neighborhood $U$ of $\varphi(S)$, then $\varphi$ is an embedding. Please provide me some hints.
If it is not an embedding, then there is a point $x\in S$ s.t. $$B^M(\phi(x),\frac{1}{n}) \bigcap \phi (S)$$ is not homeomorphic to $k$-dimensional closed ball, where ${\rm dim}\ S=k$. That is, there is a point $x_n\in S$ s.t. $d_M(\phi(x_n),\phi(x)) < \frac{1}{n}$ and $d_S(x_n,x)\geq 1$.
If $x_n\rightarrow x_\infty$, then define a function $f$ : $f(x_\infty)=1$ and $f=0$ on $B^S(x_\infty,1)^c$.
If $d_S(x_i,x_j)>2$ for $i\neq j$, then $f(x_i)=1$ and $f=0$ on $\bigg(\bigcup_i\ B^S(x_i,\frac{1}{2}) \bigg)^c$.
If $f$ has an extension, then $f(x)=1$, since $\phi(x_n)\rightarrow \phi(x)$. It is a contradiction.
[Add] To distinguish immersion and embedding, we must consider at a point. If $\phi : S\rightarrow M$ where $S,\ M$ are differentiable manifolds, then there is a differential chart so that we can assume that $\phi : \mathbb{R}^k\rightarrow \mathbb{R}^n$. Euclidean space has a topology induced from metric so that the above holds.