Assign 3 Ans
Assign 3 Ans
Homework 3 (Solution)
1. Show that single-tape TMs that cannot write on the portion of the tape containing the
input string recognize only regular languages.
Answer: Let M = (Q, Σ, Γ, q0 , qaccept , qreject ) be a single-tape TM that cannot write on the
input portion of the tape. A typical case when M works on an input string x is as follows:
the tape head will stay in the input portion for some time, and then enter the non-input
portion (i.e., the portion of the tape on the right of the |x|th cells) and stay there for some
time, then go back to the input portion, and stay there for some time, and then enter the
non-input portion, and so on. We call the event that the tape head switches from input
portion to non-input portion an out event, and the event that the tape head switches from
non-input portion to input-portion an in event.
Let firstx denote the state that M is in just after its first “out” event (i.e., the state of M
when it first enters the non-input portion). In case M never enters the non-input portion,
we assign firstx = qaccept if M accepts x, and assign firstx = qreject if M does not accept x.
Next, we define a characteristic function fx such that for any q ∈ Q, fx (q) = q 0 implies that
if M is at state q and about to perform an “in” event, the next “out” event will change M
in state q 0 ; in case M never enters the non-input portion again, we assign fx (q) = qaccept if
M enters the accept state inside the input portion, and qreject otherwise.
It is easy to check that if for two strings x and y, if firstx = firsty and for all q, fx (q) = fy (q),
we have x and y are indistinguishable by M . (That is, M accepts xz if and only if M
accepts yz.) As there are finite choices of firstx and fx (precisely, |Q||Q|+1 such choices),
the number of distinguishable strings are finite. By Myhill-Nerode theorem, the language
recognized by M is regular.
D = “On input w:
/ {0, 1}∗ , reject.
1. If w ∈
2. Else, w is equal to si for a specific i.
3. Use E to enumerate hM1 i, hM2 i, . . . until hMi i.
4. Run Mi on input w.
5. If Mi accepts, reject. Otherwise, accept.”
†
The question seems strange at the first glance. In fact, it is asking you to prove that the language consisting
of all descriptions of Turing deciders is not Turing-recognizable.
1
Clearly, D is a decider (why??). However, D is different from any Mi (why??), so that hDi
is not in A.
3. Let E = {hM i | M is a DFA that accepts some string with more 1s than 0s}. Show that
E is decidable. (Hint: Theorems about CFLs are helpful here.)
Answer: Let A = {x | x has more 1s than 0s}. The language A is context-free, as we can
easily construct a PDA to recognize A. Now, we construct the TM M below to decide E
as follows:
5. (Bonus Question) Show that the problem of determining whether a CFG generates all
string in 1∗ is decidable. In other words, show that {hGi | G is a CFG over {0, 1} and 1∗ ⊆
L(G)} is a decidable language.
Answer: Please discussed the solution with Yu-Han directly.