Hi,
There are two problems in your code:
1. You have TorsionCD (which is zero, because it is the torsion of the Levi-Civita connection) instead of TorsionCDT in a couple of places.
2. Indexed assignments need IndexSet and patterns.
So the code would be something like this:
<< xAct`xTensor`
$PrePrint = ScreenDollarIndices;
DefManifold[M, 4, {a, b, c, d, e, f, h, i, j}];
DefMetric[-1, g[-a, -b], CD];
DefCovD[CDT[-a], SymbolOfCovD -> {"#", "D"}, Torsion -> True, FromMetric -> g];
DefTensor[T[-a], M];
IndexSet[T[a_], 1/3 TorsionCDT[b, a, -b]]
DefTensor[S[-a], M]
IndexSet[S[a_], 1/6 epsilong[b, c, d, a] TorsionCDT[-b, -c, -d]]
DefTensor[q[-a, -b, -c], M]
IndexSet[q[a_, b_, c_], TorsionCDT[a, b, c] - (T[b] g[a, c] - T[c] g[a, b]) + epsilong[a, b, c, d] S[-d]]
Delta = -TorsionCDT[a, -a, -b] TorsionCDT[c, -c, b] - 1/2 TorsionCDT[a, b, c] TorsionCDT[-b, -c, -a] + 1/4 TorsionCDT[c, a, b] TorsionCDT[-c, -a, -b]
Then we can check your relation:
-Delta + (-6 T[-a] T[a] + 3/2 S[-a] S[a] + 1/2 q[a, b, c] q[-a, -b, -c]) // ContractMetric // ToCanonical
(* 0 *)
Cheers,
Jose.