[proofplan]
The forward implication uses the defining property of the [discrete topology](/page/Discrete%20Topology): every singleton in $Y$ is open. Continuity then makes the fiber over $f(x)$ an open neighborhood of $x$, and this fiber is a neighborhood on which $f$ is constant. Conversely, if $f$ is locally constant, then the preimage of any subset of $Y$ is open because each of its points has an open neighborhood on which $f$ stays inside that subset.
[/proofplan]
[step:Use continuity to make each fiber an open constant neighborhood]
Assume $f$ is continuous. Let $x\in X$. Since $Y$ has the discrete topology, the singleton $\{f(x)\}\subset Y$ is open in $Y$. By continuity of $f$, the preimage
\begin{align*}
V_x:=f^{-1}(\{f(x)\})
\end{align*}
belongs to $\tau_X$. Since $f(x)\in \{f(x)\}$, we have $x\in V_x$. Moreover, if $z\in V_x$, then $f(z)=f(x)$ by the definition of preimage. Hence $f|_{V_x}$ is constant with value $f(x)$. Therefore $f$ is locally constant.
[/step]
[step:Use local constancy to prove every preimage of an open set is open]
Assume $f$ is locally constant. Let $U\in\tau_Y$ be arbitrary. Since $\tau_Y=\mathcal{P}(Y)$, this is the same as taking an arbitrary subset $U\subset Y$. Define
\begin{align*}
A:=f^{-1}(U)\subset X.
\end{align*}
We prove that $A$ is open in $X$.
Let $x\in A$. By local constancy, there exists an [open set](/page/Open%20Set) $V_x\in\tau_X$ with $x\in V_x$ such that $f|_{V_x}$ is constant. Since $x\in A$, we have $f(x)\in U$. For every $z\in V_x$, constancy of $f|_{V_x}$ gives $f(z)=f(x)$, hence $f(z)\in U$. Thus $V_x\subset A$.
It follows that every point of $A$ is contained in an open subset of $X$ lying inside $A$. Equivalently,
\begin{align*}
A=\bigcup\{V\in\tau_X:V\subset A\}.
\end{align*}
The right-hand side is a union of open sets, so it belongs to $\tau_X$. Therefore $f^{-1}(U)$ is open in $X$.
[guided]
Assume $f$ is locally constant, and let $U\in\tau_Y$ be an arbitrary open subset of $Y$. Because $Y$ has the discrete topology, every subset of $Y$ is open; however, for continuity we only need to show that the preimage of this arbitrary open set is open in $X$.
Define the subset
\begin{align*}
A:=f^{-1}(U)\subset X.
\end{align*}
To prove that $A$ is open, it is enough to show that each point of $A$ has an open neighborhood contained in $A$. Let $x\in A$. The condition $x\in A$ means exactly that $f(x)\in U$.
Now use local constancy at this point $x$. There exists an open set $V_x\in\tau_X$ with $x\in V_x$ such that $f|_{V_x}$ is constant. Since $f|_{V_x}$ is constant and $x\in V_x$, every point $z\in V_x$ satisfies
\begin{align*}
f(z)=f(x).
\end{align*}
Because $f(x)\in U$, this equality implies $f(z)\in U$ for every $z\in V_x$. Therefore $z\in f^{-1}(U)=A$ for every $z\in V_x$, so
\begin{align*}
V_x\subset A.
\end{align*}
Thus every point $x\in A$ lies in some open set $V_x$ contained in $A$. This shows that $A$ is the union of all open subsets of $X$ that are contained in $A$:
\begin{align*}
A=\bigcup\{V\in\tau_X:V\subset A\}.
\end{align*}
A union of open sets is open in a topology, so $A\in\tau_X$. Since $A=f^{-1}(U)$, the preimage of the arbitrary open set $U$ is open. Hence $f$ is continuous.
[/guided]
[/step]
[step:Combine the two implications]
The first step proves that continuity of $f$ implies local constancy. The second step proves that local constancy of $f$ implies continuity. Therefore $f$ is continuous if and only if $f$ is locally constant.
[/step]