Cadabra
a field-theory motivated approach to computer algebra

Indices

Declare names to be used as indices.
Declare index names to be usable for dummy index purposes. Typical usage is of the form
{r,s,t}::Indices(vector); {a,b,c,d}::Indices(spinor);
\(\displaystyle{}\text{Attached property Indices(position=free) to }(r, s, t).\)
\(\displaystyle{}\text{Attached property Indices(position=free) to }(a, b, c, d).\)
This indicates the name of the index set ("vector" resp. "spinor" in the example above).
Indices can occur as subscripts or superscripts, and you may use this to indicate e.g. covariant and contravariant transformation behaviour. In this case, use the additional argument position=fixed to indicate that the position carries meaning. If you do not want cadabra to automatically raise or lower indices when canonicalising expressions, or if upper and lower indices are not related at all, use position=independent. The default is position=free, which means that indices in a pair can be positioned anywhere and their position carries no meaning. Be aware that this is not what you want if there is a metric involved!
When you work with vector spaces which are subspaces of larger spaces, it is possible to indicate that a given set of indices take values in a subset of values of a larger set. An example makes this more clear. Suppose we have one set of indices $A,B,C$ which take values in a four-dimensional space, and another set of indices $a,b,c$ which take values in a three-dimensional subspace. This is declared as
{A,B,C}::Indices(fourD); {a,b,c}::Indices(threeD, parent=fourD);
\(\displaystyle{}\text{Attached property Indices(position=free) to }(A, B, C).\)
\(\displaystyle{}\text{Attached property Indices(position=free) to }(a, b, c).\)
This will allow Cadabra to canonicalise expressions which contain mixed index types, as in
{A,B,C}::Indices(fourD); {a,b,c}::Indices(name=threeD, parent=fourD); M_{q? r?}::AntiSymmetric; ex:=M_{a A} + M_{A a};
\(\displaystyle{}\text{Attached property Indices(position=free) to }(A, B, C).\)
\(\displaystyle{}\text{Attached property Indices(position=free) to }(a, b, c).\)
\(\displaystyle{}\text{Attached property AntiSymmetric to }{M}_(q?r?).\)
\(\displaystyle{}M_{a A}+M_{A a}\)
canonicalise(_);
\(\displaystyle{}0\)
Note the way in which the symmetry of the $M$ tensor was declared here.

Index values

For various algorithms (e.g. evaluate) it is necessary to specify the values that a particular index can take. The value of an index needs to be either a Coordinate or a Symbol, or it can be an integer. The following are all valid:
{x,y,z}::Coordinate. {a,b,c}::Indices(values={x,y,z}). {d,e,f}::Indices(values={0,1,3}). {m,n,p}::Indices(values={0,1,2}). {q,r,s}::Indices(values={0..3}).
When values is a sequence or a list of integers with no gaps, an automatic Integer property will be generated that reflects these values. So e.g. the last line above (but not the middle line) leads to an automatic attachment
{m,n,p}::Integer(0..3).
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science