Stanford Unversty CS54: Computatonal Complexty Notes 7 Luca Trevsan January 9, 014 Notes for Lecture 7 1 Approxmate Countng wt an N oracle We complete te proof of te followng result: Teorem 1 For every countng problem #A n #, tere s a probablstc algortm C tat on nput x, computes wt g probablty a value v suc tat (1 ɛ)#a(x) v (1 + ɛ)#a(x) (1) n tme polynomal n x and n 1 ɛ, usng an oracle for N. Gven wat we proved n te prevous lecture, t only remans to develop an approxmate comparson algortm for #CSAT, tat s, an algortm a comp suc tat for every crcut C: If #CSAT (C) k+1 ten a comp(c, k) = YES wt g probablty; If #CSAT (C) < k ten a comp(c, k) = NO wt g probablty. Te dea of te proof s to pck a random functon : {0, 1} n {0, 1} k, and ten consder te number of satsfyng assgnments for te crcut C (x) := C(x) ((x) = 0). If #CSAT (C) k+1 ten, on average over te coce of, C (x) as at least two satsfyng assgnments, but f #CSAT (C) k+1 ten, on average over te coce of, C (x) as less tan one satsfyng assgnments. Ceckng f C s satsfable s a test tat we would expect to dstngus te two cases. To make ts argument rgorous, we cannot pck te functon unformly at random among all functons, because ten would be an object requrng an exponental sze descrpton, and a descrpton of (n te form of an evaluaton algortm) as to be part of te crcut C. Instead we wll pck from a parwse ndependent dstrbuton of functons. To mprove te dstngusng probablty and smplfy te analyss, we wll work wt functons : {0, 1} n {0, 1} k 5, and we wll treat te case k 5 separately. 1.1 arwse ndependent as functons Defnton Let H be a dstrbuton over functons of te form : {0, 1} n {0, 1} m. We say tat H s a parwse ndependent dstrbuton of as functons f for every two dfferent nputs x, y {0, 1} n and for every two possble outputs s, t {0, 1} m we ave [(x) = s (y) = t] = 1 H m 1
Anoter way to look at te defnton s tat for every x y, wen we pck at random ten te random varables (x) and (y) are ndependent and unformly dstrbuted. In partcular, for every x y and for every s, t we ave [(x) = s (y) = t] = [(x) = s] A smple constructon of parwse ndependent as functons s as follows: pck a matrx A {0, 1} m n and a vector b {0, 1} m unformly at random, and ten defne te functon A,b (x) := Ax + b were te matrx product and vector addton operatons are performed over te feld F. (Tat s, tey are performed modulo.) To see tat te parwse ndependence property s satsfed, consder any two dstnct nputs x, y {0, 1} n and any two outputs s, t {0, 1} m. If we call a 1,..., a m te rows of A ten we ave [Ax + b = s Ay + b = t] = A,b m [a T x + b = s a T y + b = t ] =1 because te events (a T x + b = s a T y + b = t ) are all mutually ndependent. Te condton (a T x + b = s a T y + b = t ) can be equvalently rewrtten as and as a T x s = a T y t b = a T x s and ts probablty s a T (x y) = s t b = a T x s [a T (x y) = s t b = a T x s ] = [a T (x y) = s t ] [b = a T x s a T (x y) = s t ] = 1 1 = 1 4 Because x y s a non-zero vector, and so a T (x y) s a vector bt, and because b s a random bt ndependent of x, y. In concluson, we ave ( ) 1 m [Ax + b = s Ay + b = t] = A,b 4 as desred. We wll use te followng fact about parwse ndependent as functons.
Lemma 3 Let H be a dstrbuton of parwse ndependent as functons {0, 1} n {0, 1} m, and Let S {0, 1} n. Ten, for every t [ {a S : (a) = 0} S ] m t S t m. () H roof: We wll use Cebysev s Inequalty to bound te falure probablty. Let S = {a 1,..., a k }, and pck a random H. We defne random varables X 1,..., X k as X = { 1 f (a ) = 0 0 oterwse. (3) Clearly, {a S : (a) = 0} = X. We now calculate te expectatons. For eac, [X = 1] = 1 and E[X m ] = 1. Hence, m [ ] E X = S m. (4) Also we calculate te varance Var[X ] = E[X ] E[X ] E[X ] Because X 1,..., X k are parwse ndependent, [ ] Var X = = E[X ] = 1 m. Var[X ] S m. (5) Usng Cebysev s Inequalty, we get [ {a S : (a) = 0} S ] [ m t = X E[ Var[ X ] t = S t m ] X ] t] 1. Te algortm a-comp We defne te algortm a-comp as follows. nput: C, k f k 5 ten ceck exactly weter #CSAT (C) k. 3
f k 6 pck from a set of parwse ndependent as functons : {0, 1} n {0, 1} m, were m = k 5 answer YES ff tere are more ten 48 nputs x to C suc tat C(x) = 1 and (x) = 0. Notce tat te test at te last step can be done wt one access to an oracle to N and tat te overall algortm runs n probablstc polynomal tme gven an N oracle. We now analyze te correctness of te algortm. Let S {0, 1} n be te set of nputs x suc tat C(x) = 1. Tere are cases. If S k+1, let S S be an arbtrary subset of S of sze exactly k+1. S / m = 64 and we can use Lemma 3 to estmate te error probablty as: Ten [ {x S : (x) = 0} 48] H [ {x S : (x) = 0} 48] H [ S ] = {x S : (x) = 0} 16 H m 1 16 S m = 1 4 If S < k, ten S / m < 3, and te probablty of error can be estmated as [ {x S : (x) = 0} > 48] H [ ] {x S : (x) = 0} S 16 m H 1 16 S m 1 8 Terefore, te algortm wll gve te correct answer wt probablty at least 3/4, wc can ten be amplfed to, say, 1 1/4n (so tat all n nvocatons of a-comp are lkely to be correct) by repeatng te procedure O(log n) tmes and takng te majorty answer. Te Valant-Vazran Reducton We say tat an nstance C of crcut-sat s unquely satsfable f t as exactly one satsfyng assgnment. Valant and Vazran proved tat f tere s a polynomal tme randomzed algortm tat, gven a unquely satsfable crcut, fnds ts satsfyng assgnment, ten crcut-sat (and, ence, all oter problems n N) can be solved n randomzed polynomal tme. Te dea s related to te argument n te prevous secton. Gven a satsfable crcut C, we guess a number k suc tat k s approxmately te number of satsfyng assgnments 4
of C, we pck at random a parwse ndependent as functon : {0, 1} n {0, 1} k, and we construct te crcut C suc tat C (x) := C(x) ((x) = 0). Wt constant probablty, C as exactly one satsfyng assgnment, and ten te ypotetcal algortm tat solves unquely satsfable nstances wll fnd a satsfyng assgnment for C, and ence for C. It remans to prove tat f we ave a set S {0, 1} n, and we pck a parwse ndependent as functon : {0, 1} n {0, 1} k, were k log S, ten tere s a constant tat (x) = 0 for exactly one element of S. It wll not be possble to make ts argument work by usng Cebysev s nequalty, because wen te expected number of elements tat as to 0 s around 1, te standard devaton wll be too g. Instead, we use parwse ndependence to argue tat eac element of S as probablty Ω(1/ S ) of beng te unque element of S asng to 0; tese events are dsjont, and so ter probablty can be added up. Lemma 4 (Valant-Vazran) Let S {0, 1} n, let k be suc tat k S k+1, and let H be a famly of parwse ndependent as functons of te form : {0, 1} n {0, 1} k+. Ten f we pck at random from H, tere s probablty at least 1/8 tat tere s a unque element x S suc tat (x) = 0. recsely, r H [ {x S : (x) = 0} = 1] 1 8 (6) roof: For eac element x S, te probablty tat x s te unque element of S asng to 0 s [(x) = 0 ( y S {x}.(y) 0] Were = [(x) = 0] [(x) = 0 ( y S {x}.(y) = 0)] [(x) = 0] = 1 k+ and, usng a unon bound and parwse ndependence, [(x) = 0 ( y S {x}.(y) = 0)] y S {x} [(x) = (y) = 0] = S 1 k+4 1 k+3 Te probablty tat x s te unque element of S tat ases to 0 s tus [(x) = 0 ( y S {x}.(y) 0] 1 k+3 and te probablty tat a unque element of S ases to 0 s te sum of te above probabltes over all elements of S, and so t s at least S / k+3, wc s at least 1/8. We ave proved te followng result. Teorem 5 Suppose tat tere s a randomzed polynomal tme algortm A suc tat, gven a unquely satsfable crcut C, A fnds te satsfyng assgnment of C. Ten every problem n N s solvable n randomzed polynomal tme. 5
roof: It s enoug to sow tat, under te assumpton of te teorem, gven a (not necessarly unquely) satsfable crcut C, we can fnd a satsfyng assgnment for t n randomzed polynomal tme wt constant probablty. To do so, f n s te number of nputs of te gven crcut C, we try all k = 0,..., n, and for eac k we pck a parwse ndependent as functon k : {0, 1} n {0, 1} k+, and we run algortm A on te crcut C k (x) := C(x) ((x) = 0). For te coce of k suc tat te number of satsfyng assgnments of C s between k and k+1, we ave a constant probablty tat C k s unquely satsfable and tat A wll fnd a satsfyng assgnment. 3 Approxmate Samplng So far we ave consdered te followng queston: for an N-relaton R, gven an nput x, wat s te sze of te set R x = {y : (x, y) R}? A related queston s to be able to sample from te unform dstrbuton over R x. Wenever te relaton R s downward self reducble (a tecncal condton tat we won t defne formally), t s possble to prove tat tere s a probablstc algortm runnng n tme polynomal n x and 1/ɛ to approxmate wtn 1 + ɛ te value R x f and only f tere s a probablstc algortm runnng n tme polynomal n x and 1/ɛ tat samples a dstrbuton ɛ-close to te unform dstrbuton over R x. We sow ow te above result apples to 3SAT (te general result uses te same proof dea). For a formula φ, a varable x and a bt b, let us defne by φ x b te formula obtaned by substtutng te value b n place of x. 1 If φ s defned over varables x 1,..., x n, t s easy to see tat #φ = #φ x 0 + #φ x 1 Also, f S s te unform dstrbuton over satsfyng assgnments for φ, we note tat [x 1 = b] = #φ x b (x 1,...,x n) S #φ Suppose ten tat we ave an effcent samplng algortm tat gven φ and ɛ generates a dstrbuton ɛ-close to unform over te satsfyng assgnments of φ. Let us ten ran te samplng algortm wt approxmaton parameter ɛ/n and use t to sample about Õ(n /ɛ ) assgnments. By computng te fracton of suc assgnments avng x 1 = 0 and x 1 = 1, we get approxmate values p 0, p 1, suc tat p b (x1,...,x n) S[x 1 = b] ɛ/n. Let b be suc tat p b 1/, ten #φ x b /p b s a good approxmaton, to wtn a multplcatve factor (1 + ɛ/n) to #φ, and we can recurse to compute #φ x b to wtn a (1 + ɛ/n) n 1 factor. Conversely, suppose we ave an approxmate countng procedure. Ten we can approxmately compute p b = #φ x b #φ, generate a value b for x 1 wt probablty approxmately p b, and ten recurse to generate a random assgnment for #φ x b. Te same equvalence olds, clearly, for SAT and, among oter problems, for te problem of countng te number of perfect matcngs n a bpartte grap. It s known 1 Specfcally, φ x 1 s obtaned by removng eac occurrence of x from te clauses were t occurs, and removng all te clauses tat contan an occurrence of x; te formula φ x 0 s smlarly obtaned. 6
tat t s N-ard to perform approxmate countng for SAT and ts result, wt te above reducton, mples tat approxmate samplng s also ard for SAT. Te problem of approxmately samplng a perfect matcng as a probablstc polynomal soluton, and te reducton mples tat approxmately countng te number of perfect matcngs n a grap can also be done n probablstc polynomal tme. Te reducton and te results from last secton also mply tat 3SAT (and any oter N relaton) as an approxmate samplng algortm tat runs n probablstc polynomal tme wt an N oracle. Wt a careful use of te tecnques from last week t s ndeed possble to get an exact samplng algortm for 3SAT (and any oter N relaton) runnng n probablstc polynomal tme wt an N oracle. Ts s essentally best possble, because te approxmate samplng requres randomness by ts very defnton, and generatng satsfyng assgnments for a 3SAT formula requres at least an N oracle. 7