CSE596 Problem Set 4 Answer Key Fall 2015

advertisement
CSE596
Problem Set 4 Answer Key
Fall 2015
(A) “Groundhog Day” is a fantasy romantic comedy movie about a guy stuck in a repeating
loop of the same day until he finds a way to “accept” his life. So let’s take a Turing machine
M that halts for all inputs and, given an input x, keep trying it the repeating inputs x, xx,
xxx, xxxx,. . . . Define the “Groundhog” language
GM = {x : for some i, M accepts xi }.
Is GM necessarily decidable? Is it c.e.? What do you think? Can you see any way to prove
your answer?
Answer: The technique for most of this “preview problem” hasn’t been covered yet, but
we can “get a feel for” the issues in a way that you will often be able to expect that your
“feel” is right. The one thing that has been covered is yes you can tell that GM is c.e.
Important vocabulary note: c.e. includes decidable, so saying a language is c.e. doesn’t mean
it’s undecidable, rather that “c.e.” is all you know at this point. To design a TM M 0 such
that L(M 0 ) = GM , write a while(1) loop each of whose iterations does k++ and carries out
k steps of M (xi ) for 1 ≤ i ≤ k. If and when any of those simulations accepts within the k
steps, break the loop and accept.
This is called a “dove-tailing loop” and I will use the idea for some proofs in Chapter 3.
A shortcut, however, is you could design a nondeterministic TM N to guess i and then run
M (xi ). The NTM N then accepts x iff some guess i makes M accept xi , which is exactly
the definition of GM , so L(N ) = GM . Then convert N into an equivalent DTM M 0 such that
L(M ) = L(N ) = GM .
A further wrinkle here is that although we took M to be fixed, the simulations work equaly
well if M is a variable—that is, if its code is part of the input. We can use our universal Turing
machine U and run U (M, xi ) instead of M (xi ) directly, accepting x iff U accepts hM, xi i. The
one thing we give up is that many M ’s won’t be total anymore, but for the “is c.e.” part it
happens not to matter. So what we’ve really shown is that the more general “Groundhog”
language
G = {hx, M i : (∃i)[xi ∈ L(M )]}
is c.e. Now we can say up front that G isn’t even close to being decidable—“fuhgeddaboudit”
as they say in New York City. But when we fix just one M —and are given that M is total—
what then? So is GM decidable?
Tick-tick-tick-tick-tick. . . clock ticking. . . what’s the answer? That’s the answer. Suppose
M on input xi does i time-steps of some other TM M0 —with M0 running on its own code or
on λ or on anything, actually— and accepts only if M0 accepts within those i steps. (If x is
already a repeated word, x = y j , then M might grab the number ij instead of i, but that’s
OK.) Then M is total—regardless of whether M0 is total—because it won’t run more steps
than the length of x. But whether M accepts xi for some i is equivalent to whether M0 ever
accepts at all. This fact should give a feel of undecidability. But whether the language GM
is decidable can depend on the particular M . For some M , it’s easy—the answer might be
“yes” for any x, for instance.
The ultimate point is to find a particular M such that GM is undecidable. That’s enough
to show that GM is not always decidable. But proving undecidability for a particular M
requires a bit of “lateral thinking.” Lectures have already emphasized how a machine can
be treated as a string, but this will involve the opposite: a proof of undecidability will come
when the innocent-looking string x is treated as a machine.
(B) Find the “lie” in the following demonstration that a Turing machine M 0 with a single
one-way-infinite tape can simulate a TM M with a single two-way-infinite tape with linear
time overhead:
1. On any input x 6= λ, M 0 first shuffles spaces inside x, technically meaning that M 0
produces the ID
I = ∧x1 %x2 %x3 . . . %xn $,
. . . in O(n) time. . .
Answer: That’s the “lie”: although the task looks simple—and is simple in linear time for
a two-tape machine—I don’t think it can be done in anything less than quadratic time by a
one-tape TM. But I don’t know how to prove it either—do you?
(1) With reference to discussion problem (B)—and using ideas from the k-tapes-to-one
proof on Friday—fix the issue by not using the ID I after all. Describe your revised M 0 in
prose and show rigorously that it runs in O(n + t) time. Thus we can finally say that the two
flavors of one-tape Turing machines are equivalent not only in power but also in efficiency.
Answer: When you use the tracking idea from the proof rather than the “shuffling” idea
in (B), the essential difference is that the tape doesn’t expand—only the alphabet does:
Γ0 = (Γ ∪ {%})2 ∪ {∧, $} will do the trick. The initial routine converts x1 x2 · · · xn to
∧[x1 , %][x2 , %] · · · [xn , %]$. It can do this in one linear-time pass by blending the “shift-over”
idea in lecture with translating every char c in x to the “combo char” [c, %]. The rest of the
simulation proceeds as described in (B). As a followup question—this is the sort of thing that
might bring a few points extra credit if you think of it—can you avoid the extra step this
construction still takes when the head “crosses over” at ∧ between the tapes?
(2) Suppose A is a c.e. language, f and g are computable total functions, and B is a
language such that for all x ∈ Σ∗ , x ∈ B ⇐⇒ f (x) ∈ A, and x ∈
/ B ⇐⇒ g(x) ∈ A. Show
that B is decidable expressly by diagramming (in flowchart style) a total Turing machine MB
such that L(MB ) = B, given components MA , Mf , Mg that carry out the behavior specified
above.
Answer in words (again a drawing would be best): On input x, MB computes y = f (x) and
z = g(x). Since f and g are total computable functions this means Mf and Mg are total, so
they can be one-shot solid boxes in a diagram—no need to do any “step-by-step” with them.
But since MA need not be total—we only know that A is c.e.—we do have to do a similar
step-by-step loop with MA . Compared to the lecture example for RE ∩ co-RE = REC, instead
of stepping two complementary machines M and M 0 in parallel on the same string x, this time
we step two instances of MA on the strings y and z, respectively. The output logic is similar:
we accept x if and when MA accepts y and reject x if and when MA accepts z. Since one
of the two acceptance events by MA must happen (by the stipulations x ∈ B ⇐⇒ f (x) ∈ A
and x ∈
/ B ⇐⇒ g(x) ∈ A), MB is total and L(MB ) = B, so B is decidable.
Download