NP-complete Languages
Costas Busch - LSU
1
Polynomial Time Reductions
Polynomial Computable function f :
There is a deterministic Turing machine M
such that for any string w computes f (w)
k
O
(|
w
|
)
in polynomial time:
Costas Busch - LSU
2
Observation:
the length of f (w) is bounded
| f (w ) | O (|w |k )
since, M cannot use
more than O (| w |k ) tape space
in time O (| w |k )
Costas Busch - LSU
3
Definition:
Language A
is polynomial time reducible to
language B
if there is a polynomial computable
function f such that:
w A f ( w) B
Costas Busch - LSU
4
Theorem:
Suppose that A is polynomial reducible to
If B P then A P .
B.
Proof:
Let
M
be the machine that decides B
in polynomial time
Machine M to decide
On input string
w:
A
in polynomial time:
1. Compute f (w)
2. Run M on input f (w)
3. If f (w ) B acccept w
Costas Busch - LSU
5
Example of a polynomial-time reduction:
We will reduce the
3CNF-satisfiability problem
to the
CLIQUE problem
Costas Busch - LSU
6
3CNF formula:
variable or its
literal complement
( x1 x2 x3 ) ( x3 x5 x6 ) ( x3 x6 x4 ) ( x4 x5 x6 )
clause
Each clause has three literals
Language:
3CNF-SAT ={
w
:
w
Costas Busch - LSU
is a satisfiable
3CNF formula}
7
A 5-clique in graph
G
Language:
CLIQUE = { G, k : graph G
contains a
Costas Busch - LSU
k-clique}
8
Theorem:
Proof:
3CNF-SAT is polynomial time
reducible to CLIQUE
give a polynomial time reduction
of one problem to the other
Transform formula to graph
Costas Busch - LSU
9
Transform formula to graph.
Example:
(x 1 x 2 x 4 ) (x 1 x 2 x 4 ) (x 1 x 2 x 3 ) (x 2 x 3 x 4 )
Clause 2
Create Nodes:
Clause 1
x1
x2
x4
Clause 3
x1
x1
x2
x2
x4
Clause 4
x2
Costas Busch - LSU
x3
x3
x4
10
(x 1 x 2 x 4 ) (x 1 x 2 x 4 ) (x 1 x 2 x 3 ) (x 2 x 3 x 4 )
x1
x2
x4
x1
x1
x2
x2
x4
x3
x2
x3
x4
Add link from a literal to a literal in every
other clause, except the complement
Costas Busch - LSU
11
(x 1 x 2 x 4 ) (x 1 x 2 x 4 ) (x 1 x 2 x 3 ) (x 2 x 3 x 4 )
x1
x2
x4
x1
x1
x2
x2
x4
x3
x2
x3
x4
Resulting Graph
Costas Busch - LSU
12
(x 1 x 2 x 4 ) (x 1 x 2 x 4 ) (x 1 x 2 x 3 ) (x 2 x 3 x 4 ) 1
x1 1
x2 0
x3 0
x4 1
x1
x2
x4
x1
x1
x2
x2
x4
x3
x2
x3
x4
The formula is satisfied if and only if
the Graph has a 4-clique
End of Proof
Costas Busch - LSU
13
NP-complete Languages
We define the class of NP-complete
languages
Decidable
NP
NP-complete
Costas Busch - LSU
14
A language L is NP-complete if:
• L is in NP, and
• Every language in NP
is reduced to L in polynomial time
Costas Busch - LSU
15
Observation:
If a NP-complete language
is proven to be in P then:
P NP
Costas Busch - LSU
16
Decidable
NP
P
?
NP-complete
Costas Busch - LSU
17
An NP-complete Language
Cook-Levin Theorem:
Language SAT (satisfiability problem)
is NP-complete
Proof:
Part1: SAT is in NP
(we have proven this in previous class)
Part2: reduce all NP languages
to the SAT problem
in polynomial time
Costas Busch - LSU
18
Take an arbitrary language L NP
We will give a polynomial reduction of L to SAT
Let M be the NonDeterministic
Turing Machine that decides L in polyn. time
For any string w we will construct
in polynomial time a Boolean expression (M,w )
such that: w L (M,w ) is satisfiabl e
Costas Busch - LSU
19
All computations
of M on string w
q0
qj
qi
depth
| w | n
…
…
…
…
reject
n
k
accept
accept
(deepest leaf)
reject
Costas Busch - LSU
20
Consider
an accepting
computation
q0
qj
qi
depth
…
…
…
…
reject
n
k
accept
accept
(deepest leaf)
reject
Costas Busch - LSU
21
Computation path
Sequence of
Configurations
q0
qi
qj
initial state
…
1:
2:
q0 1 2 n
1 qi 2 n
qm
qa
nk x :
1 l qa l1 n k
accept state
accept
w 1 2 n
Costas Busch - LSU
22
n
Machine M Tape
n
w
n
k
2n
k
k
Maximum working space area on tape
k
during n time steps
Costas Busch - LSU
23
1: #
2: #
Tableau of Configurations
q0 1 2 n
1 qi 2 n
#
#
……
x: #
Accept configuration
1 2 3
qa l1
n #
qa l1
n #
k
indentical rows
nk : #
n
1 2 3
n
k
k
k
2n 3
k
Costas Busch - LSU
24
Tableau Alphabet
C { # } {tape alphabet} {set of states}
{ # } {1 ,, r } {q1 ,, qt }
Finite size (constant)
| C | O (1)
Costas Busch - LSU
25
For every cell position
i, j
and
for every symbol in tableau alphabet
Define variable
s C
xi , j ,s
Such that if cell i , j contains symbol s
Then xi , j ,s 1
Else xi , j ,s 0
Costas Busch - LSU
26
Examples:
nk 3
1: #
2: #
q0 1 2 n
1 qi 2 n
x1,1,# 1
x2,n k 3,q 1
x1,1, 0
x2,n k 3,# 0
#
#
i
Costas Busch - LSU
27
(M,w )
is built from variables
xi , j ,s
(M ,w ) cell start accept move
When the formula is satisfied,
it describes an accepting computation
in the tableau
of machine M on input w
Costas Busch - LSU
28
cell
cell
makes sure that every
cell in the tableau contains
exactly one symbol
xi , j ,s xi , j ,s xi , j ,t
all i , j s C
s ,t C
s t
Every cell contains
at least one symbol
Every cell contains
at most one symbol
Costas Busch - LSU
29
Size of
cell
:
xi , j ,s xi , j ,s xi , j ,t
all i , j s C
s ,t C
s t
cell
(2n 3)n ( |C |
k
k
O (n
2k
|C |2 )
)
Costas Busch - LSU
30
start
makes sure that the tableau
starts with the initial configuration
start x1,1,# x1,2, x1,n
k
1,
x1,n k 2,q x1,n k 3, x1,n k n 2,
0
1
n
x1,n k n 3, x1,2n k 2, x1,2n k 2,#
Describes the initial configuration
in row 1 of tableau
Costas Busch - LSU
31
Size of
start :
start x1,1,# x1,2,
x1,n k 1, x1,n k 2,q x1,n k 3,
0
x1,2n k 2, x1,2n k 3,#
1
2n 3 O (n )
k
k
Costas Busch - LSU
32
makes sure that the computation
accept leads to acceptance
accept xi , j ,q
all i , j
all q F
Accepting states
An accept state should appear somewhere
in the tableau
Costas Busch - LSU
33
Size of
accept :
accept xi , j ,q
all i , j
all q F
(2n 3)n O(n )
k
k
Costas Busch - LSU
2k
34
move
move
makes sure that the tableau
gives a valid sequence
of configurations
is expressed in terms of
legal windows
Costas Busch - LSU
35
Tableau
Window
a q1 b
q2 a c
2x6 area of cells
Costas Busch - LSU
36
Possible Legal windows
a b, R
q1
b c, L
b a,R
q2
a q1 b
q2 a c
a q1 b
a a q2
a a q1
a a b
a b a
a b q2
Legal windows obey the transitions
Costas Busch - LSU
37
Possible illegal windows
a b a
a a a
a b, R
q1
b c, L
b
q2
q2
b a,R
Costas Busch - LSU
a q1 b
q1 a a
q1 b
b q2
38
move (window (i, j) is legal)
all i,j
window (i,j) is legal:
j
j
j
i a q1 b i a q1 b i a a q1
q2 a c
a a q2
a a b
((is legal) (is legal) (is legal))
all possible legal windows
in position (i , j )
Costas Busch - LSU
39
j
i a q1 b
q2 a c
(is legal)
Formula:
xi , j ,a xi , j 1,q1 xi , j 2,b
xi 1, j ,q2 xi 1, j 1,a xi 1, j 2,c
Costas Busch - LSU
40
move
Size of
:
Size of formula for a legal window
in a cell i,j: 6
Number of possible legal windows
in a cell i,j: at most |C |6
k
k
(
2
n
3
)
n
Number of possible cells:
| C | (2n 3)n O(n )
6
k
k
Costas Busch - LSU
2k
41
Size of (M,w ) :
(M ,w ) cell start accept move
O (n 2k )
O (n
2k
O (n k )
O (n 2k )
O (n 2k )
)
it can also be constructed in time O (n 2k )
polynomial in
Costas Busch - LSU
n
42
(M ,w ) cell start accept move
we have that:
w L (M,w ) is satisfiabl e
Costas Busch - LSU
43
Since,
w L (M,w ) is satisfiabl e
and
(M,w ) is constructed
in polynomial time
L
is polynomial-time reducible to SAT
END OF PROOF
Costas Busch - LSU
44
Observation 1:
The (M,w ) formula can be converted
to CNF (conjunctive normal form) formula
in polynomial time
(M ,w ) cell start accept move
Already CNF
NOT CNF
But can be converted to CNF
using distributive laws
Costas Busch - LSU
45
Distributive Laws:
P (Q R ) (P Q ) (P R )
P (Q R ) (P Q ) (P R )
Costas Busch - LSU
46
Observation 2:
The (M,w ) formula can also
be converted to a 3CNF formula
in polynomial time
a1 a2 al
convert
a1 a2 z1 (z1 a3 z 2 ) (z 2 a4 z 3 ) (zl 3 al 1 zl )
Costas Busch - LSU
47
From Observations 1 and 2:
CNF-SAT and
3CNF-SAT are
NP-complete languages
(they are known NP languages)
Costas Busch - LSU
48
Theorem:
If: a. Language A is NP-complete
b. Language B is in NP
c. A is polynomial time reducible to B
Then: B is NP-complete
Proof:
Any language L in NP
is polynomial time reducible to A.
Thus, L is polynomial time reducible to B
(sum of two polynomial reductions,
gives a polynomial reduction)
Costas Busch - LSU
49
Corollary: CLIQUE is NP-complete
Proof:
a. 3CNF-SAT is NP-complete
b. CLIQUE is in NP (shown in last class)
c. 3CNF-SAT is polynomial reducible to CLIQUE
(shown earlier)
Apply previous theorem with
A=3CNF-SAT
and
Costas Busch - LSU
B=CLIQUE
50
© Copyright 2026 Paperzz