35
NP-Completeness A language B is NP-complete iff B NP A NP A P B This property means B is NP hard 1

NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

NP-Completeness

• A language B is NP-complete iff • B ∈ NP • ∀ A ∈ NP A ≤P B

This property means B is NP hard

1

Page 2: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

3SAT is NP-complete

2

Page 3: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

Result Idea:

• B is known to be NP complete • Use it to prove NP-Completeness of C

IF • C is NP-hard

• B is NP-complete and • B ≤P C and

• C ∈ NP THEN

• C is NP-complete3

Page 4: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

Result• CLIQUE is NP-hard

• 3SAT is NP-complete and • 3SAT ≤P CLIQUE and

• CLIQUE ∈ NP

THEREFORE

• CLIQUE is NP-complete4

Page 5: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

Result• VERTEX-COVER is NP-hard

• 3SAT is NP-complete and • 3SAT ≤P VERTEX-COVER and

• VERTEX-COVER ∈ NP

THEREFORE

• VERTEX-COVER is NP-complete5

Page 6: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

Result

IF • B is NP-complete and • B ∈ P

THEN • P = NP

6

Page 7: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

SAT ∈ P ⇔ P = NP3SAT ∈ P ⇔ P = NP

CLIQUE ∈ P ⇔ P = NPVERTEX-COVER ∈ P ⇔ P = NP

7

Page 8: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

SAT = { Φ | Φ is a satisfiable Boolean formula}

SAT ∈ NP

Page 9: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

SAT is NP-complete

Cook-Levin Theorem

In other words • SAT ∈ NP • ∀ A ∈ NP A ≤P SAT

9

Page 10: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

To prove • ∀ A ∈ NP A ≤P SAT

define polynomial time computable function f: Σ* →Σ*

∀ w ∈ Σ* w ∈ A ⇔ f(w) ∈ SAT

∀ w ∈ Σ* w ∈ A ⇔ Φ ∈ SAT10

Page 11: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

Consider any A ∈ NP ∃ NTM N that decides A in polytime nk For any input w ∈ Σ*

valid tableau of configurations

11

Page 12: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

There is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is generated ‘legally’

Properties of a Valid Tableau

12

Page 13: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

For any input w ∈ A there is an accepting (valid) tableau of configurations

13

Page 14: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

There is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is generated ‘legally’ One of these rows is an accepting configuration

Properties of an Accepting Tableau

14

Page 15: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

Given N and w construct a Boolean formula that is satisfiable exactly when N has an accepting tableau on input w

15

Proof Idea

Page 16: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

Define Boolean formula with variables xijs for

• 1 ≤ i ≤ nk • 1 ≤ j ≤ nk • s ∈ State Set ∪ Tape Alphabet ∪ Delimiter

Want following semantics: xijs is T iff cell (i, j) contains symbol s

for some valid accepting tableau

16

Constructing the formula

Page 17: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

xijs is T iff cell (i, j) contains symbol s x12q_0 is T whereas x12⊔ is F

17

Page 18: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

There is exactly one symbol in each cellThe first row is the (‘legal’) start configuration Every subsequent row is generated ‘legally’ One of these rows is an accepting configuration

Properties of an Accepting Tableau

18

Page 19: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

represent valid tableau with a Boolean formula with components

•Φcell • exactly one symbol per cell

for any pair (i,j)the cell contains at least one symbol

the cell contains at most one symbol19

Page 20: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

There is exactly one symbol in each cell The first row is the (‘legal’) start configurationEvery subsequent row is generated ‘legally’ One of these rows is an accepting configuration

Properties of an Accepting Tableau

20

Page 21: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

represent valid tableau with a Boolean formula with components

• Φcell • exactly one symbol per cell

• Φstart • legal starting configuration

21

Page 22: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

There is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is generated ‘legally’One of these rows is an accepting configuration

Properties of an Accepting Tableau

22

Page 23: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

represent valid tableau with a Boolean formula with components

•Φcell • exactly one symbol per cell

•Φstart • legal starting configuration

•Φmove • legal moves

23

Page 24: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

represent valid tableau with a Boolean formula with components

• Φmove • legal moves

# a b q1 b c ⊔ ⊔ ⊔ ⊔ ⊔ ⊔# a q2 b c c ⊔ ⊔ ⊔ ⊔ ⊔ ⊔

# a b q1 b c ⊔ ⊔ ⊔ ⊔ ⊔ ⊔# a b a q2 c ⊔ ⊔ ⊔ ⊔ ⊔ ⊔

q2

b → c, L

q1N

transition function

b → a, Ra → b, R

24

Page 25: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

represent valid tableau with a Boolean formula with components

• Φmove • legal moves represented by legal windows

q2

b → c, L

q1N

transition function

b → a, Ra → b, R

25

Page 26: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

represent valid tableau with a Boolean formula with components

• Φmove • legal moves represented by legal windows

26

Page 27: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

There is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is generated ‘legally’ One of these rows is an accepting configuration

Properties of an Accepting Tableau

27

Page 28: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

represent valid accepting tableau with a Boolean formula with components

•Φcell • exactly one symbol per cell

•Φstart • legal starting configuration

•Φmove • legal moves

•Φaccept • legal accepting configuration

28

Page 29: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

represent valid accepting tableau with Boolean formula Φcell ∧ Φstart ∧ Φmove ∧ Φaccept

29

Page 30: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

∀ w ∈ Σ* w ∈ A ⇔

there is a valid accepting tableau ⇔

constructed formula is SATISFIABLE

30

SAT is NP-complete

Corollary 7.42: 3SAT is NP-complete

Page 31: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

HALTTM = { M, w : M is a TM that halts on input w}

HALTTM is NP-hard

In other words ∀ A ∈ NP A ≤P HALTTM

31

Page 32: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

define polynomial time computable function f: Σ* →Σ*

∀ w ∈ Σ* w ∈ 3SAT ⇔ f(w) ∈ HALTTM

3SAT ≤P HALTTM

32

Page 33: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

Define TM M as follows

M: On input w:

If w is not a valid 3CNF encoding then loop

If w is a valid 3CNF encoding then

check if w evaluates to True for any possible assignment to variables in w If yes then accept else loop

3SAT ≤P HALTTM

∀ w ∈ Σ* w ∈ 3SAT ⇔ M, w ∈ HALTTM33

Page 34: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

HALTTM = { M, w : M is a TM that halts on input w}

Is HALTTM NP-complete?

34

Page 35: NP-Completeness - Swarthmore Collegesindhu/cs46/s16/SAT.pdfThere is exactly one symbol in each cell The first row is the (‘legal’) start configuration Every subsequent row is

P

NP

All languages

NP-hard

NP-complete

35