a field-theory motivated approach to computer algebra

## meld

Combine terms when allowed by symmetries.
In a sum of terms, combine terms using mono-term and multi-term symmetries such that the expression does not use an overcomplete basis. The meld algorithm does not rewrite the expression to a canonical form, but it instead combines terms such that no terms remain which are a linear combination of the other terms. It can hence be used to prove equivalency of expressions under both mono-term and multi-term symmetries.
A typical use cases where meld is preferable over e.g. canonicalise is when the expression contains tensors with multi-term symmetries:
R_{a b c d}::RiemannTensor; ex:=R_{a b c d}R_{a b c d} + R_{a b c d}R_{a c b d}; meld(ex);
$$\displaystyle{}\text{Attached property TableauSymmetry to }R_{a b c d}.$$
$$\displaystyle{}R_{a b c d} R_{a b c d}+R_{a b c d} R_{a c b d}$$
R_{a b c d} R_{a b c d} + R_{a b c d} R_{a c b d}
$$\displaystyle{}\frac{3}{2}R_{a b c d} R_{a b c d}$$
3/2 R_{a b c d} R_{a b c d}
What has happened here is that the algorithm figured out that the first term is expressible in terms of the second, and has combined the two. If you write the terms in the opposite order, meld still combines them, but now in the form of the other term:
ex:=R_{a b c d}R_{a c b d}+ R_{a b c d}R_{a b c d}; meld(ex);
$$\displaystyle{}R_{a b c d} R_{a c b d}+R_{a b c d} R_{a b c d}$$
R_{a b c d} R_{a c b d} + R_{a b c d} R_{a b c d}
$$\displaystyle{}3R_{a b c d} R_{a c b d}$$
3R_{a b c d} R_{a c b d}
So meld does not canonicalise, but rather writes the expression such that there remain no linear dependencies between terms.
This algorithm can of course be used for simpler situations, e.g. one which uses mono-term symmetries only:
A_{m n}::AntiSymmetric; ex:=A_{m n} - A_{n m}; meld(ex);
$$\displaystyle{}\text{Attached property AntiSymmetric to }A_{m n}.$$
$$\displaystyle{}A_{m n}-A_{n m}$$
A_{m n}-A_{n m}
$$\displaystyle{}2A_{m n}$$
2A_{m n}
The meld algorithm can also be used as a quick way to collect terms which only differ by dummy index relabelling (even when there are no symmetries present), e.g.
ex:=Q_{m n} R^{m n} + R^{p q} Q_{p q};
$$\displaystyle{}Q_{m n} R^{m n}+R^{p q} Q_{p q}$$
Q_{m n} R^{m n} + R^{p q} Q_{p q}
meld(ex);
$$\displaystyle{}2Q_{m n} R^{m n}$$
2Q_{m n} R^{m n}
The algorithm also handles cyclic symmetries of traces:
{\mu,\nu}::Indices(vector). u^{\mu}::ImplicitIndex. u^{\mu}::SelfNonCommuting. tr{#}::Trace. ex := tr{u^{\mu} u^{\mu} u^{\nu} u^{\nu}} - tr{u^{\mu} u^{\nu} u^{\nu} u^{\mu}}; meld(ex);
$$\displaystyle{}tr\left(u^{\mu} u^{\mu} u^{\nu} u^{\nu}\right)-tr\left(u^{\mu} u^{\nu} u^{\nu} u^{\mu}\right)$$
tr(u^{\mu} u^{\mu} u^{\nu} u^{\nu})-tr(u^{\mu} u^{\nu} u^{\nu} u^{\mu})
$$\displaystyle{}0$$
0