Skip to content

Commit

Permalink
fix docs not building issue
Browse files Browse the repository at this point in the history
  • Loading branch information
exAClior committed Oct 15, 2023
1 parent cf20e85 commit f873abc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Multigraphs

indigo = DocThemeIndigo.install(ZXCalculus)
makedocs(;
modules = Module[ZXCalculus],
modules = Module[ZXCalculus, ZXCalculus.ZX, ZXCalculus.ZXW, ZXCalculus.ZW, ZXCalculus.Utils, ZXCalculus.Application, ZXCalculus.PMG],
format=Documenter.HTML(;
# ...
# put your indigo css in assets
Expand Down
5 changes: 5 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# APIs

```@autodocs
Modules = [ZXCalculus, ZXCalculus.ZX, ZXCalculus.ZXW, ZXCalculus.ZW, ZXCalculus.Utils, ZXCalculus.PMG]
Order = [:function, :type]
```
45 changes: 12 additions & 33 deletions docs/src/tutorials.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Tutorials
```@meta
CurrentModule= ZXCalculus.ZX
```

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
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
ZX-diagrams.

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.
Expand All @@ -12,21 +9,15 @@ In each `ZXDiagram`, there is a `layout` for storing layout information for the

## Construction of ZX-diagrams

As we usually focus on quantum circuits, the recommended way to construct `ZXDiagram`s is by the following function.
```@docs
ZXDiagram(nbits::T) where T<:Integer
```
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.
```@docs
push_gate!(zxd::ZXDiagram{T, P}, ::Val{:Z}, loc::T, phase = zero(P); autoconvert::Bool=true) where {T, P}
pushfirst_gate!(zxd::ZXDiagram{T, P}, ::Val{:Z}, loc::T, phase::P = zero(P)) where {T, P}
```
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).

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.

For example, in `example\ex1.jl`, one can generate the demo circuit by the function
```julia
using ZXCalculus
function generate_example()
zxd = ZXDiagram(4)
zxd = ZXCalculus.ZX.ZXDiagram(4)
push_gate!(zxd, Val(:Z), 1, 3//2)
push_gate!(zxd, Val(:H), 1)
push_gate!(zxd, Val(:Z), 1, 1//2)
Expand Down Expand Up @@ -56,11 +47,7 @@ function generate_example()
end
```

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:
```@docs
ZXGraph(zxd::ZXDiagram{T, P}) where {T, P}
```

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):

## Visualization

Expand All @@ -78,18 +65,12 @@ With `ZXCalculus.jl`, one can manipulate ZX-diagrams at different levels.
- Rewriting ZX-diagrams with rules
- Rewriting ZX-diagrams at the graphical level

The highest level is the circuit simplification algorithms. By now there are two algorithms are available:
```@docs
clifford_simplification(circ::ZXDiagram)
phase_teleportation(circ::ZXDiagram{T, P}) where {T, P}
```
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).

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).

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:
```@docs
simplify!(r::ZXCalculus.AbstractRule, zxd::AbstractZXDiagram)
replace!(r::ZXCalculus.AbstractRule, zxd::AbstractZXDiagram)
```
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).

For example, in `example/ex1.jl`, we can get a simplified graph-like ZX-diagram by:
```julia
zxd = generate_example()
Expand All @@ -102,10 +83,8 @@ replace!(Rule{:pab}(), zxg)
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.

The following APIs are useful for more detailed rewriting.
```@docs
match(::ZXCalculus.AbstractRule, zxd::AbstractZXDiagram{T, P}) where {T, P}
rewrite!(r::ZXCalculus.AbstractRule, zxd::AbstractZXDiagram{T, P}, matches::Vector{Match{T}}) where {T, P}
```
1. [`ZXCalculus.ZX.match`](@ref)
2. [`ZXCalculus.ZX.rewrite!`](@ref)

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.

Expand Down

0 comments on commit f873abc

Please sign in to comment.