<<

Introduction to the ZX-calculus

Ross Duncan 10 YEARS OF ZX

The story in 3 parts :

1 : Introduction to the ZX-calculus (past 10+ years)

2 : Completeness of ZX-calculus (past ~1 year) (Simon Perdrix)

3 : The ZH-calculus (next 10 years!) (Miriam Backens) What is the ZX-calculus?

1. Formal Theory for computing

• Diagrammatic syntax for representing quantum processes • Axioms expressing equalities between diagrams • Sound interpretation of diagrams as linear maps What is the ZX-calculus?

2. A graph rewriting system

• A language of labelled graphs • Rewrite rules expressing equations • “Compute” by double push-out rewriting What is the ZX-calculus?

3. A particular class of tensor networks

• Index free diagrammatic presentation • Simple contraction rules • Transformation laws between different presentations of the same tensor What is the ZX-calculus?

4. Categorical algebraic theory

• A PROP whose morphisms are diagrams • Distributive laws between: • Frobenius algebras • Hopf Algebras • Abelian groups • Some other axioms What is the ZX-calculus?

5. Intermediate representation for quantum programs

• Architecture independent • Formal theory of “program” transformations • Suggestive of more basic operations than the usual unitary gates 0. Motivations Transistors are shrinking

10000

1000

100

Feature Size (nm) Log-scale Feature 1972 1988 2005 2016 10

1 1970 1980 1990 2000 2010 2020 Transistors are shrinking

10000

1000

100

Feature Size (nm) Log-scale Feature 1972 1988 2005 2016 10 Quantum effects become important 1 1970 1980 1990 2000 2010 2020

• IDEA: exploit quantum effects for computation

• Fast algorithms (Shor, Grover)

• Simulate physical systems (chemistry, materials)

• Novel cryptographic protocols (QKD, blind computing)

• …. and more. Quantum Computing

announced: 75 machine in the lab Quantum Computing

16

target: 50 qubit machine for sale by 2021 Quantum Computing

target: 400 qubits by 2020

Motivations Motivations Motivations Motivations Motivations

x.y.z.xz(yz) Motivations Motivations Motivations

Hilbert space, unitary transforms, self-adjoint operators.... Motivations ????

Hilbert space, unitary transforms, self-adjoint operators.... The need for abstraction:

This is an 8-bit adder

D ~ 2^1764 What’s so special about quantum? What’s so special about quantum?

Seek a mathematical answer. Superposition? Superposition? Superposition?

Classical waves can exhibit superposition too! No-Cloning and No-Deleting

Theorem: There are no unitary operations D such that D : ⇥ ⇥ ⇥ | ⌅ ⇤⇥ | ⌅| ⌅ D : | ⌅ ⇤⇥ | ⌅| ⌅ unless and are orthogonal [Wooters & Zurek 1982] | |

Theorem: There are no unitary operations E such that E : ⇥ 0 | ⇤ ⇥ | ⇤ E : 0 | ⇤ ⇥ | ⇤ unless and are orthogonal [Pati & Braunstein 2000] | | No-Cloning and No-Deleting

Linear types have been proposed* to capture this: !AAB Separate classical and quantum data in a hybrid machine

** Hensinger et al Nature 2005 But we need additional axioms to get the QM-like behaviour

*vanTonder 2003, Selinger and Valiron 2005, Arrighi and Dowek 2003, Altenkirch & Grattage 2005 Non-locality or Contextuality?

* Aspect et al PRL 1981 Non-locality or Contextuality?

But!

“generalised probabilistic theories” display even stronger non-locality than quantum theory!

Many aspects of contextuality appear in classical settings like databases and NLP!

* Aspect et al PRL 1981 Complementarity

Quantum systems have properties which are not accessible at the same time. They are not even simultaneously well-defined! 1. Quantum Theory in 5 minutes 1. Quantum Theory in 5* minutes

*Might be more than 5 1. Quantum states are represented by unit vectors in a complex Hilbert space.

0 , 1 , 1 ( 0 + 1 ) 2 =: | ⇤ | ⇤ 2 | ⇤ | ⇤ Q 0 |

0 + ei 1 | | 1 | 2. The state space formed by combining two or more systems is the tensor product of their individual state spaces

010 := 0 1 0 2 2 2 = 3 | ⌅ | ⌅| ⌅| ⌅⇥ Q 3. For each discrete time step, an undisturbed quantum system evolves according to a unitary acting on its state space

X, Z, H : X, Z : Q2 Q2 Q Q ⇤ ⇤

...but the is not directly accessible... more on this later! Example: Z-Rotation

0 |

1 | Quantum Circuits

Input register “Time” | Í

2n - 2n U : C C Unitary gates

Õ Output register | Í Universality

We say that a model of quantum computation is universal if it can represent all unitary maps.

The circuit model requires a small set of gates to be universal: Universality

We say that a model of quantum computation is universal if it can represent all unitary maps.

The circuit model requires a small set of gates to be universal: Example 3.9 (Bell state). A Bell state, 00 + 11 , is prepared by the circuit | Í | Í below, on the left.

0 0 | Í | Í Q R H T H = ú ú ú æ æ æ c d c d c d c d a b The corresponding zx-calculus derivation is a proof of the correctness of this circuit. To simplifyQuantum the next Circuits example, we introduce some shorthand for some useful Example 3.9 (Bell state). A Bell state, 00 + 11 , is prepared by the circuit circuit elements. | Í | Í below, on the left.

0 0 | Í | Í H 0 + | Í Q R H T H Z= := ú ú| Í := ú æ æ Hæ c d c d H c d c d a b ThePreparing corresponding a Bell statezx-calculusControlled- derivation gate is a proof of the correctness of this circuit.Example 3.10 (1D-). A 1-dimensional cluster state consists of a collection qubits 1,...,n initialised in the state + = 0 + 1 , which are then Z | Í | Í | Í entangledTo simplify by the applying next example, a Z operation we introduce to qubits somei and shorthandi 1, and for some to i and usefuli +1. · ≠ circuitThe corresponding elements. circuit is shown below:

... + + + + ...... | Í | Í | Í |HÍ 0 Q R H H H T Z Z Z = + | Í Z := | Í := c d ... H H H ... c ... Z Z ... d c H d c d a b The zx-calculus translation can be radically simplified by repeated use of the Examplespider rule: 3.10 (1D-cluster state). A 1-dimensional cluster state consists of a collection qubits 1,...,n initialised in the state + = 0 + 1 , which are then ...... | Í | Í | Í entangled by applying a Z operation to qubits i and i 1, and to i and i +1. H H · H ... H H≠ H H H ... The corresponding circuit is shown below:ú ... H H ... æ ... + + + + ...... | Í | Í | Í | Í

Q The 1D-cluster is a special case of a moreR generalH class of states:H graphH states. T These statesZ are the basisZ of measurement-basedZ = quantum computation, and will c d ... H H ... cplay... an importantZ role later inZ the paper.... d c d c d a b The3.2zx-calculus Circuit-like translation diagrams can be radically simplified by repeated use of the spider rule: While the preceding has demonstrated the ease with quantum circuits can be ...translated into diagrams, there... are many diagrams which do not correspond to ...... H H H ú H H H H H æ ... H H ... 16

The 1D-cluster is a special case of a more general class of states: graph states. These states are the basis of measurement-based quantum computation, and will play an important role later in the paper.

3.2 Circuit-like diagrams While the preceding has demonstrated the ease with quantum circuits can be translated into diagrams, there are many diagrams which do not correspond to

16 Quantum

4. Each quantity O is represented as self-adjoint operator Oˆ = e e : i i | i⇥ i| ˆ •The possible values of O are the eigenvalues i of O When we observe O for a system in state , there is • 2 | probability e of observing . i | ⇥ i •If i is the outcome of the measurement, the system is then in state e i . | X and Z Spins

We can measure the of qubit ⇤ = 0 + ⇥ 1 | | | 10 01 Z = X = 0 1 10 ⇥ ⇥ 0 + ⇥ 1 | ⇥ | ⇥

p =( p =( 2 2 + ⇥ ⇥ = ⇥ ) = p ) / p / 2 2 2 2

⇥ ⇥ 0 1 + | ⇥ | ⇥ | ⇥ |⇥ X and Z Spins

We can measure the spin of qubit ⇤ = 0 + ⇥ 1 | | | 10 01 Z = X = 0 1 10 ⇥ ⇥ 0 | ⇥

p p =1 =1 =1 / p =0 / 2 p 2

⇥ ⇥ 0 1 + | ⇥ | ⇥ | ⇥ |⇥ Quantum Observables

Measuring A then B may give a different answer than measuring B first then A!

