Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 461 – Nov. 30 Section 7.5 How to show a problem is NP-complete –Show it’s in NP. –Show that it corresponds to another problem already known to be NP-complete.

Similar presentations


Presentation on theme: "CS 461 – Nov. 30 Section 7.5 How to show a problem is NP-complete –Show it’s in NP. –Show that it corresponds to another problem already known to be NP-complete."— Presentation transcript:

1 CS 461 – Nov. 30 Section 7.5 How to show a problem is NP-complete –Show it’s in NP. –Show that it corresponds to another problem already known to be NP-complete. Example NP-complete problems –3SAT, special case of SAT –Clique –Subset sum

2 Other problems We now have 1 problem, “SAT”, proved to be NP-complete by definition. To show that some other problem is NP-complete, all we need to do is create a polynomial-time correspondence with SAT, or other problem already proved to be NP- complete. –Not necessary to start over with arbitrary NTM. Examples: –3SAT: the satisfiability question assuming the boolean formula is of the form (_  _  _)  (_  _  _)  (_  _  _)  … i.e. CNF in which each factor has exactly 3 terms. –Clique, subset-sum, isomorphic, Hamiltonian path, etc. Review:

3 3SAT Want to show this is NP-complete. Note that we can’t simply say “3SAT is a special case of SAT, therefore it’s NP-complete.” –Consider this special case of SAT: all boolean formulas containing just one variable and no operators. Now the problem is trivially in P. –It’s possible that a “special case” of an NP-problem could become simple enough to be in P. But in the case of 3SAT we show it’s still NP-complete. Simple approach: re-do our proof of SAT, but this time make sure each  formula we write is expressed: –in CNF (conjunctive normal form) –with exactly 3 terms per factor

4 3SAT in CNF The  we created for SAT is almost already in CNF. –CNF means an AND of OR’s. –  has 4 factors. See book for precise definitions. –3 of the 4 factors are in CNF. Only 4 th factor  move needs modifying. –  move is more complex: an AND of OR’s of AND’s. We can use DeMorgan’s Law to convert OR’s of AND’s into AND’s of OR’s. Now we have CNF.

5 continued We also need exactly 3 terms per factor (_  _  _). –If fewer than 3, just repeat a term. e.g. (p  q  q) –To reduce 4 terms to 3, we would do this: (x 1  x 2  x 3  x 4 ) = (x 1  x 2  d)  (d’  x 3  x 4 ) where “d” is a new dummy variable. See why it works? Consider all x i false. Consider one x i true. –For more than 4 terms the technique generalizes: (x 1  x 2  x 3  …  x n ) = (x 1  x 2  d 1 )  (d 1 ’  x 3  d 2 )  (d 2 ’  x 4  d 3 )…  (d n-3 ’  x n-1  x n )

6 Clique problem Given a graph G and a number k, does G contain a complete subgraph of k vertices? –Alternatively, given a graph G, find the size (k) of the largest complete subgraph. This problem is in NP, because we could be given a subgraph to consider, and we can verify in O(k 2 ) time that it’s complete by checking that all required edges are present. To complete the proof that “Clique” is NP-complete, we will give a polynomial-time reduction from 3SAT to clique. –We already know that 3SAT is NP-complete. –We must convert a boolean formula  into a graph G, such that the  is true iff G has a clique.

7 3SAT  Clique We’re given , which has k factors, 3 terms per factor. Create the graph G as follows. The vertices are arranged in groups of 3. –Each “triple” of vertices corresponds to a factor in  –Label each vertex with corresponding term (e.g. x 1 ’). Note that the same label may appear in other triples. Edges connect all vertices except: –Vertices within the same triple –Vertices that are opposites of each other (as x 1 and x 1 ’) Why does this construction work? –We’ll show:  is “true”  G has a clique with k vertices.

8  True  clique Suppose  = true. –One of the terms in each triple must be true. –Looking at G, the vertices are grouped in k triples. –There are lots of edges between triples. The only type of edge between triples we don’t have is between contradictory terms like x 1 and x 1 ’. –A “true term” in a triple can always be connected to a “true term” in another triple. –Therefore, there is a clique of size k. Suppose G has a clique of size k. –Each vertex in the clique must be in a different triple. –Let’s assign truth values to each vertex to make each clique vertex true. There will be no contradictions. –Therefore, each triple will have one term that is true, so  is true.

9 Summary Thus far we have shown: –SAT is NP-complete –Therefore, 3SAT is NP-complete –Therefore, Clique is NP-complete Please watch this video lecture by Ron Graham: RonaldLG1988.mpeg on the class Web site Next: –Wrap up section 7.5 –Review


Download ppt "CS 461 – Nov. 30 Section 7.5 How to show a problem is NP-complete –Show it’s in NP. –Show that it corresponds to another problem already known to be NP-complete."

Similar presentations


Ads by Google