61
1 1 Slides by Gil Nadel & Lena Yerushalmi. Slides by Gil Nadel & Lena Yerushalmi. Adapted from Oded Goldreich’s course lecture notes Adapted from Oded Goldreich’s course lecture notes by Amiel Ferman, Noam Sadot, Erez Waisbard and Gera by Amiel Ferman, Noam Sadot, Erez Waisbard and Gera Weiss. Weiss.

1 Slides by Gil Nadel & Lena Yerushalmi. Adapted from Oded Goldreich’s course lecture notes by Amiel Ferman, Noam Sadot, Erez Waisbard and Gera Weiss

  • View
    218

  • Download
    1

Embed Size (px)

Citation preview

11

Slides by Gil Nadel & Lena Yerushalmi.Slides by Gil Nadel & Lena Yerushalmi.

Adapted from Oded Goldreich’s course lecture notes by Adapted from Oded Goldreich’s course lecture notes by Amiel Ferman, Noam Sadot, Erez Waisbard and Gera Weiss.Amiel Ferman, Noam Sadot, Erez Waisbard and Gera Weiss.

22

IntroductionIntroduction

In this lecture we’ll In this lecture we’ll cover:cover:

Non-Deterministic Non-Deterministic Logarithmic SpaceLogarithmic Space

Probabilistic Probabilistic ComputationsComputations

33

The composition lemmaThe composition lemma Lemma (decision version):Lemma (decision version):

Assume a machine Assume a machine MM that solves a that solves a problem problem , using space , using space s(s(··)) and and having having oracleoracle accessaccess to decision to decision problems problems 11,…, ,…, tt. .

Further, suppose that for every Further, suppose that for every ii, the , the task task i i can be solved within space can be solved within space ssi i ((··))..Then, Then, can be solved within space can be solved within spaces’(n)s’(n) = s(n) + max= s(n) + maxii{s{sii(e(es(n)s(n))})}

6.1

44

The composition lemma The composition lemma (cont)(cont)

Lemma (search version):Lemma (search version):Suppose machine Suppose machine MM solves problem solves problem

using space using space s(·)s(·) and having and having oracleoracle accessaccess to search tasks to search tasks 11,,…,…,tt..All queries of All queries of MM and the answers and the answers have length bounded by have length bounded by ees(n)s(n)..For every For every ii, , i i can be solved can be solved within space within space ssi i (·)(·)..

Hence, Hence, can be solved within spacecan be solved within spaces’(n)s’(n) = s(n) + max= s(n) + maxii{s{sii(e(es(n)s(n))})}

55

Search version - proof Search version - proof guidelinesguidelines

Search tasks oracles may return Search tasks oracles may return strings rather than single bitsstrings rather than single bits

Every time Every time MM needs any bit in the needs any bit in the answer to answer to ii(q) (q) (q is the query) it (q is the query) it runs runs MMii again on again on qq and stores and stores only the required bitonly the required bit; i.e the ; i.e the answer from the oracle would be answer from the oracle would be written on the output one bit at a written on the output one bit at a time and by using a counter the time and by using a counter the machine could tell when did it machine could tell when did it reach the desired bit of answer.reach the desired bit of answer.

66

The composition lemma The composition lemma (cont)(cont)

Lemma (time version):Lemma (time version):

Assume machine Assume machine MM solves solves problem problem using space using space s(s(··)) and and having having oracleoracle accessaccess to decision to decision problems problems 11,…, ,…, kk. .

Further, suppose that for every Further, suppose that for every ii, , i i can be solved within space can be solved within space tti i

((··))..

Then, Then, can be solved within time can be solved within timet’(n)t’(n) = t(n) = t(n) max maxii{t{tii(t(n))}(t(n))}..

77

Definition of NLDefinition of NL NL=NSPACE(O(log(n)))NL=NSPACE(O(log(n)))

Def:Def: LL NL NL if there is a non- if there is a non-deterministic TM deterministic TM MM that accepts that accepts LL, and a function , and a function f(n)=O(log(n))f(n)=O(log(n)) s.t. for every input s.t. for every input xx and every and every computation of computation of MM on on xx, at most , at most f(|x|)f(|x|) distinct work-tape cells are distinct work-tape cells are usedused

6.2

88

Log-Space ReductionLog-Space ReductionDef:Def:

A log-space reduction of A log-space reduction of LL11 to to LL22 ((LL11ls ls LL22) is a function ) is a function f(n) f(n) Dspace[O(log(n))]Dspace[O(log(n))] s.t.: s.t.:

xxLL1 1 f(x) f(x) L L22

Note: see proof of the composition Note: see proof of the composition lemmalemma

