Converse of contraction mapping theorem Let $(X,d)$ be a metric space such that, if $Y \subset X$ is closed, then every contraction mapping on $Y$ has a fixed point. Show that $X$ is complete.
This problem appeared in an exam and I attempted a solution, but admittedly was not able to get very far. I started by letting $X$ not be complete and considering a Cauchy sequence in $X$, $\lbrace y_n \rbrace \rightarrow y, y \notin X$. Then, maybe we could construct a contraction mapping which would have fixed point as $y$, i.e $f(y)=y$, and arrive at a contradiction that way.
 A: Suppose $X$ is not complete. Then, take a Cauchy sequence $(x_n)$ that does not converge in $X$. The set $Y = \{x_n : n \in \mathbb{N} \}$ is closed in $X$, so we will work on this subspace. To show $Y$ is closed, we show that the complement is open. So let $w \in X \setminus Y$ be any arbitrary point. If we can find an open ball center $w$ radious $\epsilon$, denote $B(w, \epsilon)$, that does not contain any points in $Y$, then there is nothing to do. Otherwise, if $w$ is chosen so that no such ball exists, then $w$ is a limit point of $(x_n)$, but this contradicts our choice of $(x_n)$! Hence, $Y$ is closed.
Now, we an always replace $(x_n)$ by a subsequence of itself. So WLOG, we can assume the elements of $x_n$ are all distinct, since we can always throw away duplicates. After that, lets replace it with this special subsequence $(y_n)$, which I will describe later. This special subsequence will be chosen so that the map $f(y_n) = y_{n+1}$ is a contraction map. Then by hypothesis, $f$ must have a fixed point, and it can't be any of the $y_n$ (because then $y_{n+1} = f(y_n) = y_n$ contradicts the distinctness of the sequence). Thus, $(y_n)$ has no fixed point, which contradicts the hypothesis.
Now, it remains to find this subsequence $(y_n)$, and show that $f$ is contraction map. The idea is that we want consecutive terms of $(y_n)$ to not be close to each other.
Take $y_1 = x_1$. Then let $\epsilon_1 = \inf\{ |x_1 - x_m| : m > 1 \}$. If $\epsilon_1 = 0$, then $y_1$ is the limit of $x_n$, so this Cauchy sequence has a limit. Otherwise, $\epsilon_1 > 0$. Then, by Cauchyness of $(x_n)$, you find $M$ sufficiently large so that for all $n, m \ge M$, $|x_n - x_m| \le \epsilon_1 / 6$. Then, discard all the elements $x_i$ with $2 \le i \le M$ from the sequence $(x_n)$. Now, with this modified $(x_n)$, we take $x_2$, and repeat the construction to inductively create a sequence, which we denote $(y_n)$.
Intuitively, what we have done is to modify $(x_n)$ so that $x_1$ is 'isolated', the remaining elements of $(x_n)$ are all clustered in some ball of radius at most $\epsilon_1 / 3$, and $x_1$ is at least distance $\epsilon_1$ away from this cluster. Try to draw a picture to see this.

Then now $f(y_n) = y_{n+1}$ is contraction, because for any $n, m$,
$$ |x_{n+1} - x_{m+1}| < \epsilon_n / 6 < \epsilon_n / 2 < \frac{1}{2} |x_n - x_m| $$
The first inequality is because $x_{n+1}$ and $x_{m+1}$ are contained in the ball constructed while choosing $x_n$. And so their distance is at most $\epsilon_n / 6$.
