Non-deterministic time

37
Non-deterministic time [AB 2]

description

Non-deterministic time. [AB 2]. Non-deterministic Turing Machines. Excluding “ _ ”.  and _. q reject q accept. 3. The accepted language. Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration - PowerPoint PPT Presentation

Transcript of Non-deterministic time

Page 1: Non-deterministic time

Non-deterministic time

[AB 2]

Page 2: Non-deterministic time

Next:

•Let us now consider a non realistic computational model: NONDETERMIONISTIC

Which:

•Mathematically natural

•can be simulated by DTMs

•However, with an exponential blowup in time.

2

Page 3: Non-deterministic time

• finite set of statesQ• input alphabet: a finite set • tape alphabet • :QP(Q{L,R}) - transition function• start stateq0

• accept stateQacc

• reject stateQrej3

Non-deterministic Turing Machines

3

Excluding “_”

and _

qrejectqaccept

power set

P(A)={B | BA}

Page 4: Non-deterministic time

The accepted language

Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

In particular if it rejects x, there is no path from an initial configuration to an accepting configuration in the configuration graph of x

Page 5: Non-deterministic time

Time complexity

Def: The running time of a NDTM T on input x

is the length of the longest path from an initial configuration to a terminating configuration.

Def: A NDTM T runs in time f(n) if for every input x, the running time of T on x is at most f(|x|).

Page 6: Non-deterministic time

• Let t:NN be a complexity function

Definition, Non-deterministic time:

Nondet. Polynomial time:

6

Time-Complexity

k

knNTIMENP

TM non time- by decided | ticdeterminisntOLLntNTIME

EXPNP

P

Page 7: Non-deterministic time

Non-deterministic computation

tree

Deterministic computation

7

Deterministic vs. Nondeterministic

Time

accepts if some computation accepts

Page 8: Non-deterministic time

Perfect Matching – Input G=(V,E). Yes instances: G has a perfect matching.No instances: G does not have a perfect matching.

MaxClique-atleast-kInput G=(V,E),k. Yes instances: G has a k-clique.No instances: G does not have a k-clique.

Examples

8

Page 9: Non-deterministic time

No Perfect Matching – Input G=(V,E). No instances: G has a perfect matching.Yes instances: G does not have a perfect matching.

MaxClique-atmost-kInput G=(V,E),k. No instances: G has a k-clique.Yes instances: G does not have a k-clique.

What about

9

Page 10: Non-deterministic time

Co-NP

NP

P

10

P, NP and co-NPcoL= *-L

coNP== {coL | LNP}

Page 11: Non-deterministic time

A language L belongs to NP if there exists A polynomial p(n)A polynomial time TM M

Such that

xL iff u {0,1}p(n) s.t. M(x,u)=1

Any u s.t. M(x,u)=1 is called a witness for xL

NP – second definition

11

Page 12: Non-deterministic time

Nondet. TM

A verifier

magically guess which

transitions to take to eventually accept if possible

Verifies a witness,

certificate to the fact that xL

Witness Verification Program

12

Page 13: Non-deterministic time

13

Nodeterministic

GuessTraverse from s to t

A prime factorization

Isomorphism

VerifyIs it a path from s to

t?

Primes, product =N

Does transform G into G’?

Page 14: Non-deterministic time

Proof:

Suppose L belongs to NP, solvable by M(x,u).

Algorithm in PSPACE:

Given x {0,1}n , try sequentially all u {0,1}p(n)

and accept iff for some u, M(x,u)=1.

NP PSPACE

14

Page 15: Non-deterministic time

Defined complexity classes via bounds on TMs:

• Polynomial timeP

• Nondeterministic Poly time

NP

• Complement of NPcoNP

• Exponential timeEXPTIME

• Logarithmic spaceL

• Polynomial SpacePSPACE15

EXP

PSPACE

NPcoNP

P

L

Page 16: Non-deterministic time

anbncn

STCON

Perfect

matching

Hamiltonian

Path

Factoring

Name the Class

16

EXPPSPACENP

