
def test01():
   __cdbkernel__=create_scope()
   t::Coordinate;
   {\mu,\nu}::Indices(spacetime);
   {i,j,k}::Indices(space, parent=spacetime);
   ex:= A_{\mu} B^{\mu};
   split_index(_, $\mu, t, i$)
   print("Test 01 passed")

test01()

def test02():
   __cdbkernel__=create_scope()
   \partial{#}::Derivative;
   t::Coordinate;
   {i,j}::Indices;
   ex:=\partial_{t}{ \psi_{1} } \partial_{i}{ v0_{i} } 
      -\partial_{i}{ v0_{i} } \partial_{t}{ \psi_{1} }    ;
   sort_product(_)
   assert(ex==0)
   print("Test 02 passed")

test02()

def test03():
   __cdbkernel__=create_scope()
   {\mu, \nu, \rho, \sigma, \alpha, \beta, \gamma, \delta, \tau}::Indices(full);
   {t, r, \theta, \phi}::Coordinate;
   {a, b, c, d, e, f, g, h, i, j, k, l, m, n, s}::Indices(space1, values={t, r});
   {A, B, C, E, F, G, H}::Indices(space2, values={\theta, \phi});
   {\theta, \phi}::Coordinate;
   D{#}::Derivative;
   \partial{#}::PartialDerivative;
   duRaA:=duR_{\mu a A \sigma} = \frac{1}{2} e_{\mu a}^{\alpha \beta} R_{\alpha \beta A \sigma};
   ex:=K_{a A} = D_{\tau}{D_{\sigma}{\Theta}} duR^{\tau}_{a A}^{\sigma};
   substitute(ex, duRaA)
   split_index(_, $\mu, a, A$)
   tst:= (K_{a A} = 1/2 D_{\tau}{D_{\sigma}{\Theta}} e^{\tau}_{a}^{b \beta} R_{b \beta A}^{\sigma}
       + 1/2 D_{\tau}{D_{\sigma}{\Theta}} e^{\tau}_{a}^{B \beta} R_{B \beta A}^{\sigma}) - @(ex);
   assert(tst==$0=0$)
   print("Test 03 passed")

test03()