Not all observables are well defined at the same time: • Two observables are compatible if their operators commute • Two operators commute if they have the same eigenvectors • Identify a non-degenerate observable with its eigenbasis Incompatible Observables

a0 b0

b1

a1 Complementary Observables

a0

b1 b0

a1

1 ai bj = | | ⇥| ⌅D Complementary Observables

a0

b1 b0

a1

1 ai bj = “Mutually Unbiased Bases” | | ⇥| ⌅D 2. Diagrammatic Languages PAST / HEAVEN

FUTURE / HELL Why Diagrams? Why Diagrams?

100 0 1 1 010 0 01 ⇤ ⇤ ⌅ ⌅ 2 1 ⇥ 001 0 ⇥ 10 ⇥ ⇥ ⌥ ⌥ 000ei⇤ ⌥ ⌥ ⇧ ⇧ ⌃ ⌃ 1000 1000 11 01 0010 ⇤⇤ ⇤ ⇤ ⌅⌅ ⇤ 0001 ⇥ 1 1 ⇤ 10 ⇥ 0100 ⇤ ⇥ ⇥⇥ ⇥ ⌥⌥ ⌥ ⌥ 0001 ⌥⌥ ⌥ ⌥ ⇧⇧ ⇧ ⇧ ⌃⌃ 1000 0100 10 10 ⇤⇤ ⌅ ⌅⌅ ⌅ = ? 0001 ⇥ 01 ⇥ 01 ⇥ ⇥ ⌥⌥ 0010 ⌥⌥ ⇧⇧ ⌃ ⌃⌃ ⌃ 1000 100 0 0100 cos ⌅ 10 010 0 ⇤⇤ ⌅ 6 ⌅ ⇤ ⌅ ⇤ 0001 ⇤ i sin ⌅ ⇥ 0 ei⇥ ⇥ 001 0 6 ⇥ ⇥⇥ ⌥⌥ 0010 ⌥ 000ei ⌥⌥ ⌥ ⇧⇧ ⌃ ⌃ ⇧ ⌃ Diagrams

A B j : A B C D E j ⇥

C D E Diagrams

Input Systems A B j : A B C D E j ⇥

C D E Diagrams

Input Systems A B j : A B C D E j ⇥

C D E

Output Systems Diagrams

Input Systems A B j : A B C D E j Interaction, ⇥ or process, or state change, or ...

C D E

Output Systems Monoidal Categories f : A Bg: B Ch: C D A B C f g h B C D Monoidal Categories

f : A Bg: B Ch: C D A B C f g h B C D g f : A C ⇥ A f B g

C Monoidal Categories

f : A Bg: B Ch: C D A B C f g h B C D g f : A C ⇥ A f h : A C B D f ⇥ A C B f h g B D C Monoidal Categories

A f A C B A B C f h g f g h B D C B C D g k h C E D Monoidal Categories

Monoidal categories have a special unit object called I which is a left and right identity for the tensor: I A = A = A I id f = f = f id I I No lines are drawn for I in the graphical notation:

⇥ : I A † : A I † ⇥ : I I ⇥ ⇥ ⇥

⇥ : I A † : A I †⇥ :⇥I : I A I † : A I † ⇥ : I I ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ : I A ⇥† : IA AI † : A⇥ : I I I † ⇥ : I I ⇥ ⇥⇥ ⇥ ⇥ ⇥ Graphical Calculus Theorem

Thm: one diagram can be deformed to another iff their denotations are equal by the structural equations of the category.

C g D h

B f

A

c k C E Graphical Calculus Theorem

Thm: one diagram can be deformed to another iff their denotations are equal by the structural equations of the category.

C g C A D h g f B

f = D B c A k h E C c k C E 3. The Theorems Behind The Scene “Observables”

Non-degenerate, projective observables on finite dimensional spaces i.e. Orthonormal bases A = a , a ,..., a | 1i | 2i | di Unbiasedness and Phases

A state is unbiased for a basis A if | i 1 ai = |h | i| pd Every unbiased state determines a unitary map via U : a pd a a | ii 7! h i | i | ii This is called a phase map for A. Unbiasedness and Phases

A state is unbiased for a basis A if | i 1 a = Proposition 1: |h i | i| p The phases of any observable form dan abelian group Every unbiased state determines a unitary map via U : a pd a a | ii 7! h i | i | ii This is called a phase map for A. Phases & Unbiased Points

0 0 | |

0 + ei 1 | | 1 1 | | 10 Z = ↵ 0 ei↵ ✓ ◆ Complementarity

Two observables A and B are complementary if 1 ai bj = i, j |h | i| pd 8 (aka mutually unbiased)

They are strongly complementary if U b i is a { i } subgroup of the phase group A . Observables are Frobenius Algebras

Theorem 2: Observables are in bijection with †- special commutative Frobenius algebras. : A A Aµ: A A A ! ⌦ ⌦ ! ✏ : A I ⌘ : I A ! ! Via:

:: a a a µ = † | ii!| ii⌦| ii ✏ :: a 1 ⌘ = ⌘✏†† | ii!

Coecke, Pavlovic, and Vicary, “A new description of orthogonal bases”, MSCS 23(3), 2013. arxiv:0810.0812 Strongly Complementary Observables are Hopf algebras

Theorem 3: Two observables are strongly complementary iff they form a Hopf algebra

” ‘ µ ÷ µ ÷ ” ‘

Coecke and Duncan, “Interacting Quantum Observables: categorical algebra and diagrammatics”, NJP 13(043016), 2011, arXiv:0906.4725.

1 Strongly Complementary Observables are Hopf algebras

Theorem 3: Two observables are strongly complementary iff they form a Hopf algebra

Frobenius ” ‘ µ ÷

Frobenius µ ÷ ” ‘

Coecke and Duncan, “Interacting Quantum Observables: categorical algebra and diagrammatics”, NJP 13(043016), 2011, arXiv:0906.4725.

1 Strongly Complementary Observables are Hopf algebras

Theorem 3: Two observables are strongly complementary iff they form a Hopf algebra

” ‘ µ ÷ µ ÷ ” ‘

Hopf Hopf

Coecke and Duncan, “Interacting Quantum Observables: categorical algebra and diagrammatics”, NJP 13(043016), 2011, arXiv:0906.4725.

1 Strong Complementarity ⟺ GHZ/Mermin Non-locality

Theorem 4: Two observables are strongly complementary iff they admit a Mermin-style probability-free proof of non-locality.

B. Coecke, RD, A. Kissinger, Q. Wang, Strong Complementarity and Non-locality in Categorical , LiCS 2012, doi: 10.1109/LICS.2012.35 B. Coecke, RD, A. Kissinger, Q. Wang, Generalised Compositional Theories and Diagrammatic Reasoning; arXiv:1506.03632 5. The ZX-Calculus ZX-calculus syntax

...... – – – – H H ......

