# Symbolic reduce of augmented matrices with TensorReduce

I am trying to reduce a symbolic matrix expression containing augmented/concatenated matrices using TensorReduce, but it does not behave as expected when transposing an augmented matrix.

I assume the problem is that building a matrix from multiple submatrices creates a tensor of higher dimension instead of a bigger 2d tensor, but I do not know how to create a symbolic 2d tensor from multiple smaller symbolic 2d tensors.

As an example

$Assumptions = { Element[P, Matrices[{n, n}]] }; TensorReduce[Transpose[{{P, P}}]]  yields {{P}, {P}}  and not {{Transpose[P]}, {Transpose[P]}}  which is the result I would expect. ## 2 Answers The tensor functionality will not produce a mixed output of explicit and symbolic matrices. That is, the tensor will remain symbolic unless all of the parts are explicit matrices/arrays. Also, it is better to use TensorTranspose instead of Transpose when dealing with tensors. At any rate, we can write your expression as both a mixed expression and as a tensor expression as follows: mixed = {{P, P}}; tensor = TensorProduct[{{1, 1}}, P];  Let's check that the two are equivalent by substituting an explicit matrix for P: mixed == tensor /. P->Array[a, {3,3}]  True Now, the tensor framework, and in particular TensorTranspose, does not know how to deal with this mixed form. For example: $Assumptions = P ∈ Arrays[{n, n}];
TensorTranspose[{{P, P}}, {1, 2, 4, 3}]


TensorTranspose::lowlen: Required length 2 is smaller than maximum 4 of support of {1,2,4,3}.

TensorTranspose[{{P, P}}, {1, 2, 4, 3}]

On the other hand, TensorTranspose (as well as Transpose) knows how to deal with the tensor form:

transpose = TensorReduce @ TensorTranspose[tensor, {1, 2, 4, 3}]


TensorTranspose[P \[TensorProduct] {{1, 1}}, {4, 3, 1, 2}]

Let's check that this agrees with your expected result when substituting an explicit matrix for P:

expected = {{Transpose[P], Transpose[P]}};
expected == transpose /. P->Array[a, {3,3}]


True

Summarizing, if you use:

TensorProduct[{{1, 1}}, P]


{{P, P}}


then the tensor framework is more likely able to do some transformations of the input.

What you are expecting does not happen for a number of reasons. Firstly, I think, Transpose operates on the assumption that the elements of the list are scalars, regardless of any assumption you give.

Assuming[Element[P, Matrices[{n, n}]], Transpose[{{P, P}}]]
(* {{P}, {P}} *)


TensorReduce has nothing left to do here.

Further, according to the documentation, Transpose "transposes the first two levels in list". This means that

 With[{P = Array[a, {2, 2}]}, Print[P]; Transpose[{{P, P}}]]

(* {{a[1,1],a[1,2]},{a[2,1],a[2,2]}} *)
(* {{{{a[1, 1], a[1, 2]}, {a[2, 1], a[2, 2]}}}, {{{a[1, 1],
a[1, 2]}, {a[2, 1], a[2, 2]}}}} *)


So the matrices inside do not get transposed.