Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bialgebra rewrites from "basic rules" and drag-and-drop result in different global scalars #314

Closed
RazinShaikh opened this issue Jul 10, 2024 · 2 comments · Fixed by zxcalc/pyzx#256
Labels
Category: Proof mode Issues and enhancements related to Proof mode Priority: High Type: bug Something is not right

Comments

@RazinShaikh
Copy link
Collaborator

RazinShaikh commented Jul 10, 2024

For instance, apply both bialgebra rewrites on the following diagram and observe the scalar on the top left corner.

The basic rules version and the drag-and-drop version show 2.0 and 1.41 respectively.

@RazinShaikh RazinShaikh added Type: bug Something is not right Category: Proof mode Issues and enhancements related to Proof mode Priority: High labels Jul 10, 2024
@jvdwetering
Copy link
Collaborator

Is this a bug in the pyzx implementation?

@RazinShaikh
Copy link
Collaborator Author

I have figured out the error. In the PR zxcalc/pyzx#248 I changed basicrules.py version to call the editor_actions.py bialgebra, so both rewrites are calling the same pyzx method under the hood. But both functions originally had slightly different assumptions; such as the first vertex out of the two was always an X spider.
I need to change the following block

        if g.type(v2) == VertexType.Z:
            g.scalar.add_power((g.vertex_degree(v1)-2)*(g.vertex_degree(v2)-2))
        else: #g.type(w) == VertexType.H_BOX
            g.scalar.add_power(g.vertex_degree(v1)-2)

to

        if g.type(v1) == VertexType.H_BOX or g.type(v2) == VertexType.H_BOX: # x-h bialgebra
            x_vertex = v1 if g.type(v2) == VertexType.H_BOX else v2
            g.scalar.add_power(g.vertex_degree(x_vertex)-2)
        else: # z-x bialgebra
            g.scalar.add_power((g.vertex_degree(v1)-2)*(g.vertex_degree(v2)-2))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Proof mode Issues and enhancements related to Proof mode Priority: High Type: bug Something is not right
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants