Lecture 8: Computational Complexity

143
Lecture 8: Computational Complexity 虞虞虞 虞虞虞虞虞虞虞 虞虞虞虞虞 虞虞虞

description

Lecture 8: Computational Complexity. 虞台文. 大同大學資工所 智慧型多媒體研究室. Content. Time-Bounded Turing Machine Rate of Growth Functions Time-Bound Simulations P and NP NP –Completeness Bounded Halting Problems Some Important NP -Complete Problems. Lecture 8: Computational Complexity. - PowerPoint PPT Presentation

Transcript of Lecture 8: Computational Complexity

Page 1: Lecture 8:  Computational Complexity

Lecture 8: Computational Complexity

虞台文大同大學資工所智慧型多媒體研究室

Page 2: Lecture 8:  Computational Complexity

Content

Time-Bounded Turing Machine Rate of Growth Functions Time-Bound Simulations P and NP NP –Completeness Bounded Halting Problems Some Important NP-Complete Problems

Page 3: Lecture 8:  Computational Complexity

Lecture 8: Computational Complexity

Time-Bounded Turing Machine

大同大學資工所智慧型多媒體研究室

Page 4: Lecture 8:  Computational Complexity

Computational Effectiveness for Solvable Problems

Not Solvable Solvable

Can such a problem, e.g., TSP,

be solved in any practical sense?

Page 5: Lecture 8:  Computational Complexity

Yields in t Steps tM├

C C0M├ iff C C

C C1tM├ iff

C such that

C CtM├ and C C M├

Page 6: Lecture 8:  Computational Complexity

Time-Bounded TM

Let T: N N be a function. Let L be a

language, and let be a k-tape TM

with 0 . We say that M decides L in time T if

the following holds:

*0

, , ,M K s

1. w L

2. w L

, # #, #, , # , # #, #, , #s w h Y tM├ for some t T(|w|);

, # #, #, , # , # #, #, , #s w h N tM├ for some t T(|w|);

Page 7: Lecture 8:  Computational Complexity

TIME(T)

We say that L is decidable in time T if there is some k-tape TM (k > 0) that decides L in time T.

The class of all languages decidable in time T is denoted by

( )TIME T

Page 8: Lecture 8:  Computational Complexity

Absolute Time Bound (2n + 4)

n

# w #

Head

Y/N ##

Head

>L ##

RYR

#

>L ##

RNR

#

• |w|+1 writing steps

• |w|+3 head-moving steps

erase w (write ‘#’)write ‘Y’ or ‘N’

( ) 2 4T n n

Page 9: Lecture 8:  Computational Complexity

Lecture 8: Computational Complexity

Rate ofGrowth Functions

大同大學資工所智慧型多媒體研究室

Page 10: Lecture 8:  Computational Complexity

Time-Bound Notations

Upper Bound

Lower Bound

Exact Bound

( )f O g

, :f g N N

( )f g

( )f g

0 0st , ( ) i( ) fc n f n cg n n n

0 0st , ( ) i( ) fc n f n cg n n n

1 2 0 1 2 0, , ( ) (st if) ( )c c n c g n f n c g n n n

Page 11: Lecture 8:  Computational Complexity

Time-Bound Notations

Upper Bound

Lower Bound

Exact Bound

( )f O g

, :f g N N

( )f g

( )f g

0 0st , ( ) i( ) fc n f n cg n n n

0 0st , ( ) i( ) fc n f n cg n n n

1 2 0 1 2 0, , ( ) (st if) ( )c c n c g n f n c g n n n

Fact:

( ) ( ) an ( )df g f O g f g

Page 12: Lecture 8:  Computational Complexity

Lemma

0

( ) 0 d

jj d

j

f n a n a

with

1 1

( ) ( )

( ) (

a)

b) and ) ( ) ( )

d

d d

f n n

f n O n f n n

Page 13: Lecture 8:  Computational Complexity

Lemma0

( ) 0 d

jj d

j

f n a n a

with

1 1

a)

b) and

( )

( ) ( )

d

d d

f n n

f n O n f n n

Pf)For a, we need to prove and .( ) ( )df n O n ( )dn O f n

( ) ( )df n O n

0 0

( ) ( ) | | | |d d

j dj j

j j

f n f n a n n a

c

( )dn O f n

0( ) if dn cf n n n

0( ) 0 if dcf n n n n

Therefore, we have to find c (exercise) such that

11( ) ( 1) 0d d d

d dcf n n ca n ca n

Page 14: Lecture 8:  Computational Complexity

Lemma0

( ) 0 d

jj d

j

f n a n a

with

1 1

a)

b) and

( )

( ) ( )

d

d d

f n n

f n O n f n n

Pf)1( ) ( )df n O n

1df n

1 ( )d dn O n

Suppose that nd+1 = O(nd), Then, nnd = nd+1 cnd for n n0.But for any c, when n > c, nd+1 cnd.

Since f = O(nd), we only need to show that nd = O(nd+1), which is trivially satisfied because nd nd+1 for all n 0.

Page 15: Lecture 8:  Computational Complexity

Theorem

0

( 0. ) d

jj d

j

f n a n a

Let with Then,

( ) ( ), 1.nf n O r r

Page 16: Lecture 8:  Computational Complexity

Theorem0

( 0. ) d

jj d

j

f n a n a

Let with Then,

( ) ( ), 1.nf n O r r

Pf) Because f = O(nd), we only need to prove that nd = O(rn), i.e.,

0 d nn cr n n f or0

0( ) 0n kdn k cr k f or

0 0 00 0

0 0 0

1 2( )

1 1

d d d

d d n n n kn k n

n n n k

00 0 0

1 1 11 1 1

1 1

d d d

dnn n n k

k terms

00

11

kd

dnn

0 0n k n kcr cr r

Page 17: Lecture 8:  Computational Complexity

Theorem0

( 0. ) d

jj d

j

f n a n a

Let with Then,

( ) ( ), 1.nf n O r r

Pf) Because f = O(nd), we only need to prove that nd = O(rn), i.e.,

0 d nn cr n n f or0

0( ) 0n kdn k cr k f or

0 00 0

0

1( ) 1

kd

d d n k n kn k nn

cr cr r

Let 00dncr n

0

0n

dnc

r

0

11

d

rn

1/

0

11 dr

n

1/

0

11dr

n 0 1/

1

1dn

r

