cadabra2
cadabra2 copied to clipboard
Derivatives do not inherit SelfAntiCommuting properly in canonicalise
They do work in sort_product, so it is most likely a bug in core/Exchange.cc.
See https://cadabra.science/qa/908/derivatives-inheriting-selfanticommuting-canonicalise?show=909#a909 for a test case.
If I edit properties/Derivative.hh and add "public Inherit<SelfCommutingBehaviour>" to the definition of "class Derivative", then canonicalise behaves as expected.
(In cadabra v1, the corresponding modification goes into modules/algebra.hh.)
Thanks for digging into this! I suspect that there are still issue lurking here (those comments about anti-commuting derivatives in the source point to problems which cannot really be solved with the current setup). But since your fix squashes the bug you reported and it does not break any of the other tests, I have pushed to github now.
Thanks! I also intended to mention that I noticed in pythoncdb/py_properties.cc that there is a line:
using Py_Derivative = BoundProperty<Derivative, Py_IndexInherit, Py_CommutingAsProduct, Py_NumericalFlat, Py_TableauBase, Py_Distributable, Py_WeightBase>;
I don't understand how the python bindings work, and I wasn't sure if this needed to be modified to track with the change in Derivative.cc.
To be consistent this should also include Py_SelfCommutingBehaviour. But those declarations are only there to make the property visible on the Python side; if it is not listed then you will simply not be able to check on the Python side whether a pattern with a a Derivative property has a SelfCommutingBehaviour attached to it.