Home Algorithms

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1)

2) The answer is true. If HALTTM is polynomial time reducible to some language B


(HALTTM <=P B), then it is possible that B is polynomial-time decidable (that is, belongs
to P). This is because if HALTTM <=P B, then there exists a polynomial-time algorithm
that reduces instances of HALTTM to instances of B. Since B is polynomial-time decidable,
this algorithm can be used to solve instances of HALTTM in polynomial time as well.
3) The language L(M) of a Turing machine M is recognizable if there exists a
Turing machine that accepts all strings in L(M) and rejects all strings not in
L(M). The language L(M) is decidable if there exists a Turing machine that accepts
all strings in L(M) and rejects all strings not in L(M), and halts on all inputs 1.
Let L1 = {<M> | L(M) is recognizable} and L2 = {<M> | L(M) is decidable}. Then,
every decidable language is recognizable, but not every recognizable language is
decidable. Therefore, we have L2 ⊆ L11.
So the answer is ii. L2 ⊂ L1.

4) The language L={<M> | M is a TM and there exists w such that M halts on w in less
than |<M>| steps} is decidable. To prove this, we can construct a decider D for L as
follows:
D = "On input <M>:

1. Constructing the following TM M’ on input w: M’ = “On input w: 1. Simulate M on input


w for |<M>| steps. 2. If M halts on w within |<M>| steps, accept; otherwise, reject.”
2. Running M’ on the empty string.
3. If M’ accepts, accept; otherwise, reject."

Since M’ simulates M on input w for at most |<M>| steps, it will halt if and only if M
halts on w within |<M>| steps. Therefore, D accepts <M> if and only if L(M) is
recognizable.

5) a. L is not a decidable language. To prove this, we can use a reduction from the
Halting problem to show that L is undecidable. Suppose there exists a decider D for L.
We can construct a decider E for the Halting problem as follows:

E = "On input <M,w>:

1. Construct the following TM M’ on input x: M’ = “On input x: 1. If x = 0, run M on w. 2. If x


= 1, accept.”
2. Run D on input <M’>.
3. If D accepts, accept; otherwise, reject."

If M halts on w, then L(M’) contains an even-length string and does not contain an odd-
length string, so <M’> ∈ L. If M does not halt on w, then L(M’) contains an odd-length
string and does not contain an even-length string, so <M’> ∉ L. Therefore, E decides the
Halting problem if D decides L.

Since the Halting problem is undecidable, we have shown that L is also undecidable.

b. L is recognizable but not decidable. To see that L is recognizable, we can construct


a recognizer R for L as follows:

R = "On input <M>:

1. Construct the following TM M’ on input x: M’ = “On input x: 1. If x = 0, run M on any


even-length string. 2. If x = 1, run M on any odd-length string. 3. If M accepts or rejects
within |x| steps, accept.”
2. Run M’ on the empty string.
3. If M’ accepts, accept; otherwise, loop."
Since every TM that accepts at least one even-length word and rejects at least one odd-
length word will eventually halt when run on an even-length word or an odd-length
word (respectively), R will eventually accept every TM in L and loop on every TM not in L.

However, we cannot construct a decider for L because there is no way to determine


whether a given TM accepts at least one even-length word and rejects at least one odd-
length word in finite time.

6) The answer is True.


If language C is NP-complete and C belongs to P, then P = NP. This is because if C is NP-complete, then
every language in NP can be reduced to C in polynomial time. If C is also in P, then every language in NP
can be decided in polynomial time by first reducing it to C and then solving C in polynomial time1.
Therefore, if P = NP, then every language in NP can be decided in polynomial time. Since C is an NP-
complete language, it can also be decided in polynomial time. Therefore, if C belongs to P, then every
language in NP can be decided in polynomial time, which means that P = NP

You might also like