Quantum Computation (Lecture QC-3: Quantum Algorithms) Lu s Soares - - PowerPoint PPT Presentation
Quantum Computation (Lecture QC-3: Quantum Algorithms) Lu s Soares - - PowerPoint PPT Presentation
Quantum Computation (Lecture QC-3: Quantum Algorithms) Lu s Soares Barbosa MFES - Arquitectura e C alculo May 2019 Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover A quantum machine Structure of a quantum
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
A quantum machine
Structure of a quantum algorithm
- 1. State preparation (fix initial setting): typically the qubits in the
initial classical state are put into a superposition of many states;
- 2. Transform, through unitary operators applied to the superposed
state;
- 3. Measure, i.e. projection onto a basis vector associated with a
measurement tool.
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
My first quantum program
Is f : 2 − → 2 constant, with a unique evaluation?
Oracle
|x⟩ Uf |x⟩ |y⟩ |y ⊕ f (x)⟩
where ⊕ stands for exclusive disjunction.
- The oracle takes input |x, y to |x, y ⊕ f (x)
- for y = 0 the output is |x, f (x)
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
My first quantum program
Is f : 2 − → 2 constant, with a unique evaluation?
Oracle
- The oracle is a unitary, i.e. reversible gate
|x⟩ Uf |x⟩ Uf |x⟩ |y⟩ |y ⊕ f (x)⟩ |y⟩
|x, (y ⊕ f (x)) ⊕ f (x) = |x, y ⊕ (f (x) ⊕ f (x)) = |x, y ⊕ 0 = |x, y
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
My first quantum program
Idea: Avoid double evaluation by superposition
|x⟩ Uf |1⟩ H
- The circuit computes:
- utput = |x|0 ⊕ f (x) − |1 ⊕ f (x)
√ 2 =
- |x |0−|1
√ 2
⇐ f (x) = 0 |x |1−|2
√ 2
⇐ f (x) = 1 = (−1)f (x) |x|0 − |1 √ 2
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
My first quantum program
Idea: Avoid double evaluation by superposition
|0⟩ H Uf H
- |1⟩
H
(H ⊗ I) Uf (H ⊗ H)(|01) Input in superposition |σ1 = |0 + |1 √ 2 |0 − |1 √ 2 = |00 − |01 + |10 − |11 2
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
My first quantum program
|σ2 = (−1)f (0)|0 + (−1)f (1)|1 √ 2 |0 + |1 √ 2
- =
(+1)
- |0+|1
√ 2 |0−|1 √ 2
- ⇐ f constant
(+1)
- |0−|1
√ 2 |0−|1 √ 2
- ⇐ f not constant
|σ3 = H|σ2 = (+1) |0
- |0−|1
√ 2
- ⇐ f constant
(+1) |1
- |0−|1
√ 2
- ⇐ f not constant
To answer the original problem is now enough to measure the first qubit: if it is in state |0, then f is constant.
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
The Deutsch-Jozsa Algorithm
Generalizing Deutsch’s algorithm to functions whose domain is an initial segment n of N, encoded into a binary string (i.e. the set of natural numbers from 0 to 2n − 1. Assuming f : 2n − → 2 is either balanced or constant, determine which is the case with a unique evaluation
Oracle
|x⟩ /n Uf /n |x⟩ |y⟩ | f (x) ⊕ y⟩
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Using H⊗n to put n qubits superposed
Computing H⊗n
H = 1 √ 2 (−1)0∧0 (−1)0∧1 (−1)1∧0 (−1)1∧1
- H⊗2 =
1 √ 2 (−1)0∧0 (−1)0∧1 (−1)1∧0 (−1)1∧1
- ⊗ 1
√ 2 (−1)0∧0 (−1)0∧1 (−1)1∧0 (−1)1∧1
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Using H⊗n to put n qubits superposed
Computing H⊗n
H⊗2 = 1 √ 2
- (−1)0∧0
(−1)0∧1 (−1)1∧0 (−1)1∧1
- ⊗ 1
√ 2
- (−1)0∧0
(−1)0∧1 (−1)1∧0 (−1)1∧1
- =
1 2 (−1)00,00 (−1)00,01 (−1)01,00 (−1)01,01 (−1)00,10 (−1)00,11 (−1)01,10 (−1)01,11 (−1)10,00 (−1)10,01 (−1)11,00 (−1)11,01 (−1)10,10 (−1)10,11 (−1)11,10 (−1)11,11 where x, y = (x0 ∧ y0) ⊕ (x1 ∧ y1) ⊕ · · · ⊕ (xn ∧ yn) Note that (−1)a∧b ⊗ (−1)a ′∧b ′ = (−1)a∧a ′⊕b∧b ′ = (−1)aa ′,bb ′
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Using H⊗n to put n qubits superposed
Computing H⊗n
In general, the value of H⊗n at coordinates i, j (row and column numbers as binary strings) is given by H⊗n
i,j
= 1 √ 2n (−1)i,j Applying H⊗n to an arbitrary basic state |i (which is a column vector with 1 in line i and 0 everywhere else), extracts the i-column of H⊗n: H⊗n|i = 1 √ 2n
- x∈{0,1}n
(−1)x,i|x e.g. H⊗2|0 = 1 2 1 1 1 1 1 −1 1 −1 1 1 −1 −1 1 −1 −1 1 1 = 1 2 1 1 1 1 = 1 2
- x∈{0,1}n
|x
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
First move: Uf (I ⊗ H)|x, 1
|x⟩ /n Uf /n
- |1⟩
H ⇑ |ϕ0⟩ ⇑ |ϕ1⟩ ⇑ |ϕ2⟩ (6.65)
|ϕ1 = |x|0 − |1 √ 2 = |x, 0 − |x1 √ 2 |ϕ2 = |x|f (x) ⊕ 0 − |f (x) ⊕ 1 √ 2 = (−1)f (x)|x|0 − |1 √ 2
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Second move: (H⊗n ⊗ I)Uf (H⊗n ⊗ H)|0, 1
Put input |x into a superposition in which all 2n possible strings have equal probability: H⊗n|0.
|0⟩ /n H⊗n /n Uf /n H⊗n /n |1⟩ H ⇑ |ϕ0⟩ ⇑ |ϕ1⟩ ⇑ |ϕ2⟩ ⇑ |ϕ3⟩
|ϕ1 =
- x∈{0,1}n |x
√ 2n |0 − |1 √ 2 |ϕ2 =
- x∈{0,1}n (−1)f (x)|x
√ 2n |0 − |1 √ 2
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Second move: (H⊗n ⊗ I)Uf (H⊗n ⊗ H)|0, 1
|0⟩ /n H⊗n /n Uf /n H⊗n /n |1⟩ H ⇑ |ϕ0⟩ ⇑ |ϕ1⟩ ⇑ |ϕ2⟩ ⇑ |ϕ3⟩
|ϕ3 =
- x∈{0,1}n (−1)f (x)
z∈{0,1}n (−1)z,x|z
√ 2n |0 − |1 √ 2 =
- x,z∈{0,1}n (−1)f (x)(−1)z,x|z
√ 2n |0 − |1 √ 2 =
- x,z∈{0,1}n (−1)f (x)⊕z,x|z
√ 2n |0 − |1 √ 2
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Finally: observe!
When do the top qubits of |ϕ3 collapse to |0?
Making |z = |0 (and thus z, x = 0 for all x) leads to |ϕ3 =
- x∈{0,1}n (−1)f (x)|0
√ 2n |0 − |1 √ 2 i.e. the probability of collapsing to |0 depends only on f (x)
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Finally: observe!
Analyse the top qubits
f is constant at 1
- x∈{0,1}n (−1)|0
√ 2n
=
−(2n)|0 2n
= −|0 f is constant at 0
- x∈{0,1}n 1|0
√ 2n
=
(2n)|0 2n
= |0 f is balanced
- x∈{0,1}n (−1)f (x)|0
√ 2n
=
0|0 2n
= 0|0 because half of the x will cancel the other half The top qubits collapse to |0 only if f is constant Exponential speed up: f was evaluated once rather than 2n − 1 times
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Search problems
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Search problems
A more precise formulation
Given a function f : 2n − → 2 such that there exsits a unique binary string x∗ st f (x) =
- 1
⇐ x = x∗ ⇐ x = x∗ determine e.
A quadratic speed up
- Worst case for a classic algorithm: 2n evaluations of f
- Worst case for Grover’s algorithm:
√ 2n evaluations of f
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Grover’s algorithm
Oracle Uf inverts the phase at |x∗
Recall from Deutsch-Josza:
|x⟩ /n Uf /n
- |1⟩
H ⇑ |ϕ0⟩ ⇑ |ϕ1⟩ ⇑ |ϕ2⟩ (6.65)
|ϕ2 = (−1)f (x)|x|0 − |1 √ 2 =
- −|x |0−|1
√ 2
⇐ x = x∗ +|x |0−|1
√ 2
⇐ x = x∗
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Grover’s algorithm
Oracle Uf inverts the phase at |x∗
Thus, providing as input a balanced superposition of all possible states, via H⊗n|0, the oracle is able to detect the solution and shift its phase:
- However, the probability of collapsing to |x∗ is equal to the one of
collapsing to any other basic state becase | − 1 √ 2n |2 = | − 1 √ 2n |2
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Boosting the phase separation
The trick: Inversion around the mean
- e ′ = mean + (mean − e) ⇔ e ′ = −e + 2mean
Computing the mean (example)
1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5
53 38 17 23 79 = 42 42 42 42 42
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Boosting the phase separation
The trick: Inversion around the mean
For A the grid matrix, V ′ = −V + 2AV = (−I + 2A)V multiplying any state by (−I + 2A) inverts amplitudes around the mean.
Healthiness test
Operator (−I + 2A) is unitary, because
- (−I + 2A)† = (−I + 2A)
- (−I + 2A) (−I + 2A) = I − 2A − 2A + 4A2 = I − 4A + 4A = I
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Combining effects over time to amplify the right phase
Example
- Start with [10, 10, 10, 10, 10]T
- Invert the fourth entry: [10, 10, 10, −10, 10]T
- Invert around mean (6): [2, 2, 2, 22, 2]T
Note 22 − 2 = 20
- Invert the fourth entry again: [2, 2, 2, −22, 2]T
- Invert around mean (−2.8): [−7.6, −7.6, −7.6, 16.4, −7.6]T
Note 16.4 + 7.6 = 24.
- ...
The right phase is amplified in successive iterations
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Combining effects to amplify the right phase
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Combining effects to amplify the right phase
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Grover’s algorithm
Repeat √ 2n times Phase inversion Inversion about mean |0⟩ /n H⊗n /n Uf /n −I + 2A /n
- |1⟩
H ⇑ ⇑ ⇑ ⇑
- Questions
- Why
√ 2n iterations?
- How to implement the oracle?
- Generalizations?
e.g. multiple search requires
- 2n
t iterations for t the multiplicity
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Grover’s algorithm is everywhere
SAT (= Boolean satisfiability) problems
Determining values for Boolean variables so that a given Boolean expression evaluates to true
- NP-complete
- Many problems, like scheduling, can be converted into a SAT
- Can be seen as a search problem whose goal is to find a precise
combination of Boolean values that yields true
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Second thoughts
Creating a uniform superposition of all basis states does not allow to satisfactorily solve NP-complete problems Let Uf encode a SAT formula on n Boolean variables: Uf (|i ⊗ |0) = |i ⊗ |f (i) Applying Uf to a superposition obtained via H⊗n|0, which evaluates the truth assignment of all possible binary strings, will return a binary string that satisfies the formula iff the last qubit has value 1 after the measurement, and this happens with a probability that depends on the number of binary assignments that satisfy the formula (e.g.
τ 2n , for τ such assignments).
Quantum Algorithms The Deutsch-Jozsa Algorithm Quantum Search: Grover
Second thoughts
Although, in general, solving NP-hard problems in polynomial time with quantum computers is probably not possible (cf P = NP?), there is a recipe to produce faster equivalent quantum algorithms:
- Create a uniform superposition of basis states
- Make the basis states interact with each other so that the modulus
- f the coefficients for some (desirable) basis states increase, which
implies that the other coefficients decrease.
- How to do it ... depends on the problem