def riemann_cyclic(t2):
 if isinstance(t2, (TensMul, Tensor)):
  args = [t2]
 else:
  args = t2.args
 a1 = [x.split() for x in args]
 a2 = [[riemann_cyclic_replace(tx) for tx in y] for y in a1]
 a3 = [tensor_mul(*v) for v in a2]
 t3 = TensAdd(*a3)
 if (not t3):
  return t3
 else:
  return canon_bp(t3)

def riemann_cyclic ( t2 ) : if isinstance ( t2 , ( TensMul , Tensor ) ) : args = [ t2 ] else : args = t2 . args a1 = [ x . split ( ) for x in args ] a2 = [ [ riemann_cyclic_replace ( tx ) for tx in y ] for y in a1 ] a3 = [ tensor_mul ( * v ) for v in a2 ] t3 = TensAdd ( * a3 ) if ( not t3 ) : return t3 else : return canon_bp ( t3 )
replace each riemann tensor with an equivalent expression satisfying the cyclic identity .