is retract of a hausdorff space closed in that space? If $Z$ is a topological space, we call $Y\subset Z$ a retract of $Z$ if there is a continuous map $r:Z \rightarrow Y$ such that $r(y)=y$  for all $y\in Y $.
If $Z$ is Hausdorff and $Y$ a retract of $Z$ , why is $Y$ closed in $Z$?
This is a problem from Munkres' topology book and looks really easy but I don't know why I can't solve it! I thought we can prove $Z \setminus Y$ is open, but I couldn't.
Help please.
Thanks.
 A: For two maps $f,g:X→Y$ the so-called equalizer $\{x\in X\mid f(x)=g(x)\}$ is a closed subspace of $X$ if $Y$ is Hausdorff. This follows from the diagonal $\Delta_Y$ being closed in $Y\times Y$ and $(f,g):X→Y×Y$ being continuous.
Just take $f=\text{id}_Z$ and $g=r$ considered a map to $Z$ rather than $Y$. The equalizer is then the retract $Y$.
For a direct proof of $Y$ being closed, consider a point $z\in\partial Y$. If $r(z)\ne z$, then there are disjoint neighborhoods $U$ of $z$ and $V$ of $r(z)$. By continuity of $r$ there must be a neighborhood $W\subseteq U$ of $z$, so that $r[W]⊆V$. However $r[W\cap Y]$ is a non-empty subset of $W$, so it cannot be in $V$. Hence we must have $r(z)=z\in Y$.
A: Let $f: Z \to Z \times Z$ be given by $f(z)=\big(r(z),z \big)$. Since each coordinate is continuous, $f$ is a continuous map (notice that the first map is just the composition $i \circ r$, where $i$ inclusion of $Y$ in $Z$).
Since $Z$ is Hausdorff, the diagonal $\Delta=\left\{ (x,y) \in Z \times Z \, | \, x=y \right\} \subseteq Z \times Z$ is closed.
Hence, by continuity of $f$,
$$f^{-1}(\Delta)=\left\{ z \in Z \, | \, f(z) \in \Delta \right\} = \left\{ z \in Z \, | \, r(z)=z \right\} = \left\{ z \in Z \, | \, z \in Y \right\} = Y$$
is also closed.
Alternative: consider a net $(y_{\lambda})_{\lambda \in \Lambda}$ in Y that converges to a point $y \in Z$. Our aim is to show that $y$ lies in $Y$.
By continuity of $r$, we must have $y_\lambda = r(y_\lambda) \to r(y)$.
Since $Z$ is Hausdorff, by the uniqueness of the limit, we must have $y=r(y)$ which lies in $Y$.
