Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— 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 x i, generate n 2D points on a parabola, e.g. (x i,x i 2 ). –Compute the (ordered) convex hull of the points. –The order of the convex hull points is the numerical order of the x i.

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 P NP NP- complete NP-hard Primality testing Semidefinite programming … Hamilton cycle, Independent Set, Vertex Cover, Graph 3-coloring, Satisfiability … Factoring … Halting Problem Assuming P  NP

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. Corollary 3-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 P is 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 Algorithm for P Reduction R R(x) Input for P Output for P yes/no Output for Q x Input for Q Reduction revisited: ( Q  P) 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  P 3-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 (a 1  a 2 ) by (a 1 ∨ a 2 ∨ a 2 ) If 3 literals, leave it as it is.

18 CNF-SAT to 3-SAT 4 literals : Replace (a 1  a 2  a 3  a 4 ) by (a 1  a 2  z)  (  z  a 3  a 4 ) In general, replace (a 1  a 2    a k ) by (a 1  a 2  z 1 )  (  z 1  a 3  z 2 )  (  z 2  a 4  z 3 )    (  z k-3  a k-1  a k ) – z 1, , z k-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  P 3-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 VC is NP-Complete –(can be reduced from 3-SAT)

26 Approximation Alg for VC 1.S   2.E  E[G] 3.while E  4.let (u,v) be am arbitrary edge in E 5.S  S  {u,v} 6.remove from E every edge incident on either u or v 7.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?


Download ppt "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."

Similar presentations


Ads by Google