P

NL

L

Page 17: Non-deterministic time

• A Boolean formula.

SAT Instance:

• Is the formula satisfiable?

Decision Problem:

17

SAT

SA

T o

r u

nS

AT

?

)x(x) x) xx((x 231321 11 xx

EXP

PSPACENPcoNP

P

L

Theorem:

• SAT is in NP

Proof:

• Can verify an ass. efficiently

Page 18: Non-deterministic time

• SAT is NP-Complete

Theorem:

• Given an NP machine M(x,w) and an input x,

construct a Boolean formula M,x M,x (w,auxiliary variables) is satisfiable M(x,w)=1

Proof Outline:

18

Cook/LevinSIP 254-259, AB 2.3

xLM ,x SAT

Page 19: Non-deterministic time

# q0 X2 X3 Wp(n) _ _ _ #

# ? q? X3 Wp(n) _ _ _ #

# #

# #

# #

# #

# #

# #

# #

# #

# qacc _ _ _ _ _ _ _ _ #Tapeends

Input

State +cell

content

19

TableauxRepresent a computation as a configurations` table

cne

Page 20: Non-deterministic time

20

Example• = {q0,q1,qaccept,qreject}

Q

• = {0, 1}

• = {0,1,q*,_}

• (q0,1)={(q1,_,R)}• (q1,1)={(q0,_,R)}• (q0,0)={(q0,_,R)}• (q1,0)={(q1,_,R)}• (q0,_)={(qacc,_,L)}• (q1,_)={(qrej,_,L)}

# q00 0 1 1 1 #

# _ q00 1 1 1 #

# _ _ q01 1 1 #

# _ _ _ q11 1 #

# _ _ _ _ q01 #

# _ _ _ _ _ q1_

# _ _ _ _ qrej _

Page 21: Non-deterministic time

21

M(Q{#})4• = {q0,q1,qaccept,qreject}

Q • = {0, 1}

• = {0, 1, q*, _}

• (q0,1)={(q1,_,R)}• (q1,1)={(q0,_,R)}• (q0,0)={(q0,_,R)}• (q1,0)={(q1,_,R)}• (q0,_)={(qacc,_,L)}• (q1,_)={(qrej,_,L)}

q00 0 0

.. q30 ..

# q00 0

.. q01 ..

_ 0 0

.. q00 ..

1 0 0

.. 1 ..

1 0 0

.. 0 ..

q00 0 0

.. q31 ..

Page 22: Non-deterministic time

# q0 x1 x2 Wm _ _ _ #

# ? q? x2 Wm _ _ _ #

# #

# #

# S #

# #

# #

# #

# #

# #

# qacc _ _ _ _ _ _ _ _ #22

M,x variablesBoolean Xi,j,S standing for:does cell i,j has value S? cn

e

i

j

Page 23: Non-deterministic time

1 value for each entry

input consistent

transitions legal

machine accepts

0,0,# 1,0, 2,0, ',0, ' 1,0,_ ,0,_ 1,0,#21e eX X X X X X Xq x n w n cn cnix m

,M x

23

M,w

acce qjicnjiX ,,

,0

, , 1, 1, 1 , 1, 2 1, 1, 3( , 1, 2, 3)1 , e i j s i j s i j s i j ss s s s Validi j cn

X X X X

input blanks

accepting configuration

start

locally legal transition

)xx(x tj,i,sj,i,#ts

sj,i,#sji,1 QQcne

≥1 value

<2 values

Page 24: Non-deterministic time

,M x

24

Q.E.D.

acce qjicnjiX ,,

,0

, , 1, 1, 1 , 1, 2 1, 1, 3( , 1, 2, 3)1 , e i j s i j s i j s i j ss s s s Validi j cnX X X X

)xx(x tj,i,sj,i,#ts

sj,i,#sji,1 QQcne

• tableau legal i,j transition is locally legal

Claim:

• M,x Satisfiable xLM

Corollary:

• Size of M,x polynomial in |x|

Claim:

0,0,# 1,0, 2,0, ',0, ' 1,0,_ ,0,_ 1,0,#21e eX X X X X X Xq x n w n cn cnix m

Page 25: Non-deterministic time

ANY NP LANGUAG

E

•JUST SHOWN

SAT

25

SAT is NPCWe have just shown SAT is NP-hard, as any NP language can be reduced to SAT

Page 26: Non-deterministic time

Co-NPNP

PNPC

26

P, NP, co-NP and NPC

SAT

Page 27: Non-deterministic time

ANY NP LANGUAG

E

• JUST SHOWN

SAT • SHOW

A

27

NPCClaim: To show a problem A is NP-hard, it suffices to reduce SAT to

A

Page 28: Non-deterministic time

ANY NP LANGUAG

E

• SHOWN

A • SHOW

B

28

NPCFurthermore, once we’ve shown A is NP-hard, we can reduce from it to show other problems NP-hard

Page 29: Non-deterministic time

proved SAT is NP-Complete

Consider SAT the Genesis problem, show other problems are NP-hard

29

Summary so far

Page 30: Non-deterministic time

30

Goal:

•introduce some additional NP-Complete problems.

Plan:

•3SAT•CLIQUE & INDEPENDENT-SET

Page 31: Non-deterministic time

So far we only showed one such problem: SAT

• 3SAT

Next we show a special case of SAT is NPC:

• 3CNF formula

3SAT Instance:

• Is it satisfiable?

Decision Problem:

31

3SAT• L In NP• L NP-hard – via Karp-

reduction

Recall: L is NPC if

Conjunctive Normal

Form – 3 literals in each

clause

3C

NF:

(xyz)(xyz)

(xxx)(xxx)

Page 32: Non-deterministic time

• CNF NPClaim:

• CNF NP-hardClaim:

• amend our SAT formula, so it becomes CNF• To make it a CNF: use DNFCNF on 3rd line

Proof:

32

CNF is NPCSIP 259-260

CNF is a

special case of

SAT.

acce qjicnjiX ,,

,0

)xx(x tj,i,sj,i,#ts

sj,i,#sji,1 QQcne

What is the size of new

formula?

wM ,

, , 1, 1, 1 , 1, 2 1, 1, 3( , 1, 2, 3)1 , e i j s i j s i j s i j ss s s s Validi j cnX X X X

0,0,# 1,0, 2,0, ',0, ' 1,0,_ ,0,_ 1,0,#21e eX X X X X X Xq x n w n cn cnix m

Page 33: Non-deterministic time

(xy)(x1x2... xt)...

33

CNF3CNF

clauses with 1 or 2 literals

(xyx)

replication

clauses with more than 3 literals

split

(x1 x2 c11)(c11 x3 c12)... (c1t-3 xt-1xt)

QED

3SAT is NP-

Complete

Page 34: Non-deterministic time

• CLIQUE NP

Observation:

• Given C, verify all inner edges are in G

Proof:

• A graph G=(V,E) and a threshold k

CLIQUE instance:

• Is there a set of nodes C={v1,...,vk}V, s.t. u,vC: (u,v)E

Decision problem:

34

CLIQUE is NPC

Page 35: Non-deterministic time

3S

AT

C

LIQ

UE

G,k

35

3SAT L CLIQUE

001 010 111

101

7 vertex for each clauseedge consistency

k = number of clauses

Page 36: Non-deterministic time

SAT p CLIQUE: proof

• Let A be a satisfying assignment to , C(A) is the set of vertices that correspond to this assignment.

Completeness:

• A clique C in G of size k corresponds to a satisfying assignment to

Soundness:

36

SIP 251-253

Page 37: Non-deterministic time

• A graph G=(V,E) and a threshold k

IS instance:

• Is there a set of nodes I={v1,...,vk}V, s.t. u,vI: (u,v)E

Decision problem:

37

INDEPENDENT-SET is NPC

• IS NPObservation:

• Given I, verify all inner edges not in GProof:

• IS is NP-hard

Observation:

CliqueIS on complement graph