99

Def:Def:

A language A language LL is is NL-CompleteNL-Complete if: if:

1.1. L L NL NL

2.2. L’ L’ NL: L’ NL: L’lslsLL

NL-CompletenessNL-Completeness

1010

Claim Claim : if : if LLlslsL'L' and and L'L'SPACE(O(log(n)))SPACE(O(log(n))) then then L L SPACE(O(log(n))) SPACE(O(log(n)))proofproof: : (1) (1) L'L'SPACE(O(log(n)))SPACE(O(log(n))) M'M' that decides that decides

L' L' using log space. using log space.

(2) (2) L L lslsL'L' f(f())=Dspace[O(log(n))]:=Dspace[O(log(n))]: x x L L f(x) f(x) L' L'

(3) so (3) so MM that that xx accesses an oracle for accesses an oracle for f(x)f(x) to decide to decide L L in log space, and sincein log space, and since

( ( lg(|f(x)|)lg(|f(x)|)lg(elg(elg(|x|)lg(|x|)) = O(lg(|x|)))) = O(lg(|x|))) ), ), LL is decidable in logspace is decidable in logspace

Discussion of ReducibilityDiscussion of Reducibility6.3

1111

Cook Reduction vs Karp Cook Reduction vs Karp ReductionReduction

(1) if (1) if L L KarpKarpL’L’ and and L’L’NPNP then then L L NP NP

(2) if (2) if L L lslsL’L’ and and L’L’NLNL then then L L NL NL

May May KarpKarp reduction be replaced reduction be replaced by by CookCook reduction in (1)? reduction in (1)?

Probably not: Probably not:

coSATcoSATCook Cook SATSAT, but if , but if NPNPcoNPcoNP, , coSATcoSATNPNP

(3) if (3) if LLCookCookL’L’ and and L’L’PP then then L L P P

6.4

1212

Graph Connectivity (CONN)Graph Connectivity (CONN)Def:Def:

CONNCONN={ (={ (G,u,vG,u,v): ): GG is a directed is a directed graph,graph,

u,vu,vV(G)V(G), there is directed, there is directed path from path from uu to to vv in in GG } }

6.5

1313

CONN is NL-completeCONN is NL-complete Thm:Thm: CONN is NL-completeCONN is NL-complete

proof:proof: CONN CONN NL ( by algorithm ) NL ( by algorithm )

InputInput:: G = (V; E), v, u G = (V; E), v, u V V

TaskTask:: Find if there exists a directed path from Find if there exists a directed path from vv to to uu in in GG..1. x 1. x v v

2. counter 2. counter |V| |V|

3. repeat 3. repeat

4. decrement counter by 1 4. decrement counter by 1

5. guess a node y 5. guess a node y V s.t. (x,y) V s.t. (x,y) E E

6. if y 6. if y u then x u then x y y

7. until y = u or counter = 0 7. until y = u or counter = 0

8. if y = u then accept, else reject8. if y = u then accept, else reject

1414

CONN is NL-complete (cont)CONN is NL-complete (cont)

L L NL NL, , LL is log-space reducible to is log-space reducible to CONNCONN

InputInput:: an input string an input string xx

TaskTask:: output a graph output a graph G=(V,E)G=(V,E) and two nodes and two nodes v, u v, u V V s.t. there is a path from s.t. there is a path from vv to to uu in in GG iff iff xx is accepted by is accepted by MM

1. compute 1. compute nn, the number of different configurations of , the number of different configurations of MM while computing input while computing input xx

2. for 2. for i = 1i = 1 to to nn

3. for 3. for j = 1j = 1 to to nn

4. if there is a transition of 4. if there is a transition of MM from configuration from configuration ii to to configuration configuration jj output output 11 otherwise output otherwise output 00

5. output 5. output 11 and and nn

1515

Complementing ClassesComplementing Classes

DefDef::

Let Let LL{0,1}*{0,1}* be a language. The be a language. The

complementcomplement ofof L L, denoted, denotedLL, is , is

the language the language {0,1}* \ L{0,1}* \ L

DefDef::

Let C be a complexity class. The Let C be a complexity class. The

complement complement of of CC, denoted , denoted coCcoC is is

coC = {coC = {L: LL: LC}C}

6.6

1616

Is Is C=coCC=coC? ? For every For every CC that is a that is a

deterministicdeterministic time or space time or space complexity class, complexity class, C=coCC=coC

In particular, In particular, P=coPP=coP Is Is NP=coNPNP=coNP? The conjecture is: ? The conjecture is:

NPNPcoNPcoNP

1717

