None of the above ;-)
First, remember that this is all stored on the C++ side. All properties are stored in two ways: a map from patterns to property objects, and a map from property objects to patterns. So for
{F1, F2, F3}::AntiCommuting
there is a map props
which contains
F1 -> A1
F2 -> A1
F3 -> A1
where A1
is an instance of the property object AntiCommuting
. And there is a map pats
which contains
A1 -> F1
A1 -> F2
A1 -> F3
(so an ordered multi-map, to be precise).
Now the properties
object which contains all this has methods to find a shared AntiCommuting
object for two given patterns. So you can ask it "Do F1 and F2 have an AntiCommuting property in common?".
(This all looks terribly complicated until you start to build in property inheritance and the like, when simpler solutions tend to be insufficient).
Now most of this is not easily accessible on the Python side because it was written long before I added the Python wrapper on top of the C++ core. Your solution (of repeating the list property declaration) is by far the simplest. Of course if you run into something that cannot be done that way.
Unfortunately, while there is a way to retrieve property information for an expression using [PropertyName].get(...)
, you cannot use this to check whether to elements are in the same list (yet). So if you do
{F1, F2}::AntiCommuting;
p1 = AntiCommuting.get($F1$)
p2 = AntiCommuting.get($F2$)
p1 == p2
you get False
, and there is no
p = AntiCommuting($F1$, $F2$)
yet either (which would probably be the easiest way out).