<<

Quantum computation 21 104 CHAPTER III. QUANTUM COMPUTATION

= = NOT = = AND > > (a) (b)

= = = OR > = XOR > > > (c) (d)

= (e) = NAND > = >

= (f) = NOR > = >

Figure 1.6. On the left are some standard single and multiple bit gates, while on the right is the prototypical Figuremultiple III.9: gate, Left: the controlled- classical gates..Thematrixrepresentationofthecontrolled- Right: controlled-Not gate., UCN [from,iswrittenwith Nielsen respect to the amplitudes for 00 , 01 , 10 ,and 11 ,inthatorder. & Chuang (2010, Fig.| 1.6)] | | |

qubit. The action of the gate may be described as follows. If the control qubit is set to C.20, then Quantum the target qubit gatesis left alone. If the control qubit is set to 1, then the target qubit is flipped. In equations: Quantum gates are analogous to ordinary logic gates (the fundamental build- ing blocks of circuits),00 00 but; 01 they must01 ; 10 be unitary11 ; 11 transformations10 . (see(1.18) Fig. III.9, left, for ordinarty| i!| i logic| i! gates).| i | Fortunately,i!| i | i! Bennett,| i Fredkin, and ToAnother↵oli have way already of describing shown the howis all as the a generalization usual logic of the operations classical cangate, be since done reversibly.the action Inof the this gate section may be you summarized will learn as A, the B mostA, important B A ,where quantumis addition gates. modulo two, which is exactly what the gate| does.i! That| is, thei control qubit and the C.2.atarget qubitSingle-qubit are ed and gates stored in the target qubit. Yet another way of describing the action of the is to give a matrix represen- Thetation, NOT as showngate is in simple the bottom because right of it Figure is reversible: 1.6. You canNOT easily0 verify= 1 , that NOT the1 first= | i | i | i 0 column.Itsdesiredbehaviorcanberepresented: of UCN describes the transformation that occurs to 00 ,andsimilarlyforthe | iother computational basis states, 01 , 10 ,and 11 . As for| thei single qubit case, the | i | i | i requirement that probability beNOT conserved : is0 expressed1 in the fact that U is a unitary | i 7! | i CN matrix,thatis,UCN† UCN = I. 1 0 . We noticed that the can be regarded| i 7! as a type| i of generalized- gate. Can Noteother that classical defining gates such it on as a the basis definesor the regular it on all quantumgate be understood states. Thereforeas unitary it cangates be in awritten sense similar as a sumto the of way dyads the quantum (outer products):gate represents the classical gate? It turns out that this is not possible. The reason is because the and gates are essentially irreversible or non-invertibleNOT = 1 .Forexample,giventheoutput0 + 0 1 . A B from | ih | | ih | an gate, it is not possible to determine what the inputs A and B were; there is an You can read this, “return 1 if the input is 0 ,andreturn 0 if the input irretrievable loss of information associated with the irreversible action of the gate. is 1 .” Recall that in the| standardi basis 0| i=(10)T and| i1 =(01)T. On| i the other hand, unitary quantum gates are always| i invertible, since the| i inverse of a unitary matrix is also a unitary matrix, and thus a quantum gate can always be inverted by another quantum gate. Understanding how to do classical logic in this reversible or invertible sense will be a crucial step in understanding how to harness the power of C. QUANTUM INFORMATION 105

Therefore NOT can be represented in the standard basis by computing the outer products:

0 1 00 01 01 NOT = (1 0) + (0 1) = + = . 1 0 10 00 10 ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ The first column represents the result for 0 ,whichis 1 ,andthesecond represents the result for 1 ,whichis 0 . | i | i Although NOT is defined| i in terms| ofi the computational basis vectors, it applies to any qubit, in particular to superpositions of 0 and 1 : | i | i NOT(a 0 + b 1 )=aNOT 0 + bNOT 1 = a 1 + b 0 = b 0 + a 1 . | i | i | i | i | i | i | i | i Therefore, NOT exchanges the amplitudes of 0 and 1 . In , the NOT transformation| i is| i usually called X.It is one of four useful unitary operations, called the Pauli matrices,whichare worth remembering. In the standard basis:

