probabilistic complexity. probabilistic algorithms def: a probabilistic turing machine m is a type...

28
Probabilistic Complexity

Post on 20-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Probabilistic Complexity

Page 2: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of

non-deterministic TM, where each non-deterministic step is called a coin-flip step and has 2 legal next moves.

' .

assign a probability to each branch b of

M s computation on input w as follows

Page 3: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Define the probability of branch b to be Pr[b]=2-k, where k is the number of coin-flip steps

that occur on branch b. Define the probability that M accepts w to be

Pr[M accepts w] = Pr[b]

For 0 ½ , we say that M recognize language A with error probability if

wA implies Pr[M accepts w] 1-, and wA implies Pr[M rejects w] 1-

branchaccepting

anisb

Page 4: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

BPP Def: BPP is the class of languages that are

recognized by probabilistic polynomial time TM’s with an error probability of 1/3 .

Lemma: [Amplification Lemma]Let 0<<½. Then for any polynomial p(n) a probabilistic poly time TM M1 that operates with error probability has an equivalent probabilistic poly time TM M2 that operates with an error probability of 2-p(n) .

Page 5: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Pf: M1: recognizes a language with error , and a poly

p(n). Construct M2 that recognizes the same language

with an error probability 2-p(n).

M2 =“ On input w

1. Calculate k and repeat the following 2k times2. Simulate M1 on w.

3. If most runs of M1 accept, then accept;

otherwise reject. ”

Page 6: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

M1 errs on w with some probability < ½ , /1- <1 . 2

2

2

2

2

Pr[ 2 ]

2(1 )

2( 1) (1 )

( 1)2 (1 ) ( 1)(4 (1 ))

( 1)(4 (1 ))

k i k

i k i

k i k

k k

k k k k

k

M errs exactly i times on k runs

k

i

kk

k

k k

k

(1-)-(1-)<0

Page 7: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Need to show that (k+1)(4(1-))k 2-p(n) .Let t=2p(n), a=1/4(1-), b=max(1,1/loga), c=2logbt, k=bc Claim: (k+1)(1/a)k 1/t

ak = abc abc 2c

2c = 22log(bt) = (bt)2

b1, assume that t9 bt9 bt>2+2log(bt) (bt)2 > bt(2+2logbt) = t(2b+2blogbt) ∵ b 1

i) if 1/loga > 1 b=1/loga abc=a1/loga•C=2 C

ii) if 1/loga < 1 b=1 and a>2 abc=aC>2 C

Page 8: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Hence ak t(2+2blogbt) t(1+2blogbt) t(1+bc) = t(k+1)

(k+1)(4(1- ))k = (k+1)/ak 1/t =2-p(n)

Page 9: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Primality: Composite number : 複合數 Prime : 質數

Zp+={1,2,…,p-1}, Zp ={0}Zp

+

Z5 ={0,1,2,3,4}Z6 ={0,1,2,3,4,5}Z6

+={1,2,3,4,5} x mod p is the smallest non-negative y where x y (mod

p) .

Page 10: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Lemma: Suppose that a1,…,at all divide n and (ai,aj)=1 for ij.Then a1…at n.

Pf:By induction. It is clear for t=1Suppose the lemma is true up to t-1,i.e. a1…at-1n.(at,a1…at-1)=1 Exist r and s such that r at + s a1…at-1 =1,ratn + sa1…at-1n=n .

■ by ind. at|n

Page 11: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Thm: (Chinese Remainder theorem)Suppose m=m1m2…mt and (mi,mj)=1 for ij. Let b1,b2,…,bt be integers and consider the system of congruencies :

xb1 (mod m1)xb2 (mod m2)

xbt (mod mt)

.

mofmultiplea

bydiffersolutionstwoany

solutionshassystemThis

Page 12: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Pf:Let ni = m/mi , then (mi,ni)=1. Exist ri and si such that rimi+sini=1.Let ei = sini ei 1 (mod mi)

ei 0 (mod mj), ijLet x0= biei. Then x0 biei (mod mi)

bi (mod mi) x0 is a solution.Suppose x1 is another solution. Then x1–x0 0 (mod mj), for i=1,…,t .That is m1,…,mt divide x1-x0 . m x1-x0

t

i 1

Page 13: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

The CRT says that a 1-1 correspondence exists between Zm and Zm1×…×Zmt

Thm: (Fermat’s little theorem) If p is a prime number and aZp

+, then ap-1 1 (mod p) .

Page 14: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Pf: 1a,2a,…,(p-1)a1i,jp-1, ia ja (mod p)(ia–ja) 0 (mod p)(i-j)a = k•p p (i-j) i=j . Thus, 1a,2a,…(p-1)a is a permutation of 1,2,…,(p-1).

1a•2a• …•(p-1)a 1•2•…•(p-1) (mod p) (p-1)!ap-1 (p-1)! (mod p) (p-1)!(ap-1 -1) 0 (mod p) (p-1)!(ap-1 -1) k•p

p ap-1 –1, ap-1 1 (mod p) .

Page 15: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

eg.27-1=26=64, 64 mod 7 =1.

Fermat test: we say that p passes the Fermat test at a, we mean that ap-1 1 (mod p) . Fermat’s little theorem states that primes pass all Ferm

