06-Quantum-algorithmic-foundations-slides
06-Quantum-algorithmic-foundations-slides
quantum information
and computation
By John Watrous
Lesson 6
Quantum algorithmic foundations
The prime factorization of N is the list of prime factors of N and the powers to
which they must be raised to obtain N by multiplication.
Prime factorizations are unique (by the Fundamental Theorem of Arithmetic).
Example
The prime factorization of 12 is
2
12 = 2 ⋅ 3
Integer factorization
Integer factorization
Input: an integer N ≥ 2
Output: the prime factorization of N
The prime factorization of N is the list of prime factors of N and the powers to
which they must be raised to obtain N by multiplication.
Prime factorizations are unique (by the Fundamental Theorem of Arithmetic).
Example
The prime factorization of
3402823669209384634633740743176823109843098343
is
3402823669209384634633740743176823109843098343
2
= 3 ⋅ 74519450661011221 ⋅ 5073729280707932631243580787
Integer factorization
Integer factorization
Input: an integer N ≥ 2
Output: the prime factorization of N
The prime factorization of N is the list of prime factors of N and the powers to
which they must be raised to obtain N by multiplication.
Prime factorizations are unique (by the Fundamental Theorem of Arithmetic).
Example
The prime factorization of this number is unknown:
RSA1024
= 13506641086599522334960321627880596993888147560566702752448514
38515265106048595338339402871505719094417982072821644715513736
80419703964191743046496589274256239341020864383202110372958725
76235850964311056407350150818751067659462920556368552947521350
0852879416377328533906109750544334999811150056977236890927563
Integer factorization
Integer factorization
Input: an integer N ≥ 2
Output: the prime factorization of N
The prime factorization of N is the list of prime factors of N and the powers to
which they must be raised to obtain N by multiplication.
Prime factorizations are unique (by the Fundamental Theorem of Arithmetic).
Example
The largest RSA challenge number factored thus far is RSA250, which
was factored in 2020 using the number field sieve.
6413528947707158027879019017057738908482501474
214032465024074496126442307283933356300861 2943447208116859632024532344630238623598752668
471514475501779775492088141802344714013664 = 347708737661925585694639798853367
334551909580467961099285187247091458768739 ⋅
626192155736304745477052080511905649310668
769159001975940569345745223058932597669747 3337202759497815655622601060535511422794076034
1681738069364894699871578494975937497937 4767554666784520987023841729210037080257448673
296881877565718986258036932062711
Greatest common divisor
Greatest common divisor (GCD)
Input: nonnegative integers N and M (not both zero)
Output: the greatest common divisor of N and M
The greatest common divisor of N and M is the largest integer d that evenly
divides both N and M.
• In general, the input length is the length of the binary string encoding of the
input, with respect to whatever encoding scheme has been selected.
Elementary operations
input computation output
The unitary gates in this set are universal — any unitary operation can be closely
approximated by a circuit of these gates.
Elementary operations
input computation output
• AND
• OR
• NOT
• FANOUT
FANOUT gates are not always explicitly considered to be gates, but for this
lesson it is important to do this.
Circuit size (and depth)
Circuit size
The size of a circuit (Boolean or quantum) is the total number of gates it
includes. We may write size(C) to refer to the size of a circuit C.
Example
∧
¬
¬
∧
Circuit size (and depth)
Circuit size
The size of a circuit (Boolean or quantum) is the total number of gates it
includes. We may write size(C) to refer to the size of a circuit C.
Circuit size corresponds to sequential running time. (This is how we will measure
computational cost in this lesson.)
Circuit depth
Example
t(n) = size(Cn )
Asymptotic notation
It’s good to know precisely how many gates are needed to perform computations…
…but we’ll be buried in secondary details if we try to do this in general.
Big-O notation
For two functions g(n) and h(n), we write that g(n) = O(h(n)) if there
exists a positive real number c > 0 and a positive integer n0 such that
g(n) ≤ c ⋅ h(n)
for all n ≥ n0 .
Example
For two functions g(n) and h(n), we write that g(n) = O(h(n)) if there
exists a positive real number c > 0 and a positive integer n0 such that
g(n) ≤ c ⋅ h(n)
for all n ≥ n0 .
Example
size(Cn ) = O(n)
Integer multiplication
Input: integers N and M
Output: NM
By the standard multiplication algorithm, there are Boolean circuits of size O(n )
2
More generally, there are circuits of size O(nm) for multiplying an n-bit integer to
an m-bit integer.
Integer division
Input: /0
integers N and M =
Output: integers q and r so that 0 ≤ r < ∣M∣ and N = qM + r
The standard division algorithm solves this problem for n-bit integers at cost
O(n ).
2
Asymptotic notation
Examples
Addition of n-bit integers can be computed at cost O(n).
Multiplication of n-bit integers can be computed at cost O(n ).
2
Modular exponentiation
Input: integers K ≥ 0, M ≥ 1, and N
(mod M)
K
Output: N
Asymptotic notation
Examples
Addition of n-bit integers can be computed at cost O(n).
Multiplication of n-bit integers can be computed at cost O(n ).
2
Integer factorization
Input: an integer N ≥ 2
Output: the prime factorization of N
Examples
Acknowledgment
1,000,000
An algorithm whose cost scales as n on inputs of length n is not
reasonably categorized as efficient…
…but it must still doing something clever to avoid exponential cost!
O (2 )
ε
n
O (2 )
ε
n
cost limit
l
ntial
ia
m
cost (time)
no
e
ly
expon
po
input length
Toffoli gates
Recall that Toffoli gates are controlled-controlled-NOT gates:
∣a⟩ ∣a⟩
∣b⟩ ∣b⟩
∣c⟩ +
+ ∣c ⊕ ab⟩
We can also think about Toffoli gates as being query gates for the AND function.
T + T
†
+
H + T
†
+ T + T
†
+ T H
Simulating Boolean gates
NOT gates can be left alone.
AND and OR gates can be simulated with Toffoli and NOT gates:
AND gate OR gate
∣0⟩ + ∣a ∧ b⟩ ∣0⟩ + + ∣a ∨ b⟩
∣a⟩ ∣a⟩
∣0⟩ + ∣a⟩
Simulating Boolean circuits
AND gate OR gate FANOUT gate
∣0⟩ + ∣a ∧ b⟩ ∣0⟩ + + ∣a ∨ b⟩
n m
f∶Σ →Σ
Replace each AND, OR, and FANOUT gate of C with its quantum simulation:
⎧
⎪ ⎧
⎪
⎪
⎪ ⎫
⎪ ⎪
⎪ ⎫
⎪
⎪ ⎪
⎪ ⎪ ⎪
x ⎪
⎨ ⎬ ∣x⟩ ⎪
⎨ ⎪
⎬ ∣f(x)⟩
C
⎪
⎪ ⎪
⎪ ⎪
⎪ ⎪
⎪
⎪
f(x)
⎪
⎪ t gates
⎭ ⎪
⎪ ⎪
⎭
⎪
⎩ ⎪
⎩
⎫
R
⎧ ⎪
⎪
⎪
⎪ ⎪
⎪
⎪ ⎪
O(t) gates
⎪
⎪ ⎪
⎪
k ⎪ ⎪
∣0 ⟩ ⎪
⎨
⎪
⎪
⎬
⎪ ∣g(x)⟩
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎩ ⎪
⎪
⎭
Simulating Boolean circuits
⎧
⎪ ⎫
The string g(x) represents garbage.
⎪
⎪ ⎪
⎪ ⎪
∣x⟩ ⎪
⎨
⎪
⎪
⎬
⎪ ∣f(x)⟩
⎪
⎪ ⎪
⎪
It will ruin the interference patterns that
⎪
⎪ ⎭
⎩ make quantum algorithms work.
⎫
R
⎧ ⎪
⎪
⎪
⎪ ⎪
⎪
To get rid of it, we can use the fact that
⎪ ⎪
O(t) gates
⎪
⎪ ⎪
⎪
k ⎪ ⎪
∣0 ⟩ ⎪ ⎪
R can be inverted…
⎨
⎪ ⎬
⎪ ∣g(x)⟩
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎩ ⎪
⎪
⎭
⎧
⎪ ⎫
⎪
⎪
⎪ ⎪
⎪
⎪ ⎪
∣x⟩ ⎪
⎨
⎪
⎪
⎬
⎪ ∣x⟩
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎩ ⎭
⎧ ⎫
†
⎪ ⎪
R
⎪ ⎪
R
⎪
⎪ ⎪
⎪
⎪ ⎪
k ⎪ ⎪
∣0 ⟩ ⎪
⎨
⎪
⎪
⎬
⎪ ∣0 ⟩
k
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎩ ⎭
⎧
⎪ ⎫
⎪
⎪ ⎪
+
∣y⟩ ⎪ ⎪
+
⎨ ⎬ ∣y ⊕ f(x)⟩
+
⎪ ⎪
+
⎪ ⎪
+
⎪ ⎪
+
⎩ ⎭
+
+
+
+
Simulating Boolean circuits
⎧
⎪ ⎫
⎪
⎪
⎪ ⎪
⎪
⎪ ⎪
∣x⟩ ⎪
⎨
⎪
⎪
⎬
⎪ ∣x⟩
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎩ ⎭
⎧ ⎫
†
⎪ ⎪
R
⎪ ⎪
R
⎪
⎪ ⎪
⎪
⎪ ⎪
k ⎪ ⎪
∣0 ⟩ ⎪ ⎪
Q
⎨
⎪ ⎬
⎪ ∣0 ⟩
k
⎪
⎪
O(t) gates ⎪
⎪
⎪
⎪ ⎪
⎪
⎪
⎪ ⎪
⎪
⎩ ⎭
⎧
⎪ ⎫
⎪
⎪ ⎪
+
∣y⟩ ⎪ ⎪
+
⎨ ⎬ ∣y ⊕ f(x)⟩
+
⎪ ⎪
+
⎪ ⎪
+
⎪ ⎪
+
⎩ ⎭
+
+
+
+
⎧
⎪
⎪
⎪ ⎫
⎪
⎪ ⎪
⎪
x ⎪
⎨ ⎬
C
⎪
⎪ ⎪
⎪
⎪
f(x)
⎪
⎪ t gates
⎭
⎪
⎩