Hence, nd = O(rn).

Page 18: Lecture 8:  Computational Complexity

Lecture 8: Computational Complexity

Time-Bound Simulations

大同大學資工所智慧型多媒體研究室

Page 19: Lecture 8:  Computational Complexity

Time-Complexities on TMs

Not Solvable Solvable

The complexities to solve problems

on different TMs are different.

Page 20: Lecture 8:  Computational Complexity

Theorem 1

1 22-way standardinfinite 1-way

tape tape

L TIME T L TIME T

where 2 1( ) 6 ( ) 3 8.T n T n n

Page 21: Lecture 8:  Computational Complexity

Theorem 2

1 2-tape standard

1-waytape

k

L TIME T L TIME T

where

22 1 1( ) 4 ( ) (4 4 3) ( ) 5 15.T n T n n k T n n

Page 22: Lecture 8:  Computational Complexity

Conclusions

A polynomial algorithm of any TM can be simulated using some polynomial algorithms of other TM’s.

In the following, we consider two classes of problems:– Polynomial algorithms (P)– Exponential algorithms (NP)

?

Page 23: Lecture 8:  Computational Complexity

Lecture 8: Computational Complexity

P and NP

大同大學資工所智慧型多媒體研究室

Page 24: Lecture 8:  Computational Complexity

Definition (P )

( ) : 0dTIME n d P

That is, P denotes the class of all languages that are decided by TM’s in some polynomial time bounds.

Page 25: Lecture 8:  Computational Complexity

Example: (Integer Programming)

1

, 1, 2, ,n

ij j ij

a x b i m

Does

have solution in 0 and 1?

0-1

Matrix formulation:

ij m nA a

1

m

b

b

b

1

n

x

x

x

Given A and b, is there any binary vector x such that

Ax b

Page 26: Lecture 8:  Computational Complexity

Example: (Integer Programming)

Given A and b, is there any binary vector x such that

Ax b

1 3

2 3

2 3

3 2 2

x x

x x

1

2

3

1 0 2 3

0 3 2 2

x

x

x

A x b

Encode: ( )A II I III I IIc c II IIIc c cc ( )b IIII IIccI

( ) ( ) has a binary soluti@ onB A b Ax b Language

?BP No answer!

Page 27: Lecture 8:  Computational Complexity

Example: (Integer Programming)

Given A and b, is there any binary vector x such that

Ax b

( ) ( ) has a binary soluti@ onB A b Ax b Language

?BP No answer!

( ) ( ) ( ) is a binary solut@ ion to $B A b x x Ax b

Language

?BP Yes, it is.

3B TIME nFact:

Page 28: Lecture 8:  Computational Complexity

Definition

:T N N*0 0, L

( , , , )M K s

M accepts L in nondeterministic time T if the following holds

For all ,*0w

( , # #) ( , )w L s w h u v iff tM├

for some u, v *, , and t T(|w|).

We say that L is acceptable in nondeterministic time T if there is an NTM that accepts L in nondeterministic time T.

Page 29: Lecture 8:  Computational Complexity

Definition

( )NTIME TThe class of languages acceptable in nondeterministic time T.

What is the difference between TIME(T) and NTIME(T)?

Page 30: Lecture 8:  Computational Complexity

Definition (NP )

( ) : 0dNTIME n d NP

That is, NP denotes the class of all languages that are accepted by NTM’s in some nondeterministic polynomial time bounds.

Page 31: Lecture 8:  Computational Complexity

Definition (Step Counting Function)

f : NN is a step-counting function if a k-tape Turing machine M such that for all w*, M halts in exactly f(|w|) steps on input w, i.e.,

1 1 1( , # #, , #) ( , , , )k k ks w h u a v u a v (| |)Mf w├

for some u1, …, uk, v1, …, vk * and a1, …, ak.

Page 32: Lecture 8:  Computational Complexity

Exercise

Given d >0, there exists a polynomial p of

degree d being a step counting function.

Page 33: Lecture 8:  Computational Complexity

Theorem 3

Let L be a language accepted in time T1 by

a NTM M1=(K1, 1, 1, s1) where T1 is a step

counting function.

A k2-tape DTM M2=(K2, 2, 2, s2) decides L in time T2 where

1 ( )2 2( ) ( 1, and 1)T nT n r k r

See text for the proof.

Page 34: Lecture 8:  Computational Complexity

Polynomial Balanced Languages

Let L *$* be a language, where $.

Then, L is said to be polynomial balanced

if there exists a polynomial p such that

| | | | .$x Ly y p x only if

Page 35: Lecture 8:  Computational Complexity

Theorem 4

Let L * be a language, $ and ||

2.

* \ $ ,L L L andPL NP iff L’ *$* such that

where L’ is a polynomial balanced language.

Page 36: Lecture 8:  Computational Complexity

Theorem 4

Pf) “”

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

L’ is a p.b.l. Polynomial p s.t. x$yL’ only if |y| p(|x|).

L’P k–tape DTM M’ that decides L’ in time q (a polynomial).

To prove L NP, we construct an NTM M based on M’ to accept L as follows:

M’:

>RNR

M’’:

>RNR

M: >$(1)

(1)1

(1)m

. . .

M’’

Page 37: Lecture 8:  Computational Complexity

Theorem 4

Pf) “”

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

L’ is a p.b.l. Polynomial p s.t. x$yL’ only if |y| p(|x|).

L’P k–tape DTM M’ that decides L’ in time q (a polynomial).

To prove L NP, we construct an NTM M based on M’ to accept L as follows:

M’:

>RNR

M’’:

>RNR

M: >$(1)

(1)1

(1)m

. . .

M’’

M can be accept L in nondeterministic time p + q.

Hence, L NP.

M can be accept L in nondeterministic time p + q.

Hence, L NP.

Page 38: Lecture 8:  Computational Complexity

Theorem 4

Pf) “”

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

We shall show that L’ = {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’ can decides L’ in polynomial time.

Y(x)=? M’ =?

Page 39: Lecture 8:  Computational Complexity

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

Theorem 4

Pf) “”

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?Since LNP, an NTM M

that accept L in

nondeterministic time q (a

polynomial).That is, given xL, we have

such that0 1 tC C C├M ├M ├M

. . .

