You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/src/tutorials.md
+12-33
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,6 @@
1
1
# Tutorials
2
-
```@meta
3
-
CurrentModule= ZXCalculus.ZX
4
-
```
5
2
6
-
ZX-diagrams are the basic objects in ZX-calculus. In our implementation, each ZX-diagram consists of a multigraph and vertices information including the type of vertices and the phase of vertices. [`ZXDiagram`](@ref) is the data structure for representing
3
+
ZX-diagrams are the basic objects in ZX-calculus. In our implementation, each ZX-diagram consists of a multigraph and vertices information including the type of vertices and the phase of vertices. [`ZXCalculus.ZX.ZXDiagram`](@ref) is the data structure for representing
7
4
ZX-diagrams.
8
5
9
6
There are 5 types of vertices: `In`, `Out`, `Z`, `X`, `H` which represent the inputs of quantum circuits, outputs of quantum circuits, Z-spiders, X-spiders, H-boxes. There can be a phase for each vertex. The phase of a vertex of `Z` or `X` is the phase of a Z or X-spider. For the other types of vertices, the phase is zero by default.
@@ -12,21 +9,15 @@ In each `ZXDiagram`, there is a `layout` for storing layout information for the
12
9
13
10
## Construction of ZX-diagrams
14
11
15
-
As we usually focus on quantum circuits, the recommended way to construct `ZXDiagram`s is by the following function.
16
-
```@docs
17
-
ZXDiagram(nbits::T) where T<:Integer
18
-
```
19
-
Then one can use `push_gate!` to push quantum gates at the end of a quantum circuit, or use `pushfirst_gate!` to push gates at the beginning of a quantum circuit.
pushfirst_gate!(zxd::ZXDiagram{T, P}, ::Val{:Z}, loc::T, phase::P = zero(P)) where {T, P}
23
-
```
12
+
As we usually focus on quantum circuits, the recommended way to construct `ZXDiagram`s is by the following function [`ZXCalculus.ZX.ZXDiagram(nbits::T) where {T<:Integer}`](@ref).
13
+
14
+
Then one can use [`ZXCalculus.ZX.push_gate!`](@ref) to push quantum gates at the end of a quantum circuit, or use [`ZXCalculus.ZX.pushfirst_gate!`](@ref)to push gates at the beginning of a quantum circuit.
24
15
25
16
For example, in `example\ex1.jl`, one can generate the demo circuit by the function
26
17
```julia
27
18
using ZXCalculus
28
19
functiongenerate_example()
29
-
zxd =ZXDiagram(4)
20
+
zxd =ZXCalculus.ZX.ZXDiagram(4)
30
21
push_gate!(zxd, Val(:Z), 1, 3//2)
31
22
push_gate!(zxd, Val(:H), 1)
32
23
push_gate!(zxd, Val(:Z), 1, 1//2)
@@ -56,11 +47,7 @@ function generate_example()
56
47
end
57
48
```
58
49
59
-
In the paper [arXiv:1902.03178](https://arxiv.org/abs/1902.03178), they introduced a special type of ZX-diagrams, graph-like ZX-diagrams, which consists of Z-spiders with 2 different types of edges only. We use [`ZXGraph`](@ref) for representing this special type of ZX-diagrams. One can convert a `ZXDiagram` into a `ZXGraph` by simply use the construction function:
60
-
```@docs
61
-
ZXGraph(zxd::ZXDiagram{T, P}) where {T, P}
62
-
```
63
-
50
+
In the paper [arXiv:1902.03178](https://arxiv.org/abs/1902.03178), they introduced a special type of ZX-diagrams, graph-like ZX-diagrams, which consists of Z-spiders with 2 different types of edges only. We use [`ZXCalculus.ZX.ZXGraph`](@ref) for representing this special type of ZX-diagrams. One can convert a `ZXDiagram` into a `ZXGraph` by simply use the construction function [`ZXCalculus.ZX.ZXGraph(zxd::ZXCalculus.ZX.ZXDiagram{T, P}) where {T, P}`](@ref):
64
51
65
52
## Visualization
66
53
@@ -78,18 +65,12 @@ With `ZXCalculus.jl`, one can manipulate ZX-diagrams at different levels.
78
65
- Rewriting ZX-diagrams with rules
79
66
- Rewriting ZX-diagrams at the graphical level
80
67
81
-
The highest level is the circuit simplification algorithms. By now there are two algorithms are available:
82
-
```@docs
83
-
clifford_simplification(circ::ZXDiagram)
84
-
phase_teleportation(circ::ZXDiagram{T, P}) where {T, P}
85
-
```
68
+
The highest level is the circuit simplification algorithms. By now there are two algorithms are available: [`ZXCalculus.ZX.clifford_simplification`](@ref) and [`ZXCalculus.ZX.phase_teleportation`](ref).
69
+
86
70
The input of these algorithms will be a ZX-diagram representing a quantum circuit. And these algorithms will return a ZX-diagram of a simplified quantum circuit. For more details, please refer to [Clifford simplification](https://arxiv.org/abs/1902.03178) and [phase teleportation](https://arxiv.org/abs/1903.10477).
87
71
88
-
One can rewrite ZX-diagrams with rules. In `ZXCalculus.jl`, rules are identified as data structures [`Rule`](@ref). And we can use the following functions to simplify ZX-diagrams:
One can rewrite ZX-diagrams with rules. In `ZXCalculus.jl`, rules are identified as data structures [`Rule`](@ref). And we can use the following functions to simplify ZX-diagrams: [`ZXCalculus.ZX.simplify!`](@ref) and [`ZXCalculus.ZX.replace!`](@ref).
73
+
93
74
For example, in `example/ex1.jl`, we can get a simplified graph-like ZX-diagram by:
94
75
```julia
95
76
zxd =generate_example()
@@ -102,10 +83,8 @@ replace!(Rule{:pab}(), zxg)
102
83
The difference between `simplify!` and `replace!` is that `replace!` only matches vertices and tries to rewrite with all matched vertices once, while `simplify!` will keep matching until nothing matched.
103
84
104
85
The following APIs are useful for more detailed rewriting.
105
-
```@docs
106
-
match(::ZXCalculus.AbstractRule, zxd::AbstractZXDiagram{T, P}) where {T, P}
107
-
rewrite!(r::ZXCalculus.AbstractRule, zxd::AbstractZXDiagram{T, P}, matches::Vector{Match{T}}) where {T, P}
108
-
```
86
+
1.[`ZXCalculus.ZX.match`](@ref)
87
+
2.[`ZXCalculus.ZX.rewrite!`](@ref)
109
88
110
89
The lowest level for rewriting ZX-diagrams is manipulating the multigraphs directly. This way is not recommended unless one wants to develop new rules in ZX-calculus.
0 commit comments