I am reading "Topology Second Edition" by James R. Munkres.
The author wrote as follows:
EXAMPLE 1. Let $X$ be the subspace $[0,1]\cup [2,3]$ of $\mathbb{R}$, and let $Y$ be the subspace $[0,2]$ of $\mathbb{R}$. The map $p:X\to Y$ defined by \begin{equation} p(x)= \begin{cases} x & \text{for $x\in [0,1]$,} \\ x-1 & \text{for $x\in [2,3]$} \end{cases} \end{equation} is readily seen to be surjective, continuous, and closed.
I could readily see to be surjective.
But I could not readily see to be continuous, and closed.
My proof is the following:
Let $y\in [0,2]$.
If $y=1$, then $p(1)=p(2)=1$.
If $y\in [0,1)$, then $p(y)=y$.
If $y\in (1,2]$, then $p(y+1)=y$.
So, $p$ is surjective.
By elementary set theory, $p^{-1}(A\cup B\cup C\cup\dots)=p^{-1}(A)\cup p^{-1}(B)\cup p^{-1}(C)\cup\dots$ holds.
Let $U$ be an arbitrary open set in $\mathbb{R}$.
Let $U+1:=\{y+1:y\in U\}$.
Then, $U+1$ is open in $\mathbb{R}$.
If $1\in U$, then $$p^{-1}(U\cap [0,2])=p^{-1}(U\cap [0,1))\cup p^{-1}(U\cap \{1\})\cup p^{-1}(U\cap (1,2])\\=(U\cap [0,1))\cup(\{1,2\})\cup ((U+1)\cap (2,3])\\=(U\cap [0,1))\cup(\{1\})\cup ((U+1)\cap (2,3])\cup (\{2\})\\=(U\cap [0,1])\cup ((U+1)\cap [2,3])\\=[(U\cap (-1,1.5))\cap ([0,1]\cup [2,3])]\cup [((U+1)\cap (1.5,4))\cap ([0,1]\cup [2,3])].$$
And $[(U\cap (-1,1.5))\cap ([0,1]\cup [2,3])]\cup [((U+1)\cap (1.5,4))\cap ([0,1]\cup [2,3])]$ is open in $X$.
If $1\notin U$, then $$p^{-1}(U\cap [0,2])=p^{-1}(U\cap [0,1))\cup p^{-1}(U\cap \{1\})\cup p^{-1}(U\cap (1,2])\\=(U\cap [0,1))\cup ((U+1)\cap (2,3])\\=[(U\cap (-1,1))\cap ([0,1]\cup [2,3])]\cup [((U+1)\cap (2,4))\cap ([0,1]\cup [2,3])].$$
And $[(U\cap (-1,1))\cap ([0,1]\cup [2,3])]\cup [((U+1)\cap (2,4))\cap ([0,1]\cup [2,3])]$ is open in $X$.
By elementary set theory, $p(A\cup B\cup C\cup\dots)=p(A)\cup p(B)\cup p(C)\cup\dots$ holds.
Let $A$ be an arbitrary closed set in $\mathbb{R}$.
Let $A-1:=\{y-1:y\in A\}$.
Then, $A-1$ is closed in $\mathbb{R}$.
$$p(A\cap([0,1]\cup[2,3]))=p(A\cap[0,1])\cup p(A\cap[2,3])\\=(A\cap[0,1])\cup((A-1)\cap[1,2])\\=[(A\cap[0,1])\cap[0,2])]\cup[((A-1)\cap[1,2])\cap[0,2]].$$
And $[(A\cap[0,1])\cap[0,2])]\cup[((A-1)\cap[1,2])\cap[0,2]]$ is closed in $Y$.
Is there any very short proof of these facts?