NP-complete Languages
-
Upload
howard-roberts -
Category
Documents
-
view
220 -
download
0
description
Transcript of NP-complete Languages
![Page 1: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/1.jpg)
Costas Busch - LSU 1
NP-complete Languages
![Page 2: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/2.jpg)
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
![Page 3: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/3.jpg)
Costas Busch - LSU 3
)|(||)(| kwOwf
since, cannot use more than tape spacein time
M)|(| kwO
)|(| kwO
Observation:
the length of is bounded)(wf
![Page 4: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/4.jpg)
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:
![Page 5: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/5.jpg)
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
![Page 6: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/6.jpg)
Costas Busch - LSU 6
Example of a polynomial-time reduction:
We will reduce the
3CNF-satisfiability problemto the
CLIQUE problem
![Page 7: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/7.jpg)
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
![Page 8: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/8.jpg)
Costas Busch - LSU 8
A 5-clique in graph
CLIQUE = { : graph contains a -clique}
kG, Gk
G
Language:
![Page 9: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/9.jpg)
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
![Page 10: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/10.jpg)
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:
![Page 11: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/11.jpg)
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
![Page 12: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/12.jpg)
Costas Busch - LSU 12
)()()()( 432321421421 xxxxxxxxxxxx
1x
2x
1x 2x 4x
1x
2x
3x
2x 4x
4x
3x
Resulting Graph
![Page 13: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/13.jpg)
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
![Page 14: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/14.jpg)
Costas Busch - LSU 14
We define the class of NP-completelanguages
Decidable
NP-complete
NP-complete Languages
NP
![Page 15: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/15.jpg)
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
![Page 16: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/16.jpg)
Costas Busch - LSU 16
Observation:
If a NP-complete languageis proven to be in P then:
NPP
![Page 17: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/17.jpg)
Costas Busch - LSU 17
NP-complete
NP
P ?
Decidable
![Page 18: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/18.jpg)
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
![Page 19: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/19.jpg)
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:
![Page 20: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/20.jpg)
Costas Busch - LSU 20
0q
iq jq
… … …
… accept
accept
reject
reject
kn
(deepest leaf)
depth
All computations of on stringw
nw ||
M
![Page 21: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/21.jpg)
Costas Busch - LSU 21
0q
iq jq
… … …
… accept
accept
reject
reject
kn
(deepest leaf)
depth
Consideran acceptingcomputation
![Page 22: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/22.jpg)
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
![Page 23: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/23.jpg)
Costas Busch - LSU 23
w
n
knkn
kn2Maximum working space area on tapeduring time steps kn
Machine TapeM
![Page 24: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/24.jpg)
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
……
![Page 25: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/25.jpg)
Costas Busch - LSU 25
}q,,{q},,{}#{states} of {setalphabet} {tape}#{
t1r1
C
Tableau Alphabet
Finite size (constant))1(|| OC
![Page 26: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/26.jpg)
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
![Page 27: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/27.jpg)
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
![Page 28: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/28.jpg)
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
![Page 29: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/29.jpg)
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
![Page 30: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/30.jpg)
Costas Busch - LSU 30
tjisjitsCtssjiCsji
xxx ,,,,,,,, allcell
Size of :cell
||C 2||C( )kk nkn )2(
)( 2knO
![Page 31: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/31.jpg)
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
![Page 32: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/32.jpg)
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
![Page 33: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/33.jpg)
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
![Page 34: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/34.jpg)
Costas Busch - LSU 34
Size of :accept
qjijix ,,
F q all, allaccept
)()32( 2kkk nOnn
![Page 35: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/35.jpg)
Costas Busch - LSU 35
move makes sure that the tableaugives a valid sequence of configurations
move is expressed in terms of legal windows
![Page 36: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/36.jpg)
Costas Busch - LSU 36
Tableau
a 1q b2q a c
Window
2x6 area of cells
![Page 37: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/37.jpg)
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
![Page 38: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/38.jpg)
Costas Busch - LSU 38
Possible illegal windows
Rba ,
Lcb ,1q
Rab ,
2q b
2q
a1q
ba
b
b
b
1q
1q
2q
aaa
aaa
![Page 39: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/39.jpg)
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
![Page 40: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/40.jpg)
Costas Busch - LSU 40
ija 1q b2q a c
(is legal)
cjiajiqji
bjiqjiaji
xxxxxx
,2,1,1,1,,1
,,,1,,,
2
1
Formula:
![Page 41: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/41.jpg)
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
![Page 42: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/42.jpg)
Costas Busch - LSU 42
moveacceptstartcell),( wM
Size of :),( wM
)( 2knO )( knO )( 2knO )( 2knO )( 2knO
polynomial in nit can also be constructed in time )( 2knO
![Page 43: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/43.jpg)
Costas Busch - LSU 43
esatisfiabl is ),( wMLw
moveacceptstartcell),( wM
we have that:
![Page 44: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/44.jpg)
Costas Busch - LSU 44
is constructed in polynomial time
esatisfiabl is ),( wMLw
),( wM
Since,
and
Lis polynomial-time reducible to SAT
END OF PROOF
![Page 45: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/45.jpg)
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
![Page 46: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/46.jpg)
Costas Busch - LSU 46
Distributive Laws:
)()()( RPQPRQP
)()()( RPQPRQP
![Page 47: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/47.jpg)
Costas Busch - LSU 47
Observation 2:The formula can alsobe converted to a 3CNF formulain polynomial time
),( wM
laaa 21
)()()( 13342231121 lll zazzazzazzaa
convert
![Page 48: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/48.jpg)
Costas Busch - LSU 48
From Observations 1 and 2:
CNF-SAT and 3CNF-SAT are NP-complete languages
(they are known NP languages)
![Page 49: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/49.jpg)
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
![Page 50: NP-complete Languages](https://reader036.fdocuments.in/reader036/viewer/2022062504/5a4d1bc57f8b9ab0599d4949/html5/thumbnails/50.jpg)
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)