Is restriction of smooth functions to an open submanifold epimorphic? I learned recently that restricting smooth functions from a manifold $M$ to a closed submanifold $X$ is a surjective ring homomorphism, which is reminiscent of how (to my understanding) closed subschemes of $\operatorname{Spec} A$ are defined as quotient rings of $A$, i.e surjections out of $A$. Also for affine schemes, restricting regular functions from $\operatorname{Spec} A$ to an open subscheme is not a ring surjection but is always a localisation homomorphism, and hence an epimorphism.
My question is, does a similar result hold for open submanifolds? That is, does restricting smooth functions from a manifold $M$ to some open $U$ give an epimorphism - either in general or for some class of manifolds? To be honest I'm not sure what the most appropriate category to use would be, e.g I can imagine the restriction being an epimorphism in $\mathbb{R}$-Alg but not CRing or something. Any insight would be appreciated.
 A: If $M$ is a smooth manifold and $U\subseteq M$ is open, then the restriction map $r:C^\infty(M)\to C^\infty(U)$ is an epimorphism of rings.  Indeed, I claim that $C^\infty(U)$ is generated as a ring by elements of the image of $r$ and their inverses.
Here's the idea for how to prove this.  For a given $f\in C^\infty(U)$, take $g\in C^\infty(U)$ such that $g$ and its derivatives go to $\infty$ much faster than $f$ as you approach the boundary of $U$.  Then $1/g$ will extend smoothly to all of $M$ by setting it equal to $0$ outside of $U$, and so will $1/(g+f)$.  So, both $g$ and $g+f$ are inverses of elements of the image of $r$, and $f$ is their difference.
Now, it takes some work to actually show that an appropriate smooth function $g$ exists.  To sketch the construction, let $(\varphi_i)$ be a partition of unity on $U$ where each $\varphi_i$ has compact support.  Then you can take $1/g=\sum_ic_i\varphi_i$ where $c_i$ is a sequence of positive constants that shrinks sufficiently fast, where you use choose the $c_i$ one by one to make sure that each of the derivatives of both $1/g$ and $1/(g+f)$ go to $0$ as you approach the boundary of $U$.
(In fact, it follows similarly that $r$ is actually a localization.  The argument above shows that if $S\subseteq C^\infty(M)$ is the set of functions that do not vanish on $U$, then $r$ induces a surjection $C^\infty(M)[S^{-1}]\to C^\infty(U)$.  To see that this map is also injective, note that if $f\in C^\infty(M)$ vanishes on $U$, then $fg=0$ where $g$ is any function with $g^{-1}(\{0\})=M\setminus U$.  Such a $g$ is in $S$, and so $f$ already maps to $0$ in the localization $C^\infty(M)[S^{-1}]$.)
