MakeRule conditions

622 views
Skip to first unread message

Teake

unread,
Sep 12, 2011, 2:25:27 PM9/12/11
to xAct Tensor Computer Algebra
Hi all,

I hope you're not getting tired of reading my e-mails, as I feel I've
been spamming the mailing list lately. But does anybody know how to
get the conditions in MakeRule to work? I've tried
MakeRule[{LHS,RHS,True}] as a test condition, but that fails with the
message Validate::inhom. If anybody could explain the correct syntax
to me I'd be grateful!

I (think I) need this for converting expressions of Christoffel
symbols into Riemann tensors (much like the GradMetricToChristoffel
function does for converting metrics to Christoffels). My approach is
to make a rule that converts a partial derivative of a Christoffel
into a Riemann tensor + squares of Christoffels + another PD of a
Christoffel.
But as the PDs of Christoffels come in (antisymmetric) pairs, applying
this rule to both at the same time gets you nowhere. So you're better
of if you only apply the rule if the PD of a Christoffel has all its
lower indices in a particular (canonical) order. The other PD of a
Christoffel, being antisymmetric in an index pair, will have a
different ordering of its lower indices and will not get replaced. Did
that make sense?

But for the above to work I need figure out how the conditions in
MakeRule work. Any help is appreciated!
Best,

Teake Nutma

TB

unread,
Sep 12, 2011, 3:08:14 PM9/12/11
to xAct Tensor Computer Algebra
Hi!

There is an easier way to solve your problem. I will come back to that
soon...

I usually use equations all the time and therefore I have function
that makes rules from equations with the help of MakeRule.
I define two variants:

ApplyRule[LHS_ == RHS_] := MakeRule[Evaluate[{LHS, RHS}], MetricOn ->
All, ContractMetrics -> True]
ApplyRuleN[LHS_==RHS_]:=MakeRule[Evaluate[{LHS,RHS}]]

The ApplyRuleN is used if you don't allow contractions with metrics as
in your case.

The equation you want to use is the following (but backwards):

RiemannToPDChristoffel=RiemannCD[-a,-b,-
c,d]==ChangeCurvature[RiemannCD[-a,-b,-c,d],CD,PD]

This produces a rule where you replace the last term (one partial
derivative) with the Riemann etc.

RiemannToPDChristoffel[[2,-1]]==RiemannToPDChristoffel[[2,-1]]-
RiemannToPDChristoffel[[2]]+RiemannToPDChristoffel[[1]]
PDChristoffelRule1 = ApplyRuleN@%

The trick is now to use it only on half the expression you want.
For instance if you have the right hand side of RiemannToPDChristoffel
and want to turn it to a Riemann tensor. Do the following:

RiemannToPDChristoffel[[2]]
ToCanonical[%/2 + (% /. PDChristoffelRule1)/2]

I hope this solves your problem.

I have found that making a convex combination of the original
expression and a manipulated expression is very useful.
For instance it can be used when commuting derivatives.

Regards
Thomas Bäckdahl

JMM

unread,
Sep 12, 2011, 3:18:00 PM9/12/11
to xAct Tensor Computer Algebra
Hi Teake,

> I hope you're not getting tired of reading my e-mails, as I feel I've
> been spamming the mailing list lately.

I think it is a good idea to post all xAct-related questions in this
mail list because then other users are aware of the problem and know
the answers. It also contributes to construct an archive that can be
searched.

> But does anybody know how to
> get the conditions in MakeRule to work? I've tried
> MakeRule[{LHS,RHS,True}] as a test condition, but that fails with the
> message Validate::inhom. If anybody could explain the correct syntax
> to me I'd be grateful!

Assuming LHS and RHS are symbols, that command should work as you
wrote it, and return

{HoldPattern[LHS] :> Module[{}, RHS] /; True}

If LHS and RHS are tensor expressions then MakeRule will do index
checking. Note that indices in LHS must not contain patterns because
MakeRule will decide for you which indices must be converted into
patterns. In principle the third argument (the condition) is
completely innert and will be put in the Condition expression inside
Module. For example:

