[proofplan]
We prove the contrapositive by assuming that $f$ is not constant. Then two points of $X$ have distinct images in $Y$, and the $T_0$ property separates these two image points by an [open set](/page/Open%20Set) containing exactly one of them. Continuity pulls this open set back to an open subset of the indiscrete space $X$, but the preimage is simultaneously nonempty and proper, contradicting the fact that the only open subsets of $X$ are $\varnothing$ and $X$.
[/proofplan]
[step:Assume two domain points have distinct images]
Suppose, for contradiction, that $f$ is not constant. Since $f:X\to Y$ is a map and $X$ is nonempty, there exist points $x_1,x_2\in X$ such that $f(x_1)\neq f(x_2)$.
[guided]
To prove that $f$ is constant, we must show that every pair of points in $X$ has the same image. We argue by contradiction. Assume that $f$ is not constant. By the definition of a nonconstant map, there must be two points $x_1,x_2\in X$ such that their images are distinct:
\begin{align*}
f(x_1)\neq f(x_2).
\end{align*}
The hypothesis that $X$ is nonempty ensures that the domain is not vacuous, but the contradiction argument itself starts from the stronger assumption that such two points exist.
[/guided]
[/step]
[step:Use the $T_0$ property to separate the two image points]
Because $(Y,\tau_Y)$ is $T_0$ and $f(x_1)\neq f(x_2)$, there exists an open set $U\in\tau_Y$ such that either $f(x_1)\in U$ and $f(x_2)\notin U$, or $f(x_2)\in U$ and $f(x_1)\notin U$.
[/step]
[step:Pull the separating open set back to a nonempty proper subset of $X$]
Define the subset $A\subset X$ by
\begin{align*}
A:=f^{-1}(U)=\{x\in X:f(x)\in U\}.
\end{align*}
Since $U\in\tau_Y$ and $f:X\to Y$ is continuous, the preimage $A=f^{-1}(U)$ is open in the topology $\{\varnothing,X\}$ on $X$.
If $f(x_1)\in U$ and $f(x_2)\notin U$, then $x_1\in A$ and $x_2\notin A$. If $f(x_2)\in U$ and $f(x_1)\notin U$, then $x_2\in A$ and $x_1\notin A$. In either case, $A$ is nonempty and $A\neq X$.
[guided]
The open set $U$ lives in the codomain $Y$, so we convert it into a subset of the domain by taking its preimage. Define
\begin{align*}
A:=f^{-1}(U)=\{x\in X:f(x)\in U\}.
\end{align*}
Continuity of $f:X\to Y$ means precisely that the preimage of every open set in $Y$ is open in $X$. Since $U\in\tau_Y$, it follows that $A$ is open in $X$.
Now we record what the separation property tells us about $A$. If $f(x_1)\in U$ and $f(x_2)\notin U$, then by the definition of preimage we have $x_1\in A$ and $x_2\notin A$. Hence $A$ is nonempty, because it contains $x_1$, and $A$ is not all of $X$, because it does not contain $x_2$.
The other possible $T_0$ separation is symmetric: if $f(x_2)\in U$ and $f(x_1)\notin U$, then $x_2\in A$ and $x_1\notin A$. Again $A$ is nonempty and proper. Thus in every case,
\begin{align*}
\varnothing\subsetneq A\subsetneq X.
\end{align*}
[/guided]
[/step]
[step:Contradict the indiscrete topology and conclude constancy]
The topology on $X$ is the [indiscrete topology](/page/Indiscrete%20Topology) $\{\varnothing,X\}$. Therefore every open subset of $X$ is either $\varnothing$ or $X$. This contradicts the previous step, where $A=f^{-1}(U)$ was shown to be open, nonempty, and not equal to $X$.
Hence the assumption that $f$ is not constant is false. Therefore, for all $x_1,x_2\in X$, one has $f(x_1)=f(x_2)$, so $f$ is constant.
[/step]