I have a really simple problem but I don't know how to solve it. Basically, I am doing vecor manipulation and I am summing a lot of Kronecker delta here and there. How can I teach Mathematica that for any sum of the form $ \sum_{i=1}^{d}\delta_{\mu\nu}\delta_{\mu\nu}=d $. I tried
$Assumptions = Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], {u, 1,
d}, {μ, 1, d}] == d
Which does not work. To be precise, consider a Ansatz of the following form, depending on a vector $\vec{s}$ and some coefficients.
customAnsatzC[s_, μ_, ν_, λ_, σ_] := C1 s.s KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] +
C2 s.s (KroneckerDelta[μ, σ] KroneckerDelta[λ, ν] +
KroneckerDelta[μ, λ]KroneckerDelta[ν, σ]);
When I take the Trace of something like this, it gives back
Sum[KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] customAnsatzC[{s1, s2, s3,
s4}, μ, ν, λ, σ], {λ, 1, 4}, {σ, 1, 4}, {μ, 1, 4}, {ν, 1, 4}] // FullSimplify
This gives back $8 (2 C1 + C2) (s1^2 + s2^2 + s3^2 + s4^2)$ but I would like it to give back $(d^2C1 + 2dC2)(s1^2+s2^2+s3^2+s4^2)$ instead. Is there a way to do this ?