DefManifold[ M, 4, {a, b, c, d} ]
DefTensor[T[a, -b], M]
MakeRule[ { T[a, -b] T[b, -c], T[b, -b] T[a, -c],
conditiononindices[a, c] } ]

That should return a valid condition. Note that index checking does
not worry about the condition.

> I (think I) need this for converting expressions of Christoffel
> symbols into Riemann tensors (much like the GradMetricToChristoffel
> function does for converting metrics to Christoffels). My approach is
> to make a rule that converts a partial derivative of a Christoffel
> into a Riemann tensor + squares of Christoffels + another PD of a
> Christoffel.

Yes. This would be a GradChristoffelToRiemann.

> But as the PDs of Christoffels come in (antisymmetric) pairs, applying
> this rule to both at the same time gets you nowhere. So you're better
> of if you only apply the rule if the PD of a Christoffel has all its
> lower indices in a particular (canonical) order. The other PD of a
> Christoffel, being antisymmetric in an index pair, will have a
> different ordering of its lower indices and will not get replaced. Did
> that make sense?
> But for the above to work I need figure out how the conditions in
> MakeRule work. Any help is appreciated!

That makes perfect sense to me. Note also this trick: if T[a,b] is
defined as

T[a,b] = H[a,b] - H[b,a] + rest[a,b]

and you want to get H then, because only the antisymmetric part of H
is given, you have

H[a,b] = ( T[a,b] - rest[a,b] ) / 2 + S[a,b]

where S[a,b] is some arbitrary symmetric tensor. You can use that
formula, that does not require conditions, and if at the end all S
tensors cancel then you know that your original expression containing
H's could be indeed reexpressed in terms of T[a,b].

Cheers,
Jose.

Teake Nutma

unread,
Sep 12, 2011, 3:34:18 PM9/12/11
to xAct Tensor Computer Algebra
> Assuming LHS and RHS are symbols, that command should work as you
> wrote it, and return
>
> {HoldPattern[LHS] :> Module[{}, RHS] /; True}
>
> If LHS and RHS are tensor expressions then MakeRule will do index
> checking. Note that indices in LHS must not contain patterns because
> MakeRule will decide for you which indices must be converted into
> patterns. In principle the third argument (the condition) is
> completely innert and will be put in the Condition expression inside
> Module. For example:
>
> DefManifold[ M, 4, {a, b, c, d} ]
> DefTensor[T[a, -b], M]
> MakeRule[ { T[a, -b] T[b, -c], T[b, -b] T[a, -c],
> conditiononindices[a, c] } ]
>
> That should return a valid condition. Note that index checking does
> not worry about the condition.

Thanks for the explanation. I figured it had to work like that, but
for some reason it didn't. Turns out it doesn't work if you load xPert
first. Can this be remedied?

Cheers,

Teake

Leo Stein

unread,
Sep 12, 2011, 5:56:44 PM9/12/11
to Teake, xAct Tensor Computer Algebra
Teake,

If I may ask, why do you have to deal explicitly with Christoffels? In
your earlier email, you said that you were getting equations of motion
from different Lagrangians. If your are doing metric variation and you
have a Lagrangian built only out of the metric, its determinant, a
metric-compatible connection, and the curvature tensors of that
connection, then you should not have to encounter Christoffel.
What you do is something like this (of course, feel free to ignore my
example if I am guessing wrong about what it is you're doing! but
somebody else may find this code useful):

Needs["xAct`xPert`"];
DefManifold[M, 4, IndexRange[a, q]];
DefMetric[-1, met[-a, -b], CD, PrintAs -> "g", WeightedWithBasis -> AIndex];
DefMetricPerturbation[met, metpert, eps];
PrintAs[metpert] ^= "h";
DefConstantSymbol /@ {c1, c2, c3};
L = Sqrt[-Detmet[]] (c1 RicciScalarCD[] + c2 RicciScalarCD[]^2 + c3
RicciCD[-a, -b] RicciCD[a, b]);
Lpert = ToCanonical@ContractMetric@ExpandPerturbation@Perturbation@L;
VarL = VarD[metpert[LI[1], a, b], CD][Lpert]/Sqrt[-Detmet[]] /.
delta[-LI[1], LI[1]] -> 1 // ContractMetric // SortCovDs //
ToCanonical;

