37
Non-deterministic time [AB 2]

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

Embed Size (px)

Citation preview

Page 1: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

Non-deterministic time

[AB 2]

Page 2: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

• 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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

• 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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

Non-deterministic computation

tree

Deterministic computation

7

Deterministic vs. Nondeterministic

Time

accepts if some computation accepts

Page 8: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

Co-NP

NP

P

10

P, NP and co-NPcoL= *-L

coNP== {coL | LNP}

Page 11: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

anbncn

STCON

Perfect

matching

Hamiltonian

Path

Factoring

Name the Class

16

EXPPSPACENP

P

NL

L

Page 17: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

• 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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

• SAT is NP-Complete

Theorem:

• Given an NP machine M and an input w, construct a Boolean formula M,w M,w satisfiable M accepts w.

Proof Outline:

18

Cook/LevinSIP 254-259, AB 2.3

LM M,w SAT

Page 19: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

# q0 X2 X3 Xn _ _ _ #

# ? q? X3 Xn _ _ _ #

# #

# #

# #

# #

# #

# #

# #

# #

# qacc _ _ _ _ _ _ _ _ #

State +cell

content

Tapeends

Input

19

TableauxRepresent a computation as a configurations` table

cne

Page 20: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

# q0 W1 W2 Wn _ _ _ #

# ? q? W2 Wn _ _ _ #

# #

# #

# S #

# #

# #

# #

# #

# #

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

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

e

i

j

Page 23: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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 w n w n cn cniw n

wM ,

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

wM ,

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,w Satisfiable WLM

Corollary:

• Size of M,w polynomial in |W|

Claim:

0,0,# 1,0, 2,0, ,0, 1,0,_ ,0,_ 1,0,#21e eX X X X X X Xq w n w n cn cniw n

Page 25: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

Co-NPNP

PNPC

26

P, NP, co-NP and NPC

SAT

Page 27: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

ANY NP LANGUAG

E

• JUST SHOWN

SAT • SHOW

A

27

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

A

Page 28: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

proved SAT is NP-Complete

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

29

Summary so far

Page 30: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

30

Goal:

•introduce some additional NP-Complete problems.

Plan:

•3SAT•CLIQUE & INDEPENDENT-SET

Page 31: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

• 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 w n w n cn cniw n

Page 33: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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

33

CNF3CNF

Complexi

ty©D.Moshkovitz

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

• 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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

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: [AB 2]. 2 3 3 Def: A Non-deterministic Turing machine (NDTM) accepts L iff there exists a path from an initial configuration to an accepting configuration

• 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