<<

1 2

What is Quantum ? Lecture 1 Aim to use quantum mechanical phenomena that have no classical counterpart for computational purposes.

Anuj Dawar Central research tasks include: Building devices — with a specified behaviour. • Designing — to use the behaviour. and

Mediating these two are models of computation.

3 4

Bird’s eye view Why look at Quantum Computing?

A scientist looks at Quantum Computing: The world is quantum • – classical models of computation provide a level of Algorithmic Languages abstraction – discrete state systems /complexity Devices are getting smaller • System Architecture – Moore’s law – Specified Behaviour the only descriptions that work on the very small scale are quantum Exploit quantum phenomena • – using quantum phenomena may allow us to perform Dragons computational tasks that are not otherwise possible/efficient – understand capabilities/resources 5 6

Course Outline Useful

A total of eight lecturers. Some useful books: 1. Bits and Qubits (this lecture). Nielsen, M.A. and Chuang, I.L. (2000). Quantum Computation • and . Cambridge University Press. 2. Linear Algebra Mermin, N.D. (2007). Quantum . CUP. 3. Quantum • Kitaev, A.Y., Shen, A.H. and Vyalyi, M.N. (2002). Classical 4. Models of Computation • and Quantum Computation. AMS. 5. Some Applications Hirvensalo, M. (2004). Quantum Computing. Springer. 6. Search Algorithms • Course website: 7. Factorisation http://www.cl.cam.ac.uk/teaching/0910/QuantComp/ 8. Complexity

7 8

Bits Qubits

A building block of classical computational devices is a two-state tells us that any such system can exist in a system. superposition of states.

0 1 In general, the state of a quantum (or for short) is ←→ described by: α 0 + β 1 | i | i Indeed, any system with a finite set of discrete, stable states, with where, α and β are complex numbers, satisfying controlled transitions between them will do. α 2 + β 2 = 1 | | | | 9 10

Qubits Measurement

Any attempt to measure the state A qubit may be visu- α 0 + β 1 1 alised as a unit vector | i | i | i β α 0 + β 1 on the plane. results in 0 with α 2, and 1 with probability β 2. | i | i | i | | | i | |

In general, however, After the measurement, the system is in the measured state! 0 α and β are complex α | i numbers. That is, further measurements will always yield the same value.

We can only extract one bit of information from the state of a qubit.

11 12

Measurement Vectors

Formally, the state of a qubit is a unit vector in C2—the 1 2-dimensional complex . | i β α 0 + β 1 α 0 + β 1 and α 0 β 1 have | i | i α | i | i | i− | i The vector can be written as the same for their  β  measurement 0 α | i   α 0 + β 1 | i | i However, they are distinct states α 0 β 1 1 0 which behave differently in terms | i− | i where, 0 = and 1 = .     of how they evolve. | i 0 | i 1     φ — a ket, Dirac notation for vectors. | i 13 14

Basis Example

Any pair of vectors φ , ψ C2 that are linearly independent 1 | i | i∈ The vector √2 measured in the computational gives could serve as a basis. 1 " √2 # either outcome with probability 1/2. α 0 + β 1 = α′ φ + β′ ψ | i | i | i | i Measured in the basis

1 1 The basis is determined by the measurement process or device. √2 , √2  1   1  √2 √−2 Most of the time, we assume a standard (orthonormal) basis 0     | i it gives the first outcome with probability 1. and 1 is given. | i This will be called the computational basis

15 16

Entanglement Entanglement

An n-qubit system can exist in any superposition of the 2n basis Compare the two (2-qubit) states: states. 1 1 ( 00 + 01 ) and ( 00 + 11 ) √ | i | i √ | i | i α0 000000 + α1 000001 + + α2n 1 111111 2 2 | i | i ··· − | i 2n 1 2 with i=0− αi = 1 | | If we measure the first qubit in the first case, we see 0 with | i P probability 1 and the state remains unchanged. Sometimes such a state can be decomposed into the states of individual bits In the second case (an EPR pair), measuring the first bit gives 0 1 1 1 | i ( 00 + 01 + 10 + 11 )= ( 0 + 1 ) ( 0 + 1 ) or 1 with equal probability. After this, the second qubit is also 2 | i | i | i | i √2 | i | i ⊗ √2 | i | i | i determined. 1 2

Linear Algebra Quantum Computing

Lecture 2 The state space of a quantum system is described in terms of a vector space.

Anuj Dawar Vector spaces are the object of study in Linear Algebra.

In this lecture we review definitions from linear algebra that we Review of Linear Algebra need in the rest of the course.

We are mainly interested in vector spaces over the field – C.

We use the Dirac notation—|vi, |φi (read as ket) for vectors.

3 4

Vector Spaces Cn

A vector space over C is a set V with α1 Cn . • a commutative, associative addition operation + that has is the vector space of n-tuples of complex numbers:  . . – 0 0  αn  an identity : |vi + = |vi     – inverses: |vi +(−|vi)= 0 α1 β1 α1 + β1 . . . • an operation of multiplication by a scalar α ∈ C such that: with addition  .  +  .  =  . 

– α(β|vi)=(αβ)|vi  αn   βn   αn + βn        – (α + β)|vi = α|vi + β|vi and α(|ui + |vi)= α|ui + α|vi       α1 zα1 – 1|vi = |vi. . . and scalar multiplication z  .  =  . 

 αn   zαn          5 6

Basis Bases for Cn

A basis of a vector space V is a minimal collection of vectors 1 0 0

|v1i,..., |vni such that every vector |vi∈ V can be expressed as a  0   1   0  The standard basis for Cn is , ,..., linear combination of these: . . .  .   .   .              |vi = α1|v1i + ··· + αn|vni.  0   0   1        (written |0i,..., |n − 1i).      

3 4 2 n—the size of the basis—is uniquely determined by V and is called But other bases are possible: , is a basis for C . 2 −i the dimension of V. " # " #

