Sie sind auf Seite 1von 3

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.”

M' accepts w is either M1 or M2 accepts it. If both reject, M' rejects.


b. CONCATENATION
To prove polynomial Language P is closed under concatenation, the TM M (for L=L1L2)
considers all possible partitions xy of string w, runs TM M1(of L1) on x and TM M2 (of
L2) on y and accepts if and only if both accept for some partition w=xy.

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.”

M accepts w if and only if both M1 and M2 accept some partition w=xy.


c. COMPLEMENTATION
For any Polynomial Time Language L1, let M1 be the TM that decides them in
polynomial time. We construct a TM M' that decides the complementation of L1 and
L2:
“On input w:
Run M1 on w. If it accepts, reject.
If it rejects, accept.”
Because it is a complement, every time the machine accepts, we will do the opposite,
so we will reject and vice versa.
7. Show that NP is closed under union and concatenation.
a. UNION
For any two NP languages L1 and L2, Let M1 and M2 be the NDTMs that decide them in
polynomial time time. We construct NDTM 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.”

M' accepts w is either M1 or M2 accepts it. If both reject, M' rejects.


b. CONCATENATION
To prove NP is closed under concatenation, the NDTM M (for L=L1L2) considers all
possible partitions xy of string w, runs TM M1(of L1) on x and TM M2 (of L2) on y and
accepts if and only if both accept for some partition w=xy.
For any NP Language where L=L1L2, let the NDTM 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.”

M accepts w if and only if both M1 and M2 accept some partition w=xy.


7.10 Show that ALLdfa is in P.
ALLdfa is the set of every language that is deterministically computed, in other words,
there is always a finite number of steps to be computed and the machine never has to
make any decisions, it always knows its next state. The class P is defined as a class of
languages that are decidable in polynomial time on a deterministic single tape Turing
machine. So, given a TM where we run an input string w, if it is accepted as decidable in
polynomial time, then it is Deterministic and therefore in Class P.

Modification of Theorem 4.1


M= “On input<B,w>, where B is a DFA and w is a string:
1. Simulate B on input w.
2. If the simulation ends in an accept state, accept. If it ends in a non-accepting state,
reject.”
If input is accepted, then it is in class P, else it is not in class P.
7.17 Show that, if P=NP, then every language A is an element of P, except A=empty set
and A=sigma*, is NP Complete.
Assume P=NP
Let A be any language in NP such that A does not equal empty set and A does not equal
sigma star. Thus, there exists strings w1, w2 which are elements of sigma star such that
w1 is an element of A but w2 is not an element of A.

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.)

We prove 3COLOR is NP complete


Construction of a graph which can be colored with n+1 colors.
• Make all variables {v1, ... , vn} and their complements vertices of the graph.
• Connect each variable to its complement, each one must be colored differently, so each
pair has a true and false.
• Make the true colors to be different from each other.
• Create a new set of vertices called {x1,...,xn} and have them all connected to each other.
• The n xi's now form a clique.
• Connect each xi to each vj and their complements except with i=j.

Reduce 3-SAT to COLOR


Add a vertex for each clause and name them c1, ... , cr. Connect each of them to all the
variables and their complements except for the three literals which are in the clause. We now
have the following edges in our graph for all i and j between 1 and n, and k between 1 and r.
All the true variables must be different because the xi's form a clique. So, all the ci's are
connected to all the non ci's.

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.

Das könnte Ihnen auch gefallen