Cook Levin HAM NPcompleteness 3 SAT CLIQUE 1

  • Slides: 44
Download presentation
Cook. Levin HAM NPcompleteness 3 SAT CLIQUE 1

Cook. Levin HAM NPcompleteness 3 SAT CLIQUE 1

Reductions Or • How to link between problems’ complexity, while not knowing what they

Reductions Or • How to link between problems’ complexity, while not knowing what they are 2

Goal: Plan: • Formalize the notion of “reductions ” • Define Karp reductions •

Goal: Plan: • Formalize the notion of “reductions ” • Define Karp reductions • Example: show HAMPATH p HAMCYCLE • Closeness under reductions • Define Cook reductions • Discuss Completeness 3

Reductions an efficient procedure for A using A cannot be an efficient procedure for

Reductions an efficient procedure for A using A cannot be an efficient procedure for B • In other words: B is at least as hard as A Notation A radically harder than B ≤p B 4

SIP 250 Karp reductions –Definition A is polynomial-time reducible to B (denote A p

SIP 250 Karp reductions –Definition A is polynomial-time reducible to B (denote A p B)) If there exists a s. t. for every w poly-time-computable function f: * * e TM m i t y l o p i. e. , on ) w ( f s t u p that out input w w A f(w) B f is a poly-time reduction of A to B 5

Karp Reductions –Ilustrated A * - A * f B * - B *

Karp Reductions –Ilustrated A * - A * f B * - B * 6

Don’t Panic Come up with a reduction-function f Show f is polynomial time computable

Don’t Panic Come up with a reduction-function f Show f is polynomial time computable Prove f is a reduction, i. e. , show: ! • w A B f(w) ould that, by default, w ns io ct du re e us ll • We’ called: this type, which is ping reduction • Polynomial-time map y-one reduction • Polynomial-time man rp reduction • Polynomial-time Ka be of 7

Reductions and Efficiency Polynomial-time algorithm for. A W f f(W) f(w) B w A

Reductions and Efficiency Polynomial-time algorithm for. A W f f(W) f(w) B w A Polynomial-time algorithm for. B 8

Hamiltonian Path Instance : • A directed graph G=(V, E) Decision Problem : •

Hamiltonian Path Instance : • A directed graph G=(V, E) Decision Problem : • Is there a path in G, , which goes through every vertex exactly once? 9

Hamiltonian Cycle Instance: • a directed graph G=(V, E). Decision Problem : • Is

Hamiltonian Cycle Instance: • a directed graph G=(V, E). Decision Problem : • Is there a simple cycle in G that paths through each vertex exactly once? 10

HAMPATH p HAMCYCLE G p G u Completeness : • Given a Hamiltonian path

HAMPATH p HAMCYCLE G p G u Completeness : • Given a Hamiltonian path (v 0, …, vn) in G, , (v 0 , …, vn , u) is a Hamiltonian cycle in G’ Soundness : • Given a Hamiltonian cycle (v 0, …, vn, u) in G’, , removing u yields a Hamiltonian path. 11

Check list Come up with a reduction-function f ? Show f is polynomial time

Check list Come up with a reduction-function f ? Show f is polynomial time computable Prove f is a reduction, i. e. , show: • w HAMPATH f(w) HAMCYCLE 12

Closeness Under Reductions: Definition A complexity class C is closed under poly-time reductions if:

Closeness Under Reductions: Definition A complexity class C is closed under poly-time reductions if: • L is reducible to L’ and L’ C L is also in C. C L ≤p L’ C 13

Observation Theorem : NP PSPACE and EXPTIME are • P, NP, closed under polynomial-time

Observation Theorem : NP PSPACE and EXPTIME are • P, NP, closed under polynomial-time Karp reductions Proof: • Do it yourself !! 14

Log-space Reductions SIP 250 A is log-space reducible to B (denote A L B))