↵ [0, 2⇡) FigureFigure 2: Interior2 2: Interior vertices vertices of diagrams of diagrams Defn: A diagram is an undirected open graph generated by the above vertices. X vertices with m inputs and n outputs, labelled by an angle – [0, 2fi); X vertices• with m inputs and n outputs, labelled by an angle – [0,œ2fi); • these are these are denotedm Xm(–), and shown graphicallyœ as (dark) red these are these are denoted Xn (–),n and shown graphically as (dark) red circles,circles, H (or Hadamard)H (or Hadamard) vertices, vertices, restricted restricted to degree to degree 2; shown 2; shown as squares. as squares. • • If a X Ifor aZXvertexor Z vertex has – has=0–then=0 thethen label the label is entirely is entirely omitted. omitted. The The allowed allowed verticesvertices are shown are shown in Figure in Figure??. ??. Since the inputs and outputs of of a diagram are totally ordered, we can Since the inputs and outputs of of a diagram are totally ordered, we can identify them with natural numbers and speak of the kth input, etc. identify them with natural numbers and speak of the kth input, etc. Remark 3.4. When a vertex occurs inside the graph, the distinction between Remark 3.4. When a vertex occurs inside the graph, the distinction between inputs and outputs is purely conventional: one can view them simply as vertices inputs andof degree outputsn + ism purely; however, conventional: this distinction one can allows view the them semantics simply to as be vertices stated more of degreedirectly,n + m; see however, below. this distinction allows the semantics to be stated more directly, see below. The collection of diagrams forms a compact category in the obvious way: the Theobjects collection are of natural diagrams numbers forms and a compact the arrows categorym inn theare obvious those diagrams way: the with objects are natural numbers and the arrows m n æare those diagrams with m inputs and n outputs; composition g f æis formed by identifying the inputs m inputs and n outputs; composition g f is¶ formed by identifying the inputs of g with the outputs of f and erasing¶ the corresponding vertices; f g is the of g with the outputs of f and erasing the corresponding vertices; f g is¢ the diagram formed by the disjoint union of f and g with If ordered¢ before Ig, and diagramsimilarly formed for by the the outputs. disjoint union This is of basicallyf and g thewith freeIf (self-dual)ordered before compactIg, category and similarlygenerated for the outputs. by the arrows This is shown basically in Figure the free??. (self-dual) compact category generated byWe the can arrows make thisshown category in Figure-compact??. by specifying that f † is the same † Wediagram can make as thisf, but category with the-compact inputs and by outputs specifying exchanged, that f † andis the all the same angles † diagramnegated. as f, but with the inputs and outputs exchanged, and all the angles negated. This construction yields a category that does not incorporate the algebraic Thisstructure construction of strongly yields complementary a category that observables. does not incorporate To obtain the the desired algebraic category structurewe of must strongly quotient complementary by the equations observables. shown in To Figure obtain??. the We desired denote category the category we mustso-obtained quotient by by theD. equations shown in Figure ??. We denote the category so-obtainedRemark by D 3.5.. The equations shown in Figure ?? are not exactly those described Remarkin Sections 3.5. The?? equationsand ??, however shown in they Figure are?? equivalentare not exactly to them. those We shall described therefore, in Sectionson occasion,?? and ?? use, however properties they discussed are equivalent earlier as to derived them. rules We shall in computations. therefore, on occasion,Since useD propertiesis a monoidal discussed category earlier we can as assign derived an rulesinterpretation in computations. to any diagram by providing a monoidal functor from to any other monoidal category. Since Since D is a monoidal category we can assignD an interpretation to any diagram we interested in quantum mechanics, the obvious target category is fdHilb. by providing a monoidal functor from D to any other monoidal category. Since we interestedDefinition in quantum 3.6. Let mechanics,: D fdHilb the obviousbe a symmetric target category monoidal is fdHilb functor. defined · æ on objects by Definition 3.6. Let : D fdHilb be a symmetric2 monoidal functor defined · æ 1 = on objects by J K C 2 J K 1 = C J K18 J K18

hl h variables the while

variables

eapido qubit on applied be

odtosi h etsection. next the in conditions

hwtecniin hc oto h ro-orcigpr.W ildrv these derive will We part. error-correcting the control which conditions the show

ydoe n rca ealhsbe mte rmti itr:w onot do we picture: this from omitted been has detail crucial One syndrome.

h n,wihaeapplied are which end, the

ro syndrome error

n hnmaue h nile h eutn esrmnsaecle the called are measurements resulting The ancillae. the measures then and

h eoigcruti ipyteecdri reverse. in encoder the simply is circuit decoding The error-detecting

hw nFgr .Ntc httecrutntrlyslt notoprs The parts. two into splits naturally circuit the that Notice 4. Figure in shown

orc roso h noe aa h ici o arigotti ucinis function this out carrying for circuit The data. encoded the on errors correct

h ro corrector error The

tutr oeclearly. more structure

eo;tefia qaini eeyararnmn ftevrie oso the show to vertices the of rearrangment a merely is equation final the below;

iia omwtothmnitreto.Tersligsmlfiaini shown is simplification resulting The intervention. human without form minimal

i h ici hw nFgr a.Nt htqbt3i h nu.Uigthe Using input. the is 3 qubit that Note (a). 3 Figure in shown circuit the via

iue3(b). 3 Figure

rnlto ecie nEape25w banthe obtain we 2.5 Example in described translation

h encoder The

etasaetecrutit the into circuit the translate We

h noigcruti ipeeog htQatmtccnrdc tt its to it reduce can Quantomatic that enough simple is circuit encoding The

|

|

|

|

|

|

0

0

0

0

0

0

H

H

H

Í

Í

Í

Í

Í

Í

iue3 h noe a sacrut b nthe in (b) circuit; a as (a) encoder The 3: Figure

,b f , . . . b, a,

H

H

H

.The

atitoue -ui nil,etnlsi ihteinput, the with it entangles ancilla, 6-qubit a introduces part

h noe asasnl nu ui ote7qbtcode-space 7-qubit the to qubit input single a maps encoder The

x

a (b) (a)

i

niaeteotoe ftesxsnrm measurments, syndrome six the of outcomes the indicate

i

ftecodeword. the of

and

error-correcting

necdri o eyueu fw antdtc and detect cannot we if useful very not is encoder An

0

1

2

3

4

5

6

z

i

conditionally

=

niaewehraPauli a whether indicate

0

1

2

3

4

5

6

zx

6

atcmrsstePuioeain at operations Pauli the comprises part

cluu ssoni iue5 The 5. Figure in shown as -calculus

eedn ntevleo h error the of value the on depending ,

0

1

2

3

4

5

6

zx

=

X

cluu emsonin shown term -calculus

H H

Example H

or zx

1 qubit

Z

-calculus.

orcinneed correction

0

1

2

3

4

5 6

7 qubit

4

2

3

6

0

1 5 ZX-calculus semantics

... n m... 0 ⌦ 0 ⌦ – | i 7! | i – H n i↵ m 1 ⌦ e 1 ⌦ ... | i 7! | ...i

... Figure... 2: Interiorn verticesm of diagrams + ⌦ + ⌦ – – | i 7! | Hi n i↵ m ⌦ e ⌦ ...... |i 7! |i X vertices with m inputs and n outputs, labelled by an angle – [0, 2fi); • m œ Figurethese 2: Interior are these vertices are denoted of diagramsXn (–), and shown graphically as (dark) red circles, H (or Hadamard) vertices, restricted to degree 2; shown as squares. X vertices with m•inputs and n outputs, labelled by an angle – [0, 2fi); • m œ these are theseIf are a X denotedor Z vertexXn (– has), and– =0 shownthen graphically the label is as entirely (dark) omitted. red The allowed circles, vertices are shown in Figure ??. H (or Hadamard)Since vertices, the restricted inputs and to outputs degree of 2; shownof a diagram as squares. are totally ordered, we can • identify them with natural numbers and speak of the kth input, etc. If a X or Z vertex has – =0then the label is entirely omitted. The allowed vertices are shown inRemark Figure ?? 3.4.. When a vertex occurs inside the graph, the distinction between inputs and outputs is purely conventional: one can view them simply as vertices Since the inputsof and degree outputsn + m of; however, of a diagram this distinction are totally allows ordered, the semantics we can to be stated more identify them with naturaldirectly, numbers see below. and speak of the kth input, etc. Remark 3.4. When aThe vertex collection occurs of inside diagrams the graph, forms a the compact distinction category between in the obvious way: the inputs and outputs isobjects purely are conventional: natural numbers one can and view the them arrows simplym asn verticesare those diagrams with æ of degree n + m; however,m inputs this and distinctionn outputs; allows composition the semanticsg f tois be formed stated by more identifying the inputs ¶ directly, see below. of g with the outputs of f and erasing the corresponding vertices; f g is the ¢ diagram formed by the disjoint union of f and g with I ordered before I , and The collection of diagrams forms a compact category in the obvious way:f the g similarly for the outputs. This is basically the free (self-dual) compact category objects are natural numbers and the arrows m n are those diagrams with generated by the arrows shownæ in Figure ??. m inputs and n outputs; composition g f is formed by identifying the inputs We can make this¶ category -compact by specifying that f † is the same of g with the outputs of f and erasing the corresponding† vertices; f g is the diagram as f, but with the inputs and outputs exchanged,¢ and all the angles diagram formed by thenegated. disjoint union of f and g with If ordered before Ig, and similarly for the outputs.This This construction is basically yields the free a category (self-dual) that compact does not category incorporate the algebraic generated by the arrowsstructure shown of in strongly Figure complementary??. observables. To obtain the desired category We can make this category -compact by specifying that f † is the same we must quotient† by the equations shown in Figure ??. We denote the category diagram as f, but withso-obtained the inputs by D and. outputs exchanged, and all the angles negated. This constructionRemark yields a 3.5. categoryThe equations that does shown not incorporate in Figure ?? theare algebraic not exactly those described structure of stronglyin complementary Sections ?? and observables.??, however To they obtain are equivalentthe desired to category them. We shall therefore, we must quotient byon the occasion, equations use shown properties in Figure discussed??. We earlier denote as derived the category rules in computations. so-obtained by D. Since D is a monoidal category we can assign an interpretation to any diagram Remark 3.5. The equationsby providing shown a monoidal in Figure functor?? are from not exactlyD to any those other described monoidal category. Since we interested in quantum mechanics, the obvious target category is fdHilb. in Sections ?? and ??, however they are equivalent to them. We shall therefore, on occasion, use propertiesDefinition discussed 3.6. Let earlier: asD derivedfdHilb rulesbe a in symmetric computations. monoidal functor defined · æ on objects by Since D is a monoidal category we can assign an interpretation2 to any diagram J K 1 = C by providing a monoidal functor from D to any other monoidal category. Since we interested in quantum mechanics, the obvious target category is fdHilb. J K18 Definition 3.6. Let : D fdHilb be a symmetric monoidal functor defined · æ on objects by 2 J K 1 = C