Is Is NL=coNLNL=coNL??ClaimClaim: : LLNLNL-complete s.t. -complete s.t. LLcoNLcoNL NL=coNLNL=coNLproofproof::

(1) (1) L' L' NL NL. . L L NL complete NL complete L'L'lslsLL with with f(f()=Dspace[O(log(n))])=Dspace[O(log(n))] and and x x L' L' f(x) f(x) L L

(2) On other hand, (2) On other hand, x x L'L' f(x) f(x) LL, , sosoLLNL NL L'L'NLNL

(3) Implying (3) Implying L'L'NL,NL,L'L'NLNL, thus , thus NL=coNLNL=coNL

6.7

1818

The The CONNCONN problem problem

DefDef: : CONNCONN={ (={ (G,u,vG,u,v): ): GG is a directed is a directed graph,graph,

u,vu,vV(G)V(G), there is no , there is no directed directed

path from path from uu to to vv in in GG } }

QuestionQuestion :: ConnConnNLNL??

Answer:Answer: Yes!Yes!

Result:Result: NL=coNLNL=coNL ( Immerman ( Immerman theorem,1988)theorem,1988)

1919

NonDet. Alg. & Count NonDet. Alg. & Count ReachablityReachablity

DefDef: A non-deterministic TM : A non-deterministic TM MM is said to is said to compute a function compute a function ff if on any input if on any input xx

(1) either (1) either MM halts with the right answer halts with the right answer f(x) f(x) or or MM halts with output “failure” halts with output “failure”

(2) at least one of (2) at least one of MM’s computations ’s computations halts with the right answerhalts with the right answer

Def(CR): Def(CR): Given Given G=(V,E)G=(V,E) and a vertex and a vertex vvVV CR(G, v)CR(G, v) is the number of is the number of vertices reachable from vertices reachable from vv in in GG

Thm (CR):Thm (CR): CR CR L L

2020

Algorithm for CRAlgorithm for CRCR ( j )CR ( j )

1. n=01. n=02. for u2. for uV V

3. count = 03. count = 04. for v4. for vV V

5. non-deterministic switch:5. non-deterministic switch:

5.1 5.1 if if reachreach(v, j-1) (v, j-1) count++count++ else else failfail if if (v,u) (v,u) E then n++, break E then n++, break

5.2 continue5.2 continue endend

6. if counter 6. if counter CR(j-1) then fail CR(j-1) then failendend7.return n7.return n

Recursive call!

In NL

Assume (v,v) E

2121

Algorithm for CRAlgorithm for CRCR(j)CR(j)

1. n=01. n=02. for u2. for uV V

3. count=03. count=04. for v4. for vV V

5. non-deterministic switch:5. non-deterministic switch:

5.1 5.1 if if reachreach(v, j-1) (v, j-1) count++count++ else else failfail if if (v,u) (v,u) E then n++, break E then n++, break

5.2 continue5.2 continue endend

6. if counter 6. if counter CR-1CR-1 then fail then failendend7.return n7.return n

Global variable

CR(n)CR-1 = 1for j = 1..|V| CR-1 = CR(j)end

2222

Proof of CR (cont)Proof of CR (cont)LemmaLemma: machine CR uses O(log(n)) : machine CR uses O(log(n))

spacespaceproof:proof: -- line1 - O(log(n))line1 - O(log(n)) - each other step - at most ten - each other step - at most ten

variables, each of variables, each of ≤ O(log(n))≤ O(log(n)) space space

LemmaLemma: machine CR outputs an : machine CR outputs an integer, then it is correctinteger, then it is correct

CorollaryCorollary: Machine CR is good: Machine CR is good

6.11

2323

Immerman Theorem Immerman Theorem

Thm:Thm: NL=coNLNL=coNL

Proof:Proof:

(1)(1) CONNCONNNLNL-complete-complete

(2) (2) CONNCONNNLNL

HenceHence, , byby the above claime the above claime

NL=coNLNL=coNL

ExtensionExtension:: s(n)s(n)log(n)log(n), , NSPACE(s(n))=coNSPACE(s(n))NSPACE(s(n))=coNSPACE(s(n))

6.10

2424

Slides by Gil Nadel & Lena Yerushalmi.Slides by Gil Nadel & Lena Yerushalmi.

Adapted from Oded Goldreich’s course lecture notes by Adapted from Oded Goldreich’s course lecture notes by Amiel Ferman, Noam Sadot, Erez Waisbard and Gera Weiss.Amiel Ferman, Noam Sadot, Erez Waisbard and Gera Weiss.

2525

Probabilistic Computations

Extend the notion of “efficient Extend the notion of “efficient computation” beyond computation” beyond polynomial-time-TMs.polynomial-time-TMs.