0 ( , # #)C s x( , )tC h w u | |t q x

Let be the encoding function that encodes TM’s and their memory configurations in {I,

c}*.Let Y(x) be the set of all strings

0( )@ ( )@ @ ( )ty M C C

where M is the NTM that accepts L.

Page 40: Lecture 8:  Computational Complexity

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

Theorem 4

Pf) “”

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?0( )@ ( )@ @ ( )ty M C C

0

( ) ( ) #@'t

jj

y M C s

constant to be discussed

q(|x|)

| | | |jC q x x input length

accept in time q

(| |) | |jC M q x x

Page 41: Lecture 8:  Computational Complexity

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

Theorem 4

Pf) “”

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

0

( ) ( ) #@'t

jj

y M C s

q(|x|)

| | | |jC q x x (| |) | |jC M q x x

( ) (| |) 2 (| |) | | (| |)M q x q x x q x

0( )@ ( )@ @ ( )ty M C C

Page 42: Lecture 8:  Computational Complexity

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

Theorem 4

Pf) “”

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

0

( ) ( ) #@'t

jj

y M C s

( ) (| |) 2 (| |) | | (| |)M q x q x x q x

Polynomial of |x|

0( )@ ( )@ @ ( )ty M C C

Page 43: Lecture 8:  Computational Complexity

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

Theorem 4

Pf) “”

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

0

( ) ( ) #@'t

jj

y M C s

( ) (| |) 2 (| |) | | (| |)M q x q x x q x

Let $ , ( )L x y x L y Y x

0( )@ ( )@ @ ( )ty M C C

L’ is polynomial balanced.

Page 44: Lecture 8:  Computational Complexity

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

Theorem 4

Pf) “”

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

We shall show that

L’= {x$Y(x) : x L, |Y(x)| p(|x|)},

where p is a polynomial, such that L’P, i.e.,

a DTM M’can decides L’ in polynomial time.

Y(x)=? M’ =?

0

( ) ( ) #@'t

jj

y M C s

( ) (| |) 2 (| |) | | (| |)M q x q x x q x

Let $ , ( )L x y x L y Y x

0( )@ ( )@ @ ( )ty M C C

L’ is polynomial balanced.

?

Page 45: Lecture 8:  Computational Complexity

Let L * be a language, $ and ||

2.

* \ $ .L L L andP

L NP iff L’ *$* such that

where L’ is a p.b.l.

Theorem 4

Pf) “” $ , ( )L x y x L y Y x We now show that L’P by designing a DTM M’ which decides L’ as follows:

1. Check the syntax of the input string

To verify the following things:a) Is Cj a configuration of M?b) C0 = (s, #x#)?c) Ct = (h, uv)?

If rejected, print out ‘N’ then halt. This steps requires O(n) time.2. Check Cj├M Cj+1, j= 0, …, t1 by consulting (M). If rejected print out ‘

N’ and then halt. This steps requires O(n2).3. Therefore, L’P.

0$ ( )@ ( )@ @ ( )tw x M C C

Page 46: Lecture 8:  Computational Complexity

Example (Integer Programming BNP )

( ) ( ) has a binary soluti@ onB A b Ax b

( ) ( ) ( ) is a binary solut@ ion to $B A b x x Ax b

| | (| |)| |

Polynomial Balanced

$ ( ) ( ) ( @ )w O ww

A b x B

3( )B TIME n P BNP

Page 47: Lecture 8:  Computational Complexity

Example (Integer Programming BNP )

( ) ( ) has a binary soluti@ onB A b Ax b

( ) ( ) ( ) is a binary solut@ ion to $B A b x x Ax b

3( )B TIME n P BNP

?BPNo answer

Page 48: Lecture 8:  Computational Complexity

Is P = NP ?

NPP

How to show?

P NPShow NP Pand

Trivial (why?) DifficultNo answer, now.

Page 49: Lecture 8:  Computational Complexity

Example (TSPNP )

1

2

5

3

4

6

7

8

[ ]ijD d Distance matrix

TSPF

Find the shortest tour t.

Page 50: Lecture 8:  Computational Complexity

Example (TSPNP )

1

2

5

3

4

6

7

8

[ ]ijD d Distance matrix

TSPF

Find the shortest tour t.

:[1, 2, , ] [1,2, , ]t n n t is a bijection E.g.

,1 7 6 4 5 3 8

1 2 3 4 5 6 7 8

2

It is not language decision problem. Rather, it is a problem of function evaluation.

Page 51: Lecture 8:  Computational Complexity

Example (TSPNP )

[ ]ijD d Distance matrix

TSPF Find the shortest tour t.

TSP Denote the cost of t as D(t).

@ ( )@ a tour with ( )n bTSP I D I t D t b

1

2

5

3

4

6

7

8

1

2

5

3

4

6

7

8

TSP’

( )@ ( )@ ( )$n bTSP I D I bt D t

Polynomial balanced

P

NP

Page 52: Lecture 8:  Computational Complexity

Exercises

Show that

1. TSPNP.

2. TSPP a polynomial algorithm for TSPF.

3. TSP’P.

Page 53: Lecture 8:  Computational Complexity

Remark

TSPP P = NP

Page 54: Lecture 8:  Computational Complexity

Lecture 8: Computational Complexity

NP-Completeness

大同大學資工所智慧型多媒體研究室

Page 55: Lecture 8:  Computational Complexity

Definition: Polynomial-Time Computable

* *1 2:f is said to be computed in time T if

a k-tape DTM s.t.

, # #, #, , # , # ( ) #, #, , #s x h f x tM├

with t T(|x|).

Furthermore, if T(|x|) is a polynomial, then f is said to be polynomial-time computable.

Page 56: Lecture 8:  Computational Complexity

Definition: Polynomial-Time Reduction

be polynomial-time computable.* *1 2:

Then L1 is said to be polynomial-time reducible to L2 iff

Let and be languages,*1 1L *

2 2L

1 2( )x L x L

Page 57: Lecture 8:  Computational Complexity

More on Polynomial Reduction

L2 P L1 P.

Transitivity

. .1 2( )p rx L x L

Time to decide 21 ) ( ) ?(x xL x L

. . . .1 2 3

p r p rL L L

p.r.

Page 58: Lecture 8:  Computational Complexity

Definition: NP-Completeness

is called NP-complete iff*L

1. LNP

2.

.

L

L L

NP

is polynomial reducible to

Page 59: Lecture 8:  Computational Complexity

More on NP-Completeness

1. LNP..2. .p rL L L NP

NP

P

L

NP-Complete

p.r.p.r.

Page 60: Lecture 8:  Computational Complexity

Not Solvable Solvable

NP-Hard

1. LNP..2. .p rL L L NP

NP

P

L

NP-Complete

p.r.p.r.

NP-Hard

Page 61: Lecture 8:  Computational Complexity

Important Theorem

1. LNP..2. .p rL L L NP

Let L be an NP-complete language.

Then, L P NP P.NP

P

L

NP-Complete

p.r.

Pf)“”