J K18 ZX-calculus semantics

... n m... 0 ⌦ 0 ⌦ – | i 7! | i – H n i↵ m 1 ⌦ e 1 ⌦ ... | i 7! | ...i Extend this to a strict monoidal functor: get a linear map for every diagram ... Figure... 2: Interiorn verticesm of diagrams + ⌦ + ⌦ – – | i 7! | Hi n i↵ m ⌦ e ⌦ ...... |i 7! |i X vertices with m inputs and n outputs, labelled by an angle – [0, 2fi); • m œ Figurethese 2: Interior are these vertices are denoted of diagramsXn (–), and shown graphically as (dark) red circles, H (or Hadamard) vertices, restricted to degree 2; shown as squares. X vertices with m•inputs and n outputs, labelled by an angle – [0, 2fi); • m œ these are theseIf are a X denotedor Z vertexXn (– has), and– =0 shownthen graphically the label is as entirely (dark) omitted. red The allowed circles, vertices are shown in Figure ??. H (or Hadamard)Since vertices, the restricted inputs and to outputs degree of 2; shownof a diagram as squares. are totally ordered, we can • identify them with natural numbers and speak of the kth input, etc. If a X or Z vertex has – =0then the label is entirely omitted. The allowed vertices are shown inRemark Figure ?? 3.4.. When a vertex occurs inside the graph, the distinction between inputs and outputs is purely conventional: one can view them simply as vertices Since the inputsof and degree outputsn + m of; however, of a diagram this distinction are totally allows ordered, the semantics we can to be stated more identify them with naturaldirectly, numbers see below. and speak of the kth input, etc. Remark 3.4. When aThe vertex collection occurs of inside diagrams the graph, forms a the compact distinction category between in the obvious way: the inputs and outputs isobjects purely are conventional: natural numbers one can and view the them arrows simplym asn verticesare those diagrams with æ of degree n + m; however,m inputs this and distinctionn outputs; allows composition the semanticsg f tois be formed stated by more identifying the inputs ¶ directly, see below. of g with the outputs of f and erasing the corresponding vertices; f g is the ¢ diagram formed by the disjoint union of f and g with I ordered before I , and The collection of diagrams forms a compact category in the obvious way:f the g similarly for the outputs. This is basically the free (self-dual) compact category objects are natural numbers and the arrows m n are those diagrams with generated by the arrows shownæ in Figure ??. m inputs and n outputs; composition g f is formed by identifying the inputs We can make this¶ category -compact by specifying that f † is the same of g with the outputs of f and erasing the corresponding† vertices; f g is the diagram as f, but with the inputs and outputs exchanged,¢ and all the angles diagram formed by thenegated. disjoint union of f and g with If ordered before Ig, and similarly for the outputs.This This construction is basically yields the free a category (self-dual) that compact does not category incorporate the algebraic generated by the arrowsstructure shown of in strongly Figure complementary??. observables. To obtain the desired category We can make this category -compact by specifying that f † is the same we must quotient† by the equations shown in Figure ??. We denote the category diagram as f, but withso-obtained the inputs by D and. outputs exchanged, and all the angles negated. This constructionRemark yields a 3.5. categoryThe equations that does shown not incorporate in Figure ?? theare algebraic not exactly those described structure of stronglyin complementary Sections ?? and observables.??, however To they obtain are equivalentthe desired to category them. We shall therefore, we must quotient byon the occasion, equations use shown properties in Figure discussed??. We earlier denote as derived the category rules in computations. so-obtained by D. Since D is a monoidal category we can assign an interpretation to any diagram Remark 3.5. The equationsby providing shown a monoidal in Figure functor?? are from not exactlyD to any those other described monoidal category. Since we interested in quantum mechanics, the obvious target category is fdHilb. in Sections ?? and ??, however they are equivalent to them. We shall therefore, on occasion, use propertiesDefinition discussed 3.6. Let earlier: asD derivedfdHilb rulesbe a in symmetric computations. monoidal functor defined · æ on objects by Since D is a monoidal category we can assign an interpretation2 to any diagram J K 1 = C by providing a monoidal functor from D to any other monoidal category. Since we interested in quantum mechanics, the obvious target category is fdHilb. J K18 Definition 3.6. Let : D fdHilb be a symmetric monoidal functor defined · æ on objects by 2 J K 1 = C

J K18 Representing Qubits Representing Paulis Representing Phase shifts Representing CNot The ZX-calculus is universal

Theorem: Let U be a unitary map on n qubits; then there exists a ZX-calculus term D such that:

D = U

J K The ZX-calculus is universal

Theorem: Let U be a unitary map on n qubits; then there exists a ZX-calculus term D such that:

D = U

J 7!K

7!

7! Equations Equations Generalised Spider Equations Equations “Strong Complementarity” Equations

··· ⇡ ··· ⇡ 2 2 2 2 n ↵ + 2 = ↵

⇡ ⇡ 2 2 2 2 ··· ··· (colour change) Equations A weird one specific to ZX

··· ⇡ ··· ⇡ 2 2 2 2 n ↵ + 2 = ↵

⇡ ⇡ 2 2 2 2 ··· ··· (colour change) The ZX-calculus is sound

Theorem: Let D1 and D2 be diagrams of the ZX-calculus. Then:

ZX implies D1 = D2 D1 = D2

J K J K Proof: The semantics defines a strict monoidal functor; then just check that the axioms obey the property. Representing Hadamard

fi 2

1 11 H = = fi Ô 1 1 2 2 3 ≠ 4 JKfi 2 More on the Hadamard

fi 2

fi H := 2

fi 2 More on the Hadamard

H ··· H

H H ··· More on the Hadamard

⇡ 2 ··· 2 ⇡ H ··· H 2 2

n ↵ = ↵ + 2

⇡ H H 2 2 ··· ⇡ 2 2 ··· More on the Hadamard

⇡ ⇡ ⇡ 2 ··· 2 2 ··· 2 ⇡ ⇡ ⇡ H ··· H 2 2 2 2 n ↵ = ↵ + 2 = ↵

⇡ ⇡ ⇡ H H 2 2 2 2 ··· ⇡ ⇡ ⇡ 2 2 2 2 ··· ··· More on the Hadamard

⇡ ⇡ ⇡ 2 ··· 2 2 ··· 2 ⇡ ⇡ ⇡ H ··· H 2 2 2 2 ··· n ↵ = ↵ + 2 = ↵ = ↵

⇡ ⇡ ⇡ H H 2 2 2 2 ··· ⇡ ⇡ ⇡ ··· 2 2 2 2 ··· ··· Corollary: total symmetry between red and green Proof. It suces to show that there are zx-calculus terms for the matrices Z–, H and X.Wehave ·

H = H, – = Z and = X – ·

Example 3.9 (Bell state). A BellJ state,K 00 + 11 ,J is preparedK by the circuit J K which can be verified| Í by| Í direct calculation. Note that below, on the left.

0 0 | Í | Í Q R H T H = ú ú ú= æ æ æ c d c d c d c d J K J K a b so the presentation of X is unambiguous. The corresponding zx-calculus derivation is a proof· of the correctness of this circuit. ExampleExample: 3.12 (TheControlled-ZZ-gate). The Z-gate can be obtained by using a · · To simplify the nextHadamard example, we ( introduceH) gate to some transform shorthand the for second some useful qubit of a X gate. We obtain a · circuit elements. simpler representation using the colour-change rule

H H 0 + | Í := | Í := H Z H = H 7! H

From the presentation of Z in the zx-calculus, we can immediately read o Example 3.10 (1D-cluster state). A 1-dimensional· cluster state consists of a collection qubits 1,...,nthatinitialised it is symmetric in the state in+ its= inputs.0 + 1 , Furthermore, which are then we can prove one of the basic | Í | Í | Í entangled by applying apropertiesZ operation of the to qubitsZ gate,i and namelyi 1, and that to i isand self-inverse.i +1. · · ≠ The corresponding circuit is shown below:

