L - 大同大學

Lecture 6:
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 6:
Computational Complexity
Time-Bounded
Turing Machine
大同大學資工所
智慧型多媒體研究室
Computational Effectiveness for
Solvable Problems
Not Solvable
Solvable
Can such a problem, e.g., TSP,
be solved in any practical sense?
t
M
Yields in t Steps ├
C ├ C iff C  C
0
M
C ├ C iff
t 1
M
C such that
t
C ├M C and C├M C
Time-Bounded TM
Let T: N  N be a function. Let L  *0 be a language,
and let M   K , ,  , s  be a k-tape TM with 0  . We
say that M decides L in time T if the following holds:
1. w  L 
 s, # w #, #,
, # ├tM  h, # Y #, #,
, #  for some t  T(|w|);
, # ├tM  h, # N #, #,
, #  for some t  T(|w|);
2. w  L 
 s, # w #, #,
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 )
T ( n)  2n  4
Absolute Time Bound (2n + 4)
Head
n
#
#
w
Head
# Y/N #
• |w|+1 writing steps
>L
#
#
>L
#
#
#
RYR
RNR
#
erase w (write ‘#’)
write ‘Y’ or ‘N’
• |w|+3 head-moving steps
Lecture 6:
Computational Complexity
Rate of
Growth Functions
大同大學資工所
智慧型多媒體研究室
f ,g:N
N
Time-Bound Notations

Upper Bound
f  O( g )  c, n0 st f (n)  cg (n) if n  n0

Lower Bound
f  ( g )  c, n0 st f (n)  cg (n) if n  n0

Exact Bound
f   (g)
 c1 , c2 , n0 st c1 g (n)  f (n)  c2 g (n) if n  n0
f ,g:N
N
Time-Bound Notations

Upper Bound
f  O( g )  c, n0 st f (n)  cg (n) if n  n0

Lower Bound
f  ( g )  c, n0 st f (n)  cg (n) if n  n0

Exact Bound
f   (g)
Fact:
f   ( g )  f  O( g ) and f  ( g )
 c1 , c2 , n0 st c1 g (n)  f (n)  c2 g (n) if n  n0
Lemma
d
f (n)   a j n with ad  0
j
j 0
a) f (n)   (n )
d
b) f (n)  O(n
d 1
) and f (n)   (n
d 1
)
d
f (n)   a j n j with ad  0
j 0
a) f  n    (n d )
Lemma
Pf)
b) f  n   O(n d 1 ) and f  n    (n d 1 )
d
For a, we need to prove f (n)  O(n ) and nd  O  f (n) .
c
f ( n)  O ( n d )
d
f (n)  f (n)   | a j |n  n
j
d
d
j 0
| a
j 0
nd  O  f (n) 
n d  cf (n) if n  n0
cf (n)  n d  0 if n  n0
Therefore, we have to find c (exercise) such that
cf (n)  n d  (cad  1)n d  cad 1n d 1 
0
j
|
d
f (n)   a j n j with ad  0
j 0
Lemma
a) f  n    (n d )
b) f  n   O(n d 1 ) and f  n    (n d 1 )
Pf)
f (n)  O(n d 1 )
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.

f   n d 1

nd 1  O(nd )
Suppose that nd+1 = O(nd), Then, nnd = nd+1  cnd for n  n0.
But for any c, when n > c, nd+1  cnd. 
Theorem
d
Let f (n)   a j n j with ad  0. Then,
j 0
f (n)  O(r ), r  1.
n
d
Let f (n)   a j n j with ad  0. Then,
j 0
f (n)  O(r ), r  1.
Theorem
Pf)
n
Because f = O(nd), we only need to prove that nd = O(rn), i.e.,
n d  cr n for n  n0
( n0  k ) d  cr n0  k for k  0
d
 n 1 
(n0  k ) d  n0d  0

n
0


d


1
 n0d 1 

n
0 

d
 n0  2 
 n0  k 




n

1
n

k

1
 0

 0

d
d




1
1
1

1





n

1
n

k

1
0
0




k terms
1 
d 
 n0 1 

n
0 

d
kd
 cr n0  k  cr n0  r k
d
Let f (n)   a j n j with ad  0. Then,
j 0
f (n)  O(r ), r  1.
Theorem
Pf)
n
Because f = O(nd), we only need to prove that nd = O(rn), i.e.,
n d  cr n for n  n0
( n0  k ) d  cr n0  k for k  0
1 
d
d 
(n0  k )  n0 1 

n
0 

Let cr
n0
n
d
0
d
n0d
 c  n0
r
kd
 cr n0  k  cr n0  r k
Hence, nd = O(rn).


1 
1 
1
1
1/ d
1


r

1


r

 r 1/ d  1  n0  1/ d




n0 
n0 
n0
r 1


Lecture 6:
Computational Complexity
Time-Bound
Simulations
大同大學資工所
智慧型多媒體研究室
Time-Complexities on TMs
Not Solvable
Solvable
The complexities to solve problems
on different TMs are different.
Theorem 1
L  TIME T1   L  TIME T2 
2-way
infinite
tape
standard
1-way
tape
where T2 (n)  6T1 (n)  3n  8.
Theorem 2
L  TIME T1   L  TIME T2 
k -tape
standard
1-way
tape
where
T2 (n)  4T1 (n) 2  (4n  4k  3)T1 (n)  5n  15.
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)
?
Lecture 6:
Computational Complexity
P and NP
大同大學資工所
智慧型多媒體研究室
Definition (P )
P
TIME (n
d

):d  0
That is, P denotes the class of all
languages that are decided by TM’s in
some polynomial time bounds.
0-1
Example: (Integer Programming)
Does
n
a x
j 1
ij
j
 bi , i  1, 2,