“”

L P NP P.

L P P NP.

trivial

trivial

Page 62: Lecture 8:  Computational Complexity

Remark

NP

P

L

NP-Complete

p.r.

If one can decide any NP-complete language in polynomial time, then all languages in NP can be decided effectively.

Surely, the guy will win Turing Award.

Page 63: Lecture 8:  Computational Complexity

Lecture 8: Computational Complexity

Bounded Halting Problems

大同大學資工所智慧型多媒體研究室

Page 64: Lecture 8:  Computational Complexity

Bounded Halting Problem N0

0

The NTM accepts input( ) ( )

in or fewer steps@ tN M w I

M

w t

Fact:

Halting problem is not solvable.

Is Bounded Halting problem is solvable?

Page 65: Lecture 8:  Computational Complexity

Theorem: N0 is NP-Complete

0

The NTM accepts input( ) ( )

in or fewer steps@ tN M w I

M

w t

01. N NP

.0

.2. .p rL L N NP

Page 66: Lecture 8:  Computational Complexity

Theorem: N0 is NP-Complete

0

The NTM accepts input( ) ( )

in or fewer steps@ tN M w I

M

w t

01. N NP

Define

0 1

0

0 0

1

( ) ( ) ( ) ( ) ( )

such that

(a) ( , , , ) an NTM

(b) a configuration of

