Given a general sum with multiple variables from some finite set, I can transform it to be a nested sum or a product of distinct sums over one variable each:
$$ S = \sum_{\substack{a,b,c, d}} f(a)f(b)f(c)f(d) = \left(\sum_a f(a)\right)\left(\sum_b f(b)\right)\left(\sum_c f(c)\right) \left(\sum_d f(d)\right)$$
But can I do something similar if I have a similar sum with a condition like
$$ S = \sum_{\substack{a,b,c, d\\a+b=c+d}} f(a)f(b)f(c)f(d) = \sum_{a}\sum_{b}\sum_c\sum_{d}f(a)f(b)f(c)f(d) \cdot \delta\{a+b=c+d\} $$
Can I transform it to be a product of simpler sums, or a nested sum?
One way I can think of is to throw away the condition, then I'll be able to write the sum as a product of independent sums (exactly as shown above), and finally multiply it by the number of 4-tuples $(a, b, c, d)$ matching the condition divided by the total number of 4-tuples $(a, b, c, d)$, but I am not sure if it's correct, or if there is a simpler solution.
From $$ a+b = c +d, $$ we obtain $$ d = a+b-c, $$ and then $$ \sum_a \sum_b \sum_c \sum_d f(a) f(b) f(c) f(d) = \sum_a \sum_b \sum_c \sum_{a+b-c} f(a) f(b) f(c) f(a+b-c). $$ In the right-hand side, the first three summation symbols can of course be interchanged freely without affacting the answer.