,m
have solution in 0 and 1?
Matrix formulation:
A  aij 
 x1 
x   
 xn 
mn
 b1 
b   
bm 
Given A and b, is there any
binary vector x such that
Ax  b
Given A and b, is there any
binary vector x such that
Ax  b
Example: (Integer Programming)
2 x3  3
x1
3x2
2 x3  2
 x1 
1 0 2    3
0 3 2  x2    2

 x   
 3
A
Encode:  ( A)  IIcIcIIIccIcIIIIcIII
x
b
 (b)  IIIIccIII


Language B   ( A) @  (b) Ax  b has a binary solution
BP ?
No answer!
Given A and b, is there any
binary vector x such that
Ax  b
Example: (Integer Programming)
Language B   ( A) @  (b) Ax  b has a binary solution
BP ?
No answer!
Language
B   ( A) @  (b)$ ( x) x is a binary solution to Ax  b
B P ?
Yes, it is.
 
3

Fact: B  TIME n
Definition
T:N
N
*
L  0 , 0  
M accepts L in nondeterministic
time T if the following holds
M  ( K , , , s)
t
w

L
iff
(
s
,
#
w
#)
├M (h, u v )
*
For all w  0,
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.
What is the difference between
TIME(T) and NTIME(T)?
Definition
NTIME (T )
The class of languages acceptable
in nondeterministic time T.
Definition (NP )
NP 
NTIME (n
d

):d  0
That is, NP denotes the class of all
languages that are accepted by NTM’s
in some nondeterministic polynomial
time bounds.
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.,
(s, # w #,
, #)
f (| w|)
├M
(h, u1 a1v1,
, uk ak vk )
for some u1, …, uk, v1, …, vk * and a1, …, ak.
Exercise
Given d >0, there exists a polynomial p of
degree d being a step counting function.
See text for the proof.
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
T2 (n)  r
T1 ( n )
(k2  1, and r  1)
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$ y  L only if | y | p | x | .
Theorem 4
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
L  P and L  L \ $ ,
*
where L’ is a polynomial balanced
language.
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
Theorem 4
L  P and L  L \ $* .
where L’ is a p.b.l.
Pf) “”
L’ is a p.b.l.
L’P
 Polynomial p s.t. x$yL’ only if |y|  p(|x|).
 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:
 1(1)
>RNR
M’’:
>RNR
M’’
...
M’:
M: >$(1)
 m(1)
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
L  P and
L p L+ \q.$ .
M can be accept L in nondeterministic
time
Theorem 4
Hence,
L  NP.
*
where L’ is a p.b.l.
Pf) “”
L’ is a p.b.l.
L’P
 Polynomial p s.t. x$yL’ only if |y|  p(|x|).
 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:
 1(1)
>RNR
M’’:
>RNR
M’’
...
M’:
M: >$(1)
 m(1)
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
Theorem 4
L  P and L  L \ $* .
where L’ is a p.b.l.
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’ =?
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
Theorem 4
L  P and L  L \ $* .
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.,
Pf) “”
 a DTM M’ can decides L’ in polynomial time.
Since LNP,  an NTM M that
accept L in nondeterministic
time q (a polynomial).
That is, given xL, we have
C0├M C1├M . . . ├MCt
such that
C0  ( s, # x #)
Ct  (h, w u )
t  q | x | 
Y(x)=?
M’ =?
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
y   (M )@  (C0 )@
@  (Ct )
where M is the NTM that accepts L.
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
L  P and L  L \ $* .
Theorem 4
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.,
Pf) “”
 a DTM M’ can decides L’ in polynomial time.
y   (M )@  (C0 )@
@  (Ct )
Y(x)=?
t
M’ =?
 q(|x|)
y   (M )    (C j )  #@' s
j 0
to be discussed
constant
accept in time q
C j  q | x |   | x |
   C j     M   q(| x |) | x |
input length
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
Theorem 4
L  P and L  L \ $* .
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.,
Pf) “”
 a DTM M’ can decides L’ in polynomial time.
y   (M )@  (C0 )@
@  (Ct )
t
Y(x)=?
M’ =?
 q(|x|)
y   (M )    (C j )  #@' s
j 0
  (M )  q(| x |)  2 q(| x |) | x |  q(| x |)
C j  q | x |   | x |
   C j     M   q(| x |) | x |
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
Theorem 4
L  P and L  L \ $* .
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.,
Pf) “”
 a DTM M’ can decides L’ in polynomial time.
y   (M )@  (C0 )@
@  (Ct )
Y(x)=?
M’ =?
t
y   (M )    (C j )  #@' s
j 0
  (M )  q(| x |)  2 q(| x |) | x |  q(| x |)
Polynomial of |x|
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
L  P and L  L \ $* .
Theorem 4
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.,
Pf) “”
 a DTM M’ can decides L’ in polynomial time.
y   (M )@  (C0 )@
@  (Ct )
Y(x)=?
M’ =?
t
y   (M )    (C j )  #@' s
j 0
  (M )  q(| x |)  2 q(| x |) | x |  q(| x |)
