IFT6121 Automne 2008 Complexité du calcul CS151 Complexity Theory Partie 2 La hiérarchie polynômiale Lecture 12 May 3, 2007 Transparents tirés (avec permission) des séances 12 et 13 du cours CSC 151 de mai 2007 donné par Chris Umans de la California Institute of Technology A motivating question Oracle Turing Machines • Oracle Turing Machine (OTM): • Central problem in logic synthesis: • is there a circuit C’ of size at most k that computes the same function C does? • Complexity of this problem? – multitape TM M with special “query” tape – special states q?, qyes, qno – on input x, with oracle language A – MA runs as usual, except… – when MA enters state q?: • y = contents of query tape • y A transition to qyes • y A transition to qno • given Boolean circuit C, integer k x1 x2 x3 … xn – NP-hard? in NP? in coNP? in PSPACE? – complete for any of these classes? May 3, 2007 CS151 Lecture 12 3 May 3, 2007 CS151 Lecture 12 4 Oracle Turing Machines Oracle Turing Machines • Nondeterministic OTM Shorthand #1: • applying oracles to entire complexity classes: – defined in the same way – (transition relation, rather than function) • oracle is like a subroutine, or function in your favorite programming language – complexity class C – language A – but each call counts as single step e.g.: given ij1, ij2, …, ijn are even # satisfiable? – poly-time OTM solves with SAT oracle May 3, 2007 CS151 Lecture 12 5 CA = {L decided by OTM M with oracle A with M “in” C} – example: PSAT May 3, 2007 CS151 Lecture 12 6 Oracle Turing Machines The Polynomial-Time Hierarchy Shorthand #2: • using complexity classes as oracles: • can define lots of complexity classes using oracles • the classes on the next slide stand out – OTM M – complexity class C – MC decides language L if for some language A C, MA decides L – they have natural complete problems – they have a natural interpretation in terms of alternating quantifiers – they help us state certain consequences and containments (more later) Both together: CD = languages decided by OTM “in” C with oracle language from D exercise: show PSAT = PNP May 3, 2007 CS151 Lecture 12 7 May 3, 2007 CS151 Lecture 12 8 The Polynomial-Time Hierarchy The Polynomial-Time Hierarchy Ȉ0 = Ȇ0 = P ǻi+1=PȈi ǻ1=PP ǻ2=PNP ǻi+1=P Ȉi Ȉ1=NP Ȇ1=coNP Ȉ2=NPNP Ȇ2=coNPNP Ȉi+i=NP Ȉi Ȇi+1=coNP • Example: – MIN CIRCUIT: given Boolean circuit C, integer k; is there a circuit C’ of size at most k that computes the same function C does? – MIN CIRCUIT Ȉ2 Ȉi Polynomial Hierarchy PH = i Ȉi May 3, 2007 CS151 Lecture 12 9 May 3, 2007 The Polynomial-Time Hierarchy ǻi+1=PȈi CS151 Lecture 12 10 EXP The PH PSPACE: generalized geography, 2-person games… Ȉ0 = Ȇ0 = P Ȉi+i=NPȈi Ȇi+1=coNPȈi PSPACE PH Ƶ3 – EXACT TSP: given a weighted graph G, and an integer k; is the k-th bit of the length of the shortest TSP tour in G a 1? – EXACT TSP ǻ2 CS151 Lecture 12 11 2nd level: MIN CIRCUIT, BPP… 1st level: SAT, UNSAT, factoring, etc… May 3, 2007 CS151 Lecture 12 Ƴ3 ¨3 3rd level: V-C dimension… • Example: May 3, 2007 Ȉ0 = Ȇ0 = P Ȉi+i=NPȈi Ȇi+1=coNPȈi Ƶ2 Ƴ2 ¨2 NP coNP P 12 Useful characterization Useful characterization • Recall: L NP iff expressible as Theorem: L Ȉi iff expressible as L = { x | y, |y| |x|k, (x, y) R } L = { x | y, |y| |x|k, (x, y) R } where R P. where R Ȇi-1. • Corollary: L coNP iff expressible as • Corollary: L Ȇi iff expressible as L = { x | y, |y| |x|k, (x, y) R } L = { x | y, |y| |x|k, (x, y) R } where R P. May 3, 2007 where R Ȉi-1. CS151 Lecture 12 13 May 3, 2007 CS151 Lecture 12 Useful characterization Useful characterization Theorem: L Ȉi iff expressible as L = { x | y, |y| |x|k, (x, y) R }, where R Ȇi-1. Theorem: L Ȉi iff expressible as L = { x | y, |y| |x|k, (x, y) R }, where R Ȇi-1. ( ) – given L Ȉi = NPȈi-1 decided by ONTM M running in time nk – try: R = { (x, y) : y describes valid path of M’s computation leading to qaccept } – but how to recognize valid computation path when it depends on result of oracle queries? • Proof of Theorem: – induction on i – base case (i =1) on previous slide ( ) – we know Ȉi = NPȈi-1 = NPȆi-1 – guess y, ask oracle if (x, y) R May 3, 2007 CS151 Lecture 12 14 15 May 3, 2007 CS151 Lecture 12 16 Useful characterization Useful characterization Theorem: L Ȉi iff expressible as L = { x | y, |y| |x|k, (x, y) R }, where R Ȇi-1. Theorem: L Ȉi iff expressible as L = { x | y, |y| |x|k, (x, y) R }, where R Ȇi-1. – try: R = { (x, y) : y describes valid path of M’s computation leading to qaccept } – valid path = step-by-step description including correct yes/no answer for each A-oracle query zj (A Ȉi-1) – verify “no” queries in Ȇi-1: e.g: z1 A z3 A … z8 A – for each “yes” query zj: wj, |wj| |zj|k with (zj, wj) R’ for some R’ Ȇi-2 by induction. – for each “yes” query zj put wj in description of path y May 3, 2007 CS151 Lecture 12 17 – single language R in Ȇi-1 : (x, y) R all “no” zj are not in A and all “yes” zj have (zj, wj) R’ and y is a path leading to qaccept. – Note: AND of Ȇi-1 predicates is in Ȇi-1. May 3, 2007 Alternating quantifiers • Proof: – ( ) induction on i – base case: true for Ȉ1=NP and Ȇ1=coNP – consider LȈi: L = {x | y1 (x, y1) R’ }, for R’ Ȇi-1 L = {x | y1y2y3 …Qyi (x, y1,y2,…,yi)R} – same argument for L Ȇi – ( ) exercise. L = { x | y1y2y3 …Qyi (x, y1,y2,…,yi)R } where Q=/ if i even/odd, and RP • LȆi iff expressible as L = { x | y1y2y3 …Qyi (x, y1,y2,…,yi)R } where Q= / if i even/odd, and RP CS151 Lecture 12 18 Alternating quantifiers Nicer, more usable version: • LȈi iff expressible as May 3, 2007 CS151 Lecture 12 19 May 3, 2007 CS151 Lecture 12 20 Alternating quantifiers Pleasing viewpoint: const. # of alternations Complete problems • three variants of SAT: 6i-complete – QSATi (i odd) = {3-CNFs ij(x1, x2, …, xi) for which x1x2x3 … xi ij(x1, x2, …, xi) = 1} – QSATi (i even) = {3-DNFs ij(x1, x2, …, xi) for which x1x2x3 … xi ij(x1, x2, …, xi) = 1 } – QSAT = {3-CNFs ij for which x1x2x3 … Qxn ij(x1, x2, …, xn) = 1} “…” PSPACE poly(n) alternations ¨3 “” Ƶ2 “” Ƴ2 PH “…” Ƶi “…”Ƴi ¨2 “” Ƶ3 “”Ƴ3 “” NP “”coNP P May 3, 2007 CS151 Lecture 12 21 May 3, 2007 QSATi is Ȉi-complete …x… …y1… …y2… …y3… May 3, 2007 CS151 Lecture 12 …yi… CVAL reduction for R 1 iff (x, y1,y2,…,yi) R – Problem set: can construct 3-CNF ij from C: z ij(x,y1,…,yi,z) = 1 C(x,y1,…,yi) = 1 – we get: y1y2…yi z ij(x,y1,…,yi,z) = 1 y1y2…yiC(x,y1,…,yi) = 1 x L …yi… C 1 iff (x, y1,y2,…,yi) R … C – assume i odd; given L Ȉi in form { x | y1y2y3 … yi (x, y1,y2,…,yi) R } … 22 QSATi is Ȉi-complete Theorem: QSATi is Ȉi-complete. • Proof: (clearly in Ȉi) …x… …y1… …y2… …y3… CS151 Lecture 12 CVAL reduction for R 23 May 3, 2007 CS151 Lecture 12 24 QSATi is Ȉi-complete QSATi is Ȉi-complete …x… …y1… …y2… …y3… • Proof (continued) … May 3, 2007 – Problem set: can construct 3-DNF ij from C: z ij(x,y1,…,yi,z) = 1 C(x,y1,…,yi) = 1 – we get: y1y2… yiz ij(x,y1,y2,…,yi,z) = 1 y1y2…yiC(x,y1,y2,…,yi) = 1 x L …yi… CVAL reduction for R CS151 Lecture 12 25 QSAT is PSPACE-complete CS151 Lecture 12 26 – given TM M deciding L PSPACE; input x k – 2n possible configurations – single START configuration – assume single ACCEPT configuration – in PSPACE: x1x2x3 … Qxn ij(x1, x2, …, xn)? – “x1”: for each x1, recursively solve x2x3 … Qxn ij(x1, x2, …, xn)? • if encounter “yes”, return “yes” – “x1”: for each x1, recursively solve x2x3 … Qxn ij(x1, x2, …, xn)? • if encounter “no”, return “no” – base case: evaluating a 3-CNF expression – poly(n) recursion depth – poly(n) bits of state at each level CS151 Lecture 12 May 3, 2007 QSAT is PSPACE-complete Theorem: QSAT is PSPACE-complete. • Proof: May 3, 2007 CVAL reduction for R 1 iff (x, y1,y2,…,yi) R C 1 iff (x, y1,y2,…,yi) R …yi… C – assume i even; given L Ȉi in form { x | y1y2y3 … yi (x, y1,y2,…,yi) R } …x… …y1… …y2… …y3… … – define: REACH(X, Y, i) configuration Y reachable from configuration X in at most 2i steps. 27 May 3, 2007 CS151 Lecture 12 28 QSAT is PSPACE-complete QSAT is PSPACE-complete REACH(X, Y, i) configuration Y reachable from configuration X in at most 2i steps. – Goal: produce 3-CNF ij(w1,w2,w3,…,wm) such that – for i = 0, 1, … nk produce quantified Boolean expressions ȥi(A, B, W) w1w2… ȥi(A, B, W) REACH(A, B, i) – convert ȥnk to 3-CNF ij • add variables V – hardwire A = START, B = ACCEPT w1w2… V ij(W, V) x L w1w2…Qwm ij(w1,…,wm) REACH(START, ACCEPT, nk) May 3, 2007 CS151 Lecture 12 29 May 3, 2007 CS151 Lecture 12 QSAT is PSPACE-complete QSAT is PSPACE-complete – ȥo(A, B) = true iff – Key observation #1: REACH(A, B, i+1) • A = B or • A yields B in one step of M … STEP STEP STEP config. A STEP … May 3, 2007 Boolean expression of size O(nk) CS151 Lecture 12 30 Z [REACH(A, Z, i) REACH(Z, B, i)] – cannot define ȥi+1(A, B) to be Z [ȥi(A, Z) ȥi(Z, B)] config. B (why?) 31 May 3, 2007 CS151 Lecture 12 32 QSAT is PSPACE-complete QSAT is PSPACE-complete – Key idea #2: use quantifiers ȥo(A, B) = true iff A = B or A yields B in 1 step ȥi+1(A, B) = – couldn’t do ȥi+1(A, B) = Z [ȥi(A, Z) ȥi(Z, B)] ZXY [((X=AY=Z)(X=ZY=B)) ȥi(X, Y)] – define ȥi+1(A, B) to be – |ȥ0| = O(nk) – |ȥi+1| = O(nk) + |ȥi| ZXY [((X=AY=Z)(X=ZY=B)) ȥi(X, Y)] – total size of ȥnk is O(nk)2 = poly(n) – logspace reduction – ȥi(X, Y) is preceded by quantifiers – move to front (they don’t involve X,Y,Z,A,B) May 3, 2007 CS151 Lecture 12 PH collapse Theorem: if Ȉi = Ȇi then for all j > i Ȉj = Ȇj = ǻj = Ȉi “the polynomial hierarchy collapses to the i-th level” 33 PH ¨3 Ƶ2 Ƴ2 ¨2 NP coNP P – sufficient to show Ȉi = Ȉi+1 – then Ȉi+1= Ȉi = Ȇi = Ȇi+1; apply theorem again CS151 Lecture 12 35 CS151 Lecture 12 34 PH collapse Ƴ3 Ƶ3 • Proof: May 3, 2007 May 3, 2007 – recall: L Ȉi+1 iff expressible as L = { x | y (x, y) R } where R Ȇi – since Ȇi = Ȉi, R expressible as R = { (x,y) | z ((x, y), z) R’ } where R’ Ȇi-1 – together: L = { x | (y, z) (x, (y, z)) R’} – conclude L Ȉi May 3, 2007 CS151 Lecture 12 36