at tests for aZp+ .

Page 16: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Carmichael numbers:Composite numbers that passes all Fermat tests.

Pseudo-prime = “ On input p:1. Select a1,…,ak randomly in Zp

+ .2. Compute ai

p-1 mod p for each i .3. If all computed values are 1 , accept ; otherwise, rejects . “

Page 17: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Numbers of prime power: N=pk

It is easy to test such type of numbers!

It is clear that (p-1)| (N-1)

Find a number a such that gcd(a, p) =1.

Then aN-1 1 (mod p). Why?

Thus p | gcd ( N, aN-1 -1).

Test prime power

Page 18: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

PRIME = “ On input p1. If p is even and p=2 then accept ; else reject .2. Select a1,…,ak randomly in Zp

+ .3. For i=1 to k do4. Compute ai

p-1 mod p and reject if different from 1.5. Let p-1=st where s is odd and t=2h

6. Compute mod p.

7. If some element is not 1, then find the last one that is not 1 and reject if it is not –1.8. All tests have passed at this point, so accept. “

hsi

si

si

si aaaa 2222 ,...,,,

210

Page 19: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Lemma: If p is an odd prime number, then Pr[PRIME accepts p]=1 .

Pf:If p is an odd prime, then it will pass stage 4.If a were a stage 7 witness, some b exists in Zp

+, where b 1 (mod p) and b 1(mod p) b2-1 0 (mod p)(b-1)(b+1) 0 (mod p)

Page 20: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

(b-1)(b+1) = cp for some positive integer c. ∵ b 1 (mod p) 0<b+1 , b-1<p . Therefore, p is composite because a prime number

cannot be expressed as a product of numbers that are smaller than it is.

Page 21: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Lemma: If p is an odd composite number, thenPr[PRIME accepts p] 2-k .

Pf: Goal: If p is an odd composite number and a is selected ra

ndomly in Zp+, then Pr[a is witness] ½ .

Prove by demonstrating that at least as many witnesses as non-witnesses exist in Zp

+ , i.e. by finding a unique witness for each non-witness.

Page 22: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

For every non-witness, the sequence computed in stage 6 is either all 1 or contains –1 at some position followed by 1’s .

1: non-witness of the first kind1,1,1,…,1

-1:non-witness of the second kind-1,1,1,…1

Among all non-witness of 2nd kind, find a non-witness for which the –1 appears in the largest position in the sequence.

Page 23: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Let h be a non-witness.,…,……………..-1,1,…,1

∵ p is composite. We can write p = qr, (q,r)=1, or p is a prime power. We handle former case first.By the CRT, there exists t Zp .

t h (mod q)t 1 (mod r)

j-th0 12 2 2 2, , ...... 1 ( mod p)

j jS S S Sh h h h

r) (mod 1 t

q) (mod 12

2

j

j

s

st

Page 24: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Hence t is a witness because but

p) (mod 12 jst

p) (mod 112 jst

p). (mod 1 ,

r) (mod 1

q) (mod 1

1 p) (mod 1

2

2

22

j

j

jj

s

s

ss

tforsimilarly

t

kpttIf

Page 25: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Next we prove that dt mod p is a unique witness for each non-witness d by 2 observations .

. p) (mod 1(dt) and 1

because witness,a is p mod

)p(mod 1 and )p(mod 1 )1

1

1

22

22

jj

jj

ss

ss

(dt)

dt

dd

1 2

1 212

2) If and are distinct non-witnesses, then

mod p mod p .

The reason is that mod p 1 js

d d

d t d t

t

Page 26: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Thus the number of witnesses must be as large as the number of non-witnesses when p=qr.

2

212

112

1

21

12

p mod p mod

then mod p mod If

1. p mod

11

1

d

dttdttd

ptdtd

tt

jj

j

ss

s

Page 27: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

For the case p=qe, where q is a prime and e >1. Let t= 1+ qe-1, which is < p. Thus t p = (1+ q e-1)p = 1 + p qe-1 + (.....) q2(e-1)

= 1 + p(.........) 1 (mod p). Observe that if t p-1 1 (mod p), then t p t !1 (mod p),

which contradicts that t p 1 (mod p). Thus t is a stage 4 witness, since t p-1 ! 1 (mod p). If d is a stage 4 non-witness, then dp-1 1 (mod p), but

then (dt)p-1 ! 1 (mod p), ie, dt is a witness. If d1 and d2 are distinct non-witness, then d1 t mod p d2 t mod p. Otherwise, d1 =d1 tp mod p = d2 tp mod p = d2. Thus the number of stage 4 witnesses must be as large

as the number of non-witnesses.

Thm: PRIMES BPP, actually co-RP.

Page 28: Probabilistic Complexity. Probabilistic Algorithms Def: A probabilistic Turing Machine M is a type of non- deterministic TM, where each non-deterministic

Def: BPP is the class of all languages L for which there is a non-det poly time TM M, whose computation branches all have the same length, and

when xL Pr[M(x) accepts] 2/3 , when xL Pr[M(x) accepts] < 1/3 .

Def: LRP, if a NTM in poly time. when xL Pr[M(x) accepts] 2/3 , when xL Pr[M(x) accepts] =0 .

RPBPP. ?

ZPP Def: ZPP = RPco-RP .