User:Rivanbooth/sandbox

The ZX-calculus is a rigorous graphical language for reasoning about linear maps between qubits, which are represented as ZX-diagrams. A ZX-diagram consists of a set of generators called spiders that represent specific tensors. These are connected together to form a tensor network similar to Penrose graphical notation. Due to the symmetries of the spiders and the properties of the underlying category, topologically deforming a ZX-diagram (i.e. moving the generators without changing their connections) does not affect the linear map it represents. In addition to the equalities between ZX-diagrams that are generated by topological deformations, the ZX-calculus also has a set of graphical rewrite rules for transforming ZX-diagrams into one another. The ZX-calculus is universal in the sense that any linear map between qubits can be represented as a ZX-diagram, and different sets of graphical rewrite rules are complete for different families of linear maps. ZX-diagrams can be seen as a generalisation of quantum circuit notation.

History
The ZX-calculus was first introduced by Bob Coecke and Ross Duncan in 2008 as an extension of the Categorical Quantum Mechanics school of reasoning. They introduced the fundamental concepts of spiders, strong complementarity and most of the standard rewrite rules.

In 2009 Duncan and Perdrix found the additional Euler Decomposition rule for the Hadamard gate, which was used by Backens in 2013 to establish the first completeness result for the ZX-calculus. Namely that there exists a set of rewrite rules that suffice to prove all equalities between stabilizer ZX-diagrams, where phases are multiples of $$\pi/2$$, up to global scalars. This result was later refined to completeness including scalar factors.

In 2017, a completion of the ZX-calculus for the approximately universal $$\pi/4$$ fragment was found, in addition to two different completeness results for the universal ZX-calculus (where phases are allowed to take any real value).

Also in 2017 the book Picturing Quantum Processes was released, that builds quantum theory from the ground up, using the ZX-calculus.

Informal introduction
ZX-diagrams consist of green and red nodes called spiders, which are connected by wires. Wires may curve and cross, arbitrarily many wires may connect to the same spider, and multiple wires can go between the same pair of nodes. There are also Hadamard nodes, usually denoted by a yellow box, which always connect to exactly two wires.

ZX-diagrams represent linear maps between qubits, similar to the way in which quantum circuits represent unitary maps between qubits. ZX-diagrams differ from quantum circuits in two main ways. The first is that ZX-diagrams do not have to conform to the rigid topological structure of circuits, and hence can be deformed arbitrarily. The second is that ZX-diagrams come equipped with a set of rewrite rules, collectively referred to as the ZX-calculus. Using these rules, calculations can be performed in the graphical language itself.

Generators
The building blocks or generators of the ZX-calculus are graphical representations of specific states, unitary operators, linear isometries, and projections in the computational basis and the Hadamard-transformed basis. The colour green (or sometimes white) is used to represent the computational basis and the colour red (or sometimes grey) is used to represent the Hadamard-transformed basis. Each of these generator can furthermore be labelled by a phase, which is a real number from the interval $$[-2\pi,2\pi]$$. If the phase is zero it is usually not written.

The generators are:

Composition
The generators can be composed in two ways: These laws correspond to the composition and tensor product of linear maps.
 * sequentially, by connecting the output wires of one generator to the input wires of another;
 * in parallel, by stacking two generators vertically.

Any diagram written by composing generators in this way is called a ZX-diagram. ZX-diagrams are closed under both composition laws: connecting an output of one ZX-diagram to an input of another creates a valid ZX-diagram, and vertically stacking two ZX-diagrams creates a valid ZX-diagram.

Only topology matters
Two diagrams represent the same linear operator if they consist of the same generators connected in the same ways. In other words, whenever two ZX-diagrams can be transformed into one another by topological deformation, then they represent the same linear map. Thus, the controlled-NOT gate can be represented as follows:

Diagram rewriting
The following example of a quantum circuit constructs a GHZ-state. By translating it into a ZX-diagram, using the rules that "adjacent spiders of the same color merge", "Hadamard changes the color of spiders", and "arity-2 spiders are identities", it can be graphically reduced to a GHZ-state:



Any linear map between qubits can be represented as a ZX-diagram, i.e. ZX-diagrams are universal. A given ZX-diagram can be transformed into another ZX-diagram using the rewrite rules of the ZX-calculus if and only if the two diagrams represent the same linear map, i.e. the ZX-calculus is sound and complete.

