Solution (source code)

= Solution

The <Schmidt decomposition> states that every finite-dimensional bipartite pure state has
$$
\boxed{|\phi\rangle_{AB}
=\sum_{j=1}^r s_j|a_j\rangle_A|b_j\rangle_B},
$$
where $s_j>0$, $\sum_js_j^2=1$, and the two displayed families are orthonormal. The integer $r$ is the <Schmidt rank>.

To prove it, choose product bases and write
$$
|\phi\rangle=\sum_{m,n}C_{mn}|m\rangle_A|n\rangle_B.
$$
Apply the <singular value decomposition> $C=USV^\dagger$. Absorbing the columns of $U$ and the complex conjugates of the columns of $V$ into new orthonormal bases gives the stated sum, with the nonzero singular values as the <Schmidt coefficients>. Equivalently, $s_j^2$ are the common nonzero eigenvalues of the two <reduced density matrices>, so $r=\operatorname{rank}\rho_A=\operatorname{rank}\rho_B$.