We’ll be interested in orthonormal bases. That is bases of vectors Given a basis, every vector |vi can be represented as an n-tuple of of unit length that are mutually orthogonal. Examples are |0i, |1i scalars. 1 1 and √2 (|0i + |1i), √2 (|0i−|1i).

7 8

Linear Operators Matrices

A linear operator A from one vector space V to another W is a Given a choice of bases |v1i,..., |vni and |w1i,..., |wmi, let function such that: m A|vj i = αij|wii A(α|ui + β|vi)= α(A|ui)+ β(A|vi) i=1 X

Then, the matrix representation of A is given by the entries αij. If V is of dimension n and W is of dimension m, then the operator A can be represented as an m × n-matrix. Multiplying this matrix by the representation of a vector |vi in the basis |v1i,..., |vni gives the representation of A|vi in the basis |w1i,..., |w i. The matrix representation depends on the choice of bases for V m and W. 9 10

Examples Inner Products

1 1 An inner product on V is an operation that associates to each pair A 45 rotation of the real plane that takes to √2 and ◦ 1 |ui, |vi of vectors a complex number " 0 # " √2 # − 1 0 √2 hu|vi. to 1 is represented, in the standard basis by the " 1 # " √2 # matrix The operation satisfies 1 1 √2 − √2 • hu|αv + βwi = αhu|vi + βhu|wi  1 1  √2 √2 • hu|vi = hv|ui∗ where the ∗ denotes the complex conjugate.   • hv|vi≥ 0 (note: hv|vi is a real number) and hv|vi = 0 iff 0 −i The operator does not correspond to a transformation |vi = 0.  i 0  of the real plane. 

11 12

Inner Product on Cn Norms

The standard inner product on Cn is obtained by taking, for The norm of a vector |vi (written |||vi||) is the non-negative, real number: |ui = ui|ii and |vi = vi|ii v v v . i i ||| i|| = h | i X X p A unit vector is a vector with norm 1. hu|vi = ui∗vi i X Two vectors |ui and |vi are orthogonal if hu|vi = 0.

Note: hu| is a bra, which together with |vi forms the bra-ket hu|vi. An orthonormal basis for an inner product space V is a basis made up of pairwise orthogonal, unit vectors.

the term is also used for an inner product space 13 14

Outer Product Eigenvalues

With a pair of vectors |ui∈ U, |vi∈ V we associate a linear An eigenvector of a linear operator A : V → V is a non-zero vector operator |uihv| : V → U, known as the outer product of |ui and |vi. |vi such that A|vi = λ|vi (|uihv|)|v′i = hv|v′i|ui for some complex number λ λ is the eigenvalue corresponding to the eigenvector v. |vihv| is the projection on the one-dimensional space generated by |vi. The eigenvalues of A are obtained as solutions of the characteristic equation: Any linear operator can be expressed as a linear combination of det(A − λI) = 0 outer products:

A = Aij|iihj|. Each operator has at least one eigenvalue. ij X

15 16

Diagonal Representation Adjoints

A linear operator A is diagonalisable if Associated with any linear operator A is its adjoint A† which satisfies A = λi|viihvi| i hv|Awi = hA†v|wi X where the |vii are an orthonormal set of eigenvectors of A with T corresponding eigenvalues λi. In terms of matrices, A† =(A∗) where ∗ denotes complex conjugation and T denotes transposition. Equivalently, A can be written as a matrix

λ1 1+ i 1 − i † 1 − i −1 . =  ..   −1 1   1+ i 1     λn          in the basis |v1i,..., |vni of its eigenvectors. 17 18

Normal and Hermitian Operators Unitary Operators

An operator A is said to be normal if A linear operator A is unitary if

AA† = A†A AA† = A†A = I

Fact: An operator is diagonalisable if, and only if, it is normal. Unitary operators are normal and therefore diagonalisable. A is said to be Hermitian if A = A† Unitary operators are norm-preserving and invertible. A normal operator is Hermitian if, and only if, it has real eigenvalues. hAu|Avi = hu|vi

All eigenvalues of a unitary operator have modulus 1.

19 20

Tensor Products Tensor Products

If U is a vector space of dimension m and V one of dimension n In matrix terms, then U ⊗ V is a space of dimension mn.

Writing |uvi for the vectors in U ⊗ V: A11B A12B ··· A1mB   • |(u + u′)vi = |uvi + |u′vi A21B A22B ··· A2mB A ⊗ B =  . . .  • |u(v + v )i = |uvi + |uv i  . . .  ′ ′      Am1B Am2B ··· AmmB  • z|uvi = |(zu)vi = |u(zv)i     Given linear operators A : U → U and B : V → V, we can define an operator A ⊗ B on U ⊗ V by

(A ⊗ B)|uvi = |(Au), (Bv)i 1 2

What is Quantum Mechanics Quantum Computing

Lecture 3 Quantum Mechanics is a framework for the development of physical .

Anuj Dawar It is not itself a physical theory.

It states four mathematical postulates that a physical theory must Principles of Quantum Mechanics satisfy.

Actual physical theories, such as are built upon a foundation of quantum mechanics.

3 4

What are the Postulates About First Postulate

The four postulates specify a general framework for describing the Associated to any physical system is a complex inner product space behaviour of a physical system. (or Hilbert space) known as the state space of the system. 1. How to describe the state of a closed system.—Statics or state The system is completely described at any given point in time by space its state vector, which is a unit vector in its state space.

2. How to describe the evolution of a closed system.—Dynamics Note: Quantum Mechanics does not prescribe what the state 3. How to describe the interactions of a system with external space is for any given physical system. That is specified by systems.—Measurement individual physical theories. 4. How to describe the state of a composite system in terms of its component parts. 5 6

Example: A Qubit Second Postulate

Any system whose state space can be described by C2—the The time evolution of closed quantum system is described by the two-dimensional complex vector space—can serve as an Schr¨odinger equation: implementation of a qubit. d ψ Example: An . i~ | i = H ψ dt | i

