0% found this document useful (0 votes)
14 views

Assign 5 Ans

1. This document contains the suggested solutions to homework problems in the Theory of Computation course CS5371. 2. The first problem proves that if P=NP, the PATH problem is NP-complete by showing SAT can be reduced to PATH in polynomial time. 3. The second problem shows the LPATH problem is NP-complete by reducing the HAMPATH problem to it in polynomial time.

Uploaded by

Kamal Walia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Assign 5 Ans

1. This document contains the suggested solutions to homework problems in the Theory of Computation course CS5371. 2. The first problem proves that if P=NP, the PATH problem is NP-complete by showing SAT can be reduced to PATH in polynomial time. 3. The second problem shows the LPATH problem is NP-complete by reducing the HAMPATH problem to it in polynomial time.

Uploaded by

Kamal Walia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CS5371 Theory of Computation

Homework 5 (Suggested Solution)

1. Prove that if P = N P , then PATH is NP-complete.


Ans. If P = N P , we claim that every language in NP can be reduced to PATH in
polynomial time. Then, together with the fact that PATH is in NP, we have PATH is
NP-complete.
To prove our claim, we shall show SAT can be reduced to PATH in polynomial time.
Firstly, since P = N P , there exists a decider D for SAT that runs in polynomial time.
Based on this, consider the following TM F that computes a reduction f from SAT to
PATH :

F = “On input hφi,


1. Run D on hφi.
2. If D accepts hφi, construct a graph G containing two vertices s and t, with an edge
{s, t} joining them.
3. Otherwise, if D rejects hφi, construct a graph G with two isolated vertices s and t.
4. In either case, output hG, s, ti.”

It is easy to check that hφi ∈ SAT ⇔ hG, s, ti ∈ PATH. Also, the above reduction takes
polynomial time. This completes the proof of the claim.

2. Let LPATH denote the language:

LPATH = {hG, s, t, ki | G contains a simple path of length at least k from s to t}.

Ans. Firstly, LPATH is in NP because a certificate for hG, s, t, ki simply consists of the
sequence of edges in a simple path from s to t with length at least k, so that for this kind
of certificate, we can find a corresponding polynomial time DTM verifier.
To further show that every NP problem can be reduced LPATH in polynomial time,
we shall reduce HAMPATH to LPATH. Consider the following TM F that computes a
reduction f from HAMPATH to LPATH :

F = “On input hG, s, ti,


1. Output hG, s, t, n − 1i, where n is the number of vertices in G.”

Firstly, if there is a hamiltonian path from s to t in G, the path would have length n − 1
so that hG, s, t, n − 1i is in LPATH. On the other hand, if hG, s, t, n − 1i is in LPATH, the
simple path from s to t has length n − 1, so that it must be hamiltonian. Thus,

hG, s, ti ∈ HAMPATH ⇔ hG, s, t, n − 1i ∈ LPATH.

Also, it is obvious that the above reduction runs in polynomial time. This implies HAM-
PATH is polynomial-time reducible to LPATH. Thus, LPATH is NP-complete.

1
3. Let S be a finite set and C = {C1 , C2 , . . . , Ck } be a collection of subsets of S, for some
k > 0. We say S is two-colorable with respect to C if we can color the elements of S in
either red or blue, such that each subset Ci contains at least a red element and at least a
blue element.
Let 2COLOR denote the language:

2COLOR = {hS, Ci | S is two-colorable with respect to C}.

Show that 2COLOR is NP-complete.


Ans. It is easy to show that 2COLOR is in NP (how?). To show that every NP language
can be reduced to 2COLOR in polynomial time, we shall use reduction from 6=SAT.
Consider the following TM F that computes a reduction from 6=SAT to 2COLOR:

F = “On input formula hψi,


1. For each variable x in ψ, create two variables sx and s0x in S.
Also, create a subset {sx , s0x } of C.
2. For each clause γi in ψ, create a subset ci of C such that
(i) if x ∈ γi , sx ∈ ci ;
(ii) if ¬x ∈ γi , s0x ∈ ci .
3. Output hS, Ci.”

Firstly, if there is a satisfying not-all-equal assignment (say, A) for ψ, it is easy to obtain


