Smooth invariance of domain This is Theorem 22.3 in Tu's textbook. There are a multiple of similar questions, but all answers seemed unsatisfactory for me. (One of them used algebraic topology result, but I am unfamiliar with the subject.)
Theorem: Let $U$ be an open subset, $S \subset \mathbb R^n$ an arbitrary, and $f: U \rightarrow S$ a diffeomorphism. Then $S$ is open in $\mathbb R^n$.
Proof: Let $f(p)$ be an arbitrary point in $S$ with $p \in U$. Since $f$ is a diffeomorphism, there is an open set $V \subset \mathbb R^n$ containing $S$ and a smooth map $g: V \rightarrow \mathbb R^n$ such that $g|_S = f^{-1}$.
I am not sure why the bolded statement is true. I agree that $f(U) \subset S$ is open in $S$, but why does it guarantee the existence of such $g$? If $S$ were a closed set, I may extend $f^{-1}: S \rightarrow U$ to $\tilde g: V \supset S \rightarrow U$ with $\tilde{g}|_S = f^{-1}$ using partition of unity, but there is no assumption about $S$.
 A: This is a comment but its to long for a comment.
You have to ask yourself what does it mean for a function to be smooth for arbitrary sets of $\mathbb{R}^n$? one possible definition given in the appendix of Lee introduction to smooth manifolds goes as follows
We sometimes need to consider smoothness of functions whose domains are subsets of
$\mathbb{R}^{n}$ that are not open. If $A \subseteq \mathbb{R}^{n}$ is an arbitrary subset, a function $F: A \rightarrow \mathbb{R}^{m}$ is said to be smooth on $A$ if it admits a smooth extension to an open neighborhood of each point, or more precisely, if for every $x \in A,$ there exist an open subset $U_{x} \subseteq \mathbb{R}^{n}$ containing $x$ and a smooth function $\widetilde{F}: U_{x} \rightarrow \mathbb{R}^{m}$ that agrees with $F$ on $U_{x} \cap A .$ The notion of diffeomorphism extends to arbitrary subsets in the obvious way: given arbitrary subsets $A, B \subseteq \mathbb{R}^{n},$ a diffeomorphism from $A$ to $B$ is a smooth bijective map $f: A \rightarrow B$ with smooth inverse.
You can use partition of unity to construct $g$
