Good night to all.
I am posting here because I am not sure if a rule [to be used in a “replace all” command in Wolfram Mathematica] is true or false. I could not find a reference to that calculation in the Wolfram documentation nor in the literature.
The sample calculation is just a tiny part of a much more complicated one, I am looking for identities to simplify expressions like [see notation below].
Transpose[(a*b*c).v,permv]
For example, by expanding it to (given suitable arrays “a”, “b”, “c”, and “v”)
a*(b*Transpose[c,permv]).v
The sample [simpler] calculation is below, to be done on Wolfram Mathematica [version 15.01] using the “Symbolic Arrays” functions.
The computation is the following:
- The candidate rule
[N.B. the product shown there is just the simple element by element multiplication
(i.e. “Times[a,b]” in Wolfram Language, not the “dot” product (“.”)
To be true, I guess that is necessary the following:
a) the array “a” must be of smaller depth than the array “b” (for example, “a” could be a vector and “b” could be a higher-order array)
b) the dimensions of “a” must be a subsequence of “b” (for example “a” could have dimensions {dim1} and “b” dimensions {dim1, dim2, dim3}, where dim1, dim2 and dim3 could be any positive integer.
c) the permutation vector “permv” should not touch the dimensions linked to “a”. For example, the permutation vector {1,3,2} should change the dimensions of the result from {dim1,dim2,dim3} to {dim1,dim3,dim2}, leaving “dim1” in its place.
- Example: [here I use the Wolfram Mathematica “Symbolic Arrays” functions].
First of all, the proposed rule:
condition1[a_,b_]:=0<TensorRank[a]<TensorRank[b];
condition2[a_,b_]: = MatchQ[TensorDimensions[a],Take[TensorDimensions[b],TensorRank[a]]]
condition3[a_,b_,permv_]: = MatchQ[TensorDimensions[a],Take[TensorDimensions[Transpose[b,permv]],TensorRank[a]]]
rule=Transpose[a_*b_,permv_]/;(condition1[a,b]&&condition2[a,b]&&condition3[a,b,permv]):>a*Transpose[b,permv]
Then, an example. Introducing this:
A = ArraySymbol[a,{dim1}];
B = ArraySymbol[b,{dim1,dim2,dim3}];
permv={1,3,2};
And doing this:
AB = A*B;
ABt = Transpose[A*B,permv]
testRule = ABt == (ABt/.rule)
The rule should result in:
testRule = Transpose[A*B,permv]===A*Transpose[B,permv]
I have run a sample notebook [attached] with 2 examples. However, this is not a proof, only a guess, and so I am not sure if someone could find a counter-example where the stated identity (with 3 conditions) is not valid.