[proofplan]
The proof is an operator calculation on the invariant domain $\mathcal{S}(\mathbb{R})$. First we verify the canonical commutator $[X,P]=i\hbar I$ directly from the definitions of $X$ and $P$. Then we expand $aa^*$ and $a^*a$ without commuting $X$ and $P$; the pure $X^2$ and $P^2$ terms agree, and the mixed terms differ exactly by the commutator $[X,P]$. Finally we reuse the expansion of $a^*a$ to identify the harmonic oscillator Hamiltonian.
[/proofplan]
[step:Compute the position momentum commutator on $\mathcal{S}(\mathbb{R})$]
The constants $m,\omega,\hbar$ are positive, $I$ is the identity on $\mathcal S(\mathbb R)$, and $X$, $P$, $H$, $a$, and $a^*$ are the operators defined in the statement. Let $\psi \in \mathcal{S}(\mathbb{R})$. Since $\mathcal{S}(\mathbb{R})$ is closed under differentiation and multiplication by $x$, both $XP\psi$ and $PX\psi$ belong to $\mathcal{S}(\mathbb{R})$. For each $x \in \mathbb{R}$, the definition of $P$ gives
\begin{align*}
((XP)\psi)(x)=x(-i\hbar\psi'(x)).
\end{align*}
Using the product rule for the derivative of the map $x \mapsto x\psi(x)$,
\begin{align*}
((PX)\psi)(x)=-i\hbar\frac{d}{dx}(x\psi(x))=-i\hbar(\psi(x)+x\psi'(x)).
\end{align*}
Therefore
\begin{align*}
(([X,P]\psi)(x))=((XP-PX)\psi)(x)=i\hbar\psi(x).
\end{align*}
Since this holds for every $\psi \in \mathcal{S}(\mathbb{R})$ and every $x \in \mathbb{R}$,
\begin{align*}
[X,P]=i\hbar I.
\end{align*}
[guided]
We first isolate the only non-commuting ingredient in the proof. The operators $X$ and $P$ are both defined on $\mathcal{S}(\mathbb{R})$, and this space is stable under multiplication by $x$ and under differentiation. Thus the compositions $XP$ and $PX$ are well-defined maps from $\mathcal{S}(\mathbb{R})$ to itself.
Fix $\psi \in \mathcal{S}(\mathbb{R})$. The operator $XP$ means that $P$ acts first and then $X$ acts. Hence, for each $x \in \mathbb{R}$,
\begin{align*}
((XP)\psi)(x)=x(P\psi)(x)=x(-i\hbar\psi'(x)).
\end{align*}
The operator $PX$ means that $X$ acts first and then $P$ acts. The function $X\psi: \mathbb{R}\to\mathbb{C}$ is given by $(X\psi)(x)=x\psi(x)$, so the product rule gives
\begin{align*}
((PX)\psi)(x)=-i\hbar\frac{d}{dx}(x\psi(x))=-i\hbar(\psi(x)+x\psi'(x)).
\end{align*}
Subtracting these two identities cancels the terms containing $x\psi'(x)$:
\begin{align*}
(([X,P]\psi)(x))=((XP-PX)\psi)(x)=i\hbar\psi(x).
\end{align*}
This equality holds pointwise for every $x \in \mathbb{R}$ and for every test vector $\psi \in \mathcal{S}(\mathbb{R})$. Therefore the operator identity on $\mathcal{S}(\mathbb{R})$ is
\begin{align*}
[X,P]=i\hbar I.
\end{align*}
[/guided]
[/step]
[step:Expand $aa^*$ and $a^*a$ while preserving operator order]
Define the positive constants
\begin{align*}
\alpha=\sqrt{\frac{m\omega}{2\hbar}}
\end{align*}
and
\begin{align*}
\beta=\frac{1}{\sqrt{2m\hbar\omega}}.
\end{align*}
Then
\begin{align*}
a=\alpha X+i\beta P
\end{align*}
and
\begin{align*}
a^*=\alpha X-i\beta P.
\end{align*}
Expanding the product $aa^*$ as a composition of operators on $\mathcal{S}(\mathbb{R})$ gives
\begin{align*}
aa^*=\alpha^2X^2-i\alpha\beta XP+i\alpha\beta PX+\beta^2P^2.
\end{align*}
Equivalently,
\begin{align*}
aa^*=\alpha^2X^2+\beta^2P^2+i\alpha\beta(PX-XP).
\end{align*}
Similarly,
\begin{align*}
a^*a=\alpha^2X^2+i\alpha\beta XP-i\alpha\beta PX+\beta^2P^2.
\end{align*}
Equivalently,
\begin{align*}
a^*a=\alpha^2X^2+\beta^2P^2+i\alpha\beta(XP-PX).
\end{align*}
[/step]
[step:Use $[X,P]=i\hbar I$ to obtain $[a,a^*]=I$]
Subtracting the expansion of $a^*a$ from the expansion of $aa^*$ gives
\begin{align*}
[a,a^*]=aa^*-a^*a=i\alpha\beta(PX-XP)-i\alpha\beta(XP-PX).
\end{align*}
Since $PX-XP=-[X,P]$, this becomes
\begin{align*}
[a,a^*]=-2i\alpha\beta[X,P].
\end{align*}
Using $[X,P]=i\hbar I$,
\begin{align*}
[a,a^*]=2\alpha\beta\hbar I.
\end{align*}
Finally,
\begin{align*}
2\alpha\beta\hbar=2\sqrt{\frac{m\omega}{2\hbar}}\frac{1}{\sqrt{2m\hbar\omega}}\hbar=1.
\end{align*}
Hence
\begin{align*}
[a,a^*]=I.
\end{align*}
[/step]
[step:Rewrite $a^*a$ as the Hamiltonian shifted by $\frac{1}{2}I$]
From the expansion above and $XP-PX=[X,P]=i\hbar I$,
\begin{align*}
a^*a=\alpha^2X^2+\beta^2P^2+i\alpha\beta[X,P].
\end{align*}
Substituting $[X,P]=i\hbar I$ gives
\begin{align*}
a^*a=\alpha^2X^2+\beta^2P^2-\alpha\beta\hbar I.
\end{align*}
The constants satisfy
\begin{align*}
\alpha^2=\frac{m\omega}{2\hbar}
\end{align*}
and
\begin{align*}
\beta^2=\frac{1}{2m\hbar\omega}.
\end{align*}
Also $\alpha\beta\hbar=\frac{1}{2}$. Therefore
\begin{align*}
a^*a=\frac{m\omega}{2\hbar}X^2+\frac{1}{2m\hbar\omega}P^2-\frac{1}{2}I.
\end{align*}
Multiplying by $\hbar\omega$ yields
\begin{align*}
\hbar\omega a^*a=\frac{m\omega^2}{2}X^2+\frac{1}{2m}P^2-\frac{\hbar\omega}{2}I.
\end{align*}
By the definition $H=\frac{1}{2m}P^2+\frac{m\omega^2}{2}X^2$ on $\mathcal S(\mathbb R)$,
\begin{align*}
\hbar\omega a^*a=H-\frac{\hbar\omega}{2}I.
\end{align*}
Adding $\frac{\hbar\omega}{2}I$ to both sides gives
\begin{align*}
H=\hbar\omega\left(a^*a+\frac{1}{2}I\right).
\end{align*}
This proves both asserted operator identities on $\mathcal{S}(\mathbb{R})$.
[/step]