TITLE: Idempotents split in category of smooth manifolds?
QUESTION [20 upvotes]: In his paper "Qualitative Distinctions Between Some Toposes of Generalized Graphs" (reproduced here), page 267, Lawvere says that the idempotent-splitting completion of the category of open sets of Euclidean spaces $\mathbb{R}^n$ and smooth maps between them is the category of smooth (second-countable, Hausdorff) manifolds and smooth maps. 
It's not very hard to see that every smooth manifold is a smooth retract of such an open set, so that the category of smooth manifolds embeds fully and faithfully in the idempotent-splitting completion. However, I haven't been able to find a proof of the converse, that every smooth retract of an open set is in fact a smooth manifold. Equivalently: if $p: U \to U$ is a smooth map on an open set $U$ of $\mathbb{R}^n$ such that $p \circ p = p$, then the fixed-point set $Fix(p) = \{x \in U: p(x) = x\}$ admits a smooth structure so that the inclusion $Fix(p) \hookrightarrow U$ is a smooth embedding. Can someone provide details of a proof?

REPLY [15 votes]: Assume that:
$$0\in Fix(p)$$
and $U$ is a small neighborhood of $0$.
Let $$f(x)=x-p(x)$$
Identifying $\mathbb R^n$ with $T_0\mathbb R^n$, set $\pi_{\mathrm{ker}(dp(0))}$ to be the projection $\mathbb R^n\to\mathrm{ker}(dp(0))$. 
Then $g=\pi_{\mathrm{ker}(dp(0))}\circ f$ is smooth and regular at $0$, so $M=g^{-1}(0)$ is a manifold of dimension equal to the rank of $dp(0)$. 
By construction, $M$ contains $Fix(p)$. 
On the other hand, since $Fix(p)$ is the image of $p$, $p$ preserves $M$. 
Thus, $p|_M$ is a smooth retraction of full rank on $M$. In particular, it's a local diffeomorphism (since it has full rank), and since it's a retraction and we're working in a small neighborhood of $0$, it's the identity.