Title: Computer Science 500 Theory of Computation Spring, 2000, April 5
1Computer Science 500Theory of ComputationSpring,
2000, April 5 1. Vertex Cover 2. Hamiltonian
Path
2NP-harddefinition
A language L is NP-hard iff ? L in NP, L
ltp L
3NP-completedefinition
A language L is NP-complete iff 1) L ? NP
2) L is NP-hard
4Theorem (Cook-Levin)SAT is NP-complete
Proof We already know SAT ? NP. So, we only
need to show that SAT is NP-hard. Let L be any
language in NP. We demonstrate a poly-time
reduction f from L to SAT
5Definition 3-SAT
3-SAT ?(x1, x2 xn) ? ? SAT ? C1 AND
C2 AND Cn where Ci ?i1 OR ?i2 OR
?i3, and ?i,j ?k ?ij xk or ?ij xk
Conjunctive Normal Form
6Theorem(Cook/Levin) 3-SAT is NP-complete
Proof 1) 3-SAT ? NP (by guessing the
assignment to variables and verifying that ?(x1,
x2 xn) 1) 2) ?L, L ? NP L ltp 3-SAT Proof of
(2) a) use DeMorgans law to convert f of
Cook/Levin to conjunctive normal form (an AND
of ORs). b) convert ORs to clauses of 3
variables
72 Definitions Vertex Cover and VERTEX-COVERpairs
1. Given graph G (V,E), a subset V1 of
vertices is a vertex cover if each edge in E is
adjacent to at least one vertex in V1 2.
VERTEX-COVERpairs (G,k) G has a
vertex cover of size at most
k
8Claim VERTEX-COVERpairs is NP-complete
Proof 1) VERTEX-COVERpairs (G,k) ? S ? VG
s.t. A) S lt k B) S is a vertex cover
of G So VERTEX-COVERpairs ? NP 2)
VERTEX-COVERpairs is NP-hard we will show 3-SAT
ltp VERTEX-COVERpairs
93-SAT ltp VERTEX-COVERpairs
Define Reduction f 1. f formulas ? Graphs x
Z 2. f is poly-time computable
Input Boolean formula F in 3-SAT form e.g. F
(a or b or not c) AND ((not a) or b or d) AND
Let C be the number of clauses and N be the
number of variables
Output graph G 3. ? F, F ? 3-SAT ? f(F)
(G,2C N) ? Vertex-Cover
10? f, f(f) (G,k) where k 2CNand graph G is
as follows C triangles and N pairs
a
a
b
d
b
c
11Defining G
- Each instance vertex of a variable is connected
to one - of the variables pair vertices
- T if the instance is not negated
- and F if the instance is negated
12Showing the reduction f 3-SAT to
VERTEX-COVERpairs is correct
1. ?f, f ?3-SAT ? (G, k 2CN) ?
VERTEX-COVERpairs 2. ?f, f ?3-SAT ? (G, k 2CN)
? VERTEX-COVERpairs
(reduction does not necessarily preserve the size
of the witness set)
13Showing 1.
Given an assignment, circle T or F accordingly,
a
a
b
d
b
c
14Showing 1. ...
For each triangle / clause circle two vertices,
leaving one true literal
This covers the edges
a
a
b
d
b
c
15Showing 2.
(At least) one of each true/false pair of
vertices must be in the cover
16Showing 2. ...
(At least) two vertices in each triangle / clause
must be in the cover
a
b
c
17Showing 2. ...
If any one of the clauses is not satisfied, then
one of the highlighted edges is not covered
a
b
c
182 definitions Hamiltonian Pathand Directed_HP
1. A Hamiltonian path from vertex s to vertex t
in a graph G is one that starts at vertex s, ends
at vertex t, and visits every vertex of G exactly
once
2. Directed_HP (G,s,t) G is a directed
graph with a Hamiltonian path that starts at
vertex s and ends at vertex t
19Hamiltonian Pathexample
(G, s, t) ? Direct_HP
s
G
t
This does have a Hamiltonian Path
20TheoremDirected-HP is NP-complete
21Proof
Proof 1) Directed_HP (G,s,t) ? p ? EG
s.t. A) p is a path from s to t B) p
enters and leaves each vertex other than
s and t exactly once So Directed_HP ?
S1,p NP
22Proof continued
2. Directed-HP is NP-hard by reduction from
3-SAT We will demonstrate f formulae
Graphs x vertices x vertices ??, ? ? 3-SAT ?
f(?) ? Directed-HP
2
Polynomial time
1
3
f(?) (G,s,t)
23Reduction 3-SAT to Directed-HP
f(?)
Suppose ? has N variables and C clauses
Variable x1 x2 . . xN
s
One variable Gadget for each variable
t
24Reduction 3-SAT to Directed-HP Continued
Variable x1 x2 . . xN
Clausej X1 OR X2 OR XN
s
N Clause Gadgets for each clause
t
25Claim ? ?3-SAT ? f(?) (G,s,t) ? directed-HP
26Proof ( ) If f is satisfiable by x1 T,
x2 F, xN T then the following path
works
Variable x1 x2 . . xN
s
t
27Proof ( )
Any Hamiltonian path in our graph must be of the
above form
28In class Clique