1 / 47

This class

This class. Satisfiability problem NP completeness The complexity class co-NP Some NP-Completeness proofs. CNF-satisfiability  NP. Important problem in logic First problem shown to be NP-Complete by Cook To show CNF-satisfiability  NP :

edwardbeck
Download Presentation

This class

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. This class • Satisfiability problem • NP completeness • The complexity class co-NP • Some NP-Completeness proofs

  2. CNF-satisfiability  NP • Important problem in logic • First problem shown to be NP-Complete by Cook • To show CNF-satisfiability  NP : • First, Conjunctive Normal Form will be defined • Then, the CNF-satisfiability problem will be defined • Finally, we will show a polynomial boundedverificationalgorithm for the problem

  3. Conjunctive Normal Form (CNF) • A logical (Boolean) variable is a variable that may be assigned the value true or false (for example p, q, r and s) • A literal is a logical variable or the negation of a logical variable (p and Øq are literals) • A clause is a disjunction of literals (for example (pÚqÚs) and (Øq Ú r) are clauses) • A logical expression is in Conjunctive Normal Form if it is a conjunction of clauses. Forexample the expression: (pÚqÚs) Ù(Øq Ú r)Ù(Øp Ú r) Ù(Ør Ú s)Ù(ØpÚØsÚØq)

  4. The CNF-satisfiability problem • Is there a truth assignment for the variables of a CNF expression which causes the CNF expression to be true? • Answer is true, if all clauses evaluate to T (true) • For example, p=T, q=F, r=T and s=T is a truth assignment for (pÚqÚs) Ù(ØqÚ r)Ù(Øp Úr) Ù(Ør Ús)Ù(ØpÚØsÚØq) • Note that if q=F then Øq=T

  5. NP-completeness • A language L (or problem corresponding to the language) is NP-complete if 1. L Î NP and 2. L' µ L for every L'ÎNP. • The class of NP-complete problems (languages) is called NPC.

  6. Theorem 1.If any problem in NPC is polynomial-time solvable, then P = NP. 2.If any problem in NP is not polynomial-time solvable, then all problems in NPC are not polynomial-time solvable.

  7. Proof 1.Given: L ÎP and L ÎNPC For any L'ÎNP L' µ L (definition of NPC). So by last theorem, L' Î P and P = NP. 2.Given: L ÎNP and LÏP Let L' ÎNPC. Assume that L'ÎP. Then L µ L' (definition of NPC) and thus by last theorem, LÎP. Contradiction. So L’ÏP and all NPC problems are not polynomial time solvable

  8. Proving NP completeness • Cook showed CNF-SATISFIABILITY is NP-complete. • To prove any other problem NP-complete, we then just have to reduce CNF- SATISFIABILITY to that problem and show that problem lies in the class NP.

  9. Theorem: polynomial reducibility is transitive If L1  L2 and L2 µ L3 then L1 µ L3 Proof outline: • There is a polynomially computable function • that reduces all inputs x  L1 into an input T1(x)  L2 • that reduces all inputs y  L2 into an input T2(y)  L3 • Applying T1 to x and T2 to T1(x) reduces any instance x  L1 to an instance T2(T1(x))  L3, and this conversion requires a polynomial number of steps

  10. Shortcut for NP-completeness Proofs • To prove a language L is NP-complete: Prove 1. L Î NP. Choose L' Î NPC, and prove 2. L’ L • Why is L is NP-complete? By 1. L Î NP. By definition L Î NPC, if every M Î NP satisfies M  L. We will show that this is correct, and thus L is NP-complete Since L’ Î NPC every M Î NP satisfies M  L’ (definition), and by 2. L’ L. So by transitivity M  L

  11. Complexity Class co-NP • The complexity class co-NP is the class of problems L such that Lbar ÎNP. • An open question: “is NP closed under complement” or is NP = co-NP? • To show that NP=co-NP we would need to show that for every language L Î NP, also LbarÎ NP

  12. TS: Given a set of cities {c1, …, cm} a distance d between every pair, and a bound B. Is it true that there is a TS cycle such that the distance of the cycle is at most B? Certificate is a permutation of the cities Polynomial bound verification algorithm (see slides) TSbar: Given a set of cities {c1, …, cm} a distance d between every pair, and a bound B. Is it true that there is no TS cycle such that the distance of the cycle is at most B? What is the certificate? A polynomial bound verification algorithm? NP=co-NP?

  13. P=co-P • The class of languages in P are closed under union, intersection, concatenation, Kleene star and complement • Proof for P=co-P • Let L  P. There exists a polynomial bound algorithm A that decides L (i.e, answers yes or no). • By changing A to answer no instead of yes and to yes instead of no we have a polynomial time algorithm B for Lbar. So Lbar  P and P=co-P

  14. SpanTree= {G|G is an undirected connected graph that contains a spanning tree of length at most B} Algorithm for SpanTree: L=Kruskal(G) //find length of MST if (L<=B) return true else return false SpanTreebar= {G|G is an undirected connected graph that does not contain a spanning tree of length at most B} Algorithm for SpanTreebar: L=Kruskal(G) //find length of MST if (L<=B) return false else return true Example

  15. P  (NP  co-NP) • Show P  co-NP. We need to show that for every language L, LP  Lco-NP Proof: Since LP and P = co-P  LbarP Since LbarP and P  NP  LbarNP So (Lbar)bar=L co-NP • Since P  NP and P  co-NP P  (NP co-NP)

  16. Theorem If NP co-NP then P  NP ProofMain idea: Use contradiction. Assume P=NP We know P=co-P. We will show that P=NP  NP=co-NP Contradicting the assumption NP co-NP

  17. Detailed Proof (cont.) • Given : P = NP, and P = co-P • We will show NP= co-NP 1. X  NP  X  P Xbar  P  Xbar  NP X  co-NP NP co-NP 2. X  co-NP Xbar  NP Xbar  P  X  P X  NP co-NP NP • From 1. And 2. NP= co-NP

  18. The four possibilities • P= NP = co-NP • P  NP and NP = co-NP • P = (NP co-NP) NP co-NP • P  (NP co-NP), NP co-NP P= NP=co-NP co-NP NPco-NP P= NPco-NP NP NP P co-NP NP=co-NP P

  19. NP-completeness Proofs in detail • To prove a language L is NP-complete: Step 1. Prove LÎ NP. Step 2. Choose a known language L' Î NPC. Step 3. Describe T mapping every instance of L' to an instance of L.

  20. NP-completeness Proofs in detail Step 4. Show that x Î L' iff T(x) Î L for all x. Step 5. Show that T , the algorithm that computes T(x) , runs in polynomial time.

  21. 3-CNF-SAT • Every clause has exactly 3 literals. • 3-CNF-SAT is NP-Complete • It can be shown that 3-CNF-SAT Î NP and CNF-SAT µ 3-CNF-SAT

  22. The Clique Problem • A clique is a complete undirected graph --- every vertex is connected to every other vertex. CLIQUE Input: An undirected graph G and a positive integer k. Output: YES iff a clique of size k exists in G.

  23. Clique example 1 2 8 3 7 4 • G contains a clique of 4 (with vertices 3, 5, 6, 7) • The 4 people 3, 5, 6, 7 “know” (can work with each other) each other 6 5

  24. The Clique Problem • Theorem: CLIQUE is NP-complete. • Proof: • Step 1. CLIQUE Î NP Given a set of k vertices V' ÍV, we can check if V' forms a clique by checking for every pair of nodes u, v ÎV’ that (u,v) Î E • Clearly, this can be done in polynomial time.

  25. The Reduction Step 2. Selection 3-CNF-SATwhich is NP-Complete. Step 3. Mapping For a formula C1Ç... Ç Ck such that Cr = l1,r+ l2,r+l3,r we construct a graph G with vertices v1,r v2,r v3,r for r = 1,…, k, where vi,r represents the literal li,r

  26. The Reduction We put an edge between vi,r and vj,s if both of the following hold: 1. r ¹ s and 2. li,r is not the negation of lj,s.

  27. v1,1 v1,2 k=2 The graph has 6 cliques of size 2 v2,1 v2,2 v3,2 v3,1

  28. Step 4a. Yes for 3-Sat implies yes for clique • Assume formula satisfiable. • With the satisfying assignment each clause contains at least 1 literal that is assigned 1. • Since each literal from each clause is a vertex in the graph, if we pick out a literal that is assigned 1 from each of the k clauses, we get k vertices in the graph.

  29. Step 4a. Yes for 3-Sat implies yes for clique • This set of k vertices is a clique. • For any two vertices, the corresponding literals are from different clauses, and are both assigned 1, so they cannot be complements of a single variable • Thus there is an edge between any two such vertices.

  30. Step 4b. Yes for Clique implies yes for 3-Sat • Assume G has a clique V' of size k. • No edge connects vertices in the same triple, so each of k triples has exactly one vertex in V'. • Assign 1 to each literal in V' without getting an inconsistent assignment (why?) and arbitrary values to the rest of the variables. • For this assignment each clause is satisfied and thus the answer for 3-SAT is yes.

  31. Step 5. Reduction is polynomial • Step 5. The reduction is polynomial. • The formula is read and 3k vertices are generated in O(k) steps. Then, each pair of literals ( ) from two different clauses is checked and an edge is added if the literals are not complimentary. • The reduction is O(k2)

  32. The vertex-cover problem • A vertex cover of an undirected graph is a set of vertices V' such that for every edge (u,v), either u or v or both are in V'. The problem is to find a cover of minimum size. • VERTEX-COVER • Input: A graph G and a number k. • Output: YES iff G has a vertex cover of size k.

  33. 1 2 3 5 4 Example of a vertex cover problem G k=2

  34. Application of vertex cover • What is the fewest # of guards we need to place in a museum to cover all the corridors? An airport to cover all the main walkways Hall 1 Hall 5 Hall 2 Hall 3 Hall 6 Hall 4

  35. The vertex-cover problem • Theorem: VERTEX-COVER is NP-complete. • Proof: Step 1. VERTEX-COVER ÎNP (obvious algorithm, given a subset of vertices). • Step 2. We select CLIQUE (will show that CLIQUE µ VERTEX-COVER)

  36. The reduction • Step 3. The mapping. • Given an instance of the CLIQUE problem <G, k> we output an instance <G’, |V|-k> of the VERTEX-COVER problem. • G’ has the same vertices as G and exactly those edges that are not in G. • It is easy to show the reduction is polynomial (step 5)

  37. Reduction Example G G’ 1 1 2 2 3 3 5 5 4 4 Clique {1,2} of size 2 Cover {3,4,5} of size 3

  38. Step 4. Correctness of the reduction • Assume G has a clique C of size k. • In G’ there are no edges between any pair of vertices in C G G’ 1 1 2 2 3 3 5 5 4 4

  39. Step 4 cont • So all edges in G’ are between a node in C and a node in V-C, or two nodes in V-C. • So V-C is a vertex cover for G’. G G’ 1 1 2 2 3 3 5 5 4 4

  40. Step 4. Correctness of the reduction • Assume G’=(V, E’) has a vertex cover V'Í V, where |V'| = |V|-k. • Thus for all u, v ÎV-V‘ (not in the cover), (u,v) E’ and thus (u,v) ÎE • V-V' is thus a clique. G G’ 1 1 2 2 3 3 5 5 4 4

  41. Hamiltonian Cycle • A Hamiltonian cycle of a graph G is a cycle that contains each vertex in V exactly once. A graph is Hamiltonian if it has a Hamiltonian cycle. • HAM-CYCLE • Input: A graph G. • Output: YES iff G is Hamiltonian.

  42. Hamiltonian Cycle • Theorem: HAM-CYCLE is NP-complete. • 3-CNF-SATµ HAM-CYCLE (proof omitted).

  43. Traveling Salesman • A tour is a Hamiltonian cycle in a graph. We want the minimum cost tour in a weighted graph. • TSP: • Input: A graph G, weights c for edges and a positive integer k. • Output: YES iff G with weights c has a TS tour of cost at most k.

  44. Traveling Salesman • Theorem: TSP is NP-complete. • Proof: Step 1: TSP is in NP • A certificate is a permutation of the cities. • This certificate can easily be verified by checking that all cities are included exactly once and that the sum of the distances is k or less. • This can be done in polynomial time, so TSP ÎNP.

  45. The reduction • Step 2: Select HAM-CYCLE (We will show that HAM-CYCLE µ TSP). • Step 3: The reduction • Given an instance G of HAM-CYCLE, we construct a graph G' = (V,E'). G' is a complete graph and c(i,j) = 0 if (i,j) is an edge and 1 otherwise. • The instance of TSP is then (G',c,0) where 0 is the bound on the cost of the tour. This conversion can be done in polynomial time (step 5).

  46. The reduction (example) G 0, G’ 1 2 1 2 0 0 1 1 0 0 3 3 1 5 0 5 0 4 4

  47. The reduction (step 4) • If G has a Hamiltonian cycle h, each edge in h belongs to E and thus has no cost in G'. Thus h is a tour with cost 0. • If G' has a tour of cost 0, the tour must have edges from E (since any edge not in E adds 1 to the cost). Thus, the tour must be a Hamiltonian cycle in G.

More Related