<<xACT`xTensor`

DefManifold[M4,4,{a,b,c,d,e,f,g,h,i,j,k,l}]

DefMetric[-1,gg[-i,-j],cd,{";","∇"}]

DefTensor[s[],M4]

DefTensor[contra[i],M4]

contra[i]

DefTensor[covar[-i],M4]

DefTensor[T[-i,-j],M4,Antisymmetric[{-i,-j}]];

T[-i,-j]

T[-i,-j]+T[-j,-i]

T[-i,-j]+T[-j,-i]//ToCanonical

gg[i,k] Riemanncd[-i,-j,-k,-l]//ContractMetric

gg[i,k] Riemanncd[-i,-j,-k,-l]//ContractMetric//InputForm

gg[j,l] Riccicd[-j,-l]//ContractMetric

cd[-i][T[-j,-l]]

cd[-a]@cd[-b]@cd[-c]@T[-d,-e]//ToCanonical

cd[-a][gg[c,d]]

cd[-a]@cd[-b]@cd[-c]@T[-d,-e]//ToCanonical//SortCovDs

$PrePrint=ScreenDollarIndices;

cd[-a]@cd[-b]@cd[-c]@T[-d,-e]//ToCanonical//SortCovDs

DefCovD[CD[-a],{";","∇"}]

term1=Antisymmetrize[CD[-e][RiemannCD[-c,-d,-b,a]],{-c,-d,-e}]

Antisymmetrize[CD[-e][RicciCD[-a,-b]],{-c,-e,-d}]

bianchi2=3 term1//ToCanonical

exp1=bianchi2//CovDToChristoffel

exp2=exp1//RiemannToChristoffel

exp3=exp2//ToCanonical

<<xACT`xPert`

DefMetricPerturbation[gg,pert,ϵ]

PrintAs[pert]^="h";

pert[LI[2],-a,-b]

Perturbation[gg[-a,-b],3]

Perturbation[gg[a,b],1]

Perturbation[gg[a,b],1]//ExpandPerturbation

Perturbation[gg[a,b],2]//ExpandPerturbation

Perturbation[gg[-a,-b],1]//ExpandPerturbation

Perturbation[gg[-a,-b],2]//ExpandPerturbation

Perturbation[gg[a,b],4]//ExpandPerturbation

Perturbed[gg[-a,-b],3]

Perturbed[gg[-a,-b],1]

Perturbed[gg[a,b],1]//ExpandPerturbation

Perturbed[gg[-a,-b],2]

Perturbed[gg[a,b],3]//ExpandPerturbation

firstorderonly=pert[LI[n_],__] :> 0/;n>1;Perturbed[gg[-a,-b],3]/.firstorderonly

DefTensor[sf[],M4]

PrintAs[sf]^= "ϕ" ;

DefTensorPerturbation[pertsf[LI[order]],sf[],M4]

PrintAs[pertsf]^="δϕ";

DefScalarFunction[V]

DefConstantSymbol[massP]

PrintAs[massP]^="m";

L=Sqrt[-1*Detgg[]]*(massP^2*RicciScalarcd[]/2 - V[sf[]]-(1/2)*cd[-b][sf[]]*cd[b][sf[]])

varL=L//Perturbation

varL=L//Perturbation//ExpandPerturbation

varL = L//Perturbation//ExpandPerturbation//ContractMetric

varL = L//Perturbation//ExpandPerturbation//ContractMetric//ToCanonical

0==VarD[pertsf[LI[1]],cd][varL]/Sqrt[-Detgg[]]

0==VarD[pertsf[LI[1]],cd][varL]/Sqrt[-Detgg[]]//ToCanonical

vartf=2 (-VarD[pert[LI[1],a,b],cd][varL]/Sqrt[-Detgg[]])

delta[-LI[1],LI[1]]-> 1;

vartf=2 (-VarD[pert[LI[1],a,b],cd][varL]/Sqrt[-Detgg[]])/.delta[-LI[1],LI[1]]-> 1//Simplification

vartf=2 (-VarD[pert[LI[1],a,b],cd][varL]/Sqrt[-Detgg[]]//SeparateMetric[gg]//RicciToEinstein)//Expand//ContractMetric//ToCanonical

delta[-LI[1],LI[1]]-> 1;

vartf/.delta[-LI[1],LI[1]]-> 1

0==vartf/.delta[-LI[1],LI[1]]-> 1

eterm=IndexCollect[cd[a]@vartf/.delta[-LI[1],LI[1]]-> 1//ToCanonical,CD[-b][sf[]]]//Simplification

0==eterm

gg[a,b]

UndefCovD[CD]

UndefTensor/@{contra,covar}

UndefScalarFunction[V]

UndefConstantSymbol[massP]

UndefTensor[pert]

UndefMetric[gg]

UndefTensor[pertsf]

UndefTensor[sf]

UndefTensor[T]

UndefTensor[pertGG]

UndefTensor[gPert]

UndefManifold[M4]

?Global`*