8.1. MakeRule
Defining rules is one of the most important components of a tensor package. The function IndexRule takes care of dummy generation, but there are other points to consider when defining a rule:
1. Checking consistency between left and right hand sides.
2. Defining rules that work only for a given vbundle.
3. Extending the rule to pattern expressions with equivalent index-structure under symmetries.
4. Extendig the rule to patterns with a different up/down character if metrics are present.
We define the function MakeRule, which takes care of all these things. Note that there is not a parallel function for Set, but below we present a way to automatize a collection of rules.
MakeRule Construct rules between xTensor` expressions
AutomaticRules Automate rules
Construction of rules.
In[778]:=
Out[778]=
The simplest way to define a rule would easily give corrupted answers:
In[779]:=
Out[779]=
In[780]:=
Out[780]=
In[781]:=
Out[781]=
We have seen that changing to IndexRule we can solve those problems (underlined indices denote patterns):
In[782]:=
Out[782]=
In[783]:=
Out[783]=
In[784]:=
Out[784]=
We can also define the same rule using MakeRule. Note that there is no pattern on the lhs; by default all indices on the LHS are converted into patterns:
In[785]:=
Out[785]=
In[786]:=
Out[786]=
In[787]:=
Out[787]//InputForm=
{HoldPattern[v[(a_Symbol)?TangentM3`Q]] :> Module[{h$41203}, T[a, -h$41203]*v[h$41203]]}
Due to the option TestIndices→True, membership of the indices of the LHS is checked. The function M3`Q checks that an up-index belongs to M3, but it does not accept down-indices (this is due to the option MetricOn->None):
In[788]:=
Out[788]=
In[789]:=
Out[789]=
In[790]:=
Out[790]=
In order to allow both up/down-indices of a given vbundle we use MetricOn. We need to have a metric first. (If the vbundle of the index did not have a metric MakeRule would refuse to change the up/down character):
In[791]:=
Out[791]=
In[792]:=
Out[792]//InputForm=
{HoldPattern[v[(a_)?TangentM3`pmQ]] :> Module[{h$41215}, T[a, -h$41215]*v[h$41215]]}
In[793]:=
Out[793]=
In[794]:=
Out[794]=
If we have symmetries the situation gets even more complicated (here we need to use 6 rules):
In[795]:=
Out[795]=
In[796]:=
Out[796]=
In[797]:=
Out[797]=
In[798]:=
Out[798]=
It is possible to automate rules, declaring them as definitions for a symbol, in this case the tensor U:
In[799]:=
In[800]:=
Out[800]=
In[801]:=
Out[801]=
In[802]:=
|
The simplest way to remove those definitions for U is removing the tensor and defining it again:
In[803]:=
In[804]:=
Created by Mathematica (May 16, 2008) |