To prove the dimension of a smooth manifold is well-defined, I need to prove that the composition of diffeomorphisms (defined between arbitrary subsets) is also a diffeomorphism. Could you have a check on my proof?
First, I recall related definitions to remove ambiguity.
Let $U \subseteq \mathbb{R}^{n}$ be open and $V \subseteq \mathbb R^m$. Then the concept of differentiability of $f: U \to V$ is well-defined.
Let $X \subseteq \mathbb{R}^{n}$ and $Y \subseteq \mathbb{R}^{m}$. A map $f: X \rightarrow Y$ is differentiable if $\forall x \in X, \exists$ an open subset $U \subseteq \mathbb{R}^{n}$ containing $x$ and a differentiable map $\tilde{f}: U \rightarrow \mathbb{R}^{m}$ such that $\tilde{f}$ and $f$ agree on $U \cap X$.
Let $X \subseteq \mathbb{R}^{n}$ and $Y \subseteq \mathbb{R}^{m}$. A differentiable map $f: X \rightarrow Y$ is called a diffeomorphism if it is bijective, and if its inverse $f^{-1}: Y \rightarrow X$ is also differentiable.
Let $X \subseteq \mathbb{R}^{n}$ and $Y \subseteq \mathbb{R}^{m}$. Then $X$ is diffeomorphic to $Y$ if there exists a diffeomorphism between them.
Theorem: Let $X \subseteq \mathbb R^m$, $Y \subseteq \mathbb R^n$, and $Z \subseteq \mathbb R^p$ such that $X$ and $Z$ are diffeomorphic to $Y$ respectively. Then $X$ is diffeomorphic to $Z$.
Proof: Let $f:X \to Y$ and $g:Y \to Z$ be diffeomorphisms. Let $h := g \circ f$. Clearly, $h$ is bijective. Let's prove that $h$ is differentiable.
Fix $x \in X$. There exist $U$ open in $\mathbb R^m$ and a differentiable map $\varphi: U \to \mathbb R^n$ such that $x \in U$ and $\varphi_{\restriction U \cap X} = f_{\restriction U \cap X}$.
Let $y := f(x) \in Y$. There exist $V$ open in $\mathbb R^n$ and a differentiable map $\psi: V \to \mathbb R^p$ such that $y \in V$ and $\psi_{\restriction V \cap Y} = g_{\restriction V \cap Y}$.
Let $U' := \varphi^{-1} (V)$. Then $U'$ is open in $\mathbb R^m$ and $x \in U'$. Let $U'' := U \cap U'$. Then $U''$ is open in $\mathbb R^m$ and $x \in U''$. Then $\phi:= \psi \circ \varphi_{\restriction U''}$ is a differentiable map from $U'' \subseteq \mathbb R^m$ to $\mathbb R^p$. If $x \in U'' \cap X$, then $x \in U \cap X$ and $f(x) \in V \cap Y$. This means $\phi(x) = \psi \circ \varphi_{\restriction U''} (x) = g \circ f (x) = h(x)$. It follows that $h$ is differentiable.
Similarly, we can show that $h^{-1} = f^{-1} \circ g^{-1}$ is differentiable. Then $h$ is indeed a diffeomorphism. This completes the proof.