sympy/sympy — pull request #1699 by pernici (2012-12-20 12:33:18+00:00)
Title: Tensor expressions with canonicalization

It is implemented a tensor class with monoterm canonicalization
and algebraic operations on tensors.

There are two applications:

check of identities involving the cyclic symmetry of the Riemann tensor

```
>>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, TensorSymmetry, TensorType, riemann_cyclic, riemann_bsgs
>>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L')
>>> i, j, k, l = tensor_indices('i,j,k,l', Lorentz)
>>> symr = TensorSymmetry(riemann_bsgs)
>>> R4 = TensorType([Lorentz]*4, symr)
>>> R = R4('R')
>>> t = R(i,j,k,l)*(R(-i,-j,-k,-l) - 2*R(-i,-k,-j,-l))
>>> riemann_cyclic(t)
0
```

gamma matrices in dimensional regularization

```
>>> from sympy import Symbol, S
>>> from sympy.tensor.tensor import (TensorIndexType, tensor_indices,\
TensorSymmetry, get_symmetric_group_sgs, TensorType, Tensor)
>>> from sympy.tensor.dgamma_matr import GammaMatrices
>>> D = Symbol('D')
>>> Lorentz = TensorIndexType('Lorentz', dim=D, dummy_fmt='L')
>>> sym1 = TensorSymmetry(get_symmetric_group_sgs(1))
>>> S1 = TensorType([Lorentz], sym1)
>>> GM = GammaMatrices(Lorentz)
>>> gamma_trace = GM.gamma_trace
>>> G = GM.G
>>> m0, m1, m2, m3 = tensor_indices('m0,m1,m2,m3', Lorentz)
>>> gamma_trace(G(m0)*G(m1)*G(-m0)*G(m3))
(-4*D + 8)*metric(m1, m3)

>>> p, q = S1('p,q')
>>> t = G(m0)*G(m1)*G(m2)*G(m3)*p(-m1)*q(-m3)
>>> gamma_trace(t)
-4*metric(m0, m2)*p(L_0)*q(-L_0) + 4*p(m0)*q(m2) + 4*p(m2)*q(m0)
```