Open wzpxq opened 8 months ago
The same goes also for H_BOX next to an H-edge, btw:
g = zx.Graph()
v0 = g.add_vertex(zx.VertexType.BOUNDARY, 0, 0)
v1 = g.add_vertex(zx.VertexType.H_BOX, 0, 1)
g.add_edge((v0, v1), zx.EdgeType.HADAMARD)
v2 = g.add_vertex(zx.VertexType.BOUNDARY, 0, 2)
g.add_edge((v1, v2))
full_reduce
assumes that the input is a ZX-diagram, meaning it shouldn't have H_BOX
es. I agree that this is confusing, and at some stage probably a conversion from H_BOX
to Hadamard edges should happen. At the minimum, full_reduce
should warn that the input is invalid.
See also #161 for some background.
I also bumped into this as a first-time user of zxlive
; lowering 2-ary H boxes sounds like a sensible pass to implement (and I agree, a warning for "invalid" inputs would have helped a lot in figuring out what is going on here!).
Thank you for the two replies.
So, as I have understood it, I simply have to call zx.hsimplify.from_hypergraph_form(g)
to turn all H_BOX
es into HADAMARD
edges, before full_reduce
can do its thing.
I tried it and it works.
But I suggest that if that H_BOX
conversion will not be included into full_reduce
that at least a new prominent API should be created that incorporates all simplifications to any graph.
Unless I am missing it there is no "Hadamard cancellation" implemented.
Consider the following graph:
full_reduce
,clifford_simp
have no effect on it (nor did I find any other API that cancels the two Hadamards.