cadabra2 icon indicating copy to clipboard operation
cadabra2 copied to clipboard

Derivatives do not inherit SelfAntiCommuting properly in canonicalise

Open kpeeters opened this issue 7 years ago • 5 comments

They do work in sort_product, so it is most likely a bug in core/Exchange.cc.

kpeeters avatar Aug 24 '18 18:08 kpeeters

See https://cadabra.science/qa/908/derivatives-inheriting-selfanticommuting-canonicalise?show=909#a909 for a test case.

kpeeters avatar Aug 24 '18 18:08 kpeeters

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.)

dpbutter avatar Nov 20 '23 15:11 dpbutter

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.

kpeeters avatar Nov 22 '23 18:11 kpeeters

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.

dpbutter avatar Nov 22 '23 22:11 dpbutter

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.

kpeeters avatar Nov 23 '23 15:11 kpeeters