[proofplan]
We first show that the assignment $[x] \mapsto [f(x)]$ is well defined on path components by transporting a path in $X$ through $f$ to obtain a path in $Y$. The three functoriality properties then follow: homotopy invariance comes from evaluating a homotopy $H: X \times I \to Y$ on the slice $\{x\} \times I$ to obtain a path from $f(x)$ to $g(x)$; the composition and identity laws reduce to pointwise identities of representatives. The continuity of $f$ enters precisely once — in verifying that $f$ maps paths to paths.
[/proofplan]
[step:Verify that $\pi_0(f)$ is well defined on path components]
Let $[x] = [y]$ in $\pi_0(X)$, i.e., $x$ and $y$ lie in the same path component of $X$. By the definition of $\pi_0$, there exists a [path](/pages/Path) $\gamma: I \to X$ with $\gamma(0) = x$ and $\gamma(1) = y$, where $I = [0, 1]$. Consider the composition
\begin{align*}
f \circ \gamma: I &\to Y \\
t &\mapsto f(\gamma(t)).
\end{align*}
The composition of continuous maps is continuous, so $f \circ \gamma$ is a continuous map $I \to Y$ — that is, a path in $Y$. Its endpoints are
\begin{align*}
(f \circ \gamma)(0) = f(\gamma(0)) = f(x), \qquad (f \circ \gamma)(1) = f(\gamma(1)) = f(y).
\end{align*}
Therefore $f(x)$ and $f(y)$ lie in the same path component of $Y$, i.e., $[f(x)] = [f(y)]$ in $\pi_0(Y)$. The assignment $[x] \mapsto [f(x)]$ thus depends only on the class of $x$, so
\begin{align*}
\pi_0(f): \pi_0(X) &\to \pi_0(Y), \\
[x] &\mapsto [f(x)]
\end{align*}
is a well-defined function.
[guided]
We have to check that the formula $\pi_0(f)([x]) := [f(x)]$ does not depend on the choice of representative $x$. Suppose we pick a different representative $y$ for the same class, so $[x] = [y]$. By the [definition of $\pi_0$](/pages/Pi%20Zero), this means there is a path $\gamma: I \to X$ connecting $x$ to $y$, i.e., a continuous map $\gamma: I \to X$ with $\gamma(0) = x$ and $\gamma(1) = y$.
We need to produce a path from $f(x)$ to $f(y)$ in $Y$. The natural candidate is the composition
\begin{align*}
f \circ \gamma: I &\to Y \\
t &\mapsto f(\gamma(t)).
\end{align*}
Is this actually a path? A path in $Y$ is a continuous map $I \to Y$. Continuity follows because $\gamma$ is continuous (it is a path) and $f$ is continuous (it is the given map), and compositions of continuous maps are continuous. Its endpoints are
\begin{align*}
(f \circ \gamma)(0) = f(\gamma(0)) = f(x), \qquad (f \circ \gamma)(1) = f(\gamma(1)) = f(y),
\end{align*}
so $f \circ \gamma$ is a path from $f(x)$ to $f(y)$. This shows $[f(x)] = [f(y)]$ in $\pi_0(Y)$.
Why does this step consume the continuity of $f$? The set-theoretic formula $[x] \mapsto [f(x)]$ makes sense for any function $f$. But without continuity, $f \circ \gamma$ need not be continuous, and we would have no way to link $f(x)$ and $f(y)$ by a path. Continuity of $f$ is exactly what guarantees that $f$ carries paths to paths.
[/guided]
[/step]
[step:Verify homotopy invariance]
Suppose $f \simeq g$ via a [homotopy](/pages/Homotopy) $H: X \times I \to Y$ with $H(x, 0) = f(x)$ and $H(x, 1) = g(x)$ for all $x \in X$. Fix $x \in X$ and define
\begin{align*}
\alpha_x: I &\to Y \\
t &\mapsto H(x, t).
\end{align*}
The map $\alpha_x$ is the composition of the continuous inclusion $I \to X \times I$, $t \mapsto (x, t)$, with the continuous map $H$, hence continuous. Its endpoints are $\alpha_x(0) = H(x, 0) = f(x)$ and $\alpha_x(1) = H(x, 1) = g(x)$, so $\alpha_x$ is a path from $f(x)$ to $g(x)$ in $Y$. Therefore $[f(x)] = [g(x)]$ in $\pi_0(Y)$ for every $x \in X$, which gives
\begin{align*}
\pi_0(f)([x]) = [f(x)] = [g(x)] = \pi_0(g)([x]) \qquad \text{for every } [x] \in \pi_0(X).
\end{align*}
Hence $\pi_0(f) = \pi_0(g)$.
[guided]
We want to show that if $f$ and $g$ are homotopic then the induced functions on $\pi_0$ agree. By hypothesis there is a continuous map $H: X \times I \to Y$ with $H|_{X \times \{0\}} = f$ and $H|_{X \times \{1\}} = g$.
What does $H$ give us at a single point $x \in X$? If we freeze the first coordinate at $x$ and let the second vary, we get a map
\begin{align*}
\alpha_x: I &\to Y \\
t &\mapsto H(x, t).
\end{align*}
This is the **track** of $x$ under the homotopy. We must verify $\alpha_x$ is continuous. The map $t \mapsto (x, t)$ is continuous as a map $I \to X \times I$ (in fact, it is the restriction of a slice inclusion). Composing with the continuous $H$ gives a continuous map $I \to Y$, so $\alpha_x$ is indeed a path.
Its endpoints are $\alpha_x(0) = H(x, 0) = f(x)$ and $\alpha_x(1) = H(x, 1) = g(x)$. So $\alpha_x$ is a path from $f(x)$ to $g(x)$, proving $[f(x)] = [g(x)]$ in $\pi_0(Y)$.
By the definition of $\pi_0(f)$ and $\pi_0(g)$, for any $[x] \in \pi_0(X)$ we have
\begin{align*}
\pi_0(f)([x]) = [f(x)] = [g(x)] = \pi_0(g)([x]).
\end{align*}
Equality of functions is pointwise, so $\pi_0(f) = \pi_0(g)$.
The core idea: a homotopy between $f$ and $g$ gives, for **each** point $x$, a path from $f(x)$ to $g(x)$. On path components, a path is the witness that two points are equivalent, so the images coincide at the level of $\pi_0$.
[/guided]
[/step]
[step:Verify the composition law $\pi_0(k \circ h) = \pi_0(k) \circ \pi_0(h)$]
Let $h: X \to Y$ and $k: Y \to Z$ be composable continuous maps. By Step 1, the functions $\pi_0(h): \pi_0(X) \to \pi_0(Y)$, $\pi_0(k): \pi_0(Y) \to \pi_0(Z)$, and $\pi_0(k \circ h): \pi_0(X) \to \pi_0(Z)$ are all well defined. For any $[x] \in \pi_0(X)$,
\begin{align*}
\pi_0(k \circ h)([x]) &= [(k \circ h)(x)] = [k(h(x))] \\
&= \pi_0(k)([h(x)]) = \pi_0(k)(\pi_0(h)([x])) \\
&= (\pi_0(k) \circ \pi_0(h))([x]).
\end{align*}
The first equality is the definition of $\pi_0(k \circ h)$, the second is the definition of composition of functions, the third applies the definition of $\pi_0(k)$ to the representative $h(x)$, the fourth applies the definition of $\pi_0(h)$ to the representative $x$, and the fifth is the definition of composition. Since this holds for every $[x] \in \pi_0(X)$, we have $\pi_0(k \circ h) = \pi_0(k) \circ \pi_0(h)$ as functions $\pi_0(X) \to \pi_0(Z)$.
[/step]
[step:Verify the identity law $\pi_0(\operatorname{id}_X) = \operatorname{id}_{\pi_0(X)}$]
For any $[x] \in \pi_0(X)$, applying the definition of $\pi_0(\operatorname{id}_X)$ with the representative $x$,
\begin{align*}
\pi_0(\operatorname{id}_X)([x]) = [\operatorname{id}_X(x)] = [x] = \operatorname{id}_{\pi_0(X)}([x]).
\end{align*}
Equality holds for every class, so $\pi_0(\operatorname{id}_X) = \operatorname{id}_{\pi_0(X)}$.
Combining Steps 1–4 establishes that $\pi_0$ is a functor from the homotopy category of [topological spaces](/pages/Topological%20Space) to the category of sets, completing the proof.
[/step]