PIQC Lecture 3
PIQC Lecture 3
Elı́as F. Combarro
[email protected]
2 / 100
I, for one, welcome our new quantum overlords
4 / 100
Tools and resources
• Jupyter Notebooks
• Web application to create and execute notebooks that
include code, images, text and formulas
• They can be used locally (Anaconda) or in the cloud
(mybinder.org, Google Colab...)
• IBM Quantum Experience
• Free online access to quantum simulators (up to 32 qubits)
and actual quantum computers (1, 5 and 15 qubits) with
different topologies
• Programmable with a visual interface and via different
languages (python, qasm, Jupyter Notebooks)
• Launched in May 2016
• https://quantum-computing.ibm.com/
• Quirk
• Online simulator (up to 16 qubits)
• Lots of different gates and visualization options
• http://algassert.com/quirk
• D-Wave Leap
• Access to D-Wave quantum computers
• Ocean: python library for quantum annealing
• Problem specific (QUBO, Ising model...)
• https://www.dwavesys.com/take-leap
6 / 100
The shape of things to come
7 / 100
What is quantum computing?
Quantum computing
Quantum computing is a computing paradigm that exploits
quantum mechanical properties (superposition, entanglement,
interference...) of matter in order to do calculations
8 / 100
Models of quantum computing
• There are several models of quantum computing (they’re
all equivalent)
• Quantum Turing machines
• Quantum circuits
• Measurement based quantum computing (MBQC)
• Adiabatic quantum computing
• Topological quantum computing
• Regarding their computational capabilities, they are
equivalent to classical models (Turing machines)
10 / 100
What technologies are used to build quantum
computers?
11 / 100
What is a quantum computer like?
13 / 100
What are the elements of a quantum circuit?
14 / 100
Part II
15 / 100
What is a qubit?
• A classical bit can take two different values (0 or 1). It is
discrete.
• A qubit can “take” infinitely many different values. It is
continuous.
• Qubits live in a Hilbert vector space with a basis of two
elements that we denote |0i y |1i.
• A generic qubit is in a superposition
|ψi = α |0i + β |1i
where α and β are complex numbers such that
|α|2 + |β|2 = 1
17 / 100
What are quantum gates?
UU † = U † U = I
18 / 100
Reversible computation
• As a consequence, all the operations have an inverse:
reversible computing
• Every gate has the same number of inputs and outputs
• We cannot directly implement some classical gates such
as or , and, nand, xor ...
• But we can simulate any classical computation with small
overhead
• Theoretically, we could compute without wasting energy
(Landauer’s principle, 1961)
20 / 100
Action of a one-qubit gate
that is, into the state |ψi = (aα + bβ) |0i + (cα + dβ) |1i
• Since U is unitary, it holds that
21 / 100
The X or NOT gate
|0i X |1i
|1i X |0i
that is, it acts like the classical NOT gate
• On a general qubit its action is
22 / 100
The Z gate
• Its action is
|0i Z |0i
|1i Z − |1i
23 / 100
The H or Hadamard gate
• The H or Hadamard gate is defined by the (unitary) matrix
1 1 1
√
2 1 −1
• Its action is
|0i+|1i
|0i H √
2
|0i−|1i
|1i H √
2
• We usually denote
|0i + |1i
|+i := √
2
and
|0i − |1i
|−i := √
2
24 / 100
Other important gates
• Y gate
0 −i
i 0
• S gate
1 0
π
0 ei 2
• T gate
1 0
π
0 ei 4
• The gates X , Y and Z are also called, together with the
identity, the Pauli gates. An alternative notation is σX , σY ,
σZ .
25 / 100
The Bloch sphere
26 / 100
The Bloch sphere (2)
• From |ψi = cos 2θ |0i + eiϕ sin 2θ |1i we can obtain spherical
coordinates for a point in R3
(sin θ cos ϕ, sin θ sin ϕ, cos θ)
cos 2θ −i sin 2θ
−i θ2 X θ θ
RX (θ) = e = cos I − i sin X =
2 2 −i sin 2θ cos 2θ
cos 2θ − sin 2θ
θ θ θ
RY (θ) = e−i 2 Y = cos I − i sin Y =
2 2 sin 2θ cos 2θ
θ
!
e−i 2
−i θ2 Z θ θ 0 1 0
RZ (θ) = e = cos I−i sin Z = ≡
2 2 0
θ
ei 2 0 eiθ
28 / 100
Using rotation gates to generate one-qubit gates
θ θ θ
U ≡ e−i 2 r ·σ = cos I − i sin (rx X + ry Y + rz Z )
2 2
• For instance, choosing θ = π and r = ( √1 , 0, √1 ) we can
2 2
see that
θ 1
H ≡ e−i 2 r ·σ = −i √ (X + Z )
2
• Additionally, it can also be proved that there exist angles α,
β and γ such that
29 / 100
Inner product, Dirac’s notation and Bloch sphere
30 / 100
Hello, quantum world!
|0i H
|0i + |1i
√
2
• When we measure, we obtain 0 or 1, each with 50%
probability: we have a circuit that generates perfectly
uniform random bits!
31 / 100
Part III
32 / 100
One-time pad: a Catch-22 situation
• Alice wants to send Bob a message m without Eve being
able to learn anything about its content
• This can be achieved if Alice and Bob share in advance a
string k of random bits:
• Alice computes x = m ⊕ k and sends x to Bob
• Eve cannot learn anything from x
(Pr (M = m|X = x) = Pr (M = m))
• But Bob can recover m by computing x ⊕ k
• The main problem is that k has to be as long as m and
cannot be reused so... how to agree on k?
33 / 100
The problem of key distribution
• Alice and Bob may share several keys for later use when
they are together
• But... what if they cannot meet each other?
• There exist key distribution methods like the Diffie-Hellman
protocol but...
• They are not unconditionally secure (they usually rely on
hardness assumptions)
• In fact, DH can be broken with quantum computers!
34 / 100
BB84: Alice’s part
35 / 100
BB84: Bob’s part
36 / 100
BB84: Alice and Bob on the phone
37 / 100
BB84: The protocol in an image
38 / 100
Eve tries to intercept and resend...
39 / 100
Information reconciliation and privacy amplification
• Because of imperfections in the channel and devices or
because of eavesdropping, some of the bits that Alice and
Bob have may be different
• They can conduct a process of information reconciliation
(for instance, with the cascade protocol)
• After this phase (or even before), some information may
have leaked to Eve
• Alice and Bob can perform privacy amplification (for
instance, with randomness extractors)
41 / 100
Kak’s three-stage protocol
• Proposed by Kak in 2006
• It needs an authenticated quantum channel
• Suppose Alice wants to send |xi ∈ {|0i , |1i} to Bob:
• Alice chooses θA at random and sends RY (θA ) |xi to Bob
• Bob choose θB at random and sends RY (θB )RY (θA ) |xi
back to Alice
• Alice applies RY (−θA ) and sends
RY (−θA )RY (θB )RY (θA ) |xi = RY (θB ) |xi
to Bob
• Bob can now recover |xi by applying RY (−θB )
42 / 100
The quantum one-time pad
X a |xi = |x ⊕ ai
45 / 100
Working with two qubits
• Each of the qubits can be in state |0i or in state |1i
• So for two qubits we have four possibilities:
|0i ⊗ |0i , |0i ⊗ |1i , |1i ⊗ |0i , |1i ⊗ |1i
that we also denote
|0i |0i , |0i |1i , |1i |0i , |1i |1i
or
|00i , |01i , |10i , |11i
• Of course, we can have superpositions so a generic state
is
|ψi = α00 |00i + α01 |01i + α10 |10i + α11 |11i
where αxy are complex numbers such that
1
X
|αxy |2 = 1
x,y=0
46 / 100
Measuring a two-qubit system
47 / 100
Measuring just one qubit in a two-qubit system
• If we have a state
48 / 100
Two-qubit states and vector representation
• A general two-qubit quantum state is
50 / 100
The CNOT gate
51 / 100
Action of the CNOT gate
|xi • |xi
|y i |y ⊕ xi
• This is an extremely important gate for it allows to:
• Create entanglement (more on this soon)
• Copy classical information, because:
|00i → |00i
|10i → |11i
• Construct other controlled gates
52 / 100
Equivalences with CNOT gates
H H
• •
•
53 / 100
Constructing controlled gates by using the CNOT gate
eiθ AXBXC
with ABC = I
• Then, the circuit
• • RZ (θ)
C B A
54 / 100
The no-cloning theorem
• There is no quantum gate that makes copies of an
arbitrary (unknown) qubit
• The proof is easy: suppose we have a gate U such that
U |ψi |0i = |ψi |ψi
• Then U |00i = |00i and U |10i = |11i and by linearity
1 1 1
U √ (|00i+|10i) = √ (U |00i+U |10i) = √ (|00i+|11i)
2 2 2
• But
|00i + |10i |0i + |1i
√ = √ |0i
2 2
so we should have
|00i + |10i (|0i + |1i) (|0i + |1i) 1
U √ = √ √ 6= √ (|00i + |11i)
2 2 2 2
55 / 100
Quantum entanglement: the spooky action at a
distance
56 / 100
Hello, entangled world!
|0i
• Initially, the state of the system is |00i
• After we apply the H gate, the state is
|00i + |10i
√
2
• When we apply the CNOT gate, the state changes to
|00i + |11i
√
2
57 / 100
Hello, entangled world!
|0i H •
|0i
58 / 100
Part V
59 / 100
The CHSH game
• Based in an inequality proposed in 1969 by Clauser,
Horne, Shimony and Holt based on previous work by John
Bell
• Alice and Bob receive bits x and y from a referee
• They have to respond with bits a and b
• They win if
a⊕b =x ·y
• They can decide on a joint strategy beforehand, but they
cannot communicate during the game
60 / 100
Classical strategies for the CHSH game
• Alice and Bob can win 75% of the time if they always
answer ‘0’
• No other deterministic strategy can do better
• And probabilistic strategies are convex combinations of
classical strategies so they cannot improve the 75%
success rate
61 / 100
Quantum strategy for the CHSH game
|0i H • RY ( π2 )
|0i RY ( π4 )
62 / 100
Some comments on the CHSH game
• It can be proved that cos2 ( π8 ) is the highest possible
success rate for a quantum strategy (Tsirelson’s bound)
• The CHSH game can be used to rule out local realism
• Several experiments have been conducted, including:
• Aspect et al. (1981-82)
• Hensen et al. (2005) - Eliminate the locality and detection
loopholes
• All of them agree with the predictions of quantum theory
63 / 100
The GHZ game
• Introduced by Greenberger, Horne and Zeilinger
• A referee selects rst from {000, 011, 101, 110} and sends r
to Alice, s to Bob and t to Charlie
• They produce a, b and c and win if
a⊕b⊕c =r ∨s∨t
• Classically, they can only win with 75% probability
• Quantumly, they can win every single time
• They share the state
1
(|000i − |011i − |101i − |110i)
2
• They apply H to their qubit if the receive 1
• They measure and return the answer
• This is sometimes called “quantum pseudo-telepathy”
(Brassard, Cleve, Tapp)
• Both the CHSH and the GHZ game can be used for
randomness certification (and expansion)
64 / 100
Part VI
65 / 100
Quantum teleportation: Quantum me up, Scotty!
• Can Alice sent a qubit |ψi to Bob it there is no quantum
channel available?
• We are interested in the most general case, even if Alice
does not know which state she has
• The problem can be solved if Alice and Bob share an
entangled state √1 (|00i + |11i)
2
66 / 100
Quantum teleportation: Alice’s part
• Alice and Bob share an entangled state √1 (|00i + |11i)
2
• This can be done in advance
• Or they can rely on a source that distributes entangled pairs
• Alice applies a CNOT gate to the qubit she wants to
teleport |ψi = a |0i + b |1i and to her part of the Bell pair.
We will have
1
√ (a(|000i + |011i) + b(|110i + |101i))
2
• Alice further applies the H gate to the qubit she wants
teleported. Then, we have
1
|00i (a |0i + b |1i) + |01i (b |0i + a |1i)
2
+ |10i (a |0i − b |1i) + |11i (−b |0i + a |1i)
• Alice measures her two qubits and sends the result (two
classical bits) to Bob (through a classical channel)
67 / 100
Quantum teleportation: Bob’s part
68 / 100
Quantum teleportation: some comments
69 / 100
Entanglement swapping
• Quantum teleportation can also be used with entangled
qubits
• Alice shares a Bell pair with Bob and another one with
Charlie
• In the figure, the top and bottom qubits belong to Alice.
The second from the top belongs to Bob and the other to
Charlie
• Alice teleports her top qubit to Charlie
• Now Bob’s and Charlie’s qubits are entangled (although
maybe they were never in direct contact)
Image credits: Created with Quirk. Click here to access the circuit
70 / 100
Gate teleportation
• We can generalize the idea of quantum teleportation to
teleport the action of gates
• With the circuit of the figure, we can apply gate U to an
arbitrary state |ψi
• This is useful if preparing √1 (|0i U |0i + |1i U |1i) and
2
applying UXU † , UZU † , UZXU † are easy compared to
applying U to a general qubit
• Such a situation can happen when U = T in the context of
fault-tolerant quantum computing
|ψi • H •
|0i H • •
|0i U U† Z U
71 / 100
Superdense coding: two for the price of one (more or
less)
72 / 100
Superdense coding: Alice’s part
73 / 100
Superdense coding: Bob’s part
• Bob receives Alice’s qubit
• He applies a CNOT gate controlled by Alice’s qubit
• He applies H to Alice’s qubit
• He measures and recovers b1 and b2
74 / 100
Superdense coding: an example
1 1
√ (|01i − |11i) = √ (|0i − |1i) |1i
2 2
• And with the H gate he gets |11i that now he can measure
75 / 100
Part VII
76 / 100
Deutsch’s algorithm: statement of the problem
• In 1985, David Deutsch proposed a very simple algorithm
that, nevertheless, hints at the capabilities of quantum
computing
• The problem it solves is only of theoretical relevance and
was later generalized in a joint work with Jozsa
• We are given a circuit (an oracle) that implements a
one-bit boolean function and we are asked to determine
whether the function is constant (returns the same value
for all inputs) or balanced (returns 1 on one input and 0 on
the other)
• Alternatively, we can think of the oracle as indexing a bit
string of length two and we are asked to compute the XOR
of the bits of the string
• In the classical case, we would need to consult the oracle
twice, to compute both values of the function
• In the quantum case, we can make just one oracle call...
but in superposition
77 / 100
Deutsch’s algorithm: the oracle
|xi |xi
Of
|y i |y ⊕ f (x)i
78 / 100
Deutsch’s algorithm: the circuit
|0i H H
Of
|1i H
79 / 100
Deutsch’s algorithm: the magic
|0i H H
Of
|1i H
• The initial state is |0i |1i
• After the H the gates we have
(|0i + |1i)(|0i − |1i)
2
which is the same as
|0i (|0i − |1i) |1i (|0i − |1i)
+
2 2
• When we apply the oracle, by linearity we obtain
|0i (|0 ⊕ f (0)i − |1 ⊕ f (0)i) |1i (|0 ⊕ f (1)i − |1 ⊕ f (1)i)
+
2 2
80 / 100
Deutsch’s algorithm: the magic (2)
|0i H H
Of
|1i H
• If f (0) = 0, we have
(−1)f (0) |0i (|0i − |1i) (−1)f (1) |1i (|0i − |1i)
+
2 2
81 / 100
Deutsch’s algorithm: the magic (3)
|0i H H
Of
|1i H
• We can also write that state as
|0i (|0i − |1i) (−1)f (0)+f (1) |1i (|0i − |1i)
+
2 2
• So if f (0) = f (1), we will have
|0i (|0i − |1i) |1i (|0i − |1i) (|0i + |1i)(|0i − |1i)
+ =
2 2 2
and when we apply the last H and measure we obtain 0.
• But if f (0) 6= f (1), the state is
|0i (|0i − |1i) |1i (|0i − |1i) (|0i − |1i)(|0i − |1i)
− =
2 2 2
and, then, we obtain 1.
82 / 100
Deutsch’s algorithm: some comments
• When we apply the oracle we have a phase kickback: we
only act on one qubit, but it affects the whole state
• Deutch’s algorithm exploits an interference phenomenon
similar to that found in some physical experiments
(double-slit experiment, Mach-Zehnder interferometer)
83 / 100
Part VIII
84 / 100
n-qubit systems
• Each of the n qubits can be in state |0i and |1i
• Thus, for the n-qubit state we have 2n possibilities:
or simply
|0i , |1i , . . . , 2n − 1
85 / 100
Measuring a n-qubit state
86 / 100
Measuring one qubit in a n-qubit state
• We have
87 / 100
n-qubit quantum gates
• A n-qubit state is
• We can represent it by
α0
α1
α2
..
.
α2n −1
|xi • |xi
|y i • |y i
|zi |z ⊕ (x ∧ y)i
• The Toffoli gate is universal for classical logic, and thus
any classical circuit can be simulated with a quantum
circuit
• However, the Toffoli gate, on its own, is not universal for
quantum computing (and it is not even necessary,
because it can be simulated with one and two-qubit gates)
89 / 100
Universal gates in quantum computing
Theorem
The one-qubit gates together with the CNOT gate are universal
for quantum computing
Theorem
The gates X , H, T and CNOT are universal for quantum
computing
90 / 100
Gate equivalences
Z = H X H
S = T T
Y = Z X S X S X
T† = S S S T
S† = S S S
91 / 100
Equivalence of the Toffoli gate
H T† T T† T H
• • T T†
• • • T •
92 / 100
Part IX
93 / 100
Urban legends about quantum parallelism
• But... don’t quantum computers try all 2n possibilities in
parallel?
• The answer is... yes and no (this is quantum computing
after all!)
94 / 100
Evaluating a function: querying the oracle
|xi |xi
Of
|yi |y ⊕ f (x)i
95 / 100
Evaluating a function in parallel: the superposition
hocus-pocus
• Suppose that we have an oracle Of for a function f (x) with
a one-bit input
• We know that, using the H gate, we can put a qubit in
superposition
• If we start with the state |0i |0i and we apply H on the first
qubit, we will have
1 1
√ |0i |0i + √ |1i |0i
2 2
• If we now apply Of , by linearity we have
1 1
√ |0i |f (0)i + √ |1i |f (1)i
2 2
• We have evaluated the function on two different inputs with
just one call!
96 / 100
Evaluating a function in parallel: the tensor-product
abracadabra
97 / 100
Evaluating a function in parallel: the tensor-product
abracadabra (2)
• If we expand the product we get
n2 −1
(|0 . . . 0i + |0 . . . 1i + . . . + |1 . . . 1i) |0i 1 X
√ =√ |xi |0i
2n 2n x=0
• And, when we apply the oracle, we will get the state
n
2 −1
1 X
√ |xi |f (x)i
2n x=0
• An exponential number of function evaluations with just
one call!
H
|0i⊗n H
Of
H
|0i 98 / 100
All that glitters ain’t gold
• And now... how do we retrieve the values f (x)?
• To obtain a result, we need to perform a measurement
• But then we will get a state of the form
|ci |f (c)i
• That is, we only obtain the result of the function for a
randomly chosen input (this may be even worse than
classically evaluating the function)
Image credits: The Talk, by Scott Aaronson and Zach Weinersmith 99 / 100
Interferences come to the rescue
• How can we use the 2n evaluations to extract useful
information?
• One possibility is... to produce interferences!
• The amplitudes of some states can be negative
• If we manage to “annihilitate” the amplitudes of states we
are not interested in, the probability of obtaining the
answer that we need will grow
• This is, in general, no easy task, but we know how to
achieve it in some interesting cases
Image credits: The Talk, by Scott Aaronson and Zach Weinersmith 100 / 100