Is this space contractible? Let $X$ be the following topological space (with the subspace topology): Connect the rational points of $([0,1]\cap \mathbb{Q})\times \{0\}$ with the point $(0,1)$ and connect the points of $([-1,0]\cap \mathbb{Q})\times \{1\}$ with $(0,0)$, as shown in the figure. Is $X$ contractible?   

 A: Let's first restrict the study to a simple class of continuous functions.
A continuous function $f : X \rightarrow X$ is "simple" if $\forall y \in [0;1], \exists y' \in [0;1]$ such that :


*

*$f(0,y) = (0,y')$

*$\forall q \in [0;1] \cap \mathbb{Q}, f(-qy,y) = (-qy',y')$ or $\forall q \in [0;1] \cap \mathbb{Q}, f(-qy,y) = (0,y')$

*$\forall q \in [0;1] \cap \mathbb{Q}, f(q(1-y),y) = (q(1-y'),y')$ or $\forall q \in [0;1] \cap \mathbb{Q}, f(q(1-y),y) = (0,y')$


This means that the image of a point $x$ in the central segment is a point $f(x)$ on the central segment, the points to its left are either sent to the corresponding points on the left of $f(x)$ or all equal to $f(x)$, and the same with points on the right.
Call $\hom_S(X,X)$ the set of simple maps.
I could define a more general class of simple maps for example by allowing points on the left to be sent to points on the right, but it would only make things more complicated, and it's unneeded because this will be enough to separate the identity map from a constant map.
The identity map $id_X$, and the constant map $k : x \rightarrow (0,1/2)$ are in $\hom_S(X,X)$
Surely, if I want to prove that $X$ is not contractible, it is at least as hard as proving that it is not contractible with a homotopy that only uses simple maps. So, let's prove that there is no homotopy of simple maps between $id_X$ and $k$.

In order to do that, I show that $\hom_S(X,X)$ is "homeomorphic" to a subset of $\hom([0;1],S^1)$ :
For $f : [0;1] \rightarrow S^1$, define $\phi(f) \in \hom_S(X,X)$ with :
$$\phi(f)(0,y) = \left\{\begin{array}{ll}(0,2f(y)/\pi) & \text{for} f(y) \in [0; \pi/2] \\
 (0,2-2f(y)/\pi) & \text{for} f(y) \in [\pi/2; \pi] \\
 (0,2f(y)/\pi-2) & \text{for} f(y) \in [\pi; 3\pi/2] \\
 (0,4-2f(y)/\pi) & \text{for} f(y) \in [3\pi/2; 2\pi]\end{array} \right. $$ 
the points on the left of $(0,y)$ are taken to the points on the left of $f(0,y)$ if $\theta \in [0; \pi]$, are sent to $f(0,y)$ otherwise ;
the points on the right of $(0,y)$ are taken to the points on the right of $f(0,y)$ if $\theta \in [-\pi/2; \pi/2]$, are sent to $f(0,y)$ otherwise.
It is easy to check that $\phi(f)$ is continuous if and only if $f(0) \notin [0; \pi]$ and
 $f(1) \notin [-\pi/2; \pi/2]$. If I call $\hom_S([0;1],S^1)$ the subset of functions with this property, $\phi$ is a bijection from $\hom_S([0;1],S^1)$ into $\hom_S(X,X)$ that conserves homotopies.

Now we have to study homotopies in $\hom_S([0;1],S^1)$.
For $f \in \hom_S([0;1],S^1)$, define $w(f) = $ the number of times the function winds up from $0$ to $\pi/2$. More precisely, define 
$\alpha : S^1 \rightarrow S^1 : \theta \rightarrow 4\theta$ for $\theta \in [0;\pi/2]$ and $0$ otherwise.
$\forall f \in \hom_S([0;1],S^1), (\alpha \circ f)(0) = (\alpha \circ f)(1) = 0$, so we can quotient that map and get a function $\hat{f} : S^1 \rightarrow S^1$.
Then define $w(f)$ as the winding number of $\hat{f}$.
$w$ is a homotopic invariant (in fact it completely describes homotopy inside $\hom_S(X,X)$), but $w(\phi^{-1}(id_X)) = 1$ while $w(\phi^{-1}(k)) = 0$. Therefore $id_X$ and $k$ are not homotopic inside $\hom_S(X,X)$

Now what is left is to show that if there is a homotopy using any continuous maps, then there is one that only uses simple maps.
To do that, I need an approximation map $\psi : \hom(X,X) \rightarrow \hom_S (X,X)$ that push forward homotopies.
First, define $\psi(f)(0,y) = (0,y')$ where $(x',y') = f(0,y)$.
If $x' \neq 0$, send all the points on the left/right side of $(0,y)$ into $(0,y')$ as well.
Otherwise, we need to decide when to send the points on the left/right side of $(0,y)$ on the left/right side of $f(0,y)$. There are uncountably many ways to do it, so let's arbitrarily settle it with this :
For $y \in [0;1]$, define $P_l(y) = \exists x_1,x_2,\ldots x_n \ldots < 0, \lim x_n = 0$, and $f(x_n,y)$ are on the (strictly) left half of $X$,
and similarly $P_r(y) = \exists x_1,x_2,\ldots x_n \ldots > 0, \lim x_n = 0$, and $f(x_n,y)$ are on the (strictly) right half of $X$.
Then, send the points on the left (resp. right) side of $(0,y)$ on the left (resp. right) of $\psi(f)(0,y)$ if and only if $P_l(y)$ (resp. $Pr(y)$) is true.
It is important to note that $P_l(0)$ and $P_r(1)$ are always false.
Now I have to prove that not only $\psi(f)$ is continuous, but that for any homotopy $h : [0;1] \times X \rightarrow X$, the map $\psi(h) : [0;1] \times X \rightarrow X$ is a homotopy of simple maps.
Suppose $(t_n,y_n) \rightarrow (t,y)$ in $[0;1]\times[0;1]$. 
Call $(x'_n,y'_n) = h(t_n,(0,y_n))$ and $(x',y') = h(t,(0,y))$.
First, $h(t_n,(0,y_n)) \rightarrow (x',y') = h(t,(0,y))$.
This shows that $\psi(h)(t_n,(0,y_n)) \rightarrow (0,y') = \psi(h)(t,(0,y))$.
If $x' \neq 0$, then eventually neither are the $x'_n$ so $\psi(h)(t_n,(x_n,y_n)) = (0,y'_n) \rightarrow (0,y') = \psi(h)(t,(x,y))$, for any sequence $x_n \rightarrow x$.
If $y' \notin \{0;1\}$ then there is a neighbourhood of $(0,y')$ in $X$ where the diagonal lines are all disconnected from each other, so for $n$ large enough, the points on the diagonal lines near $(0,y)$ who are sent on the diagonal lines near $(0,y')$ are stuck there, so eventually $P_l$ and $P_r$ will not change.
This also means that if $y=0$ (resp. $y=1$), $P_l$ (resp. $P_r$) must eventually be false.
So there is no obstruction and $\psi(h)(t_n,(x_n,y_n)) \rightarrow \psi(h)(t,(x,y))$ for any sequence $x_n \rightarrow x$.
The only troublesome points are when $y' = 0$ or $y' = 1$.
For example, if $y' = 0$, then $P_r$ will not change for the same reason as stated above, so $\psi(h)(t_n,(x_n,y_n)) \rightarrow (0,y') = \psi(h)(t,(x,y))$ for any positive sequence $x_n \rightarrow x$.
For the points on the left, since $y'_n \rightarrow 0$, whatever $P_l(y_n)$ is and for any negative sequence $x_n \rightarrow x$, $\psi(h)(t_n,(x_n,y_n)) \rightarrow (0,0) = \psi(h)(t,(x,y))$ .
The case $y' = 1$ is similar, and this proves that the approximation map $\phi$ transport homotopies in $\hom(X,X)$ into homotopies in $\hom_S(X,X)$ (though it doesn't pull back homotopies at all).
Since $id_X$ and $k$ were not homotopic in $\hom_S(X,X)$, they are not homotopic in $\hom(X,X)$, which shows that $X$ is not contractible.
