a field-theory motivated approach to computer algebra

## rename_dummies

Rename dummy indices, within a set or from one set to another.
Rename the dummy indices in an expression. This can be necessary in order to make various terms in a sum use the same names for the indices, so that they can be collected.
{m,n,p,q,r,s}::Indices(vector); ex:=A_{m n} B_{m n} - A_{p q} B_{p q};
$$\displaystyle{}\text{Attached property Indices(position=free) to }\left(m, \mmlToken{mo}[linebreak="goodbreak"]{} n, \mmlToken{mo}[linebreak="goodbreak"]{} p, \mmlToken{mo}[linebreak="goodbreak"]{} q, \mmlToken{mo}[linebreak="goodbreak"]{} r, \mmlToken{mo}[linebreak="goodbreak"]{} s\right).$$
$$\displaystyle{}A_{m n} B_{m n}-A_{p q} B_{p q}$$
Using canonicalise does nothing here,
canonicalise(_);
$$\displaystyle{}A_{m n} B_{m n}-A_{p q} B_{p q}$$
However, renaming indices does the trick,
rename_dummies(_);
$$\displaystyle{}0$$
Note that the indices need to have been declared as being part of an index list, using the Indices property.
The algorithm can also be used to rename dummies from one set to another one, e.g. to change index conventions (this is used in many of Cadabra's packages). Here is an example.
{m,n,p,q}::Indices("one"); {a,b,c,d}::Indices("two"); ex:= A_{m} A^{m} + B_{m} C^{m} + A_{n} A^{n} + Q_{c d} R^{d c};
$$\displaystyle{}\text{Attached property Indices(position=free) to }\left[m, n, p, q\right].$$
$$\displaystyle{}\text{Attached property Indices(position=free) to }\left[a, b, c, d\right].$$
$$\displaystyle{}A_{m} A^{m}+B_{m} C^{m}+A_{n} A^{n}+Q_{c d} R^{d c}$$
The above expression has indices in two different sets. We now rename the first set to the second,
rename_dummies(_, "one", "two");
$$\displaystyle{}2A_{a} A^{a}+B_{a} C^{a}+Q_{c d} R^{d c}$$