H H H H H ... + + + + ...... | Í | Í | Í | Í = = = = = Q H R H H H H H T Z Z Z = H H c d ... H H ... c ... Z Z ... d c d c Example 3.13 d(Bell state). The following is a zx-calculus term representing a a b The zx-calculus translationquantum can be circuit radically which simplified produces by repeated a Bell state, use of00 the+ 11 . We can verify this fact | Í | Í spider rule: by the equations of the calculus......

... H H H H H ... H H H ú H = = = ... H H ... æ

The 1D-cluster is a special case of a more general class of states: graph states. These states are the basisThe of measurement-based corresponding zx quantum-calculus computation, derivation and is a will proof of the correctness of this play an important role latercircuit. in the paper. The zx-calculus can represent many things which do not correspond to 3.2 Circuit-like diagrams quantum circuits. We now present a criterion to recognise which diagrams do While the preceding hascorrespond demonstrated to thequantum ease with circuits. quantum circuits can be translated into diagrams, there are many diagrams which do not correspond to

21 16 Proof. It suces to show that there are zx-calculus terms for the matrices Z–, H and X.Wehave ·

H = H, – = Z and = X – · J K J K J K which can be verified by direct calculation. Note that

=

J K J K so the presentation of X is unambiguous. · Example 3.12 (The Z-gate). The Z-gate can be obtained by using a · · Hadamard (H) gate to transform the second qubit of a X gate. We obtain a Example: Controlled-Z · simpler representation using the colour-change rule

H

= H

H

From the presentation of Z in the zx-calculus, we can immediately read o · that it is symmetric in its inputs. Furthermore, we can prove one of the basic properties of the Z gate, namely that is self-inverse. ·

H H H H H = = = = = H H H H H

Example 3.13 (Bell state). The following is a zx-calculus term representing a which produces a Bell state, 00 + 11 . We can verify this fact | Í | Í by the equations of the calculus.

H = = =

The corresponding zx-calculus derivation is a proof of the correctness of this circuit. The zx-calculus can represent many things which do not correspond to quantum circuits. We now present a criterion to recognise which diagrams do correspond to quantum circuits.

21 = = =

= = =

Example: CNOTS

? == = =

= = =

= – – + — —

–2 = –4

= i –i –1 q – –3 –5

= – – + — —

–2

–4 1

= i –i –1 q

–3 –5

1 Example: CNOTS

= = =

= = = =

= – – + — —

–2

–4

= i –i –1 q

–3 –5

1 Example: 2-Qubit Quantum Fourier Transform

H j = 1 1 | j = 0 0 | input H qubits /4 /4 controlled Z/2 gate Example: 2-Qubit Quantum Fourier Transform

H

H /4 /4 Example: 2-Qubit Quantum Fourier Transform

H

H /4 /4 Example: 2-Qubit Quantum Fourier Transform

H

H /4 /4 Example: 2-Qubit Quantum Fourier Transform

H /4 /4 Example: 2-Qubit Quantum Fourier Transform

/4 /4 Example: 2-Qubit Quantum Fourier Transform

/4 /4 Example: 2-Qubit Quantum Fourier Transform

/4 /4 Example: 2-Qubit Quantum Fourier Transform

/4 /4 Example: 2-Qubit Quantum Fourier Transform

/2 Example: 2-Qubit Quantum Fourier Transform

output qubits

i j = 0 + e 2 1 0 | | j = 0 + ei 1 1 | |

/2 6. Applications Liam’s project :

* Formalise the “smallest interesting colour code” in the ZX-calculus

* Formally verify its basic properties in quantomatic Liam’s project :

* Formalise the “smallest interesting colour code” in the ZX-calculus

* Formally verify its basic properties in quantomaticA Liam’s project :

* Formalise the “smallest interesting colour code” in the ZX-calculus

* Formally verify its basic properties in quantomaticA

Liam doesn’t know anything about quantum theory! 8 The Smallest Interesting Colour Code in Quantomatic Encoding encoder in reverse.

Enc := Dec := Enc† =

We note that the graph for Enc contains no H vertices and no angles. For such terms we have the following result: Proposition 5.1. [23]Anyzx-calculus term without angles or H vertices is equal to a term in subset-spanning form; further, the subset-spanning form is quasi-unique and can be computed by a terminating algorithm. Space does not permit a description of the quasi-normal forms; the important point here is that the normalisation procedure is implemented in a Quantomatic simproc called rotate_simp. We will make extensive use of this in the sequel.

Proposition 5.2. Encoding followed by decoding is the identity, i.e. Enc† Enc = id ,orin ¶ 3 pictures:

=

This result can be proven by rotate_simp without human intervention; it requires 66 rewrite steps and takes approximately 5 seconds of real time. See Appendix C.1.1. Note that Proposition 5.2 doesn’t establish that the 8 codewords of Table 1 are prepared as required; this is a corollary of the tranversality of the Pauli group, which we show in the next section. The astute reader will have noticed that the encoder is not actually a quantum circuit: the top “rails” end in a projection onto the state + . However, no post-selection is required: we can | Í implement Enc with a circuit using five ancilla qubits. Proposition 5.3. Enc is a unitary embedding.

Proof. We do the proof in two stages, shown below.

= = 8 EncodingThe Smallest Interesting Colour Code in Quantomatic encoder in reverse.

Enc := Dec := Enc† =

We note that the graph for Enc contains no H vertices and no angles. For such terms we have the following result: Proposition 5.1. [23]Anyzx-calculus term without angles or H vertices is equal to a term in subset-spanning form; further, the subset-spanning form is quasi-unique and can be computed by a terminating algorithm. Space does not permit a description of the quasi-normal forms; the important point here is that the normalisation procedure is implemented in a Quantomatic simproc called rotate_simp. We will make extensive use of this in the sequel.

Proposition 5.2. Encoding followed by decoding is the identity, i.e. Enc† Enc = id ,orin ¶ 3 pictures:

=

This result can be proven by rotate_simp without human intervention; it requires 66 rewrite steps and takes approximately 5 seconds of real time. See Appendix C.1.1. Note that Proposition 5.2 doesn’t establish that the 8 codewords of Table 1 are prepared as required; this is a corollary of the tranversality of the Pauli group, which we show in the next section. The astute reader will have noticed that the encoder is not actually a quantum circuit: the top “rails” end in a projection onto the state + . However, no post-selection is required: we can | Í implement Enc with a circuit using five ancilla qubits. Proposition 5.3. Enc is a unitary embedding.

Proof. We do the proof in two stages, shown below.

= = 8 8 TheEncoding SmallestThe Interesting Smallest Colour Interesting Code Colour in Quantomatic Code in Quantomatic encoder in reverse.encoder in reverse.

Enc := Enc := Dec := Enc† =Dec := Enc† =

We note that theWe graph note that for Enc the graphcontains for noEncHcontainsvertices no andH novertices angles. and For no such angles. terms For we such have terms we have the following result:the following result: Proposition 5.1.Proposition[23]Any 5.1.zx-calculus[23]Any termzx-calculus without anglesterm without or H vertices angles or isH equalvertices to a isterm equal in to a term in subset-spanningsubset-spanning form; further, form the subset-spanning; further, the subset-spanning form is quasi-unique form is andquasi-unique can be computed and can bybe computed by a terminatinga algorithm. terminating algorithm. Space does notSpace permit does a description not permit of a description the quasi-normal of the quasi-normal forms; the important forms; the point important here is point here is that the normalisationthat the procedurenormalisation is implemented procedure is in implemented a Quantomatic in a Quantomatic simproc called simprocrotate_simp called rotate_simp. . We will make extensiveWe will make use of extensive this in the use sequel. of this in the sequel.

Proposition 5.2. Encoding followed by decoding is the identity, i.e. Enc† Enc = id ,orin Proposition 5.2. Encoding followed by decoding is the identity, i.e. Enc† Enc = id ,orin 3 ¶ 3 ¶ pictures: pictures:

= =

This result can be proven by rotate_simp without human intervention; it requires 66 rewrite This result can be proven by rotate_simp without human intervention; it requires 66 rewrite steps and takes approximately 5 seconds of real time. See Appendix C.1.1. Note that Proposition steps and takes approximately 5 seconds of real time. See Appendix C.1.1. Note that Proposition 5.2 doesn’t establish that the 8 codewords of Table 1 are prepared as required; this is a corollary 5.2 doesn’t establishof the that tranversality the 8 codewords of the Pauli of Table group, 1 are which prepared we show as in required; the next this section. is a corollary of the tranversality of the Pauli group, which we show in the next section. The astute reader will have noticed that the encoder is not actually a quantum circuit: the The astutetop reader “rails” will end have in noticeda projection that onto the encoder the state is+ not. However, actually a no quantum post-selection circuit: is required: the we can top “rails” end in a projection onto the state + . However,| noÍ post-selection is required: we can implement Enc with a circuit using| Í five ancilla qubits. implement Enc with a circuit using five ancilla qubits. Proposition 5.3. Enc is a unitary embedding. Proposition 5.3. Enc is a unitary embedding. Proof. We do the proof in two stages, shown below. Proof. We do the proof in two stages, shown below.

