Suppose I have two kinds of operators $a[i,j],a^\dagger[i,j]$ where i is a non-negative integer and $j=\pm 1$, I want to create a list containing all possible products of
$ a^{(\dagger)}[x_1,j_1]a^{(\dagger)}[x_2,j_2]a^{(\dagger)}[x_3,j_3]...a^{(\dagger)}[x_r,j_r]$
where $a^{(\dagger)}$ could take the value of $a$ or $a^\dagger$
such that
$r+ \sum_{i=1}^{r} |x_i|\leq K $
where K is an integer I need to specify.
The first question is how to create this list?
The second question is what can I do to restrict all elements of this list in a "normal-ordered form" meaning that $a^{\dagger}[i,j]$ is always in front of $a[i,j]$ ([i,j] have the same value for $a, a\dagger$) with the anti-commutation relation $a[i,j] a^\dagger[k,l] +a^\dagger[k,l] a[i,j]=\delta_{ik}\delta_{jl}$ where $\delta_{ij}=1$ if $i=j$ and 0 for other cases.
It would be ideal if I can make all elements having the form
$(a^{\dagger}[x1,1]a^{\dagger}[x1,1]...a[x1,1])(a^{\dagger}[x1,-1]a^{\dagger}[x1,-1]...a[x1,-1])(a^{\dagger}[x2,-1]a^{\dagger}[x2,-1]...a[x2,-1])...$
meaning $a^{(\dagger)}[i,j]$ with same $[i,j]$ stays inside a parentheses.
IntegerPartitions[k - r, k, Range[r]]
should work. Or maybe,Flatten[Permutations /@ IntegerPartitions[k - r, k, Range[r]], 1]
$\endgroup$IntegerPartitions[k]
(or perhapsRest@IntegerPartitions[k]
) to get them all at once. $\endgroup$