1+ """
2+ $(TYPEDEF)
3+
4+ Remove two adjacent Pauli Z spiders by pivoting. Some requirements:
5+
6+ - Both spiders must be interior (not connected to inputs/outputs)
7+ - Both spiders must have Pauli phases (0 or pi)
8+ - The two spiders must be connected by an hadamard edge.
9+ """
110struct Pivot1Rule <: AbstractRule end
211
312function Base. match (:: Pivot1Rule , zxg:: ZXGraph{T, P} ) where {T, P}
@@ -14,7 +23,9 @@ function Base.match(::Pivot1Rule, zxg::ZXGraph{T, P}) where {T, P}
1423 for v2 in neighbors (zxg, v1)
1524 if spider_type (zxg, v2) == SpiderType. Z && length (searchsorted (vB, v2)) == 0 &&
1625 is_pauli_phase (phase (zxg, v2)) && v2 > v1
17- push! (matches, Match {T} ([v1, v2]))
26+ if is_hadamard (zxg, v1, v2)
27+ push! (matches, Match {T} ([v1, v2]))
28+ end
1829 end
1930 end
2031 end
@@ -31,7 +42,7 @@ function check_rule(::Pivot1Rule, zxg::ZXGraph{T, P}, vs::Vector{T}) where {T, P
3142 if v2 in neighbors (zxg, v1)
3243 if spider_type (zxg, v2) == SpiderType. Z && is_interior (zxg, v2) &&
3344 is_pauli_phase (phase (zxg, v2)) && v2 > v1
34- return true
45+ return is_hadamard (zxg, v1, v2)
3546 end
3647 end
3748 end
0 commit comments