<<xAct`xTras`

Manifold

$DefInfoQ=False;
$Post=ScreenDollarIndices;

(* DefConstantSymbol[Dim,PrintAs->"D"] (* dimension D*) *)
DefConstantSymbol[s,PrintAs->"s"] 
DefConstantSymbol[γ,PrintAs->"γ"] 
DefConstantSymbol[α,PrintAs->"α"] 
DefConstantSymbol[β,PrintAs->"β"] 
DefConstantSymbol[ξ,PrintAs->"ξ"](* weight *)

I change this to dimension 3, because that’s what you will use later.

DefManifold[M,3,{a,b,c,d,i,j,k}]
DefMetric[-1,g[-a,-b],CD];

$CommuteCovDsOnScalars=True;(* commutation of CovDs on scalars*)

DefTensor[ϕ[],M]

expr=Sqrt[-Detg[]]EinsteinCD[-a,-b] RicciScalarCD[] CD[a][ϕ[]] CD[b][ϕ[]]

Declare the coordinate system you will work with, called polar:

DefChart[polar,M,{0,1,2},{t[],r[],θ[]}]

All specific scalar functions of scalar coordinates must be declared too:

DefScalarFunction[A]
DefScalarFunction[B]

DefScalarFunction[F]

Construct the metric in the given coordinate system:

(metric=CTensor[DiagonalMatrix[{-A[r[]]B[r[]]^2,1/A[r[]],r[]^2}],{-polar,-polar}])[-a,-b]

This is the associated Levi-Civita connection:

metricCD=CovDOfMetric[metric]

Now it’s all a matter of constructing the objects you will want to replace in your expression. Note how you have abstract (xTensor) objects on the LHS of the rules and component (xCoba) objects on the RHS of the rules:

rules={
g[a_?DownIndexQ,b_?DownIndexQ]->metric[a,b],
g[a_?UpIndexQ,b_?UpIndexQ]->Inv[metric][a,b],
Detg->Determinant[metric],
CD->metricCD,
RicciCD->Ricci[metricCD],
EinsteinCD->Einstein[metricCD],
RicciScalarCD->RicciScalar[metricCD],
ϕ[]->F[r[]]
};

expr//.rules//Simplify

expr2=((RicciScalarCD[])^2) CD[-a][CD[a][ϕ[]]]

expr2//.rules//Simplify