Let L   x$ y x  L, y  Y ( x)
L’ is polynomial balanced.
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
L  P and L  L \ $* .
Theorem 4
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.,
Pf) “”
 a DTM M’ can decides L’ in polynomial time.
y   (M )@  (C0 )@
@  (Ct )
Y(x)=?
M’?=?
t
y   (M )    (C j )  #@' s
j 0
  (M )  q(| x |)  2 q(| x |) | x |  q(| x |)
Let L   x$ y x  L, y  Y ( x)
L’ is polynomial balanced.
Let L  * be a language, $ and ||2.
L  NP iff  L’  *$* such that
Theorem 4
Pf) “”
L  P and L  L \ $* .
where L’ is a p.b.l.
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 w  x$  ( M )@  (C0 )@ @  (Ct )
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.
Example (Integer Programming BNP )
B   ( A) @  (b) Ax  b has a binary solution
B   ( A) @  (b)$ ( x) x is a binary solution to Ax  b
 ( A) @  (b)
$
 ( x )  B
|w| O (|w|)
| w|
Polynomial Balanced
B  TIME (n )  P
3
BNP
Example (Integer Programming BNP )
B   ( A) @  (b) Ax  b has a binary solution
B   ( A) @  (b)$ ( x) x is a binary solution to Ax  b
?
P
B
B  TIME (n )  P
3
BNP
How to show?
Is P = NP ?
Show
P  NP
Trivial (why?)
P
and
NP  P
Difficult
No answer, now.
NP
Example (TSPNP )
2
TSPF
1
3
5
Find the shortest tour t.
8
4
7
6
D  [dij ] Distance matrix
t is a bijection
t :[1, 2,
, n]  [1, 2,
, n]
E.g.,
1 2 3 4 5 6 7 8 


1
7
6
4
5
3
8
2


Example (TSPNP )
2
TSPF
1
3
Find the shortest tour t.
5
It is not language decision problem.
Rather, it is a problem of function
evaluation.
8
4
7
6
D  [dij ] Distance matrix
2
1
3
D  [dij ] Distance matrix
5
8
4
7
Example (TSPNP )
6
TSPF Find the shortest tour t.
TSP
Denote the cost of t as D(t).
  NP

TSP  I n @  ( D) @ I b a tour t with D(t )  b
TSP’ Polynomial balanced

 P
TSP  I n @  ( D) @ I b $ (t ) D(t )  b
Exercises
Show that
1.
TSPNP.
2.
TSPP   a polynomial algorithm for TSPF.
3.
TSP’P.
Remark
TSPP
P = NP
Lecture 6:
Computational Complexity
NP-Completeness
大同大學資工所
智慧型多媒體研究室
Definition:
Polynomial-Time Computable
f : 1*  *2 is said to be computed in time T if
 a k-tape DTM s.t.
 s, # x #, #,
, # ├tM
 h, # f ( x) #, #,
, #
with t  T(|x|).
Furthermore, if T(|x|) is a polynomial, then f is said to
be polynomial-time computable.
Definition:
Polynomial-Time Reduction
Let L1  1 and L2   2 be languages,
*
*
 : 1*  *2 be polynomial-time computable.
Then L1 is said to be polynomial-time reducible to L2 iff
x  L1   ( x)  L2
x  L1  ( x)  L2
p .r .
More on Polynomial Reduction

L2  P  L1  P.
Time to decide

L1   x   ( x)    ( x)  L2 ?
Transitivity
L1  L2  L3
p .r .
p .r .
p.r.
Definition: NP-Completeness
L
*
is called NP-complete iff
1. LNP
2. L  NP
 L is polynomial reducible to L.
1. LNP.
p .r
2. L  NP  L 
 L.
More on NP-Completeness
NP
L
P
NP-Complete
1. LNP.
NP-Hard
Not Solvable
p .r
2. L  NP  L 
 L.
Solvable
NP L 
P
NP-Complete
NP-Hard
1. LNP.
p .r
2. L  NP  L 
 L.
Important Theorem
Let L be an NP-complete language.
Then,
P  NP  L P.
Pf)
NP
“” P  NP  L P.
trivial
“” LP  P  NP.
trivial
L
.
p.r
P
NP-Complete
Remark


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.
NP
L
.
p.r
P
NP-Complete
Lecture 6:
Computational Complexity
Bounded Halting
Problems
大同大學資工所
智慧型多媒體研究室
Bounded Halting Problem N0


t The NTM M accepts input
N0    (M )  ( w) @ I

w in t or fewer steps


Fact:
Halting problem is not solvable.
Is Bounded Halting problem is solvable?


t The NTM M accepts input
N0    (M )  ( w) @ I

steps
fewer
or
t
in
w


Theorem: N0 is NP-Complete
1. N 0 NP
2. L  NP  L  N 0 .
p .r .


t The NTM M accepts input
N0    (M )  ( w) @ I

steps
fewer
or
t
in
w


Theorem: N0 is NP-Complete
1. N 0 NP
  ( M )  ( w) @ I t $  (C0 ) @  (C1 ) @

such that
(a) M  ( K , , , s)  an NTM

