Marcela Reyna
Marcela Reyna
Marcela Reyna
Computation HW Chapter 7:
7. Show that P is closed under union, concatenation, and complement.
a. UNION
For any two P languages L1 and L2, Let M1 and M2 be the TMs that decide them in
polynomial time time. We construct TM M' to recognize the union of L1 and L2 in
polynomial time.
“On input w:
1. Run M1 on w. If it accepts, accept.
2. Run M2 on w. If it accepts, accept. Otherwise reject.”
For any Polynomial timed Language P where L=L1L2, let the TM M consider all
possible partitions xy of string w.
“On input w:
1. Run M1 on x. If it accepts, accept.
2. Run M2 on y. If it accepts, accept. Otherwise, reject.”
We will show that A is NP-hard. Let L be any other language in NP. Since P=NP, we
know that L can be decided in polynomial time. Give a string w, we give a polynomial-
time computable function f such that w is an element of L if and only if f(w) is an
element of A. The function f is computed as follows. On input w, decide in polynomial
time if w is an element of L. If yes, set f(w)=w1. Else, set f(w)=w2. Clearly, w is an
element of L if and only if f(w) is an element of A. Thus, A is NP-complete. We needed
to exclude A equals empty set otherwise we would have had no candidate f(w) if w is
an element of L. Similarly, we needed to exclude A = sigma star as otherwise we
would have had no candidate f(w) if w is an element of L.
7.27 A coloring of a graph is an assignment of colors to its nodes so that no two
adjacent nodes are assigned the same color. Let 3COLOR={G| the nodes of G can be
colored with three colors such that no two nodes joined by an edge have the same
color}
Show that 3COLOR is in NP complete. (HINT: use the following three subgraphs.)
Suppose that there is a truth assignment to the variables which satisfies all of the ci. Color
each true variable with appropriate ti and color its complement false. One of its literals must
have been colored with one of the true colors since the clause is satisfied. The vertex ci can
be colored that way too since it is not connected to that literal. That makes exactly n+1 colors
for all the vertices of the graph.
If there is no truth assignment which satisfies all of the clauses, then for each of these
assignments there must be a clause (ci) which has all its literals colored with the false or
(n+1)-st color. This means that ci is connected to vertices of every true color since it is
connected to all those it does not contain. And since it is connected to all but three of the
literal vertices, it must be connected to a vertex colored false also since there are at least
three variables. Thus the graph cannot be colored with only n+1 colors.
Now, it is shown that 3-SAT £ p COLOR and therefore COLOR is NP-complete since making
the graph is done is polynomial time.