# Simplifying symbolic sums using KroneckerDelta

I am trying to use Mathematica to simplify a symbolic expression of the following form $$S_i = \sum_{n_1 = 0}^\infty \sum_{n_2 = 0}^\infty \ldots \sum_{n_M=0}^\infty n_i \times \Big( \sum_{j = 1}^M a_{j} \big\lbrace n_j \, f(n_1,n_2,\ldots,n_j, \ldots, n_M) - (n_j + 1) \, f(n_1, n_2, \ldots, n_j+1, \ldots, n_M) \big\rbrace \Big) \, ,$$ where $$i$$ is a fixed integer between $$1$$ and $$M$$ (would be better to keep this general, but in practice $$M=10$$), and assuming that the sum exists. Upon changing the order of the $$j$$ summation and after a shift in the second summation as $$n_j+1 \to n_j$$, it can be seen that for the $$j \neq i$$ terms, the summation vanishes. On the other hand, for the $$j=i$$ term, this shift also causes a shift in the $$n_i$$ multiplicative factor. In general, these two effects can be combined as \begin{align} \label{eq1} \sum_{n_1,n_2,\ldots} \sum_j n_i (n_j+1) f(n_1,\ldots, n_j+1,\ldots, n_M) &= \sum_{n_1,n_2,\ldots} \sum_j (n_i - \delta_{ij}) \, n_j f(n_1,\ldots, n_j,\ldots, n_M) \\ &= \sum_{n_1,n_2, \ldots} \sum_{j \neq i} n_i n_j f(n_1,\ldots,n_M) - \sum_{n_1,n_2,\ldots}n_i \, f(n_1,\ldots,n_M) \, , \end{align} which gives (note that the lower limit of the $$n_j$$ summation can still start from zero) $$S_i = - \sum_{n_1,n_2,\ldots} n_i f(n_1,n_2,\ldots,n_M) \, .$$

I would like to make the simplification process as automatic as possible, since in general instead of $$n_i$$, I will have a multiplication of $$n$$'s and the calculation grows very quickly. Is there a way to enforce this shift as a rule in the summation?

I have seen this post for a very simple scenario involving KroneckerDelta but haven't been able to implement anything for my scenario.