Define N 0  (b) Ci  a configuration of M
(c) C  ( s, # w #), C  (h, u v)
0
0

(d) Ci
Ci 1


(e) t   t
@  (Ct  ) 













t The NTM M accepts input
N0    (M )  ( ) @ I

s
step
fewer
or
t
in
w


Theorem: N0 is NP-Complete
1. N 0 NP
  ( M )  ( ) @ I t $  (C0 ) @  (C1 ) @

such that
(a) M  ( K , , , s)  an NTM

Define N 0  (b) Ci  a configuration of M
(c) C  ( s, # w #), C  (h, u v)
0
0


N

polynomial
balance
 0 (d) C C
i
i 1


 N0 (eP) t   t
Exercise
@  (Ct  ) 









0

N NP


t The NTM M accepts input
N0    (M )  ( ) @ I

s
step
fewer
or
t
in
w


Theorem: N0 is NP-Complete
2. L  NP  L  N 0 .
p .r .
For any LNP, find L.
• LNP
M L : NTM


 to accept L
 pL : polynomial 
P |w|
• Let  L (w)   (M L )  (w)@ I  
L
• Fact: L(w) is polynomial computable.
• w  L  L(w)  N0.
The Language N̂ 0


t The NTM M accepts input
N0    ( M )  (u ) @ I

u in t or fewer steps




The
NTM
M
accepts
inp
ut
Nˆ 0    ( M )  (u)

u in 2 | u | or fewer steps 

Theorem:
N̂ 0
is NP-Complete


t The NTM M accepts input
N0    ( M )  (u ) @ I

u in t or fewer steps




The
NTM
M
accepts
inp
ut
Nˆ 0    ( M )  (u)

u in 2 | u | or fewer steps 

1. Nˆ 0 NP
2. N0  Nˆ 0
p.r .
Exercise
Find .


N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
Theorem:
Find
:
N̂ 0
N0
w   ( M )  (u )@ I t
w  N0
M  ?
t steps.
2 | u | steps
is NP-Complete
 Nˆ 0
p .r .
  (w)   (M )  (u)
  (w)  Nˆ
p.r .
0
u  ?


N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
N̂ 0
Theorem:
Find
:
t steps.
2 | u | steps
is NP-Complete
 Nˆ 0
p .r .
  (w)   (M )  (u)
  (w)  Nˆ
p.r .
N0
w   ( M )  (u )@ I t
w  N0
0
Case 1. w   ( M )  (u) @ I , t  2 | u | 2
t
u  u #
t  2  2|u|
#
M  :  L 
 RM
#
t + 2  2|u| + 2 + t
= 2t + 4  2|u| =2|u’|


N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
N̂ 0
Theorem:
Find
:
 Nˆ 0
p .r .
  (w)   (M )  (u)
  (w)  Nˆ
p.r .
N0
w  N0
0
Halt within
t
 (M
)

(
u
)
@
I
,
2|u’| steps.
u  u #
t  2  2|u|
2 | u | steps
is NP-Complete
w   ( M )  (u )@ I t
Case 1. w 
t steps.
t  2 | u | 2
#
Halt within
t steps.
M  :  L 
 RM
#
t + 2  2|u| + 2 + t
= 2t + 4  2|u| =2|u’|


N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
Theorem:
Find
:
N̂ 0
t steps.
2 | u | steps
is NP-Complete
 Nˆ 0
p .r .
  (w)   (M )  (u)
  (w)  Nˆ
p.r .
N0
w   ( M )  (u )@ I t
w  N0
0
Case 2. w   ( M )  (u) @ I , t  2 | u | 2
t
u  u
2|u| t

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


N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
Theorem:
Find
:
N̂ 0
N0
w  N0
Halt within
t
 (M
)

(
u
)
@
I
,
2|u’| steps.
u  u
2 | u | steps
is NP-Complete
 Nˆ 0
p .r .
  (w)   (M )  (u)
  (w)  Nˆ
p.r .
w   ( M )  (u )@ I t
Case 2. w 
t steps.
0
t  2 | u | 2
Halt within
t steps.
2|u| t

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


N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
Theorem:
Find
:
N̂ 0
t steps.
2 | u | steps
is NP-Complete
 Nˆ 0
p .r .
  (w)   (M )  (u)
  (w)  Nˆ
p.r .
N0
w   ( M )  (u )@ I t
w  N0
0
Hence,
I
w is not in the form of  ( M )  (u)@ I t
 ( w)  
t
  ( M )  (u) w is in the form of  ( M )  (u)@ I
See previous slides

N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
Theorem:
N̂ 0

t steps.
2 | u | steps
is NP-Complete
Summary of the proof:
ˆ
1. N0 NP
ˆ
2. N0  N0
p.r .
Known NP-complete
Special Bounded Halting Problem N2


t M  ( K , , , s), and
N2    (M ) @ I

t
( s, #)├M (h, u v) with t   t 



t The NTM M accepts input
N0    ( M )  (u ) @ I

u in t or fewer steps




The
NTM
M
accepts
inp
ut
Nˆ 0    ( M )  (u)

u in 2 | u | or fewer steps 


N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
Theorem: N2 is NP-Complete


t M  ( K , , , s), and
N2    (M ) @ I

t
( s, #)├M (h, u v) with t   t 

Pf)
1. N 2 NP
obvious.
p .r .
p .r .
2. NP  L 
N 0 
N̂ 0
p.r.
p.r.
p.r.
N2



N 0   ( M )  (u ) @ I t
Nˆ 0    ( M )  (u )
Theorem: N2 is NP-Complete


t M  ( K , , , s), and
N2    (M ) @ I

t
( s, #)├M (h, u v) with t   t 

Pf)
1. N 2 NP
obvious.
p .r .
p .r .
2. NP  L 
N 0 
N̂ 0
=?
p.r.
N2


p .r .
p .r .
2. NP  L 
N 0 
N̂ 0
=?
p.r.
N2
Theorem: N2 is NP-Complete
 : N   (M )  (u ) @ I
0
t


N2   (M ) @ I t
 (w)   (M )@ I t
w   ( M )  (u )@ I t
w  N0

 ( w)  N 2
M   ? t  ?

p .r .
p .r .
2. NP  L 
N 0 
N̂ 0
=?
p.r.
N2
Theorem: N2 is NP-Complete
 : N   (M )  (u ) @ I
0
t


N2   (M ) @ I t
 (w)   (M )@ I t
w   ( M )  (u )@ I t
Let
 ( w)  N 2

w  N0
M  :  Ru (1) Ru (2)
Ru (| u |) RM
2|u|
t   t  2 | u | 1
1 t

p .r .
p .r .
2. NP  L 
N 0 
N̂ 0
=?
p.r.
N2
Theorem: N2 is NP-Complete
 (Mon)  (u) @ I
 : MN ’ halts
0
t

M halts on u

N2   (M ) @ I t
 in t ’ steps
w   ( M )  (u )@ I t
 ( w)  N 2

w  N0
Let
t steps
 (win
)   ( M )@ I t 
M  :  Ru (1) Ru (2)
Ru (| u |) RM
2|u|
t   t  2 | u | 1
1 t

M  :  Ru (1) Ru (2)
Ru (| u |) RM
2|u|
1 t
t   t  2 | u | 1
Theorem: N2 is NP-Complete
 : N   (M )  (u ) @ I
0
t


N2   (M ) @ I t
 (w)   (M )@ I t
w   ( M )  (u )@ I t
w  N0


 ( w)  N 2
I
if w is not in form of  ( M )  (u ) @ I t
 ( w)  
t  2|u|1
t


(
M
)
@
I
if
w
is
in
form
of

(
M
)

(
u
)@
I

Summary
NP  L  N 0  N̂ 0
p .r .
p .r .
p.r.
N2
Lecture 6:
Computational Complexity
Some Important
NP-Complete
Problems
大同大學資工所
智慧型多媒體研究室
Bounded Tiling Problem (BT)
Tiling System:
D  ( D, d0 , H ,V )
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.
D  ( D, d0 , H ,V )
Bounded Tiling Problem (BT)
Given D and s > 0, an s  s
tiling by D is a function
f :[0,1,
, s  1]  [0,1,
, s  1]
such that
5
D
4
3
1. f (0,0)  d0
2
2.  f (m, n), f (m  1, n)   H
1
3.  f (m, n), f (m, n  1)  V
0
d0
0
1
2
3
4
5
D  ( D, d0 , H ,V )
Bounded Tiling Problem (BT)

BT   (D ) @ I s there is an s  s tiling by D
BT is NP-Complete

D  ( D, d0 , H ,V )
Theorem: BT is NP-Complete

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

Pf)
1. BT NP
BT    (D ) @ I
s
$ ( D) D is an s  s tiling by D

a p.b.l.
P
p .r .
p .r .
N
NP

L


N̂ 0
2.
0
p.r.
p .r .
N 2 
BT
p .r .
p .r .
2. NP  L  N 0  N̂ 0
p.r.

p .r .
N 2 
BT
Theorem: BT is NP-Complete
:

N2   (M ) @ I
t


BT   (D ) @ I
 ( w)   (D )@ I s
w   ( M )@ I t
w  N2
s

 ( w)  BT
D  ( D, d0 , H ,V )  ?
s ?

w   ( M )@ I t
 ( w)   (D )@ I s
Theorem: BT is NP-Complete
s t 2
t+1
t
1
0
0
1
t
t+1
 ( w)   (D )@ I s
w   ( M )@ I t
M  ( K , , , s)
Theorem: BT is NP-Complete
s t 2
D  ( D, d0 , H ,V )  ?
1) For each a, create tiles
t+1
t
(a, k+1)
(a, k)
1
0
0
1
t
t+1
0k t
 ( w)   (D )@ I s
w   ( M )@ I t
M  ( K , , , s)
Theorem: BT is NP-Complete
D  ( D, d0 , H ,V )  ?
e.g ., t  6
s t 28
1) For each a, create tiles
(a, 7)
7
(a, 6)
(a, 6)
6
(a, 5)
(a, 5)
5
(a, k+1)
(a, 4)
(a, 4)
4
(a, 3)
(a, 3)
3
(a, k)
(a, 2)
(a, 2)
2
(a, 1)
(a, 1)
1
(a, 0)
0
0
1
2
3
4
5
6
7
0k t
w   ( M )@ I t
 ( w)   (D )@ I s