= = = = 8 The Smallest Interesting Colour Code in Quantomatic encoder in reverse.

Enc := Dec := Enc† =

We note that the graph for Enc contains no H vertices and no angles. For such terms we have the following result: Proposition 5.1. [23]Anyzx-calculus term without angles or H vertices is equal to a term in subset-spanning form; further, the subset-spanning form is quasi-unique and can be computed by a terminating algorithm. Space does not permit a description of the quasi-normal forms; the important point here is that the normalisation procedure is implemented in a Quantomatic simproc called rotate_simp. We will make extensive useEncode-Decode of this in the sequel.

Proposition 5.2. Encoding followed by decoding is the identity, i.e. Enc† Enc = id ,orin ¶ 3 pictures: • Lemma :

=

This result can be proven by rotate_simp without human intervention; it requires 66 rewrite steps and takes approximately 5 seconds of real time. See Appendix C.1.1. Note that Proposition 5.2 doesn’t establish that the 8 codewords of Table 1 are prepared as required; this is a corollary of the tranversality of the Pauli group, which we show in the next section. The astute reader will have noticed that the encoder is not actually a quantum circuit: the top “rails” end in a projection onto the state + . However, no post-selection is required: we can | Í implement Enc with a circuit using five ancilla qubits. Proposition 5.3. Enc is a unitary embedding.

Proof. We do the proof in two stages, shown below.

= = STOP!

Quanto time! 7. Application: the one-way model Application 1: MBQC

1WQC is a quantum computer design based on single qubit projective measurements on a graph state.

• We can use the ZX-calculus to translate from the 1WQC to circuit model • Relies on the Hopf algebra normal form • Produces circuits with minimal space complexity Example 3.9 (Bell state). A Bell state, 00 + 11 , is prepared by the circuit | Í | Í below, on the left.

0 0 | Í | Í Q R H T H = ú ú ú æ æ æ c d c d c d c d a b The corresponding zx-calculus derivation is a proof of the correctness of this circuit. To simplify the next example, we introduce some shorthand for some useful circuit elements.

H 0 + | Í := | Í := Z H H

Graph States Example 3.10 (1D-cluster state). A 1-dimensional cluster state consists of a collection qubits 1,...,n initialised in the stateLet G+ = (V,E)= be 0a simple,+ 1undirected, which graph. are Then define: then | Í | Í | Í entangled by applying a Z operation to qubits i andGi = 1, andCZ to i and+i +1. · | i ≠ vu | i (v,u) E v V The corresponding circuit is shown below: O2 O2 Viewed as circuit we get this: ... + + + + ...... | Í | Í | Í | Í

Q R H H H T Z Z Z = c d ... H H ... c ... Z Z ... d c d c d a b The zx-calculus translation can be radically simplified by repeated use of the spider rule: ...... H H H ú H H H H H ... H H ... æ

The 1D-cluster is a special case of a more general class of states: graph states. These states are the basis of measurement-based quantum computation, and will play an important role later in the paper.

3.2 Circuit-like diagrams While the preceding has demonstrated the ease with quantum circuits can be translated into diagrams, there are many diagrams which do not correspond to

16 Example 3.9 (Bell state). A Bell state, 00 + 11 , is prepared by the circuit | Í | Í below, on the left.

0 0 | Í | Í Q R H T H = ú ú ú æ æ æ c d c d c d c d a b The corresponding zx-calculus derivation is a proof of the correctness of this circuit. To simplify the next example, we introduce some shorthand for some useful circuit elements.

H 0 + | Í := | Í := Z H H

Example 3.10 (1D-cluster state). A 1-dimensional cluster state consists of a collection qubits 1,...,n initialised in the state + = 0 + 1 , which are then | Í | Í | Í entangled by applying a Z operation to qubits i and i 1, and to i and i +1. · ≠ The corresponding circuit is shown below:

... + + + + ...... | Í | Í | Í | Í

Q R H H H T Z Z Z = Graph States c d ... H H ... c ... Z Z ... d c dLet G = (V,E) be a simple, undirected graph. Then define: c d a b G = CZ + | i vu | i The zx-calculus translation can be radically simplified(v,u by) E repeatedv V use of the spider rule: O2 O2 ...... H H H ú H H H H H ... H H ... æ

The 1D-cluster is a special case of a more general class of states: graph states. These states are the basis of measurement-based quantum computation, and will play an important role later in the paper.

3.2 Circuit-like diagrams While the preceding has demonstrated the ease with quantum circuits can be translated into diagrams, there are many diagrams which do not correspond to

16 ··· ···

x y x y x y k1 k1 k2 k2 k3 k3

fi fi fi

XXX XY Y YXY Y YX

fi fi fi

Graph States

Let G = (V,E) be a simple, undirectedfi graph. Then define: G = CZ + | i vu | i (v,u) E v V O2 O2 fi = ”

2 ··· ···

x y x y x y k1 k1 k2 k2 k3 k3

fi fi fi

XXX XY Y YXY Y YX

fi fi fi

Graph States fi Let G = (V,E) be a simple, undirected graph. Then define:

G = CZ + | i vufi | i (v,u) E = v V Or in 2D: O2 ” O2

2 Raussendorf and Briegel. PRL (86) 2001 Raussendorf, Browne, Briegel J. Mod. Opt. (46) 2003 The One-Way Model

A graph state, coupled to some input qubits:

The only operation is to measure single qubits in the basis: Raussendorf and Briegel. PRL (86) 2001 Raussendorf, Browne, Briegel J. Mod. Opt. (46) 2003 The One-Way Model

A graph state, coupled to some input qubits:

* Measured qubits are removed from the cluster; * The outcome of measurement alters the remaining state. Raussendorf and Briegel. PRL (86) 2001 Raussendorf, Browne, Briegel J. Mod. Opt. (46) 2003 The One-Way Model

A graph state, coupled to some input qubits:

* Measured qubits are removed from the cluster; * The outcome of measurement alters the remaining state. Raussendorf and Briegel. PRL (86) 2001 Raussendorf, Browne, Briegel J. Mod. Opt. (46) 2003 The One-Way Model

A graph state, coupled to some input qubits:

* Measured qubits are removed from the cluster; * The outcome of measurement alters the remaining state. Raussendorf and Briegel. PRL (86) 2001 Raussendorf, Browne, Briegel J. Mod. Opt. (46) 2003 The One-Way Model

A graph state, coupled to some input qubits:

* Measured qubits are removed from the cluster; * The outcome of measurement alters the remaining state. Raussendorf and Briegel. PRL (86) 2001 Raussendorf, Browne, Briegel J. Mod. Opt. (46) 2003 The One-Way Model

A graph state, coupled to some input qubits:

Z

* Measured qubits are removed from the cluster; * The outcome of measurement alters the remaining state.

Finally, any output qubits can be corrected by a local Pauli Raussendorf and Briegel. PRL (86) 2001 Raussendorf, Browne, Briegel J. Mod. Opt. (46) 2003 The One-Way Model

A graph state, coupled to some input qubits:

* Measured qubits are removed from the cluster; * The outcome of measurement alters the remaining state.

Finally, any output qubits can be corrected by a local Pauli Non-determinism

Non-determinism of measurements leads to probabilistic branching

Yay! Boo!Yay! Boo!

Yay! Boo! Yay! Boo!

Yay! Boo!Yay! Boo!

Attempt to control branching by using adaptive measurements: (choice of later measurements depends on the outcome of earlier ones) Non-determinism

Non-determinism of measurements leads to probabilistic branching

Yay! Boo! Can we carry outBoo! measurement-basedYay!

computationYay! Boo! deterministically?Yay! Boo!

Yay! Boo!Yay! Boo!

Attempt to control branching by using adaptive measurements: (choice of later measurements depends on the outcome of earlier ones) Example: 1-Qubit Unitary

Prepared + qubits | H H Z-gates H H

Projective measurements Example: 1-Qubit Unitary

H H

H H

Example: 1-Qubit Unitary

H H H H Example: 1-Qubit Unitary

H H H H Example: 1-Qubit Unitary

H H Example: 1-Qubit Unitary

H H Example: 1-Qubit Unitary

