diff --git a/src/Application/Application.jl b/src/Application/Application.jl new file mode 100644 index 0000000..ef214fe --- /dev/null +++ b/src/Application/Application.jl @@ -0,0 +1,9 @@ +module Application + +using OMEinsum, MLStyle +using ..ZXW: ZXWDiagram, Z, X, W, H, D, Input, Output +using ..Utils: PiUnit, Factor, Parameter, unwrap_scalar +using ..ZXW: get_outputs, get_inputs, degree, neighbors, vertices, scalar, nin, nout + +include("to_eincode.jl") +end # module Application diff --git a/src/to_eincode.jl b/src/Application/to_eincode.jl similarity index 100% rename from src/to_eincode.jl rename to src/Application/to_eincode.jl diff --git a/src/PMG/PMG.jl b/src/PMG/PMG.jl new file mode 100644 index 0000000..7e17e2c --- /dev/null +++ b/src/PMG/PMG.jl @@ -0,0 +1,12 @@ +module PMG + +using Graphs + +import Graphs: AbstractEdge, src, dst, nv, ne, neighbors +import Graphs.SimpleGraphs: vertices + +export HalfEdge, src, dst, new_edge, PlanarMultigraph + +include("planar_multigraph.jl") + +end # module PlanarMultigraph diff --git a/src/planar_multigraph.jl b/src/PMG/planar_multigraph.jl similarity index 100% rename from src/planar_multigraph.jl rename to src/PMG/planar_multigraph.jl diff --git a/src/Utils/Utils.jl b/src/Utils/Utils.jl new file mode 100644 index 0000000..5d66c23 --- /dev/null +++ b/src/Utils/Utils.jl @@ -0,0 +1,10 @@ +module Utils + +using Expronicon.ADT: @const_use, @adt +using MLStyle + +include("scalar.jl") +include("phase.jl") +include("parameter.jl") + +end diff --git a/src/parameter.jl b/src/Utils/parameter.jl similarity index 100% rename from src/parameter.jl rename to src/Utils/parameter.jl diff --git a/src/phase.jl b/src/Utils/phase.jl similarity index 100% rename from src/phase.jl rename to src/Utils/phase.jl diff --git a/src/scalar.jl b/src/Utils/scalar.jl similarity index 100% rename from src/scalar.jl rename to src/Utils/scalar.jl diff --git a/src/ZW/ZW.jl b/src/ZW/ZW.jl new file mode 100644 index 0000000..396f556 --- /dev/null +++ b/src/ZW/ZW.jl @@ -0,0 +1,43 @@ +module ZW +using Expronicon.ADT: @adt, @const_use +using MLStyle, Graphs +using ..ZXW: _round_phase, Parameter + +# these will be changed to using PlanarMultigraph: vertices after we split out package +using ..PMG: + vertices, + nv, + has_vertex, + ne, + neighbors, + rem_edge!, + add_edge!, + degree, + next, + split_vertex!, + split_edge!, + face, + trace_face, + make_hole!, + add_vertex_and_facet_to_boarder!, + split_facet!, + twin, + prev, + add_multiedge!, + join_facet!, + trace_vertex, + join_vertex! + +# these remains +using ..Utils: add_phase!, Scalar, Phase, Parameter, PiUnit, Factor, add_power! +using ..PMG: PlanarMultigraph, HalfEdge, new_edge, src, dst +import ..Utils: add_power! +import ..ZX: add_global_phase!, scalar, spiders, rem_spider! +import Graphs.rem_edge! + +export ZWDiagram + +include("zw_adt.jl") +include("zw_diagram.jl") +include("zw_utils.jl") +end # module ZW diff --git a/src/zw_adt.jl b/src/ZW/zw_adt.jl similarity index 100% rename from src/zw_adt.jl rename to src/ZW/zw_adt.jl diff --git a/src/zw_diagram.jl b/src/ZW/zw_diagram.jl similarity index 100% rename from src/zw_diagram.jl rename to src/ZW/zw_diagram.jl diff --git a/src/zw_utils.jl b/src/ZW/zw_utils.jl similarity index 100% rename from src/zw_utils.jl rename to src/ZW/zw_utils.jl diff --git a/src/ZX/ZX.jl b/src/ZX/ZX.jl new file mode 100644 index 0000000..f05e9dd --- /dev/null +++ b/src/ZX/ZX.jl @@ -0,0 +1,38 @@ +module ZX + +using Graphs, Multigraphs, YaoHIR, YaoLocations +using YaoHIR.IntrinsicOperation +using YaoHIR: Chain +using YaoLocations: plain +using MLStyle +using ..Utils: Scalar, Phase, add_phase! + +import ..Utils: add_power! + +export spiders, + tcount, spider_type, phase, rem_spider!, rem_spiders!, pushfirst_gate!, push_gate! + +export SpiderType, EdgeType +export AbstractZXDiagram, ZXDiagram, ZXGraph + +export AbstractRule +export Rule, Match + +export rewrite!, simplify! + +export convert_to_chain, convert_to_zxd +export clifford_simplification, full_reduction, circuit_extraction, phase_teleportation + +include("abstract_zx_diagram.jl") +include("zx_layout.jl") +include("zx_diagram.jl") +include("zx_graph.jl") + +include("rules.jl") +include("simplify.jl") + +include("circuit_extraction.jl") +include("phase_teleportation.jl") + +include("ir.jl") +end diff --git a/src/abstract_zx_diagram.jl b/src/ZX/abstract_zx_diagram.jl similarity index 100% rename from src/abstract_zx_diagram.jl rename to src/ZX/abstract_zx_diagram.jl diff --git a/src/circuit_extraction.jl b/src/ZX/circuit_extraction.jl similarity index 100% rename from src/circuit_extraction.jl rename to src/ZX/circuit_extraction.jl diff --git a/src/ir.jl b/src/ZX/ir.jl similarity index 100% rename from src/ir.jl rename to src/ZX/ir.jl diff --git a/src/phase_teleportation.jl b/src/ZX/phase_teleportation.jl similarity index 100% rename from src/phase_teleportation.jl rename to src/ZX/phase_teleportation.jl diff --git a/src/rules.jl b/src/ZX/rules.jl similarity index 100% rename from src/rules.jl rename to src/ZX/rules.jl diff --git a/src/simplify.jl b/src/ZX/simplify.jl similarity index 100% rename from src/simplify.jl rename to src/ZX/simplify.jl diff --git a/src/zx_diagram.jl b/src/ZX/zx_diagram.jl similarity index 100% rename from src/zx_diagram.jl rename to src/ZX/zx_diagram.jl diff --git a/src/zx_graph.jl b/src/ZX/zx_graph.jl similarity index 100% rename from src/zx_graph.jl rename to src/ZX/zx_graph.jl diff --git a/src/zx_layout.jl b/src/ZX/zx_layout.jl similarity index 100% rename from src/zx_layout.jl rename to src/ZX/zx_layout.jl diff --git a/src/ZXCalculus.jl b/src/ZXCalculus.jl index 8bb1ca0..ca64307 100644 --- a/src/ZXCalculus.jl +++ b/src/ZXCalculus.jl @@ -1,141 +1,11 @@ module ZXCalculus -module Utils - -using Expronicon.ADT: @const_use, @adt -using MLStyle - -include("scalar.jl") -include("phase.jl") -include("parameter.jl") - -end - -module ZX - -using Graphs, Multigraphs, YaoHIR, YaoLocations -using YaoHIR.IntrinsicOperation -using YaoHIR: Chain -using YaoLocations: plain -using MLStyle -using ..Utils: Scalar, Phase, add_phase! - -import ..Utils: add_power! - -export spiders, - tcount, spider_type, phase, rem_spider!, rem_spiders!, pushfirst_gate!, push_gate! - -export SpiderType, EdgeType -export AbstractZXDiagram, ZXDiagram, ZXGraph - -export AbstractRule -export Rule, Match - -export rewrite!, simplify! - -export convert_to_chain, convert_to_zxd -export clifford_simplification, full_reduction, circuit_extraction, phase_teleportation - -include("abstract_zx_diagram.jl") -include("zx_layout.jl") -include("zx_diagram.jl") -include("zx_graph.jl") - -include("rules.jl") -include("simplify.jl") - -include("circuit_extraction.jl") -include("phase_teleportation.jl") - -include("ir.jl") -end - -module ZXW - -using Expronicon.ADT: @const_use, @adt -using MLStyle, Multigraphs, Graphs -using ..Utils: Scalar, Phase, Parameter, PiUnit, Factor, add_phase! -using ..ZX: safe_convert, AbstractRule, Rule, Match - -import ..Utils: add_power! -import ..ZX: - rewrite!, simplify!, push_gate!, pushfirst_gate!, spiders, rem_spider!, rem_spiders! - -export ZXWDiagram, substitute_variables! - -include("adts.jl") -include("zxw_diagram.jl") -include("zxw_rules.jl") -include("utils.jl") - -end # module ZXW - -module PMG - -using Graphs - -import Graphs: AbstractEdge, src, dst, nv, ne, neighbors -import Graphs.SimpleGraphs: vertices - -export HalfEdge, src, dst, new_edge, PlanarMultigraph - -include("planar_multigraph.jl") - -end # module PlanarMultigraph - -module ZW -using Expronicon.ADT: @adt, @const_use -using MLStyle, Graphs -using ..ZXW: _round_phase, Parameter - -# these will be changed to using PlanarMultigraph: vertices after we split out package -using ..PMG: - vertices, - nv, - has_vertex, - ne, - neighbors, - rem_edge!, - add_edge!, - degree, - next, - split_vertex!, - split_edge!, - face, - trace_face, - make_hole!, - add_vertex_and_facet_to_boarder!, - split_facet!, - twin, - prev, - add_multiedge!, - join_facet!, - trace_vertex, - join_vertex! - -# these remains -using ..Utils: add_phase!, Scalar, Phase, Parameter, PiUnit, Factor, add_power! -using ..PMG: PlanarMultigraph, HalfEdge, new_edge, src, dst -import ..Utils: add_power! -import ..ZX: add_global_phase!, scalar, spiders, rem_spider! -import Graphs.rem_edge! - -export ZWDiagram - -include("zw_adt.jl") -include("zw_diagram.jl") -include("zw_utils.jl") -end # module ZW - -module Application - -using OMEinsum, MLStyle -using ..ZXW: ZXWDiagram, Z, X, W, H, D, Input, Output -using ..Utils: PiUnit, Factor, Parameter, unwrap_scalar -using ..ZXW: get_outputs, get_inputs, degree, neighbors, vertices, scalar, nin, nout - -include("to_eincode.jl") -end # module Application - +include("Utils/Utils.jl") +include("ZX/ZX.jl") +include("ZXW/ZXW.jl") +include("PMG/PMG.jl") +include("ZW/ZW.jl") +include("Application/Application.jl") include("deprecations.jl") + end # module diff --git a/src/ZXW/ZXW.jl b/src/ZXW/ZXW.jl new file mode 100644 index 0000000..fd0e220 --- /dev/null +++ b/src/ZXW/ZXW.jl @@ -0,0 +1,19 @@ +module ZXW + +using Expronicon.ADT: @const_use, @adt +using MLStyle, Multigraphs, Graphs +using ..Utils: Scalar, Phase, Parameter, PiUnit, Factor, add_phase! +using ..ZX: safe_convert, AbstractRule, Rule, Match + +import ..Utils: add_power! +import ..ZX: + rewrite!, simplify!, push_gate!, pushfirst_gate!, spiders, rem_spider!, rem_spiders! + +export ZXWDiagram, substitute_variables! + +include("adts.jl") +include("zxw_diagram.jl") +include("zxw_rules.jl") +include("utils.jl") + +end # module ZXW diff --git a/src/adts.jl b/src/ZXW/adts.jl similarity index 100% rename from src/adts.jl rename to src/ZXW/adts.jl diff --git a/src/utils.jl b/src/ZXW/utils.jl similarity index 100% rename from src/utils.jl rename to src/ZXW/utils.jl diff --git a/src/zxw_diagram.jl b/src/ZXW/zxw_diagram.jl similarity index 100% rename from src/zxw_diagram.jl rename to src/ZXW/zxw_diagram.jl diff --git a/src/zxw_rules.jl b/src/ZXW/zxw_rules.jl similarity index 100% rename from src/zxw_rules.jl rename to src/ZXW/zxw_rules.jl