Prove this problem is in NP

Slides:



Advertisements
Similar presentations
Max Cut Problem Daniel Natapov.
Advertisements

Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
NP-Completeness: Reductions
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Reduction Techniques Restriction Local Replacement Component Design Examples.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
Fall 2006Costas Busch - RPI1 More NP-complete Problems.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 24 Instructor: Paul Beame.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Clique Cover Cook’s Theorem 3SAT and Independent Set
February 25, 2015CS21 Lecture 211 CS21 Decidability and Tractability Lecture 21 February 25, 2015.
1 1. Draw the machine schema for a TM which when started with input 001 halts with abbb on the tape in our standard input format. 2. Suppose you have an.
NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle
1 3-COLOURING: Input: Graph G Question: Does there exist a way to 3-colour the vertices of G so that adjacent vertices are different colours? 1.What could.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 33.
Techniques for Proving NP-Completeness Show that a special case of the problem you are interested in is NP- complete. For example: The problem of finding.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Suppose I construct a TM M f which: 1. Preserves its input u. 2. Simulates a machine M b on input ε. 3. If M b hangs on input ε, force an infinite loop.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 30, 2014.
NPC.
NP-Completeness Note. Some illustrations are taken from (KT) Kleinberg and Tardos. Algorithm Design (DPV)Dasgupta, Papadimitriou, and Vazirani. Algorithms.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
Given this 3-SAT problem: (x1 or x2 or x3) AND (¬x1 or ¬x2 or ¬x2) AND (¬x3 or ¬x1 or x2) 1. Draw the graph that you would use if you want to solve this.
Prof. Busch - LSU1 Busch Complexity Lectures: More NP-complete Problems.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
Costas Busch - LSU 1 More NP-complete Problems. Costas Busch - LSU 2 Theorem: If: Language is NP-complete Language is in NP is polynomial time reducible.
The NP class. NP-completeness
More NP-Complete and NP-hard Problems
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Computability and Complexity
More NP-complete Problems
More NP-complete Problems
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness (36.4-5) P: yes and no in pt NP: yes in pt NPH  NPC
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
Intro to Theory of Computation
CS21 Decidability and Tractability
ICS 353: Design and Analysis of Algorithms
Complexity 6-1 The Class P Complexity Andrei Bulatov.
More NP-complete Problems
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Richard Anderson Lecture 29 NP-Completeness
Linear Programming Duality, Reductions, and Bipartite Matching
1. for (i=0; i < n; i+=2) if (A[i] > A[i+1]) swap(A[i], A[i+1])
Richard Anderson Lecture 28 NP Completeness
NP-Complete Problems.
Richard Anderson Lecture 27 NP Completeness
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
CSE 6408 Advanced Algorithms.
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
More NP-complete problems
Richard Anderson Lecture 27 Survey of NP Complete Problems
Richard Anderson Lecture 25 NP Completeness
Instructor: Aaron Roth
Lecture 23 NP-Hard Problems
Presentation transcript:

Prove this problem is in NP 3-COLOURING: Input: Graph G Question: Does there exist a way to 3-colour the vertices of G so that adjacent vertices are different colours? 1.What could you use for a certificate for the 3-colouring problem? 2. Give the pseudo code for a polynomial time algorithm for checking your certificate.

Announcements: Assignment #5 has been posted. Due Tues. Dec. 7 at 1pm. Slip it under my office door if I am not in my office when you come by. I have indicated on your #4 (or on a blank sheet if you did not hand in #4) the grade you need on #5 to pass the assignments so you can write the final exam. No class on Friday Dec. 3: National Day of Remembrance and Action on Violence Against Women. I am away at a conference Dec. 3-6 (no office hours). Old finals- available from our web pages. Final Exam tutorial: Thurs. Dec. 9, 5:30pm, ECS 116.

SAT (Satisfiability) Variables: u1, u2, u3, ... uk. A literal is a variable ui or the negation of a variable ¬ ui. If u is set to true then ¬ u is false and if u is set to false then ¬ u is true. A clause is a set of literals. A clause is true if at least one of the literals in the clause is true. The input to SAT is a collection of clauses.

SAT (Satisfiability) The output is the answer to: Is there an assignment of true/false to the variables so that every clause is satisfied (satisfied means the clause is true)? If the answer is yes, such an assignment of the variables is called a truth assignment. SAT is in NP: Certificate is true/false value for each variable in satisfying assignment.

If SAT is solvable in polynomial time, then so is HAMILTON CYCLE . This is on p. 303 in text but there are numerous typos. Use my notes not text. Graph G has n vertices 0, 1, 2, …, n-1. Variables: xi, j : 0 ≤ i, j ≤ n-1 Meaning: Node i is in position j in Hamilton cycle.

Variables: xi, j : 0 ≤ i, j ≤ n-1 Meaning- Node i is in position j in Ham. cycle. Conditions to ensure a Hamilton cycle: Exactly one node appears in position j. At least one node appears in position j. For each j, add a clause: (x0, j OR x1,j OR x2, j OR … xn-1, j ) (b) At most one node appears in position j. For each pair of vertices i,k add a clause (not xi, j OR not xk,j )

Variables: xi, j : 0 ≤ i, j ≤ n-1 Meaning- Node i is in position j in Ham. cycle. 2. Vertex i occurs exactly once on the cycle. (a) Vertex i occurs at least once. For each i, add a clause: (xi, 0 OR xi,1 OR xi, 2 OR … xi, n-1 ) (b) Vertex i occurs at most once. For each vertex i and pair of positions j,k add a clause (not xi, j OR not xi,k )

