Introduction to Quantum Information Processing QIC 710 / CS 667 / PH 767 / CO 681 / AM 871 Lectures 17-19 (2011) Richard Cleve DC 2117 cleve@cs.uwaterloo.ca 1 Complexity class NP 2 Complexity classes Recall: • P (polynomial time): problems solved by O(nc)-size classical circuits (decision problems and uniform circuit families) • BPP (bounded error probabilistic polynomial time): problems solved by O(nc)-size probabilistic circuits that err with probability ¼ • BQP (bounded error quantum polynomial time): problems solved by O(nc)-size quantum circuits that err with probability ¼ • PSPACE (polynomial space): problems solved by algorithms that use O(nc) memory. 3 Summary of previous containments P BPP BQP PSPACE EXP We now consider further structure between P and PSPACE EXP PSPACE Technically, we will restrict our attention to languages (i.e. {0,1}-valued problems) BQP Many problems of interest can be cast in terms of languages P BPP For example, we could define FACTORING = {(x,y) : 2 z y, such that z divides x} 4 NP Define NP (non-deterministic polynomial time) as the class of languages whose positive instances have “witnesses” that can be verified in polynomial time Example: Let 3-CNF-SAT be the language consisting of all 3-CNF formulas that are satisfiable 3-CNF formula: f x1 ,..., xn x1 x3 x4 x2 x3 x5 x1 x5 xn f x1 ,..., xn is satisfiable iff there exists b1 ,...,bn 0,1 such that f b1 ,...,bn 1 No sub-exponential-time algorithm is known for 3-CNF-SAT But poly-time verifiable witnesses exist (namely, b1, ..., bn) 5 Other “logic” problems in NP • k-DNF-SAT: f x1 ,..., xn x1 x3 x4 x2 x3 x5 x1 x5 xn But, unlike with k-CNF-SAT, this one is known to be in P • CIRCUIT-SAT: 1 Λ 0 Λ 1 Λ Λ 1 Λ 0 Λ Λ Λ Λ Λ Λ Λ Λ Λ output bit All known algorithms exponentialtime 6 “Graph theory” problems in NP • k-COLOR: does G have a k-coloring ? • k-CLIQUE: does G have a clique of size k ? • HAM-PATH: does G have a Hamiltonian path? • EUL-PATH: does G have an Eulerian path? 7 “Arithmetic” problems in NP • FACTORING = {(x, y) : 2 z y, such that z divides x} • SUBSET-SUM: given integers x1, x2 , ..., xn, y, do there exist i1, i2 , ..., ik {1, 2,... , n} such that xi1+ xi2 + ... + xik = y? • INTEGER-LINEAR-PROGRAMMING: linear programming where one seeks an integer-valued solution (its existence) 8 P vs. NP All of the aforementioned problems have the property that they reduce to 3-CNF-SAT, in the sense that a polynomialtime algorithm for 3-CNF-SAT can be converted into a polytime algorithm for the problem Example: algorithm for 3-COLOR algorithm for 3-CNF-SAT If a polynomial-time algorithm is discovered for 3-CNF-SAT then a polynomial-time algorithm for 3-COLOR follows And this holds for any problem X NP 9 P vs. NP For any problem X NP algorithm for X algorithm for 3-CNF-SAT A problem that has this property is said to be NP-hard Polynomial-time algorithm any NP-Hard problem implies P=NP NP-hard problems: 3-CNF-SAT, CIRCUIT-SAT, 3-COLOR , k-CLIQUE, HAM-PATH, SUBSET-SUM, INT-LIN-PROG, … Some problems in P: 10 k-DNF-SAT, 2-COLOR, 3-CLIQUE, EUL-PATH, ... FACTORING vs. NP Is FACTORING NP-hard too? If so, then every problem in NP is solvable by a poly-time quantum algorithm! 3-CNF-SAT But FACTORING has not been shown to be NP-hard PSPACE NP co-NP FACTORING Moreover, there is “evidence” that it is not NP-hard: FACTORING NPco-NP If FACTORING is NP-hard then NP = co-NP P 11 FACTORING vs. co-NP FACTORING = {(x, y) : 2 z y, s.t. z divides x} co-NP: languages whose negative instances have “witnesses” that can be verified in poly-time Question: what is a good witness for the negative instances? PSPACE NP co-NP FACTORING P Answer: the prime factorization p1, p2 , ..., pm of x will work Can verify primality and compare p1, p2 , ..., pm with y, all in poly-time 12 Grover’s quantum search algorithm 13 Quantum search problem f : {0,1}n {0,1} f is satisfiable (if x {0,1}n s.t. f(x) = 1) Given: a black box computing Goal: determine if In positive instances, it makes sense to also find such a satisfying assignment x Classically, using probabilistic procedures, order 2n queries are necessary to succeed—even with probability ¾ (say) Grover’s quantum algorithm that makes only O(2n) queries Query: [Grover ’96] x1 xn y x1 Uf xn y f(x1,...,xn) 14 Applications of quantum search The function f could be realized as a 3-CNF formula: f x1 ,..., xn x1 x3 x4 x2 x3 x5 x1 x5 xn Alternatively, the search could be for a certificate for any problem in NP The resulting quantum algorithms appear to be quadratically more efficient than the best classical algorithms known* Subtlety in that the search space might have to be redefined to achieve this PSPACE 3-CNF-SAT NP co-NP FACTORING P 15 Prelude to Grover’s algorithm: two reflections = a rotation Consider two lines with intersection angle : reflection 2 2 2 1 1 reflection 1 Net effect: rotation by angle 2, regardless of starting vector 16 Grover’s algorithm: description I Basic operations used: x1 xn y x1 Uf x1 xn y xn y f(x1,...,xn) x1 U0 H Uf x = (1) f(x) x xn y [x = 0...0] Hadamard Implementation? X X X X X X U0 x = (1) [x = 0...0]x H H H 17 Grover’s algorithm: description II iteration 1 iteration 2 ... 0 0 H Uf H U0 H Uf H U0 H 1. construct state H 0...0 2. repeat k times: apply H U0 HUf to state 3. measure state, to get x{0,1}n, and check if f(x) =1 (The setting of k will be determined later) 18 Grover’s algorithm: analysis I A = {x {0,1}n : f (x) = 1} and B = {x {0,1}n : f (x) = 0} and N = 2n and a = |A| and b = |B| Let Let A a 1 x x b B and 1 xA xB Consider the space spanned by A and B A goal is to get close to this state H0...0 B 1 N x a N A b N B x{ 0 ,1} n Interesting case: a << N 19 Grover’s algorithm: analysis II A Algorithm: (HU0 HUf )k H 0...0 H0...0 B Observation: Uf is a reflection about B: Uf A = A Question: what is HU0 H ? U0 and Uf B = B is a reflection about H0...0 Partial proof: H U0 HH0...0 = H U0 0...0 = H( 0...0) = H 0...0 20 Grover’s algorithm: analysis III A Algorithm: 2 2 2 2 (HU0 HUf )k H 0...0 H0...0 B Since HU0 HUf is a composition of two reflections, it is a rotation by 2, where sin()=a/N When a = 1, we want a/N (2k+1)(1/N) /2 , so k (/4)N More generally, it suffices to set k (/4)N/a Question: what if a is not known in advance? 21 Unknown number of solutions 1 solution 2 solutions 3 solutions 6 solutions 100 solutions success probability 1 0 number of iterations √N/2 4 solutions success probability very close to zero! Choose a random k in the range to get success probability > 0.43 22 Optimality of Grover’s algorithm 23 Optimality of Grover’s algorithm I Theorem: any quantum search algorithm for (2n) queries to f f : {0,1}n {0,1} must make (if f is used as a black-box) Proof (of a slightly simplified version): |x Assume queries are of the form (1) f(x)|x f and that a k-query algorithm is of the form |0...0 U0 f U1 f U2 f U3 where U0, U1, U2, ..., Uk, are arbitrary unitary operations f Uk 24 Optimality of Grover’s algorithm II Define fr : {0,1}n {0,1} as fr (x) = 1 iff x = r Consider |0 U0 fr U1 fr U2 fr U3 fr Uk |ψr,k I U1 I U2 I U3 I Uk |ψr,0 versus |0 U0 We’ll show that, averaging over all r {0,1}n, || |ψr,k |ψr,0 || 2k / 2n 25 Optimality of Grover’s algorithm III Consider |0 U0 I U1 ki I U2 fr U3 fr Uk |ψr,i i Note that |ψr,k |ψr,0 = (|ψr,k |ψr,k1) + (|ψr,k1 |ψr,k2) + ... + (|ψr,1 |ψr,0) which implies || |ψr,k |ψr,0 || || |ψr,k |ψr,k1 || + ... + || |ψr,1 |ψr,0 || 26 Optimality of Grover’s algorithm IV query |0 U0 I U1 I query |0 U0 I U1 i I query i+1 fr U2 i U3 |ψr,i fr Uk fr Uk |ψr,i-1 query i+1 I U2 α i ,x U3 x x || |ψr,i |ψr,i-1 || = |2i,r|, since query only negates |r Therefore, || |ψr,k |ψr,0 || k 1 2α i 0 i ,r 27 Optimality of Grover’s algorithm V Now, averaging over all r {0,1}n, 1 2n r ψ r ,k ψ r ,0 1 n 2 k 1 2 α i ,r r i 0 1 n 2 2 α i ,r i 0 r k 1 ( ) 1 k -1 £ n å2 2n 2 i=0 (By Cauchy-Schwarz) 2k 2n Therefore, for some r {0,1}n, the number of queries k must be (2n), in order to distinguish fr from the all-zero function This completes the proof 28