Refactoring ZX implementation
This PR is breaking because it introduces a new design to support general ZX-diagram rewriting for potential applications beyond circuit simplification.
The previous design was specific to circuit simplification:
- The
ZXDiagramwas intended to provide a circuit-level interface. - For circuit simplification, the
ZXDiagramwould be converted into aZXGraph, as most rewriting rules are only defined on theZXGraph. - Additionally, the
ZXGraphwould implicitly assume a circuit structure including inputs and outputs, while also tracking the master diagram for phase teleportation.
The previous design limited the application of this package. For instance, it was not possible to use this package for rewriting general ZX-diagrams when they are not from a circuit due to these design constraints.
This PR implements the following design changes:
- The
ZXGraphis now the foundational graphical infrastructure to support arbitrary ZX-diagram rewriting. - A new
ZXCircuithas been introduced to provide additional circuit structures beyond theZXGraph, including inputs/outputs and phase tracking. - The
ZXDiagramhas been retained to ensure compatibility with the old interface.
@Roger-luo @GiggleLiu Sorry for the gigantic PR. I believe it may be too much for a human to review all at once. I am not sure if it can be decomposed into smaller ones. Please let me know what I should do to push forward this refactoring.
I briefly checked the interface changes. I think it is a nice move.
I don't have a strong opinion on the refactor, but I agree this is a good generalization of the old design.
@GiggleLiu @Roger-luo Thanks for the comments. In this case, shall I merge the PR directly?