M  ( K , , , s)
Theorem: BT is NP-Complete
D  ( D, d0 , H ,V )  ?
e.g ., t  6
s t 28
Can’t
reach the highest layer if q  h.
7
(p, b, 6)
6
(q, a, 5)
(p, b, 5)
5
(p, b, k+1)
(q, a, 4)
(p, b, 4)
4
(q, a, 3)
(p, b, 3)
3
(q, a, k)
(q, a, 2)
(p, b, 2)
2
1
2) For each (q, a, p, b)  where
b and q  h, create tiles
(q, a, 1)
(p, b, 1)
(q, a, 0)
0
0
1
2
3
4
5
6
7
0k t
 ( w)   (D )@ I s
w   ( M )@ I t
M  ( K , , , s)
Theorem: BT is NP-Complete
D  ( D, d0 , H ,V )  ?
e.g ., t  6
s t 28
3) For each (q, a, p, L) ,
create tiles
7
6
5
(p, b, k+1)
4
p
1
p
(p, b, 3) (a, 3)
3
2
(a, k+1)
(b, 2) (q, a, 2)
(?, 2)
(?, 2)
(?, 2)
(?, 2)
(b, 2)
(?, 1)
(?, 1)
(?, 1)
(?, 1)
(?, 1)
(?, 1)
(?, 1)
(?, 1)
(b, 1)
(b, 1)
(a, 1)
(a, 1)
(?, 1)
(?, 1)
(?, 1)
(?, 1)
(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
(?, 0)
(?, 0)
(?, 0)
(a, 0)
(b, 0)
(?, 0)
0
1
2
3
4
5
6
7
(?, 3)
(a, 3) (h, b, 3) (?, 3)
(q, a, 2) (b, 2)
(q, a, 2) (b, 2)
5) For each a, create tiles
(h, a, k+1)
(h, a, k+1)
(h, a, k)
(?, 2)
(?, 2)
0
0k t
w   ( M )@ I t
 ( w)   (D )@ I s
