Rules among tensor expressions. There are two levels to consider: 1) ensuring syntactically correct rules and 2) having flexible ways of producing rules.
Given the simple structure of our tensor expressions, it is tempting to construct simple rules to replace tensors by other tensor expressions. However that would inmediately produce syntactic errors, like repeated indices (see examples of this in xTensorDoc.nb). xTensor` generalizes the four main rule constructs to work with indexed expressions, with new names having the prefix Index:
Rule IndexRule (infix notation RightTeeArrow)
RuleDelayed IndexRuleDelayed
Set IndexSet (infix notation DoubleRightTee)
SetDelayed IndexSetDelayed
The function MakeRule offers a large flexibility in constructing tensor rules and their equivalents under certain changes, as controlled by its options. The syntax is either MakeRule[{lhs, rhs}, options] or MakeRule[{lhs, rhs, conditions}, options] if we want to add conditions (head Condition) to the final rules. Possible options are:
PatternIndices: indices to be converted into patterns
TestIndices: whether vbundle of indices must be checked
MetricOn: indices on which the metric must be used
UseSymmetries: whether symmetries of tensors must be used or not
ContractMetrics: whether to contract metric factors on the rhs
Verbose: report on the internal progress
The rules produced by MakeRule or any other rules can be converted into permanent definitions (like those produced by Set) using the function AutomaticRules. This function works like the TagSet family, deciding whether the rule must be defined as a downvalue or an upvalue for a given symbol. If none of those is possible then the rule is appended to the list $Rules, which must be imposed explicitly by the user.
Created by Mathematica (May 16, 2008) | ![]() |