## canonicalise

Bring a tensorial expression to canonical form by re-ordering indices.

Canonicalise a product of tensors, using the mono-term
index symmetries of the individual tensors and the
exchange symmetries of identical tensors. Tensor exchange takes into
account commutativity properties of identical tensors.
Note that this algorithm does not take into account multi-term
symmetries such as the Ricci identity of the Riemann tensor; those
canonicalisation procedures require the use
of `young_project_tensor`

or `young_project_product`

. Similarly,
dimension-dependent identities are not taken into account, use
`decompose_product`

for those.
In order to specify symmetries of tensors you need to use symmetry
properties such as `Symmetric`

, `AntiSymmetric`

or `TableauSymmetry`

. The following example illustrates this.A_{m n}::AntiSymmetric.
B_{p q}::Symmetric.
ex:=A_{m n} B_{m n};
canonicalise(_);

\(\displaystyle{}A_{m n} B_{m n}\)

\(\displaystyle{}0\)

If the various terms in an expression use different index names, you
may need an additional call to

`rename_dummies`

before the terms get collected together:{m,n,p,q,r,s}::Indices.
A_{m n}::AntiSymmetric.
C_{p q r}::AntiSymmetric.
ex:=A_{m n} C_{m n q} + A_{s r} C_{s q r};
canonicalise(_);

\(\displaystyle{}A_{m n} C_{m n q}+A_{s r} C_{s q r}\)

\(\displaystyle{}A_{m n} C_{q m n}-A_{r s} C_{q r s}\)

rename_dummies(_);

\(\displaystyle{}0\)

If you have symmetric or anti-symmetric tensors with many indices, it
sometimes pays off to sort them to the end of the expression (this may
speed up the canonicalisation process considerably).