Some systems may require an infinite-dimensional state space. where We always assume, for the purposes of this course, that our systems ~ is Planck’s constant; and have a finite dimensional state space. • H is a fixed Hermitian operator known as the Hamiltonian of • the system.

7 8

Second Postulate—Simpler Form Why Unitary?

The state ψ of a closed quantum system at time t1 is related to | i Unitary operations are the only linear maps that preserve norm. the state ψ′ at time t2 by a unitary operator U that depends only | i on t1 and t2. ψ′ = U ψ | i | i ψ′ = U ψ implies | i | i

U is obtained from the Hamiltonian H by the equation: ψ′ = U ψ = ψ = 1 ||| i|| || | i|| ||| i|| iH(t2 t1) U(t1, t2) = exp[− ~ − ] Exercise: Verify that unitary operations are norm-preserving. This allows us to consider time as discrete and speak of computational steps Exercise: Check that if H is Hermitian, U is unitary. 9 10

Gates, Operators, Matrices Pauli Gates

In this course, most linear operators we will be interested in are A particularly useful set of 1-qubit gates are the Pauli Gates. unitary. The X gate They can be represented as matrices where each column is a unit X vector and columns are pairwise orthogonal.

 0 1  Another useful representation of unitary operators we will use is as X 0 = 1 X 1 = 0 X = | i | i | i | i 1 0 gates:   The Y gate G Y

A 2-qubit gate is a unitary operator on C4. 0 i Y 0 = i 1 Y 1 = i 0 Y =  −  | i | i | i − | i  i 0 

11 12

Pauli Gates–contd. Third Postulate

The Z gate A measurement on a quantum system has some set M of outcomes. Quantum measurements are described by a collection Z Pm : m M of measurement operators. These are linear (not { ∈ } unitary) operators acting on the state space of the system. 1 0 Z 0 = 0 Z 1 = 1 Z =   If the state of the system is ψ before the measurement, then the | i | i | i −| i 0 1 | i  −  probability of outcome m is:

p(m)= ψ Pm† Pm ψ h | | i 1 0 Sometimes we include the identity I =   as a fourth Pauli 0 1   The state of the system after measurement is gate. Pm ψ | i ψ Pm† Pm ψ qh | | i 13 14

Third Postulate—contd. Measurement in the Computational Basis

The measurement operators satisfy the completeness equation. We are generally interested in the special case where the measurement operators are projections onto a particular P Pm = I X m† orthonormal basis of the state space (which we call the m M ∈ computational basis).

So, for a single qubit, we take measurement operators P0 = 0 0 This guarantees that the sum of the probabilities of all outcomes | ih | and P1 = 1 1 adds up to 1. | ih |

p(m)= ψ Pm† Pm ψ = ψ I ψ = 1 This gives, for a qubit in state α 0 + β 1 : Xm Xm h | | i h | | i | i | i

p(0) = α 2 p(1) = β 2 | | | |

Exercise: Verify!

15 16

Global Phase Relative Phase

