ZX-Calculus for the Working Quantum Computer Scientist
Total Page:16
File Type:pdf, Size:1020Kb
ZX-calculus for the working quantum computer scientist John van de Wetering1,2 1Radboud Universiteit Nijmegen 2Oxford University December 29, 2020 The ZX-calculus is a graphical language for reasoning about quantum com- putation that has recently seen an increased usage in a variety of areas such as quantum circuit optimisation, surface codes and lattice surgery, measurement- based quantum computation, and quantum foundations. The first half of this review gives a gentle introduction to the ZX-calculus suitable for those fa- miliar with the basics of quantum computing. The aim here is to make the reader comfortable enough with the ZX-calculus that they could use it in their daily work for small computations on quantum circuits and states. The lat- ter sections give a condensed overview of the literature on the ZX-calculus. We discuss Clifford computation and graphically prove the Gottesman-Knill theorem, we discuss a recently introduced extension of the ZX-calculus that allows for convenient reasoning about Toffoli gates, and we discuss the recent completeness theorems for the ZX-calculus that show that, in principle, all reasoning about quantum computation can be done using ZX-diagrams. Ad- ditionally, we discuss the categorical and algebraic origins of the ZX-calculus and we discuss several extensions of the language which can represent mixed states, measurement, classical control and higher-dimensional qudits. Contents 1 Introduction3 1.1 Overview of the paper . 4 1.2 Tools and resources . 5 2 Quantum circuits vs ZX-diagrams6 2.1 From quantum circuits to ZX-diagrams . 6 2.2 States in the ZX-calculus . 7 arXiv:2012.13966v1 [quant-ph] 27 Dec 2020 2.3 Hadamards and colour changing . 8 3 ZX-diagrams9 3.1 Spiders . 9 3.2 Composition . 11 3.3 Symmetries . 13 3.4 Scalars . 15 3.5 Adjoints, transpose and conjugate . 16 3.6 Hadamards . 17 John van de Wetering: [email protected], http://vdwetering.name 1 3.7 Universality . 18 4 The ZX-calculus 18 4.1 Spider fusion and identity removal . 19 4.2 The copy rule and π-commutation . 20 4.3 Formal rewriting and soundness . 22 4.4 Colour changing . 23 4.5 The bialgebra and Hopf rule . 24 4.6 The complete calculus . 27 5 Some example derivations 28 5.1 GHZ-preparation circuit . 29 5.2 Pauli pushing . 29 5.3 Magic state injection . 30 5.4 Teleportation . 30 5.5 Detecting entanglement . 31 5.6 Phase polynomials and phase gadgets . 32 6 Clifford computation 34 6.1 Graph states . 35 6.2 Graph-like diagrams . 36 6.3 Measurement-based quantum computation . 37 6.4 Local complementation and pivoting . 39 6.5 Simplification of Clifford ZX-diagrams . 40 6.6 From ZX-diagrams to circuits . 41 7 ZX-diagrams, categorically 43 7.1 Category theory background . 43 7.2 Interpretation of a ZX-diagram . 44 7.3 Rewriting and completeness . 45 7.4 !-boxes . 46 7.5 Monoids, comonoids, Frobenius algebras and bialgebras . 47 8 Toffoli gates and the ZH-calculus 50 8.1 H-boxes . 50 8.2 The ZH-calculus . 52 8.3 Controlled unitaries . 56 8.4 The graphical Fourier transform . 58 8.5 Optimising Toffoli gates . 60 9 Completeness 62 9.1 History of completeness results . 62 9.2 W-states and the ZW-calculus . 63 9.3 The Oxford completeness results . 65 9.4 The Nancy completeness results . 68 9.5 Completeness from Euler decompositions . 69 9.6 Completeness for other fragments . 70 10 Extensions of the language 70 10.1 Mixed states, decoherence and discarding . 71 10.2 Classical control and doubling . 72 2 10.3 ZX-calculus for qudits . 74 11 Concluding remarks 76 References 76 A ZX-calculus cheatsheets 86 A.1 Generators and their matrices . 86 A.2 Unitaries . 87 A.3 Basic Rewrite rules . 88 A.4 Derived rewrite rules . 89 A.5 ZX-calculus full cheatsheet . 90 A.6 Circuit identities . 91 B Extended generators and rules 92 B.1 ZH-calculus cheatsheet . 93 List of Figures 1 Rules of the ZX-calculus . 27 2 The phase-free rules of the ZH-calculus. 54 3 Rules of the ZW-calculus . 65 4 Extended rules for ZX-calculus (Oxford) . 67 5 Extended rules for ZX-calculus (Nancy) . 68 6 Rules for the discard generator in the ZX-calculus . 72 1 Introduction A ZX-diagram is a graphical representation of a linear map between qubits reminiscent of a conventional quantum circuit diagram. For instance, we can write the circuit on the left below as the ZX-diagram on the right: |0i + |0i H |0i + ZX-diagrams come equipped with a compact set of graphical rewrite rules that allow us to diagrammatically reason about linear maps. For instance, we can prove diagram- matically that the above circuit implements a GHZ state: = = = = = The graphical language consisting of ZX-diagrams and their rewrite rules is called the ZX-calculus. Since the introduction of the ZX-calculus in 2008 by Coecke and Duncan [27, 28], the ZX-calculus has been used for a wide variety of tasks related to quantum computing. One of the first use-cases was in measurement-based quantum computation (MBQC). Graph states have a simple representation as ZX-diagrams [55] and hence the one-way model and related protocols can be described easily [13, 82]. In more recent years the ZX-calculus has been used successfully in quantum circuit optimisation [42, 46, 57, 83]; quantum 3 circuit equality validation [83, 91]; and as a tool for reasoning about surface code quantum computing [72] and lattice surgery [44, 47, 64, 69]. It has also seen use in the design and verification of quantum error correcting codes [23, 25, 53, 62]; elucidating the structure of SAT and #SAT problems [48]; reasoning about certain condensed matter systems [43]; and in describing natural language processing tasks on a quantum computer [39]. In 2017 it was shown that certain rule sets for the ZX-calculus are complete, meaning that any equality between linear maps can be proven entirely diagrammatically [67, 76, 101]. This means that in principle all reasoning about quantum computation can be done inside the ZX-calculus. The goal of this paper is threefold. The first is that after reading this paper the reader should be comfortable enough with the notation and conventions of the ZX-calculus to be able to read any research paper using it. The second goal is to serve as a review of the literature on the ZX-calculus. There are well over a hundred papers and theses that use the ZX-calculus1, yet no concise overview of what has been done and what is known exists. Note that in this review we focus on general results regarding the ZX-calculus. We will not go into detail on domain-specific results except where illustrative (such as in Section6 where we demonstrate the simplification of Clifford circuits). The third and perhaps most ambitious goal is to make the reader comfortable enough with ZX-diagrams that it becomes another tool in their arsenal for their day-to-day reason- ing about quantum computing. Most researchers will regularly use some ad hoc reasoning about quantum circuits and matrices as part of their work. Many of those computations can be replaced by the ZX-calculus in a way that is faster, less error-prone and more amenable to automation. To aid in accomplishing this goal, this paper will spend quite some time explaining how to construct ZX-diagrams for common operators, explain how the rewriting works, and what the motivation is behind certain rewrites. 1.1 Overview of the paper This paper is divided into two parts. Sections2{5 give a general introduction to ZX- diagrams and the ZX-calculus. This part should be read sequentially. Sections6{10 each cover a different topic and can be read more or less independently from each other. In Section2 we informally introduce ZX-diagrams and graphical rewriting by compar- ing it to standard quantum circuit notation. Then in Section3 we introduce ZX-diagrams in full generality. Section4 introduces the rewrite rules of the ZX-calculus. These rules are introduced one by one including motivation and examples. The entire set of rules is presented at the end in Figure1. Section5 serves as a repository of examples of how the ZX-calculus can be used in practice, covering for instance the simplification of quantum circuits, and the proving of correctness of protocols like quantum teleportation. The review portion of the paper starts with Section6 wherein we discuss stabiliser states and Clifford computation using the ZX-calculus. We give a proof sketch that the ZX-calculus is complete for Clifford computation and we give a diagrammatic proof of the Gottesman-Knill theorem, i.e. that Clifford computation can be classically efficiently simulated. We furthermore show how measurement-based quantum computation can be represented in the ZX-calculus and how ZX-diagrams can be transformed back into circuits. In Section7 we review the origins of the ZX-calculus in categorical quantum mechanics and we recall formalisations of several concepts that are commonly used in an intuitive way. 1A list of all publications involving the ZX-calculus is maintained at https://zxcalculus.com/ publications. 4 Section8 discusses Toffoli gates and other multi-linear Boolean logic gates and how they can be represented in the ZX-calculus. To do this, we recall the ZH-calculus, an alternative graphical calculus, that we can view as an extension of the ZX-calculus. A question that was the topic of many early works on the ZX-calculus is whether the ZX-calculus is complete. That is, whether the rules of the ZX-calculus suffice to prove any equation between linear maps that is true.