200 likes | 366 Views
NP-completeness. Sipser 7.4 (pages 271 – 283). The classes P and NP. NP =∪ k NTIME(n k ) . P =∪ k TIME(n k ). A famous NP problem. CNF satisfiability ( CNFSAT ): Given a boolean formula B in conjunctive normal for (CNF), is there a truth assignment that satisfies B ? .
E N D
NP-completeness Sipser 7.4 (pages 271 – 283)
The classes P and NP NP =∪kNTIME(nk) P =∪kTIME(nk)
A famous NP problem • CNF satisfiability (CNFSAT): Given a boolean formula B in conjunctive normal for (CNF), is there a truth assignment that satisfies B?
A graph theory NP problem • CLIQUE: Given a graph G = (V, E) and an integer k, does G contain Ck as a subgraph? • Is <G,3>∈ CLIQUE?
A graph theory NP problem • CLIQUE: Given a graph G = (V, E) and an integer k, does G contain Ck as a subgraph? • Is <G,3>∈ CLIQUE?
A graph theory NP problem • CLIQUE: Given a graph G = (V, E) and an integer k, does G contain Ck as a subgraph? • Is <G,4>∈ CLIQUE?
A graph theory NP problem • CLIQUE: Given a graph G = (V, E) and an integer k, does G contain Ck as a subgraph? • Is <G,4>∈ CLIQUE?
A graph theory NP problem • CLIQUE: Given a graph G = (V, E) and an integer k, does G contain Ck as a subgraph? • Is <G,5>∈ CLIQUE?
CLIQUE∈ NP • Verifier: V = “On input <<G,k>,c>: • Test whether c is a set of k nodes of G • Test whether G contains all edges connecting nodes in c • If both pass, accept; otherwise, reject.” • NTM: N = “On input <G,k>: • Nondeterministically select a subset c of k nodes of G • Test whether G contains all edges connecting nodes in c • If yes, accept; otherwise, reject.”
Which problem is harder? NP P CNF CLIQUE
Recall… • Definition 5.17: A function f:Σ*→Σ* is a computable function if ∃ some Turing machine M, on every input w, halts with just f(w) on its tape.
Polynomial time computable functions • Definition 7.28: A function f:Σ*→Σ* is a polynomial time computable function if ∃ some polynomial time Turing machine M, on every input w, halts with just f(w) on its tape.
Recall… • Definition 5.20: Language A is mapping reducible to language B, written A ≤m B, if there is a computable function f:Σ* → Σ*, where for every w, w ∈ A ⇔ f(w) ∈ B A B f f
Polynomial time mapping reducibility • Definition 7.29: Language A is polynomial time mapping reducible to language B, written A ≤p B, if there is a polynomial time computable function f:Σ* → Σ*, where for every w, w ∈ A ⇔ f(w) ∈ B A B f f
Intuitively, A is no harder than B • Theorem 7.31: If A ≤p B and B∈ P, then A∈ P. • Proof: Algorithm for deciding A Reduction algorithm F Algorithm for deciding B “yes” w f(w) “no”
CNF ≤p CLIQUE • Given a boolean formula B in CNF, we show how to construct a graph G and an integer k such that G has a clique of size k⇔ B is satisfiable. • Given the construction would yield
NP’s hardest problems • Definition 7.34: A language B is NP-complete if • B∈NP • A≤pB, for all A∈NP NP A2 A1 B (NP-complete) A3
P=NP? • Theorem 7.35: If B is NP-complete and B∈ P, then P = NP. NP P=NP A2 A1 P B (NP-complete) A3
Cook-Levin Theorem • SAT is NP-complete. (If A∈NP, then A≤pSAT.) NP A2 A1 SAT A3
But that’s not the only one! • CLIQUE is NP-complete (why?) NP A2 A1 CLIQUE SAT A3