# Manipulating matrix valued differential forms

Dear community, I'm trying to manipulate matrix valued differential forms. By academic deformation, I'm used to work in models with extra dimensions (say five to analyse the simplest case).

The problem I'm having is with the order of indices and elements of the expressions.

Below the calculations:

## Example of notebook

### Some initial definitions

{A,B,C,L,M,N,P,Q}::Indices(full,position=independent);
{\alpha,\beta,\mu,\nu,\lambda,\rho,\sigma}::Indices(position=independent, parent=full);
d{#}::ExteriorDerivative.
d{#}::LaTeXForm("\mathrm{d}").
\delta{#}::KroneckerDelta.
G_{M N}::Metric(signature=-1).
G^{M N}::InverseMetric.
\epsilon{#}::EpsilonTensor(metric=G);


### Notation and properties

eh{#}::LaTeXForm("\hat{e}").
oh{#}::LaTeXForm("\hat{\omega}").
Rh{#}::LaTeXForm("\hat{R}").
Th{#}::LaTeXForm("\hat{T}").
{eh^{A?}, oh^{A? B?}}::DifferentialForm(degree=1);
{Th^{A?}, Rh^{A? B?}}::DifferentialForm(degree=2);
{oh^{A? B?}, Rh^{A? B?}}::AntiSymmetric.
Rh^{A? B?}::SelfCommuting.
eh^{A?}::SelfAntiCommuting.
{\epsilon{#}, Rh^{4 B}, Rh^{A B}, eh^{m}, eh^{4}}::SortOrder;


### Working a term

Lambda := \epsilon_{A B C L M} eh^{A} ^ eh^{B} ^ eh^{C} ^ eh^{L} ^ eh^{M};
split_index(Lambda, $M, m, 4$, repeat = True)
sort_product(_)
canonicalise(_);


The result is shown in the ## Discussion

As you can see, the wedge product is not sorted properly, nor the indices!
the right result should be

$$\epsilon_{a b c l m} \hat{e}^{m}\wedge \hat{e}^{a}\wedge \hat{e}^{b}\wedge \hat{e}^{c}\wedge \hat{e}^{l} - 5\epsilon_{4 a b c l} \hat{e}^{l}\wedge \hat{e}^{a}\wedge \hat{e}^{b}\wedge \hat{e}^{c}\wedge \hat{e}^{4}.$$

Any suggestion on how to manipulate correctly these expressions?

Update: Looking at the source code I found that the algorithm indexsortis implemented, but the problem persists. It seems to be a "bug" with the sort_product and canonicalise algorithms on differential forms.

Yes, that's a bug, or rather, an incompleteness: you cannot yet have matrix-valued differential forms, and any such property (in your case the eh^{A?}::SelfAntiCommuting.) is silently ignored by the building blocks underlying sort_product and canonicalise. It's not terribly hard to add, I'll put it on the list (won't happen before next week).
Thank you Kasper for the helpful explanation, and unstoppable labor in the development of cadabra. I'll be aware of your updates.