0% found this document useful (0 votes)
36 views38 pages

Lecture 4.1 - Quantum Query Algorithms

The document summarizes Deutsch's algorithm, which solves Deutsch's problem of determining if a function f from {0,1} to {0,1} is constant or balanced using only one query. Deutsch's problem normally requires 2 queries for a classical algorithm. Deutsch's algorithm applies a Hadamard gate to input qubits, applies the query gate Uf, measures the qubits to obtain the answer - 0 if the function is constant or 1 if it is balanced. The algorithm is able to solve the problem with only one query using quantum interference.

Uploaded by

hu jack
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
36 views38 pages

Lecture 4.1 - Quantum Query Algorithms

The document summarizes Deutsch's algorithm, which solves Deutsch's problem of determining if a function f from {0,1} to {0,1} is constant or balanced using only one query. Deutsch's problem normally requires 2 queries for a classical algorithm. Deutsch's algorithm applies a Hadamard gate to input qubits, applies the query gate Uf, measures the qubits to obtain the answer - 0 if the function is constant or 1 if it is balanced. The algorithm is able to solve the problem with only one query using quantum interference.

Uploaded by

hu jack
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 38

Overview

Contents

1. The query model of computation


2. Deutsch’s algorithm
3. The Deutsch-Jozsa algorithm
4. Simon’s algorithm
A standard picture of computation
A standard abstraction of computation looks like this:

input computation output

Different specific models of computation are studied, including


Turing machines and Boolean circuits.

Key point

The entire input is provided to the computation — most typically as a


string of bits — with nothing being hidden from the computation.
The query model of computation
In the query model of computation, the input is made available in the form of a
function, which the computation accesses by making queries.

input

⋯ queries

computation output

We often refer to the input as being provided by an oracle or black box.


The query model of computation
Throughout this lesson, the input to
query problems is represented by a input
function
n
f∶Σ →Σ
m ⋯ queries

where n and m are positive integers


and Σ = {0, 1}. computation output

Queries

To say that a computation makes a query means that it evaluates the


n m
function f once: x ∈ Σ is selected, and the string f(x) ∈ Σ is made
available to the computation.

We measure the efficiency of query algorithms by counting the


number of queries to the input they require.
Examples of query problems
Or
n
Input: f∶Σ →Σ
n
Output: 1 if there exists a string x ∈ Σ for which f(x) = 1
0 if there is no such string

Parity
n
Input: f∶Σ →Σ
n
Output: 0 if f(x) = 1 for an even number of strings x ∈ Σ
n
1 if f(x) = 1 for an odd number of strings x ∈ Σ

Minimum
n m
Input: f∶Σ →Σ
n
Output: The string y ∈ {f(x) ∶ x ∈ Σ } that comes first in the
m
lexicographic ordering of Σ
Examples of query problems
Sometimes we also consider query problems where we have a promise on the
input. Inputs that don’t satisfy the promise are considered as “don’t care”
inputs.

Unique search
n
Input: f∶Σ →Σ
n
Promise: There is exactly one string z ∈ Σ for which f(z) = 1,
with f(x) = 0 for all strings x =
/z
Output: The string z

Or, Parity, Minimum, and Unique search are all very “natural” examples of query
problems — but some query problems of interest aren’t like this.

We sometimes consider very complicated and highly contrived problems, to look


for extremes that reveal potential advantages of quantum computing.
Query gates
For circuit models of computation, queries are made by query gates.

For Boolean circuits, query gates generally compute the input function f directly.




⎪ ⎫

⎪ ⎪

x ⎪

⎪ f ⎬
⎪ f(x)

⎪ ⎪


⎪ ⎭

For example, the following circuit computes Parity for every f ∶ Σ → Σ.

0 f ∧
¬

¬
1 f ∧
Query gates
For the quantum circuit model, we choose a different definition for query gates
that makes them unitary — allowing them to be applied to quantum states.

Definition
n m
The query gate Uf for any function f ∶ Σ →Σ is defined as

Uf (∣y⟩∣x⟩) = ∣y ⊕ f(x)⟩∣x⟩

