1 / 50

NP-Completeness

NP-Completeness. NP-Completeness. Coming up Intractability P,NP,NP-Complete,P<>NP NP-Completeness Proofs Informal Illustration Key Concepts Formal definitions: P,NP,NP-Complete First NP-Complete Problem NP-Completeness proofs and Examples (Chap 34).

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

  2. NP-Completeness Coming up • Intractability • P,NP,NP-Complete,P<>NP • NP-Completeness Proofs • Informal Illustration • Key Concepts • Formal definitions: P,NP,NP-Complete • First NP-Complete Problem • NP-Completeness proofs and Examples (Chap 34)

  3. Polynomial-time Alg., Tractable Halting Problem: The problem of determining in advance whether a particular program or algorithm will terminate (will not run forever). • Polynomial-time algorithms: • On inputs of size n, the worst-case running time is O(nk) for some constant k. • There are some problems that cannot be solved in polynomial-time. • Eg. Turing’s famous Halting Problem cannot be solved by any computer, no matter how much time is given: Example_A(…) For i = 1 to n .. while (i < j*k) if (j is ..) return true … return false • Polynomial-time algorithms are “Tractable”, “Easy”, eg. O(n), O(1), O(n3), O(n lg n)vs Superpolynomial time: “Intractable”, “Hard”, eg. O(2n),O(nn),O(n!)

  4. P, NP, NPC 3 classes of problems: Class P: Solvable in Polynomial-time ( O(nk) ) for some constant k. Class NP: “Verifiable” in polynomial-time Given a “certificate” of a solution, we can verify that the certificate is correct in O(nk) time. Hamiltonian-cycle problem: Find a simple cycle that contains each vertex of a given directed graph. A certificate would be a path of n vertices. It is easy to check that this certificate is correct, in O(nk) time. A problem solvable in polynomial-time must be verifiable in polynomial time. ie. P  NP. Class NPC (The class of NP-complete problems):These problems are in NP and are as “hard” as any problem in NP, eg. Hamiltonian-cycle

  5. P=NP Class P Solvable in Polynomial-time Class NP Verifiable in polynomial-time We are interested in whether P = NP ? --- (*) If we can find a polynomial-verifiable problem that is proved not polynomial-time solvable, then we can disprove (*). NP P NP We know P  NP P NP P=NP P, NP, NPC But so far we cannot find any. Class NPC (The class of NP-complete problems): These problems are hardest ones in NP (no other NP problem is harder then these problems) There are many problems in NPC. So it is important to know whether these problems are tractable. Moreover, if a polynomial time solution can be found for any one of them, then all NP problems are polynomial-time solvable (hence * can be proved). However, so far no such solution is discovered. So, many believe that P  NP (NP-complete problems are intractable.)

  6. P, NP, NPC Class P: Solvable in Polynomial-time Class NP: “Verifiable” in polynomial-time Class NPC (The class of NP-complete problems):These problems are in NP and are as “hard” as any problem in NP. … So, many people believe that P  NP (NP-complete problems are intractable.) • Why study NP-completeness? • When we can establish a problem as NP-complete, we provide good evidence for its intractability. • Then we better spend the time to develop an approximation algorithm, or solve a tractable special case. • Interestingly, several NP-complete problems are similar to some tractable ones.

  7. AND AND OR OR OR OR OR OR x1 x2 x1 x3 x2 x3 x1 x2 x4 x1 x3 x4 x2 x3 x1 More examples 1. Shortest vs longest simple paths Single-source shortest paths can be found in O(VE) time. But finding longest simple path between 2 vertices is NP-complete 2. Euler tour vs hamiltonian cycle Euler tour: traverses each edge of a connected, directed graph exactly once (O(E)) Hamiltonian cycle: a simple cycle that contains each vertex of a given graph: NP-complete 3. 2-CNF satisfiability vs 3-CNF satisfiability (k-conjunctive normal form) A boolean formula is satisfiable if there is some assignment of the 0/1 variable values that makes the formula results in “1”. Example: 2-CNF : P 3-CNF : NPC 2 elements 3 elements

  8. By the way, why do we study polynomial time algorithms? “Polynomial time” Algorithms

  9. ProgramA(…) • For i = 1 to n • while (i < j*k) • For i = 1 to n • For i = 1 to n • .. • while (i < j*k) • For i = 1 to n • .. • while (i < j*k) • if (j is ..) • For i = 1 to n • while (i < j*k) • For i = 1 to n • .. • while (i < j*k) • if (j is ..) • .. • while (i < j*k) • if (j is ..) • return true • if (j is ..) • … • return false • ProgramA(…) • For i = 1 to n • .. • while (i < j*k) • For i = 1 to n • .. • while (i < j*k) • if (j is ..) • return true • if (j is ..) • return true • … • return false O(n2) • ProgramA(…) • For i = 1 to n • .. • while (i < j*k) • For i = 1 to n • if (j is ..) • return true • … • return false • ProgramA(…) • For i = 1 to n • .. • while (i < j*k) • For i = 1 to n • .. • while (i < j*k) • return true • if (j is ..) • return true • … • return false ProgramA(…) For i = 1 to n .. while (i < j*k) while (i < j*k) while (i < j*k) while (i < j*k) return false O(n lg n) Why study polynomial-time algorithms From experience, once a polynomial-time algorithm for a problem is discovered (eg. (n100)), more efficient algorithm often follow. Polynomials are closed under , , .. Example: if an algorithm only include polynomial-time execution of basic instructions and a constant number of calls to polynomial-time subroutines, the running time of the composite algorithm is polynomial. A problem that can be solved in polynomial time in one model (one computer architecture) can be solved in polynomial time in another.

  10. How do we know a problem is NP-complete? How to prove NP-Completeness We’ll have an informal illustration first: • The concept of “Polynomial-time reducibility” - For comparing the hardness of problems. • How to prove a problem to be NP-complete (the first NP-complete problem). • Based on some already known NP-complete problems, how to prove some other problems are NP-complete.

  11. Instance of P1 Solve for P1 Map instance of P1 to Instance of P2 Instance of P2 Solve for P2 Answer of instance of P2 Answer of instance of P1 Note that, if we can solve a problem P1 by mainly solving P2, this does not imply P1 is harder than P2. Indeed, we can say the P2 algorithm is a powerful engine that can solve for P1, although maybe P1 is only a piece of cake. How to prove NP-CompletenessInformal Illustration • We map an input problem instance of P1 to P2 , Given 2 problems: P1 and P2, Polynomial-time Reduction • Then solve for P2, • And then obtain the answer for P1 directly from the answer from P2. If the mapping (reduction) is in polynomial time, then we say: P1 is polynomial-time reducible to P2. We can use P2 as a subroutine of P1, with only a polynomial amount of overhead.

  12. Instance of a problem in NP Solve for the problem in NP Polynomial-time Reduction Instance of a subroutine problem An problem used as subroutine Note that, if we can solve a problem P1 by mainly solving P2, this does not imply P1 is harder than P2. Indeed, we can say the P2 algorithm is a powerful engine that can solve for P1, although maybe P1 is only a piece of cake. Answer of the subroutine problem Answer of the problem in NP How to prove NP-CompletenessInformal Illustration NP-complete problems are the hardest ones of all NP problems. One method to prove that a particular problem is NP-complete: • Given a particular problem that can essentially be used as a subroutine for all problems in NP, with only a polynomial amount of overhead. • (Polynomial-time Reduction) • => This problem is harder than or at least equally hard as all NP problems. “This problem is ” • => If this problem is also in NP, then, this problem is NP-complete.

  13. Solve for P1(NP-complete) Polynomial-time Reduction Instance of P1(NP-complete) Instance of P2(in NP) P2 Answer of P2(in NP) Answer of P1(NP-complete) Note that, if we can solve a problem P1 by mainly solving P2, this does not imply P1 is harder than P2. Indeed, we can say the P2 algorithm is a powerful engine that can solve for P1, although maybe P1 is only a piece of cake. How to prove NP-CompletenessInformal Illustration NP-complete problems are the hardest ones of all NP problems. After we prove that a particular problem is NP-complete, Given this NP-complete problem, eg., P1, we can prove some others are NP-complete: • To prove the NP-completeness for P2: • If we can show that P2 can essentially be used as a subroutine for P1, with only a polynomial amount of overhead. (Polynomial-time Reduction) • => P2 is harder than or at least equally hard as P1. • => P2 is harder than or at least equally hard as all NP problems. “P2 is NP-hard” • => If P2 is also in NP, then, P2 is NP-complete.

  14. H Problem: T Problem: 1 1 1 2 2 2 1 2 1 1 How to prove NP-CompletenessInformal Illustration Example: Assume we already know that the Hamiltonian Cycle Problem is NP-complete: Hamiltonian Cycle Problem:whether there is a simple cycle containing each vertex of a given undirected graph (simple cycle => each vertex visited once) Traveling Salesman Problem:whether there is a simple cycle containing each vertexof a given complete graph with edge costs and has total cost  K? We can reduce the H problem to the T problem as shown. Then we solve the T problem with k=number of edges in the H problem. Then we use the result of the T problem to answer the H problem. Since we already know that the H problem is NP-Complete. We can conclude that the T problem is.

  15. Let’s go to a formal study of NP-Completeness proofs. How to prove NP-Completeness To prove a problem is NP-complete, we need to show “how hard it is”. 3 Key concepts for the proofs. A. Decision problems vs. optimization problems B. Reductions C. A first NP-complete problem

  16. How to prove NP-Completeness3 Key concepts for the proofs A. Decision problems vs. optimization problems Likewise, “a decision problem is hard” implies “the related opt. problem is hard”. Hence the theory of NP-completeness often has implications for optimization problems as well. NP-Completeness applies directly to decision problems, not optimization ones. But optimization problems usually have a related decision problem. Optimization problems each feasible solution has a value to be optimized eg. SHORTEST-PATH PATH(G,u,v,k) 1. run SHORTEST-PATH(G,u) 2. compare result of SHORTEST-PATHwith k if is easy, then is easy as well. Decision problemsanswer is simply yes or no. eg. PATH(G,u,v,k) : whether a path exists between 2 given vertices having at most k edges.

  17. An algorithm to decide A Polynomial-timereduction algorithm  An algorithm to decide B no yes yes no How to prove NP-Completeness3 Key concepts for the proofs • B. Reductions • We have 2 decision problems: A and B. • We have a a polynomial-time reduction algorithm that transforms any instance  of A into some instance  of B such that the answers (yes/no) to  and  are the same. • “Problem A is hard” => “” • “A is NP-Complete” => “”if B is also in NP. • The reduction method for NP-Completeness proofs: • Given an NP-Complete problem A, we can prove problem B as NP-Complete by • 1. Prove that B is in NP. • 2. Then, find a polynomial-time reduction algorithm from A to B.

  18. The notation of polynomial-time reducibility: p Eg. A p B  An algorithm to decide A Polynomial-timereduction algorithm  An algorithm to decide B no yes yes no How to prove NP-Completeness3 Key concepts for the proofs C. A first NP-Complete Problem • The reduction method for NP-Completeness proofs: • Given an NP-Complete problem A, we can prove problem B as NP-Complete by • 1. Prove that B is in NP. • 2. Then, find a polynomial-time reduction algorithm from A to B. • We need a first NP-Complete problem in order to prove a different problem NP-Complete. • Our first NP-Complete problem: • Circuit-Satisfiability Problem

  19. In the followings, we will (1) Formalize the definitions of P, NP, and NP-Complete (2) Illustrate NP-Complete proofs. (3) Introduce some NP-Complete problems.

  20. u  k Edges? v Encoding, Polynomial-time solvable The PATH problem : Encoding of a set A of abstract objects is a mapping from A to the set of binary strings. Eg. We can map {0,1,2,3,4,..15} to {0000,0001,0010,..1111} Eg., we can encode each one such instance asG,u,v,k = “00101100…0101” Polygons, graphs, programs -- All can be encoded as binary strings. • A PATH algorithm is to map every such G,u,v,k to {1,0}, ie. {yes,no} • For some binary string that does not represent any relevant problem instance, the PATH algorithm maps it to “0” or “no”. • A problem is if there is an algorithm that solves it in time O(nk), for some constant k, where n = the size of the encoded binary string representation of each problem instance.

  21. Accepted vs Decided, Class P • Decision problems : map the problem instances to {0,1} (ie. True/False). • Given an algorithm A and an input instance x, we can say that Axif A(x) returns 1. Ax if A(x) returns 0. • Consider all inputs x1,x2,.. xn that results “1”.Suppose L is a set such that L = {x1,x2,.. xn}. Then L is accepted by A if every element xi in L is accepted by A. (But A may loop forever for an element x L without rejecting it.) L is decided by A if every element xi in L is accepted by A and every element not in L is rejected by A. For Turing’s Halting Problem, there exists an accepting algorithm, but no decision algorithm exists. • The complexity class P : A problem belongs to P if and only if it has a polynomial time decision algorithm.

  22. Verification Algorithm, CLASS NP • Consider the decision problem PATH, for a given problem instance x = <G,u,v,k>, we need to determine whether it is true or false. If we are also given a path from u to v (a certificate) that helps to prove for k, then the verification of x is easy. • A A is a 2-input algorithm that outputs whether a given certificate verifies a given problem instance x: A(x,certificate) = 1, or A(x,certificate) = 0 Eg. bool Verify_Path(<G,u,v,k>,a_path) • The complexity class NP: A problem belongs to NP if and only if it has a polynomial-time verification algorithm, A(x, certificate), such that |certificate| = O(|xc|).

  23. CIRCUIT-SAT SAT 3-CNF-SAT CLIQUE SUBSET-SUM VERTEX-COVER HAM-COVER TSP NP-Completeness and the Proofs • A problem, A, is NP-Complete: • (1) A  NP, and • (2) LpA, for every LNP. [NP-hard] • We also say that A belongs to NPC • Some famous NP-Complete problems: CIRCUIT-SAT, SAT, 3-CNF-SAT, CLIQUE, .. • Alternatively, we can conclude that a problem, A, is NP-Complete if: • (1) , and • (2’) , for some LNPC [=>] • CIRCUIT-SAT is proved using (1) and (2). • SAT, 3-CNF-SAT, CLIQUE.. are proved using (1) and (2’).

  24. x1 x2 A x y xy x x x z 0 0 0 1 1 0 1 1 0 0 0 1 z z Output y y x x x3 0 1 1 0 x y xy 0 0 0 1 1 0 1 1 0 1 1 1 CIRCUIT-SATFirst NP-complete Problem Elements: Circuit-Satisfiability Problem (CIRCUIT-SAT) Given a boolean combinational circuit composed of AND, OR, and NOT gates, is it satisfiable? If we assign 1, 1, 0 to x1, x2, and x3, the output will be 1. => The circuit is satisfied by some => It is satisfiable. However, if A is replaced by an AND gate, we can’t find any “assignment” of (x1, x2, x3) to make it satisfied. => It is not satisfiable.

  25. x1 x2 Output x3 CIRCUIT-SATFirst NP-complete Problem • The of a boolean combinational circuit = no. of boolean combinational elements + no. of wires • To such a circuit into a binary string:we can devise a graph like encoding • If there are k inputs, then there are 2k possible assignments. By simply checking all these assignments => O(). • By proving that it is NP-Complete, we can claim that “there is strong evidence that no polynomial-time algorithm exists” for CIRCUIT-SAT.

  26. x1 x2 Output x3 CIRCUIT-SAT First NP-complete ProblemPart A of the proof: CIRCUIT-SATNP CIRCUIT-SAT is NP-Complete 2 parts of the proof: A. CIRCUIT-SATNP B. CIRCUIT-SAT is NP-hard Part A of the proof: CIRCUIT-SATNP Consider an algorithm: bool Verify_Circuit_Sat( Input_Circuit, Certificate/*an assignment to the wires, eg. x1, x2, x3*/) This algorithm computes values of the logic gates based on the assignment. If circuit output is 1 (0), then the algorithm returns 1 (0). This is a algorithm for CIRCUIT-SAT Since we can find such an algorithm for CIRCUIT-SAT, we say that CIRCUIT-SAT can be verified in polynomial time, and .

  27. One Configurationof Computer MemoryConfig1 Transformed by the computer by running first statement Another Configurationof Computer Memory Config2 Run second statement Another Configurationof Computer Memory Config3 Configi a boolean combinational circuit Configi+1 CIRCUIT-SAT First NP-complete ProblemPart B of the proof: CIRCUIT-SAT is NP-hard • Part B of the proof: CIRCUIT-SAT is NP-hard • Show that every NP problem is polynomial-time reducible to CIRCUIT-SAT. • When a program is being executed, the computer changes the content of the computer memory by running program statements. • The computer hardware can be constructed as a boolean combinational circuit. • Hence correspondingly we can construct a boolean combinational circuit that maps Configi to Configi+1

  28. Certificate Encoded_Input Program code Program code Program code Variables, etc. Variables, etc. Variables, etc. Config1 Config2 Program code Variables, etc. ConfigT(n) 0/1 Output CIRCUIT-SAT First NP-complete ProblemPart B of the proof: Every NP problem is polynomial-time reducible to CIRCUIT-SAT • Part B of the proof: CIRCUIT-SAT is NP-hard • If the program is a 2-input verification program, then, Config1 is: • Suppose T(n) = worst case running time. Then the solution can be obtained by evaluating Config1, Config2, Config3, .. ConfigT(n). • If the exact execution time is 452, then, Config452 =Config453 =Config454 = … = ConfigT(n) . • In the “final” configuration, there is a memory location storing the result (1/0).

  29. Certificate Encoded_Input Execution of A: ? Program code of A Variables, etc. Config1 Config1 Circuit1 Circuit1 Circuit1 Config2 Config2 Circuit2 Circuit2 Circuit2 CircuitT(n) CircuitT(n) CircuitT(n) 0/1 Encoded Input + “bool A(Encoded_input,Certificate)” A boolean combinational circuit C such that “” CIRCUIT-SAT First NP-complete ProblemPart B of the proof: Every NP problem is polynomial-time reducible to CIRCUIT-SAT Part B of the proof: CIRCUIT-SAT is NP-hard Let L be any problem in NP, we need to describe a polynomial-time algorithm Fto reduce every input instance of L to a circuit C such that result of L = result of C. For any NP problem, it must have a 2-input polynomial-time verification algorithmA. Suppose T(n) = worst case running time of A. polynomial_time_F

  30. CIRCUIT-SAT First NP-complete ProblemPart B of the proof: Every NP problem is polynomial-time reducible to CIRCUIT-SAT Part B of the proof: CIRCUIT-SAT is NP-hard For each NP problem, we design F in this way: Bool_Combinational_Circuit polynomial_time_F(encoded_input_of_an_NP_instance) 1 n = size of encoded_input_of_an_NP_problem_instance 2 Compute T(n) of alg. A using n, where A is the verification program of the NP_problem 3 Based on a computer capable of running A, create T(n) copies of the corresponding boolean combinational circuits, such that circuiti will map configi to configi+1. 4 Create the whole_circuit by wiring the outputs of circuit1 to circuit2, and outputs of circuit2 to circuit3, etc. 5 Wire the “Program Code” pins of circuit1 according to A’s code. 6 Wire the “Encoded_input” pins of circuit1 according to encoded_input_of_an_NP_problem_instance. 7 Ignore (ground) all outputs of whole_circuit, except the 0/1 output of circuitT(n). 8 Return whole_circuit. Polynomial time of n

  31. CIRCUIT-SAT SAT Show 3-CNF-SAT CLIQUE SUBSET-SUM VERTEX-COVER HAM-COVER TSP NP-Completeness and the Proofs After some problems have been proved NP-Complete, we can prove for other problems more easily: 1. Prove A NP 2. Select a known NP-complete problem K 3. Describe an algorithm that maps every instance of A to an instance of K 4. Prove that the results for both instances (yes or no) in (3) are the same 5. Prove that the algorithm in (3) runs in polynomial time [ Polynomial-time Reducibility ] A common approach to prove that a problem, A, is NP-complete:

  32. PTTFF QTFTF P  QTFFF P QTTTF  PFFTT P  QTFTT P QTFFT The SAT Problem Formula-Satisfiability Problem (SAT) Boolean functions: Given a boolean formula of n boolean variables, m boolean connectives, and required parenthesis, is it satisfiable? Example: ((x1 x2) (( x1 x3)  x4))  x2 It is satisfiable by the assignment: <x1=0, x2=0, x3=1, x4=1>: ((0  0)  (( 0  1)  1))  0 = (1 (1  1))  1 = =

  33. The SAT ProblemPart A of the proof: SATNP • SAT is NP-Complete • 2 parts of the proof: • A. SATNP • B. SAT is NP-hard Example: ((x1 x2) (( x1 x3)  x4))  x2 Part A of the proof: SATNP Consider an algorithm: bool Verify_Sat( Input_Boolean_Formula, Certificate/*an assignment to the variables, eg. x1, x2, x3*/) This algorithm replaces each variable in the formula with its corresponding values and evaluate the expression. This is a 2-input, polynomial-time verification algorithm for SAT. Since we can find such an algorithm for SAT, we say that SAT can be verified in polynomial time, and .

  34. s z t x y t x z y The SAT Problem Part B of the proof: SAT is NP-hard Part B of the proof: SAT is NP-hard Show that CIRCUIT-SAT pSAT ie. Any instance of circuit satisfiability can be reduced in polynomial time to an instance of formula satisfiability. Reduction by simple translation, Sometimes it is easy: But not always: z = (t  (xy))  ((xy)) z = (s t)  ((x y)) Original circuit: 4 gates + 8 wires Resultant formula: 4 variables + 4 operators Original circuit: 4 gates + 8 wires Resultant formula: variables + operators Reason of complexity: Fan-out > 1 Indeed, such a reduction is not in polynomial time.

  35. x1 x5 x2 x8 x6 x10 x9 x3 x7 x4 A CIRCUIT-SAT instance with m gates and n wires Polynomial timereduction A SAT instance (size = polynomial in the size of CIRCUIT-SAT) The SAT Problem Part B of the proof: CIRCUIT-SAT pSAT Part B of the proof: SAT is NP-hard Since we need to show that “Any instance of circuit satisfiability can be reduced in to an instance of formula satisfiability.” We design a more clever method: The formula: x10  (x4   x3)  (x5  (x1  x2))  (x6  x4)  (x7  (x1  x2  x4))  (x8  (x5  x6))  (x9  (x6  x7))  (x10  (x7  x8  x9)) Step 1. For each gate, formulate it with the operation on its incident wires. eg. x10  (x7  x8  x9) Step 2. “AND” all the formulas of the gates.

  36. One or more literals “” together Conjunctive normal form (CNF) (x?x?  …)(x?x?  …)(x?x?  …).. x? or x? x? or x? x? or x? x? or x? x? or x? x? or x? 3-CNF (x?x?)(x?x?)(x?x?).. 2-CNF x? or x? x? or x? x? or x? x? or x? x? or x? x? or x? 3-CNF (x?x?x?)(x???x?)(x?x?x?).. x? or x? x? or x? x? or x? x? or x? x? or x? x? or x? x? or x? x? or x? x? or x? The 3-CNF-SAT Problem 3CNF-Satisfiability Problem (3-CNF-SAT) A literal: eg. x1 or x1 (an occurrence of a variable or its negation) Given a boolean formula in 3-CNF, is it satisfiable? Eg. (x1x2)(x3x2x4)x1 Eg. (x1x2)(x3x4)(x1x3) Eg. ( x1x1x2)(x3x2x4)(x1x3x4)

  37. The 3-CNF-SAT ProblemPart A of the proof: 3-CNF-SATNP • 3-CNF-SAT is NP-complete • 2 parts of the proof: • A. 3-CNF-SATNP • B. 3-CNF-SAT is NP-hard A 3-CNF Example: (x1x1x2)(x3x2x4)(x1x3x4) Part A of the proof: 3-CNF-SATNP Consider an algorithm: bool Verify_3_CNF_SAT( Input_Boolean_Formula, Certificate /*an assignment to the variables*/ ) This algorithm replaces each variable in the formula with its corresponding values and evaluate the expression. This is a 2-input, polynomial-time verification algorithm for 3-CNF-SAT. Since we can find such an algorithm for 3-CNF-SAT, we say that 3-CNF-SAT can be verified in polynomial time, and 3-CNF-SATNP.

  38. y1  y2 x2  y3 y4  y5 x1 x2  x4 y6   x1 x3 The 3-CNF-SAT Problem Part B of the proof: 3-CNF-SAT is NP-hard Part B of the proof: 3-CNF-SAT is NP-hard Show that SAT p3-CNF-SAT ie. Any instance of formula satisfiability can be reduced in polynomial time to an instance of 3-CNF formula satisfiability. A formula Example: ((x1  x2)   ((x1 x3 ) x4 ))  x2 A 3-CNF Example: (x1x1x2)(x3x2x4)(x1x3x4) The Reduction : Step 1: Create a binary “parse” tree for the formula. Step 2: Rewrite it in the form: y1  (y1  (y2  x2))  (y2  (y3  y4))  (y3  (x1 x2 ))  (y4   y5)  (y5  (y6  x4))  (y6  ( x1  x3))

  39. Part B of the proof: 3-CNF-SAT is NP-hard Show that SAT p3-CNF-SAT ie. Any instance of formula satisfiability can be reduced in polynomial time to an instance of 3-CNF formula satisfiability. A formula: eg. ((x1  x2)   ((x1 x3 ) x4 ))  x2 3-CNF eg. (x1x1x2)(x3x2x4)(x1x3x4)… Eg. (y1y2x2) y1 y2 x2 (y1 (y2  x2)) 1 1 1 0 1 1 0 1 1 0 1 0 1 0 0 0 0 1 1 1 0 1 0 0 0 0 1 1 0 0 0 1 (y1y2x2) (y1y2x2) (y1y2x2) The Reduction : Step 3: Change each sub-clause of the following to an OR of literals: y1  (y1  (y2  x2))  (y2  (y3  y4))  (y3  (x1  x2 ))  (y4   y5)  (y5  (y6  x4))  (y6  ( x1  x3)) We can rewrite (y1 (y2  x2)) as:  [(y1y2x2) (y1y2x2) (y1y2x2) (y1y2x2) ] By DeMorgan’s laws: => (y1y2x2)  (y1y2x2) (y1y2x2) (y1y2x2) => (y1 y2 x2) (y1  y2 x2) (y1 y2 x2) (y1 y2 x2)

  40. Part B of the proof: 3-CNF-SAT is NP-hard Show that SAT p3-CNF-SAT ie. Any instance of formula satisfiability can be reduced in polynomial time to an instance of 3-CNF formula satisfiability. A formula: eg. ((x1  x2)   ((x1 x3 ) x4 ))  x2 3-CNF eg. (x1x1x2)(x3x2x4)(x1x3x4)… Polynomial timereduction A SAT instance A 3-CNF-SAT instance such that result of SAT instance = result of 3-CNF-SAT instance The Reduction : y1  (y1  (y2  x2))  (y2  (y3  y4))  (y3  (x1  x2 ))  (y4   y5)  (y5  (y6  x4))  (y6  ( x1  x3)) Step 3: Change each sub-clause to an OR of literals: (Con’td) We can rewrite (y1 (y2  x2)) as: (y1 y2 x2) (y1  y2 x2) (y1 y2 x2) (y1 y2 x2) Apply the same method to other sub-clauses: y1  (y1y2x2)(y1y2x2)(y1y2x2)(y1y2x2)  (y2  (y3  y4))  (y3  (x1  x2 ))  (y4   y5)  (y5  (y6  x4))  (y6  ( x1  x3))

  41. CIRCUIT-SAT SAT 3-CNF-SAT CLIQUE SUBSET-SUM VERTEX-COVER HAM-CYCLE TSP NP-Completeness and the Proofs Recall:

  42. u u u v v v z w y y y x x x The Clique Problem A Clique in an undirected graph G=(V,E) is a complete subgraph of G. A complete graph Clique Problem Optimization problem: Find a clique of maximum size in a graph. Decision problem: Whether a clique of a given size k exists in the graph.

  43. u u v v z w y y x x The CLIQUE ProblemPart A of the proof: CLIQUENP • CLIQUE is NP-complete • 2 parts of the proof: • A. CLIQUE NP • B. CLIQUE is NP-hard Part A of the proof: CLIQUE NP Consider an algorithm: bool Verify_CLIQUE( Input_Graph, Certificate /*a set of vertices in the input graph*/ ) This algorithm checks whether the set of vertices in the certificate are linked up as a complete graph. This is a 2-input, polynomial-time verification algorithm for CLIQUE. Since we can find such an algorithm for CLIQUE, we say that CLIQUE can be verified in polynomial time, and CLIQUENP.

  44. x1 x2 x3 x1 x1 x2 x2 Polynomial time reduction A 3-CNF-SAT instance x3 x3 A CLIQUE instance s.t. result of 3-CNF-SAT instance = result of CLIQUE instance The CLIQUE Problem Part B of the proof: CLIQUE is NP-hard Part B of the proof: CLIQUE is NP-hard Show that 3-CNF-SAT pCLIQUE ie.Any instance of 3-CNF formula satisfiability can be reduced in polynomial time to an instance of CLIQUE. A 3-CNF Example: (x1x2x3)(x1x2x3)(x1x2x3) The Reduction : Describe a 3-CNF formula with k sub-clauses as: (l11 l12 l13)  (l21 l22 l23)  .. (lk1 lk2 lk3) Reduce it to a clique problem such that it is satisfiable if and only if a corresponding graph has a clique of size k. Step 1: Represent each “term” lri as a vertex vri. Step 2: Create the edges for any two vertices: vri and vsj if:r  s and lri is not the negation of lsj

  45. u v u v u v z w z w z w y x y x y x The VERTEX-COVER Problem A Vertex-Cover in an undirected graph is a set of vertices that cover all edges in the graph. A vertex Coversa set of edges: Vertex-Cover = {w,z} Vertex-Cover Problem Optimization problem: Find a vertex-cover of minimum size in a graph. Decision problem: Whether a graph has a vertex-cover of a given size k.

  46. u v z w y x The VERTEX-COVER ProblemPart A of the proof: VERTEX-COVERNP • VERTEX-COVER is NP-complete • 2 parts of the proof: • A. VERTEX-COVER NP • B. VERTEX-COVER is NP-hard Part A of the proof: VERTEX-COVER NP Consider an algorithm: bool Verify_VERTEX_COVER( Input_Graph, Certificate /*a set of vertices*/ ) This algorithm checks whether the set of vertices in the certificate cover all edges in the input graph. This is a 2-input, polynomial-time verification algorithm for VERTEX-COVER. Since we can find such an algorithm for VERTEX-COVER, we say that VERTEX-COVERcan be verified in polynomial time, and VERTEX-COVERNP.

  47. u v z w y x G G’ = complement of G Example: u u v v CLIQUE problem:In the graph G=(V,E), can we find a clique of size k=4? u v z w z w y y x x y x Polynomialtimereduction A CLIQUE instance A VERTEX-COVER instance s.t. result of CLIQUE inst. = result of VERTEX-COVER inst. The VERTEX-COVER Problem Part B of the proof: VERTEX-COVER is NP-hard Part B of the proof: VERTEX-COVER is NP-hard Show that CLIQUEpVERTEX-COVER ie.Any instance of CLIQUE satisfiability can be reduced in polynomial time to an instance of VERTEX-COVER. The Reduction : For any CLIQUE satisfiability problem < G=(V,E), k>, we can create a VERTEX-COVER problem <G’,|V|-k> such that G’ is the complement of G. VERTEX-COVER problem:In the graph G’, can we find a clique of size |V|-k=2?

  48. u v z w y x The HAM-CYCLE Problem A Hamiltonian Cycle in an undirected graph is a simple cycle that contains each vertex in V. The HAM-CYCLE Problem Does a graph have a hamiltonian cycle? • HAM-CYCLE is NP-complete • 2 parts of the proof: • A. HAM-CYCLE NP • B. HAM-CYCLE is NP-hard

  49. The HAM-CYCLE Problem Part B of the proof: HAM-CYCLE is NP-hard Part A of the proof: HAM-CYCLE NP Consider an algorithm: bool Verify_HAM-CYCLE (Input_Graph,Certificate /*a seq of vertices of a ham-cycle*/ ) It checks: 1. The certificate covers all vertices in input_graph exactly once. 2. The certificate is a valid path (each vertex links to next one). 3. An edge joins the first and the last vertex in the certificate. This is a 2-input, polynomial-time verification algorithm for HAM-CYCLE. Since we can find such an algorithm for HAM-CYCLE, we say that HAM-CYCLEcan be verified in polynomial time, and HAM-CYCLENP. Part B of the proof: HAM-CYCLE is NP-hard Show that VERTEX-COVERpHAM-CYCLE ie.Any VERTEX-COVER instance can be reduced in polynomial time to a HAM-CYCLE instance. The Reduction : Please refer to the text book. Chp 34.5.3

  50. CIRCUIT-SAT SAT 3-CNF-SAT CLIQUE SUBSET-SUM VERTEX-COVER HAM-CYCLE TSP NP-Completeness Summary • Intractability • P,NP,NP-Complete,P<>NP • NP-Completeness Proofs • Informal Illustration • Key Concepts • Formal definitions: P,NP,NPC • First NP-Complete Problem • NP-Completeness proofs • Examples

More Related