We will still consider only We will still consider only machines that are allowed to run machines that are allowed to run no more than a fixed polynomial no more than a fixed polynomial in the input length.in the input length.

7.1

2626

Random vs. Non-Random vs. Non-deterministic deterministic computationscomputations

In a NDTM, even a single wizard’s In a NDTM, even a single wizard’s witness is enough to cause the witness is enough to cause the input to be accepted.input to be accepted.

In the In the randomized modelrandomized model - we - we require the probability that such a require the probability that such a witness is detected to be larger witness is detected to be larger than a certain threshold.than a certain threshold.

There are two approaches to There are two approaches to randomness, online & offline, randomness, online & offline, which we will show to be identicalwhich we will show to be identical..

2727

Online approach

NDTM NDTM : (<state>,<symbol>,<: (<state>,<symbol>,<guessguess>) >) (<state>,<move>,<symbol>)(<state>,<move>,<symbol>)

Randomized TMRandomized TM: (<state>,<symbol>,<: (<state>,<symbol>,<tosstoss>) >) (<state>,<move>,<symbol>)(<state>,<move>,<symbol>)

NDTM accepts if a “good” guess NDTM accepts if a “good” guess exists - a exists - a singlesingle accepting accepting computation is enough.computation is enough.

A Random TM accepts if A Random TM accepts if sufficientsufficient accepting computations exist.accepting computations exist.

7.2

2828

Online approachOnline approach

A random online TM defines a A random online TM defines a probability space on possible probability space on possible computations.computations.

The computations can be The computations can be described as a tree.described as a tree.

We usually regard only binary We usually regard only binary tree, because we can simulate tree, because we can simulate any other tree as good as any other tree as good as necessary.necessary.

2929

Offline approachOffline approach

A language A language LLNPNP iff there exists a iff there exists a DTMDTM MM and a polynomial and a polynomial p(p()) and a and a TM TM MM, s.t. for every , s.t. for every xxL L y |y|y |y|p(|p(|x|)x|) and and M(x,y)M(x,y)

The DTM has access to a “witness” The DTM has access to a “witness” string of polynomial length.string of polynomial length.

Similarly, a random TM has access Similarly, a random TM has access to a “guess” input string. to a “guess” input string. BUTBUT......

There must be sufficient such There must be sufficient such witnesseswitnesses

7.3

3030

The Random Complexity The Random Complexity classesclasses

A language that can be A language that can be recognized by a polynomial time recognized by a polynomial time probabilistic TM with good probabilistic TM with good probability, is considered probability, is considered relatively easy.relatively easy.

We first consider a We first consider a two-sidedtwo-sided error complexity class.error complexity class.

3131

The Scheme The Scheme

DefDef::LLPPPP iff there exists a polynomial- iff there exists a polynomial-time probabilistic TM time probabilistic TM MM, such that, such that

x: Prob[M(x)=x: Prob[M(x)=LL(x)] (x)] 1-1-

where where LL(x)=1(x)=1 if if xxLL, and , and LL(x)=0(x)=0 if if xxLL..

7.13

3232

Claim: Claim: PPPP PSPACE

Let Let LLPPPP, , MM be the TM that be the TM that recognizes recognizes LL, and , and p(p()) the time bound. the time bound.

Define Define M’(x)M’(x) run run M(x)M(x) using all using all p(|x|)p(|x|) possible coin possible coin tosses, and decides according to the tosses, and decides according to the fraction that makes fraction that makes M(x)=1M(x)=1..

M’M’ uses polynomial space for each of uses polynomial space for each of the (exponential number of) the (exponential number of) invocations, and only needs to count invocations, and only needs to count the number of successes.the number of successes.

7.14

3333

PPPP½½ Not a Realistic Class Not a Realistic Class

DefDef: : LLPP’PP’ iff a TM iff a TM MM exists s.t. exists s.t.xxLL Prob[M(x)=1] Prob[M(x)=1] ½½ xxLL Prob[M(x)=1] Prob[M(x)=1] ≤≤ ½ ½

Obviously, Obviously, PPPP½½ PP’PP’

7.13

3434

Claim: PPClaim: PP½½=PP’=PP’

Let Let LLPP’PP’, , MM the TM that recognizes the TM that recognizes LL, and , and p(p()) the time bound. the time bound.

M’(x,(aM’(x,(a11,a,a22,...,a,...,ap(|x|)p(|x|),b,b11,b,b22,...,b,...,bp(|x|)p(|x|))) )) if aif a11=a=a22=...=a=...=ap(|x|)p(|x|)=1=1 then return NO, then return NO,else return else return M(x,(bM(x,(b11,b,b22,...,b,...,bp(|x|)p(|x|)))))