Example: 1-Qubit Unitary

= Z⇤ X⇥Z How to Measure

Suppose we have a measuring device for the standard 1-qubit basis:

0 1 | |

Yay! Boo! How to Measure

Suppose we have a measuring device for the standard 1-qubit basis:

0 1 | | X Yay! Yay! Should be this:

+ | |

Yay! Yay! Should be this:

+ | |

Yay! Yay! Example: Hadamard

Prepared + qubit | H Z-gate Projective measurement Example: Hadamard

H

Yay! Example: Hadamard

H

Yay! Example: Hadamard

H

Yay! Example: Hadamard

H

Example: Hadamard

H

Boo! Example: Hadamard

H

Boo! Example: Hadamard

H

Boo! Example: Hadamard

H

Boo! Example: Hadamard

H

Boo! Add correction here: Example: Hadamard

H

Boo! Add correction here: Example: Hadamard

H

Boo! Add correction here: numbers and an arrow g : m n is a diagram with m input and n outputs. The æ tensor product is juxtaposition, and composition g f is defined by identifying ¶ the output vertices of f with the input vertices of g. For more details see [4, 3]. Denote this category D(S); we denote the category D( ) of unconditional ÿ diagrams by D. Note that the components shown in Figure 1 are the generators of D(S). Definition 2.2. Let v : S 0, 1 be any boolean function; it naturally assigns æ { } a truth value v() to any formula over S.Wedefineavaluation functor vˆ : D(S) D by relabelling the Z and X vertices as follows: æ – if v()=1 –, ‘æ 0 otherwise ; Definition 2.3. Let : D fdHilb be a traced monoidal functor; define its · æn action on objects by n = C2 ; define its action on the generators as: J K ... m n J K– 0 ¢ 0 ¢ = | Í m ‘æ | i–Í n u ... } 1 ¢ e 1 ¢ ; | Í ‘æ | Í v ~ ... m n – + ¢ + ¢ = | Í m ‘æ | i–Í n u ... } ¢ e ¢ ; |≠Í ‘æ |≠Í v ~ Conditional1 ZX11 H = . u } Ô2 1 1 ... 3 ... ≠ 4 w  v ~–, –, H Definition 2.4. The denotation... of a diagram... D over variables S is a superop- erator constructed by summing over all the valuations of S: Figure 1: Permitted interior vertices While the simple repetition code described above can be adapted for the fl vˆ(D) fl vˆ(D) † . quantum case, at a‘æ cost of 9 qubits for each encoded qubit, we will consider a v 2S 7-qubit code due to Andrewœ Steane [8]. Like the repetition code, the Steane ÿ 2 code can only correct single qubitJ errorsK J. PracticallyK speaking the code consists Example 2.5of three(Unitary circuits: gates) an encoding. Any circuit, quantum a decoding circuit circuit (adjoint can be to the written encoder), in the zx-calculus. Thisand an is error most correcting easily circuit seen that via tests the translationthe code-space of for a errors universal and corrects gate set: them. In the rest of the paper, the three circuits mentioned above will be translated into the graphical formalismcos – of theizxsin-calculus– [1]. Using the formalism, as implementedX = in the automated2 rewriting≠ system2 Quantomatic= [2],– the circuits are – i sin – cos – simplified. We then,3≠ again by2 rewriting, derive2 4 the error syndromet conditions| for the correction circuit, and verify that it does indeed correct the claimed errors. (It is remarkable how simple and clear this graphical proof is, compared to the usual textbook approach.) Finally, we show that the combined circuit—encoder- corrector-decoder—rewrites10 to the identity on one qubit, proving it does not Z— = = — introduce any errors itself as0 a consequenceei— of its design. 3 4 2 The zx-calculus J K 1 11 TheH zx-calculus= is a formal language for reasoning about= quantumH computational systems. It comprises a graphicalÔ2 1 syntax1 and a set of axiomsu presented} as rewrite rules. It has a standard semantics3 ≠ in4 Hilbert spaces, and can represent any quantum circuit. We briefly review the zx-calculus here; forv full detalis~ consult [1]; here we make use of1000 the zx-calculus extended with conditional vertices, as elaborated in [5, 6]. 0100 = Q R . = Definition 2.1. Let S 0001be some set of variables. A diagramt over S is| an open c0010d graph whose interiorc vertices are restrictedd to the following types: Z-vertices, labelleda by an angle –b [0, 2fi) and a boolean formula with • œ variables from S; these are shown3 as (light) green circles, X vertices, labelled by an angle – [0, 2fi) and a boolean formula with • œ variables from S; these are shown as (dark) red circles,

H (or Hadamard) vertices, restricted to degree 2; shown as squares. • The allowed vertices are shown in Figure 1. If an X or Z vertex is labelled by – =0then the label is omitted. If the labelling formula is not constant then the vertex is called conditional; otherwise it is unconditional. We omit the formulae from unconditional vertices. For each S, the diagrams over S form a symmetric monoidal category (in fact compact closed) in the obvious way: the objects of the category are natural

2This is not exactly true. As we shall see later, the code can correct a single Z error and/or asingleX error, but they do not have to aect the same qubit.

2 Example

A measurement in the + , | | basis: Translation from MC to ZX- calculus

We can translate any measurement pattern to diagram using the table below: Example

CLAIM: this deterministically computes the CNOT of its input Example Rewrite

We removed all the conditional operations, therefore this pattern is deterministic.

Can we do this in general? Determinism in MBQC

Measurement Pattern “low-level program” Determinism in MBQC

Measurement Pattern “low-level program” implicitly defines Geometry “entangled resource” “graph state” Determinism in MBQC

Measurement Pattern “low-level program” implicitly defines Geometry “entangled resource” “graph state”

can possess Flow and GFlow “correction strategy” Determinism in MBQC

Measurement Pattern “low-level program” implicitly defines Geometry “entangled resource” “graph state” Uniformly jointly determine Deterministic can possess Pattern Flow and GFlow “correction strategy” Determinism in MBQC

Measurement not necessarily the same! Pattern “low-level program” implicitly defines Geometry “entangled resource” “graph state” Uniformly jointly determine Deterministic can possess Pattern Flow and GFlow “correction strategy” Determinism in MBQC

Measurement not necessarily the same! Pattern “low-level program” implicitly defines Geometry “entangled resource” “graph state” Uniformly jointly determine Deterministic can possess Pattern

Flow and GFlow translates to “correction strategy” Quantum Circuit Determinism in MBQC

Measurement not necessarily the same! Pattern “low-level program” implicitly defines Geometry “entangled resource” “graph state” Uniformly jointly determine Deterministic can possess Pattern

Flow and GFlow translates to “correction strategy” Quantum Circuit with ancilla qubits The plan:

Measurement Pattern “low-level program”

Geometry “entangled resource” “graph state”

Flow and GFlow “correction strategy” The plan:

Measurement Pattern “low-level program”

Geometry “entangled resource” “graph state”

Flow and GFlow “correction strategy” The plan:

Measurement translation Graphical form Pattern “direct translation” “low-level program”

rewrites to

Geometry included in Minimal Graphical Form “entangled resource” “annotated geometry” “graph state”

Flow and GFlow “correction strategy” The plan:

Measurement translation Graphical form Pattern “direct translation” “low-level program”

rewrites to

Geometry included in Minimal Graphical Form “entangled resource” “annotated geometry” “graph state”

“flow strategy” Flow and GFlow “correction strategy” Quantum Circuit if original pattern is deterministic The plan:

Measurement translation Graphical form Pattern “direct translation” “low-level program”

rewrites to

Geometry included in Minimal Graphical Form “entangled resource” “annotated geometry” “graph state” “gflow strategy” “flow strategy” Flow and GFlow “correction strategy” Quantum Circuit Circuit-like form has flow if original pattern is deterministic Hopf Algebra Equivalence

Thm: any Hopf algebra expression can be put into normal form: GFlow Strategy Flow Strategy Application 1: MBQC

Result: complicated MBQC implementation to simpler circuit specification.

WIP: the converse, optimally. Circuit Perspective

X–

Z– Z–

X–

1 Circuit Perspective

Inputs

X–

Z– Z–

X– Outputs

1 X“

Z– Z— Circuit Perspective X” Inputs “

– —

Outputs

1 X“

Z– Z— Circuit Perspective X”

– —

1 X“

Z– Z— Circuit Perspective X”

– —

1 X“

Z– Z—

X”

– — ???” Perspective ” “

– —

1 X“

Z– Z—

X”

– — ???” Perspective ” “

– —

1 X“

Z– Z—

X”

– — ???” Perspective ” “

Hopf algebra expression

