The behaviour described below could be a bug, or due to my ignorance! (I plead guilty)

Inspired in the example of Kaluza--Klein provided by Kasper, I wanted to play around with more general models than General Relativity. In particular I considered a Lagrangian with quadratic terms in the curvature (Gauss--Bonnet)

```
{\alpha,\beta,\gamma,\lambda,\chi#,\xi,\mu,\nu,\sigma,\rho,\tau}::Indices(position=independent);
D{#}::Derivative;
\partial{#}::PartialDerivative;
g_{\mu \nu}::Metric;
g^{\mu\nu}::InverseMetric;
R_{\mu \nu \sigma \rho}::RiemannTensor;
```

I define some substitutions

```
afin_conex:= \Gamma^{\rho?}_{\mu? \nu?} -> 1/2 g^{\rho? \alpha?}(\partial_{\mu?}{g_{\nu? \alpha?}} + \partial_{\nu?}{g_{\mu? \alpha?}}
- \partial_{\alpha?}{g_{\mu? \nu?}}) + K^{\rho?}_{\mu? \nu?};
curv:= R^{\rho? \sigma?}_{\mu? \nu?} -> \partial_{\mu?}{\Gamma^{\rho?}_{\nu?}^{\sigma?}} - \partial_{\nu?}{\Gamma^{\rho?}_{\mu?}^{\sigma?}} +
\Gamma^{\rho?}_{\mu? \chi1} \Gamma^{\chi1}_{\nu?}^{\sigma?} - \Gamma^{\rho?}_{\nu? \chi1} \Gamma^{\chi1}_{\mu?}^{\sigma?};
Lag:= ( R^{\mu \nu}_{\mu \nu} - 4 \Lambda + \phi /24 (R^{\mu \nu}_{\mu \nu} R^{\rho \sigma}_{\rho \sigma}
- 4 R^{\mu \xi}_{\nu \xi} R^{\nu \lambda}_{\mu \lambda} + R^{\mu \nu}_{\rho \sigma} R^{\rho \sigma}_{\mu \nu}));
```

And try to substitute

`substitute( Lag, curv, repeat=True);`

The summed indices within the substitution are repeated and I get and error

```
ConsistencyException: Triple index \chi1 inside a single factor found.
At:
<string>(2): <module>
```

Ok, I can by pass this by defining two different curvatures $R$ and $Rp$

```
afin_conex:= \Gamma^{\rho?}_{\mu? \nu?} -> 1/2 g^{\rho? \alpha?}(\partial_{\mu?}{g_{\nu? \alpha?}} + \partial_{\nu?}{g_{\mu? \alpha?}}
- \partial_{\alpha?}{g_{\mu? \nu?}}) + K^{\rho?}_{\mu? \nu?};
curv:= R^{\rho? \sigma?}_{\mu? \nu?} -> \partial_{\mu?}{\Gamma^{\rho?}_{\nu?}^{\sigma?}} - \partial_{\nu?}{\Gamma^{\rho?}_{\mu?}^{\sigma?}} +
\Gamma^{\rho?}_{\mu? \chi1} \Gamma^{\chi1}_{\nu?}^{\sigma?} - \Gamma^{\rho?}_{\nu? \chi1} \Gamma^{\chi1}_{\mu?}^{\sigma?};
curvp:= Rp^{\rho? \sigma?}_{\mu? \nu?} -> \partial_{\mu?}{\Gamma^{\rho?}_{\nu?}^{\sigma?}} - \partial_{\nu?}{\Gamma^{\rho?}_{\mu?}^{\sigma?}} +
\Gamma^{\rho?}_{\mu? \chi2} \Gamma^{\chi2}_{\nu?}^{\sigma?} - \Gamma^{\rho?}_{\nu? \chi2} \Gamma^{\chi2}_{\mu?}^{\sigma?};
Lag:= ( R^{\mu \nu}_{\mu \nu} - 4 \Lambda + \phi /24 (R^{\mu \nu}_{\mu \nu} Rp^{\rho \sigma}_{\rho \sigma}
- 4 R^{\mu \xi}_{\nu \xi} Rp^{\nu \lambda}_{\mu \lambda} + R^{\mu \nu}_{\rho \sigma} Rp^{\rho \sigma}_{\mu \nu}));
```

and it works, but the problem persists as I try the next substitution!

Does anyone know what the problem is?