Log-space Reductions SIP 250 A is log-space reducible to B (denote A L B)) If there exists a log-space-computable function f: * * s. t. for every w w A f(w) B f is a log-space Theorem : e TM c a p s g o l i. e. , on ) w ( f s t u p that out input w reduction of A to B • L , NL , P , NP , PSPACE and EXPTIME are closed under log-space reductions. 15

Reductions: General Cook Reduction: • Assuming an efficient procedure that decides B, construct one

Reductions: General Cook Reduction: • Assuming an efficient procedure that decides B, construct one for A. Karp is a special case of Cook reduction : an efficient procedure for A using It allows only 1 call to B, w an efficient procedure for outcome hose must be B outputte d as is 16

Cook red. : HAMCYCLE HAMPATH. 1 2 E’=E E’= reject 3 4 <u, v>

Cook red. : HAMCYCLE HAMPATH. 1 2 E’=E E’= reject 3 4 <u, v> E’ HAMPATH ( <V+{w, z}, E’+{<w, u>, <v, z>}> ) accept 5 • E’ = E’ – {<u, v>} 6 • Go to step 2 17

Definition : C-complete Completeness • For a class C of decision problems and a

Definition : C-complete Completeness • For a class C of decision problems and a language L C, L is C-complete if: L’ C L’ is reducible to L. Theorem : • L is complete for classes C, C’ C=C’ Proof: • All languages in C and in C’ are reducible to L, which is in both. Since both are closed under reductions , they’re the same Theorem : • Any L NPC, L P P=NP

Summary Discussed types of reductions : • Cook vs. Karp reductions • Poly-time vs.

Summary Discussed types of reductions : • Cook vs. Karp reductions • Poly-time vs. log-space Find Defined: • “completeness ” L and C s. t. L is C-complete Discussed a way to show: • equality between complexity classes 19

The Cook/ Levin theorem: SAT is NP-Complete: 20

The Cook/ Levin theorem: SAT is NP-Complete: 20

Goal: Plan: • In the beginning… of NP-Completeness • SAT - definition and examples

Goal: Plan: • In the beginning… of NP-Completeness • SAT - definition and examples • The Cook-Levin Theorem • Look ahead 21

SAT Instance: • A Boolean formula. EXP PSPACE Decision Problem : NPco. NP •

SAT Instance: • A Boolean formula. EXP PSPACE Decision Problem : NPco. NP • Is the formula satisfiable ? P SAT or un SAT? NL L Theorem : • SAT is in NP Proof: • Can verify an ass. efficiently 22

Cook/Levin SIP 254 -259 Theorem : • SAT is NP-Complete Proof Outline: • Given

Cook/Levin SIP 254 -259 Theorem : • SAT is NP-Complete Proof Outline: • Given an NP machine M and an input w, construct a Boolean formula M, w satisfiable M accepts w. LM M, w SAT 23

Tableaux Represent a computation as a configurations` table # # machine’ # s state

Tableaux Represent a computation as a configurations` table # # machine’ # s state # q 0 X 1 X 2 Xn _ _ _ # ? q? X 2 Xn _ _ _ # # Input # # cne # # # # # # Tape ends# # qacc _ _ _ _ # 24

 M ( Q {#})6 • = {q 0, q 1, qaccept , qreject

M ( Q {#})6 • = {q 0, q 1, qaccept , qreject } Q • = {0, 1} # q 0 0 # q 0 # 0 0 q 0 0 • = {0, 1, _} q 0 1 # q 0 # 1 • (q 0, 1)={(q 1, _, R)} • (q 1, 1)={(q 0, _, R)} • (q 0, 0)={(q 0, _, R)} • (q 1, 0)={(q 1, _, R)} • (q 0, _)={(q acc , _, L)} • (q 1, _)={(q rej , _, L)} # 1 1 0 0 _ 1 0 0 0 q 0 _ 0 0 q 0 1 0 q 0 0 1 0 0 0 qrej 1 0 1 0 q 0 1 0 0 q 1 0 0 26

cne # q 0 W 1 W 2 Wn _ _ _ # #

cne # q 0 W 1 W 2 Wn _ _ _ # # ? q? W 2 Wn _ _ _ # # j M, w variables i Boolean Xi, j, S standing for: does cell i, j has value S? # # # S # # # # # # # qacc _ _ _ _ # 27

 M, w start ≥ 1 value <2 values input blanks locally legal transition

M, w start ≥ 1 value <2 values input blanks locally legal transition accepting configuration 1 value to each entry input consistent transitions legal machine accepts 28

Q. E. D. Claim: • i, j transition is locally legal tableau legal Corollary:

Q. E. D. Claim: • i, j transition is locally legal tableau legal Corollary: • M, w Satisfiable W LM Claim: • Size of M, w polynomial in |W| 29

We have just shown SAT is NP-hard, as any NP language can be reduced

We have just shown SAT is NP-hard, as any NP language can be reduced to SAT is NPC 30

P, NP, co-NP and NPC Co-NP NP NPC P SAT 31

P, NP, co-NP and NPC Co-NP NP NPC P SAT 31

Henceforth, to show a problem A is NPhard, it suffices to reduce SAT to

Henceforth, to show a problem A is NPhard, it suffices to reduce SAT to A NPC A 32

Furthermore, once we’ve shown A is NPhard, we can reduce from it to show

Furthermore, once we’ve shown A is NPhard, we can reduce from it to show other problems NP-hard NPC B 33

Summary proved SAT is NP-Complete Consider SAT the Genesis problem, and explored how to

Summary proved SAT is NP-Complete Consider SAT the Genesis problem, and explored how to proceed and show other problems are NP-hard 34

Goal: Plan: • introduce some additional NP -Complete problems. • 3 SAT • CLIQUE

Goal: Plan: • introduce some additional NP -Complete problems. • 3 SAT • CLIQUE & INDEPENDENTSET 35

L is NPC if SAT and NPC • L In NP • L NP-hard

L is NPC if SAT and NPC • L In NP • L NP-hard – via Karp-reduction So far we only showed one such problem: SAT • which, however, is not up for the tasks ahead Next we show a special case of SAT is NPC: • 3 SAT • 3 CNF formula Decision Problem : • Is it satisfiable ? – m r o l F a m r o Conjunctive N h clause ac e n i s l a r e t i l 3 3 CNF: 3 SAT Instance: y z) x ( ) z (x y x) x x (x x x) ( 36

SIP 259 -260 Claim: • 3 SAT NP cial e p s a s

SIP 259 -260 Claim: • 3 SAT NP cial e p s a s i T A 3 S case of SAT. 3 SAT is NPC Claim: • 3 SAT NP-hard Proof: • amend our SAT formula, so it becomes 3 CNF • First make it a CNF: CNF use DNF CNF on 3 rd line Does this suffice? Are all others OK? What is the size of new formula? 37

CNF 3 CNF (x y) (x 1 x 2. . . xt). . .

CNF 3 CNF (x y) (x 1 x 2. . . xt). . . clauses with 1 or 2 literals clauses with more than 3 literals replication split (x y x) Com QED (x 1 x 2 1 x t) ) ( x 3 ). . . ( xt- 3 SAT is NP-Complete 38

CLIQUE instance: CLIQUE is NPC • A graph G=(V, E) and a threshold k

CLIQUE instance: CLIQUE is NPC • A graph G=(V, E) and a threshold k Decision problem : • Is there a set of nodes C={v 1, . . . , v k } V, s. t. u, v C: (u, v) E Observation : • CLIQUE NP Proof: • Given C, verify all inner edges are in G 39

G, k SAT p CLIQUE 3 SAT 1 vertex for 1 occurrence inconsistency non-edge

G, k SAT p CLIQUE 3 SAT 1 vertex for 1 occurrence inconsistency non-edge • within triplets. = . K = number of clauses 40

SIP 251 -253 SAT p CLIQUE: proof each triplet disconnected k-clique has 1 vertex

SIP 251 -253 SAT p CLIQUE: proof each triplet disconnected k-clique has 1 vertex in each Completeness : • Let A be a satisfying assignment to , , C(A) contains 1 v s. t. A(v ) for every clause Soundness : • In a clique C in G of size k, , each variable has 1 of its literals-vertex in C • extend to a satisfying assignment to 41

INDEPENDENT-SET is NPC IS instance: • A graph G=(V, E) and a threshold k

INDEPENDENT-SET is NPC IS instance: • A graph G=(V, E) and a threshold k Decision problem : • Is there a set of nodes I={v 1, . . . , v k } V, s. t. u, v I: (u, v) E Observation : • IS NP Proof: • Given I, verify all inner edges not in G Observation : • IS is NP-hard Clique IS on complement gr aph 42

Reductions Hamiltonian Path Polynomial Time Reductions Completeness Log Space Reductions Completeness WWindex Hamilton, William

Reductions Hamiltonian Path Polynomial Time Reductions Completeness Log Space Reductions Completeness WWindex Hamilton, William Rowan Karp, Richard Complexity Classes NP co-NP Levin, Leonid P L EXPTIME Cook, Stephen Arthur NL PSPACE 43

SAT Cook-Levin Theorem 3 SAT Cook-Levin Theorem Clique Independent Set Subset Sum CNF NPC

SAT Cook-Levin Theorem 3 SAT Cook-Levin Theorem Clique Independent Set Subset Sum CNF NPC NP Hard WWindex 44