M  ( K , , , s)
Theorem: BT is NP-Complete
D  ( D, d0 , H ,V )  ?
e.g ., t  6
s t 28
7
(s, #, 0)
6)
6
d0 =
#
5
4
3
(#, 0)
2
7) Base tile
1
0
(s, #, 0) (#, 0) (#, 0) (#, 0) (#, 0) (#, 0) (#, 0) (#, 0)
# #
# #
# #
# #
# #
# #
# #
#
0
1
2
3
4
5
6
7
#
#
 ( w)   (D )@ I s
w   ( M )@ I t
s t 2
M  ( K , , , s)
Theorem: BT is NP-Complete
1) For each a, create tiles
4) For each (q, a, p, R) , create tiles
(a, k+1)
(a, k+1)
0k t
p
(a, k)
(q, a, k)
2) For each (q, a, p, b)  where
b and q  h, create tiles
3) For each (q, a, p, L) , create tiles
(p, b, k+1)
p
(q, a, k)
0k t
(h, a, k)
7) Base tile
6)
(#, 0)
(s, #, 0)
(a, k+1)
p
(b, k)
(h, a, k+1)
0k t
(q, a, k)
0k t
p
5) For each a, create tiles
(p, b, k+1)
(b, k)
(p, b, k+1)
0k t
d0 =
#
#
#
D  ( D, d0 , H ,V )
Theorem: BT is NP-Complete

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

Pf)
1. BT NP
BT    (D ) @ I
s
$ ( D) D is an s  s tiling by D

a p.b.l.
P
p .r .
p .r .
N
NP

L


N̂ 0
2.
0
p.r.
p .r .
N 2 
BT
Integer Programming
B   ( A) @  (b) Ax  b has a binary solution
B   ( A) @  (b)$ ( x) x is a binary solution to Ax  b
BNP
already known
Is B NP-complete?

BT   (D ) @ I s

Theorem: B is NP-Complete
B   ( A) @  (b) Ax  b has a binary solution
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
B
p .r .
p .r .

N2
BT 
Theorem: B is NP-Complete
:

BT   (D ) @ I s

B   ( A) @  (b)
 ( w)   ( A) @  (b)
w   (D )@ I s
w  BT

p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.

 ( w)  B
B
p .r .
p .r .

N2
BT 
Theorem: B is NP-Complete
:

BT   (D ) @ I s

B   ( A) @  (b)
 ( w)   ( A) @  (b)
w   (D )@ I s
w  BT

Define variables
1 dk  D is placed at (i, j )
xijk  
0 dk  D is not placed at (i, j )
where
0  i, j  s
0  k | D | 1

 ( w)  B
ss
dk
(i , j )
1 dk  D is placed at (i, j )
xijk  
0 dk  D is not placed at (i, j )
Theorem: B is NP-Complete
• Every place has exactly one tile
| D|1
x
ijk
k 0
1
• Horizontal rules
xijk 

( dk , dl )H
xi 1, j ,l  1
• Vertical rules
xijk 

( dk , dl )V
xi , j 1,l  1
• Place d0 at (0, 0)
x000  1
0  i, j  s  1
0  i, j  s  1
0  k | D | 1
ss
dk
0  i, j  s  1
0  k | D | 1
(i , j )
1 dk  D is placed at (i, j )
xijk  
0 dk  D is not placed at (i, j )
Theorem: B is NP-Complete
• Every place has exactly one tile
| D|1
x
ijk
k 0
1
• Horizontal rules
xijk 

( dk , dl )H
xi 1, j ,l  1
• Vertical rules
xijk 