(c) ( , # #), ( , )

(d)

(e)

@ @ @ @

$tt

i

i i

M w I C C C

M K s

C M

C s w C h u v

C C

t t

N

Page 67: Lecture 8:  Computational Complexity

Theorem: N0 is NP-Complete

0

The NTM accepts input( ) ( )

in or fewer step@

stN M I

M

w t

01. N NP

Define

1

1

0

0

0 0

( ) ( ) ( ) ( ) ( )

such that

(a) ( , , , ) an NTM

(b) a configuration of

(c) ( , # #), ( , )

(d)

(e

$ @

)

@

@ @tt

i

i i

M I C C C

M K s

C M

C s w C h u v

C C

t t

N

0

0

polynomial balanceN

N

P 0N NP

Exercise

Page 68: Lecture 8:  Computational Complexity

Theorem: N0 is NP-Complete

0

The NTM accepts input( ) ( )

in or fewer step@

stN M I

M

w t

.0

.2. .p rL L N NPFor any LNP, find L.

• LNP: NTM

: polynomial

L

L

ML

p

to accept

• Let | |( ) ( ) ( )@ LP wLL w w IM

• Fact: L(w) is polynomial computable.

• w L L(w) N0.

Page 69: Lecture 8:  Computational Complexity

The Language0N̂

0

The NTM accepts inp

2 | |

utˆ ( ) ( ) in or fewer steps

NM

u uM u

0

The NTM accepts input( ) ( )

in or fewer steps@ tN M u I

M

u t

Page 70: Lecture 8:  Computational Complexity

Theorem: is NP-Complete0N̂

0

The NTM accepts inp

2 | |

utˆ ( ) ( ) in or fewer steps

NM

u uM u

0

The NTM accepts input( ) ( )

in or fewer steps@ tN M u I

M

u t

0. ˆ1 N NP. .

0 0ˆ2. p rN N

Exercise

Find .

Page 71: Lecture 8:  Computational Complexity

Theorem: is NP-Complete0N̂ 0

ˆ ( ) ( ) 2 | | stepsuN M u

0 @( ) ( ) steps.tN M u I t

.0

.0: ˆ p rN N Find

( ) ( )@ tw M u I ( ) ( ) ( )w M u

0w N

. .p r 0

ˆ( )w N

?M ?u

Page 72: Lecture 8:  Computational Complexity

Theorem: is NP-Complete0N̂ 0

ˆ ( ) ( ) 2 | | stepsuN M u

0 @( ) ( ) steps.tN M u I t

.0

.0: ˆ p rN N Find

( ) ( )@ tw M u I ( ) ( ) ( )w M u

0w N

. .p r 0

ˆ( )w N

Case 1. ( ) ( ) 2 | | 2, @ tw M u I t u

2 2| |#t uu u #

: M L RM #

t + 2 2|u| + 2 + t

= 2t + 4 2|u| =2|u’|

Page 73: Lecture 8:  Computational Complexity

Theorem: is NP-Complete0N̂ 0

ˆ ( ) ( ) 2 | | stepsuN M u

0 @( ) ( ) steps.tN M u I t

.0

.0: ˆ p rN N Find

( ) ( )@ tw M u I ( ) ( ) ( )w M u

0w N

. .p r 0

ˆ( )w N

Case 1. ( ) ( ) 2 | | 2, @ tw M u I t u

2 2| |#t uu u #

: M L RM #

t + 2 2|u| + 2 + t

= 2t + 4 2|u|

Halt within t steps.

Halt within t steps.

Halt within 2|u’|

steps.

Halt within 2|u’|

steps.

=2|u’|

Page 74: Lecture 8:  Computational Complexity

Theorem: is NP-Complete0N̂ 0

ˆ ( ) ( ) 2 | | stepsuN M u

0 @( ) ( ) steps.tN M u I t

.0

.0: ˆ p rN N Find

( ) ( )@ tw M u I ( ) ( ) ( )w M u

0w N

. .p r 0

ˆ( )w N

Case 2. ( ) ( ) 2 | | 2, @ tw M u I t u

u u 2| |: u tM MR t +2|u| t =2|u| =2|u’|

Page 75: Lecture 8:  Computational Complexity

Theorem: is NP-Complete0N̂ 0

ˆ ( ) ( ) 2 | | stepsuN M u

0 @( ) ( ) steps.tN M u I t

.0

.0: ˆ p rN N Find

( ) ( )@ tw M u I ( ) ( ) ( )w M u

0w N

. .p r 0

ˆ( )w N

Case 2. ( ) ( ) 2 | | 2, @ tw M u I t u

u u 2| |: u tM MR t +2|u| t =2|u| =2|u’|

Halt within t steps.

Halt within t steps.

Halt within 2|u’|

steps.

Halt within 2|u’|

steps.

Page 76: Lecture 8:  Computational Complexity

Theorem: is NP-Complete0N̂ 0

ˆ ( ) ( ) 2 | | stepsuN M u

0 @( ) ( ) steps.tN M u I t

.0

.0: ˆ p rN N Find

( ) ( )@ tw M u I ( ) ( ) ( )w M u

0w N

. .p r 0

ˆ( )w N

Hence,

is not in the form of ( ) ( )@ ( )

( ) ( ) is in the form of ( ) ( )@

t

t

I w M u Iw

M u w M u I

See previous slides

Page 77: Lecture 8:  Computational Complexity

Theorem: is NP-Complete0N̂

0. ˆ1 N NP. .

0 0ˆ2. p rN N

0ˆ ( ) ( ) 2 | | stepsuN M u

0 @( ) ( ) steps.tN M u I t

Known NP-complete

Summary of the proof:

Page 78: Lecture 8:  Computational Complexity

Special Bounded Halting Problem N2

0

The NTM accepts inp

2 | |

utˆ ( ) ( ) in or fewer steps

NM

u uM u

0

The NTM accepts input( ) ( )

in or fewer steps@ tN M u I

M

u t

2

( , , , ), and( )

( , #) ( , ) wi@

th t M K s

N M Is h u v t t

tM

Page 79: Lecture 8:  Computational Complexity

Theorem: N2 is NP-Complete

0ˆ ( ) ( )N M u

0 ( ) ( )@ tN M u I

2

( , , , ), and( )

( , #) ( , ) wi@

th t M K s

N M Is h u v t t

tM

0N0N̂. .p r LNP

2Np.r.

p.r.

Pf)21. N NP

2. . .p r

p.r.

? ? ?

obvious.

Page 80: Lecture 8:  Computational Complexity

Theorem: N2 is NP-Complete

0ˆ ( ) ( )N M u

0 ( ) ( )@ tN M u I

2

( , , , ), and( )

( , #) ( , ) wi@

th t M K s

N M Is h u v t t

tM

0N0N̂. .p r LNP

2Np.r.

Pf)21. N NP

2. . .p r

obvious.

= ?

Page 81: Lecture 8:  Computational Complexity

Theorem: N2 is NP-Complete

0 ( ) ( )@ tN M u I 2 ( )@ tN M I :( ) ( )@ tw M u I

0N0N̂. .p r LNP

2Np.r.

2. . .p r

= ?0N

0N̂. .p r LNP

2Np.r.p.r.

2. . .p r

= ?

( ) ( )@ tw M I

0w N 2( )w N

?M ?t

Page 82: Lecture 8:  Computational Complexity

Theorem: N2 is NP-Complete

0 ( ) ( )@ tN M u I 2 ( )@ tN M I :( ) ( )@ tw M u I

0N0N̂. .p r LNP

2Np.r.

2. . .p r

= ?0N

0N̂. .p r LNP

2Np.r.p.r.

2. . .p r

= ?

( ) ( )@ tw M I

0w N 2( )w N

(1) (2) (: | |)u u uM R R RMuR Let

2|u| 1 t

2 | | 1t t u

Page 83: Lecture 8:  Computational Complexity

Theorem: N2 is NP-Complete

0 ( ) ( )@ tN M u I 2 ( )@ tN M I :( ) ( )@ tw M u I

0N0N̂. .p r LNP

2Np.r.

2. . .p r

= ?0N

0N̂. .p r LNP

2Np.r.p.r.

2. . .p r

= ?

( ) ( )@ tw M I

0w N 2( )w N

(1) (2) (: | |)u u uM R R RMuR Let

2|u| 1 t

2 | | 1t t u

M halts on u in t stepsM halts on u in t steps

M ’ halts on in t ’ steps

M ’ halts on in t ’ steps

Page 84: Lecture 8:  Computational Complexity

Theorem: N2 is NP-Complete

0 ( ) ( )@ tN M u I 2 ( )@ tN M I :( ) ( )@ tw M u I ( ) ( )@ tw M I

0w N 2( )w N

(1) (2) (: | |)u u uM R R RMuR

2|u| 1 t

2 | | 1t t u

2| | 1

if is not in form of ( ) ( )( )

( ) if is in form of ( )@(@ )

@

t

t u t

I w M u Iw

M I w M u I

Page 85: Lecture 8:  Computational Complexity

Summary

0N0N̂. .p r LNP

2Np.r.

. .p r

Page 86: Lecture 8:  Computational Complexity

Lecture 8: Computational Complexity

Some Important NP-Complete

Problems

大同大學資工所智慧型多媒體研究室

Page 87: Lecture 8:  Computational Complexity

Bounded Tiling Problem (BT)

0( , , , )D d H VD

Tiling System:

D: a set of finite number of tiles.

d0D: the tile place at the origin.

HDD: the Horizontal tiling rule.

VDD: the Vertical tiling rule.

Page 88: Lecture 8:  Computational Complexity

Bounded Tiling Problem (BT)

0( , , , )D d H VD

Given D and s > 0, an s s tiling by D is a function

:[0,1, , 1] [0,1, , 1]f s s D

such that

01. (0,0)f d

2. ( , ), ( 1, )f m n f m n H

3. ( , ), ( , 1)f m n f m n V 0 1 2 3 4 5

0

1

2

3

4

5

0d

Page 89: Lecture 8:  Computational Complexity

Bounded Tiling Problem (BT)

0( , , , )D d H VD

( ) there is an tiling by @ sBT I s s D D

BT is NP-Complete

Page 90: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

0( , , , )D d H VD

( ) there is an tiling by @ sBT I s s D D

Pf)1. BT NP

2. 0N0N̂. .p r LNP

2Np.r.

. .p r

( ) ( ) is an tiling by $@ sBT I D D s s D Da p.b.l.P

BT. .p r

Page 91: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

2. 0N0N̂. .p r LNP

2Np.r.

. .p r

BT. .p r

2. 0N0N̂. .p r LNP

2Np.r.

. .p r 0N0N̂. .p r LNP

2Np.r.p.r.

. .p r

BT. .p r

( )@ sBT I D 2 ( )@ tN M I :( )@ tw M I ( ) ( )@ sw I D

2w N ( )w BT

0( , , , ) ?D d H V D?s

Page 92: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

2s t

0 1 t t+1

0

1

t

t+1

( )@ tw M I ( ) ( )@ sw I D

Page 93: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

2s t

0 1 t t+1

0

1

t

t+1

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

1) For each a, create tiles

(a, k)

(a, k+1)

0 k t

Page 94: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

1) For each a, create tiles