M'M' is exactly the same as is exactly the same as MM, except , except for an additional probability of for an additional probability of 22-p(|x|)-1-p(|x|)-1

for returning NO.for returning NO.

7.15

3535

PPPP½½=PP’ continued=PP’ continued

If If xxLL, , Prob[M(x)=1] > ½ Prob[M(x)=1] > ½ Prob[M(x)=1] Prob[M(x)=1] ½+2 ½+2-p(|x|)+1-p(|x|)+1 Prob[M’(x)=1] Prob[M’(x)=1] (½+2 (½+2-p(|x|)-p(|x|))(1-2)(1-2-p(|x|)+1-p(|x|)+1) ) > ½> ½

If If xxLL, , Prob[M(x)=0] Prob[M(x)=0] ½ ½ Prob[M’(x)=1] Prob[M’(x)=1] ½(1-2 ½(1-2-p(|x|)+1-p(|x|)+1)+2)+2-p(|x|)+1-p(|x|)+1 > ½> ½

In any case In any case Prob[M(x)=Prob[M(x)=LL(x)] > ½(x)] > ½

3636

Claim: Claim: NPPP½

Let Let LLNPNP, , MM the NDTM that recognizes the NDTM that recognizes LL, , and and p(p()) the time bound. the time bound.

M’(x,(bM’(x,(b11,b,b22,...,b,...,bp(|x|)p(|x|))) )) if if bb11=1=1 then return then return M(x,(bM(x,(b22,...,b,...,bp(|x|)p(|x|))))), else return YES., else return YES.

If If xxLL, then , then Prob[M’(x)=1]=½Prob[M’(x)=1]=½ ( (bb11=0=0 only). only). If If xxLL, then , then Prob[M’(x)=1]>½Prob[M’(x)=1]>½ (a witness (a witness

exists)exists) Also: Also: coNPcoNPPPPP½½ because of symmetry. because of symmetry.

7.16

3737

A language A language LLRPRP, iff a probabilistic , iff a probabilistic TM TM MM exists, such that exists, such that xxL L Prob[M(x)=1] Prob[M(x)=1] ½½ xxL L Prob[M(x)=1] = 0Prob[M(x)=1] = 0

A language A language LLcoRPcoRP, iff a , iff a probabilistic TM exists probabilistic TM exists MM, such that, such thatxxL L Prob[M(x)=1] = 1Prob[M(x)=1] = 1xxL L Prob[M(x)=0] Prob[M(x)=0] ½½

coRP = { L: coRP = { L: * \ L * \ L RP }RP }

The classes The classes RPRP and and coRPcoRP7.4

3838

Comparing Comparing RPRP with with NPNP

Let Let LL be a language in be a language in NPNP or or RPRP.. Let Let RRLL be the relation defining the witness/guess be the relation defining the witness/guess

for for LL for a certain TM. for a certain TM. Then:Then:

NPNP RP RP

xxL L yy (x,y)(x,y)RRLL xxL L ProbProb[(x,r)[(x,r)RRLL]] ½½

xxL L y (x,y)y (x,y)RRLL xxL L r (x,r)r (x,r)RRLL

Obviously, Obviously, RPRPNPNP

7.5

3939

AmplificationAmplification The constant The constant ½½ in the definition of in the definition of RPRP is is

arbitrary.arbitrary. Given a probabilistic TM Given a probabilistic TM MM accepting any accepting any

xxLL with probability with probability p<½p<½, run , run MM nn times to times to “amplify” the probability gap“amplify” the probability gap

If If xxLL, all runs will return , all runs will return 00.. If If xxLL, and we run it , and we run it nn times; the times; the

probability that none of these accepts isprobability that none of these accepts is

Prob[MProb[Mnn(x)=1] = 1-Prob[M(x)=1] = 1-Prob[Mnn(x)(x)1] = 1] = = 1-Prob[M(x) = 1-Prob[M(x)1]1]n n == = 1-(1-Prob[M(x)=1]) = 1-(1-Prob[M(x)=1])n n = 1-(1-p)= 1-(1-p)nn

7.6

4040

Alternative Def’s for RPAlternative Def’s for RP

RPRP11 would make an error often, while would make an error often, while RPRP22 would almost never err:would almost never err:

DefDef:: LLRPRP11 iff iff probabilistic Poly-time TM probabilistic Poly-time TM MM and a polynomial and a polynomial p(p()), s.t. , s.t. xxL L Prob[M(x)=1] Prob[M(x)=1] 1/p(|x|) 1/p(|x|)xxL L Prob[M(x)=1] = 0Prob[M(x)=1] = 0

