Statement of the problem
I have code that performs some basic symbolic manipulations, say of the type needed for GR. I would like to learn an efficient way to relabel dummy indices towards the end of the calculation.
Typical objects look like
A[r][ν] A[r][Subscript[ρ, 2]] F[l, l][Subscript[ρ, 2],
Subscript[ρ, 3]] F[l, r][ν, Subscript[ρ, 3]]
-
A[r][Subscript[ρ, 1]] A[r][Subscript[ρ, 3]] F[l, l][
Subscript[ρ, 3], μ] F[l, r][Subscript[ρ, 1], μ]
Here [r] and [l] indicate the positioning of the indices ("raised" or "lowered") and Greek letters are indices that need to be relabelled. So the above expression in Latex is
$ A^\nu A^{\rho_2} F_{\rho_2 \rho_3} {F_\nu}^{\rho_3} - A^{\rho_1} A^{\rho_3} F_{\rho_3 \mu} {F_{\rho_1}}^\mu$
edit: the desired output of the above would be, in my code convention:
(* A[r][Subscript[\[Tau], 1]] A[r][Subscript[\[Tau], 2]] F[l, l][
Subscript[\[Tau], 2], Subscript[\[Tau], 3]] F[l, r][
Subscript[\[Tau], 1], Subscript[\[Tau], 3]]
-
A[r][Subscript[\[Tau], 1]] A[r][Subscript[\[Tau], 2]] F[l, l][
Subscript[\[Tau], 2], Subscript[\[Tau], 3]] F[l, r][
Subscript[\[Tau], 1], Subscript[\[Tau], 3]]
= 0 *)
That is, the goal would be to search for expressions that have repeated indices and relabel these indices according to a common list that is as long as the number of pairs of repeated indices.
Attempt at a solution
The following code correctly replaces a Greek letter with $\tau_1$ if that Greek letter is repeated within a term in the sum:
x = A[r][ν] A[r][Subscript[ρ, 2]] F[l, l][Subscript[ρ, 2],
Subscript[ρ, 3]] F[l, r][ν, Subscript[ρ,3]];
x// # /. (times1___ x1___[y1__][left1___, x12_,
right1___] times2___ x2___[y2__][left2___, x12_,
right2___] times3___ :>
times1 x1[y1][left1, Subscript[τ, 1], right1] times2 x2[y2][
left2, Subscript[τ, 1], right2] times3 ) &
Note that it is undesirable to simply use ReplaceRepeated
- it's important that distinct pairs of repeated Greek letters get replace by a single symbol, not that all Greek letters end up being replace by the same symbol.
I can generalize this code to replace a first repeated Greek letter with $\tau_1$ and a second repeated letter with $\tau_2$:
x// # /. (times1___ x1___[y1__][left1___, x12_,
right1___] times2___ x2___[y2__][left2___, x12_,
right2___] times3___ x3___[y3__][left3___, x34_,
right3___] times4___ x4___[y4__][left4___, x34_,
right4___] times5___ :>
times1 x1[y1][left1, Subscript[τ, 1], right1] times2 x2[y2][
left2, Subscript[τ, 1], right2] times3 x3[y3][left3,
Subscript[τ, 2], right3] times4 x4[y4][left4,
Subscript[τ, 2], right4] times5) &
(* -A[r][Subscript[τ, 1]] A[r][Subscript[τ, 2]] F[l, l][
Subscript[τ, 2], μ] F[l, r][Subscript[τ, 1], μ] +
A[r][Subscript[τ, 1]] A[r][Subscript[τ, 2]] F[l, l][
Subscript[τ, 2], Subscript[ρ, 3]] F[l, r][
Subscript[τ, 1], Subscript[ρ, 3]] *)
Continuing along this path is unsatisfactory, because (in order of importance):
- I need to apply this code to an expression that might have 50-300 terms summed together. If I add conditions to replace 3 or 4 (or even 5) indices at a time, the code becomes very slow.
- This seems like a very inelegant way to achieve what I want, but I don't know what a better strategy is
Another attempt: I can get at the indices with
x// Cases[#, AA_[y__][x__] -> {x}, All] &
(* {{ν}, {Subscript[ρ, 2]}, {Subscript[ρ, 2],
Subscript[ρ, 3]}, {ν, Subscript[ρ,3]}, {Subscript[ρ,1]},
{Subscript[ρ,3]}, {Subscript[ρ, 3], μ}, {Subscript[ρ, 1],
μ}} *)
But from here I'm not sure how to make sure that the indices corresponding to the first term are relabelled to the same indices as those corresponding to the second term, in the general case where I may not know how many indices need to be relabelled in a given a term, or how many terms there are.
Edit: For performance testing
here is some longer input:
test = 5/6 A[l][Subscript[Subscript[\[Rho]2, 1], 3]] A[r][\[Nu]] A[r][
Subscript[\[Omega], 2]] d[l][\[Phi],
Subscript[\[Omega], 2]] F[l, l][\[Nu],
Subscript[Subscript[\[Rho]2, 1], 5]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] +
5/6 A[l][\[Beta]\[Beta]] A[r][\[Beta]\[Beta]] A[r][\[Nu]] d[
l][\[Phi], Subscript[Subscript[\[Rho]2, 1], 3]] F[l, l][\[Nu],
Subscript[Subscript[\[Rho]2, 1], 5]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] -
5/6 A[l][Subscript[Subscript[\[Rho]2, 1], 3]] A[l][
Subscript[Subscript[\[Rho]2, 1], 4]] A[r][\[Nu]] d[l][\[Phi],
Subscript[\[Omega], 2]] F[l, l][\[Nu],
Subscript[Subscript[\[Rho]2, 1], 5]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] -
5/6 A[l][Subscript[\[Omega], 2]] A[l][
Subscript[Subscript[\[Rho]2, 1], 4]] A[r][\[Nu]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 3]] F[l, l][\[Nu],
Subscript[Subscript[\[Rho]2, 1], 5]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] +
5/6 A[l][Subscript[\[Omega], 2]] A[l][
Subscript[Subscript[\[Rho]2, 1], 3]] A[r][\[Nu]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 4]] F[l, l][\[Nu],
Subscript[Subscript[\[Rho]2, 1], 5]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] -
5/6 A[l][Subscript[Subscript[\[Rho]2, 1], 3]] A[l][
Subscript[Subscript[\[Rho]2, 1], 5]] A[r][\[Nu]] d[
l][\[Phi], \[Nu]] F[l, l][Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] +
5/6 A[l][\[Nu]] A[l][
Subscript[Subscript[\[Rho]2, 1], 3]] A[r][\[Nu]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 5]] F[l, l][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] -
5/6 A[l][Subscript[\[Omega], 2]] A[l][
Subscript[Subscript[\[Rho]2, 1], 5]] A[r][\[Nu]] d[
l][\[Phi], \[Nu]] F[l, l][Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] +
5/6 A[l][\[Nu]] A[l][
Subscript[\[Omega], 2]] A[r][\[Nu]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 5]] F[l, l][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 3],
Subscript[Subscript[\[Rho]2, 1], 5]] -
5/6 A[l][Subscript[Subscript[\[Rho]2, 1], 6]] A[r][\[Nu]] A[r][
Subscript[\[Omega], 2]] d[l][\[Phi], \[Nu]] F[l, l][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 8]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] -
5/6 A[l][\[Nu]] A[r][\[Nu]] A[r][
Subscript[\[Omega], 2]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 6]] F[l, l][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 8]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] +
5/6 A[l][Subscript[Subscript[\[Rho]2, 1], 6]] A[l][
Subscript[Subscript[\[Rho]2, 1], 8]] A[r][\[Nu]] d[l][\[Phi],
Subscript[\[Omega], 2]] F[l, l][\[Nu],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] -
5/6 A[l][Subscript[\[Omega], 2]] A[l][
Subscript[Subscript[\[Rho]2, 1], 6]] A[r][\[Nu]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 8]] F[l, l][\[Nu],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] +
5/6 A[l][Subscript[Subscript[\[Rho]2, 1], 6]] A[l][
Subscript[Subscript[\[Rho]2, 1], 7]] A[r][\[Nu]] d[
l][\[Phi], \[Nu]] F[l, l][Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 8]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] +
5/6 A[l][\[Nu]] A[l][
Subscript[Subscript[\[Rho]2, 1], 7]] A[r][\[Nu]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 6]] F[l, l][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 8]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] -
5/6 A[l][\[Nu]] A[l][
Subscript[Subscript[\[Rho]2, 1], 6]] A[r][\[Nu]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 7]] F[l, l][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 8]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] +
5/6 A[l][\[Nu]] A[l][
Subscript[Subscript[\[Rho]2, 1], 8]] A[r][\[Nu]] d[l][\[Phi],
Subscript[\[Omega], 2]] F[l, l][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] -
5/6 A[l][\[Nu]] A[l][
Subscript[\[Omega], 2]] A[r][\[Nu]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 1], 8]] F[l, l][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[\[Omega], 2],
Subscript[Subscript[\[Rho]2, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]2, 1], 6],
Subscript[Subscript[\[Rho]2, 1], 8]] -
5/6 A[l][Subscript[Subscript[\[Rho]2, 2], 3]] A[r][\[Nu]] A[r][
Subscript[Subscript[\[Rho]2, 2], 4]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 2], 4]] F[l, l][\[Nu],
Subscript[Subscript[\[Rho]2, 2], 5]] g[r, r][
Subscript[Subscript[\[Rho]2, 2], 3],
Subscript[Subscript[\[Rho]2, 2], 5]] -
5/6 A[l][Subscript[Subscript[\[Rho]2, 2], 5]] A[r][\[Nu]] A[r][
Subscript[Subscript[\[Rho]2, 2], 4]] d[l][\[Phi], \[Nu]] F[l, l][
Subscript[Subscript[\[Rho]2, 2], 4],
Subscript[Subscript[\[Rho]2, 2], 3]] g[r, r][
Subscript[Subscript[\[Rho]2, 2], 3],
Subscript[Subscript[\[Rho]2, 2], 5]] +
5/6 A[l][\[Nu]] A[r][\[Nu]] A[r][
Subscript[Subscript[\[Rho]2, 2], 4]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 2], 5]] F[l, l][
Subscript[Subscript[\[Rho]2, 2], 4],
Subscript[Subscript[\[Rho]2, 2], 3]] g[r, r][
Subscript[Subscript[\[Rho]2, 2], 3],
Subscript[Subscript[\[Rho]2, 2], 5]] -
5/6 A[l][Subscript[Subscript[\[Rho]2, 2], 6]] A[r][\[Nu]] A[r][
Subscript[Subscript[\[Rho]2, 2], 7]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 2], 8]] F[l, l][
Subscript[Subscript[\[Rho]2, 2], 7], \[Nu]] g[r, r][
Subscript[Subscript[\[Rho]2, 2], 6],
Subscript[Subscript[\[Rho]2, 2], 8]] -
5/6 A[l][\[Nu]] A[r][\[Nu]] A[r][
Subscript[Subscript[\[Rho]2, 2], 7]] d[l][\[Phi],
Subscript[Subscript[\[Rho]2, 2], 8]] F[l, l][
Subscript[Subscript[\[Rho]2, 2], 7],
Subscript[Subscript[\[Rho]2, 2], 6]] g[r, r][
Subscript[Subscript[\[Rho]2, 2], 6],
Subscript[Subscript[\[Rho]2, 2], 8]] -
5/12 A[l][\[Kappa]\[Kappa]] A[l][
Subscript[Subscript[\[Rho]3, 1], 3]] A[r][\[Kappa]\[Kappa]] d[
l][\[Phi], Subscript[Subscript[\[Rho]3, 1], 5]] F[l, l][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 4]] g[r, r][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]3, 1], 3],
Subscript[Subscript[\[Rho]3, 1], 5]] -
5/12 A[l][\[Kappa]\[Kappa]] A[l][
Subscript[\[Omega], 3]] A[r][\[Kappa]\[Kappa]] d[l][\[Phi],
Subscript[Subscript[\[Rho]3, 1], 5]] F[l, l][
Subscript[Subscript[\[Rho]3, 1], 3],
Subscript[Subscript[\[Rho]3, 1], 4]] g[r, r][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]3, 1], 3],
Subscript[Subscript[\[Rho]3, 1], 5]] +
5/12 A[l][\[Kappa]\[Kappa]] A[r][\[Kappa]\[Kappa]] A[r][
Subscript[\[Omega], 3]] d[l][\[Phi],
Subscript[Subscript[\[Rho]3, 1], 6]] F[l, l][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 8]] g[r, r][
Subscript[Subscript[\[Rho]3, 1], 6],
Subscript[Subscript[\[Rho]3, 1], 8]] -
5/12 A[l][\[Kappa]\[Kappa]] A[l][
Subscript[Subscript[\[Rho]3, 1], 7]] A[r][\[Kappa]\[Kappa]] d[
l][\[Phi], Subscript[Subscript[\[Rho]3, 1], 6]] F[l, l][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 8]] g[r, r][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]3, 1], 6],
Subscript[Subscript[\[Rho]3, 1], 8]] +
5/12 A[l][\[Kappa]\[Kappa]] A[l][
Subscript[Subscript[\[Rho]3, 1], 6]] A[r][\[Kappa]\[Kappa]] d[
l][\[Phi], Subscript[Subscript[\[Rho]3, 1], 7]] F[l, l][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 8]] g[r, r][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]3, 1], 6],
Subscript[Subscript[\[Rho]3, 1], 8]] -
5/12 A[l][\[Kappa]\[Kappa]] A[l][
Subscript[Subscript[\[Rho]3, 1], 8]] A[r][\[Kappa]\[Kappa]] d[
l][\[Phi], Subscript[\[Omega], 3]] F[l, l][
Subscript[Subscript[\[Rho]3, 1], 6],
Subscript[Subscript[\[Rho]3, 1], 7]] g[r, r][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]3, 1], 6],
Subscript[Subscript[\[Rho]3, 1], 8]] +
5/12 A[l][\[Kappa]\[Kappa]] A[l][
Subscript[\[Omega], 3]] A[r][\[Kappa]\[Kappa]] d[l][\[Phi],
Subscript[Subscript[\[Rho]3, 1], 8]] F[l, l][
Subscript[Subscript[\[Rho]3, 1], 6],
Subscript[Subscript[\[Rho]3, 1], 7]] g[r, r][
Subscript[\[Omega], 3],
Subscript[Subscript[\[Rho]3, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]3, 1], 6],
Subscript[Subscript[\[Rho]3, 1], 8]] -
5/12 A[l][\[Kappa]\[Kappa]] A[r][\[Kappa]\[Kappa]] A[r][
Subscript[Subscript[\[Rho]3, 2], 4]] d[l][\[Phi],
Subscript[Subscript[\[Rho]3, 2], 5]] F[l, l][
Subscript[Subscript[\[Rho]3, 2], 4],
Subscript[Subscript[\[Rho]3, 2], 3]] g[r, r][
Subscript[Subscript[\[Rho]3, 2], 3],
Subscript[Subscript[\[Rho]3, 2], 5]] +
5/12 A[l][\[Kappa]\[Kappa]] A[r][\[Kappa]\[Kappa]] A[r][
Subscript[Subscript[\[Rho]3, 2], 7]] d[l][\[Phi],
Subscript[Subscript[\[Rho]3, 2], 8]] F[l, l][
Subscript[Subscript[\[Rho]3, 2], 7],
Subscript[Subscript[\[Rho]3, 2], 6]] g[r, r][
Subscript[Subscript[\[Rho]3, 2], 6],
Subscript[Subscript[\[Rho]3, 2], 8]] +
5/12 A[l][Subscript[Subscript[\[Rho]1, 1], 3]] A[r][
Subscript[\[Omega], 1]] A[r][
Subscript[Subscript[\[Rho]1, 1], 3]] d[l][\[Phi],
Subscript[\[Omega], 1]] g[r, r][\[Nu], \[Mu]] S[l,
l][\[Nu], \[Mu]] +
5/12 A[l][\[Beta]\[Beta]] A[r][\[Beta]\[Beta]] A[r][
Subscript[Subscript[\[Rho]1, 1], 3]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 3]] g[r, r][\[Nu], \[Mu]] S[l,
l][\[Nu], \[Mu]] -
5/12 A[l][Subscript[Subscript[\[Rho]1, 2], 3]] A[r][
Subscript[Subscript[\[Rho]1, 2], 3]] A[r][
Subscript[Subscript[\[Rho]1, 2], 4]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 2], 4]] g[r, r][\[Nu], \[Mu]] S[l,
l][\[Nu], \[Mu]] -
5/12 A[l][Subscript[Subscript[\[Rho]1, 1], 3]] A[l][
Subscript[Subscript[\[Rho]1, 1], 4]] A[r][
Subscript[Subscript[\[Rho]1, 1], 3]] d[l][\[Phi],
Subscript[\[Omega], 1]] g[r, r][\[Nu], \[Mu]] g[r, r][
Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 4]] S[l, l][\[Nu], \[Mu]] -
5/12 A[l][Subscript[\[Omega], 1]] A[l][
Subscript[Subscript[\[Rho]1, 1], 4]] A[r][
Subscript[Subscript[\[Rho]1, 1], 3]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 3]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 4]] S[l, l][\[Nu], \[Mu]] +
5/12 A[l][Subscript[\[Omega], 1]] A[l][
Subscript[Subscript[\[Rho]1, 1], 3]] A[r][
Subscript[Subscript[\[Rho]1, 1], 3]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 4]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 4]] S[l, l][\[Nu], \[Mu]] -
5/12 A[l][Subscript[Subscript[\[Rho]1, 1], 3]] A[l][
Subscript[Subscript[\[Rho]1, 1], 5]] A[r][
Subscript[\[Omega], 1]] d[l][\[Phi],
Subscript[\[Omega], 1]] g[r, r][\[Nu], \[Mu]] g[r, r][
Subscript[Subscript[\[Rho]1, 1], 3],
Subscript[Subscript[\[Rho]1, 1], 5]] S[l, l][\[Nu], \[Mu]] -
5/12 A[l][\[Beta]\[Beta]] A[l][
Subscript[Subscript[\[Rho]1, 1], 5]] A[r][\[Beta]\[Beta]] d[
l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 3]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[Subscript[\[Rho]1, 1], 3],
Subscript[Subscript[\[Rho]1, 1], 5]] S[l, l][\[Nu], \[Mu]] +
5/12 A[l][Subscript[Subscript[\[Rho]1, 1], 3]] A[l][
Subscript[Subscript[\[Rho]1, 1], 4]] A[l][
Subscript[Subscript[\[Rho]1, 1], 5]] d[l][\[Phi],
Subscript[\[Omega], 1]] g[r, r][\[Nu], \[Mu]] g[r, r][
Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]1, 1], 3],
Subscript[Subscript[\[Rho]1, 1], 5]] S[l, l][\[Nu], \[Mu]] +
5/12 A[l][Subscript[\[Omega], 1]] A[l][
Subscript[Subscript[\[Rho]1, 1], 4]] A[l][
Subscript[Subscript[\[Rho]1, 1], 5]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 3]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]1, 1], 3],
Subscript[Subscript[\[Rho]1, 1], 5]] S[l, l][\[Nu], \[Mu]] -
5/12 A[l][Subscript[\[Omega], 1]] A[l][
Subscript[Subscript[\[Rho]1, 1], 3]] A[l][
Subscript[Subscript[\[Rho]1, 1], 5]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 4]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 4]] g[r, r][
Subscript[Subscript[\[Rho]1, 1], 3],
Subscript[Subscript[\[Rho]1, 1], 5]] S[l, l][\[Nu], \[Mu]] +
5/12 A[l][Subscript[Subscript[\[Rho]1, 2], 3]] A[l][
Subscript[Subscript[\[Rho]1, 2], 5]] A[r][
Subscript[Subscript[\[Rho]1, 2], 4]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 2], 4]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[Subscript[\[Rho]1, 2], 3],
Subscript[Subscript[\[Rho]1, 2], 5]] S[l, l][\[Nu], \[Mu]] -
5/12 A[l][Subscript[Subscript[\[Rho]1, 1], 6]] A[r][
Subscript[\[Omega], 1]] A[r][
Subscript[Subscript[\[Rho]1, 1], 6]] d[l][\[Phi], \[Nu]] g[r,
r][\[Nu], \[Mu]] S[l, l][Subscript[\[Omega], 1], \[Mu]] -
5/12 A[l][\[Nu]] A[r][Subscript[\[Omega], 1]] A[r][
Subscript[Subscript[\[Rho]1, 1], 6]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 6]] g[r, r][\[Nu], \[Mu]] S[l,
l][Subscript[\[Omega], 1], \[Mu]] +
5/12 A[l][Subscript[Subscript[\[Rho]1, 1], 6]] A[l][
Subscript[Subscript[\[Rho]1, 1], 7]] A[r][
Subscript[Subscript[\[Rho]1, 1], 6]] d[l][\[Phi], \[Nu]] g[r,
r][\[Nu], \[Mu]] g[r, r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 7]] S[l, l][
Subscript[\[Omega], 1], \[Mu]] +
5/12 A[l][\[Nu]] A[l][Subscript[Subscript[\[Rho]1, 1], 7]] A[r][
Subscript[Subscript[\[Rho]1, 1], 6]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 6]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 7]] S[l, l][
Subscript[\[Omega], 1], \[Mu]] -
5/12 A[l][\[Nu]] A[l][Subscript[Subscript[\[Rho]1, 1], 6]] A[r][
Subscript[Subscript[\[Rho]1, 1], 6]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 7]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 7]] S[l, l][
Subscript[\[Omega], 1], \[Mu]] +
5/12 A[l][Subscript[Subscript[\[Rho]1, 1], 6]] A[l][
Subscript[Subscript[\[Rho]1, 1], 8]] A[r][
Subscript[\[Omega], 1]] d[l][\[Phi], \[Nu]] g[r,
r][\[Nu], \[Mu]] g[r, r][Subscript[Subscript[\[Rho]1, 1], 6],
Subscript[Subscript[\[Rho]1, 1], 8]] S[l, l][
Subscript[\[Omega], 1], \[Mu]] +
5/12 A[l][\[Nu]] A[l][Subscript[Subscript[\[Rho]1, 1], 8]] A[r][
Subscript[\[Omega], 1]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 6]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[Subscript[\[Rho]1, 1], 6],
Subscript[Subscript[\[Rho]1, 1], 8]] S[l, l][
Subscript[\[Omega], 1], \[Mu]] -
5/12 A[l][Subscript[Subscript[\[Rho]1, 1], 6]] A[l][
Subscript[Subscript[\[Rho]1, 1], 7]] A[l][
Subscript[Subscript[\[Rho]1, 1], 8]] d[l][\[Phi], \[Nu]] g[r,
r][\[Nu], \[Mu]] g[r, r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]1, 1], 6],
Subscript[Subscript[\[Rho]1, 1], 8]] S[l, l][
Subscript[\[Omega], 1], \[Mu]] -
5/12 A[l][\[Nu]] A[l][Subscript[Subscript[\[Rho]1, 1], 7]] A[l][
Subscript[Subscript[\[Rho]1, 1], 8]] d[l][\[Phi],
Subscript[Subscript[\[Rho]1, 1], 6]] g[r, r][\[Nu], \[Mu]] g[r,
r][Subscript[\[Omega], 1],
Subscript[Subscript[\[Rho]1, 1], 7]] g[r, r][
Subscript[Subscript[\[Rho]1, 1], 6],
Subscript[Subscript[\[Rho]1, 1], 8]] S[l, l][
Subscript[\[Omega], 1], \[Mu]];
Expand
ed your expression, and it really is a sum over different terms, then# //. Module[ {vars = DeleteDuplicates@Cases[#, _[__][y__] :> y, Infinity]} , Thread[vars -> Table[Subscript[\[Tau], k], {k, Length@vars}]] ] & /@ x
. This relabels each terms separately, so that the subscripts restart in each term. Your first expression then evaluates to zero, which I think it should. Is this what you want? $\endgroup$