Solution (source code)

= Solution

In units with $\hbar=1$, the <quantum harmonic oscillator> Hamiltonian and <number operator> are
$$
\boxed{H=\omega\left(N+\frac12\right)},
\qquad
\boxed{N=A^\dagger A}.
$$
The nontrivial commutators among the <creation and annihilation operators> and $N$ are
$$
\boxed{
[A,A^\dagger]=1,
\qquad
[N,A]=-A,
\qquad
[N,A^\dagger]=A^\dagger
}.
$$
Their reversed commutators have the opposite signs, while the commutator of any operator with itself is zero.

The operator $N$ is <self-adjoint> because
$$
(A^\dagger A)^\dagger=A^\dagger A.
$$
Its eigenvalues are therefore real. Moreover, for every state $|\psi\rangle$,
$$
\langle\psi|N|\psi\rangle
=\langle A\psi|A\psi\rangle
=\|A|\psi\rangle\|^2\geq0,
$$
so every eigenvalue is nonnegative.

If $N|\nu\rangle=\nu|\nu\rangle$, the commutator with $A$ gives
$$
N(A|\nu\rangle)=(\nu-1)A|\nu\rangle,
$$
and
$$
\|A|\nu\rangle\|^2=\nu\|\,|\nu\rangle\|^2.
$$
Repeated application of $A$ lowers the eigenvalue by one. It must terminate before producing a negative eigenvalue. If $m$ is the last occupied rung, then $A|\nu-m\rangle=0$, and the norm identity forces $\nu-m=0$. Hence
$$
\boxed{\nu\in\{0,1,2,\ldots\}}.
$$
This is the <integer spectrum of the number operator>.