( dk , dl )V
xi , j 1,l  1
• Place d0 at (0, 0)
x000  1
0  i, j  s  1
0  i, j  s  1
0  k | D | 1
ss
dk
0  i, j  s  1
0  k | D | 1
(i , j )
Introducing slack variables
yijk , zijk  {0,1}
Theorem: B is NP-Complete
• Every place has exactly one tile
| D|1
x
ijk
k 0
1
• Horizontal rules
xijk 

( dk , dl )H
xi 1, j ,l  1
• Vertical rules
xijk 

( dk , dl )V
xi , j 1,l  1
• Place d0 at (0, 0)
x000  1
0  i, j  s  1
0  i, j  s  1
0  k | D | 1
0  i, j  s  1
0  k | D | 1
xijk 

xi 1, j ,l  yijk  1

xi , j 1,l  zijk  1
( dk , dl )H
xijk 
( dk , dl )V
Introducing slag variables
yijk , zijk  {0,1}
Theorem: B is NP-Complete
• Every place has exactly one tile
| D|1
x
k 0
ijk
1
• Horizontal rules
xijk 

( dk , dl )H
xi 1, j ,l  yijk  1
• Vertical rules
xijk 

( dk , dl )V
• Place d0 at (0, 0)
xi , j 1,l  zijk  1
x000  1
0  i, j  s  1
0  i, j  s  1
0  k | D | 1
0  i, j  s  1
0  k | D | 1
Introducing slag variables
yijk , zijk  {0,1}
Theorem: B is NP-Complete
• Every place has exactly one tile
| D|1
x
k 0
ijk
1
• Horizontal rules
xijk 

( dk , dl )H
xi 1, j ,l  yijk  1
• Vertical rules
xijk 

( dk , dl )V
• Place d0 at (0, 0)
xi , j 1,l  zijk  1
x000  1
0  i, j  s  1
0  i, j  s  1
0  k | D | 1
0  i, j  s  1
0  k | D | 1
Language Br is NP-Complete

all entries of A are in {0,1}, 


Br   ( A) @  (b) all entries of b are 1, and 


Ax

b
has
a
binary
solut
ion


Hamilton Cycle
Theorem: H is NP-Complete
H    (G ) G has a Hamilton Cycle
Pf)
1. H NP
2.
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
p .r .
p .r .
p .r .
N 2 
BT  B 
 Br 
H
H    (G ) G has a Hamilton Cycle
Theorem: H is NP-Complete
a
b
x
y
z
c
d
H    (G ) G has a Hamilton Cycle
Theorem: H is NP-Complete
a
b
x
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.
y
z
c
d
H    (G ) G has a Hamilton Cycle
Theorem: H is NP-Complete
a
b
x
y
z
c
d
H    (G ) G has a Hamilton Cycle
Theorem: H is NP-Complete
a
b
a
b
d
c
d
x
y
z
c
H    (G ) G has a Hamilton Cycle
Theorem: H is NP-Complete
a
b
c
d
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
p .r .
p .r .
p .r .
N 2 
BT  B 
 Br 
Theorem: H is NP-Complete
 : Br   ( A) @  (b) 
H    (G )
w   ( A) @  (b)
 ( w)   (G )
w  Br
x1

x2

x3
x2
x3

x4
1

x4
1

x4
1

 ( w)  H

H
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
p .r .
p .r .
p .r .
N 2 
BT  B 
 Br 
Theorem: H is NP-Complete
x1

x2

x3
x2
x3

x4
1

x4
1

x4
1
H
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
p .r .
p .r .
p .r .
N 2 
BT  B 
 Br 
Theorem: H is NP-Complete
x1

x2

x3
x2
x3

x4
1

x4
1

x4
1
H
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
p .r .
p .r .
p .r .
N 2 
BT  B 
 Br 
Theorem: H is NP-Complete
x1

x2

x3
x2
x3

x4
1

x4
1

x4
1
H
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
p .r .
p .r .
p .r .
N 2 
BT  B 
 Br 
Theorem: H is NP-Complete
 : Br   ( A) @  (b) 
H    (G )
w   ( A) @  (b)
 ( w)   (G )
w  Br
x1

x2

x3
x2
x3

x4
1

x4
1

x4
1

 ( w)  H

H
Traveling Salesman Problem (TSP)

TSP  I

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

@  ( D) @ I b $ (t ) D(t )  b
TSPNP
already known
Is TSP NP-complete?
Theorem: TSP is NP-Complete


TSP  I n @  ( D) @ I b a tour t with D(t )  b
TSP
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
N 2  BT  B  H
p .r .
p .r .
p .r .
 Br 
p.r.


TSP  I n @  ( D) @ I b a tour t with D(t )  b
Theorem: TSP is NP-Complete
:
H    (G )


TSP  I n @  ( D) @ I b
w   (G )
w H
 (w)  I n @ ( D)@ I b
 ( w)  TSP

TSP
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.

N 2  BT  B  H
p .r .
p .r .
p .r .
 Br 
p.r.


TSP  I n @  ( D) @ I b a tour t with D(t )  b
Theorem: TSP is NP-Complete
:
H    (G )


TSP  I n @  ( D) @ I b
w   (G )
w H
 (w)  I n @ ( D)@ I b

n?
D   d ij   ?
 ( w)  TSP
b?



TSP  I n @  ( D) @ I b a tour t with D(t )  b
Theorem: TSP is NP-Complete
G = (V, E)
H  I n @  ( D) @ I b
 : Br   (G) 