n m
for all x ∈ Σ and y ∈ Σ .

Notation
The string y ⊕ f(x) is the bitwise XOR of y and f(x). For example:

001 ⊕ 101 = 100


Query gates
For the quantum circuit model, we choose a different definition for query gates
that makes them unitary — allowing them to be applied to quantum states.

Definition
n m
The query gate Uf for any function f ∶ Σ →Σ is defined as

Uf (∣y⟩∣x⟩) = ∣y ⊕ f(x)⟩∣x⟩

n m
for all x ∈ Σ and y ∈ Σ .

In circuit diagrammatic form Uf operates like this:

∣x⟩ ∣x⟩
Uf
∣y⟩ ∣y ⊕ f(x)⟩

This gate is always unitary, for any choice of the function f.


Deutsch’s problem
Deutsch’s problem is very simple — it’s the Parity problem for functions of the
form f ∶ Σ → Σ.

There are four functions of the form f ∶ Σ → Σ:

a f1 (a) a f2 (a) a f3 (a) a f4 (a)


0 0 0 0 0 1 0 1
1 0 1 1 1 0 1 1

The functions f1 and f4 are constant while f2 and f3 are balanced.

Deutsch’s problem

Input: f∶Σ→Σ
Output: 0 if f is constant, 1 if f is balanced
Deutsch’s problem
Deutsch’s problem

Input: f∶Σ→Σ
Output: 0 if f is constant, 1 if f is balanced

Every classical query algorithm must make 2 queries to f to solve this problem —
learning just one of two bits provides no information about their parity.

Our query algorithm from earlier is therefore optimal among classical query
algorithms for this problem.

0 f ∧
¬

¬
1 f ∧
Deutsch’s algorithm
Deutsch’s algorithm solves Deutsch’s problem using a single query.