DefDef:: LLRPRP22 iff iff probabilistic Poly-time TM probabilistic Poly-time TM MM and a polynomial and a polynomial p(p()), s.t. , s.t. xxL L Prob[M(x)=1] Prob[M(x)=1] 1-2 1-2-p(|x|)-p(|x|)

xxL L Prob[M(x)=1] = 0Prob[M(x)=1] = 0

4141

Claim: RPClaim: RP11=RP=RP22

Trivially, Trivially, RPRP22RPRP11: if : if |x||x| is long enough, then is long enough, then1-21-2-p(|x|) -p(|x|) 1/p(|x|) 1/p(|x|)

Suppose Suppose LLRPRP11: there exists : there exists MM11 s.t. s.t. xxLL: : Prob[MProb[M11(x,r)=1] (x,r)=1] 1/p(|x|) 1/p(|x|)

MM22 runs runs MM11 t(|x|)t(|x|) times, to find that times, to find that Prob[MProb[M22(x,r)=0] (x,r)=0] (1-1/p(|x|)) (1-1/p(|x|))t(|x|)t(|x|)

Solving Solving (1-1/p(|x|))(1-1/p(|x|))t(|x|)t(|x|) = 1-2 = 1-2-p(|x|)-p(|x|) gives gives t(|x|) t(|x|) p(|x|) p(|x|)22/log/log22ee

Hence, Hence, MM22 runs in polynomial time and thus runs in polynomial time and thus LLRPRP22 RP RP11RPRP22

7.7

4242

The class BPP = PPThe class BPP = PP1/31/3

DefDef: : LLBPPBPP iff there exists a poly- iff there exists a poly-time probabilistic TM time probabilistic TM MM, s.t., s.t.

xxL:L: Prob[M(x)=Prob[M(x)=LL(x)] (x)] 2/3 2/3

The BPP machine success probability The BPP machine success probability is bounded away from failure is bounded away from failure probabilityprobability

7.8

4343

Constant invarianceConstant invariance

An alternative definition: An alternative definition: xxLL Prob[M(x)=1] Prob[M(x)=1] p+ p+xxLL Prob[M(x)=1] Prob[M(x)=1] p- p-

We can build a machine We can build a machine MM22 that runs that runs MM nn times, and accept/reject depending if times, and accept/reject depending if the fraction of ‘yes’ is more or less the fraction of ‘yes’ is more or less pp. . After a constant number of executions After a constant number of executions (depending on (depending on pp and and but not on but not on xx) we ) we would get the desired probability.would get the desired probability.

7.9

4444

The weakest possible BPP The weakest possible BPP definitiondefinition

DefDef: : LLBPPWBPPW iff there exists a iff there exists a polynomial-time probabilistic TM polynomial-time probabilistic TM MM, , and a polynomial-time computable and a polynomial-time computable function function f:Nf:N[0,1][0,1] and a polynomial and a polynomial p(p()), s.t. , s.t. xxLL: : xxLL Prob[M(x)=1] Prob[M(x)=1] f(|x|) + 1/p(|x|) f(|x|) + 1/p(|x|)xxLL Prob[M(x)=1] Prob[M(x)=1] f(|x|) - 1/p(|x|) f(|x|) - 1/p(|x|)

If we set f(|x|)=½ and p(|x|)=6 we If we set f(|x|)=½ and p(|x|)=6 we get the original definition.get the original definition.

Hence, Hence, BPPBPPBPPWBPPW

7.10

4545

Chernoff’s inequalityChernoff’s inequality

If If XXii are are nn independent Bernoulli independent Bernoulli random variables with the same random variables with the same expectation expectation pp½½,,then then : 0<: 0<p(p-1),p(p-1), we have we haveProb[ |Prob[ |XXii/n - p| > /n - p| > ] ] < 2Exp(- < 2Exp(-22n/2p(1-p))n/2p(1-p)) 2e 2e-2n-2n22

4646

Claim: BPPW=BPPClaim: BPPW=BPP

Let Let LLBPPWBPPW and let and let MM be a TM for be a TM for LL Def Def M’(x)M’(x)

invoke invoke ttii=M(x) =M(x) i=1…ni=1…n, , compute compute pp==ttii/n/n, , if if pp>f(|x|)>f(|x|) return YES return YES else return NO. else return NO.

Notice Notice pp is the mean of a sample of size is the mean of a sample of size nn of the random variable of the random variable M(x)M(x)

setting setting =1/p(|x|) =1/p(|x|) andand n=-ln(1/6)/2 n=-ln(1/6)/222 we we get the desired probability gap.get the desired probability gap.

4747

