[step:Prove $\operatorname{span}\{r^{(i)}\}_{i=0}^m = K_{m+1}(A, r^{(0)})$ by induction using the residual update]Recall that $K_{m+1}(A, r^{(0)}) := \operatorname{span}\{r^{(0)}, Ar^{(0)}, \ldots, A^mr^{(0)}\}$. We prove $\operatorname{span}\{r^{(i)}\}_{i=0}^m = K_{m+1}(A, r^{(0)})$ by induction on $m$.
**Base case ($m = 0$).** Both sides equal $\operatorname{span}\{r^{(0)}\}$.
**Inductive step.** Assume $\operatorname{span}\{r^{(i)}\}_{i=0}^{m-1} = K_m(A, r^{(0)})$. The residual update in CG is:
\begin{align*}
r^{(m)} = r^{(m-1)} - \alpha_{m-1} Ad^{(m-1)}.
\end{align*}
By the previous step, $d^{(m-1)} \in \operatorname{span}\{r^{(i)}\}_{i=0}^{m-1} = K_m(A, r^{(0)})$. Therefore $Ad^{(m-1)} \in AK_m(A, r^{(0)}) \subset K_{m+1}(A, r^{(0)})$. Since $r^{(m-1)} \in K_m(A, r^{(0)}) \subset K_{m+1}(A, r^{(0)})$, we get $r^{(m)} \in K_{m+1}(A, r^{(0)})$, hence:
\begin{align*}
\operatorname{span}\{r^{(i)}\}_{i=0}^m \subset K_{m+1}(A, r^{(0)}).
\end{align*}
For the reverse inclusion, $K_{m+1}(A, r^{(0)}) = K_m(A, r^{(0)}) + \operatorname{span}\{A^m r^{(0)}\}$. By the inductive hypothesis, $K_m(A, r^{(0)}) = \operatorname{span}\{r^{(i)}\}_{i=0}^{m-1}$. Since $r^{(m)} \notin \operatorname{span}\{r^{(i)}\}_{i=0}^{m-1}$ (because $r^{(m)}$ is orthogonal to all $r^{(0)}, \ldots, r^{(m-1)}$ by property (2), which we establish independently below, and $r^{(m)} \neq 0$ by hypothesis), the dimension satisfies:
\begin{align*}
\dim \operatorname{span}\{r^{(i)}\}_{i=0}^m = m + 1 = \dim K_{m+1}(A, r^{(0)}),
\end{align*}
where the last equality holds because $K_{m+1}(A, r^{(0)})$ has dimension at most $m + 1$ and contains the $(m+1)$-dimensional subspace $\operatorname{span}\{r^{(i)}\}_{i=0}^m$. Since $\operatorname{span}\{r^{(i)}\}_{i=0}^m \subset K_{m+1}(A, r^{(0)})$ and both have dimension $m+1$, equality follows.[/step]