0 if f is constant
∣0⟩ H H {
1 if f is balanced
Uf
∣1⟩ H

∣π1 ⟩ ∣π2 ⟩ ∣π3 ⟩

1 1
∣π1 ⟩ = ∣−⟩∣+⟩ = (∣0⟩ − ∣1⟩)∣0⟩ + (∣0⟩ − ∣1⟩)∣1⟩
2 2
1 1
∣π2 ⟩ = (∣0 ⊕ f(0)⟩ − ∣1 ⊕ f(0)⟩)∣0⟩ + (∣0 ⊕ f(1)⟩ − ∣1 ⊕ f(1)⟩)∣1⟩
2 2
1 f(0) 1 f(1)
= (−1) (∣0⟩ − ∣1⟩)∣0⟩ + (−1) (∣0⟩ − ∣1⟩)∣1⟩
2 2
f(0) f(1)
(−1) ∣0⟩ + (−1) ∣1⟩
= ∣−⟩ ( √ )
2
Deutsch’s algorithm
Deutsch’s algorithm solves Deutsch’s problem using a single query.

0 if f is constant
∣0⟩ H H {
1 if f is balanced
Uf
∣1⟩ H

∣π1 ⟩ ∣π2 ⟩ ∣π3 ⟩

f(0) f(1)
(−1) ∣0⟩ + (−1) ∣1⟩
∣π2 ⟩ = ∣−⟩ ( √ )
2
f(0)⊕f(1)
f(0) ∣0⟩ + (−1) ∣1⟩
= (−1) ∣−⟩( √ )
2

⎪ f(0)
⎪(−1) ∣−⟩∣+⟩ f(0) ⊕ f(1) = 0
=⎪



⎪(−1)
f(0)
∣−⟩∣−⟩ f(0) ⊕ f(1) = 1

Deutsch’s algorithm
Deutsch’s algorithm solves Deutsch’s problem using a single query.

0 if f is constant
∣0⟩ H H {
1 if f is balanced
Uf
∣1⟩ H

∣π1 ⟩ ∣π2 ⟩ ∣π3 ⟩


⎪ f(0)
⎪(−1) ∣−⟩∣+⟩ f(0) ⊕ f(1) = 0
∣π2 ⟩ = ⎪



⎪(−1)
f(0)
∣−⟩∣−⟩ f(0) ⊕ f(1) = 1


⎪ f(0)
⎪(−1) ∣−⟩∣0⟩ f(0) ⊕ f(1) = 0
∣π3 ⟩ = ⎪



⎪(−1)
f(0)
∣−⟩∣1⟩ f(0) ⊕ f(1) = 1

f(0)
= (−1) ∣−⟩∣f(0) ⊕ f(1)⟩
Phase kickback
0 if f is constant
∣0⟩ H H {
1 if f is balanced
Uf
∣1⟩ H

c
∣b ⊕ c⟩ = X ∣b⟩
f(a)
Uf (∣b⟩∣a⟩) = ∣b ⊕ f(a)⟩∣a⟩ = (X ∣b⟩)∣a⟩
f(a) f(a)
Uf (∣−⟩∣a⟩) = (X ∣−⟩)∣a⟩ = (−1) ∣−⟩∣a⟩

f(a) phase
Uf (∣−⟩∣a⟩) = (−1) ∣−⟩∣a⟩ ⟵
kickback
Phase kickback
0 if f is constant
∣0⟩ H H {
1 if f is balanced
Uf
∣1⟩ H

∣π1 ⟩ ∣π2 ⟩ ∣π3 ⟩

f(a) phase
Uf (∣−⟩∣a⟩) = (−1) ∣−⟩∣a⟩ ⟵
kickback

∣π1 ⟩ = ∣−⟩∣+⟩
1 1
∣π2 ⟩ = Uf (∣−⟩∣+⟩) = √ Uf (∣−⟩∣0⟩) + √ Uf (∣−⟩∣1⟩)
2 2
f(0) f(1)
(−1) ∣0⟩ + (−1) ∣1⟩
= ∣−⟩( √ )
2
The Deutsch-Jozsa circuit
The Deutsch-Jozsa algorithm extends Deutsch’s algorithm to input functions of
n
the form f ∶ Σ → Σ for any n ≥ 1.

The quantum circuit for the Deutsch-Jozsa algorithm looks like this:

∣0⟩ H H ⎫











∣0⟩ H H ⎪




⎪ n

⎪ y∈Σ


Uf ⎪











∣0⟩ H H ⎪

∣1⟩ H

We can, in fact, use this circuit to solve multiple problems.


The Deutsch-Jozsa problem
The Deutsch-Jozsa problem generalizes Deutsch’s problem: for an input function
n
f ∶ Σ → Σ, the task is to output 0 if f is constant and 1 if f is balanced.
n
When n ≥ 2, some functions f ∶ Σ → Σ are neither constant nor balanced.
Example

This function is neither constant nor balanced:

x f(x)
00 0
01 0
10 0
11 1

Input functions that are neither constant nor balanced are “don’t care” inputs.
The Deutsch-Jozsa problem
The Deutsch-Jozsa problem generalizes Deutsch’s problem: for an input function
n
f ∶ Σ → Σ, the task is to output 0 if f is constant and 1 if f is balanced.

Deutsch-Jozsa problem
n
Input: f∶Σ →Σ
Promise: f is either constant or balanced
Output: 0 if f is constant, 1 if f is balanced
The Deutsch-Jozsa problem
Deutsch-Jozsa problem
n
Input: f∶Σ →Σ
Promise: f is either constant or balanced
Output: 0 if f is constant, 1 if f is balanced

∣0⟩ H H ⎫











∣0⟩ H H ⎪




⎪ n

⎪ y∈Σ




Uf ⎪











∣0⟩ H H ⎭

∣1⟩ H

n
Output: 0 if y = 0 and 1 otherwise.
Deutsch-Jozsa analysis
The Hadamard operation works like this on standard basis states:

1 1
H∣0⟩ = √ ∣0⟩ + √ ∣1⟩
2 2
1 1
H∣1⟩ = √ ∣0⟩ − √ ∣1⟩
2 2

We can express these two equations as one:

1 1 a 1 ab
H∣a⟩ = √ ∣0⟩ + √ (−1) ∣1⟩ = √ ∑ (−1) ∣b⟩
2 2 2 b∈{0,1}
Deutsch-Jozsa analysis
The Hadamard operation works like this on standard basis states:

1 ab
H∣a⟩ = √ ∑ (−1) ∣b⟩
2 b∈{0,1}

Now suppose we perform a Hadamard operation on each of n qubits:

⊗n
H ∣xn−1 ⋯x1 x0 ⟩
= (H∣xn−1 ⟩) ⊗ ⋯ ⊗ (H∣x0 ⟩)
1 xn−1 yn−1 1 x y
= (√ ∑ (−1) ∣yn−1 ⟩) ⊗ ⋯ ⊗ ( √ ∑ (−1) 0 0 ∣y0 ⟩)
2 yn−1 ∈Σ 2 y0 ∈Σ
1 xn−1 yn−1 +⋯+x0 y0
= √ ∑ (−1) ∣yn−1 ⋯y0 ⟩
2n yn−1 ⋯y0 ∈Σn
Deutsch-Jozsa analysis
⊗n
H ∣xn−1 ⋯x1 x0 ⟩
1 xn−1 yn−1 +⋯+x0 y0
= √ ∑ (−1) ∣yn−1 ⋯y0 ⟩
2n yn−1 ⋯y0 ∈Σn

⊗n 1 x⋅y
H ∣x⟩ = √ ∑ (−1) ∣y⟩
2n y∈Σn

Binary dot product

For binary strings x = xn−1 ⋯x0 and y = yn−1 ⋯y0 we define

x ⋅ y = xn−1 yn−1 ⊕ ⋯ ⊕ x0 y0


⎪1 if xn−1 yn−1 + ⋯ + x0 y0 is odd
=⎪



⎪ 0 if xn−1 yn−1 + ⋯ + x0 y0 is even

Deutsch-Jozsa analysis
⊗n 1 x⋅y
H ∣x⟩ = √ ∑ (−1) ∣y⟩
2n y∈Σn

∣0⟩ H H

∣0⟩ H H

Uf

∣0⟩ H H

∣1⟩ H

∣π1 ⟩

1
∣π1 ⟩ = ∣−⟩ ⊗ √ ∑ ∣x⟩
2n x∈Σn
Deutsch-Jozsa analysis
⊗n 1 x⋅y
H ∣x⟩ = √ ∑ (−1) ∣y⟩
2n y∈Σn

∣0⟩ H H

∣0⟩ H H

Uf

∣0⟩ H H

∣1⟩ H

∣π2 ⟩

1 f(x)
∣π2 ⟩ = ∣−⟩ ⊗ √ ∑ (−1) ∣x⟩
2n x∈Σn
Deutsch-Jozsa analysis
⊗n 1 x⋅y
H ∣x⟩ = √ ∑ (−1) ∣y⟩
2n y∈Σn

∣0⟩ H H

∣0⟩ H H

Uf

∣0⟩ H H

∣1⟩ H

∣π3 ⟩

1 f(x)+x⋅y
∣π3 ⟩ = ∣−⟩ ⊗ ∑ ∑ (−1) ∣y⟩
2n n n
y∈Σ x∈Σ
Deutsch-Jozsa analysis
n
The probability for the measurements to give y = 0 is

»» »»2
» 1 f(x) »» 1 if f is constant
p(0 ) = »»»» n ∑ (−1) »» = {
n
»» 2 x∈Σn »» 0 if f is balanced
» »»

The Deutsch-Jozsa algorithm therefore solves the Deutsch-Jozsa problem


without error with a single query.

Any deterministic algorithm for the Deutsch-Jozsa problem must at least


n−1
2 + 1 queries.

A probabilistic algorithm can, however, solve the Deutsch-Jozsa problem using


just a few queries:
1 k n
1. Choose k input strings x , . . . , x ∈ Σ uniformly at random.
1 k
2. If f(x ) = ⋯ = f(x ), then answer 0 (constant), else answer 1 (balanced).

If f is constant, this algorithm is correct with probability 1.


−k+1
If f is balanced, this algorithm is correct with probability 1 − 2 .
The Bernstein-Vazirani problem
Bernstein-Vazirani problem
n
Input: f∶Σ →Σ
Promise: there exists a binary string s = sn−1 ⋯s0 for which
n
f(x) = s ⋅ x for all x ∈ Σ
Output: the string s

∣0⟩ H H ⎫











∣0⟩ H H ⎪






⎪ s




Uf ⎪











∣0⟩ H H ⎭

∣1⟩ H

∣π3 ⟩
The Bernstein-Vazirani problem
1 f(x)+x⋅y
∣π3 ⟩ = ∣−⟩ ⊗ ∑ ∑ (−1) ∣y⟩
2n n n
y∈Σ x∈Σ
1 s⋅x+y⋅x
= ∣−⟩ ⊗ n ∑ ∑ (−1) ∣y⟩
2 n ny∈Σ x∈Σ
1 (s⊕y)⋅x
= ∣−⟩ ⊗ n ∑ ∑ (−1) ∣y⟩
2 n ny∈Σ x∈Σ

= ∣−⟩ ⊗ ∣s⟩

The Deutsch-Jozsa circuit therefore solves the Bernstein-Vazirani problem with


a single query.

Any probabilistic algorithm must make at least n queries to find s.


Simon’s problem
Simon’s problem
n m
Input: A function f ∶ Σ →Σ
n
Promise: There exists a string s ∈ Σ such that

[f(x) = f(y)] ⇔ [(x = y) or (x ⊕ s = y)]

n
for all x, y ∈ Σ
Output: The string s

n
Case 1: s = 0

The condition in the promise simplifies to

[f(x) = f(y)] ⇔ [x = y]

This is equivalent to f being one-to-one.


Simon’s problem
n
Case 2: s =
/0

The function f must be two-to-one to satisfy the promise:

f(x) = f(x ⊕ s)

with distinct output strings for each pair.

x f(x)
s = 011
000 10011
001 00101 f(000) = f(011) = 10011
010 00101
f(001) = f(010) = 00101
011 10011
100 11010 f(100) = f(111) = 11010
101 00001 f(101) = f(110) = 00001
110 00001
111 11010
Simon’s algorithm
Simon’s algorithm consists of running the following circuit several times,
followed by a post-processing step.

∣0⟩ H H ⎫











∣0⟩ H H ⎪




⎪ n

⎪ y∈Σ














∣0⟩ H Uf H ⎪

∣0⟩
∣0⟩

∣0⟩
Simon’s algorithm analysis
∣0⟩ H H ⎫











∣0⟩ H H ⎪




⎪ n

⎪ y∈Σ














∣0⟩ H Uf H ⎪

∣0⟩
∣0⟩

∣0⟩

∣π1 ⟩ ∣π2 ⟩ ∣π3 ⟩

1 m
∣π1 ⟩ = √ ∑ ∣0 ⟩∣x⟩
2n x∈Σn
1
∣π2 ⟩ = √ ∑ ∣f(x)⟩∣x⟩
2n x∈Σn

1 ⎛ 1 x⋅y ⎞ 1 x⋅y
∣π3 ⟩ = √ ∑ ∣f(x)⟩ ⊗ ⎜ √ ∑ (−1) ∣y⟩⎟ = n ∑ ∑ (−1) ∣f(x)⟩∣y⟩
2n x∈Σn ⎝ 2n y∈Σn ⎠ 2
y∈Σn x∈Σn
Simon’s algorithm analysis
1 x⋅y
∑ ∑ (−1) ∣f(x)⟩∣y⟩
2n n n y∈Σ x∈Σ

Â
 Â
 2
 1 Â
p(y) = Â
 ∣f(x)⟩Â
Â
x⋅y
Â
 n ∑ (−1) Â
Â
Â
 2 Â
Â
 x∈Σn Â
Â
 Â
 2
Â
 1 ⎛ ⎞ Â
Â
=ÂÂ ∑ ⎜ ⎜ ∑ (−1) ⎟
Â
⎟ ∣z⟩Â
x⋅y
 2n
 Â
Â
Â
 z∈range(f) ⎝x∈f−1 (z) ⎠ Â
Â
Â
 Â
Â
»» »»2
»» »
=
1
∑ »» ∑ (−1)x⋅y »»»
»» »»
22n »
z∈range(f) »»x∈f−1 ({z})
»»
» »»

n
range(f) = {f(x) ∶ x ∈ Σ }
−1 n
f ({z}) = {x ∈ Σ ∶ f(x) = z}
Simon’s algorithm analysis
»» »»2
»» »
p(y) =
1
∑ »» ∑ (−1)x⋅y »»»
»» »»
22n »
z∈range(f) »»x∈f−1 ({z})
»»
» »»

n
Case 1: s = 0
−1
Because f is a one-to-one, there a single element x ∈ f ({z}) for every z ∈ range(f):

»» »»»2
»»
»» ∑ (−1)x⋅y »»» = 1
»» »»
»» −1 »»
»»x∈f ({z}) »»

n
There are 2 elements in range(f), so

1 n 1
p(y) = ⋅2 = n
22n 2
n
(for every y ∈ Σ ).
Simon’s algorithm analysis
»» »»2
»» »
p(y) =
1
∑ »» ∑ (−1)x⋅y »»»
»» »»
22n »
z∈range(f) »»x∈f−1 ({z})
»»
» »»

n
Case 2: s =
/0
−1 −1
There are two strings in the set f ({z}) for each z ∈ range(f); if w ∈ f ({z}) either one
of them, then w ⊕ s is the other.

»» »»2
»» »
»» ∑ (−1)x⋅y »»» = »»»(−1)w⋅y + (−1)(w⊕s)⋅y »»»2 = »»»1 + (−1)s⋅y »»»2 = {4 s ⋅ y = 0
»» »» »»» »» »»» »»
»» −1 »» » » 0 s⋅y=1
»»x∈f ({z}) »»

n−1
There are 2 elements in range(f), so

»» »»2 ⎧ 1
»» » ⎪ n−1 s⋅y=0
p(y) =
1
∑ »» ∑ (−1)x⋅y »»» = ⎪⎪
⎨ 2
»» »» ⎪
22n »
»
z∈range(f) »x∈f ({z})
»
» ⎪0
⎪ s⋅y=1
»
−1 »» ⎩
Classical post-processing
n
Running the circuit from Simon’s algorithm one time gives us a random string y ∈ Σ .
n n
Case 1: s = 0 Case 2: s =
/0


⎪ 1
s⋅y=0
1 ⎪ 2n−1
p(y) = p(y) = ⎪

⎪0
2n ⎪
⎪ y⋅s=1

1 k
Suppose we run the circuit independently k = n + r times, obtaining strings y , . . . , y .

1 1 1 1 1
y = yn−1 ⋯ y0 ⎛yn−1 ⋯ y0 ⎞ ⎛0⎞

⎜ 2⎟ ⎜ ⎟
⎛sn−1 ⎞ ⎜
2
y =
2
yn−1
2
⋯ y0 ⎜y2n−1
⎜ ⋯ y0 ⎟

⎟ ⎜ ⎟ ⎜0⎟
⎜ ⎟
⎟=⎜

M=⎜





⎟ M⎜
⎜ ⋮ ⎟
⎜ ⎜ ⎟
⎟ ⎜


⋮ ⎜ ⋮

⎜ ⋱ ⋮ ⎟




⎜ ⎟ ⎜
⎟ ⎜ ⋮
⎜ ⎟




⎜ ⎟ ⎝ s0 ⎠ ⎜ ⎟
k
y = yn−1 ⋯ y0
k k ⎝ykn−1 ⋯ y0
k⎠ ⎝0⎠

Using Gaussian elimination we can efficiently compute the null space (modulo 2) of M.
−r n
With probability greater than 1 − 2 it will be {0 , s}.
Classical difficulty
n/2−1
Any probabilistic algorithm making fewer than 2 − 1 queries will fail to
solve Simon’s problem with probability at least 1/2.

• Simon’s algorithm solves Simon’s problem with a linear number of queries.


• Every classical algorithm for Simon’s problem requires an
exponential number of queries.

You might also like