Variables: xi, j : 0 ≤ i, j ≤ n-1 Meaning- Node i is in position j in Ham. cycle. 3. Consecutive vertices of the cycle are connected by an edge of the graph. For each edge (i, k) which is missing from the graph and for each j add a clause (not xi, j OR not xk,j+1 mod n )

Known: SAT is NP-complete. We just proved that if SAT is solvable in polynomial time, then so is HAMILTON CYCLE. Is this a proof that HAMILTON CYCLE is NP-complete?

Known: SAT is NP-complete. We showed that if SAT is solvable in polynomial time, then so is HAMILTON CYCLE. Is this a proof that HAMILTON CYCLE is NP-complete? NO. Wrong direction. We would have to show that you can solve SAT in polynomial time using HAMILTON CYCLE instead. Another example: proving you can solve 2-SAT using a SAT solver does not mean 2-SAT is hard.

A problem Q in NP is NP-complete if the existence of a polynomial time algorithm for Q implies the existence of a polynomial time algorithm for all problems in NP. How do we prove SAT is NP-complete? Cook’s theorem: SAT is NP-complete.

Proving problems are NP-complete. Assuming SAT is NP-complete, we prove that 3-SAT is NP-complete. We use the fact that 3-SAT is NP-complete to prove that VERTEX COVER is NP-complete.

3-SAT- each clause must contain exactly 3 variables (assignment- at most 3). Given: SAT is NP-complete (proof later) Theorem: 3-SAT is NP-Complete. The first step in any NP-completeness proof is to argue that the problem is in NP. The problem 3-SAT is a yes/no question. Certificate: truth assignment, can be checked in polynomial time. Next, we show that a polynomial time algorithm for 3-SAT implies the existence of one for SAT.

To convert a SAT problem to 3-SAT: 1.Clauses of size 1. SAT: {z} 3-SAT: {z, y1, y2}, {z, ¬ y1, y2}, {z, y1, ¬ y2}, {z, ¬ y1, ¬ y2} y1 and y2 are new variables.

2. Clauses of size 2. SAT: {z1, z2} 3-SAT: {z1, z2, y}, {z1, z2, ¬ y} y is a new variable. 3. Clauses of size 3. Leave these as they are since they are already acceptable for 3-SAT.

Clauses of size 4 or more. SAT: {z1, z2, z3, ... zk}, k>3 3-SAT: { z1, z2, y1}, {¬ y1, z3, y2}, {¬ y2, z4, y3}, ... {¬ yk-4, zk-2, yk-3}, {¬ yk-3, zk-1, zk} y1, y2, ... yk-3, are new variables.

This does not constitute a proof of NP-completeness unless we can argue that the size of the new 3-SAT problem problem is polynomially bounded by the size of the old SAT problem. Consider each case: Size of clause # new literals size before size after 1 2 12 6 3 k ≥ 4 k-3 k k + 2(k-3) In all cases, the size after is at most 12 times the original problem size.

2-SAT: All clauses have at most 2 literals. There is a linear time algorithm for 2-SAT so 2-SAT is in P. The 3-SAT problem is as hard as SAT but unless P=NP, 2-SAT is easier than 3-SAT or SAT.

A set S  V(G) is a vertex cover if every edge of G has at least one vertex in S. Given: G, k Question: Does G have a vertex cover of order k? Blue: vertex cover Red: independent set

Theorem: Vertex Cover is NP-complete. Proof: Certificate: vertex numbers of vertices in the vertex cover. To check: for (i=0; i < n; i++) cover[i]= 0; for (i=0; i < k; i++) { scanf(“%d”, &t); if (t < 0 || t >= n) {printf(“Bad cover.\n”); exit(0);} else cover[t]= 1; } Read in certificate.

Make sure each edge is covered. for (i=0; i < n; i++) { for (j=i+1; j< n; j++) { if (A[i][j]){ if (cover[i]==0 && cover[j]==0) { printf(“Bad cover.\n”); exit(0); } } printf(“Good cover\n”); Make sure each edge is covered.

To solve 3-SAT using vertex cover: 1. For each literal xi, include: 2. For each clause (xi, xj, xk) use a gadget: Each white vertex connects to the corresponding green one. Pictures from: http://cgm.cs.mcgill.ca/~athens/cs507/Projects/2001/CW/npproof.html

3-SAT Problem: (x1 or x1 or x2) AND (¬x1 or ¬ x2 or ¬ x2) AND (¬x1 or x2 or x2)

At least one vertex from is in the vertex cover. For each gadget, at least 2 vertices are in the vertex cover: Number of variables: n Number of clauses: m When is there a vertex cover of order n + 2m?

Put vertices corresponding to true variables in the vertex cover.

Satisfying assignment: Each clause has at least one true variable Satisfying assignment: Each clause has at least one true variable. Put two other vertices into the vertex cover: So each truth assignment corresponds to a vertex cover of order n + 2m.

Any vertex cover of order n + 2m corresponds to a satisfying assignment because we can only select at most one of x and ¬x (these are the true variables). The true variables must satisfy each clause since at most 2 vertices can be selected from each clause gadget.

A problem Q in NP is NP-complete if the existence of a polynomial time algorithm for Q implies the existence of a polynomial time algorithm for all problems in NP. How do we prove SAT is NP-complete? Cook’s theorem: SAT is NP-complete.