Any compact, convex subset of $\mathbb{R}^n$ is a deformation retract of $\mathbb{R}^n$ I am looking at a question from Chapter 32 of Willard's General Topology:

Any compact, convex subset of $\mathbb{R}^n$ is a deformation retract of $\mathbb{R}^n$

I'm struggling to even know where to start with this exercise, as I don't have any intuition as to why compactness is related to (deformation) retracts.
I think I will need to use the following facts / definitions:

*

*Let $X := \mathbb{R}^n$. If $Y \subseteq X$ is convex, then any $f,g \in C(X,Y)$ are homotopic.

*A subset $A \subseteq X$ is a retract of $X$ if $\exists r \in C(X,A)$ such that $r(a) = a,$ for each $a \in A$. It is a deformation retract of $X$ if $r$ is homotopic (as a map into $X$) to $1_X$ (the identity function on $X$).

*A subset $E \subseteq X$ is compact if every cover of $E$ by open sets of $X$ has a finite subcover. (Edit: according to the comments, I probably want to use the fact that any compact subset of $\mathbb{R}^n$ is closed and bounded, instead).

Any help, including hints on how to begin approaching this question, is appreciated.

Edit: Based on a comment, I tried to show that the closed unit disk $D = \{ (x,y) \in \mathbb{R}^2: x^2 + y^2 \leq 1\}$ is a deformation retract of $\mathbb{R}^2$. I think I've shown that below, but I did not find this particularly illuminating, so I'm wondering if I've skipped over something or perhaps my "proof" of this is not correct.
$D$ is a compact, convex subset of $\mathbb{R}^2$ and the function $r: \mathbb{R}^2 \to D$ given by:
$r((x,y)) = \left\{
        \begin{array}{ll}
            (x,y) & \quad x^2+y^2 < 1 \\
            \big(\frac{x}{x^2 + y^2},\frac{y}{x^2+y^2}\big) & \quad x^2+y^2 \geq 1
        \end{array}
    \right.$
is a retraction, as $r(d) = d$ for each $d \in D$ and it is continuous. Indeed, $D$ is a deformation retract; if we view $r$ as a map from $\mathbb{R}^2 \to \mathbb{R}^2$, we see that it is continuous function from $\mathbb{R}^2$ into a convex subset (clearly $\mathbb{R}^2$ is a convex subset of itself) and so by Fact 1 above, any continuous function, including the identity function $1_{\mathbb{R}^2}$, is homotopic to $r$.
Any feedback on this first attempt would be appreciated, as I really don't see how this clarifies the more general situation.
 A: We shall generalize this by proving that

Any closed convex subset of $\mathbb R^n$ is a strong deformation retract of $\mathbb R^n$.

Let $C$ be a closed convex subset of $\mathbb R^n$. For each $x \notin C$ we have
$$d(x,C) = \inf\{\lVert x - y \rVert : y \in C \} > 0 ,$$
because otherwise we would find a sequence $(y_n)$ in $C$ such that $y_n \to x$. But then we would have $x \in C$ since $C$ is closed.
Note that the definition of $d(x,C)$ is based on the Euclidean norm. This will be essential for our proof. See the remark below.
There exists $y \in C$ such that $\lVert x - y \rVert = d(x,C)$. In fact, let $y_n \in C$ such that $\lVert x - y_n \rVert < d(x,C) + 1/n$. This sequence is bounded by $\lVert x \rVert + d(x,C) + 1$, thus has a convergent subsequence, so we may assume w.l.o.g. that $(y_n)$ converges to some $y \in \mathbb R^n$. Since $C$ is closed, we have $y \in C$ and $\lVert x - y \rVert = d(x,C)$.
We claim that $y$ is unique because $C$ is convex. So  assume that $y' \in C$ is point $y' \ne y$ such that $\lVert x - y \rVert = \lVert x - y' \rVert$. The points $x, y, y'$ span an affine Euclidean plane $E^2 \subset \mathbb R^n$ and form an isosceles triangle. The midpoint $y'' = 1/2 y + 1/2y'$ of the line segment between $y, y'$ is contained in $C$. The points $x,y, y''$ form a right-angled triangle, thus $\lVert x - y \rVert^2 = \lVert x - y'' \rVert^2 + \lVert y - y'' \rVert^2$ which gives  $\lVert x - y \rVert > \lVert x - y'' \rVert$, a contradiction.
Remark: As pointed out in a comment by copper.hat, we use a special property of the Euclidean norm $\lVert - \rVert$: It is strictly convex, which means that any closed ball $B$ is a strictly convex set in the sense that every point on the line segment connecting two points $x, y \in B$ other than the endpoints is inside the interior of $B$. I proved a special case of this (for the midpoint of the line segment) using the Pythagorean theorem. Note that other norms may not have this property.
Define
$$r : \mathbb R^n \to C, r(x) = \begin{cases} x  & x \in C \\ \text{unique } y \in C \text{ such that } \lVert x - y \rVert = d(x,C) & x \notin C  \end{cases}$$
Let us prove that $r$ is continuous (i.e. that $r$ is a retraction).
Continuity is obvious in all interior points of $C$.
Let us now consider a boundary point $\xi$ of $C$. Let $\epsilon > 0$ and $x \in \mathbb R^n$ such that $\lVert x - \xi \rVert < \epsilon/2$. We claim that $\lVert r(x) - r(\xi) \rVert = \lVert r(x) - \xi \rVert < \epsilon$. This is trivial for $x \in C$. For $x \notin C$ we have $\lVert r(x) - \xi \rVert \le \lVert r(x) - x \rVert + \lVert x - \xi \rVert = d(x,C) + \lVert x - \xi \rVert \le 2 \lVert x - \xi \rVert < \epsilon$.
Let us finally consider a point $\xi \notin C$. In the sequel it will be useful to draw pictures to understand geometrically what is going on.
We begin with a preparation. Let $P^{n-1}(x)$ denote the affine hyperplane which contains $r(x)$ and is orthogonal to the line through $x$ and $r(x)$ (i.e. $P^{n-1}(x) = \{r(x) + y : \langle y, x - r(x) \rangle = 0\}$ , where $\langle -, - \rangle$ denotes the standard inner product). This is the tangent hyperplane of the sphere $S^{n-1}(x;d(x,C))$ with center $x$ and radius $d(x,C)$ at the point $r(x)$. $P^{n-1}(x)$ divides $\mathbb R^n$ in two open half-spaces. Let $H^n(x)$ denote the open half-space containing $x$ (i.e. $H^n(x) = \{r(x) + y : \langle y, x - r(x) \rangle > 0\}$). We claim that $H^n(x) \cap C = \emptyset$. Assume there exists $y \in H^n(x) \cap C$. The points $x, r(x), y$ are contained in an affine Euclidean plane $E^2 \subset \mathbb R^n$ (if $y$ lies on the line through $x$ and $r(x)$, then $E^2$ is not unique, but that does not matter). The set $S' = E^2 \cap S^{n-1}(x;d(x,C))$ is a circle in $E^2$, and $L = E^2 \cap P(x)$ is the tangent line to $S'$ at $r(x)$. The circle $S'$ bounds the open disk $D^2(x,d(x,C)) \subset E^2$ with center $x$ and radius $d(x,C)$. Clearly $y \notin D^2(x,d(x,C))$ because otherwise $d(x,C) \le \lVert y - x \rVert < d(x,C)$. The line $L(y)$ through $y$ and $r(x)$ is different from $L$, thus $D^2(x,d(x,C)) \cap L(y)$ is non-empty. Let  $y' \in D^2(x,d(x,C)) \cap L(y)$. Since $y \notin D^2(x,d(x,C))$, the point $y'$ lies between $y$ and $r(x)$, thus $y' \in C$ because $C$ is convex. Therefore $d(x,C) \le d(x,y') < d(x,C)$, a contradiction.
Now let $ 0 < \epsilon \le d(x,C)$ and $x \in \mathbb R^n$ such that $\lVert x - \xi \rVert < \epsilon/2$. Note that this assures $x \in H^n(\xi)$. We claim that $\lVert r(x) - r(\xi) \rVert < \epsilon$. Let $\rho(x) \in P^{n-1}(\xi)$ be the unique point such that line $L_x$ through $x$ and $\rho(x)$ is orthogonal to $P^{n-1}(\xi)$. We have $\lVert \rho(x) - r(\xi) \rVert < \epsilon/2$: Note that in the quadrilateral with vertices $\xi, x, r(\xi), \rho(x)$ (which span an affine Euclidean plane $E^2 \subset \mathbb R^n$) the edges $\overline{\xi r(\xi)}$ and $\overline{x \rho(x)}$ are parallel with distance $\lVert \rho(x) - r(\xi) \rVert$, thus  $\lVert \rho(x) - r(\xi) \rVert \le$ length of the edge $\overline{x \xi}$ which is $\lVert x - \xi \rVert < \epsilon/2$. We have $d(x,C) \le d(x,r(\xi))$, thus $r(x)$ is contained in the closed ball $\bar D^n(x,d(x,r(\xi))) \subset \mathbb R^n$ with center $x$ and radius $d(x,r(\xi))$. Since $H^n(\xi) \cap C = \emptyset$, we must have $r(x) \in D' = \bar D^n(x,d(x,r(\xi))) \cap G^n(\xi)$, where $G^n(\xi) = \mathbb R^n \setminus H^n(\xi)$ is the closed half-space bounded by $H^{n-1}(\xi)$ and not containing $\xi$. The intersection $D'' = \bar D^n(x,d(x,r(\xi))) \cap P^{n-1}(\xi)$ is a closed ball in $P^{n-1}(\xi)$ with center $\rho(x)$ and radius $R = \lVert \rho(x) - r(\xi) \rVert < \epsilon$. Thus $D'$ is a spherical dome of $\bar D^n(x,d(x,r(\xi)))$ with base $D''$. The diameter of $D'$ equals the diameter of $D''$ which is $2R$. Thus $\lVert r(x) - r(\xi) \rVert \le 2R < \epsilon$.
$r$ is in fact a strong deformation retraction. Look at
$$H: \mathbb R^n \times I \to \mathbb R^n, H(x,t) = (1-t)x + tr(x) .$$
