Solutions Practice Set Reductions
Solutions Practice Set Reductions
Question 1: A 2-CNF formula is a CNF formula where each clause consists of at most 2 literals. The
MAX-2-SAT problem is: given a 2-CNF formula φ and a number k, is there an assignment that satisfies
at least k clauses of φ? Show that MAX-2-SAT is NP-complete. [Hint: Try a reduction from 3-SAT. For
each 3-CNF clause involving 3 variables, give a set of ten 2-CNF clauses on 4 variables such that if the
3-CNF clause is satisfiable, then 7 of the 2-CNF clauses can satisfied whereas otherwise, only at most 6
of the 2-CNF clauses can. ]
Answer: First we note that if a truth setting of the variable makes at least k clauses true, then by
substituting these truth values we can efficiently check the truth or falsity clause by clause, keeping a
counter to hold the number of clauses found to be true so far. Hence MAX-2-SAT is in NP.
The following is a reduction from 3SAT to MAX-2-SAT. That is, given an instance of 3SAT we
construct an instance of MAX-2-SAT so that a satisfying truth assignment of 3SAT can be extended to
a satisfying truth assignment of MAX-2-SAT. Note that a satisfying truth assignment is one that makes
at least k clauses true in the MAX-2-SAT instance.
Let S be the instance of 3SAT where the clauses are C1 , ..., Cm where Ci = {xi , yi , zi }, where each
xi , yi , and zi represents either a variable or its negation and 1 ≤ i ≤ m. From S we build an instance S 0
of MAX-2-SAT as follows. Each Ci in S corresponds to a clause group Ci0 in S 0 where,
Ci0 = {(wi ), (xi ), (yi ), (zi ), (xi + yi ), (yi + zi ), (xi + zi ), (wi + xi ), (wi + yi ), (wi + zi )}
where wi is a new variable and 1 ≤ i ≤ m. We set k = 7m
Each clause in S 0 as constructed above has at most two literals. It can be seen that the clauses in S 0
can be efficiently generated from the clauses in S in polynomial time. We now argue that a satisfying
truth assignment of S exists if and only if it can be extended to a satisfying truth assignment for S 0
appropriately.
Assume that S is satisfiable. Then in a typical clause Ci = {xi , yi , zi } either one or two or all the
three variables are true.
1
Question 2: Consider the Max-Clique problem: Given an undirected graph G = (V, E) and an
integer k decide whether there exists a clique of size at least k in G (i.e., as a subgraph of G). Show
that Max-Clique problem is NP-complete. [Hint: Try a reduction from the Maximum Independent Set
problem.]
Answer: It suffices to show (a) the Max-Clique problem is in NP, and (b) Maximum Independent Set problem(IS) ≤p
Max-Clique problem(CP ).
To show (a), given a graph G and a positive integer k, we should be able to verify the certificate in
polynomial time. The certificate is a subset V 0 of the vertices, which comprises the vertices belonging to
the clique. We can validate this solution by checking that each pair of vertices belonging to the solution
are adjacent, by simply verifying that they share an edge with each other. This can be done in polynomial
time.
To show (b), let G = (V, E) and (G, k) ∈ IS then,
(G, k) ∈ IS ⇐⇒ G as independent subset of size at least k
⇐⇒ G has a clique of size at least k
⇐⇒ (G, k) ∈ CP
Therefore, any instance of the clique problem can be reduced to an instance of the Independent Set
problem. Therefore, Max-Clique problem is NP-complete.
Question 3: The circuit satisfiablity problem is: Given a circuit with boolean gates (AND, OR, and
NOT) with several input wires and one input wire, decide if there is an input that makes the output be
true.
Give a poly-time reduction from circuit satisfiability to CNF-SAT. [Hint: For each gate k introduce a
new variable xk . Then create a sub-formula for each gate. e.g. Suppose for k-th gate the input wires are
from (output wire of) i and j-th gate. Then the sub-formula will be (xk ∨ xi ) ∧ (xk ∨ xj ) ∧ (xk ∨ xi ∨ xj ).
Similarly define sub-formulas for OR and NOT gates.]
Answer: We will need to add new variables. Suppose the circuit C has m gates, including input gates,
then we introduce new variables x1 , ..., xm , with the intended meaning that variable xj corresponds to
the output of gate j.
We make a formula F which is the AND of m + 1 sub-expression. There is a sub-expression for every
gate j, saying that the value of the variable for that gate is set in accordance to the value of the variables
corresponding to inputs for gate j.
We also have a (m + 1)-th term that says that the output gate outputs 1. There is no sub-expression
for the input gates.
For a gate j, which is a NOT applied to the output of gate i, we have the sub-expression
(xi ∨ xj ) ∧ (xi ∨ xj )
For a gate k, which is an AND applied to the output of gates i and j, we have the sub-expression
(xk ∨ xi ) ∧ (xk ∨ xj ) ∧ (xk ∨ xi ∨ xj )
We have a similar sub-expression for OR gate.
We now have to show that this reduction works.Suppose C is satisfiable, then consider setting xj
being equal to the output of the j-th gate of C when a satisfying set of values is given in input. Such a
setting for x1 , ..., xm satisfies F .
Suppose F is satisfiable, and give in input to C the part of the assignment to F corresponding to
input gates of C. We can prove by induction that the output of gate j in C is also equal to xj , and
therefore the output gate of C outputs 1.
So C is satisfiable if and only if F is satisfiable.
Question 4: Give a poly-time reduction from CNF-SAT to 3-SAT. [Hint: For the clauses with more
than three literals try to write them as AND of several clauses by introducing new variables.]
Answer: Take a formula F of CNF-SAT. We transform it into a formula F 0 of 3-SAT such that F 0 is
satisfiable if and only if F is satisfiable.
Each clause of F is transformed into a sub-expression of F 0 . Clauses of length 3 are left unchanged.
A clause of length 1, such as (x) is changed as follows,
2
(x ∨ y1 ∨ y2 ) ∧ (x ∨ y1 ∨ y 2 ) ∧ (x ∨ y 1 ∨ y2 ) ∧ (x ∨ y 1 ∨ y 2 )
where y1 and y2 are two new variables added specifically for the transformation of that clause.
A clause of length 2, such as (x1 ∨ x2 ) is changed as follows
(x1 ∨ x2 ∨ y) ∧ (x1 ∨ x2 ∨ y)
where y is a new variable added specifically for the transformation of that clause.
For a clause of length k ≥ 4, such as (x1 ∨ ... ∨ xk ), we change it as follows
(x1 ∨ x2 ∨ y1 ) ∧ (y 1 ∨ x3 ∨ y2 ) ∧ (y 2 ∨ x4 ∨ y3 ) ∧ ... ∧ (y k−3 ∨ xk−1 ∨ xk )
where y1 , ..., yk−3 are new variables added specifically for the transformation of that clause.
We now have to prove the correctness of the reduction,
For reductions from length 1 and 2, we can construct the truth table and show that all instances
where F is true the output of F 0 is true, and all instance of false are false.
For reductions from length 4 and above, When F is satisfiable, at least one literal in x1 , ..., xk is true.
If any one of x1 or x2 is True; set all additional variables y1 , ..., yk−3 to False. Now, first clause of all
literals in F 0 becomes True, therefore F 0 has a satisfying assignment.
If any one of xk−1 or xk is True, set all additional variables y1 , ..., yk−3 to True. Now, last clause of
all literals in F 0 becomes Trues, therefore F 0 has a satisfying assignment.
If any other literal is true, xi where i ∈ / {1, 2, k − 1, k}. Now if we make y1 , ..., yi−2 True and make
yi−1 , ..., yk−3 False, we satisfy all the clauses in F 0 . Therefore, there is a satisfying assignment.
For an assignment which makes F false, all literals in x1 , ..., xk has to be false. In such a case there is
no assignment of y1 , ..., yk−3 which will make F 0 true. Therefore, all instances where F is false F 0 is also
false.
Therefore, F 0 is satisfiable if and only if F is satisfiable.