NANO266 - Lecture 12 - High-throughput computational materials design
Lecture 8: Computational Complexity
description
Transcript of Lecture 8: Computational Complexity
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
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?
Yields in t Steps tM├
C C0M├ iff C C
C C1tM├ iff
C such that
C CtM├ and C C M├
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|);
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
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
Lecture 8: Computational Complexity
Rate ofGrowth Functions
大同大學資工所智慧型多媒體研究室
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
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
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
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
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.
Theorem
0
( 0. ) d
jj d
j
f n a n a
Let with Then,
( ) ( ), 1.nf n O r r
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
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).
Lecture 8: Computational Complexity
Time-Bound Simulations
大同大學資工所智慧型多媒體研究室
Time-Complexities on TMs
Not Solvable Solvable
The complexities to solve problems
on different TMs are different.
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
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
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 8: Computational Complexity
P and NP
大同大學資工所智慧型多媒體研究室
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.
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
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!
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:
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.
Definition
( )NTIME TThe class of languages acceptable in nondeterministic time T.
What is the difference between TIME(T) and NTIME(T)?
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.
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.
Exercise
Given d >0, there exists a polynomial p of
degree d being a step counting function.
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.
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
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.
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’’
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.
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’ =?
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.
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
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
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
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.
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.
?
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
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
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
Is P = NP ?
NPP
How to show?
P NPShow NP Pand
Trivial (why?) DifficultNo answer, now.
Example (TSPNP )
1
2
5
3
4
6
7
8
[ ]ijD d Distance matrix
TSPF
Find the shortest tour t.
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.
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
Exercises
Show that
1. TSPNP.
2. TSPP a polynomial algorithm for TSPF.
3. TSP’P.
Remark
TSPP P = NP
Lecture 8: Computational Complexity
NP-Completeness
大同大學資工所智慧型多媒體研究室
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.
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
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.
Definition: NP-Completeness
is called NP-complete iff*L
1. LNP
2.
.
L
L L
NP
is polynomial reducible to
More on NP-Completeness
1. LNP..2. .p rL L L NP
NP
P
L
NP-Complete
p.r.p.r.
Not Solvable Solvable
NP-Hard
1. LNP..2. .p rL L L NP
NP
P
L
NP-Complete
p.r.p.r.
NP-Hard
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
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.
Lecture 8: Computational Complexity
Bounded Halting Problems
大同大學資工所智慧型多媒體研究室
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?
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
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
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
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.
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
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 .
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
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’|
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’|
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’|
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.
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
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:
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
├
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.
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.
= ?
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
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
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
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
Summary
0N0N̂. .p r LNP
2Np.r.
. .p r
Lecture 8: Computational Complexity
Some Important NP-Complete
Problems
大同大學資工所智慧型多媒體研究室
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.
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
Bounded Tiling Problem (BT)
0( , , , )D d H VD
( ) there is an tiling by @ sBT I s s D D
BT is NP-Complete
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
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
Theorem: BT is NP-Complete
2s t
0 1 t t+1
0
1
t
t+1
( )@ tw M I ( ) ( )@ sw I D
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
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)
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.
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)
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)
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)
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)
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)
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)##
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)
##
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
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?
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
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
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
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
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
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
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
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.
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
Hamilton Cycle
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
Theorem: H is NP-Complete
( ) has a Hamilton CycleH G G
x
y
z
a b
c d
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.
Theorem: H is NP-Complete
( ) has a Hamilton CycleH G G
x
y
z
a b
c d
Theorem: H is NP-Complete
( ) has a Hamilton CycleH G G
x
y
z
a b
c d
a b
c d
Theorem: H is NP-Complete
( ) has a Hamilton CycleH G G
a b
c d
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
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
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
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
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
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?
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
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
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 :
?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
?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 .
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
Normal Forms
CNF
DNF
1 1
Vi
ij
j
kk
i
c
11
Vikk
jiijd
Cook’s Theorem
SAT is NP-complete
SATP iff P =NP
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
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
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
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.
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.
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.
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).
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
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