As a proof system for matrix equations
The following table gives the generators together with their standard interpretations as linear maps, expressed in Dirac notation. The computational basis states are denoted by $$\mid 0 \rangle, \vert 1 \rangle$$ and the Hadamard-transformed basis states are $$\mid \pm \rangle = \frac{1}{\sqrt{2}} (\vert 0 \rangle \pm \vert 1 \rangle)$$. The $$n$$-fold tensor-product of the vector $$\mid \psi \rangle$$ is denoted by $$\mid \psi \rangle^{\otimes n}$$. There are many different versions of the ZX-calculus, using different systems of rewrite rules as axioms. All share the meta rule "only the topoloy matters", which means that two diagrams are equal if they consist of the same generators connected in the same way, no matter how these generators are arranged in the diagram. The following are some of the core set of rewrite rules, here given "up to scalar factor": i.e. two diagrams are considered to be equal if their interpretations as linear maps differ by a non-zero complex factor.

As a dagger compact category
The ZX-calculus describes a category $$\mathsf{ZX}$$, whose morphisms are ZX-diagrams and whose objects are the natural numbers (a ZX diagram is a morphism from $$n$$ input wires to $$m$$ output wires). This category is a dagger compact category, which means that it has symmetric monoidal structure (a tensor product), is compact closed (it has cups and caps) and comes equipped with a dagger, such that all these structures suitably interact. The tensor product is given by addition (the category is a PROP). Imposing rewrite rules on the category makes it into a monoidal 2-category, where each rewrite rule corresponds to a 2-morphism. If instead the rewrite rules are viewed as strict equalities within the category, then the category becomes a quotient category.

Graphically, two ZX-diagrams compose by juxtaposing them horizontally and connecting the outputs of the left-hand diagram to the inputs of the right-hand diagram. The monoidal product of two diagrams is represented by placing one diagram above the other. Indeed, all ZX-diagrams are built freely from the generators above via composition and monoidal product, modulo the equalities induced by the compact structure and the rules of the ZX-calculus given below. For instance, the identity of the object $$n$$ is depicted as $$n$$ parallel wires from left to right, with the special case $$n=0$$ being the empty diagram.

From this point of view, the interpretation presented above in terms of linear maps corresponds to a monoidal functor $$\mathsf{ZX} \to \mathbb{C} \text{-} \mathsf{FVect}$$ into the category of finite-dimensional vectors spaces over $$\mathbb{C}$$. There is another standard interpretation in terms of matrices, given by a functor $$\mathsf{ZX} \to \mathsf{Mat}(\mathbb{C})$$ into the category of matrices with entries in $$\mathbb{C}$$ (this category is explained in the article on additive categories) obtained from the equivalence of $$\mathsf{Mat}(\mathbb{C})$$ and $$\mathbb{C} \text{-} \mathsf{FVect}$$.

As interacting algebras
The two phase-less $$2 \to 1$$ spiders can be interpreted as binary operations $$\mathbb{C}^2 \times \mathbb{C}^2 \to \mathbb{C}^2$$. The spider fusion and identity rules imply that

for either spider, so that each of the pairs

defines a commutative algebra over $$\mathbb{C}$$. The horizontally reflected equations also hold for either of the phase-less $$1 \to 2$$ spiders, interpreted as co-multiplications $$\mathbb{C}^2 \to \mathbb{C}^2 \times \mathbb{C}^2$$, so that each of the pairs

defines a co-commutative coalgebra.

Bialgebras
The copy rule and bialgebra rule further make

each into bialgebras.

Frobenius algebras
Both of these bialgebras verify the Frobenius conditions:

so they are Frobenius algebras.

Hopf algebras
These two Frobenius algebras interact via

which make each of the pairs

Hopf algebras.

Applications
The ZX-calculus has been used in a variety of quantum information and computation tasks.


 * It has been used to describe measurement-based quantum computation and graph states.
 * The ZX-calculus is a language for lattice surgery on surface codes.
 * It has been used to find and verify correctness of quantum error correcting codes.
 * It has been used to optimize quantum circuits.

Tools
The rewrite rules of the ZX-calculus can be implemented formally as an instance of double-pushout rewriting. This has been used in the software Quantomatic to allow automated rewriting of ZX-diagrams (or more general string diagrams). In order to formalise the usage of the "dots" to denote any number of wires, such as used in the spider fusion rule, this software uses bang-box notation to implement rewrite rules where the spiders can have any number of inputs or outputs.

A more recent project to handle ZX-diagrams is PyZX, which is primarily focussed on circuit optimisation.

Related graphical languages
The ZX-calculus is only one of several graphical languages for describing linear maps between qubits. The ZW-calculus was developed alongside the ZX-calculus, and can naturally describe the W-state and Fermionic quantum computing. It was the first graphical language which had a complete rule-set for an approximately universal set of linear maps between qubits, and the early completeness results of the ZX-calculus use a reduction to the ZW-calculus.

A more recent language is the ZH-calculus. This adds the H-box as a generator, that generalizes the Hadamard gate from the ZX-calculus. It can naturally describe quantum circuits involving Toffoli gates.