1 iθ 1 For any state ψ , and any θ, we can form the vector e ψ . In contrast, consider the two states ψ = √2 ( 0 + 1 ) and | i | i 1 | i | i | i ψ2 = ( 0 1 ). | i √2 | i−| i Then, for any unitary operator U, Measured in the computational basis, they yield the same outcome iθ iθ probabilities. Ue ψ = e U ψ | i | i However, measured in a different orthonormal basis (say 1 ( 0 + 1 ) and 1 ( 0 1 ), the results are different. √2 | i | i √2 | i−| i Moreover, for any measurement operator Pm iθ iθ 1 1 ψ e− Pm† Pme ψ = ψ Pm† Pm ψ H 1   h | | i h | | i Also, if = √2 , then 1 1  −  H ψ1 = 0 H ψ2 = 1 Thus, such a global phase is unobservable and the states are | i | i | i | i physically indistinguishable. 17 18

Fourth Postulate Separable States

The state space of a composite physical system is the tensor A state of a combined system is separable if it can be expressed as product of the state spaces of the individual component physical the tensor product of states of the components. systems. E.g. 1 1 1 If one component is in state ψ1 and a second component is in ( 00 + 01 + 10 + 11 )= ( 0 + 1 ) ( 0 + 1 ) | i 2 | i | i | i | i √2 | i | i ⊗ √2 | i | i state ψ2 , the state of the combined system is | i ψ1 ψ2 If Alice has a system in state ψ1 and Bob has a system in | i⊗| i | i state ψ1 , the state of their combined system is ψ1 ψ1 . | i | i⊗| i If Alice applies U to her state, this is equivalent to Not all states of a combined system can be separated into the applying the operator U I to the combined state. ⊗ tensor product of states of the individual components.

19 20

Entangled States Summary

The following states of a 2-qubit system cannot be separated into Postulate 1: A closed system is described by a unit vector in a components parts. complex inner product space. Postulate 2: The evolution of a closed system in a fixed time 1 1 ( 10 + 01 ) and ( 00 + 11 ) interval is described by a unitary transform. √2 | i | i √2 | i | i Postulate 3: If we measure the state ψ of a system in an | i orthonormal basis 0 n 1 , we get the result j with 2| i···| − i | i Note: probability j ψ . After the measurement, the state of the Physical separation does not imply separability. Two |h | i| particles that are physically separated could still be entangled. system is the result of the measurement. Postulate 4: The state space of a composite system is the tensor product of the state spaces of the components. 1 2

Quantum Circuits Quantum Computing

Lecture 4 A is a sequence of unitary operations and measurements on an n-qubit state.

Anuj Dawar  Input State U1 U2 U3   Models of Quantum Computation M  

n n Note: each Ui is described by a 2 2 matrix. ×

3 4

Algorithms Model of Computation

A quantum specifies, for each n, a sequence As a model of computation, this is parasitic on classical models.

n = O ...Ok what is computable is not independently determined O 1 of n-qubit operations. Purely quantum models can be defined. We will see more on this in Lecture 8. The map n n must be computable. → O i.e. the individual circuits must be generated from a What computations can be performed in the model as defined? common pattern. What functions can be computed? What decision problems are decidable? All measurements can be deferred to the end (possibly, at the expense of increasing the number of qubits). Can all such computations be performed with some fixed set of unitary operations? 5 6

Simulating Boolean Gates Computing a Function

Could we find a quantum circuit to simulate a classical And gate? If f : 0, 1 n 0, 1 m is a Boolean function, the map { } → { } x f(x) a a b | i 7→ | i And ∧ b may not be unitary.

We will, instead seek to implement This would require And : 00 0x , 01 0y | i 7→ | i | i 7→ | i x 0 x f(x) 10 0z , 11 1w | i⊗| i 7→ | i⊗| i | i 7→ | i | i 7→ | i There is no unitary operation of this form.

Unitary operations are reversible. No information can be lost in the Exercise: Describe a unitary operation that implements the process. Boolean And in this sense.

7 8

One-Qubit Gates Gates on a Multi-Qubit State

We have already seen the Pauli Gates: When we draw a circuit with a one-qubit gate, this must be read as a unitary operation on the entire state. 0 1 0 −i 1 0 X = ,Y = ,Z = " 1 0 # " i 0 # " 0 −1 # U

Another useful one-qubit gate is the Hadamard gate:

1 1 1 H = √2  1 1  − U I   ⊗

H This does not change measurement outcomes on the second qubit. 9 10

Controlled Not Controlled U

The Controlled Not is a 2-qubit gate: More generally, we can define, for any single qubit operation U, the Controlled U gate: a a | i | i The controlled not flips the sec- ond qubit if the first qubit is 1 b a b | i and leaves it unchanged if it’s 0 U 0x 0x | i | ⊕ i | i | i 7→ | i 1x 1, Ux | i 7→ | i Particularly useful is the controlled-Z gate: 1 0 0 0 Z  0 1 0 0  C =  0 0 0 1  Z      0 0 1 0     

11 12

Toffoli Gate Classical Reversible Computation

a1 a1 The Toffoli Gate is a 3-qubit | i | i A Boolean function f : 0, 1 n 0, 1 n is reversible if it’s gate. { } → { } described by a 2n 2n permutation matrix. a2 a | i | 2i It has a classical counterpart × which can be used to simulate n m b (a1 a2) b For any function g : 0, 1 0, 1 , there is a reversible function | i | · ⊕ i standard Boolean operations m+n { m+}n → { } g′ : 0, 1 0, 1 with { } → { } A permutation matrix is a where all entries are g′(x, 0)=(x, g(x)). 0 or 1.

Toffoli gates are universal for reversible computation. Any 2n 2n permutation matrix can be implemented using only × Toffoli gates. The Toffoli gate cannot be implemented using 2-bit reversible classical gates. 13 14

Quantum Toffoli Gate Universal Set of Gates

The Toffoli gate can be implemented using 2-qubit quantum gates. Fact: Any unitary operation on n qubits can be implemented by a sequence of 2-qubit operations.

Q Fact: Any unitary operation can be implemented by a combination of C-NOTs and single qubit operations. Q† Q† P

H Q† Q Q† Q H Fact: Any unitary operation can be approximated to any required degree of accuracy using only C-NOTs, H, P and Q.

1 0 1 0 where, P = , Q = 4 . These can serve as our finite set of gates for quantum computation. " 0 i # " 0 eiπ/ #

15 16

Deutsch-Jozsa Problem replacemen Deutsch-Jozsa Algorithm

Given a function f : 0, 1 0, 1 , determine whether f is { } → { } 0 H H constant or balanced. | i Uf 1 ( 0 1 ) √2 | i−| i Classically, this requires two calls to the function f. Uf with input x and 0 1 is just a phase shift. | i | i−| i But, if we are given the quantum black box: It changes phase by ( 1)f(x). − a a When x = H 0 , this gives ( 1)f(0) 0 +( 1)f(1) 1 . | i U | i | i | i − | i − | i b f b f(a) | i | ⊕ i Final result is [( 1)f(0) +( 1)f(1)] 0 + [( 1)f(0) ( 1)f(1)] 1 − − | i − − − | i which is 0 if f is constant and 1 if f is balanced. One use of the box suffices | i | i 1 2

Some Applications Quantum Computing

Lecture 5 We look at some applications of the encoding of information in quantum states. Quantum , or more accurately Quantum Key Anuj Dawar • Distribution. . • Applications of Quantum Information

These do not rely on quantum computation as such, but the properties of information encoded in quantum states: superposition and entanglement.

3 4

Quantum Key Distribution Assumptions

A protocol for was described by Bennett The BB84 protocol relies on the following assumptions: and Brassard in 1984 (and is known as BB84). Alice has a source of random (classical) bits. • Eve Alice can produce qubits in states 0 and 1 . • | i | i The protocol does not pro- qubit channel Alice can apply a Hadamard operator H to the qubits. Alice Bob vide the means of transmit- • Bob can measure incoming qubits classical channel ting an arbitrary message. • – either in the basis 0 , 1 ; | i | i At the end of the protocol, there is a random sequence of bits that – or in the basis 1 ( 0 + 1 ), 1 ( 0 1 ). √2 | i | i √2 | i−| i is shared between but unknown to any third party. These conditions are satisfied, for instance, by a system based on polarised . 5 6

The Protocol The Protocol–contd.

Alice sends Bob a stream of qubits. For each qubit, Bob randomly chooses either the basis 0 , 1 • | i | i or the basis H 0 , H 1 and measures the qubit in the chosen | i | i For each qubit, before sending it, she basis. randomly chooses a bit 0 or 1 ; Bob announces (over the classical channel) which basis he used • | i | i • for each measurement. randomly either applies H to the qubit or not; and • Alice tells Bob which measurements were made in the correct sends it to Bob. • • basis. The qubits which were measured in the wrong basis are So, Bob receives a random sequence of qubits, each of which is in • one of the four states: discarded, while the rest form a shared key.

0 , 1 , H 0 , H 1 | i | i | i | i

7 8

Attacks Attack 2

Why not announce the bases for all qubits before transmission, What happens if Eve intercepts the qubits, measures each one thus avoiding the loss of half the bits? randomly in either the basis 0 , 1 or the basis H 0 , H 1 and | i | i | i | i This allows Eve to intercept, measure and re-transmit the then retransmits it? bits. that are shared between and Eve Why not wait until Bob has received all the qubits, then have Alice For half of the bits Alice Bob, will announce the basis for each one before Bob measures them? have measured them in the wrong basis. Moreover, these bits will have changed state, and so for approx. 1 Requires Bob to store the qubits—currently technically 4 • of the shared bits, the value measured by Bob will be different to difficult. the one encoded by Alice. If Bob can store the qubits, then Eve can too and then she can • Alice and Bob can choose a random sample of their shared bits and retransmit after measurement. publically check their values against each other and detect the If we could fix the basis before hand, this could be used to transmit presence of an eavesdropper. a fixed (rather than random) message. 9 10

Attack 3 Key Distribution

Could Eve intercept the qubits, make a copy without measuring Quantum key distribution relies on nothing more than them and re-transmit to Bob and then wait for the basis to be linear superposition of states; and announced? • change of basis. • No Cloning Theorem: There is no unitary operation U which for an arbitrary In particular, it does not rely on entanglement. state ψ gives We next look at some applications of entanglement. U ψ0 = ψψ . | i | i

Exercise: Prove the no-cloning theorem.

11 12

Bell States Generating Bell States

Entanglement based protocols generally rely on using the following We can generate the Bell states from the computational basis four states of a two-qubit system, known as the Bell states. 00 , 01 , 10 , 11 using the following circuit: | i | i | i | i 1 1 ( 00 + 11 ), ( 01 + 10 ) √2 | i | i √2 | i | i H

1 1 ( 00 11 ), ( 01 10 ) √2 | i−| i √2 | i−| i

4 These form an orthonormal basis for C , known as the Bell basis. 00 1 ( 00 + 11 ) | i √2 | i | i 1 ( 00 + 10 ) Note that, in each of the states, measuring either qubit in the √2 | i | i computational basis yields 0 or 1 with equal probability, but | i | i after the measurement, the other bit is determined. 13 14

Superdense Coding Superdense Coding 2

In general, it is impossible to extract more than one classical bit of Generating Bell states from 1 ( 00 + 11 ) with only operations on √2 | i | i information from a single qubit. the first qubit.

1 1 However, if Alice and Bob is each in possession of one qubit of a (X I) ( 00 + 11 )= ( 01 + 10 ) pair in a known ⊗ √2 | i | i √2 | i | i 1 ( 00 + 11 ) √2 | i | i 1 1 (Z I) ( 00 + 11 )= ( 00 11 ) ⊗ √2 | i | i √2 | i−| i Then Alice can perform an operation solely on her own qubit, and then send it to Bob to convey two bits of information. 1 1 ((XZ) I) ( 00 + 11 )= ( 01 10 ) ⊗ √2 | i | i √2 | i−| i

15 16

Superdense Coding 3 Quantum Teleportation

Once he has both qubits, Bob can convert back to the The superdense coding protocol allows Alice to send Bob two computational basis using the circuit. classical bits by transmitting a single qubit, provided they already share an entangled pair. H

Conversely, the quantum teleportation protocol allows Alice to send Bob a qubit, by sending just two classical bits along a classical channel, provided they already share an entangled pair. After this, a measurement in the computational basis yields the two bits that Alice intended to convey. Contrast this with the no-cloning theorem, which tells us that we cannot make a copy of a qubit. 17 18

Quantum Teleportation 2 Quantum Teleportation 3

Alice has a state φ that she wishes to transmit to Bob. The two Alice conveys to Bob the result of her measurement. Say the qubit | i already share a pair of qubits in state 1 ( 00 + 11 ). in Bob’s possession is in state θ , then: √2 | i | i | i If Alice measures 00 , then φ = θ . • | i | i | i If Alice measures 01 , then φ = X θ . • | i | i | i φ H | i If Alice measures 10 , then φ = Z θ . M • | i | i | i If Alice measures 11 , then φ = XZ θ .  • | i | i | i Entangled Pair Thus, Bob performs the appropriate operation and now has a qubit  whose state is exactly φ . | i 1 2

Search Problems Quantum Computing Lecture 6 One of the two most important algorithms in quantum computing is Grover’s search algorithm—first presented by Lov Grover in 1996.

Anuj Dawar This provides a means of searching for a particular value in an unstructured search space. Compare Quantum Searching searching for a name in a telephone directory • searching for a phone number in a telephone directory •

Given a black box which can take any of N inputs, and for each of them gives a yes/no answer, Grover’s algorithm allows us to find the unique value for which the answer is yes in O(√N) steps (with high probability).

3 4 replacemen Deutsch-Jozsa Algorithm revisited Oracle

Suppose we have f : N 0, 1 , and that N = 2n, so we can think 0 H H → { } | i Uf of f as operating on n bits. 1 ( 0 1 ) √2 | i−| i

We assume that we are provided a black box or oracle Uf for When the lower input to Uf is 0 1 , we can regard this as computing f, in the following sense: | i−| i unchanged, and instead see Uf as shifting the phase of the upper qubit by ( 1)f(x). −  x  | i Uf  b b f(x) | i | ⊕ i 5 6 replacements Grover’s Algorithm Grover’s Algorithm Schematic

O(√N) Suppose further that there is exactly one n-bit value a such that z }| { 0 H f(a) = 1 | i 0 H | i U W U W M 0 f ··· f and for all other values x, | i H 0 H f(x) = 0. | i

0 1 | i−| i

Grover’s algorithm gives us a way of using the black box Uf to The operator G =(W I)Uf is known as the Grover Iterate (we √ n/2 ⊗ determine the value a with O( N)= O(2 ) calls to Uf . will see soon what W is).

The input to the last bit is 1 ( 0 1 ). √2 | i−| i

7 8

The Action of Uf Components of W

n n As the “output qubit” is 0 1 , it remains unaffected by the We write H⊗ for the fol- And X⊗ for the following | i−| i action of Uf , which we can think of instead as a conditional phase lowing operation: operation: change on the n input qubits. H X    H  X a a n  n  | i 7→ −| i inputs  inputs  x x for any x = a H X | i 7→ | i 6    H  X   We will ignore the output bit completely and instead talk of the n-bit operator V above. Each of these can, of course, be implemented by a series of n Note: V = I 2 a a . 1-qubit operations. − | ih |

We now analyse the Grover iterate W V . 9 10

More Components of W Defining W

n We write cZ⊗ for the n-bit controlled-Z gate: Now, we can define W by:

n n n n n W = ( 1)H⊗ (X⊗ cZ⊗ X⊗ )H⊗ . 1 0 0 −   ···  n n n n  = ( 1)H⊗ (I 2 0 0 )H⊗  0 1 0 − − | ih | n inputs  n    cZ⊗ =  ···   . . .. .   . . . .  Write Ψ for the state    | i  Z  0 0 1     N 1 ··· − n n 1 − H⊗ 0 = i . | i √ X | i N i=0 n cZ⊗ can be implemented using O(n) cZ and Toffoli gates, using some workspace qubits (Exercise). So, W =( 1)(I 2 Ψ Ψ ), i.e. − − | ih | W = 2 Ψ Ψ I. | ih |−

11 12

The Grover Iterate Geometric View

Since G = W V , we have We can picture the action of W and V in the two-dimensional real plane spanned by the vectors a and Ψ . G = (2 Ψ Ψ I)(I 2 a a ). | i | i | ih |− − | ih | a | i V is a reflection W V Ψ about the line per- Consider the actions of W and V on the two states Ψ and a . | i | i | i pendicular to a . | i 2θ Ψ W is a reflection W Ψ = Ψ W a = 2 Ψ a . √N θ | i about Ψ . | i | i | i | i−| i | i V Ψ = Ψ 2 a V a = a The composition of | i | i− √N | i | i −| i V Ψ two reflections of the | i Thus, as we start the algorithm in state Ψ , the result of repeated plane is always a ro- | i applications of V and W will always give a real linear combination tation. of a and Ψ . | i | i 13 14

The Rotation Number of Iterations

It is clear from the picture that W V (the Grover iterate) is a After t π/2 π √N iterations of the Grover iterate G = W V , ∼ 2θ ∼ 4 rotation through an angle 2θ in the direction from Ψ to a , where the state of the system | i | i the angle between Ψ and a is π θ. Gt Ψ | i | i 2 − | i is within an angle θ of a . Ψ and a are nearly orthogonal, so θ is small (if N is large). | i | i | i A measurement at this stage yields the state a with probability π 1 1 | i sin θ = cos( θ)= a Ψ = = . n/2 N 1 2 − h | i √N 2 GtΨ a 2 (cos θ)2 = 1 (sin θ)2 = − . |h | i| ≥ − N So, 1 1 θ = ∼ √N 2n/2 Note: Further iterations beyond t will reduce the probability of for large enough values of N. finding a . | i

15 16

Multiple Solutions Lower Bound

Grover’s algorithm works even if the solution a is not unique. For classical algorithms, searching an unstructured space of | i solutions (such as given by a black box for f), it is easy to show a Suppose there is a set of solutions S 0,...,N 1 and let Ω(N) lower bound on the number of calls to the black box required ⊆ { − } M = S be the number of solutions. to identify the unique solution. | | The Grover iterate is then a rotation in the space spanned by the two vectors Grover’s algorithm demonstrates that a can beat any classical algorithm for the problem. N 1 1 − 1 Ψ = i S = j | i √N X | i | i √M X | i i=0 j S √N ∈ It is possible to show a Ω( ) lower bound for the number of calls to Uf by any quantum algorithm that identifies a unique solution.

As the angle between these is smaller, the number of iterations Grover’s algorithm does not allow quantum to solve drops, but so does the probability of success. NP-complete problems in polynomial time. 1 2

Quantum Factoring Quantum Computing

Lecture 7 A polynomial time quantum algorithm for factoring numbers was published by in 1994. polynomial time Anuj Dawar here means that the number of gates is bounded by a polynomial in the number of bits n of the number being factored.

Quantum Factoring The best known classical algorithms are exponential (in n1/3).

Fast factoring would undermine public-key cryptographic systems such as RSA.

3 4

Period Finding Order Finding

Suppose we are given a function f : N 0,...,N 1 which we Suppose we are given an integer N and an a with a < N and → { − } know is periodic, i.e. gcd(a, N) = 1. f(x + r)= f(x) for some fixed r and all x.

Consider the function f : N 0,...,N 1 given by a → { − } Can we find the least value of r? f (x) ax (mod N) a ≡ If we can find the period of a function efficiently, we can factor integers quickly. Then, fa is periodic, and if we can find the period r, we can factor N. 5 6

Factoring Factoring–contd.

Suppose (for simplicity) N = pq, where p and q are prime. And, for So, (x 1)(x +1) = kpq for some k. − some a < N, we know the period r of the function fa. Now, finding gcd(N, x 1) and gcd(N, x + 1) will find p and q. − Then, ar+1 a (mod N), so ar 1 (mod N). ≡ ≡ If we randomly choose a < N If r is even and ar/2 + 1 0 (mod N), then take x2 = ar. 6≡ (and check that gcd(a, N) = 1—if not, we’ve already found x2 1 0 (mod N) a factor of N) − ≡ (x 1)(x + 1) 0 (mod N) then, there is a probability > 1 that − ≡ 2 the period of f is even; and But, • a x 1 0 (mod N) (by minimality of r) ar/2 + 1 0 (mod N). − 6≡ • 6≡ x + 1 0 (mod N) (by assumption) 6≡

7 8

Using a Fourier Transform Discrete Fourier Transform

A fast period-finding algorithm allows us to factor numbers quickly. The discrete Fourier transform of a sequence of complex numbers

x0,...,xM 1 The idea is to use a Fourier Transform to find the period of a − function f. is another sequence of numbers

y0,...,yM 1 Note, classically, we can use the fast Fourier transform algorithm − where for this purpose, but it can be shown that this would require time M 1 1 − N log N, which is exponential in the number of bits of N. y = x e2πijk/M k √ X j M j=0 or M 1 1 − y = x ωjk. k √ X j M j=0 where ω = e2πi/M . 9 10

DFT is Unitary Inverse DFT

The discrete Fourier transform is a unitary operation on CM . The inverse of the discrete Fourier Transform is given by: Writing ω for e2πi/M , 1 1 1 1 2 M 1 M ω, ω ,...,ω − , ω = 1  ···  1 2 1 ω− ω− ω  ···  are the Mth roots of 1.  2 4 2  1  1 ω− ω− ω  D 1 =  ···  −  3 6 3  √M  1 ω− ω− ω  1 1 1 1  ···   ···   ......  2 1  . . . . .  1 ω ω ω−    ···   1 M 2 2M M 1   2 4 2   1 ω − ω − ω −  1  1 ω ω ω−  ··· D =  ···   3 6 3  √M  1 ω ω ω−   ···   . . . . .   ......  1   Exercise: Verify that D is unitary. Verify that D− as given above  M 1 2M 2   1 ω − ω − ω  is the inverse of D. ···

11 12

Quantum Fourier Transform Fourier Transform on Binary Strings

Computing the discrete Fourier transform classically takes time Suppose M = 2n, and let x be a computational basis state in CM | i polynomial in M. with binary representation x x . 1 ··· n Let Shor showed that D can be implemented using a number of one and 2πi(0 xj xj+1 xn) ηj = e · ··· . two-qubit gates that is only polynomial in the number of qubits O((log M)2). Then Note: This does not give a fast way to compute the DFT on a D x =( 0 + ηn 1 )( 0 + ηn 1 1 ) ( 0 + η1 1 ). quantum computer. | i | i | i | i − | i ··· | i | i There is no way to extract all the complex components from the transformed state. Exercise: Verify. 13 14

Quantum Fourier Transform Circuit Conditional Phase Shifts

We can use this form to implement the quantum Fourier transform Here using Hadamard gates and conditional phase-shift gates. 1 0 1 0 1 0 P =   Q =   R =   iπ/4 iπ/8  0 i   0 e   0 e  H

Two-qubit conditional phase shift gates are actually symmetric H P between the two bits, despite the asymmetry in the drawn circuit. H P Q It seems that for large n, an n-bit quantum Fourier transform H P Q R circuit would require conditional phase shifts of arbitrary precision. It can be shown that this can be avoided with some (but not In the input, the least significant bit is at the top, in the output, it significant) loss in the probability of success for the factoring is at the bottom. algorithm.

15 16

Preparing the State First Measurement

We are given an implementation of the function f as a unitary n We measure the second n qubits of the state Uf Ψ 0 and get a operator Uf | i| i value f0. The state after measurement is:

Where, now, each of the two in- m 1 x x 1 − put wires represents n distinct x0 + kr f0 . | i Uf | i √m X | i| i 0 f(x) k=0 | i | i qubits where: Writing Ψ for the state | i x0 is the least value such that f(x0)= f0 2n 1 n n 1 − H⊗ 0 = x . r is the period of the function f | i 2n/2 X | i x=0 n m = 2 . We have, ⌊ r ⌋ 2n 1 1 − U Ψ 0n = x f(x) . f | i| i 2n/2 X | i| i x=0 17 18

Applying the QFT Second Measurement

We apply the n-qubit quantum Fourier transform to the first n bits The probability of observing a given state y is: | i of the transformed state. m 1 2 1 − kry n ω . m 1 2 m X − k=0 D 1 x + kr √m X | 0 i k=0 2n 1 m 1 − 1 − = 1 ω(x0+kr)y y This probability function has peaks when ry/2n is close to an 2n/2 X √m X | i y=0 k=0 integer. 2n 1 m 1 − 1 − = ωx0y ωkry y . Indeed, if ry/2n is an integer, then the probability of measuring y X 2n/2√m X | i y=0 k=0 is 1. n where ω = e2πi/2 . Given an integer multiple of 2n/r, it is not difficult to find r.

19 20

Exponentiation Some Points to Note

To complete the factoring algorithm, we need to check that we can The two measurement steps can be combined at the end, with the also implement the unitary transform Uf for the particular function Fourier transform applied before the measurement of f(x).

x fa(x)= a mod N. The probability of successfully finding the period in any run of the with a number of quantum gates that is polynomial in log N. algorithm is only about 0.4. However, this means a small number of repetitions will suffice to This is achieved through repeated squaring. find the period with high probability.

Putting a lower bound on the conditional phase shift we are allowed to perform affects the probability of success, but not the rest of the algorithm. 1 2

Models of Computation Quantum Computing

Lecture 8 Shor’s algorithm solves, in polynomial time, a problem for which no classical, deterministic polynomial time algorithm is known.

Anuj Dawar What class of problems are solvable by quantum machines in polynomial time?

Quantum Automata and Complexity More generally, how does quantum parallelism compare with other forms of parallelism and nondeterminism.

How does the quantum model of computation affect our understanding of complexity classes?

3 4

Finite State Systems DFAs and Matrices

a a Each DFA is specified by a collection of n × n matrices, where n is This automaton accepts the set of b the number of states in the DFA, and there is one matrix for each strings that contain at least one b. letter.

Its operation can be described by a Each column of each matrix is a unit vector with 0, 1 b pair of matrices. entries.

More generally, we can form a matrix Mw for each word w.  1 0   0 0  Ma = Mb = Multiplication of matrices corresponds to concatenation of  0 1   1 1  words. MbMbMa describes the operation on states performed by reading M |ii = |ji if there is a path labelled w from state i to state j. the string abb. w 5 6

Nondeterministic Automata NFAs and Matrices

a a This automaton accepts the same set of strings as the deterministic b  1 0  one. Mbb =  2 1  The columns of the corresponding b b matrices are no longer unit vectors. Mw(i, j) gives the number of paths labeled w from state i to state j.

1 0 1 0     Mw|ii = Mw(i, j)|ji Ma = Mb = X j  0 1   1 1 

7 8

Probabilistic Automata Language Accepted

We obtain probabilistic automata if we allow fractional values in A probabilistic automaton A accepts a language L with certainty if

Mσ.  1 if w ∈ L with the proviso that each column adds up to 1. P (A accepts w)=  0 if w 6∈ L   0.5 0.0   0.8 0.2  E.g. Ma = Mb = A accepts a language L with bounded probability if there is an 0.5 1.0 0.2 0.8     ǫ< 1/2 such that:

> 1 − ǫ if w ∈ L 0.4 0.1 gives, in position (i, j) the prob-    P (A accepts w)=  MaMb = ability that string ba takes you <ǫ if w 6∈ L 0.6 0.9   from state i to state j. 

The class of languages accepted by probabilistic automata (under either definition) is the regular languages. 9 10

Quantum Automata Acceptance Probabilities

Quantum finite automata are obtained by letting the matrices Mσ If q is the starting state of the automaton, have complex entries. Mw|qi We also require each of the matrices to be unitary. is the state after reading w. If

Mσ is unitary since the sum of αj = hj|Mw|qi  −1 0  the squares of the norms in each E.g. Mσ = then αj is the that the automaton reaches 0 i column adds up to 1 and the dot   state j. product of any two columns is 0. 2 |αj| is the probability that a measurement will result in NB: If all matrices only have 0 or 1 entries and the matrices are state qj. unitary (i.e., the matrices are permutation matrices), then the 2 j F |αj| is the probability that the automaton accepts automaton is deterministic and reversible. P ∈ the string w.

11 12

Language Accepted Interference

Consider the automaton in a one letter alphabet defined as: We can define language acceptance exactly or by bounded 1 1 probability. √2 √2 1 − √2 1 1  √2 √2  Because of the reversibility requirement, quantum automata are q1 q2 Ma = 1 1 − quite a weak model. 1  √2 √2  √2

There are regular languages that cannot be accepted by a QFA. While there are two distinct paths la-  0 1  belled aa from q1 back to itself, and each Maa = has non-zero probability, the net proba- However, QFAs may be much more succinct than their classical  −1 0  bility of ending up in q1 is 0. counterparts. The automaton accepts a string of odd length with probability 0.5 and a string of even length with probability 1 if its length is not a multiple of 4 and probability 0 otherwise. 13 14

Turing Machines Configurations and Computations

A , in addition to the finite set of states in the If c0 is the configuration in the starting state, with w on the tape automaton has an infinite read-write tape. and the tape head at the left end of the string, w is accepted if the computation

A machine is determined by an alphabet Σ, a finite set of states Q c0 → c1 →···→ cf and a transition function δ which gives, for each state and symbol: eventually reaches an accepting state. a next state, a replacement symbol and a direction in which to If the length of the computation is bounded by a polynomial in the move the tape head. length of w, the language accepted by the machine is in P.

A machine has infinitely many possible configurations (reserving The action of the Turing machine can equivalently be described as the word “state” for a member of Q). a linear operator M on an infinite-dimensional space. Each configuration c is determined by a state, the contents of the The set of configurations form a basis for the space. tape (a finite string) and the position of the head.

15 16

Nondeterministic Turing Machines Probabilistic Machines

In a nondeterministic machine, δ determines, for each state and With a probabilistic machine, δ defines, for each current state and symbol, a set of next moves. symbol, a probability distribution over the possible next moves. This gives rise to a tree of configurations: c4 The action of the machine can be defined as an infinite matrix, c1 c5 A configuration may occur in several where the rows and columns are configurations, and each column adds up to 1. c6 places in the tree. c2 c0 c7 The initial string w is accepted by the ma- However, how much information can be encoded in a single entry? c8 chine if there is some path through the We require the entries α to be feasibly computable. That is, there is c9 c3 tree leading to an accepting state. a feasibly computable f such that: c10 |f(n) − α| < 2 n If the height of the tree is bounded by a polynomial in the length of − w, then the language is in NP 17 18

BPP Quantum Turing Machines

BPP is the collection of languages L for which there is a With a , δ associates with each state and probabilistic machine M, running in polynomial time with: symbol, and each possible next move, a complex probability amplitude (which we require to be a feasible complex number). > 2 if w ∈ L P (M accepts w)=  3 The machine can be seen as progressing  1 < 3 if w 6∈ L c4 through a series of stages, each of which  c1 2 1 c5 is a superposition of configurations. The class of languages is unchanged if we replace 3 and 3 by 1 − ǫ 1 0 6 and ǫ, for any ǫ< 2 , or indeed the set of all feasibly computable α c 1 c2 Note that the probability of c7 occurring probabilities with {0, , 1}. c0 α1 2 at time 2 may be less than the sum of the α2 c7 probabilities along the two paths. P NP P BPP The only inclusion relations we know are ⊆ and ⊆ . c8 c3 c9 We also require that the linear transfor- Primality testing, long known to be in NP and in BPP was shown mation defined by the machine is unitary. in 2002 to be in P.

19 20

BQP Complexity Classes

BQP is the collection of languages L recognised by a quantum Turing machine, running in polynomial time, under the bounded factorisation NP − C probability rule. PSPACE NP

The class BQP is not changed if we restrict the set of possible BPP 3 4 amplitudes to {0, ± 5 , ± 5 , 1}. P BQP

BPP ⊆ BQP

Inclusion relations among the complexity classes as we know them. Shor’s algorithm shows that the factorisation problem is in BQP. It is not known to be in BPP.