1 / 28

NP Completeness

NP Completeness. Piyush Kumar. Today. Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete Problems Average Case / Heuristics / Approx. Alg. Convex Hulls and Sorting. What are convex hulls?

byrd
Télécharger la présentation

NP Completeness

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NP Completeness Piyush Kumar

  2. Today • Reductions • Proving Lower Bounds revisited • Decision and Optimization Problems • SAT and 3-SAT • P Vs NP • Dealing with NP-Complete Problems • Average Case / Heuristics / Approx. Alg.

  3. Convex Hulls and Sorting • What are convex hulls? • Given a program for computing convex hulls, can we use it to sort ?

  4. Reduction from Sorting to CH • Given n real values xi , generate n 2D points on a parabola, e.g. (xi,xi2). • Compute the (ordered) convex hull of the points. • The order of the convex hull points is the numerical order of the xi.

  5. Reduction from Sorting to CH • Does this imply a lower bound on computation of convex hulls? • (nlgn) ? • Sorting p CH • p : Can also be read as • “No harder to solve than”

  6. Polynomial time reductions • If P is polynomial-time reducible to Q, we will use the notation P p Q • P p Q and Q p R • Implies P p R

  7. Review : P, NP • Set of problems : P, NP • P = Can be solved in polynomial time • NP = You can verify the solution in polynomial time • PNP ? • P=NP ? (Probably not?)

  8. definitions • NP-Hard : For all R in NP, R p T • Implies T is NP-Hard • NP-Complete • T is both in NP and NP-Hard

  9. Definitions : Revisited • NP-Hard • If you can solve it, you can solve everything in NP • NP-Complete • NP-Hard and in NP • NP : Non-Deterministic Polynomial time. ( Guess and verify )

  10. Assuming P  NP Halting Problem NP-hard NP-complete Hamilton cycle, Independent Set, Vertex Cover,Graph 3-coloring,Satisfiability… NP Factoring … P Primality testingSemidefinite programming…

  11. Decision Vs Optimization • Decision Problem: computational problem with intended output of “yes” or “no”, 1 or 0 • Optimization Problem: computational problem where we try to maximize or minimize some value • Introduce parameter k and ask if the optimal value for the problem is a most or at least k. Turn optimization into decision

  12. Decision Vs Optimization • Optimization Problem: TSP • Decision problem • Is their a tour of length < k? • Simplification: Worry only about decision problems. The class P, NP, NPC, NPH all constitute of only decision problems.

  13. Cook’s Theorem • Theorem (Cook 1970) SAT is NP-Complete. • CNF-SAT is also NP-Complete. • Corollary3-SAT is NP-Complete. • Proof of Corollary • How do we prove it? • Recall the defn of NP-Complete

  14. Proving NP Completeness • What steps do we have to take to prove a problem Pis NP-Complete? • A problem P is NP-complete if 1. it is in NP 2.  B  NP, B p P (it is NP-Hard) • Idea for condition 2 : • Use a known NP-Complete problem Q. • Show Q p P. • By transitivity of p, we are done •  B  NP, B p Q p P • Hence :  B  NP, B p P

  15. Reduction revisited: (Q  P) x Input for Q R(x) Input for P Output for P yes/no Output for Q Algorithm for P Reduction R Algorithm for solving Q

  16. 3-SAT is NP-Complete • 3-SAT is in NP (Trivial) • We will pick Q to be CNF-SAT • To show : CNF-SAT P3-SAT. • Let ∏ be the given CNF formula. We want to transform ∏ to an instance of 3-CNF. • Idea: Transform each clause of ∏ so that it is 3-CNF

  17. CNF-SAT to 3-SAT • If less than 3 literals, repeat them. • Replace (a1  a2) by (a1 ∨ a2 ∨ a2) • If 3 literals, leave it as it is.

  18. CNF-SAT to 3-SAT • 4 literals : Replace(a1  a2  a3  a4) by (a1  a2  z)  (z  a3  a4) • In general, replace (a1  a2    ak) by (a1  a2  z1)  (z1 a3  z2)  (z2 a4  z3)    (zk-3 ak-1  ak) • z1 ,  , zk-3:new variables • This is analogous to the 4 literal case, just applied multiple times with more variables.

  19. 3-SAT is NP-Complete • 3-SAT is in NP • CNF-SAT P3-SAT • Since we can transform an input to the CNF-SAT problem in polynomial time to the 3-SAT problem solver and get a solution to CNF-SAT. Hence CNF-SAT is ‘no harder to solve than’ 3-SAT.

  20. Other NP-Complete Problems • Hamiltonian Cycle • Of size k? • Vertex cover : A vertex cover of G is a set C  V such that all edges of E have at least one endpoint in C. • Clique : Find in a given graph G, if there is a size k clique?

  21. Other NP-Complete Problems • Set Cover : Given n sets, are there k sets out of these whose union is the same as the union of n sets? • Subset Sum : Given a set of integers, and another integer k; Is there a subset of them that sum upto k?

  22. Toy Problem • TSP is NP-Complete • Decision Version: Does  a TSP with cost < k ? • Is TSP in NP? • What problem should we pick to prove this?

  23. Approximation Algorithms • For some NP-Complete problems, there are polynomial time algorithms that give near optimal solutions.

  24. Vertex cover

  25. Vertex cover • VC is NP-Complete • (can be reduced from 3-SAT)

  26. Approximation Alg for VC • S   • E  E[G] • while E • let (u,v) be am arbitrary edge in E • S  S  {u,v} • remove from E every edge incident on either u or v • return S

  27. example

  28. 2-Factor : Proof • The vertex cover output by the approximation algorithm is no more than twice the size of the optimal vertex cover. • Why?

More Related