APIs
Base.match — Method
match(
r::ZXCalculus.ZX.AbstractRule,
_::ZXCalculus.ZX.AbstractZXDiagram{T, P}
) -> Array{ZXCalculus.ZX.Match{_A}, 1} where _A
Find all vertices in ZX-diagram zxd that match the pattern of rule r.
Returns a vector of Match objects containing the matched vertex sets.
Base.replace! — Method
replace!(
r::ZXCalculus.ZX.AbstractRule,
zxd::ZXCalculus.ZX.AbstractZXDiagram
) -> ZXCalculus.ZX.AbstractZXDiagram
Match and replace with the rule r.
Returns the modified ZX-diagram.
Graphs.neighbors — Method
neighbors(zxd, v; count_mul = false)Returns a vector of vertices connected to v. If count_mul, there will be multiple copy for each vertex. Otherwise, each vertex will only appear once.
ZXCalculus.Utils.add_power! — Method
add_power!(
_::ZXCalculus.ZX.AbstractZXDiagram,
n
) -> ZXCalculus.ZX.ZXDiagram
Add n to the power of √2 in the global scalar.
ZXCalculus.ZX.add_global_phase! — Method
add_global_phase!(
_::ZXCalculus.ZX.AbstractZXDiagram,
p
) -> ZXCalculus.ZX.ZXDiagram
Add phase p to the global phase of the ZX-diagram.
ZXCalculus.ZX.add_spider! — Method
add_spider!(
_::ZXCalculus.ZX.AbstractZXDiagram,
stype,
args...
) -> Any
Add a new spider with spider type st and phase p to the ZX-diagram.
Returns the vertex identifier of the newly added spider.
ZXCalculus.ZX.add_spider! — Method
add_spider!(zxd, spider_type, phase = 0, connect = [])Add a new spider which is of the type spider_type with phase phase and connected to the vertices connect.
ZXCalculus.ZX.ancilla_extraction — Method
ancilla_extraction(
zxg::Union{ZXCalculus.ZX.ZXCircuit, ZXCalculus.ZX.ZXGraph}
) -> ZXCalculus.ZX.ZXCircuit{Int64, ZXCalculus.Utils.Phase}
Extract a quantum circuit from a general ZX-graph even without a gflow.
This function can handle ZX-graphs that don't have a generalised flow (gflow), and will introduce post-selection operators as needed.
Returns a ZXCircuit representing the extracted circuit.
ZXCalculus.ZX.base_zx_graph — Method
base_zx_graph(
_::ZXCalculus.ZX.AbstractZXCircuit
) -> ZXCalculus.ZX.ZXGraph
Get the underlying ZXGraph of the circuit.
ZXCalculus.ZX.biadjacency — Method
biadjacency(zxg, F, N)Return the biadjacency matrix of zxg from vertices in F to vertices in N.
ZXCalculus.ZX.check_rule — Method
check_rule(
r::ZXCalculus.ZX.AbstractRule,
_::ZXCalculus.ZX.AbstractZXDiagram{T, P},
_::Array{T, 1}
) -> Bool
Check whether the vertices vs in ZX-diagram zxd still match the rule r.
This is used to verify that a previously matched pattern is still valid before rewriting, as the diagram may have changed since the match was found.
Returns true if the vertices still match the rule pattern, false otherwise.
ZXCalculus.ZX.circuit_extraction — Method
circuit_extraction(
zxg::Union{ZXCalculus.ZX.ZXCircuit{T, P}, ZXCalculus.ZX.ZXGraph{T, P}}
) -> YaoHIR.Chain
Extract a quantum circuit from a graph-like ZX-diagram.
This is the main circuit extraction algorithm that converts a ZX-diagram in graph-like form into an equivalent quantum circuit.
Returns a ZXDiagram representing the extracted circuit.
ZXCalculus.ZX.clifford_simplification — Method
clifford_simplification(
circ::ZXCalculus.ZX.ZXDiagram
) -> ZXCalculus.ZX.ZXCircuit{T, P} where {T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}
Simplify zxd with the Clifford simplification algorithms in arXiv:1902.03178.
This applies a sequence of local complementation and pivot rules to simplify the ZX-diagram while preserving Clifford structure.
Returns the simplified ZX-diagram.
ZXCalculus.ZX.column_loc — Method
column_loc(
_::ZXCalculus.ZX.AbstractZXCircuit,
v
) -> Union{Nothing, Rational{Int64}}
Get the column (time/depth) location of spider v in the circuit layout.
Returns a rational number representing the position along the circuit, or nothing if not in layout.
ZXCalculus.ZX.column_loc — Method
column_loc(
layout::ZXCalculus.ZX.ZXLayout{T},
v
) -> Union{Nothing, Rational{Int64}}
Return the column number corresponding to the spider v, or nothing if not in layout.
ZXCalculus.ZX.concat! — Method
concat!(
circ1::ZXCalculus.ZX.ZXCircuit{T, P},
circ2::ZXCalculus.ZX.ZXCircuit{T, P}
) -> ZXCalculus.ZX.ZXCircuit
Concatenate two ZX-circuits, where the second circuit is appended after the first.
The circuits must have the same number of qubits. The outputs of the first circuit are connected to the inputs of the second circuit.
Returns the modified first circuit.
ZXCalculus.ZX.concat! — Method
concat!(
zxd_1::ZXCalculus.ZX.ZXDiagram{T, P},
zxd_2::ZXCalculus.ZX.ZXDiagram{T, P}
) -> ZXCalculus.ZX.ZXDiagram
Appends two diagrams, where the second diagram is inverted
ZXCalculus.ZX.convert_to_zx_circuit — Method
convert_to_zx_circuit(
root::YaoHIR.BlockIR
) -> ZXCalculus.ZX.ZXCircuit{Int64, ZXCalculus.Utils.Phase}
Convert a BlockIR to a ZXCircuit.
This is the main conversion function from YaoHIR's BlockIR representation to ZXCalculus. It translates each gate operation in the BlockIR to the corresponding ZX-diagram representation in a ZXCircuit.
Arguments
root::YaoHIR.BlockIR: The BlockIR representation to convert
Returns
ZXCircuit: The circuit representation in ZX-calculus form
Examples
using YaoHIR, ZXCalculus
# Create a BlockIR from a quantum circuit
bir = BlockIR(...)
# Convert to ZXCircuit (two equivalent ways)
zxc = convert_to_zx_circuit(bir)
zxc = ZXCircuit(bir) # Constructor syntax
# Convert back to YaoHIR Chain
chain = convert_to_chain(zxc)See also: ZXCircuit, convert_to_chain
ZXCalculus.ZX.convert_to_zxd — Method
convert_to_zxd(
root::YaoHIR.BlockIR
) -> ZXCalculus.ZX.ZXDiagram{Int64, ZXCalculus.Utils.Phase}
Convert a BlockIR to a ZXDiagram.
convert_to_zxd is deprecated. Use convert_to_zx_circuit or ZXCircuit(bir) instead. This function internally converts to ZXCircuit and then wraps it in deprecated ZXDiagram.
Returns a ZXDiagram for backward compatibility.
ZXCalculus.ZX.dagger — Method
dagger(
circ::ZXCalculus.ZX.ZXCircuit{T, P}
) -> ZXCalculus.ZX.ZXCircuit{_A, _B} where {_B, _A}
Compute the dagger (adjoint) of a ZX-circuit.
This swaps inputs and outputs and negates all phases. The dagger operation corresponds to the adjoint of the quantum operation represented by the circuit.
Returns a new ZX-circuit representing the adjoint operation.
ZXCalculus.ZX.dagger — Method
dagger(
zxd::ZXCalculus.ZX.ZXDiagram{T, P}
) -> ZXCalculus.ZX.ZXDiagram
Dagger of a ZXDiagram by swapping input and outputs and negating the values of the phases
ZXCalculus.ZX.edge_type — Method
edge_type(
_::ZXCalculus.ZX.AbstractZXDiagram,
v1,
v2
) -> ZXCalculus.ZX.EdgeType.EType
Return the edge type between vertices v1 and v2 in the ZX-diagram.
ZXCalculus.ZX.find_inputs — Method
find_inputs(zxg::ZXGraph)Find all spiders with type SpiderType.In in the graph. This is a search utility and does not guarantee circuit structure or ordering.
ZXCalculus.ZX.find_outputs — Method
find_outputs(zxg::ZXGraph)Find all spiders with type SpiderType.Out in the graph. This is a search utility and does not guarantee circuit structure or ordering.
ZXCalculus.ZX.gaussian_elimination — Method
gaussian_elimination(M[, steps])Return result and steps of Gaussian elimination of matrix M. Here we assume that the elements of M is in binary field F_2 = {0,1}.
ZXCalculus.ZX.generate_layout! — Method
generate_layout!(
_::ZXCalculus.ZX.AbstractZXCircuit
) -> ZXCalculus.ZX.ZXLayout
Generate or update the layout for the circuit.
This computes the spatial positioning (qubit and column locations) of all spiders for visualization and analysis purposes.
Returns a ZXLayout object containing the layout information.
ZXCalculus.ZX.get_input_idx — Method
get_input_idx(zwd::ZXDiagram{T,P}, q::T) where {T,P}Get spider index of input qubit q. Returns -1 if non-existant
ZXCalculus.ZX.get_inputs — Method
get_inputs(
_::ZXCalculus.ZX.AbstractZXCircuit
) -> Vector{T} where T<:Integer
Get the ordered input spider vertices of the circuit.
Returns a vector of vertex identifiers in qubit order.
ZXCalculus.ZX.get_inputs — Method
get_inputs(zxd)Returns a vector of input ids.
ZXCalculus.ZX.get_output_idx — Method
get_output_idx(zxd::ZXDiagram{T,P}, q::T) where {T,P}Get spider index of output qubit q. Returns -1 is non-existant
ZXCalculus.ZX.get_outputs — Method
get_outputs(
_::ZXCalculus.ZX.AbstractZXCircuit
) -> Vector{T} where T<:Integer
Get the ordered output spider vertices of the circuit.
Returns a vector of vertex identifiers in qubit order.
ZXCalculus.ZX.get_outputs — Method
get_outputs(zxd)Returns a vector of output ids.
ZXCalculus.ZX.import_edges! — Method
import_edges!(
circ1::ZXCalculus.ZX.ZXCircuit{T, P},
circ2::ZXCalculus.ZX.ZXCircuit{T, P},
v2tov1::Dict{T, T}
)
Import edges of circ2 to circ1, modifying circ1.
ZXCalculus.ZX.import_edges! — Method
import_edges!(
d1::ZXCalculus.ZX.ZXDiagram{T, P},
d2::ZXCalculus.ZX.ZXDiagram{T, P},
v2tov1::Dict{T, T}
)
Import edges of d2 to d1, modify d1
ZXCalculus.ZX.import_non_in_out! — Method
import_non_in_out!(
circ1::ZXCalculus.ZX.ZXCircuit{T, P},
circ2::ZXCalculus.ZX.ZXCircuit{T, P},
v2tov1::Dict{T, T}
)
Add non-input and non-output spiders of circ2 to circ1, modifying circ1.
Records the mapping of vertex indices from circ2 to circ1.
ZXCalculus.ZX.import_non_in_out! — Method
import_non_in_out!(
d1::ZXCalculus.ZX.ZXDiagram{T, P},
d2::ZXCalculus.ZX.ZXDiagram{T, P},
v2tov1::Dict{T, T}
)
Add non input and output spiders of d2 to d1, modify d1. Record the mapping of vertex indices.
ZXCalculus.ZX.insert_spider! — Method
insert_spider!(
_::ZXCalculus.ZX.AbstractZXDiagram,
v1,
v2,
stype,
args...
) -> Vector{K} where K<:Integer
Insert a new spider on the edge between vertices v1 and v2.
Returns the vertex identifier of the newly inserted spider.
ZXCalculus.ZX.insert_spider! — Method
insert_spider!(zxd, v1, v2, spider_type, phase = 0)Insert a spider of the type spider_type with phase = phase, between two vertices v1 and v2. It will insert multiple times if the edge between v1 and v2 is a multiple edge. Also it will remove the original edge between v1 and v2.
ZXCalculus.ZX.is_hadamard — Method
is_hadamard(
zxg::ZXCalculus.ZX.AbstractZXDiagram,
v1,
v2
) -> Bool
Return true if the edge between vertices v1 and v2 is a Hadamard edge in the ZX-diagram.
ZXCalculus.ZX.is_interior — Method
is_interior(zxg::ZXGraph, v)Return true if v is a interior spider of zxg.
ZXCalculus.ZX.nin — Method
nin(zxd::ZXCalculus.ZX.AbstractZXDiagram) -> Any
Get the number of input spiders in the circuit.
ZXCalculus.ZX.nout — Method
nout(zxd::ZXCalculus.ZX.AbstractZXDiagram) -> Any
Get the number of output spiders in the circuit.
ZXCalculus.ZX.nqubits — Method
nqubits(_::ZXCalculus.ZX.AbstractZXCircuit) -> Int64
Get the number of qubits in the circuit.
Returns an integer representing the qubit count.
ZXCalculus.ZX.nqubits — Method
nqubits(zxd)Returns the qubit number of a ZX-diagram.
ZXCalculus.ZX.phase — Method
phase(
_::ZXCalculus.ZX.AbstractZXDiagram,
v
) -> ZXCalculus.Utils.AbstractPhase
Get the phase of spider v in the ZX-diagram.
Returns a phase value (typically AbstractPhase).
ZXCalculus.ZX.phase — Method
phase(zxd, v)Returns the phase of a spider. If the spider is not a Z or X spider, then return 0.
ZXCalculus.ZX.phase_teleportation — Method
phase_teleportation(
cir::ZXCalculus.ZX.ZXDiagram
) -> ZXCalculus.ZX.ZXDiagram
Reduce T-count of zxd with the phase teleportation algorithms in arXiv:1903.10477.
This optimization technique reduces the number of non-Clifford (T) gates in the circuit by teleporting phases through the diagram.
Returns a ZX-diagram with reduced T-count.
ZXCalculus.ZX.phases — Method
phases(
_::ZXCalculus.ZX.AbstractZXDiagram
) -> Dict{T, P} where {T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}
Get all spider phases in the ZX-diagram.
Returns a dictionary mapping vertex identifiers to their phases.
ZXCalculus.ZX.plot — Method
plot(zxd::ZXCalculus.ZX.AbstractZXDiagram; kwargs...)
Plot the ZX-diagram.
ZXCalculus.ZX.push_gate! — Method
push_gate!(
_::ZXCalculus.ZX.AbstractZXCircuit,
args...
) -> ZXCalculus.ZX.ZXCircuit{T, P} where {T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}
Add a gate to the end of the circuit.
ZXCalculus.ZX.push_gate! — Method
push_gate!(
_::ZXCalculus.ZX.ZXCircuit{T, P},
gate::Val{G},
args...
) -> ZXCalculus.ZX.ZXCircuit
Add a gate to the end of the circuit.
Arguments
circ: The circuit to modifygate: Gate type as Val (e.g.,Val(:H),Val(:CNOT))locs: Qubit locations where the gate is appliedphase: Optional phase parameter for phase gates (:Z, :X)
Supported gates
- Single-qubit:
:Z,:X,:H - Two-qubit:
:CNOT,:CZ,:SWAP
ZXCalculus.ZX.push_gate! — Method
push_gate!(zxd, ::Val{M}, locs...[, phase]; autoconvert=true)Push an M gate to the end of qubit loc where M can be :Z, :X, :H, :SWAP, :CNOT and :CZ. If M is :Z or :X, phase will be available and it will push a rotation M gate with angle phase * π. If autoconvert is false, the input phase should be a rational numbers.
ZXCalculus.ZX.pushfirst_gate! — Method
pushfirst_gate!(
_::ZXCalculus.ZX.AbstractZXCircuit,
args...
) -> ZXCalculus.ZX.ZXCircuit{T, P} where {T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}
Add a gate to the beginning of the circuit.
ZXCalculus.ZX.pushfirst_gate! — Method
pushfirst_gate!(
_::ZXCalculus.ZX.ZXCircuit{T, P},
gate::Val{G},
args...
) -> ZXCalculus.ZX.ZXCircuit
Add a gate to the beginning of the circuit.
Arguments
circ: The circuit to modifygate: Gate type as Val (e.g.,Val(:H),Val(:CNOT))locs: Qubit locations where the gate is appliedphase: Optional phase parameter for phase gates (:Z, :X)
Supported gates
- Single-qubit:
:Z,:X,:H - Two-qubit:
:CNOT,:CZ,:SWAP
ZXCalculus.ZX.pushfirst_gate! — Method
pushfirst_gate!(zxd, ::Val{M}, loc[, phase])Push an M gate to the beginning of qubit loc where M can be :Z, :X, :H, :SWAP, :CNOT and :CZ. If M is :Z or :X, phase will be available and it will push a rotation M gate with angle phase * π.
ZXCalculus.ZX.qubit_loc — Method
qubit_loc(
_::ZXCalculus.ZX.AbstractZXCircuit,
v
) -> Union{Nothing, Rational{Int64}}
Get the qubit (row) location of spider v in the circuit layout.
Returns an integer representing the qubit wire index (1 to nqubits), or nothing if not in layout.
ZXCalculus.ZX.qubit_loc — Method
qubit_loc(
layout::ZXCalculus.ZX.ZXLayout{T},
v
) -> Union{Nothing, Rational{Int64}}
Return the qubit number corresponding to the spider v, or nothing if not in layout.
ZXCalculus.ZX.rem_spider! — Method
rem_spider!(zxd::ZXCalculus.ZX.AbstractZXDiagram, v) -> Bool
Remove spider v from the ZX-diagram.
ZXCalculus.ZX.rem_spider! — Method
rem_spider!(zxd, v)Remove a spider indexed by v.
ZXCalculus.ZX.rem_spiders! — Method
rem_spiders!(_::ZXCalculus.ZX.AbstractZXDiagram, vs) -> Bool
Remove multiple spiders vs from the ZX-diagram.
ZXCalculus.ZX.rem_spiders! — Method
rem_spiders!(zxd, vs)Remove spiders indexed by vs.
ZXCalculus.ZX.rewrite! — Method
rewrite!(
r::ZXCalculus.ZX.AbstractRule,
zxd::ZXCalculus.ZX.AbstractZXDiagram{T, P},
matches::Array{ZXCalculus.ZX.Match{T}, 1}
) -> ZXCalculus.ZX.AbstractZXDiagram{T, P} where {T, P}
Rewrite a ZX-diagram zxd with rule r for all vertices in matches.
The matches parameter can be a vector of Match objects or a single Match instance.
Returns the modified ZX-diagram.
ZXCalculus.ZX.rewrite! — Method
rewrite!(
r::ZXCalculus.ZX.AbstractRule,
_::ZXCalculus.ZX.AbstractZXDiagram{T, P},
_::Array{T, 1}
) -> ZXCalculus.ZX.ZXGraph
Rewrite a ZX-diagram zxd with rule r for the specific vertices vs.
This is the core rewriting function that must be implemented for each rule.
Returns the modified ZX-diagram.
ZXCalculus.ZX.round_phases! — Method
round_phases!(_::ZXCalculus.ZX.AbstractZXDiagram)
Round all phases in the ZX-diagram to the range [0, 2π).
ZXCalculus.ZX.round_phases! — Method
round_phases!(zxd)Round phases between [0, 2π).
ZXCalculus.ZX.scalar — Method
scalar(
_::ZXCalculus.ZX.AbstractZXDiagram
) -> ZXCalculus.Utils.Scalar{P} where P<:ZXCalculus.Utils.AbstractPhase
Get the global scalar of the ZX-diagram.
Returns a Scalar object containing the phase and power of √2.
ZXCalculus.ZX.scalar — Method
scalar(zxd)Returns the scalar of zxd.
ZXCalculus.ZX.set_column! — Method
set_column!(
layout::ZXCalculus.ZX.ZXLayout{T},
v,
col
) -> ZXCalculus.ZX.ZXLayout{T} where T
Set the column number of the spider v to col.
ZXCalculus.ZX.set_edge_type! — Method
set_edge_type!(
_::ZXCalculus.ZX.AbstractZXDiagram,
v1,
v2,
etype
) -> Bool
Set the edge type between vertices v1 and v2 in the ZX-diagram.
ZXCalculus.ZX.set_loc! — Method
set_loc!(
layout::ZXCalculus.ZX.ZXLayout{T},
v,
q,
col
) -> ZXCalculus.ZX.ZXLayout{T} where T
Set both the qubit and column location of the spider v.
ZXCalculus.ZX.set_phase! — Method
set_phase!(_::ZXCalculus.ZX.AbstractZXDiagram, v, p) -> Bool
Set the phase of spider v to p in the ZX-diagram.
ZXCalculus.ZX.set_phase! — Method
set_phase!(zxd, v, p)Set the phase of v in zxd to p.
ZXCalculus.ZX.set_qubit! — Method
set_qubit!(
layout::ZXCalculus.ZX.ZXLayout{T},
v,
q
) -> ZXCalculus.ZX.ZXLayout{T} where T
Set the qubit number of the spider v to q.
ZXCalculus.ZX.set_spider_type! — Method
set_spider_type!(
_::ZXCalculus.ZX.AbstractZXDiagram,
v,
st
) -> Bool
Set the spider type of vertex v to st in the ZX-diagram.
ZXCalculus.ZX.simplify! — Method
simplify!(
r::ZXCalculus.ZX.AbstractRule,
zxd::ZXCalculus.ZX.AbstractZXDiagram
) -> ZXCalculus.ZX.AbstractZXDiagram
Simplify zxd with the rule r.
Repeatedly applies the rule until no more matches are found or MAX_ITERATION is reached.
Returns the simplified ZX-diagram.
ZXCalculus.ZX.spider_sequence — Method
spider_sequence(
_::ZXCalculus.ZX.AbstractZXCircuit
) -> Vector{Any}
Get the ordered sequence of spiders for each qubit.
Returns a vector of vectors, where each inner vector contains the spider vertices on a particular qubit wire, ordered by their column position.
ZXCalculus.ZX.spider_type — Method
spider_type(
_::ZXCalculus.ZX.AbstractZXDiagram,
v
) -> ZXCalculus.ZX.SpiderType.SType
Get the type of spider v in the ZX-diagram.
Returns a SpiderType.SType value (Z, X, H, In, or Out).
ZXCalculus.ZX.spider_type — Method
spider_type(zxd, v)Returns the spider type of a spider.
ZXCalculus.ZX.spider_types — Method
spider_types(
_::ZXCalculus.ZX.AbstractZXDiagram
) -> Dict{T, ZXCalculus.ZX.SpiderType.SType} where T<:Integer
Get all spider types in the ZX-diagram.
Returns a dictionary mapping vertex identifiers to their spider types.
ZXCalculus.ZX.spiders — Method
spiders(
_::ZXCalculus.ZX.AbstractZXDiagram
) -> Vector{K} where K<:Integer
Get all spider vertices in the ZX-diagram.
Returns a vector of vertex identifiers.
ZXCalculus.ZX.stype_to_val — Method
stype_to_val(st)::Union{SpiderType,nothing}Converts SpiderType into Val
ZXCalculus.ZX.tcount — Method
tcount(_::ZXCalculus.ZX.AbstractZXDiagram) -> Any
Count the number of non-Clifford phases (T-gates) in the ZX-diagram.
Returns an integer count.
ZXCalculus.ZX.tcount — Method
tcount(zxd)Returns the T-count of a ZX-diagram.
ZXCalculus.ZX.update_frontier! — Method
update_frontier!(zxg, frontier, qubit_map, cir)Update frontier. This is an important step in the circuit extraction algorithm. For more detail, please check the paper arXiv:1902.03178.
ZXCalculus.ZX.verify_equality — Method
verify_equality(
circ_1::ZXCalculus.ZX.ZXCircuit,
circ_2::ZXCalculus.ZX.ZXCircuit
) -> Bool
Check the equivalence of two different ZX-circuits.
This function concatenates the first circuit with the dagger of the second, then performs full reduction. If the result contains only bare wires, the circuits are equivalent.
Returns true if the circuits are equivalent, false otherwise.
ZXCalculus.ZX.verify_equality — Method
verify_equality(
zxd_1::ZXCalculus.ZX.ZXDiagram,
zxd_2::ZXCalculus.ZX.ZXDiagram
) -> Bool
Check the equivalence of two different ZX-diagrams.
This function concatenates the first diagram with the dagger of the second, then performs full reduction. If the result contains only bare wires, the diagrams are equivalent.
Returns true if the diagrams are equivalent, false otherwise.
ZXCalculus.ZX.AbstractZXCircuit — Type
abstract type AbstractZXCircuit{T<:Integer, P<:ZXCalculus.Utils.AbstractPhase} <: ZXCalculus.ZX.AbstractZXDiagram{T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}Abstract type for ZX-diagrams with circuit structure.
This type represents ZX-diagrams that have explicit quantum circuit semantics, including ordered inputs, outputs, and layout information for visualization.
Interface Requirements
Concrete subtypes must implement both:
The
AbstractZXDiagraminterfaces (graphinterface, calculusinterface)The circuit-specific interfaces defined here:
circuit_interface.jl: Circuit structure and gate operationslayout_interface.jl: Layout information for visualization
Use Interfaces.test to verify implementations.
See also
AbstractZXDiagram: Base abstract type for all ZX-diagramsZXCircuit: Main implementation with ZXGraph compositionZXGraph: Pure graph representation without circuit assumptions
ZXCalculus.ZX.AbstractZXDiagram — Type
abstract type AbstractZXDiagram{T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}Abstract type for ZX-diagrams, representing graph-like quantum circuit diagrams.
This type defines the base interface for all ZX-diagram representations, providing graph operations and spider (vertex) manipulation methods.
Interface Requirements
Concrete subtypes must implement the following interfaces:
graph_interface.jl: Graph operations (Graphs.jl compatibility)calculus_interface.jl: Spider and scalar operations (ZX-calculus)
Use Interfaces.test to verify implementations.
See also: AbstractZXCircuit, ZXGraph, ZXCircuit
ZXCalculus.ZX.GEStep — Type
GEStepA struct for representing steps in the Gaussian elimination.
ZXCalculus.ZX.IdentityRemovalRule — Type
struct IdentityRemovalRule <: ZXCalculus.ZX.AbstractRuleRemoves identity spiders connected to two spiders or a Pauli spider connected to one Z-spider via a Hadamard edge.
ZXCalculus.ZX.LocalCompRule — Type
struct LocalCompRule <: ZXCalculus.ZX.AbstractRuleRemove a Z-spider with Clifford phase by local complementary. Requirements:
- The spider must be interior (not connected to inputs/outputs)
- The spider must have Clifford phase (±pi/2)
- All edges connected to the spider must be hadamard edges.
ZXCalculus.ZX.Match — Type
struct Match{T<:Integer}A struct for saving matched vertices from rule matching.
Fields
vertices::Vector{T} where T<:Integer: Vector of vertex identifiers that match a rule pattern
ZXCalculus.ZX.Pivot1Rule — Type
struct Pivot1Rule <: ZXCalculus.ZX.AbstractRuleRemove two adjacent Pauli Z spiders by pivoting. Some requirements:
- Both spiders must be interior (not connected to inputs/outputs)
- Both spiders must have Pauli phases (0 or pi)
- The two spiders must be connected by an hadamard edge.
ZXCalculus.ZX.Pivot2Rule — Type
struct Pivot2Rule <: ZXCalculus.ZX.AbstractRuleThe pivoting rule that convert an internal non-Clifford u Z-spider connected to an internal Pauli Z-spider v into a phase gadget. Requirements:
- The internal non-Clifford spider must have at least two neighbors (not a part of the phase gadget).
- The internal Pauli spider must be connected to the internal non-Clifford spider via a Hadamard edge.
ZXCalculus.ZX.Pivot3Rule — Type
struct Pivot3Rule <: ZXCalculus.ZX.AbstractRuleThe pivoting rule that convert a boundary non-Clifford u Z-spider connected to an internal Pauli Z-spider v into a phase gadget. Requirements:
- The boundary non-Clifford spider must have at least two neighbors (otherwise should be extracted directly).
- The internal Pauli spider must be connected to the boundary non-Clifford spider via a Hadamard edge.ZXCalculus.ZX.PivotBoundaryRule — Type
struct PivotBoundaryRule <: ZXCalculus.ZX.AbstractRuleApplying pivoting rule when an internal Pauli Z-spider u is connected to a Z-spider v on the boundary via a Hadamard edge.
ZXCalculus.ZX.PivotGadgetRule — Type
struct PivotGadgetRule <: ZXCalculus.ZX.AbstractRule- This rule should be only used in circuit extraction.
- This rule will do pivoting on u, v but preserve u, v.
- And the scalars are not considered in this rule.
- gadget_u is the non-Clifford spider
ZXCalculus.ZX.Rule — Type
Rule{L}The struct for identifying different rules.
Rule for ZXDiagrams:
FusionRule(): fusion rule (also available asRule{:f}())XToZRule(): hadamard rule (also available asRule{:h}())Identity1Rule(): identity rule 1 (also available asRule{:i1}())HBoxRule(): identity rule 2 (also available asRule{:i2}())PiRule(): π rule (also available asRule{:pi}())CopyRule(): copy rule (also available asRule{:c}())BialgebraRule(): bialgebra rule (also available asRule{:b}())ScalarRule(): scalar rule (also available asRule{:scalar}())
Rule for ZXGraphs:
LocalCompRule(): local complementary rule (also available asRule{:lc}())Pivot1Rule(): pivoting rule (also available asRule{:p1}())PivotBoundaryRule(): rule for removing Pauli spiders adjacent to boundary spiders (also available asRule{:pab}())Pivot2Rule(): pivot rule 2 (also available asRule{:p2}())Pivot3Rule(): pivot rule 3 (also available asRule{:p3}())IdentityRemovalRule(): identity removal rule (also available asRule{:id}())GadgetFusionRule(): gadget fusion rule (also available asRule{:gf}())PivotGadgetRule(): pivot gadget rule (also available asRule{:pivot}())ScalarRule(): scalar rule (also available asRule{:scalar}())
ZXCalculus.ZX.ZXCircuit — Type
struct ZXCircuit{T, P} <: ZXCalculus.ZX.AbstractZXCircuit{T, P}This is the type for representing ZX-circuits with explicit circuit structure.
ZXCircuit separates the graph representation (ZXGraph) from circuit semantics (ordered inputs/outputs and layout). This design enables efficient graph-based simplification while maintaining circuit structure for extraction and visualization.
Fields
zx_graph::ZXCalculus.ZX.ZXGraph{T, P} where {T, P}: The underlying ZXGraph representationinputs::Vector: Ordered input spider verticesoutputs::Vector: Ordered output spider verticeslayout::ZXCalculus.ZX.ZXLayout{T} where T: Layout information for visualizationphase_ids::Dict{T, Tuple{T, Int64}} where T: Maps vertex id to its master id and scalar multiplier for phase trackingmaster::Union{Nothing, ZXCalculus.ZX.ZXCircuit{T, P}} where {T, P}: Reference to master circuit for phase tracking (optional)
ZXCalculus.ZX.ZXCircuit — Method
ZXCircuit(
nbits::Integer
) -> ZXCalculus.ZX.ZXCircuit{T, ZXCalculus.Utils.Phase} where T<:Integer
Construct an empty ZX-circuit with nbits qubits.
Each qubit is represented by a pair of In/Out spiders connected by a simple edge. This creates a minimal circuit structure ready for gate insertion.
Example
julia> circ = ZXCircuit(3)
ZXCircuit with 3 inputs and 3 outputs...ZXCalculus.ZX.ZXDiagram — Type
struct ZXDiagram{T<:Integer, P<:ZXCalculus.Utils.AbstractPhase} <: ZXCalculus.ZX.AbstractZXCircuit{T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}This is the type for representing ZX-diagrams.
ZXDiagram is deprecated and will be removed in a future version. Please use ZXCircuit instead for circuit representations.
ZXCircuit provides the same functionality with better separation of concerns and more efficient graph-based simplification algorithms.
Fields
mg::Multigraph: The underlying multigraph structurest::Dict{T, ZXCalculus.ZX.SpiderType.SType} where T<:Integer: Spider types indexed by vertexps::Dict{T, P} where {T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}: Phases of spiders indexed by vertexlayout::ZXCalculus.ZX.ZXLayout: Layout information for visualizationphase_ids::Dict{T, Tuple{T, Int64}} where T<:Integer: Maps vertex id to its master id and scalar multiplierscalar::ZXCalculus.Utils.Scalar{P} where P<:ZXCalculus.Utils.AbstractPhase: Global scalar factorinputs::Vector{T} where T<:Integer: Ordered input spider verticesoutputs::Vector{T} where T<:Integer: Ordered output spider vertices
ZXCalculus.ZX.ZXDiagram — Method
ZXDiagram(nbits)Construct a ZXDiagram of a empty circuit with qubit number nbit
julia> zxd = ZXDiagram(3)
ZX-diagram with 6 vertices and 3 multiple edges:
(S_1{input} <-1-> S_2{output})
(S_3{input} <-1-> S_4{output})
(S_5{input} <-1-> S_6{output})ZXCalculus.ZX.ZXDiagram — Method
ZXDiagram(mg::Multigraph{T}, st::Dict{T, SpiderType.SType}, ps::Dict{T, P},
layout::ZXLayout{T} = ZXLayout{T}(),
phase_ids::Dict{T,Tuple{T, Int}} = Dict{T,Tuple{T,Int}}()) where {T, P}
ZXDiagram(mg::Multigraph{T}, st::Vector{SpiderType.SType}, ps::Vector{P},
layout::ZXLayout{T} = ZXLayout{T}()) where {T, P}Construct a ZXDiagram with all information.
ZXCalculus.ZX.ZXGraph — Type
struct ZXGraph{T<:Integer, P<:ZXCalculus.Utils.AbstractPhase} <: ZXCalculus.ZX.AbstractZXDiagram{T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}This is the type for representing the graph-like ZX-diagrams.
A pure graph representation without circuit structure assumptions. Spiders of type In/Out can exist but are treated as searchable vertices, not as ordered inputs/outputs.
Fields
mg::Multigraph: The underlying multigraph structureps::Dict{T, P} where {T<:Integer, P<:ZXCalculus.Utils.AbstractPhase}: Phases of spiders indexed by vertexst::Dict{T, ZXCalculus.ZX.SpiderType.SType} where T<:Integer: Spider types indexed by vertexet::Dict{Tuple{T, T}, ZXCalculus.ZX.EdgeType.EType} where T<:Integer: Edge types indexed by sorted vertex pairsscalar::ZXCalculus.Utils.Scalar{P} where P<:ZXCalculus.Utils.AbstractPhase: Global scalar factor
ZXCalculus.ZX.ZXLayout — Type
struct ZXLayout{T<:Integer}A struct for the layout information of ZX-circuits.
Fields
nbits::Int64: Number of qubits in the circuitspider_q::Dict{T, Rational{Int64}} where T<:Integer: Mapping from spider vertices to qubit locationsspider_col::Dict{T, Rational{Int64}} where T<:Integer: Mapping from spider vertices to column positions
Base.match — Method
match(r, zxwd)Returns all matched vertices, which will be store in sturct Match, for rule r in a ZXW-diagram zxwd.
Base.match — Method
Rule that implements both f and s1 rule.
Graphs.neighbors — Method
neighbors(zxwd, v; count_mul = false)Returns a vector of vertices connected to v. If count_mul, there will be multiple copy for each vertex. Otherwise, each vertex will only appear once.
ZXCalculus.ZX.push_gate! — Method
push_gate!(zxwd, ::Val{M}, locs...[, phase]; autoconvert=true)Push an M gate to the end of qubit loc where M can be :Z, :X, :H, :SWAP, :CNOT and :CZ. If M is :Z or :X, phase will be available and it will push a rotation M gate with angle phase * π. If autoconvert is false, the input phase should be a rational numbers.
ZXCalculus.ZX.pushfirst_gate! — Method
pushfirst_gate!(zxwd, ::Val{M}, loc[, phase])Push an M gate to the beginning of qubit loc where M can be :Z, :X, :H, :SWAP, :CNOT and :CZ. If M is :Z or :X, phase will be available and it will push a rotation M gate with angle phase * π.
ZXCalculus.ZX.rem_spider! — Method
rem_spider!(zxwd, v)Remove a spider indexed by v.
ZXCalculus.ZX.rem_spiders! — Method
rem_spiders!(zxwd, vs)Remove spiders indexed by vs.
ZXCalculus.ZX.rewrite! — Method
rewrite!(r, zxd, matches)Rewrite a ZX-diagram zxd with rule r for all vertices in matches. matches can be a vector of Match or just an instance of Match.
ZXCalculus.ZXW.add_inout! — Method
Add input and outputs to diagram
ZXCalculus.ZXW.add_spider! — Method
add_spider!(zxwd, spider, connect = [])Add a new spider spider with appropriate parameter connected to the vertices connect.
ZXCalculus.ZXW.concat! — Method
Concatenate two ZXWDiagrams, modify d1.
Remove outputs of d1 and inputs of d2. Then add edges between to vertices that was conntecting to outputs of d1 and inputs of d2. Assuming you don't concatenate two empty circuit ZXWDiagram
ZXCalculus.ZXW.dagger — Method
Convert ZXWDiagram that represents unitary U to U^†
ZXCalculus.ZXW.expval_circ! — Method
Construct ZXW Diagram for representing the expectation value circuit
ZXCalculus.ZXW.get_inputs — Method
get_inputs(zxwd)Returns a vector of input ids.
ZXCalculus.ZXW.get_outputs — Method
get_outputs(zxwd)Returns a vector of output ids.
ZXCalculus.ZXW.import_edges! — Method
Import edges of d2 to d1, modify d1
ZXCalculus.ZXW.import_non_in_out! — Method
Add non input and output spiders of d2 to d1, modify d1. Record the mapping of vertex indices.
ZXCalculus.ZXW.insert_spider! — Method
insert_spider!(zxwd, v1, v2, spider)Insert a spider spider with appropriate parameter, between two vertices v1 and v2. It will insert multiple times if the edge between v1 and v2 is a multiple edge. Also it will remove the original edge between v1 and v2.
ZXCalculus.ZXW.insert_wtrig! — Method
Insert W triangle on a vector of vertices
ZXCalculus.ZXW.int_prep! — Method
Prepare spider at loc for integration.
Perform the simplified step of zeroing out phase of spider and readying it for integration
- If target spider is X spider, turn it to Z by adding H to all its legs
- Pull out the Phase of the spider
- zero out the phase
- change the current spider back to its original type if necessary,
will generate one extra H spider.
ZXCalculus.ZXW.integrate! — Method
Integrate two pairs of +/- parameter. Theorem 23 of https://arxiv.org/abs/2201.13250
ZXCalculus.ZXW.nout — Method
nout(zxwd)Returns the number of outputs of a ZXW-diagram
ZXCalculus.ZXW.nqubits — Method
nqubits(zxwd)Returns the qubit number of a ZXW-diagram.
ZXCalculus.ZXW.parameter — Method
parameter(zxwd, v)Returns the parameter of a spider. If the spider is not a Z or X spider, then return 0.
ZXCalculus.ZXW.print_spider — Method
print_spider(io, zxwd, v)Print a spider to io.
ZXCalculus.ZXW.round_phases! — Method
round_phases!(zxwd)Round phases between [0, 2π).
ZXCalculus.ZXW.set_phase! — Method
set_phase!(zxwd, v, p)Set the phase of v in zxwd to p. If v is not a Z or X spider, then do nothing. If v is not in zxwd, then return false to indicate failure.
ZXCalculus.ZXW.spider_type — Method
spider_type(zxwd, v)Returns the spider type of a spider if it exists.
ZXCalculus.ZXW.stack_zxwd! — Method
Stacking two ZXWDiagrams in place. Modify d1.
Performs tensor product of two ZXWDiagrams. The result is a ZXWDiagram with d1 on lower qubit indices. Assuming number of inputs and outputs of are the same for both d1 and d2.
ZXCalculus.ZXW.substitute_variables! — Method
Replace symbols in ZXW Diagram with specific values
ZXCalculus.ZXW.symbol_vertices — Method
Finds vertices of Spider that contains the parameter θ or -θ
Graphs.SimpleGraphs.add_edge! — Method
Graphs.add_edge!(zwd::ZWDiagram, he, mul)Add mul of edges that connects vertices with already connected with edgex.
Graphs.SimpleGraphs.rem_edge! — Method
rem_edge!(zwd::ZWDiagram, x)Remove Edge with indices x.
Graphs.neighbors — Method
neighbors(zwd, v)Returns a vector of vertices connected to v.
ZXCalculus.ZW.add_spider! — Method
add_spider!(zwd, spider, connect = [])Add a new spider spider with appropriate parameter connected to the half edges connect.
Had to make halfedge class 1 citizen because there will be ambiguity Consider A to B and there are multiple edges to A and from A to B
ZXCalculus.ZW.get_input_idx — Method
get_input_idx(zwd::ZXWDiagram{T,P}, q::T) where {T,P}Get spider index of input qubit q.
ZXCalculus.ZW.get_inputs — Method
get_inputs(zwd)Returns a vector of input ids.
ZXCalculus.ZW.get_output_idx — Method
get_output_idx(zwd::ZWDiagram{T,P}, q::T) where {T,P}Get spider index of output qubit q.
ZXCalculus.ZW.get_outputs — Method
get_outputs(zwd)Returns a vector of output ids.
ZXCalculus.ZW.insert_spider! — Method
insert_spider!(zwd, he1, spider)Insert a spider spider with appropriate parameter on the half-edge prior to he1. v1 <- he1 - v2 becomes v1 <- he1 - v2 <- henew - vnew
ZXCalculus.ZW.nout — Method
nout(zwd)Returns the number of outputs of a ZW-diagram
ZXCalculus.ZW.nqubits — Method
nqubits(zwd)Returns the qubit number of a ZW-diagram.
ZXCalculus.ZW.parameter — Method
parameter(zwd, v)Returns the parameter of a spider. If the spider is not a monoZ or binZ spider, then return 0.
ZXCalculus.ZW.print_spider — Method
print_spider(io, zwd, v)Print a spider to io.
ZXCalculus.ZW.round_phases! — Method
round_phases!(zwd)Round phases between [0, 2π).
ZXCalculus.ZW.set_phase! — Method
set_phase!(zwd, v, p)Set the phase of v in zwd to p. If v is not a monoZ or binZ spider, then do nothing. If v is not in zwd, then return false to indicate failure.
ZXCalculus.ZW.spider_type — Method
spider_type(zwd, v)Returns the spider type of a spider if it exists.
ZXCalculus.ZX.spiders — Method
spiders(zwd::ZWDiagram)Returns a vector of spider idxs.
ZXCalculus.ZW.ZWDiagram — Method
ZWDiagram(nbits::T, ::Type{P}) where {T<:Integer}Create a ZW-diagram with nbits input and output qubits.
Scalar is parameterized to be P.
ZXCalculus.Utils.continued_fraction — Method
continued_fraction(ϕ, n::Int) -> RationalObtain s and r from ϕ that satisfies |s//r - ϕ| ≦ 1/2r²
ZXCalculus.Utils.Parameter — Type
ParameterThe Algebraic Data Type for representing parameter related to spider. PiUnit(x) represents the the phase of a number exp(im*x*π). Factor(x) represents a number x.
ZXCalculus.Utils.Parameter — Method
Parameter Constructors for Parameter type.
ZXCalculus.Utils.Phase — Type
PhaseThe type supports manipulating phases as expressions. Phase(x) represents the number x⋅π.
ZXCalculus.Utils.Scalar — Type
ScalarA struct for recording the scalars when we rewrite ZX-diagrams.
ZXCalculus.PMG.add_facet_to_boarder! — Method
add_facet_to_boarder!(pmg::PlanarMultigraph{T}, h::T, g::T) where {T<:Integer}Creates a facet with edge connecting the destination of h and g.
h and g needs to be in ccw order
Reference
ZXCalculus.PMG.add_vertex_and_facet_to_boarder! — Method
add_vertex_and_facet_to_boarder!(
pmg::PlanarMultigraph{T},
h::T,
g::T,) where {T<:Integer}
TBW
Reference
ZXCalculus.PMG.create_edge! — Method
create_edge!(pmg::PlanarMultigraph{T}, vs::T, vd::T) where {T<:Integer}Create an a pair of halfedge from vs to vd, add to PlanarMultigraph pmg. Facet information is not updated yet but set to default value of 0. Vertex to halfedge is updated and set to the two newly added half edges.
ZXCalculus.PMG.create_face! — Method
create_face!(pmg::PlanarMultigraph{T}) where {T<:Integer}ZXCalculus.PMG.create_vertex! — Method
create_vertex!(g::PlanarMultigraph{T}; mul::Int = 1) where {T<:Integer}Create vertices.
Create mul of vertices and record them in PlanarMultigraph g's v_max field.
ZXCalculus.PMG.erase_facet! — Method
ZXCalculus.PMG.gc_vertex! — Method
gc_vertex!(pmg::PlanarMultigraph{T}, vs::Vector{T}) where {T<:Integer}Garbage collect vertices that's no longer connected to any edge.
ZXCalculus.PMG.is_boundary — Method
is_boundary(g::PlanarMultigraph{T}, he_id::T) where {T}If the half edge is on the boundary of entire manifold
ZXCalculus.PMG.join_facet! — Method
join_facet!(pmg::PlanarMultigraph{T}, h::T) where {T}Join two facets incident to h and it's twin into one.
The facet incident to h's twin is removed.
ZXCalculus.PMG.join_vertex! — Method
join_vertex!(pmg::PlanarMultigraph{T}, h::T) where {T<:Integer}Join two vertices connected by a HalfEdge into one.
Provides the removal of an edge.
ZXCalculus.PMG.make_hole! — Method
make_hole!(pmg::PlanarMultigraph{T}, h::T) where {T<:Integer}Convert the facet incident to a half edge into a hole.
Makes all the half edges in the facet a boundary halfedge.
Reference
ZXCalculus.PMG.n_conn_comp — Method
n_conn_comp(g::PlanarMultigraph)Return the number of connected components.
ZXCalculus.PMG.new_edge — Method
new_edge(src::T, dst::T) where {T<:Integer}Create a half edge and its twin
ZXCalculus.PMG.out_half_edge — Method
out_half_edge(g::PlanarMultigraph{T}, v::T)Get the one out half edge of a vertex
ZXCalculus.PMG.prev — Method
prev(g::PlanarMultigraph{T}, he_id::T) where {T<:Integer}Provides Previous Half Edge of a facet. HDS is bidi
ZXCalculus.PMG.split_edge! — Method
split_edge!(pmg::PlanarMultigraph{T}, h::T) where {T<:Integer}Split an edge into two consecutive ones. 1->2->3 becomes 1->4->2->3
ZXCalculus.PMG.split_facet! — Method
split_facet!(pmg::PlanarMultigraph{T}, h::T, g::T) where {T<:Integer}Split a facet incident to h and g into two facets.
Precondition
- h and g are in the same facet
- h and g are not the same half edge
- Cannot be used to split the faces incident to the multiedge.
ZXCalculus.PMG.split_vertex! — Method
split_vertex!(g::PlanarMultigraph{T}, he1::T, he2::T) where {T<:Integer}Split a vertex into 2 vertices.
Connect the two vertices with a new pair of half edges. he1 and he2 are half edges that marks the start and end of half edges that remain on v1.
After splitting, h points to the newly added vertex
Reference
ZXCalculus.PMG.surrounding_half_edge — Method
surrounding_half_edge(g::PlanarMultigraph{T}, f::T)Get the one surrounding half edge of a face
ZXCalculus.PMG.trace_face — Method
trace_face(g::PlanarMultigraph{T}, f::T; safe_trace = false) where {T}Return the half edges of a face.
If safe_trace is true, then the half edges are returned in scrambled order. Otherwise, the returned half edges are in counter clockwise order but is not guaranteed to be consitent with he2f.
ZXCalculus.PMG.σ — Method
σ(g::PlanarMultigraph{T}, he_id::T) where {T}Get prevatsource
ZXCalculus.PMG.σ_inv — Method
σ_inv(pmg::PlanarMultigraph{T}, h::T) where {T}Get nextatsource, clockwise
ZXCalculus.PMG.ϕ — Method
ϕ(g::PlanarMultigraph{T}, he_id::T) where {T}Get twin half edge id
ZXCalculus.PMG.HalfEdge — Type
HalfEdge{T<:Integer}(src ,dst)Datatype to represent a Half Edge
Reference
- Brönnimann, Hervé [Designing and Implementing a General Purpose Halfedge Data Structure]
(https://doi.org/10.1007/3-540-44688-5_5)
ZXCalculus.PMG.PlanarMultigraph — Type
PlanarMultigraph{T<:Integer}Implements a planar multigraph with a maximal HDS Structure.
Features
- Stores Forward Half Edge pointer in facet
- Vertex linked
- Face Linked
References:
Our implementation is based heavily on the CGAL Library. A good introduction on the HDS Structure and the Polyhedron3 Object which gives the boundary representation of a 2-manifold can be found in this paper.
TODO: Proof of Completeness for Euler Operations with Preconditions In the
CGAL Library, the Euler Operations are implemented with preconditions. It was pointed out that Euler Operations are closed for orientable 2-manifolds in paper where the detailed proof is in book. It was further pointed out in paper that Euler Operations are complete in Theorem 4.4.
The question remains whether the completeness remains for the preconditions attached. One way of proving is to show that for the Euler Operations used in Theorem 4.4, we could always construct them out of the Euler Operations in CGAL Library with preconditions?