Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
0 votes

This may be more of a feature than a bug report, but it has plagued me since Cadabra v1 (and still seems to be the case in Cadabra v2). The issue is that if I have a SelfAntiCommuting object (a fermion), and I hit it with a derivative, the new object will selfanticommute with sort_product (or prod_sort in v1) but not with canonicalise.

Compare the results of foo1 and foo2 below.

{a, b, c}::Indices(Vector, position=independent);
X_{a}::SelfAntiCommuting ;
\partial{#}::Derivative;
X_{a}::Depends(\partial{#});

foo1 := \partial{X_{b}} \partial{X_{a}} + X_{b} X_{a};
canonicalise(foo1);

foo2 := \partial{X_{b}} \partial{X_{a}} + X_{b} X_{a};
sort_product(foo2);

foo2 gives a sign flip in both expressions when sorting to put X_{a} first. foo1 gives a sign flip only in the second expression. I'm calling this a bug report because one would expect the result to be the same (either the derivative inherits the SelfAntiCommuting property or not).

I have dealt with this by repeatedly defining \partial{X_{a}}::SelfAntiCommuting but this has grown cumbersome in a new project. (Lots of fermions, lots of different types of derivatives.)

Does anyone know a better solution or if this is a genuine bug?

in Bug reports by (1.0k points)

1 Answer

0 votes

This is a bug, thanks for reporting it. The code path for sort_product is different from the one for canonicalise; the latter is more complicated and contains a bug somewhere. I have opened an issue at https://github.com/kpeeters/cadabra2/issues/113 .

by (82.6k points)

I was looking at this again to see if I could find the bug. I didn't find it yet, but I did discover that using either ::Accent or ::PropertyInherit leads to the correct behavior. So I imagine it has something to do with ::Derivative NOT inheriting all the properties of its argument.

(From comments in the source code, maybe you were thinking of using anticommuting derivatives at some point?)

So another potential workaround to the original problem might be to avoid ::Derivative and just define \partial as an ::Accent and then give it the extra properties we desire.

Also: I noticed that declaring the operator as both ::Derivative and ::Accent leads the program to crash when canonicalise is called.

UPDATE: I think I found a fix. Will post comment to github.

Your fix is now included, see github for more comments. Thanks!

...