(a, k)

(a, k+1)

0 k t

0 1 6 7

0

1

2 3 4 5

2

3

4

5

6

7

. ., 6e g t 2 8s t

(a, 0)

(a, 1)

(a, 1)

(a, 2)

(a, 2)

(a, 3)

(a, 3)

(a, 4)

(a, 4)

(a, 5)

(a, 5)

(a, 6)

(a, 6)

(a, 7)

Page 95: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

2) For each (q, a, p, b) where b and q h, create tiles

(q, a, k)

(p, b, k+1)

0 k t

0 1 6 7

0

1

2 3 4 5

2

3

4

5

6

7

. ., 6e g t 2 8s t

(q, a, 0)

(p, b, 1)(q, a, 1)

(p, b, 2)(q, a, 2)

(p, b, 3)(q, a, 3)

(p, b, 4)(q, a, 4)

(p, b, 5)(q, a, 5)

(p, b, 6)

Can’t reach the highest layer if q h.

Page 96: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

3) For each (q, a, p, L) , create tiles

0 k t 0 1 6 7

0

1

2 3 4 5

2

3

4

5

6

7

. ., 6e g t 2 8s t

(q, a, k)

(a, k+1)p

(b, k)

(p, b, k+1)p

(q, a, 2)

(a, 3)

(b, 2)

(p, b, 3)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(b, 0)

(b, 1)

(b, 1)

(b, 2)

(a, 0)

(a, 1)

(a, 1)

(q, a, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

Page 97: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

3) For each (q, a, p, L) , create tiles

0 k t 0 1 6 7

0

1

2 3 4 5

2

3

4

5

6

7

. ., 6e g t 2 8s t

(q, a, k)

(a, k+1)p

(b, k)

(p, b, k+1)p

(q, a, 2)

(a, 3)

(b, 2)

(p, b, 3)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(b, 0)

(b, 1)

(b, 1)

(b, 2)

(a, 0)

(a, 1)

(a, 1)

(q, a, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(a, 3)

(a, 4)

(a, 4)

(a, 5)

(a, 5)

(a, 6)

(a, 6)

(a, 7)

Page 98: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

4) For each (q, a, p, R) , create tiles

0 k t 0 1 6 7

0

1

2 3 4 5

2

3

4

5

6

7

. ., 6e g t 2 8s t

(q, a, k)

(a, k+1)p

(b, k)

(p, b, k+1)p

(q, a, 2)

(a, 3)

(b, 2)

(p, b, 3)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(a, 0)

(a, 1)

(a, 1)

(q, a, 2)

(b, 0)

(b, 1)

(b, 1)

(b, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

Page 99: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

4) For each (q, a, p, R) , create tiles

0 k t 0 1 6 7

0

1

2 3 4 5

2

3

4

5

6

7

. ., 6e g t 2 8s t

(q, a, k)

(a, k+1)p

(b, k)

(p, b, k+1)p

(q, a, 2)

(a, 3)

(b, 2)

(p, b, 3)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(a, 0)

(a, 1)

(a, 1)

(q, a, 2)

(b, 0)

(b, 1)

(b, 1)

(b, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(a, 3)

(a, 4)

(a, 4)

(a, 5)

(a, 5)

(a, 6)

(a, 6)

(a, 7)

Page 100: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

5) For each a, create tiles

0 k t

0 1 6 7

0

1

2 3 4 5

2

3

4

5

6

7

. ., 6e g t 2 8s t

(h, a, k)

(h, a, k+1)

(q, a, 2)

(a, 3)

(b, 2)

(h, b, 3)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(a, 0)

(a, 1)

(a, 1)

(q, a, 2)

(b, 0)

(b, 1)

(b, 1)

(b, 2)

(?, 0)

(?, 1)

(?, 1)

(?, 2)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 2)

(?, 3)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 3)

(?, 4)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 4)

(?, 5)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 5)

(?, 6)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(?, 6)

(?, 7)

(a, 3)

(a, 4)

(a, 4)

(a, 5)

(a, 5)

(a, 6)

(a, 6)

(a, 7)

(h, a, k+1)

Page 101: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

0( , , , ) ?D d H V D

( , , , )M K s

6)

0 1 6 7

0

1

2 3 4 5

2

3

4

5

6

7

. ., 6e g t 2 8s t

(s, #, 0)

d0 = #

7) Base tile

