Open wlcsm opened 3 months ago
We already support this as all parametric angles are taken to be multiples of pi
We do not use sympy expression as we built the symbolic module in PyZX, which has some advantages over sympy
I can understand that requiring the phases to be a multiple of pi is a design decision.
Though it It seems like we cannot implement phrases such as (k + l) * pi
or (a + 1) * \pi
. Though it is possible to create two spiders, one with phase l * \pi
and the other with phase k * \pi
and fuse them together to obtain (k + l) * \pi
.
So it seems like expressions are supported, but inputting them directly isn't. So it may just be a problem with the input validation. What are the advantages of the symbolic module over sympy?
Yeah, the input parsing needs to be updated. The benefit of the symbolic module is that it allows for more integrated custom behavior. For example, we can have specific rewrites based on the type of the variable (boolean or parametric), perform automatic substitutions from custom rewrites, etc.
Double click on a spider and input the phase (k + l) * \pi
But this works without the "*pi", doesn't it? I was able to do this:
Yes, but it would be nice to allow the input to be more flexible. In fact, for symbolic values, it doesn't even make sense to ask for inputs in units of pi (unless the type of the variable is Boolean).
Parameterised spiders currently support fractions of pi e.g. "\pi/2", but not more complex expressions such as
(k + l) * \pi
wherek
andl
are parameters. This should be achievable by storing the phase as a sympy expression.Steps to reproduce.
(k + l) * \pi
Currently ZXLive will produce an error with stating the input is invalid