I want to prove this proposition:
Proposition: Let $M$ be a smooth manifold that is Hausdorff and $2^{nd}$ countable. Let $U \subseteq M$ be open and let $p \in U$ be some point. If $f : U \longrightarrow \mathbb{R}$ is a smooth function, then there exists another smooth function $\widetilde{f} : M \longrightarrow \mathbb{R}$ such that $f$ and $\widetilde{f}$ coincide in a neighbourhood of $p$.
Now my (attempt at a) proof is as follows:
1.) $\enspace$ Let $(\varphi, V)$ be a chart around $p$. Then $(\varphi, U \cap V)$ is also a chart around $p$ and w.l.o.g. let $\varphi(p) = 0$.
2.) $\enspace$ Choose an open ball $B_r(0)$ around $\varphi(p) = 0$ in the coordinate space such that $\overline{B_r(0)} \subseteq \varphi(U \cap V)$.
3.) $\enspace$ Then the preimage $\varphi^{-1} \Big( \overline{B_r(0)} \Big) = : W$ is closed in $M$.
Here I make use of a lemma stating the following:
Lemma: If $\mathcal{O}$ is an open subset of $M$ and $W \subseteq \mathcal{O}$ is closed, then there exists a smooth function $g : M \longrightarrow \mathbb{R}$ such that $g \, |_{W} = 1$ and $g \, |_{M \backslash \mathcal{O}} = 0$.
4.) $\enspace$ Identifying $\mathcal{O} = U \cap V$, I now set the function $\widetilde{f}$ to be
$$ \widetilde{f}(p) \enspace = \enspace \begin{cases} g(p) \cdot f(p) \enspace , & \quad p \in U \cap V \\ {} & \\ 0 \enspace , & \quad p \in (U \cap V)^c \end{cases} $$
5.) $\enspace$ By what has been said so far, one knows that:
$$ \widetilde{f} \, |_W \enspace = \enspace \underbrace{g \, |_W}_{= \, 1} \cdot f \, |_W \enspace = \enspace f \, |_W \quad , \qquad \widetilde{f} \, |_{(U \cap V)^c} \enspace = \enspace g \, |_{(U \cap V)^c} \enspace = \enspace 0$$
The (closed) subset $W$ is the set on which the function $\widetilde{f}$ coincides with $f$ as desired. Products of smooth functions are smooth again and so the first "case" of $\widetilde{f}$ is smooth. Trivially, the second "case" of $\widetilde{f}$ is also smooth.
The question is: How do I proof smoothness at the boundary of $U \cap V$, i.e. on the set where these two cases "meet"? To be more specific: $g$ goes to zero when approaching the boundary of $U \cap V$ but $f$ could be diverging there and could consequently cancel the "cutoff" that $g$ provides, right? How can this be prevented?
EDIT 1:
By suggestion of peek-a-boo (provided that I did understand his hint correctly), I revise my reasoning as follows:
1.) $\enspace$ see above.
2.) $\enspace$ Choose an open ball $B_r(0) \subseteq \varphi(U \cap V)$ around $\varphi(p) = 0$ such that $B_r(0) \cap \partial \varphi(U \cap V) = \emptyset$ and choose another ball $B_{r/2}(0)$.
3.) $\enspace$ The preimage $\varphi^{-1} \Big( B_r(0) \Big) =: \mathcal{O}$ is open in $M$ and the preimage $\varphi^{-1} \Big( \overline{B_{r/2}(0)} \Big) =: W$ is closed in $M$ with $W \subseteq \mathcal{O}$ and most importantly
$$\mathcal{O} \cap \partial(U \cap V) \enspace = \enspace \emptyset \quad \overset{\mathcal{O} \subseteq U \cap V}{\Longrightarrow} \quad \mathcal{O} \cap \partial U \enspace = \enspace \emptyset$$
4.) $\enspace$ Now use the lemma, and define
$$ \widetilde{f}(p) \enspace = \enspace \begin{cases} g(p) \cdot f(p) \enspace , & \quad p \in \mathcal{O} \\ {} & \\ 0 \enspace , & \quad p \in M \backslash \mathcal{O} \end{cases} $$
5.) $\enspace$ By what has been said so far, one knows that:
$$ \widetilde{f} \, |_W \enspace = \enspace \underbrace{g \, |_W}_{= \, 1} \cdot f \, |_W \enspace = \enspace f \, |_W \quad , \qquad \widetilde{f} \, |_{ M \backslash \mathcal{O}} \enspace = \enspace g \, |_{ M \backslash \mathcal{O}} \enspace = \enspace 0$$
6.) $\enspace$ The function $f$ can only diverge on the boundary of $U$, otherwise there would be points in $U$ at which $f$ is not defined, contradicting the definition of $f$ as a function $f : U \longrightarrow \mathbb{R}$. So $f$ does not diverge on $\mathcal{O} \subseteq U$. Therefore, the product $g \cdot f$ does indeed provide a cutoff at the boundary of $\mathcal{O}$ - and so $\widetilde{f}$ is smooth everywhere.