Skip to content

feat: implement Z-X bialgebra rewrite rule - #189

Merged
ABorgna merged 3 commits into
zxcalc:masterfrom
dlyongemallo:bialgebra_rule
Nov 1, 2026
Merged

ABorgna merged 3 commits into
zxcalc:masterfrom
dlyongemallo:bialgebra_rule

Conversation

@dlyongemallo

Copy link
Copy Markdown
Contributor

No description provided.

@dlyongemallo
dlyongemallo marked this pull request as ready for review February 1, 2026 21:55
Copilot AI review requested due to automatic review settings February 1, 2026 21:55
@dlyongemallo
dlyongemallo marked this pull request as draft February 1, 2026 21:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a Z–X bialgebra rewrite rule in the ZX-calculus core rules and adds a dedicated test suite to validate its correctness (including scalar factors and boundary handling).

Changes:

  • Added check_bialg, bialg_unchecked, and the checked wrapper bialg implementing the Z–X bialgebra rule with appropriate structural and phase preconditions.
  • Implemented the bialgebra transformation to remove the central Z/X spiders, connect their neighborhoods bipartitely with normal edges, and apply the sqrt(2)^((m-1)*(n-1)) scalar factor.
  • Added a comprehensive set of unit tests covering basic, boundary, asymmetric, and non-matching cases for the bialgebra rule, verifying semantic preservation via to_tensor4().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dlyongemallo
dlyongemallo marked this pull request as ready for review February 2, 2026 06:30
@dlyongemallo
dlyongemallo marked this pull request as draft February 2, 2026 06:31
@dlyongemallo
dlyongemallo marked this pull request as ready for review February 2, 2026 06:32
@ABorgna
ABorgna enabled auto-merge November 1, 2026 19:44

@ABorgna ABorgna left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I added a check so we only do this for simple edges.

@ABorgna
ABorgna added this pull request to the merge queue Nov 1, 2026
Merged via the queue into zxcalc:master with commit 2a1f241 Nov 1, 2026
35 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants