NP-Completeness and Reductions: Clique, Vertex Cover, 3CNF-SAT, and More - Prof. H. Venkat, Study notes of Computer Science

Various np-complete problems, including the clique problem, vertex cover problem, 3cnf-sat problem, and the subset sum problem. It also explores the relationship between these problems and the class np, as well as reductions between them. The document concludes with a discussion on deciding dnf-satisfiability and the relationship between p and np.

Typology: Study notes

Pre 2010

Uploaded on 12/16/2010

wuyuxian-66
wuyuxian-66 🇺🇸

5 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computability, Algorithms, and Complexity
Fall 2010 //Test 3 practice questions
NOTES:
If necessary, make reasonable assumptions. But, please make sure that you state your assumptions. Please write neat,
legible, precise, and succinct answers.
You can bring one sheet with notes on both sides to the test. You can use without re-proving: (a) Theorems, Lemmas,
and Examples either covered in the class or covered in chapters 1 to 5 and chapter 7 of the Sipser text, and (b) Home
work problems from this course. You may not use any other source.
You can assume the following:
The clique problem is the following: Given an undirected graph G= (V , E and a natural number k, is there a subset
V0Vsuch that: (a) |V0|=k, and (b) for any u, v V0, (u, v)E?
The clique problem is N P-Complete.
The vertex cover problem is the following: Given an undirected graph G= (V, E) with nvertices and an integer
1kn, is there a vertex cover (a subset V0Vsuch that every edge in Eis incident on at least one vertex in
V0) of size k?
The vertex-cover problem is NP -Complete.
The k-coloring problem is the following: Given an undirected graph G= (V, E ) and an integer k3, is there a way
to label the vertices from {1, . . . , k}such that adjacent vertices do not get the same value.
The k-coloring problem is NP -Complete.
AHamiltonian cycle in an undirected graph G= (V, E ) is a cycle that goes through all the vertices exactly once. The
Hamiltonian Cycle problem is to decide if an input graph has a Hamiltonian cycle.
The Hamiltonian cycle problem is N P -Complete.
The subset sum problem is the following: Given a collection of n+ 1 positive integers a1,a2, . . . , an, M , is there a subset
I {1,2, . . . , n}such that PiIai=M?
The subset sum problem is N P -Complete.
The unary subset sum problem is defined as the subset problem except that the input numbers are in unary.
The unary subset sum problem is in P.
The cnfsat problem is the following: Given a Boolean formula in conjunctive normal form, is there a truth assignment
to its variables that make the formula evaluate to true?
The cnfsat problem is N P-Complete.
The 3cnfsat problem is the following: Given a Boolean formula in conjunctive normal form in which each clause has
exactly three literals in it, is there a truth assignment to its variables that make the formula evaluate to true?
The 3cnfsat problem is N P-Complete.
Evaluating a Boolean formula given a truth assignment to its variables is in P.
1
pf3
pf4

Partial preview of the text

Download NP-Completeness and Reductions: Clique, Vertex Cover, 3CNF-SAT, and More - Prof. H. Venkat and more Study notes Computer Science in PDF only on Docsity!

Computability, Algorithms, and Complexity

Fall 2010 //Test 3 practice questions

NOTES:

  • If necessary, make reasonable assumptions. But, please make sure that you state your assumptions. Please write neat, legible, precise, and succinct answers.
  • You can bring one sheet with notes on both sides to the test. You can use without re-proving: (a) Theorems, Lemmas, and Examples either covered in the class or covered in chapters 1 to 5 and chapter 7 of the Sipser text, and (b) Home work problems from this course. You may not use any other source.

You can assume the following:

  • The clique problem is the following: Given an undirected graph G = (V, E and a natural number k, is there a subset V ′^ ⊆ V such that: (a) |V ′| = k, and (b) for any u, v ∈ V ′, (u, v) ∈ E? The clique problem is N P-Complete.
  • The vertex cover problem is the following: Given an undirected graph G = (V, E) with n vertices and an integer 1 ≤ k ≤ n, is there a vertex cover (a subset V ′^ ⊆ V such that every edge in E is incident on at least one vertex in V ′) of size ≤ k? The vertex-cover problem is N P-Complete.
  • The k-coloring problem is the following: Given an undirected graph G = (V, E) and an integer k ≥ 3, is there a way to label the vertices from { 1 ,... , k} such that adjacent vertices do not get the same value. The k-coloring problem is N P-Complete.
  • A Hamiltonian cycle in an undirected graph G = (V, E) is a cycle that goes through all the vertices exactly once. The Hamiltonian Cycle problem is to decide if an input graph has a Hamiltonian cycle. The Hamiltonian cycle problem is N P-Complete.
  • The subset sum problem is the following: Given a collection of n + 1 positive integers a 1 , a 2 ,... , an, M , is there a subset I ⊂ { 1 , 2 ,... , n} such that

i ∈ I ai^ =^ M^? The subset sum problem is N P-Complete.

  • The unary subset sum problem is defined as the subset problem except that the input numbers are in unary.

The unary subset sum problem is in P.

  • The cnfsat problem is the following: Given a Boolean formula in conjunctive normal form, is there a truth assignment to its variables that make the formula evaluate to true? The cnfsat problem is N P-Complete.
  • The 3cnfsat problem is the following: Given a Boolean formula in conjunctive normal form in which each clause has exactly three literals in it, is there a truth assignment to its variables that make the formula evaluate to true? The 3cnfsat problem is N P-Complete.
  • Evaluating a Boolean formula given a truth assignment to its variables is in P.
  1. The class CON P is the complement of the languages in N P. The class N P ∩ CON P is the class of languages L such that L ∈ N P and L ∈ CON P. Is the following statement TRUE or FALSE? Justify your answer: P ⊆ N P ∩ CON P.
  2. Show that P = N P if there is a polynomial time algorithm to transform an input formula in conjunctive normal form into an equivalent formula in disjunctive normal form. Solution: - Suppose there is a poly-time algorithm M to convert a CNF formula φ into an equivalent DNF formula ψ. Since the machine itself takes polynomial time, the new formula ψ must be of size at most O(|φ|c) where c > 0 is the exponent in the running time of M. If there is a poly-time algorithm for deciding whether a DNF formula is satisfiable, then we can apply it on ψ to decide whether it is satisfiable. Since φ and ψ are equivalent, this will constitute a poly-time algorithm for CNFSAT. Since CNFSAT is an N P-complete problem, by the argument below, we have that P = N P. - By a property of poly-time mapping reducibility, if a language A is reducible to a language B and B ∈ P then A ∈ P. Therefore, if an N P-complete problem A ∈ P then N P = P since every language in N P is reducible to A. - Finally, we descibe a poly-time algorithm for deciding DNF-satisfiability. A DNF formula ψ consists of an ‘or’ of ‘and clauses, and hence is satisfiable iff at least one of the clauses c is satisfiable. Since each clause is an ‘and’ of literals, it can be satisfied iff all literals are assigned value true. This is possible iff both x and ¬x do not occur in the same clause. Thus to check for satisfiability, we go through all the clauses c ∈ ψ and output ‘no’ iff we find a clause with complementary literals x and ¬x. Clearly this algorithm runs in polynomial time.
  3. Show that P = N P if and only if unary subset sum problem is N P-Complete.

Let P = N P. Here is a reduction from cnfsat CNFSAT to unary subset sum. Since P = N P there is a polynomial time algorithm A for cnfsat. Given a CNF Boolean formula F run the algorithm A on F. If F is satisfiable then output unary numbers a 1 , a 1 and if F is not satisfiable output two distinct unary numbers a 1 , a 2. Also, unary subset sum is in P and hence in N P, this shows that unary subset sum is N P-Complete. Let unary subsetsum be N P-Complete. Then all problems in N P are polynomial time mapping reducible to unary subset sum. Since unary subset sum is in P, all problems in N P are in P.

  1. The partition problem is the following: Given a collection of n positive integers a 1 , a 2 ,... , an, is there a subset I ⊂ { 1 , 2 ,... , n} such that

i ∈ I ai^ =^

i 6 ∈ I ai? Give a polynomial time reduction from the subset sum problem to the partition problem. Why is your reduction correct? We give a reduction from the subset sum to the partition problem that operates in polynomial time. Given an instance ({a 1 , a 2 ,... , an}, M ) of the subset sum problem, we construct an instance B = {b 1 , b 2 ,... , bn+2} where bi = ai for 1 ≤ i ≤ n, bn+1 =

1 ≤ i ≤ n ai^ +^ M^ and^ bn+2^ =^2 ·^

1 ≤ i ≤ n ai^ −^ M^ of the^ partition^ problem.

  1. Problem 7.21, page 296 of the text.

Reduction from cnfsat. Given a CNFSAT formula F output F ∧ (z ∨ ¯z) for some new variable z.

  1. The set cover problem is the following:

INPUT: A set U of n elements, a collection S 1 , S 2 ,... , Sm of subsets of U , and an integer 1 ≤ k ≤ m. PROBLEM: Is there a collection of at most k of these subsets whose union is equal to the set U? Give a polynomial time reduction from the vertex cover problem to the set cover problem. Argue why your reduction is correct. Let G(V, E) be an instance of the vertex cover problem on n vertices. We construct an instance of the set cover problem as follows:

(a) The universal set U = E i.e., the edges e ∈ E form the elements of U.

  1. The F OU RSAT problem is the following: INPUT: A Conjunctive Normal Form Boolean formula F in which every clause has exactly four literals. PROBLEM: F is satisfiable. Give a polynomial time-reduction from CNFSAT to FOURSAT.
  2. Consider the following exam-scheduling problem: You are given a list of final exams F 1 , F 2 ,... , Fk to be scheduled, and a list of students S 1 , S 2 ,... , Sm. Each student is taking some specified subset of these exams. You must schedule these exams into slots so that no student is required to take two exams in the same slot. The problem is to determine if such a schedule exists that uses only h slots. Formulate this problem as a language and give a polynomial time reduction from the k-coloring problem to the exam-scheduling problem. exam − scheduling is the set of all triples 〈F, S, h〉 where F is the set of all final exams, S is a list of subsets of finals each student is taking, and h is the number of slots into which the finals are scheduled so that no student is taking two exams in the same slot. Given a graph G = (V, E) and k output F = V , S = E, and h = k. A k coloring of G can be used to assign final exams that correspond to nodes colored the same to the same slot. Given a schedule for the final exams, we get a k-coloring of the graph G by assigning colors according to the slots of the corresponding nodes.
  3. Show that the following problem is N P-Complete:

INPUT: an undirected graph G and a clique H in G PROBLEM: H is NOT a maximum-sized clique in G. Solution: We call this problem NOT-MAX-CLIQUE(G,H). First, we show that the problem is in NP (3 points). A nondeterministic verifier V will guess a set V ′^ ⊆ V of size |H| + 1, and then check whether V ′^ forms a clique in G. If yes, then it will accept as V ′^ is a clique of size greater than H. Otherwise, it will reject. Clearly, V accepts iff H is not the maximum size clique in G. To show NP-completeness, we reduce from the CLIQUE problem. Let (G(V, E), k) be an instance of the clique problem. We make a new graph G′^ on |V | + k vertices as an instance of the above problem. G′^ consists of two disjoint graphs: the first is (a copy of) the graph G itself, and the second is H, a clique on k vertices. Now, we give (G′, H) as an instance of the NOT-MAX-CLIQUE problem. Now we proceed with the proof of correctness. First, if G has a clique of size greater than k, then G′^ will have clique of size greater than H (since |H| = k) in its own copy of G. Hence, H is not a maximum size clique in G′. Now suppose than H is not a maximum size clique in G′, and that there is a larger clique H′. But then since the larger clique H′^ should completely lie inside the copy of G in G′^ since G and H are disjoint. But then we will have a clique H′^ of size greater than k = |H| in G itself. This will form a solution to the CLIQUE problem.

  1. The 2-coloring problem is to decide if the vertices of an input graph can be colored with two colors such that adjacent vertices get different colors. Show that the 2-coloring problem is in P.
  2. Given a polynomial time algorithm to decide if a graph has a clique of size k, give a polynomial time algorithm to compute the size of a maximum clique.
  3. Given an undirected graph G = (V, E), a subset V ′^ ⊆ V is an independent set if, for every pair of vertices u, v ∈ V ′, (u, v) 6 ∈ E. Given a polynomial time algorithm to decide if a graph has an independent set of size k, give a polynomial time algorithm to compute the size of a maximum independent set.
  4. Given a complete graph G = (V, E) with non-negative integer costs on the edges of G, and an integer bound k, the traveling salesperson problem is to decide if there is a Hamiltonian cycle in G whose total cost is at most k. Suppose there is a unit-time algorithm A for the traveling salesperson problem, show how to compute the cost of an optimal tour by making O(log k) calls to the algorithm A.