Costas Busch - LSU 1
NP-complete Languages
Costas Busch - LSU 2
Polynomial Time Reductions
Polynomial Computable function : f
such that for any string computesin polynomial time:
)(wfwThere is a deterministic Turing machine
)|(| kwO
M
Costas Busch - LSU 3
)|(||)(| kwOwf
since, cannot use more than tape spacein time
M)|(| kwO
)|(| kwO
Observation:
the length of is bounded)(wf
Costas Busch - LSU 4
Language is polynomial time reducible to language
if there is a polynomial computable function such that:
f
BwfAw )(
A
B
Definition:
Costas Busch - LSU 5
Suppose that is polynomial reducible to .If then .
Theorem:
PBA B
PAProof:
Machine to decide in polynomial time:AOn input string :w 1. Compute )(wf
Let be the machine that decides BM
2. Run on input )(wfM
in polynomial time
3. If acccept Bwf )( w
M
Costas Busch - LSU 6
Example of a polynomial-time reduction:
We will reduce the
3CNF-satisfiability problemto the
CLIQUE problem
Costas Busch - LSU 7
3CNF formula:
)()()()( 654463653321 xxxxxxxxxxxx
Each clause has three literals
3CNF-SAT ={ : is a satisfiable 3CNF formula}
w wLanguage:
literal
clause
variable or its complement
Costas Busch - LSU 8
A 5-clique in graph
CLIQUE = { : graph contains a -clique}
kG, Gk
G
Language:
Costas Busch - LSU 9
Theorem: 3CNF-SAT is polynomial time reducible to CLIQUE
Proof: give a polynomial time reductionof one problem to the other
Transform formula to graph
Costas Busch - LSU 10
)()()()( 432321421421 xxxxxxxxxxxx
Clause 2
Clause 1
Clause 3
1x
2x
1x 2x 4x
1x
2x
3x
2x 4x
4x
3x
Transform formula to graph. Example:
Clause 4
Create Nodes:
Costas Busch - LSU 11
)()()()( 432321421421 xxxxxxxxxxxx
1x
2x
1x 2x 4x
1x
2x
2x 4x
4x
3x
3x
Add link from a literal to a literal in everyother clause, except the complement
Costas Busch - LSU 12
)()()()( 432321421421 xxxxxxxxxxxx
1x
2x
1x 2x 4x
1x
2x
3x
2x 4x
4x
3x
Resulting Graph
Costas Busch - LSU 13
1001
4
3
2
1
xxxx
1)()()()( 432321421421 xxxxxxxxxxxx
1x
2x
1x 2x 4x
1x
2x
3x
2x 4x
4x
3x
The formula is satisfied if and only ifthe Graph has a 4-clique End of Proof
Costas Busch - LSU 14
We define the class of NP-completelanguages
Decidable
NP-complete
NP-complete Languages
NP
Costas Busch - LSU 15
A language is NP-complete if:
• is in NP, and
• Every language in NP is reduced to in polynomial time
L
L
L
Costas Busch - LSU 16
Observation:
If a NP-complete languageis proven to be in P then:
NPP
Costas Busch - LSU 17
NP-complete
NP
P ?
Decidable
Costas Busch - LSU 18
Cook-Levin Theorem: Language SAT (satisfiability problem) is NP-complete
Proof:
Part2: reduce all NP languages to the SAT problem in polynomial time
Part1: SAT is in NP(we have proven this in previous class)
An NP-complete Language
Costas Busch - LSU 19
For any string we will construct in polynomial time a Boolean expression ),( wM
esatisfiabl is ),( wMLw
Take an arbitrary language NPL
We will give a polynomial reduction of to SAT L
Let be the NonDeterministicTuring Machine that decides in polyn. time
ML
w
such that:
Costas Busch - LSU 20
0q
iq jq
… … …
… accept
accept
reject
reject
kn
(deepest leaf)
depth
All computations of on stringw
nw ||
M
Costas Busch - LSU 21
0q
iq jq
… … …
… accept
accept
reject
reject
kn
(deepest leaf)
depth
Consideran acceptingcomputation
Costas Busch - LSU 22
0q
iq
…
accept
jq
mq
aqknlal
ni
n
q
11
21
210
initial state
accept state
Computation path Sequence of Configurations
nw 21
:xnk
:1:2
Costas Busch - LSU 23
w
n
knkn
kn2Maximum working space area on tapeduring time steps kn
Machine TapeM
Costas Busch - LSU 24
##
#
##
#
0q 1iq
2 n1 2 n
:1:2
# #:x aq
:kn
32 kn
Tableau of Configurations
Accept configuration
indentical rows1 2 3 kn
1l
1 2 3 1
l knaq
kn kn
……
Costas Busch - LSU 25
}q,,{q},,{}#{states} of {setalphabet} {tape}#{
t1r1
C
Tableau Alphabet
Finite size (constant))1(|| OC
Costas Busch - LSU 26
For every cell position ji ,andfor every symbol in tableau alphabet Cs
Define variable sjix ,,
Such that if cell contains symbolThen Else
ji , s1,, sjix0,, sjix
Costas Busch - LSU 27
##
##
0q 1iq
2 n1 2 n
:1:2
Examples:
1#,1,1 x
3kn
1,3,2 i
k qnx
0,1,1 x 0#,3,2 kn
x
Costas Busch - LSU 28
moveacceptstartcell),( wM
),( wM is built from variables sjix ,,
When the formula is satisfied,it describes an accepting computation in the tableau of machine on inputM w
Costas Busch - LSU 29
cell makes sure that everycell in the tableau contains exactly one symbol
tjisjitsCtssjiCsji
xxx ,,,,,,,, allcell
Every cell containsat least one symbol
Every cell containsat most one symbol
Costas Busch - LSU 30
tjisjitsCtssjiCsji
xxx ,,,,,,,, allcell
Size of :cell
||C 2||C( )kk nkn )2(
)( 2knO
Costas Busch - LSU 31
start makes sure that the tableaustarts with the initial configuration
#,22,1,22,1,3,1
,2,1,3,1,2,1
,1,1,2,1#,1,1start
10
kkk
nkkk
k
nnnn
nnnqn
n
xxx
xxxxxx
Describes the initial configurationin row 1 of tableau
Costas Busch - LSU 32
Size of :start
#,32,1,22,1
,3,1,2,1,1,1
,2,1#,1,1start
10
kk
kkk
nn
nqnn
xx
xxxxx
)(32 kk nOn
Costas Busch - LSU 33
accept makes sure that the computationleads to acceptance
qjijix ,,
F q all, allaccept
An accept state should appear somewherein the tableau
Accepting states
Costas Busch - LSU 34
Size of :accept
qjijix ,,
F q all, allaccept
)()32( 2kkk nOnn
Costas Busch - LSU 35
move makes sure that the tableaugives a valid sequence of configurations
move is expressed in terms of legal windows
Costas Busch - LSU 36
Tableau
a 1q b2q a c
Window
2x6 area of cells
Costas Busch - LSU 37
Possible Legal windows
Rba ,
Lcb ,1q
Rab ,
2qa
a 1q b2q a
aa
c
bb
b
b
1q
1q
2q
2qaaa
aa a
a
Legal windows obey the transitions
Costas Busch - LSU 38
Possible illegal windows
Rba ,
Lcb ,1q
Rab ,
2q b
2q
a1q
ba
b
b
b
1q
1q
2q
aaa
aaa
Costas Busch - LSU 39
legal) is j)(i, window(ji, allmove
ij
aa 1q b2q a
aac b
b 1q1q2qaa
aa
j
i ij
window (i,j) is legal:
((is legal) (is legal) (is legal))
all possible legal windowsin position ),( ji
Costas Busch - LSU 40
ija 1q b2q a c
(is legal)
cjiajiqji
bjiqjiaji
xxxxxx
,2,1,1,1,,1
,,,1,,,
2
1
Formula:
Costas Busch - LSU 41
Size of : move
Number of possible legal windows in a cell i,j: 6||Cat most
Size of formula for a legal window in a cell i,j: 6
Number of possible cells: kk nn )32(
x
x )()32(|| 26 kkk nOnnC
Costas Busch - LSU 42
moveacceptstartcell),( wM
Size of :),( wM
)( 2knO )( knO )( 2knO )( 2knO )( 2knO
polynomial in nit can also be constructed in time )( 2knO
Costas Busch - LSU 43
esatisfiabl is ),( wMLw
moveacceptstartcell),( wM
we have that:
Costas Busch - LSU 44
is constructed in polynomial time
esatisfiabl is ),( wMLw
),( wM
Since,
and
Lis polynomial-time reducible to SAT
END OF PROOF
Costas Busch - LSU 45
Observation 1:The formula can be convertedto CNF (conjunctive normal form) formulain polynomial time
),( wM
moveacceptstartcell),( wM
Already CNFNOT CNF
But can be converted to CNFusing distributive laws
Costas Busch - LSU 46
Distributive Laws:
)()()( RPQPRQP
)()()( RPQPRQP
Costas Busch - LSU 47
Observation 2:The formula can alsobe converted to a 3CNF formulain polynomial time
),( wM
laaa 21
)()()( 13342231121 lll zazzazzazzaa
convert
Costas Busch - LSU 48
From Observations 1 and 2:
CNF-SAT and 3CNF-SAT are NP-complete languages
(they are known NP languages)
Costas Busch - LSU 49
Theorem:If: a. Language is NP-complete b. Language is in NP c. is polynomial time reducible to
A
A BB
Proof:Any language in NPis polynomial time reducible to .Thus, is polynomial time reducible to
AB
(sum of two polynomial reductions,gives a polynomial reduction)
L
L
Then: is NP-completeB
Costas Busch - LSU 50
Corollary: CLIQUE is NP-complete
Proof:
b. CLIQUE is in NP (shown in last class)c. 3CNF-SAT is polynomial reducible to CLIQUE
a. 3CNF-SAT is NP-complete
Apply previous theorem withA=3CNF-SAT and B=CLIQUE
(shown earlier)
Top Related