Sorry I have still some bizarre errors with index replacing. For this example notebook:
{i,j,k,l}::Indices.
{i,j,k,l}::Integer(1..3).
\delta{#}::KroneckerDelta.
{ A^{i},A2}::Depends(\commutator{#}).
{ A^{i}, A2 }::Commuting.
def post_process(ex):
unwrap(ex)
eliminate_kronecker(ex)
canonicalise(ex)
rename_dummies(ex)
collect_terms(ex)
defA2:={A2-> A^{l}A^{l}};
A2→A^iA^i
exp:=A^kA^k \delta^{i j} /A2;
A^{k} A^{k} \delta^{i j} (A2)**(-1)
substitute(exp,defA2);
A^{i} A^{i} (A^{i} A^{i})**(-1)
The \delta dissappeared and index i is repeated!!
I use Version 2.4.3 (build 2889.b1e0fefe3e dated 2022-12-18)
Thanks!