def def 10 I = = (III.10) 0 01 ✓ ◆ def def def 01 X = = = (III.11) x 1 10 ✓ ◆ def def def 0 i Y = = = (III.12) y 2 i 0 ✓ ◆ def def def 10 Z = = = (III.13) z 3 0 1 ✓ ◆ We have seen that X is NOT, and I is obviously the identity gate. Z leaves 0 unchanged and maps 1 to 1 . It is called the phase-flip operator because| i it flips the phase of the| i 1 component| i by ⇡ relative to the 0 component. (Recall that global/absolute| i phase doesn’t matter.) The Pauli| matricesi span the space of 2 2 complex matrices (Exer. III.18). Note that Z⇥+ = and Z = + .Itisthustheanaloginthesign basis of X (NOT)| i in the|i computational|i | basis.i What is the e↵ect of Y on the computational basis vectors? (Exer. III.12) Note that there is an alternative definition of Y that di↵ers only in global phase: def 01 Y = . 10 ✓ ◆ 106 CHAPTER III. QUANTUM COMPUTATION

This is a 90 = ⇡/2counterclockwiserotation:Y (a 0 + b 1 )=b 0 a 1 . Draw a diagram to make sure you see this. | i | i | i | i Note that the Pauli operations apply to any state, not just basis states. The X, Y ,andZ operators get their names from the fact that they reflect state vectors along the x, y, z axes of the Bloch-sphere representation of a qubit, which we will not use in this book. Since they are reflections, they are Hermitian (their own inverses).

C.2.b Multiple-qubit gates We know that any logic circuit can be built up from NAND gates. Can we do the same for quantum logic, that is, is there a universal quantum ? We can’t use NAND, because it’s not reversible, but we will see that there are universal sets of quantum gates. The controlled-NOT or CNOT gate has two inputs: the first determines what it does to the second (negate it or not).

CNOT : 00 00 | i 7! | i 01 01 | i 7! | i 10 11 | i 7! | i 11 10 . | i 7! | i Its first argument is called the control and its second is called the target, controlled,ordata qubit. It is a simple example of conditional quantum computation. CNOT can be translated into a sum-of-dyads representation (Sec. A.2.d), which can be written in matrix form (Ex. III.21, p. 194):

CNOT = 00 00 | ih | + 01 01 | ih | + 11 10 | ih | + 10 11 | ih |

We can also define it (for x, y 2), CNOT xy = xz ,wherez = x y, the exclusive OR of x and y. That2 is, CNOT| ix, y | = i x, x y CNOT is the only non-trivial 2-qubit reversible logic gate.| Notei that| CNOT i is unitary since obviously CNOT = CNOT† (which you can show using its dyadic representation or its matrix representation, Ex. III.21, p. 194). See the right Introduction to 15 · gates are unitary. For example

0 1 01 YY = = I. ⇤ 10 10 ✓ ◆✓ ◆

The controlled-NOT gate, Cnot,operatesontwoqubitsasfollows:itchangesthesecond bit if the first bit is 1 and leaves this bit unchanged otherwise. The vectors 00 , 01 , 10 ,and 11 form an orthonormal basis for the state space of a two-qubit system,| i | a 4i- |dimensionali | complexi vector space. In order to represent transformations of this space in matrix notation we need to choose an isomorphism between thisspaceandthespaceof complex four tuples. There is no reason, other than convention, to pick one isomorphism over another. The one we use here associates 00 , 01 , 10 ,and 11 to the standard 4- T T | T i | i | i T | i tuple basis (1, 0, 0, 0) , (0, 1, 0, 0) , (0, 0, 1, 0) and (0, 0, 0, 1) ,inthatorder.TheCnot transformation has representations

Cnot : 00 00 1000 |01i!|01i 0100 . |10i!|11i 0 00011 | i!| i 11 10 B 0010C | i!| i B C @ A The transformation Cnot is unitary since Cnot⇤ = Cnot and CnotCnot = I.TheCnot gate cannot be decomposed into a tensor product of two single-bit transformations. It is useful to have graphical representations of quantum state transformations, especially when several transformations are combined. The controlled-NOT gate Cnot is typically represented by a circuit of the form

. ⇥ The open circle indicates the control bit, and the indicates the conditional negation of the subject bit. In general there can be multiple control⇥ bits. Some authors use a solid circle to indicate negative control, in which the subject bit is toggled when the control bit is 0. Similarly, the controlled-controlled-NOT,whichnegatesthelastbitofthreeifandonly if the first two are both 1,hasthefollowinggraphicalrepresentation. C. QUANTUM INFORMATION 107

⇥ Figure III.10: Diagram for CCNOT or To↵oli gate [fig. from Nielsen & Single bit operationsChuang are (2010)]. graphically Sometimes the representedis replaced by because by appro CCNOTpriatelyxyz = labelled boxes as x, y, xy z . ⇥ | i shown. | i

panel of Fig. III.9 (p. 104) for the matrix and note the diagram notation for CNOT. Y CNOT can be used to produce an entangled state:

1 1 1 CNOT ( 0 + 1 ) 0 = CNOT ( 00 + 10 )= ( 00 + 11 )= 00 . p2 | i | i | i Zp2 | i | i p2 | i | i | i  Note also that CNOT x, 0 = x, x , that is, FAN-OUT, which would seem to violate the No-cloning| Theorem,i | i but it works as expected only for x 2. In general CNOT 0 = (Exer. III.22). 2 | i| i6 | i| i Another useful gate is the three-input/output To↵oli gate or controlled- controlled-NOT. It negates the third qubit if and only if the first two are both 1. For x, y, z 2, 2 CCNOT 1, 1,z def= 1, 1, z , | i | ¬ i CCNOT x, y, z def= x, y, z ,otherwise. | i | i That is, CCNOT x, y, z = x, y, xy z . All the Boolean operations can be implemented (reversibly!)| i by| using To ↵ioli gates (Exer. III.25). For example, CCNOT x, y, 0 = x, y, x y . Thus it is a universal gate for quantum logic. | i | ^ i In Jan. 2009 CCNOT was implemented successfully using trapped ions.5

5Monz, T.; Kim, K.; H¨ansel, W.; Riebe, M.; Villar, A. S.; Schindler, P.; Chwalla, M.; Hennrich, M. et al. (Jan 2009). “Realization of the Quantum To↵oli Gate with Trapped Ions.” Phys. Rev. Lett. 102 (4): 040501. arXiv:0804.0082. 108 CHAPTER III. QUANTUM COMPUTATION

C.2.c Walsh-Hadamard transformation Recall that the sign basis is defined + def= 1 ( 0 + 1 )and def= 1 ( 0 | i p2 | i | i |i p2 | i 1 ). The Hadamard transformation or gate is defined: | i H 0 def= + , (III.14) | i | i H 1 def= . (III.15) | i |i In sum-of-dyads form: H def= + 0 + 1 .Inmatrixform(withrespectto the standard basis): | ih | |ih | def 1 11 H = . (III.16) p2 1 1 ✓ ◆ 2 Note that H is self-adjoint, H = I (since H† = H). H can be defined also in terms of the Pauli matrices: H =(X + Z)/p2(Exer.III.33). The H transform can be used to transform the computational basis into the sign basis and back (Exer. III.32): H(a 0 + b 1 )=a + + b , | i | i | i |i H(a + + b )=a 0 + b 1 . | i |i | i | i Alice and Bob could use this in quantum key distribution. When applied to a 0 , H generates an (equal-amplitude) superposition of the two bit-values, H 0| i= 1 0 + 1 1 .Thisisausefulwayofgeneratinga p2 p2 superposition of both| possiblei | inputi bits,| i and the Walsh transform, a tensor power of H, can be applied to a quantum register to generate a superposition of all possible register values. Consider the n =2case: 2 H⌦ , =(H H)( ) | i ⌦ | i⌦| i =(H ) (H ) | i ⌦ | i In particular, 2 H⌦ 00 =(H 0 ) (H 0 ) | i | 2i ⌦ | i = + ⌦ | i 2 1 ⌦ = ( 0 + 1 ) p2 | i | i  1 2 = ( 0 + 1 )( 0 + 1 ) p2 | i | i | i | i ✓ ◆ 1 = ( 00 + 01 + 10 + 11 ). p22 | i | i | i | i C. QUANTUM INFORMATION 109

Notice that this is an equal superposition of all possible values of the 2-qubit register. (I wrote the amplitude in a complicated way, 1/p22,tohelpyou see the general case.) In general,

n n 1 n H⌦ 0 ⌦ = ( 0 + 1 )⌦ | i p2n | i | i n 1 = ( 0 + 1 ) ( 0 + 1 ) ( 0 + 1 ) p2n | i | i ⌦ | i | i ⌦···⌦ | i | i 1 z }| { = ( 00 ...00 + 00 ...01 + + 11 ...11 ) p2m | i | i ··· | i 1 = x p n | i 2 x 2n 2 2Xn 1 1 = x . p n | i 2 x=0 X Note that “2n 1” represents a string of n 1-bits, and that 2 = 0, 1 . Hence, n n n { } H⌦ 0 ⌦ generates an equal superposition of all the 2 possible values of the | i n n-qubit register. We often write Wn = H⌦ for the Walsh transformation. An linear operation applied to such a superposition state in e↵ect applies the operation simultaneously to all 2n possible input values. This is expo- nential quantum parallelism and suggests that quantum computation might be able to solve exponential problems much more eciently than classical computers. To see this, suppose U x = f(x) .Then: | i | i 2n 1 2n 1 2n 1 n n 1 1 1 U(H⌦ 0 ⌦ )=U x = U x = f(x) | i p n | i p n | i p n | i " 2 x=0 # 2 x=0 2 x=0 X X X This is a superposition of the function values f(x)forallofthe2n possible values of x;itiscomputedbyonepassthroughtheoperatorU. Quantum computation 23

in the circuit represents a wire in the . This wire does not necessarily correspond to a physical wire; it may correspondinsteadtothepassageoftime,orperhaps to a physical particle such as a photon – a particle of light – moving from one location to another through space. It is conventional to assume that the state input to the circuit is a computational basis state, usually the state consisting of all 0 s. This rule is broken frequently in the literature on quantum computation and quantum| i information, but it is considered polite to inform the reader when this is the case. The circuit in Figure 1.7 accomplishes a simple but useful task – it swaps the states of the two qubits. To see that this circuit accomplishes the swap operation, note that the sequence of gates has the following sequence of effects on a computational basis state a, b , | i a, b a, a b | i!| i a (a b),a b = b, a b ! | i | i b, (a b) b = b, a , (1.20) ! | i | i where all additions are done modulo 2. The effect of the circuit, therefore, is to inter- 110change the state of the two qubits.CHAPTER III. QUANTUM COMPUTATION

Figure 1.7. Circuit swapping two qubits, and an equivalent schematic symbol notation for this common and useful circuit.Figure III.11: Diagram for swap [from Nielsen & Chuang (2010)].

There are a few features allowed in classical circuits that are not usually present in quantum circuits. First of all, we don’t allow ‘loops’, that is, feedback from one part of the C.3quantum Quantum circuit to another; circuits we say the circuit is acyclic.Second,classicalcircuitsallow wires to be ‘joined’ together, an operation known as ,withtheresultingsinglewire Acontainingquantum the circuit bitwiseis aof sequential the inputs. series Obviously of quantumthis operation transformations is not reversible and on a quantumtherefore notregister. unitary, The so we inputs don’t allow are usuallyin our computational quantum circuits. basis Third, states the inverse (all 0 | i unlessoperation, stated otherwise).,wherebyseveralcopiesofabitareproducedisalsonotallowedinQuantum circuit diagrams are drawn with time go- ingquantum from left circuits. to right, In fact, with it turns the out quantum that quantum gates mechanics crossing forbids one or the more copying “wires” of a (qubits)qubit, making as appropriate. the operation The circuit impossible! represents We’ll see a sequence an example of of thisunitary in the opera- next tionssection on when a quantum we attempt register to design rather a circuit than to copy physical a qubit. wires. As we proceed we’ll introduce new quantum gates as needed. It’s convenient to in- troduceThese another “circuits” convention are di about↵erent quantum in several circuits respects at this from point. ordinary This convention sequential is logicillustrated circuits. in Figure First, 1.8. loops Suppose (feedback)U is any unitary are not matrix allowed, acting on but some you number cann applyof transformsqubits, so U repeatedly.can be regarded Second, as a quantumFan-In gate(equivalent on those qubits. to ThenOR) weis not can define allowed, a sincecontrolled it it- notU gate reversible which is a or natural unitary.extensionFan-Out of the controlled-is also not allowed,gate. Such because a gate ithas would a single violatecontrol the qubit No-cloning,indicatedbythelinewiththeblackdot,and Theorem. (N.B.: This doesn nottarget contradict qubits, theindicated universality by the boxed of theU To.Ifthecontrolqubitissetto0thennothinghappenstothe↵oli or Fredkin gates, which are universal only with respecttarget qubits. to logical If the orcontrol classical qubit is states.) set to 1 then the gate U is applied to the target qubits. The prototypical example of the controlled- gate is the controlled- gate, which is Fig. III.9 (right) on page 104 showsU the symbol for CNOT and its e↵ect. acontrolled-U gate with U = X,asillustratedinFigure1.9. Another important operation is measurement, which we represent by a ‘meter’ symbol, The swap operation is defined xy yx ,orexplicitly | i 7! | i SWAP = yx xy . | ih | x,y 2 X2 We can put three CNOTs in series to swap two qubits (Exer. III.35). Swap has a special symbol as shown in Fig. III.11. In general, any unitary operator U (on any number of qubits) can be conditionally controlled (see Fig. III.12); this is the quantum analogue of an if-then statement. If the control bit is 0, this operation does nothing, otherwise it does U. This is implemented by 0 0 I + 1 1 U.E↵ectively, the operators are entangled. | ih |⌦ | ih |⌦ Suppose the control bit is in superposition, = a 0 + b 1 .Thee↵ect | i | i | i C.24 QUANTUMIntroduction INFORMATION and overview 111

Figure 1.8. Controlled-U gate.

Figure III.12: Diagram for controlled-U [from Nielsen & Chuang (2010)]. of the conditional operation is: Figure 1.9. Two different representations for the controlled- . ( 0 0 I + 1 1 U) , | ih |⌦ | ih |⌦ | i =(0 0 I + 1 1 U)(a 0 + b 1 ) as shown in Figure| ih 1.10.|⌦ As previously| ih |⌦ described,| i this| operationi ⌦| i converts a single qubit state = =0 +001(ainto0 a+ probabilisticb 1 ) I classical+ 1 bit1 M(a (distinguished0 + b 1 ) fromU a qubit by | i | i | i drawing it as a double-line| ih | | i wire),| whichi ⌦ is| 0i with| probabilityih | | i 2|,or1withprobabilityi ⌦ | i = a 0 + b 1 U | | 2. | i⌦| i | i⌦ | i | | = a 0, + b 1,U . | i | i ✤❴ ❴ ❴ ❴ ❴ ❴L ❴ ❴ ✤ ✤ ✙✙ ✤ The result is a superposition of entangled✤ ✙ outputs.✤ Notice that CNOT is a ✤ ✙✙ ✤ special case of this construction, a controlled❴✤ ❴ ❴ ❴ ❴✙ ❴ ❴ ❴ ✤ X. Figure 1.10. Quantum circuit symbol for measurement. We also have a quantum analogue for an if-then-else construction. If U0 and WeU1 shallare findunitary quantum operators, circuits useful then as we models can makeof all quantum the choice processes, between including them conditionalbut not limited on to a computation, control bit communication, as follows: and even quantum noise. Several simple examples illustrate this below. 0 0 U + 1 1 U . | ih |⌦ 0 | ih |⌦ 1 1.3.5 Qubit copying circuit? ForThe example,gate is useful for demonstrating one particularly fundamental property of quantum information. ConsiderCNOT the = task0 0 of copyingI + 1 a1 classicalX. bit. This may be(III.17) done using a classical gate, which takes| ih in|⌦ the bit| toih copy|⌦ (in some unknown state x) andIn a quantum ‘scratchpad’ circuit bit initialized diagrams, to zero, the as symbol illustrated for in theFigure CCNOT 1.11. The gate output is show is two in Fig. III.10, or with for top two connections and for bottom, suggesting bits, both of which are• in the same state x. CCNOTSupposex, y,we z try= tox, copy y, xy a qubitz in. Alternately, the unknown state put “CCNot= a 0 +”inabox.Otherb 1 in the same | i | i operationsmanner by mayusing be a showngate. by The putting input state a letter of the or two symbol| qubitsi in may| i a bebox,| writteni for example as “H” for the Hadamard gate. a 0 + b 1 0 = a 00 + b 10 , (1.21) The Hadamard gate can| i be| usedi | i to generate| i | Belli states (Exer. III.34): h i The function of is to negate the second qubit when the first qubit is 1, and thus the output is simply a 00 CNOT(+ b 11 .HavewesuccessfullycopiedH I) xy = xy . ?Thatis,havewe(III.18) | i | i ⌦ | i | i | i created the state ?Inthecasewhere = 0 or = 1 that is indeed what this circuit does; it is| possiblei| i to use quantum circuits| i | toi copy| i classical| i information encoded as a 0 or a 1 .However,forageneralstate we see that | i | i | i = a2 00 + ab 01 + ab 10 + b2 11 . (1.22) | i| i | i | i | i | i 24 Introduction and overview

26 Introduction and overview understood via the equations 0,y +( 1)x 1, y¯ xy | i | i , (1.27) | i p2 where112y¯ is the negation of y. CHAPTER III. QUANTUM COMPUTATION Figure 1.8. Controlled-U gate.

In Out

00 ( 00 + 11 )/p2 00 | i | i | i | i 01 ( 01 + 10 )/p2 01 | i | i | i | i 10 ( 00 11 )/p2 10 | i Figure| i 1.9.| Twoi different | representationsi for the controlled- . 11 ( 01 10 )/p2 11 | i | i| i | i

as shownFigure 1.12. in Figure Quantum 1.10. circuit As to create previously Bell states, described, and its input–ouput this operation quantum converts‘truth table’. a single qubit Figurestate III.13:= 0 Quantum+ 1 into a circuit probabilistic for generating classical bit M Bell(distinguished states. [from from a Nielsen qubit by & | i | i | i drawing it as a double-line wire), which is 0 with probability 2,or1withprobability Chuang (2010, fig. 1.12)] | | 2. | | 1.3.7 Example: We will now apply the techniques of the last few pages to understand something non- ✤❴ ❴ ❴ ❴ ❴ ❴L ❴ ❴ ✤ trivial, surprising, and a lot of fun – quantum teleportation!✤ ✙✙ ✤ Quantum teleportation is a ✤ ✙ ✤ ✤ ✙✙ ✤ technique for moving quantum states around, even❴✤ ❴ ❴ in❴ ❴✙ ❴ the❴ ❴ ✤ absence of a quantum commu- nications channel linking theFigure sender 1.10. of Quantum the quantum circuit symbol state for to measurement. the recipient. Here’sFigure how III.14: quantum Symbol teleportation for measurement works. Alice andof a Bob quantum met long state ago but (from now Nielsen live & farChuang apart.We While shall (2010)). together find quantum they generated circuits useful an EPR asmodels pair, each of takingall quantum one qubit processes, of the includingEPR pair whenbut not they limited separated. to computation, Many years communication, later, Bob is in and hiding, even and quantum Alice’s noise. mission, Several should simple she chooseexamples to accept illustrate it, thisis to below. deliver a qubit to Bob. She does not know the state of | i the qubit, and moreover can only send classical information to Bob. Should Alice accept theThe mission? circuit for generating1.3.5 Bell Qubit states copying (Eq. III.18) circuit? is shown in Fig. III.13. Intuitively,It’s also things convenient look pretty to bad have for Alice. a symbol She doesn’t for quantum know the state state measurement,of the The gate is useful for demonstrating one particularly fundamental| i property of qubitsuchquantum she as has Fig. information.to send III.14. to Bob, Consider and the the laws task of of quantum copying a mechanics classical bit. prevent This her may from be done determining the state when she only has a single copy of in her possession. What’s using a classical gate, which takes in the bit to| copyi (in some unknown state x) worse, even if she did know the state ,describingitpreciselytakesaninfiniteamount and a ‘scratchpad’ bit initialized| toi zero, as illustrated in Figure 1.11. The output is two of classicalC.4 information Quantum since gate takes arrays values in a continuous space. So even if she did bits, both of which are in| thei same state x. know ,itwouldtakeforeverforAlicetodescribethestatetoBob.It’snotlooking Fig.| Supposei III.15 we shows try to a copy quantum a qubit in circuit the unknown for a state 1-bit full= a adder.0 + b 1 in As the we same will goodmanner for Alice. by using Fortunately a forgate. Alice, The quantum input state teleportation of the two| qubitsisi a way may| i of be utilizing| writteni the as entangledsee (Sec. EPR C.7), pair in it order is possible to send toto construct Bob, with onlyreversible a small quantumoverhead of gates classical for any | i communication.classically computable function.a 0 + b 1 In0 particular= a 00 + b the10 , Fredkin and To↵oli(1.21) gates | i | i | i | i | i Inare outline, universal. the steps of the solutionh are asi follows: Alice interacts the qubit with her halfTheBecause of function the EPR quantum of pair, andis then tocomputation negate measures the second the is two a qubit qubits unitary when in her theoperator, possession, first qubit it obtaining is| must 1,i and be thus re- the output is simply a 00 + b 11 .Havewesuccessfullycopied ?Thatis,havewe oneversible. of four possible You know classical| that results,i an| 00, irreversiblei 01, 10, and computation 11. She sends thisx| i informationf(x)canbeem- to created the state ?Inthecasewhere = 0 or = 1 that is indeed what this Bob.bedded Depending in a on reversible Alice’s classical computation message, Bob (x, performs c) ( oneg(x of),f four(x)), operations7! where onc hisare suit- circuit does; it is| possiblei| i to use quantum circuits| i | toi copy| i classical| i information encoded halfable of the ancillary EPR pair. constants Amazingly, and by doingg(x) this represents he can recover7! the the garbage original qubits. state ! Note that Theas aquantum0 or a circuit1 .However,forageneralstate shown in Figure 1.13 gives a morewe precise see that description of quantum| i throwing| i away| i the garbage qubits (dumping| i them into the environment) will teleportation. The state to be teleported2 is = 0 + 1 ,where2 and are unknown collapse the quantum state = a (equivalent00 |+iab 01| toi+ ab measurement)| 10i + b 11 . by entangling(1.22) them amplitudes. The state input| i into| i the circuit| i 0| isi | i | i in the many degrees of freedom of| thei environment. Typically these garbage 0 = 00 (1.28) qubits will be| entangledi | i| i with other qubits in the computation, collapsing them as well, and interfering with the computation. Therefore the garbage 20 E. Rieffel and W. Polak · classical computation on a quantum computer. Furthermore, it describes sets of gates with which all quantum computations can be done. The second subsection discusses quantum parallelism.

5.1 Quantum Gate Arrays The bra/ket notation is useful in defining complex unitary operations. For two arbitrary unitary transformations U and U ,the“conditional”transformation 0 0 U + 1 1 1 2 | ih |⌦ 1 | ih |⌦ U2 is also unitary. The controlled-NOT gate can defined by C = 0 0 I + 1 1 X. not | ih | ⌦ | ih | ⌦ The three-bit controlled-controlled-NOT gate or of section 4 is also an in- stance of this conditional definition: T = 0 0 I I + 1 1 C . | ih | ⌦ ⌦ | ih | ⌦ not The Toffoli gate T can be used to construct complete set of boolean connectives,ascan be seen from the fact that it can be used to construct the AND and NOT operators in the following way: T 1, 1,x = 1, 1, x | i | ¬ i C. QUANTUM INFORMATIONT x, y, 0 = x, y, x y 113 | i | ^ i

The T gate is sufficient to construct arbitrary combinatorial circuits. The following quantum circuit, for example, implements a 1 bit full adder using Toffoli and controlled-NOT gates:

c c | i | i x x | i | i y y | i | i 0 s | i ⇥ ⇥ ⇥ | i

0 c | i ⇥ ⇥ ⇥ | i

Figurewhere III.15:x and y are Quantum the data bits, circuits is their for sum 1-bit (modulo full2), adderc is the [from incoming Rie carry↵el bit, & andPolak (2000)].c is the new “x carryand bit.y are Vedral, the Barenco data and bits, Ekerts [Vedralis their et al. sum1996] (modulo define more 2), complexc is the circuits that include in-place addition and modular addition. incoming carry bit, and c0 is the new carry bit.” The is a “controlled swap” and can be defined as F = 0 0 I I + 1 1 S | ih | ⌦ ⌦ | ih | ⌦ where S is the swap operation S = 00 00 + 01 10 + 10 01 + 11 11 . | ih | | ih | | ih | | ih | The reader can verify that F ,likeT ,iscompleteforcombinatorialcircuits.

x x x g(x) g(x) 0 0 Φ Φ-1 0 0 f(x) CNOT f(x) y y⊕f(x) y y⊕f(x)

Uf

Figure III.16: Quantum gate array for reversible quantum computation. 114 CHAPTER III. QUANTUM COMPUTATION must be produced in a standard state independent of x.Thisisaccomplished by uncomputing, as we did in classical (Ch. II, Sec. C.6, p. 57). Since NOT is reversible, each 1 bit in c can be replaced by a 0 bit followed by a NOT, so we need only consider computations of the form (x, 0) (g(x),f(x)); that is, all the constant bits can be zero. 7! Therefore, we begin by embedding our irreversible computation of f in a reversible computation , which we get by providing 0 constants and gen- erating garbage g(x); see Fig. III.16. That is, will perform the following computation on four registers (data, workspace, result, target):

(x, 0, 0,y) (x, g(x),f(x),y). 7! The result f(x)isintheresultregisterandthegarbageg(x)isinthe workspace register. Notice that x and y (data and target) are passed through. Now use CNOTs between corresponding places in the result and target reg- isters to compute y f(x), where represents bitwise exclusive-or, in the target register. Thus we have computed:

(x, 0, 0,y) (x, g(x),f(x),y f(x)). 7!

1 Now we uncompute with ,butsincethedataandtargetregistersare passed through, we get (x, 0, 0,y f(x)) in the registers. We have restored the data, workspace, and result registers to their initial values and have y f(x) in the target register. Ignoring the result and workspace registers, we write (x, y) (x, y f(x)). 7! This is the standard approach we will use for embedding a classical compu- tation in a quantum computation. Therefore, for any computable f : 2m 2n,thereisareversiblequantum gate array U : m+n m+n such that! for x 2m and y 2n, f H !H 2 2 U x, y = x, y f(x) , f | i | i

See Fig. III.17. In particular, Uf x, 0 = x, f(x) .Thefirstm qubits are called the data register and the last| n iare called| thei target register. Introduction to Quantum Computing 21 · Deutsch has shown [Deutsch 1985] that it is possible to construct reversible quantum gates for any classically computable function. In fact, it ispossibletoconceiveofauniver- sal quantum Turing machine [Bernstein and Vazirani 1997]. Inthisconstructionwemust assume a sufficient supply of bits that correspond to the tape of a Turing machine. Knowing that an arbitrary classical function f with m input and k output bits can be im- plemented on quantum computer, we assume the existence of a quantum gatearray Uf that implements f. Uf is a m + k bit transformation of the form Uf : x, y x, y f(x) 6 | i!| i where denotes the bitwise exclusive-OR .QuantumgatearraysUf ,definedinthisway, are unitary for any function f.Tocomputef(x) we apply U to x tensored with k f | i zoresC. QUANTUMx, 0 .Sincef(x INFORMATION) f(x)=0we have Uf Uf = I.Graphicallythetransformation 115 U : x,| y i x, y f(x) is depicted as f | i!| i

x x | i | i Uf y y f(x) . | i | i

While the T and F gates are complete for combinatorial circuits, they cannot achieve ar- bitraryFigure quantum III.17: state Computation transformations. of In orderfunction to realize byarbitrary quantum unitary gate transformations array (Rie7,↵el & singlePolak, bit 2000). rotations need to be included. Barenco et. al. [Barenco et al. 1995] show that Cnot together with all 1-bit quantum gates is a universal gate set.Itsufficestoincludethe following one-bit transformations C.5 Quantum parallelismcos sin ei 0 , i sin cos 0 e ✓ ◆ ✓ ◆ Since Uf is linear, if it is applied to a superposition of bit strings, it will forproduce all 0 a superposition2 together with of the theC resultsnot to obtain of applying a universalf setto of them gates. inAs parallel we shall (i.e., see, such non-classical transformations are crucial for exploiting the power of quantum computers.in the same time it takes to compute it on one input): U (c x + c x + + c x )=c U x + c U x + + c U x . 5.2f Quantum1| 1i Parallelism2| 2i ··· k| ki 1 f | 1i 2 f | 2i ··· k f | ki What happens if U is applied to input which is in a superposition? The answer is easy For example, iff we have a superposition of the inputs x1 and x2, but powerful: since Uf is a linear transformation, it is applied to all basis vectorsinthe superposition simultaneouslyp3 1 and will generate a superposp3 ition of the results.1 In this way, it is possibleUf to computex1 f(+x) forxn2 values of0 x=in a singlex1 application,f(x1) + of Uxf .Thiseffectis2,f(x2) . called quantum parallelism.2 | i 2| i! ⌦| i 2 | i 2| i The power of quantum algorithms comes from taking advantage of quantum parallelism andThe entanglement. amplitude So of most a result quantumy will algorithms be the begin sum by compuof theting amplitudes a function of of interest all x such onthat a superpositiony = f(x). of all values as follows. Start with an n-qubit state 00 ...0 .Applythe m | i If we apply Uf to a superposition of all possible 2 inputs, it will compute 6 is not the direct sum of vectors. asuperpositionofallthecorrespondingoutputs in parallel (i.e., in the same 7More precisely, we mean arbitrary unitary transformations up to a constant phase factor. A constant phase shift oftime the state as has required no physical, for and therefore one function no computational evaluation)!,significance. The Walsh-Hadamard trans- formation can be used to produce this superposition of all possible inputs: 1 Wm 00 ...0 = ( 00 ...0 + 00 ...1 + + 11 ...1 ) | i p2m | i | i ··· | i 1 = x p m | i 2 x 2m 2 2Xm 1 1 = x . p m | i 2 x=0 X 116 CHAPTER III. QUANTUM COMPUTATION

In the last line we are obviously interpreting the bit strings as natural num- bers. Hence,

2m 1 2m 1 2m 1 1 1 1 Uf Wm 0 = Uf x, 0 = Uf x, 0 = x, f(x) . | i p m | i p m | i p m | i 2 x=0 ! 2 x=0 2 x=0 X X X Asinglecircuitdoesall2m computations simultaneously! “Note that since n qubits enable working simultaneously with 2n states, quantum parallelism circumvents the time/space trade-o↵of classical parallelism through its abil- ity to provide an exponential amount of computational space in a linear amount of physical space.” (Rie↵el & Polak, 2000) This is amazing, but not immediately useful. If we measure the input bits, we will get a random value, and the state will be projected into a superposition of the outputs for the inputs we measured. If we measure an output bit, we will get a value probabilistically, and a superposition of all the inputs that can produce the measured output. Neither of the above is especially useful, so most quantum algorithms transform the state in such a way that the values of interest have a high probability of being measured. The other thing we can do is to extract common properties of all values of f(x). Both of these require di↵erent programming techniques than classical computing.