zxcalc/pyzx

circuits equal up to global phase

Closed this issue · 5 comments

c0 = zx.Circuit(1)
c0.add_gate("NOT", 0)
c0.add_gate("Z", 0)

c1 = zx.Circuit(1)
c1.add_gate("Z", 0)
c1.add_gate("NOT", 0)
print(c0.verify_equality(c1))

It should be made clear in the documentation that verify_equality is equality of circuits up to global phase only. Or have I done something wrong?

See also: https://quantumcomputing.stackexchange.com/a/25789

Yes, that's right, this only verifies equality up to global phase.
It wouldn't be too hard to add support for testing exact equality here. Would that be useful for your use-case?

Thankyou John. The use case is to generate and/or compute efficiently products and equality within the Clifford group. (The tablaux methods can only do this up to global phase.) As mentioned in the stackexchange question, one idea is to compute with normal forms of ZX diagrams that represent these Clifford elements. How would I do this with PyZX ?

Do you want to work with states or with unitaries? And do the normal forms have to be unique? It is possible to get a unique normal form for states using ZX, but this is currently not implemented in PyZX. To do that you would use the algorithm described in https://arxiv.org/abs/2306.05204 but adapted again to qubits.

I'm interested in the Clifford group: these are unitary operators, but they should have efficient (in qubit number) representations. It sounds like you are telling me this is an open problem. And there needs to be a unique normal form for equality testing.

The unique normal form for states will also give you a unique normal form for unitaries, by Choi-Jamiolkowski isomorphism (bending wires from being inputs to outputs and vice versa). However, the ZX-diagram you will get out of this is then not super straightforwardly relatable to a circuit decomposition. You can however then still do this using the functions built into pyzx, it's just not straightforward to see manually.