+ All Categories
Home > Documents > NP-complete examples

NP-complete examples

Date post: 23-Feb-2016
Category:
Upload: cwen
View: 52 times
Download: 0 times
Share this document with a friend
Description:
NP-complete examples. CSCI3130 Tutorial 10. Chun-Ho Hung. [email protected]. Department of Computer Science & Engineering. Outline. Review P, NP, NPC Polynomial-time Reduction 2 problem s Double-SAT Dominating set http://en.wikipedia.org/wiki/Dominating_set_problem. Review. - PowerPoint PPT Presentation
Popular Tags:
39
NP-complete examples CSCI3130 Tutorial 10 Chun-Ho Hung [email protected] Department of Computer Science & Engineering 1
Transcript

PowerPoint Presentation

NP-complete examplesCSCI3130 Tutorial 10Chun-Ho [email protected] Department of Computer Science & Engineering11OutlineReviewP, NP, NPCPolynomial-time Reduction2 problemsDouble-SATDominating sethttp://en.wikipedia.org/wiki/Dominating_set_problem

22ReviewP, NP, NPCPolynomial-time Reduction3PP is the class of all languages that have poly-time algorithme.g., Shortest path on a directed graph, Sorting4NPNP is the class of all languages that have poly-time verifierA verifier a Turing Machine, V, s.t.Given a potential xx L V accepts input for some sSolution sV runs in polynomial time5NP (cont)While verifying a solution of a NP problem is easy (in poly-time), finding a solution could be more difficultAn 3SAT instance - Find a satisfying assignment for

VerifyingGiven an assignment, just evaluate the truth valueFinding a solution?No efficient algorithm has been discovered yet6(x1x2 ) (x2 x3 x4) (x1)f =P versus NPEvery language, L in P, L is also in NPLet Verifier = Poly-time TM that solves LThereforeP is contained in NPNote: L in NP does not imply that efficient algorithm that decides Ldoes not exist7NPPNPCA language C is NP-complete if:C is in NPEvery language L in NP, L poly-time reduces to CWhat is a reduction?8ReductionThe direction of the reduction is very importantSaying A is easier than B and B is easier than A mean different thingsA (polynomially) reduces to B means B is not easier than A

9Reduction (Cont)Consider 2 problems:BFS on unweighted graphShortest path on weighted graphAssume we have a TM, V, which solves 2)We can reduce 1) to 2):Given an instance of 1), convert it into an instance of 2):Copy the graph, add weight=1 to every edge in 2)Run this instance on V, output resultThese two yes instances corresponds to each other

10Poly-Time ReductionHow to show that a problem B is not easier than a problem A?Informally, if B can be solved efficiently, we can solve A efficientlyFormally, we say A polynomially reduces to B if:Given an instance a of problem, xThere is a polynomial time transformation to an instance of B, y = f(x) x is a yes instance if and only if y is a yes instance

11Poly-Time Reduction (Cont)Suppose A poly-time reduces to BThen there exists a poly-time TM, R, s.t., Given an instance of A, x, transforms it to an instance of B, y = f(x), andy is accepted x is accepted12Poly-Time Reduction (Implication)Suppose A reduces to BIf B is polynomial time solvable, then A is polynomial time solvableIf A is not polynomial time solvable, then B is not polynomial time solvableContrapositive13xyRTM for LaccrejPoly-time TMPoly-Time Reduction (Implication)Suppose A reduces to BSolving B cannot be easier than solving ASuppose A is difficult while B is easyHowever, by this reduction, you find a easy way to solve AConsequently, if A is NPC, then B must be NPC14xyRTM for LaccrejPoly-time TMPoly-Time Reduction - P versus NPTo show P = NP, one could try to show that a NPC problem, C, can be solved in polynomial time. Why?Every problem in NP poly-time reduces to CIf C can be solved in poly-time, so does each problem in NPThen NP = P!!But this is not that easy and it is counter-intuitive (to most people) too15P versus NP (Again)Most believe that P NP, because intuitively searching for a solution is more difficult than verifying a solutionWhat does P = NP imply?Know how to verify a solution in poly-time Know how to find a solution in poly-time (?!)Indeed we prefer P NPEncryption algorithms heavily rely on the assumption that P NPP = NP or P NP is still an open problem

16RelationsNPPNP-CeasyhardIs there any problem even harder than NP-C?Yes! e.g. I-go1717MethodologyTo show L is in NP, you can eitherShow that solutions for L can be verified in polynomial-time, orDescribe a nondeterministic polynomial-time TM for L(Come back to this if we have enough time)To show L is NP-completeShow that L is in NPPoly-time reduce some NPC problem to Li.e., design a polynomial-time reduction from some problem we know to be NP-complete1818ExampleProving a problem being NPC19Double-SATProblem:Double-SAT = { | is a Boolean formula with at least two satisfying assignments}Goal:Show that Double-SAT is NP-Complete

