Dear community.

I've been reviewing the Poincare algebra notebook, and trying to include the commutations with the momentum operator $P$. In the generalization, I noticed that even if the substitution rule `\commutator{J}{P}`

is defined, expressions including the `\commutator{P}{J}`

do not get substituted.

I included an extra commutation rule by hand and everything worked properly.

**Question:** Is there a way to automate the definition of the commuted `commutator`

?

### Update 1.

After the answer by Kasper, let me provide a piece of code,

First, some definitions from the example in the webpage,

```
{a,b,c,d,m,n,p,q,r,s,t}::Indices.
{a,b,c,d,m,n,p,q,r,s,t}::Integer(0..3).
\eta_{a b}::KroneckerDelta.
\delta{#}::KroneckerDelta.
e_{a b c d}::EpsilonTensor(delta=\delta).
J_{a b}::AntiSymmetric.
J_{a b}::SelfNonCommuting.
{ J_{a b}, P_{a}, W_{a} }::NonCommuting.
{ J_{a b}, P_{a}, W_{a} }::Depends(\commutator{#}).
def post_process(ex):
unwrap(ex)
eliminate_kronecker(ex)
canonicalise(ex)
rename_dummies(ex)
collect_terms(ex)
```

The commutator substitution:

```
subs := \commutator{J_{a b}}{P_{c}} -> \eta_{a c} P_{b} - \eta_{b c} P_{a};
```

If we apply the substitution to the commutator in the reversed order, even if the commutator is an skew-symmetric operator, it returns the initial expression

```
ex1 := \commutator{P_{c}}{J_{a b}};
substitute(ex1, subs);
```

$[P*{c},J*{a b}]$

while the substitution on the expression written in the "right" order returns the expected result,

ex2 := \commutator{J*{a b}}{P*{c}};

substitute(ex2, subs);

$\eta*{a c} P*{b}-\eta*{b c} P*{a}$

#### Re-stated question(s)

- Is it possible to generate an "automatic" substitution rule for
`\commutator{B}{A}`

if the rule`\commutator{A}{B}`

is provided? - Could this be an interesting feature request?
- If the above sounds interesting, it might be generalised to the
`anticommutator`

operator.