a 2-coloring for the variables in S as follows: If x is assigned true in A, we color sx to red
and s0x to blue; otherwise, we color sx to blue and s0x to red. Under this coloring, each
subset {sx , s0x } must contain 2 colors, while each subset ci also contains 2 colors (because
γi is not-all-equal under the assignment A). Thus, hS, Ci is in 2COLOR.
On the other hand, if hS, Ci is in 2COLOR, we can obtain a satisfying not-all-equal as-
signment for ψ as follows: Fix a 2-coloring scheme for hS, Ci. If sx is colored red, assign x
to true in ψ. Otherwise, assign x to false. Since ci contains two colors, the corresponding
clause γi in ψ must be not-all-equal under the above assignment. This implies that every
clause in ψ will be not-all-equal, so that ψ has a satisfying not-all-equal assignment.
In summary, we have

hψi ∈ 6=SAT ⇔ hS, Ci ∈ 2COLOR.

Also, the above reduction takes polynomial time to run. Thus, 6=SAT ≤P 2COLOR, so
that 2COLOR is NP-complete.

4. (Further Studies: No marks) Let φ be a cnf-formula. An assignment to the variables of φ


is called not-all-equal if in each clause, at least one literal is TRUE and at least one literal
is FALSE.
Let 6=SAT be the language:

6=SAT = {hφi | φ is a cnf-formula which has a satisfying not-all-equal assignment}.

Show that 6=SAT is NP-complete.

2
Ans. It is easy to check that 6=SAT is in NP. It remains to show that every NP language
is polynomial-time reducible to 6=SAT. To do so, we shall reduce CNF-SAT to 6=SAT.
Before that, we first notice that for any formula φ, if A is a satisfying not-all-equal assign-
ment, then the negation of A is also a satisfying not-all-equal assignment.1 For instance,
let
φ = (x ∨ y ∨ z) ∧ (¬x ∨ ¬y ∨ ¬z) ∧ (x ∨ y ∨ ¬z).
Then, A = (x = 0, y = 1, z = 0) is a satisfying not-all-equal assignment. On the other
hand, the negation of A, which is (x = 1, y = 0, z = 1), is also a satisfying not-all-equal
assignment.
Now, the reduction is as follows. Let
Ci = (x1 ∨ x2 ∨ · · · ∨ xk )
be the ith clause in an instance of CNF-SAT. We shall replace clause Ci with two clauses
Di = (x1 ∨ x2 ∨ · · · ∨ xk−1 ∨ zi ) and Ei = (¬zi ∨ xk ∨ b),
where zi is a new variable corresponding to Ci , and b is a global variable shared by other
Dj ’s and Ej ’s.
Let φ be the original cnf-formula, and ψ be the transformed cnf-formula. First, if the
original formula φ is satisfiable, it is easy to obtain a satisfying not-all-equal assignment
for the transformed formula ψ as follows:
(a) Use the same assignment for the variables that appear in φ;
(b) For clause Di , set zi = ¬(x1 ∨ x2 ∨ · · · ∨ xk−1 );
(c) Set b to be false;
Under this assignment, for each i, the clause Di must be not-all-equal. Also, we know that
either xk is true or (x1 ∨ x2 ∨ · · · ∨ xk−1 ) is true (why?). The latter case implies that zi
is false. Then, in both cases, we know that Ei must be not-all-equal (because b is set to
false). Thus, hφi is in CNF-SAT implies hψi is in 6=SAT.
On the other hand, if hψi is in 6=SAT, let A be a satisfying not-all-equal assignment for
ψ. If b is set to false in A, we claim that with the same assignment for the variables that
appear in φ, φ will become satisfied. Consider Ci : if xk is true, Ci is satisfied immediately.
Otherwise, we know that Ei is not-all-equal, so that zi is true. In this case, ¬zi is false in
Di so that (x1 ∨ x2 ∨ · · · ∨ xk−1 ) must be true. This in turn would imply Ci is satisfied in
φ. In summary, if b is set to false in A, then φ is satisfiable.
Next, if b is set to true in A, we know that the negation of A is also a satisfying not-all-
equal assignment for ψ. Then, we can proceed with the same reasoning and show that φ
is also satisfiable (using the negated assignment).
Thus, hψi is in 6=SAT implies hφi is in CNF-SAT, so that
hφi ∈ CNF-SAT ⇔ hψi ∈ 6=SAT.
Finally, the reduction takes polynomial time to run, so that we have proven CNF-SAT ≤P
6=SAT. This completes the proof.
1
The proof is very straightforward: a literal is assigned true in A if and only if it is assigned false in the
negation of A. Since A guarantees each clause has at least one false, the negation of A thus guarantees each
clause has at least one true so that it is also satisfying. Moreover, A guarantees each clause has at least one true,
so that the negation of A guarantees each clause must be not-all-equal.

You might also like