Tekstiviesti: A theory of quantum subspace diagonalization