The strongest possible BPP The strongest possible BPP definitiondefinition

Define: Define: LLBPPSBPPS iff there exists a iff there exists a polynomial-time probabilistic TM polynomial-time probabilistic TM MM, , and a polynomial and a polynomial p(p()), s.t. , s.t. xxLL Prob[M(x)=Prob[M(x)=LL(x)] (x)] 1-2 1-2-p(|x|)-p(|x|)

If we set If we set p(|x|)=2p(|x|)=2 we get the original we get the original definition, because definition, because 1-21-2-2 -2

Hence, Hence, BPPSBPPSBPPBPP

7.11

4848

ClaimClaim: : BPPS=BPPBPPS=BPP Let Let LLBPPBPP and let and let MM be a TM for be a TM for LL DefDef: : M’(x) M’(x) invoke invoke ttii=M(x) =M(x) i=1…ni=1…n, ,

compute compute pp==ttii/n/n, if , if pp>1/2>1/2 return YES return YES else return NO.else return NO.

By Chernoff’s inequality: By Chernoff’s inequality: Prob[|M’(x)-Exp[M(x)]|Prob[|M’(x)-Exp[M(x)]|2e2e-n/18-n/18

But But 1/2-1/6 1/2-1/6 Exp[M(x)] Exp[M(x)] 1/2+1/61/2+1/6 Prob[M’(x)=Prob[M’(x)=LL(x)] (x)] 1-2e 1-2e-n/18-n/18

If we choose If we choose n=18ln(2)p(|x|)n=18ln(2)p(|x|) we get we get the desired probabilitythe desired probability

4949

BPP and other BPP and other complexity classescomplexity classes

Clearly, Clearly, RPRPBPPBPP.. BPPBPPNPNP? Unknown.? Unknown. coBPP=BPPcoBPP=BPP by definition by definition..

7.12

5050

The class ZPPThe class ZPP

Define: Define: LLZPPZPP iff there exists a iff there exists a polynomial-time probabilistic TM polynomial-time probabilistic TM MM, , such that such that xxLL: : M(x)={0,1, M(x)={0,1, }}Prob[M(x)=Prob[M(x)=] ] ½ ½ and and Prob[M(x)=Prob[M(x)=LL(x) or M(x)=(x) or M(x)=] = 1] = 1

Prob[M(x)=Prob[M(x)=LL(x)]>½ (x)]>½ The symbol The symbol is “I don’t know”. is “I don’t know”. The value The value ½½ is arbitrary and can be is arbitrary and can be

replaced by replaced by 22-p(|x|)-p(|x|) or or 1-1/p(|x|).1-1/p(|x|).

7.17

5151

Claim: Claim: ZPP=RPZPP=RPcoRPcoRP Let Let LLZPPZPP, , MM a NDTM for a NDTM for LL DefDef::

M’(x) M’(x) let let b=M(x)b=M(x) if if b=b= return return 00, else return , else return bb

If If xxLL, , M’(x)M’(x) will never return will never return 11. . If If xxLL, , Prob[M’(x)=1]>½Prob[M’(x)=1]>½ as required as required ZPPZPPRPRP.. Similarily, ZPPSimilarily, ZPPcoRP.coRP.

5252

Let Let LLRPRPcoRPcoRP, , MMRPRP and and MMcoRPcoRP be the be the NDTMs for NDTMs for LL according to according to RPRP and and coRPcoRP..

DefDef:: M’(x) M’(x) if if MMRPRP(x)=YES(x)=YES return return 11 if if MMcoRPcoRP=NO=NO return return 00, else return , else return

MMRPRP(x)(x) never returns YES if never returns YES if xxLL, and , and MMcoRPcoRP(x)(x) never returns NO if never returns NO if xxLL. . Therefore, Therefore, M’(x)M’(x) never returns a values never returns a values conflicting conflicting LL(x)(x)

probability that both probability that both MMRPRP and and MMcoRPcoRP err err < < ½ ½ Prob[M’(x)=Prob[M’(x)=] < ½.] < ½.

RPRPcoRPcoRPZPPZPP

RPRPcoRPcoRPZPP

5353

The random classes The random classes hierarchyhierarchy

PPZPPZPPRPRPBPPBPP What about BPP=P?What about BPP=P?

5454

Randomized space Randomized space complexity complexity

DefDef: : LLbadRSPACE(S)badRSPACE(S) iff there iff there exists a randomized TM M s.t. exists a randomized TM M s.t. x x {0, 1}* {0, 1}*xxLL Prob[M(x)=1] Prob[M(x)=1] ½ ½ xxLL Prob[M(x)=1] = 0Prob[M(x)=1] = 0and and MM uses at most uses at most S(|x|)S(|x|) spacespace

Notice: Notice: MM has has NONO time time restriction. restriction.

7.18

5555

Claim: Claim: badRSPACE(S)=NSPACE(badRSPACE(S)=NSPACE(

S)S) Let Let LLbadRSPACE(S).badRSPACE(S). If If xxLL then there are then there are

witnesses. If witnesses. If xxLL then there are none. then there are none. Let Let LLNSPACE(S),NSPACE(S), and and MM be the NDTM for be the NDTM for

LL, with space , with space S(|x|).S(|x|). There an accepting computation in There an accepting computation in eeS(|x|)S(|x|)

time, time, r |r|<er |r|<eS(|x|)S(|x|) s.t. s.t. M(x,r)=1M(x,r)=1.. For uniform For uniform rr: : Prob[M(x,r)=1] Prob[M(x,r)=1] eeS(|x|)S(|x|) If we run If we run MM 22exp(s|x|)exp(s|x|) times, one of these runs times, one of these runs

should find the right should find the right rr..

5656

Claim: Claim: badRSPACE(S)=NSPACE(badRSPACE(S)=NSPACE(

S)S) ButBut: to do that we have to count to : to do that we have to count to

t=2t=2exp(s|x|)exp(s|x|) which takes which takes eeS(|x|)S(|x|) space! space! A randomized counter of A randomized counter of k=logk=log22tt coins coins

which stops the alg. when which stops the alg. when i ki kii=1=1 The expected time is The expected time is 22kk=t=t.. No need to store No need to store kk tosses, we only tosses, we only

have to count to have to count to kk, which takes , which takes log(k) log(k) = log(log(t)) = s(|x|)= log(log(t)) = s(|x|) space. space.

LLbadRSPACE(S)badRSPACE(S)

5757

Randomized space Randomized space complexity - the correct complexity - the correct

versionversion Define: Define: LLRSPACE(S)RSPACE(S) iff there exists a iff there exists a

randomized TM M s.t. randomized TM M s.t. x x {0,1}* {0,1}*xxLL Prob[M(x)=1] Prob[M(x)=1] ½½ xxLL Prob[M(x)=1] = 0Prob[M(x)=1] = 0MM uses at most uses at most S(|x|)S(|x|) space and runs at space and runs at most most eeS(|x|)S(|x|) time. time.

Notice: Notice: MM has both has both spacespace and and timetime restriction. restriction.

Define: Define: RL=RSPACE(log)RL=RSPACE(log) Claim: Claim: LLRLRLNLNL

5858

Undirected graph Undirected graph connectivityconnectivity

InputInput: an undirected graph : an undirected graph G=(V,E)G=(V,E) and two vertices and two vertices ss and and tt..

TaskTask: find if there’s a path between : find if there’s a path between ss and and tt in in GG..

ClaimClaim: Let : Let n=|V|.n=|V|. With probability at With probability at least least ½½, a random walk of length , a random walk of length 8n8n33 from from ss visits all the vertices in visits all the vertices in the connected component of the connected component of ss..

7.19

5959

Proof sketchProof sketch

Let Let G’=(V’,E’)G’=(V’,E’) be the connected be the connected component of component of ss in in GG. .

Let Let TTu,vu,v be a random variable of the be a random variable of the number of steps until reaching number of steps until reaching vv. .

Easily: Easily: E[TE[Tu,vu,v] ] 2|E’|2|E’| Let Let Cover(G’)Cover(G’) be the expected be the expected

number of steps until the last vertex number of steps until the last vertex in in V’V’ is encountered, and let is encountered, and let CC be a be a directed circle that covers directed circle that covers G’G’..

6060

Proof sketch - continuedProof sketch - continued

Cover(G’)Cover(G’) E[TE[Tu,vu,v] ] |C|*2|E’|< |C|*2|E’|< 4|E’||V’|4|E’||V’|

With probability at least With probability at least ½½, a , a random walk of length random walk of length 8|E’||V’|8|E’||V’| from from ss visits all the vertices in visits all the vertices in the connected component of the connected component of ss..

The machine M will simply walk The machine M will simply walk randomly in randomly in GG starting at starting at ss, until , until tt is found or until is found or until 8|E||V|8|E||V| steps steps

6161

Directed ST-CONNDirected ST-CONN

The above claim doesn’t hold for USTCONN:The above claim doesn’t hold for USTCONN:SS T T

A path of length k has A path of length k has ½½kk probability of probability of reaching the reaching the kkthth vertex from vertex from ss..

A walk of exponential length is needed A walk of exponential length is needed to reach to reach tt with high probability with high probability..

7.20