2020Double-SAT (Proof Sketch)Steps:Show that Double-SAT NPShow that Double-SAT is not easier than a certain NPC problemFor the NPC problem, we choose SATi.e., we want to poly-time reduce Double-SAT to SATShow the correspondence of yes instance between reduction21Double-SAT - (1) NPIt is trivial to see that Double-SAT NPGiven 2 assignments for , and verify whether both of them satisfy We can just evaluate the truth value in poly-time22Double-SAT - (2) ReductionReduction:On input (x1, . . . , xn): 1. Introduce a new variable w 2. Output formula (x1, . . . , xn, y) = (x1, . . . , xn) ( w w ).

23xyx L y LRTM for LaccrejTM acceptsSATDouble-SAT23Double-SAT - (3) Correspondencex L y L : Suppose there is an satisfying assignment, X, for (x1, . . . , xn), we can find two satisfying assignments for (x1, . . . , xn, w):Assignment 1 = {X, w=True}Assignment 2 = {X, w=False} (x1, . . . , xn, w) = (x1, . . . , xn) ( w w )24For {xi}, assign X,then this part = TrueNo matter what w is,this part = True24Double-SAT - (3) Correspondencex L y L: We use contrapositivei.e., to show x L y LIndeed, if x L, (x1, . . . , xn)=FalseThen, no matter what the value of y is(x1, . . . , xn, y)=False

2525Dominating SetProblem:Dominating-set = { | A dominating set of size K for G exists}Goal:Show that Dominating-set is NP-Complete2626Dominating Set (Definition)Problem:Dominating-set = { | A dominating set of size (at most) K for G exists}Let G=(V,E) be an undirected graphA dominating set D is a set of vertices that covers all verticesi.e., every vertex of G is either in D or is adjacent to at least one vertex from D2727Dominating Set (Example)Size-2 example : {Yellow vertices}e28Dominating Set (Proof Sketch)Steps:Show that Dominating-set NP. Show that Dominating-set is not easier than a NPC problemWe choose this NPC problem to be Vertex coverReduction from Vertex-cover to Dominating-setShow the correspondence of yes instances between the reduction29Dominating Set - (1) NPIt is trivial to see that Dominating-set NPGiven a vertex set D of size K, we check whether (V-D) are adjacent to Di.e., for each vertex, v, in (V-D), whether v is adjacent to some vertex u in D30Dominating Set - (2) ReductionReduction - Graph transformationConstruct a new graph G' by adding new vertices and edges to the graph G as follows:31GG L LTVertex-coverDominating-setDominating Set - (2) ReductionReduction - Graph transformation (Cont)For each edge (v, w) of G, add a vertex vw and the edges (v, vw) and (w, vw) to G'Furthermore, remove all vertices with no incident edges; such vertices would always have to go in a dominating set but are not needed in a vertex cover of GWe skip the discussion of this subtle part in the followings32GG L LTVertex-coverDominating-set[Recap] Vertex coverA vertex cover, C, is a set of vertices that covers all edgesi.e., each edge is at least adjacent to some node in C

33{2, 4}, {3, 4}, {1, 2, 3} are vertex covers1234Dominating Set Graph Transformation ExamplevwzuGwvzuvzwuvwzuvuG'34Dominating Set - (3) CorrespondenceA dominating set of size K in G A vertex cover of size K in G Let D be a dominating set of size K in GCase 1): D contains only vertices from G Then, all new vertices have an edge to a vertex in D D covers all edges D is a valid vertex cover of G35Dominating Set - (3) CorrespondenceA dominating set of size K in G A vertex cover of size K in G Let D be a dominating set of size K in GCase 2): D contains some new vertices (vertex in the form of uv) (We show how to construct a vertex cover using only old vertices, otherwise we cannot obtain a vertex cover for G) For each new vertex uv, replace it by u (or v) If u D, this node is not needed Then the edge u-v in G will be covered After new edges are removed, it is a valid vertex cover of G (of size at most K)

36Dominating Set - (3) CorrespondenceA dominating set of size K in G A vertex cover of size K in G Let C be a vertex cover of size K in G For an old vertex, v G :By the definition of VC, all edges incident to v are coveredv is also covered For a new vertex, uv G :Edge u-v must be covered, either u or v CThis node will cover uv in G Thus, C is a valid dominating for G (of size at most K)

37Dominating Set - (3) CorrespondencevwzuwvzuvzwuvwzuvuVertex-cover in GDominating-set in G'38EndAny questions? (There should be some)39


Recommended