– —

1 X“

Z– Z—

X”

– —

” “

??? Perspective– — ” “

Hopf algebra normal form

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

Physical qubits

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

Prepared qubits

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

Prepared qubits

Measured qubits

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

Prepared qubits Any ZX-calculus term can be interpreted as an MBQC in this way Measured qubits

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

Few qubit ion traps

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

Optical interconnect Few qubit ion traps

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

Architecture

The NQIT Hub’s hardware development effort is guided by detailed and continually updated plans for the system’s architecture. The Hub’s core proposition is that networking together quantum systems makes for a powerful and flexible Few qubit processing platform. Architectural theory and modelling must specify the performance requirements for Optical interconnect the nodal devices, and should determine how best they can perform core operations such as entanglement purification, where we upgrade the fidelity of a connective link by using ion traps it several times and filtering. Similarly it is essential to identify the requirements for the network’s connective fabric, such as tolerable photon loss rates, switching requirements, detector efficiency and dark count rates, as well as assessing the benefits of introducing advanced components such as photonic memories.

Architecture Progress Schematic showing how simple ion trap chips, Led by Professor Simon Benjamin devices with a few trapped atoms within, can be Because NQIT is focused on networked to form a computer / Simon Benjamin networks of small quantum devices a very fundamental architectural question is “just how small can these individual devices be?” In a theoretical study, We researchers have compared a fine-grained network involving devices with – — around five to ten qubits versus a coarse network whose nodes have hundreds of qubits. The study found that the processing capacity of the two systems was the same to within about a factor of two, for a fixed total number of qubits. The analysis required the creation of a novel approach to fault tolerance in modular systems: “the hierarchical surface code”. This encouraging result indicates that the nodes can be whatever size is most convenient for experimental reasons, without loss of performance or costly overheads. Another related question is, “how can we best use the limited resources within each node to perform purification to remove noise on the interlinks?” We researchers have answered this in case of a linear ion trap. We compiled down the protocol from the abstract language of quantum gates into device-level operations including shutting and cooling events. An unexpected and encouraging observation was that within each trap ‘zone’ it is never necessary to target a given ion while avoiding another of the same species. A consequence is that laser control systems do not need to have a narrow ‘waist’ and instead ‘fat’ beams that target entire zones may suffice. This should result in considerable reductions in the complexity and cost of the individual units. Schematic showing advanced ion trap chips, each a 2D grid of pathways along which atoms travel, networked together to form a computer / Simon Benjamin

Purification a method to upgrade the quality of a quantum link by using it several times, each time creating a ‘noisy’ entangled pair of qubits, and then combining these qubits to create a smaller number of more perfectly entangled pairs.

27

1 I did not talk about:

• Mixed states, CP-maps, probabilities

• Causality

• Contextuality, Non-locality

• Infinite dimensional spaces I did not talk about:

doi : 10.1016/j.entcs.2006.12.018 • Mixed states, CP-maps, probabilities

• Causality arXiv:1107.6019

• Contextuality, Non-locality arXiv:1203.4988

• Infinite dimensional spaces arXiv:1011.6123 arXiv:1605.04305 I did not talk about:

• Algorithms: Deutsch-Josza, Grover, Hidden Subgroup (Vicary, Zeng, Gogioso, Kissinger)

(Hillebrand, Kissinger, Tull, Westerbaan)

• Error Correction (RD, Horsman et al)

• Secret sharing (Gogioso, Perdrix)

• Topological Quantum Computing (Horsman, de Beaudrap) What next?

• “ZX-like” theories exist for any quantum system (including codeword spaces!)

• ZX-calculus has no commitment to architecture or causal structure

• ZX-calculus encodes quantum theory “below the gate level” Extensional / Denotational

x.y.z.xz(yz) Extensional / Denotational

x.y.z.xz(yz)

Intensional / Operational Extensional / Denotational

x.y.z.xz(yz)

Compilation

Intensional / Operational AZX QuantERA Call 2017

1 EXCELLENCE 1.1 Targeted breakthrough, baseline of knowledge and skills Summary: Our goal is to developThe a flexible intermediateNext representationStep for quantum software which enables formally verified program transformations, and based on this, to construct the back-end for a re-targetable optimising compiler for a variety of realistic quantum computer architectures.

Languages Models Implementations Plain Circuits Quipper Ion Traps EC Circuits Python ProjectQ/PyQuil Optics AZX Surface code LIQUi|> Superconducting MBQC circuits • • • Ancilla-mediated Hybrid systems

Software Engineering & Quantum Computation Systems Architecture Formal Methods

Context: High-level programming languages (HLLs) increase programmer productivity and software reliability, provided that the HLL compiler can generate machine code which runs well on the intended hardware platform. Quantum algorithm designers have the choice of several powerful quantum programming languages [15, 24, 27, 29]. However, proposed implementations of quantum computers vary greatly due to diering underlying technologies (ion traps, superconducting circuits, optics) and architectural concepts (networked vs. hybrid, measurement based, ancilla driven) [23, 26, 25], and no language takes account of the specific characteristics of any given platform. Worse, the technology is evolving quickly, none of these characteristics are stable, and no consensus has yet emerged on the best choice. For classical programs, modern compiler toolchains such as LLVM1 decouple the HLL from the machine by using an intermediate representation (IR), which is independent of both. By translating to and from the IR, any HLL may be used on any platform. A quantum IR accommodating dissimilar architectures is needed to support software on rapidly shifting hardware. Targeted breakthrough: We will define a universal intermediate representation language, called azx, which is platform-agnostic but which facilitates program transformations appropriate to specific hardware. Specifically, azx will provide the following (see §3 for more detail):

⌅ An easy-to-generate universal language.

⌅ Automated IR transformations for error correction, resource optimisation, and execution layout.

⌅ A complete compilation pipeline from HLL to hardware for (i) superconducting transmon qubits (QuTech) [28] and (ii) optically-coupled ion traps (NQIT) [23]. The theory, algorithms, and software architecture behind this will be flexible and extensible, thus permitting programming languages and architectures not explicitly included in the project scope to be supported. This will greatly improve the software ecosystem for quantum computers: by supporting azx, future quantum devices may easily run existing programs, and future programming languages automatically gain support on a wide range of hardware. Baseline of knowledge and skills: The closest extant thing to a quantum IR is QASM [7], a circuit description language. QASM is an output option for ProjectQ [16], and the input language for IBM’s Quantum Experience2; the ProjectQ team describe a compilation process for quantum software involving possibly multiple IRs, but do not describe a specific one. State-of-the-art quantum programming languages such as Quipper [15]andLIQUi [29] support multiple targets; in practice |Í the choice is between a circuit description or a classical simulation. Neither language exposes an IR.

1The LLVM Compiler Infrastructure, http://llvm.org 2This is a publicly accessible 5-qubit device; http://research.ibm.com/quantum/.

Page 4 of 32 THANKS • Simon Perdrix • Vladimir Zamdzhiev • Kevin Dunne

• Miriam Backens • Will Zeng • Fabrizio Genovese

• Aleks Kissinger • David Quick • Bill Edwards

• Dusko Pavlovic • Tobias Fritz • Dominic Horsman

• Eric Paquette • Alex Merry • Niel de Beaudrap

• Stefano Gogioso • Andre Ranchin • Harny Wang

• Renaud Vilmart • Chris Heunen • Kang Feng Ng

• Emmanuel Jeandel • Jamie Vicary • Liam Garvie

• Samson Abramsky • Lucas Dixon • Maxime Lucas

• Amar Hadzihasonvic • Nick Chancellor • Andrew Fagan

• Pawel Sobocinski • Alex Lang • Anne Hillebrand

• Fabio Zanasi • Julia Evans • Bob Coecke with apologies to those I forgot THANKS • Simon Perdrix • Vladimir Zamdzhiev • Kevin Dunne

• Miriam Backens • Will Zeng • Fabrizio Genovese

• Aleks Kissinger • David Quick • Bill Edwards

• Dusko Pavlovic • Tobias Fritz • Dominic Horsman

• Eric Paquette • Alex Merry • Niel de Beaudrap

• Stefano Gogioso • Andre Ranchin • Harny Wang 10• Renaud Vilmart MORE • Chris Heunen YEARS!• Kang Feng Ng • Emmanuel Jeandel • Jamie Vicary • Liam Garvie

• Samson Abramsky • Lucas Dixon • Maxime Lucas

• Amar Hadzihasonvic • Nick Chancellor • Andrew Fagan

• Pawel Sobocinski • Alex Lang • Anne Hillebrand

• Fabio Zanasi • Julia Evans • Bob Coecke with apologies to those I forgot