Hi again Teake,
> Thanks for the reply! Let me try to recap what you said:
>
> * The Module in the rule takes care of repeated dummy indices (because
> for every replacement it generates a new one).
We have to be more precise here. The Module is there to avoid what I
call "dummy collisions": If you start with a syntactically correct
product of two tensors (scalars or not) and you replace both of them
by expressions containing dummy indices then it might happen that you
end up with a tensor product with a repeated pair of dummy, say T[a,-
a] U[a,-a]. That is a dummy collision and must be avoided. The way
this works in xTensor is by producing a new dummy index any time that
a rule dealing with dummies is used. This is done by abusing Module to
produce b$12031 from b, with a different number in each call. Execute
this line in Mathematica:
{ a, a } /. a :> Module[ { b }, b ]
The important thing there is not that we change a to b, but that b has
a different number after the dollar each time the rule is used.
Now, concerning "index repetition", let also try to fix the terms of
the discussion:
1) The expression T[ a, -a ] does not contain repeated indices. The
indices a and -a are different, but they both form a dummy pair.
2) The expression T[ a, -a ] + U[ a, -a ] does not contain repeated
indices, and it is perfectly syntactically correct. Dummies in
different terms of a sum are independent. The danger of collision is
always in the products (and in the powers, which represent products).
3) The expression T[ a, a, b, -b ] contains repeated free indices. It
is syntactically incorrect.
4) The expression T[ a, -a, b ] U[ a, -a, c ] contains repeated dummy
indices (a dummy collision). It is syntactically incorrect.
> * This only fails if Mathematica rewrites two tensors as one
> expression.
I don't understand such very general statement. There is nothing wrong
in Mathematica converting S[] S[] into S[]^2, or S[] + S[] into 2 S[].
Mathematica is an eager evaluator and will try to advance your
computation as much as possible as soon as possible. That is a very
good thing in general, and xTensor follows that principle as well.
However, there is the (unrelated) issue of using rules scalar ->
tensor_with_dummies on products and powers, and there xTensor is
designed so that the user has to decide whether to use Scalar or not.
Perhaps MakeRule or even IndexRule should send a warning message
reporting the fact that such rules might be dangerous in some
scenarios.
> * But this only happens for products of identical scalars, for which
> the above problem can be circumvented with a PutScalar.
Scalar is a general solution to a more general problem. Scalar fully
shields dummies so that the expression Scalar[ v[a] v[-a] ] can be
treated as s[]. Think for example of the expression 1 / (1 + s[] ) and
now try to replace s[] by v[a]v[-a]. Suddenly we find dummies in a
denominator, and that might confuse xTensor quite seriously. Imagine
an operation like (T[b, -a] v[a] ) / ( v[a] v[-a ] ) in which both
numerator and denominator are well defined, but Mathematica is going
to destroy that expression immediately. If you wrap the denominator
with Scalar, then it works fine.
> In my example, an 'good' RHS can also be obtained by doing
> NoScalar[PutScalar[wrongRHS]]. I'm guessing this equivalent to keeping
> the Scalar head in the rule and getting rid of it after replacement,
> right?
Not really. The Scalar head must be there at the moment of using the
rule. That is, PutScalar must be used before using the rule and
NoScalar must be used after using the rule. If you are telling me that
both PutScalar and NoScalar are in the delayed RHS of the rule (i.e.
inside the Module) then it might also work, but it is unnecessarily
complicated.
> There's still one thing that bugs me about this issue, and that's the
> fact that Validate doesn't approve of repeated indices on different
> tensors, but does of repeated indices on identical tensors:
>
> U[-a, -b, b] + T[b, -b] // Validate (* problem *)
Isn't this a problem because the free indices are inhomogeneous? I
mean, change T[b,-b] to T[b,-b,-a] and it should work, as I said
above. Are you working with any graded algebra allowing addition of
tensors of different ranks? xTensor does not support such a thing.
> U[-a, -b, b] + U[b, -b, -a] // Validate (* ok *)
>
> Normally I wouldn't write down either one of those two lines, and
> would like to see Validate reject them both. Is there a reason why the
> last line is accepted?
The last line is perfectly OK, assuming your vector space has a
metric. Sums are never a problem with dummies.
Cheers,
Jose.