(#, 0)

##

(s, #, 0)#

(#, 0)##

(#, 0)##

(#, 0)##

(#, 0)##

(#, 0)##

(#, 0)##

(#, 0)##

Page 102: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

( )@ tw M I ( ) ( )@ sw I D

( , , , )M K s 2s t

1) For each a, create tiles

(a, k)

(a, k+1)

0 k t

2) For each (q, a, p, b) where b and q h, create tiles

(q, a, k)

(p, b, k+1)

0 k t

3) For each (q, a, p, L) , create tiles

(q, a, k)

(a, k+1)

p

(b, k)

(p, b, k+1)

p 0 k t

4) For each (q, a, p, R) , create tiles

(q, a, k)

(a, k+1)

p

(b, k)

(p, b, k+1)

p 0 k t

5) For each a, create tiles

(h, a, k)

(h, a, k+1)

0 k t

6)

(s, #, 0)

d0 = #

7) Base tile

(#, 0)

##

Page 103: Lecture 8:  Computational Complexity

Theorem: BT is NP-Complete

0( , , , )D d H VD

( ) there is an tiling by @ sBT I s s D D

Pf)1. BT NP

2. 0N0N̂. .p r LNP

2Np.r.

. .p r

( ) ( ) is an tiling by $@ sBT I D D s s D Da p.b.l.P

BT. .p r

Page 104: Lecture 8:  Computational Complexity

Integer Programming

( ) ( ) has a binary soluti@ onB A b Ax b

( ) ( ) ( ) is a binary solut@ ion to $B A b x x Ax b

BNP already known

Is B NP-complete?

Page 105: Lecture 8:  Computational Complexity

Theorem: B is NP-Complete

( ) ( ) has a binary soluti@ onB A b Ax b

0N0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT B. .p r

( )@ sBT I D

Page 106: Lecture 8:  Computational Complexity

Theorem: B is NP-Complete

@( ) ( )B A b

0N0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT B. .p r

( )@ sBT I D :( )@ sw I D )( @) ( ( )w A b

w BT ( )w B

Page 107: Lecture 8:  Computational Complexity

Theorem: B is NP-Complete

@( ) ( )B A b ( )@ sBT I D :( )@ sw I D )( @) ( ( )w A b

w BT ( )w B

s s

( , )i j

kd1 is placed at ( , )

0 is not placed at ( , )k

ijkk

d D i jx

d D i j

Define variables

where0 ,

0 | | 1

i j s

k D

Page 108: Lecture 8:  Computational Complexity

Theorem: B is NP-Complete

s s

( , )i j

kd

• Every place has exactly one tile

1 is placed at ( , )

0 is not placed at ( , )k

ijkk

d D i jx

d D i j

• Horizontal rules

• Vertical rules

• Place d0 at (0, 0)

| | 1

0

1D

ijkk

x

0 , 1i j s

1, ,( , )

1k l

ijk i j ld d H

x x

, 1,( , )

1k l

ijk i j ld d V

x x

0 , 1

0 | | 1

i j s

k D

000 1x

0 , 1

0 | | 1

i j s

k D

Page 109: Lecture 8:  Computational Complexity

Theorem: B is NP-Complete

s s

( , )i j

kd

• Every place has exactly one tile

1 is placed at ( , )

0 is not placed at ( , )k

ijkk

d D i jx

d D i j

• Horizontal rules

• Vertical rules

• Place d0 at (0, 0)

| | 1

0

1D

ijkk

x

0 , 1i j s

1, ,( , )

1k l

ijk i j ld d H

x x

, 1,( , )

1k l

ijk i j ld d V

x x

0 , 1

0 | | 1

i j s

k D

000 1x

0 , 1

0 | | 1

i j s

k D

Page 110: Lecture 8:  Computational Complexity

Theorem: B is NP-Complete

• Every place has exactly one tile

• Horizontal rules

• Vertical rules

• Place d0 at (0, 0)

| | 1

0

1D

ijkk

x

0 , 1i j s

1, ,( , )

1k l

ijk i j ld d H

x x

, 1,( , )

1k l

ijk i j ld d V

x x

0 , 1

0 | | 1

i j s

k D

000 1x

0 , 1

0 | | 1

i j s

k D

Introducing slack variables

, {0,1}ijkijky z

1, ,( , )

1k l

ijk i j ld d H

ijkx yx

, 1,( , )

1k l

ijk i j ld d V

ijkx zx

Page 111: Lecture 8:  Computational Complexity

Theorem: B is NP-Complete

• Every place has exactly one tile

• Horizontal rules

• Vertical rules

• Place d0 at (0, 0)

| | 1

0

1D

ijkk

x

0 , 1i j s

0 , 1

0 | | 1

i j s

k D

000 1x

0 , 1

0 | | 1

i j s

k D

Introducing slag variables

, {0,1}ijkijky z

1, ,( , )

1k l

ijk i j ld d H

ijkx yx

, 1,( , )

1k l

ijk i j ld d V

ijkx zx

Page 112: Lecture 8:  Computational Complexity

Theorem: B is NP-Complete

• Every place has exactly one tile

• Horizontal rules

• Vertical rules

• Place d0 at (0, 0)

| | 1

0

1D

ijkk

x

0 , 1i j s

0 , 1

0 | | 1

i j s

k D

000 1x

0 , 1

0 | | 1

i j s

k D

Introducing slag variables

, {0,1}ijkijky z

1, ,( , )

1k l

ijk i j ld d H

ijkx yx

, 1,( , )

1k l

ijk i j ld d V

ijkx zx

The coefficient of each

variable is 0 or 1. The coefficient of each

variable is 0 or 1. The right-hand side of each

equality is 1.The right-hand side of each

equality is 1.

Page 113: Lecture 8:  Computational Complexity

Language Br is NP-Complete

all entries of are in {0,1},

( ) ( ) all entries of are 1, and

has a binary solut

@

ionr

A

B A b b

Ax b

Page 114: Lecture 8:  Computational Complexity

Hamilton Cycle

Page 115: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

( ) has a Hamilton CycleH G GPf)

1. H NP

2.

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B H. .p r

Page 116: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

( ) has a Hamilton CycleH G G

x

y

z

a b

c d

Page 117: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

( ) has a Hamilton CycleH G G

x

y

z

a b

c d

A Hamilton cycle entering the box from a, it must leave the box from c.

A Hamilton cycle entering the box from d, it must leave the box from b.

Page 118: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

( ) has a Hamilton CycleH G G

x

y

z

a b

c d

Page 119: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

( ) has a Hamilton CycleH G G

x

y

z

a b

c d

a b

c d

Page 120: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

( ) has a Hamilton CycleH G G

a b

c d

Page 121: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B H. .p r

( )H G ( )@ ( )rB A b :( )@ ( )w A b ( ) ( )w G

rw B ( )w H

1 2 3 4

2 4

3 4

1

1

1

x x x x

x x

x x

Page 122: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B H. .p r

1 2 3 4

2 4

3 4

1

1

1

x x x x

x x

x x

Page 123: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B H. .p r

1 2 3 4

2 4

3 4

1

1

1

x x x x

x x

x x

Page 124: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B H. .p r

1 2 3 4

2 4

3 4

1

1

1

x x x x

x x

x x

Page 125: Lecture 8:  Computational Complexity

Theorem: H is NP-Complete

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B H. .p r

1 2 3 4

2 4

3 4

1

1

1

x x x x

x x

x x

( )H G ( )@ ( )rB A b :( )@ ( )w A b ( ) ( )w G

rw B ( )w H

Page 126: Lecture 8:  Computational Complexity

Traveling Salesman Problem (TSP)

@ ( )@ a tour with ( )n bTSP I D I t D t b

( )@ ( )@ ( )$n bTSP I D I bt D t

TSPNP already known

Is TSP NP-complete?

Page 127: Lecture 8:  Computational Complexity

Theorem: TSP is NP-Complete

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H

TSPp.r.

@ ( )@ a tour with ( )n bTSP I D I t D t b

Page 128: Lecture 8:  Computational Complexity

Theorem: TSP is NP-Complete

@ ( )@ a tour with ( )n bTSP I D I t D t b

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H

TSPp.r.

@ ( )@n bTSP I D I ( )H G :( )w G ( ) @ ( )@n bw I D I

w H ( )w TSP

Page 129: Lecture 8:  Computational Complexity

Theorem: TSP is NP-Complete

@ ( )@ a tour with ( )n bTSP I D I t D t b

( )w G ( ) @ ( )@n bw I D I

w H ( )w TSP

?n

?ijD d

?b

@ ( )@n bTSP I D I ( )H G :

Page 130: Lecture 8:  Computational Complexity

?n

?ijD d

?b

Theorem: TSP is NP-Complete

@ ( )@ a tour with ( )n bTSP I D I t D t b

@ ( )@n bH I D I ( )rB G :( )w G ( ) @ ( )@n bw I D I

w H ( )w TSP

G = (V, E)

G = (V, E)

| |V

0 if ,

1

if ,ij

i j Ed

i j E

0

Page 131: Lecture 8:  Computational Complexity

?n

?ijD d

?b

Theorem: TSP is NP-Complete

@ ( )@ a tour with ( )n bTSP I D I t D t b

@ ( )@n bH I D I ( )rB G :( )w G ( ) @ ( )@n bw I D I

w H ( )w TSP

G = (V, E)

G = (V, E)

| |V

0 if ,

1

if ,ij

i j Ed

i j E

0

There exists a Hamilton cycle in graph G=(V, E) if and only if there exists a zero-cost tour for the following TSP .

There exists a Hamilton cycle in graph G=(V, E) if and only if there exists a zero-cost tour for the following TSP .

Page 132: Lecture 8:  Computational Complexity

Satisfiability Problem (SAT)

: Boolean Variables; 1 2, ,x x

: the negation of xi; ix literals

A formula in the propositional calculus is an expression that can be constructed using literals and the operations (and) and (or). A satisfiability problem is to determine if a formula is true for any truth assignment of variables.

Example: 1 2 3 4x x x x

Page 133: Lecture 8:  Computational Complexity

Normal Forms

CNF

DNF

1 1

Vi

ij

j

kk

i

c

11

Vikk

jiijd

Page 134: Lecture 8:  Computational Complexity

Cook’s Theorem

SAT is NP-complete

SATP iff P =NP

Page 135: Lecture 8:  Computational Complexity

Cook’s TheoremSAT is NP-complete

Pf)

1. SAT NP

2.0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

SATp.r.

skip

Page 136: Lecture 8:  Computational Complexity

Cook’s Theorem0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

SATp.r.p.r.

s s

( , )m n

kd

Define literals:

is placed at ( , )

is not placed at ( , )k

kmnd

k

true d D m nP

false d D m n

Page 137: Lecture 8:  Computational Complexity

Cook’s Theorem0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

SATp.r.p.r.

1

2

1

1

2

2

0 1 ,0 1

m s d d Dn s d d

mnd mndP P

s s

( , )m n

kd

000 dP

1 2

1 20 10 1

1,,

,V mnm s d d H

m n

n

d d

s

P P

1 2

1 20 10 1

, 1,

,V mnm s d d V

m n

n

d d

s

P P

Page 138: Lecture 8:  Computational Complexity

Cook’s Theorem0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

SATp.r.p.r.

1

2

1

1

2

2

0 1 ,0 1

m s d d Dn s d d

mnd mndP P

s s

( , )m n

kd

000 dP

1 2

1 20 10 1

1,,

,V mnm s d d H

m n

n

d d

s

P P

1 2

1 20 10 1

, 1,

,V mnm s d d V

m n

n

d d

s

P P

True if and only if there is no different tiles being placed at

each cell.

True if and only if there is no different tiles being placed at

each cell.

Page 139: Lecture 8:  Computational Complexity

Cook’s Theorem0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

SATp.r.p.r.

1

2

1

1

2

2

0 1 ,0 1

m s d d Dn s d d

mnd mndP P

s s

( , )m n

kd

000 dP

1 2

1 20 10 1

1,,

,V mnm s d d H

m n

n

d d

s

P P

1 2

1 20 10 1

, 1,

,V mnm s d d V

m n

n

d d

s

P P

True if and only if horizontal rules are

satisfied at each cell.

True if and only if horizontal rules are

satisfied at each cell.

Page 140: Lecture 8:  Computational Complexity

Cook’s Theorem0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

SATp.r.p.r.

1

2

1

1

2

2

0 1 ,0 1

m s d d Dn s d d

mnd mndP P

s s

( , )m n

kd

000 dP

1 2

1 20 10 1

1,,

,V mnm s d d H

m n

n

d d

s

P P

1 2

1 20 10 1

, 1,

,V mnm s d d V

m n

n

d d

s

P P

True if and only if vertical rules are

satisfied at each cell.

True if and only if vertical rules are

satisfied at each cell.

Page 141: Lecture 8:  Computational Complexity

Cook’s Theorem0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

SATp.r.p.r.

1

2

1

1

2

2

0 1 ,0 1

m s d d Dn s d d

mnd mndP P

s s

( , )m n

kd

000 dP

1 2

1 20 10 1

1,,

,V mnm s d d H

m n

n

d d

s

P P

1 2

1 20 10 1

, 1,

,V mnm s d d V

m n

n

d d

s

P P

True if an only if d0 is place at (0, 0).

True if an only if d0 is place at (0, 0).

Page 142: Lecture 8:  Computational Complexity

Cook’s Theorem0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

SATp.r.p.r.

1

2

1

1

2

2

0 1 ,0 1

m s d d Dn s d d

mnd mndP P

s s

( , )m n

kd

000 dP

1 2

1 20 10 1

1,,

,V mnm s d d H

m n

n

d d

s

P P

1 2

1 20 10 1

, 1,

,V mnm s d d V

m n

n

d d

s

P P

Page 143: Lecture 8:  Computational Complexity

Summary

0N 0N̂. .p r LNP

2Np.r.

. .p r

. .p r BT . .p r

r

B

B

. .p r H TSP. .p r

p.r.SAT