Solution (source code)

= Solution

For the specified positive-exponent <discrete Fourier transform>, the <inverse discrete Fourier transforms> have negative exponents:
$$
\boxed{a_n=\frac1{\sqrt L}\sum_qe^{-iqn}A_q,\qquad
b_n=\frac1{\sqrt L}\sum_qe^{-iqn}B_q.}
$$
Every sum runs over $q=2\pi j/L$, $j=0,\ldots,L-1$. Indeed, <orthogonality of roots of unity> gives
$$
\frac1L\sum_qe^{iq(r-n)}=\delta_{rn},
$$
so substituting the forward <discrete Fourier transform> into either proposed inverse recovers the original operator. Taking <Hermitian conjugates> supplies the inverse formulas for the <creation operators>.

Multiplying the inverse <discrete Fourier transforms> gives the local <number operator> combination
$$
\boxed{\frac12(a_n^\dagger a_n+b_n^\dagger b_n)
=\frac1{2L}\sum_{q,k}e^{i(q-k)n}
\left(A_q^\dagger A_k+B_q^\dagger B_k\right).}
$$
This local expression includes off-diagonal <momentum> terms. Only after summing over sites does <orthogonality of roots of unity> give
$$
\frac12\sum_n(a_n^\dagger a_n+b_n^\dagger b_n)
=\frac12\sum_q(A_q^\dagger A_q+B_q^\dagger B_q).
$$
In a physical fixed-$s$ state the first boxed operator acts as $s$ at every site, by the <local spin constraint in the Schwinger boson representation>.