a field theory motivated approach to computer algebra

# expand_delta

Expand generalised Kronecker delta symbols
In Cadabra the KroneckerDelta property indicates a generalised Kronecker delta symbol. In order to expand it into standard two-index Kronecker deltas, use expand_delta, as in the example below.
\delta{#}::KroneckerDelta;
$$\displaystyle{}\text{Attached property KroneckerDelta to }\delta\left(\#\right).$$
ex:=\delta^{a}_{b}^{c}_{d};
$$\displaystyle{}\delta^{a}\,_{b}\,^{c}\,_{d}$$
expand_delta(_);
$$\displaystyle{}\frac{1}{2}\delta^{a}\,_{b} \delta^{c}\,_{d} - \frac{1}{2}\delta^{c}\,_{b} \delta^{a}\,_{d}$$
ex:=\delta^{a}_{m}^{l}_{n} \delta_{a}^{c}_{b}^{d};
$$\displaystyle{}\delta^{a}\,_{m}\,^{l}\,_{n} \delta_{a}\,^{c}\,_{b}\,^{d}$$
expand_delta(_); distribute(_); eliminate_kronecker(_); canonicalise(_);
$$\displaystyle{}\left(\frac{1}{2}\delta^{a}\,_{m} \delta^{l}\,_{n} - \frac{1}{2}\delta^{l}\,_{m} \delta^{a}\,_{n}\right) \left(\frac{1}{2}\delta_{a}\,^{c} \delta_{b}\,^{d} - \frac{1}{2}\delta_{b}\,^{c} \delta_{a}\,^{d}\right)$$
$$\displaystyle{}\frac{1}{4}\delta^{a}\,_{m} \delta^{l}\,_{n} \delta_{a}\,^{c} \delta_{b}\,^{d} - \frac{1}{4}\delta^{a}\,_{m} \delta^{l}\,_{n} \delta_{b}\,^{c} \delta_{a}\,^{d} - \frac{1}{4}\delta^{l}\,_{m} \delta^{a}\,_{n} \delta_{a}\,^{c} \delta_{b}\,^{d}+\frac{1}{4}\delta^{l}\,_{m} \delta^{a}\,_{n} \delta_{b}\,^{c} \delta_{a}\,^{d}$$
$$\displaystyle{}\frac{1}{4}\delta^{l}\,_{n} \delta_{m}\,^{c} \delta_{b}\,^{d} - \frac{1}{4}\delta^{l}\,_{n} \delta_{b}\,^{c} \delta_{m}\,^{d} - \frac{1}{4}\delta^{l}\,_{m} \delta_{n}\,^{c} \delta_{b}\,^{d}+\frac{1}{4}\delta^{l}\,_{m} \delta_{b}\,^{c} \delta_{n}\,^{d}$$
$$\displaystyle{}\frac{1}{4}\delta_{b}\,^{d} \delta^{c}\,_{m} \delta^{l}\,_{n} - \frac{1}{4}\delta_{b}\,^{c} \delta^{d}\,_{m} \delta^{l}\,_{n} - \frac{1}{4}\delta_{b}\,^{d} \delta^{c}\,_{n} \delta^{l}\,_{m}+\frac{1}{4}\delta_{b}\,^{c} \delta^{d}\,_{n} \delta^{l}\,_{m}$$
Note that it is in principle possible to get a result similar to the expanded form by using the Young projector and then canonicalising, but this is more expensive:
ex:=\delta^{a}_{b}^{c}_{d};
$$\displaystyle{}\delta^{a}\,_{b}\,^{c}\,_{d}$$
young_project_tensor(_);
$$\displaystyle{}\delta^{a}\,_{b}\,^{c}\,_{d}$$