Computability and Complexity
15-1
NP-Completeness
Computability and Complexity
Andrei Bulatov
Computability and Complexity
NP-Completeness Proofs
To prove that a language L is NP-complete we now just have to
perform two steps:
1.
2.
Show that L belongs to NP
Find a known NP-complete problem (language) L and
show L L
100s of problems have now been shown to be NP-complete
(for an earlier survey see Garey and Johnson)
Note: If we can complete Step 2 but not Step 1, then we say that
L is NP-hard
15-2
Computability and Complexity
NP-Completeness of Clique
Clique
Instance: A graph G and a number k.
Question: Does G contain a clique of size k?
Theorem
Clique is NP-complete
Step 1:
The problem Clique is in NP:
the list of vertices in the clique is the certificate
15-3
Computability and Complexity
Step 2:
To show that Clique is NP-complete we shall reduce
Satisfiability to Clique
Given a formula with clauses C1 , C2 ,, Ck
• For each literal X in clause C j create a graph vertex
• Put an edge between every pair of vertices from distinct clauses,
unless they are incompatible (i.e. X and X)
This construction can be carried out in polynomial time
The resulting graph has a clique of size k if and only if is
satisfiable (assign the value true to every variable occurring in the
clique)
15-4
Computability and Complexity
15-5
Example Construction
( X Y Z ) (X U ) (U V Y Z )
C1
C2
C3
X
U
Y
V
Z
Y
X
k3
U
Z
Computability and Complexity
NP-Completeness of Vertex Cover
Vertex Cover¹
Instance: A graph G = (N,E), and a natural number k.
Question: Is there a set M N, with M k, such that for each
edge (i,j) E,
{i,j} M ?
¹Sometimes called Node Cover
Step 1:
The problem Vertex Cover is in NP:
the list of vertices in M is the certificate
15-6
Computability and Complexity
15-7
Step 2:
To show that Vertex Cover is NP-complete we
shall reduce Satisfiability to Vertex Cover
Given a formula with clauses C1 , C2 ,, Cm and n variables
• For each variable X create two adjacent vertices X t and X
to represent the literals X and X
• For each clause C j of size n j create a complete subgraph
G j with vertices connected to corresponding literals
m
• Set k n ( n j 1)
j 1
This construction can be carried out in polynomial time
f
Computability and Complexity
15-8
Example Construction
( X Y Z ) (X U ) (U V Y Z )
C1
C2
C3
X
Y
G1
G2
Z
U
V
G3
k 5 2 1 3 11
Computability and Complexity
•
At least one of each pair ( X f , X t ) must be in the cover
• At least n j 1 vertices from each complete graph G j
must be in the cover
• If the formula is satisfiable, then choose the cover by choosing
each literal assigned true plus all but one vertex in each G j
(Omit a vertex which is connected to a satisfied literal.)
• Conversely, if a vertex cover exists, assign each Boolean variable
according to whether X t (true) or X f (false) is in M. (By the
choice of k, there must be one vertex in each clique which is not
in M. This vertex must be adjacent to a vertex in M, hence the
clause is satisfied.)
15-9
Computability and Complexity
Alternative Reductions
We have shown that Clique and Vertex Cover are
both NP-complete
This means it must be possible to reduce Clique to
Vertex Cover and vice versa!
15-10
Computability and Complexity
15-11
NP-Completeness of 3-SAT
To show that 3-Satisfiability is NP-complete we reduce
Satisfiability to 3-Satisfiability
• Replace every clause
C X1 X 2 X k
with k > 3 by
C' ( X 1 X 2 Y1 ) (Y1 X 3 Y2 ) (Yk 3 X k 1 X k )
• C is satisfiable if and only if C is, since at least one of the literals
other than ys must be true
© Copyright 2025 Paperzz