w   (G )
w H
 (w)  I n @ ( D)@ I b

n  ?| V |
 ( w)  TSP
b  ?0

0 if i, j  E
dij  

1 if i, j  E
D   d ij   ?



TSP  I n @  ( D) @ I b a tour t with D(t )  b
Theorem: TSP is NP-Complete
 : Br   (G) 
G = (V, E)
H  I n @  ( D) @ I b
n
b
w


(
G
)

(
w
)

I
@

(
D
)@
I
There exists a Hamilton cycle in graph G=(V, E) if
and only if there
( w)  TSP tour for the
 a zero-cost
w  Hexists
following TSP .
n  ?| V |
b  ?0

0 if i, j  E
dij  

1 if i, j  E
D   d ij   ?

Example:
 x1  x2    x3  x4 
Satisfiability Problem (SAT)
x1 , x2 ,
: Boolean Variables;
xi : the negation of xi;
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.
Normal Forms
CNF


c

ij 
V

i 1  j 1

DNF
 ki

d

ij 
V

i 1  j 1

k
k
ki
Cook’s Theorem

SAT is NP-complete

SATP iff P =NP
SAT is NP-complete
Cook’s Theorem
Pf)
1. SAT NP
2.
p.r.
NP  L  N 0  N̂ 0
p .r .
skip
p .r .
p.r.
SAT
p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP
 Br 
p.r.
p .r .
p .r .
N 0 
NP  L 
N̂ 0
Cook’s Theorem
p.r.
ss
dk
(m, n)
SAT
p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP
 Br 
Define literals:
Pmndk
true dk  D is placed at (m, n)

 false dk  D is not placed at (m, n)
p.r.
p .r .
p .r .
N 0 
NP  L 
N̂ 0
SAT
Cook’s Theorem
p.r.
ss
dk
(m, n)
p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP


 Pmnd1  Pmnd2



0 m  s 1 d1 , d 2 D
0 n  s 1 
 d1  d2

 Br 







 V Pmnd1  Pm1,n,d2 

0 m s 1  d1 , d2 H

0 n  s 1




 V Pmnd1  Pm,n1,d2 

0 m s 1  d1 , d 2 V

0 n  s 1


P00 d0

p.r.
p .r .
p .r .
N 0 
NP  L 
N̂ 0
True if and only if there
is no different tiles
being placed at each cell.
SAT
Cook’s Theorem
ss
dk
(m, n)
p.r.
p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP


 Pmnd1  Pmnd2



0 m  s 1 d1 , d 2 D
0 n  s 1 
 d1  d2

 Br 







 V Pmnd1  Pm1,n,d2 

0 m s 1  d1 , d2 H

0 n  s 1




 V Pmnd1  Pm,n1,d2 

0 m s 1  d1 , d 2 V

0 n  s 1


P00 d0

p.r.
p .r .
p .r .
N 0 
NP  L 
N̂ 0
SAT
Cook’s Theorem
p.r.
p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP
 Br 
True if and only if
horizontal rules are
satisfied at each cell.
ss
dk
(m, n)


 Pmnd1  Pmnd2



0 m  s 1 d1 , d 2 D
0 n  s 1 
 d1  d2








 V Pmnd1  Pm1,n,d2 

0 m s 1  d1 , d2 H

0 n  s 1




 V Pmnd1  Pm,n1,d2 

0 m s 1  d1 , d 2 V

0 n  s 1


P00 d0

p.r.
p .r .
p .r .
N 0 
NP  L 
N̂ 0
SAT
Cook’s Theorem
p.r.
ss
dk
(m, n)
True if and only if 
vertical rules are 
satisfied at each
cell.

0 m  s 1 d

0 n  s 1

p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP
  P
mnd1
1 , d 2 D
d1  d 2
 Pmnd2
 Br 







 V Pmnd1  Pm1,n,d2 

0 m s 1  d1 , d2 H

0 n  s 1




 V Pmnd1  Pm,n1,d2 

0 m s 1  d1 , d 2 V

0 n  s 1


P00 d0

SAT
p.r.
p .r .
p .r .
N 0 
NP  L 
N̂ 0
Cook’s Theorem
p.r.
ss
dk
(m, n)
p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP


 Pmnd1  Pmnd2



0 m  s 1 d1 , d 2 D
0 n  s 1 
 d1  d2

 Br 

True if
 an only if d0 is
place
 at (0,P0).
mnd  Pm 1, n , d


V 
0 m s 1 d1 , d2 H
0 n  s 1
1
2










 V Pmnd1  Pm,n1,d2 

0 m s 1  d1 , d 2 V

0 n  s 1


P00 d0

p.r.
p .r .
p .r .
N 0 
NP  L 
N̂ 0
SAT
Cook’s Theorem
p.r.
ss
dk
(m, n)
p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP


 Pmnd1  Pmnd2



0 m  s 1 d1 , d 2 D
0 n  s 1 
 d1  d2

 Br 







 V Pmnd1  Pm1,n,d2 

0 m s 1  d1 , d2 H

0 n  s 1




 V Pmnd1  Pm,n1,d2 

0 m s 1  d1 , d 2 V

0 n  s 1


P00 d0

Summary
p .r .
p .r .
N 0 
NP  L 
N̂ 0
p.r.
p.r.
SAT
p .r .
p .r .
p .r .
p .r .
N 2 
BT  B  H  TSP
 Br 