Pošljite SMS: A theory of quantum subspace diagonalization