kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
223 stars 37 forks source link

The NonCommuting CommutingBehaviour can be ignored when canonicalizing expressions #90

Open cls0 opened 6 years ago

cls0 commented 6 years ago

If I understand correctly, consider this (v2.2.0):

{l_{#},m_{#}}::NonCommuting.
$l_{c} m_{b} l_{a}$;
canonicalise(_);

Here, we should not be able to commute each l through m without picking up some unknown commutators. However, this outputs l_{a} m_{b} l_{c}, suggesting that the algorithm assumes that, since l commutes with itself, this expression is symmetric in a,c. This sadly isn't sufficient, so we get the wrong answer.

Note that if alternatively l does not commute with itself, this issue is dodged:

l_{#}::SelfNonCommuting.
$l_{c} m_{b} l_{a}$;
canonicalise(_);

(Prints l_{c} m_{b} l_{a}.)

kpeeters commented 6 years ago

Thanks. This is a bug in core/Exchange.cc in get_node_gs, which should use Ex_comparator::can_move_adjacent but doesn't. Will fix.