Skip to content

Commit f2bd59a

Browse files
committed
add edge checks
1 parent f7d6b23 commit f2bd59a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/ZX/rules/pivot1.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
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+
"""
110
struct Pivot1Rule <: AbstractRule end
211

312
function 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

Comments
 (0)