def post_process(ex):
sort_product(ex)
canonicalise(ex)
collect_terms(ex)
{\mu,\nu,\alpha,\beta,\sigma,\lambda,h,i,j,n,r,p,q,\eta,\chi,\rho,\delta, v,z,x}::Indices;
g_{\mu\nu}::Metric.
g_{\mu}^{\nu}::KroneckerDelta.
vert1:= f^{\gamma\delta}=(...);
vert2:= \tau^{\gamma\delta\rho\sigma}=(...);
ampl:= w^{\rho\sigma}=\tau^{\gamma\delta\rho\sigma}f_{\gamma\delta};
substitute(ampl,vert2);
substitute(ampl,vert1);
Now, the first substitution works while the second not. For the kronecker,
def post_process(ex):
sort_product(ex)
canonicalise(ex)
collect_terms(ex)
{\mu,\nu,\alpha,\beta,\sigma,\lambda,h,i,j,n,r,p,q,\eta,\chi,\rho,\delta, v,z,x}::Indices;
g_{\mu\nu}::Metric.
g_{\mu}^{\nu}::KroneckerDelta.
vert2:= \tau^{\gamma\delta\rho\sigma}=(...);
distribute(vert2);
eliminate_metric(vert2);
eliminate_kronecker(vert2);
At the end, some kronecker remains and it does not sum equal terms, resulting in a very long expression. I'm sorry if I have not been clear.