PreferDivOfRule[ tens_ ] := {
expr : (CD[ a_]@CD[b_]@inside_) :> CommuteCovDs[expr, CD, {b, a}] /;
(! FreeQ[inside, tens[___, -a, ___]]),
expr : (CD[-a_]@CD[b_]@inside_) :> CommuteCovDs[expr, CD, {b, a}] /;
(! FreeQ[inside, tens[___, a, ___]])};

EOM = (0 == Collect[
VarL /. PreferDivOfRule[RicciCD] // RicciToEinstein //
EinsteinToRicci // ContractMetric // ToCanonical,
{c1, c2, c3}])

> 0 == c1 (- RicciCD[-a, -b] + 1/2 met[-a, -b] RicciScalarCD[]) + c2 ( ... 4 terms ...) + c3 ( ... 5 terms ... )

No Christoffels appear in the above calculation, since the VarD is
with respect to the metric compatible derivative CD. You can prove to
yourself that this works with a scalar density action, as long as you
include the factor of Sqrt[-Detmet[]].

Cheers
Leo

Teake

unread,
Sep 13, 2011, 4:03:39 AM9/13/11
to xAct Tensor Computer Algebra
Leo,

I'm dealing with Christoffels because I'm doing a (sort of) Kaluza-
Klein reduction. I put in a reduction Ansatz for the metric, and let
xAct compute the lower-dimensional curvature tensors in terms of the
components of the higher-dimensional metric. This doesn't give you
automatically a nice-looking answer containing curvature tensors of
the lower-dimensional manifold, and hence my original question.

But for something else I am computing e.o.m. w.r.t. the metric, and
your code looks quite nice. The trick of going from Ricci's to
Einstein's and back again is to use the covariant constancy of the
Einstein tensor to make certain terms cancel, right?

And thanks Thomas for your code, that might prove to be useful.

Best wishes,


Teake

Teake

unread,
Sep 13, 2011, 6:17:09 AM9/13/11
to xAct Tensor Computer Algebra
Hi all,

I have isolated the reason why MakeRule[{LHS,RHS,cond}] didn't work in
my case. It turns out that the private xTensor function
'addconditions' fails if you set $PrePrint = ScreenDollarIndices
(which is something the xPert package does automatically). Why it
doesn't work is beyond me though. The easy fix for now is to not turn
on ScreenDollarIndices, but I'm hoping Jose will come up with
something better :).

Best,

Teake

Teake

unread,
Sep 13, 2011, 12:20:50 PM9/13/11
to xAct Tensor Computer Algebra
Yet another update from me on this issue (and hopefully the last):
turns out the last statement wasn't entirely correct. The
'addconditions' function works, it's just that ScreenDollarIndices
chokes on the resulting rule. The rule works fine when applied to an
expression though.

Best,

Teake

JMM

unread,
Sep 14, 2011, 12:16:08 PM9/14/11
to xAct Tensor Computer Algebra
Thanks Teake for tracking down the problem to ScreenDollarIndices. The
problem is that if we use conditions then we need to handle objects
like Condition[ tensor, condition ] and I have not trained FindIndices
to look for indices in the first argument of those, and that affects
the formatting routines. There is an easy fix:

Go to the file xAct/xTensor.m and look for the line

FindIndices[expr_Monomial]:=FindIndices1[expr,1];

It is line 2356 in my copy. Right after that line add this other one:

FindIndices[expr_Condition]:=FindIndices1[expr,1];

Your problems should disappear then.

Thanks for reporting this issue!
Jose.
Reply all
Reply to author
Forward
0 new messages