Вы находитесь на странице: 1из 3

CS 531 --- Theory of Computation --- HW01

Spring 2015

Read Chapter 3 of Sipser.

1. Let L L(M ) Accept (M ) for some dtm M. For M it is possible that Reject (M )
as well as Loop(M ) . Explain how to modify M to obtain a dtm M such that
L(M ) L(M ), but Reject (M ) . Such a machine M is said to reject by looping.
2.
3.
4.
5.

Sipser, Problem 3.11.


Sipser, Problem 3.15, parts d, e.
Sipser, Problem 3.16, parts b, d.
Sipser, Problem 3.18.

6. Draw a transition diagram of a dtm accepting the language ss s {a, b} and has no
tape symbols other than a, b.

Can use a 2-way infinite tape, see Problem 2 above.

7. Describe a non-deterministic TM for the language L 0 n1 y x y x 2 (mod n) .


You need not give the state-transition function for this TM; just give a clear sketch in
English of what the machine does, and point out the major components of its
computation.
Solutions:
1. Solution. A dtm rejects a string without looping if it halts (no transition is defined) in a
non-accepting state. Add a new state and for any q Q and A such that (q, A) is
undefined, redefine: (q, A) ( ,

, S ) and furthermore (,

) (, , S ). In other words,

the dtm, instead halting and rejecting will enter the new state and loop forever without
reading anything and without moving its head.
2. Solution. To prove that the Turing machines with a doubly infinite tape (DITMs)
recognize the class of Turing-recognizable languages we must show that the set
REDITM = {A | there exists a DITM M such that L(M) = A}
is equal to the set
RE = {A | there exists a TM M such that L(M) = A}.
First we show that REDITM is a subset of RE. Let M be a DITM. We want to show that
there exists a TM that simulates M. Let M be a Turing machine with two tapes that starts by
taking the input string and placing it on the first tape while keeping its second tape empty. As
M runs, if the first tape head moves to the left of the first tapes first cell, then the second

head will take over and continue the simulation on the second tape except that the directions
for the second tape head are now reversed. Likewise, if the second tape head moves to the
left of the second tapes first cell, then the first tape head continues the simulation. Thus
L(M) = L(M). Since we know that the set of Turing machines can simulate any two-tape
TM, we conclude that there exists a TM that simulates M.
Now we show that RE is a subset of REDITM. Let M be a TM. We want to show that there
exists a DITM that simulates M. Let M be a DITM that starts by placing a special symbol on
the cell immediately to the left of the input string. Whenever the tape head moves onto the
cell with this special symbol, it immediately moves to the right. This effectively restrains M
from moving to the left of the input string. Therefore, there exists a DITM that simulates M.
3. Solution.
(d) Let A be a decidable language. Therefore, there exists a TM M such that L(M) = A
and M always halts. Now let M be a TM that takes its input w and simulates M on w. If M
accepts, then M rejects. Likewise, if M rejects, then M accepts.
(e) Let A and B be decidable languages. Therefore, there exist TMs M and M such that
L(M) = A, L(M) = B, and both M and M always halt. Let M* be a TM that takes its input w
and simulates M on w and then simulates M on w. If both M and M accept, then M* accepts.
If either M or M reject, then M* rejects.
4. Solution.
Let A and B be Turing-recognizable languages. Therefore, there exist TMs M and M
such that L(M) = A and L(M) = B.
(b) Let M* be a NTM that takes its input w and guesses (nondeterministically) two
strings x and y such that w = xy. M* then proceeds to simulate M on x. If M rejects x then M*
will also reject, but if M accepts x then M* continues by simulating M on y. If M rejects y
then M* will also reject, but if M accepts y then M* also accepts.
(d) Let M* be a TM that takes its input w and simulates M on w. If M rejects w then M*
will reject, but if M accepts w then M* proceeds to simulate M on w. If M rejects w then M*
will reject, but if M accepts w then M* accepts.
5. Solution. First we show that if a language is decidable then there is some enumerator
that enumerates the language in the standard string order. Let M be TM that decides a
language. The enumerator simulates M on every string, one at a time, in standard string
order. The enumerator outputs every string that M accepts. Thus the strings of Ms language
are output by the enumerator in standard string order.
Now we show that if some enumerator enumerates a language in the standard string
order then the language is decidable. Let E be an enumerator that enumerates a language in
standard string order. We must consider two cases:
Case 1: The language enumerated is finite. The language is trivially decidable.

Case 2: The language enumerated is infinite. We design a TM M that takes an input w.


M proceeds by simulating E. If at any point during the simulation E outputs w, then M will
accept. However, if E eventually outputs a string whose length is strictly greater than w, then
M will reject.
6. Solution idea: Find the middle of the input string by moving symbol from the right side
one place to the right, inserting a blank symbol instead and going to the left side and,
similarly, moving one symbol to the left while inserting a blank. Repeat until the tape content
will be

where

stands for the blank symbol and x y . Compare

the two strings x and y , ACCEPT if they are equal and REJECT otherwise.
7. Description: The ntm first (nondeterministically) generates a sequence of 1s that should
be thought of as a guess of a value of x (in unary notation) that is a candidate to satisfy
y x 2 (mod n). Then it squares this number to produce x 2 (still in unary). Then,
(a) the dtm computes the remainder of x 2 divided by n (n is given in the input),
(b) similarly, the dtm computes the remainder of y divided by n (y is given in the input)
(c) if the two values computed in (a) and (b) are the same, ACCEPT, else REJECT.

Вам также может понравиться