You are on page 1of 5

COL352 Homework 4

Release date: April 19, 2021 Deadline: April 26, 2021: 23:00

Homework by:
Pratik Pranav - 2018CS10368
Sarthak Behera - 2018CS10384
Shreyans Nagori - 2018CS10390

Read the instructions carefully.

How to describe Turing Machines: Describing a Turing Machine can often be tricky: it’s hard to strike
the right balance between rigor and understandability. Here are a few ways Turing Machines can be described
(inspired from Section 3.3 of Sipser’s book).
1. Formal definition: Define all the components (Q, Σ, Γ, δ, q0 , , qacc , qrej ) mathematically. Except for
some simple Turing Machines, this gets extremely messy and hard to comprehend for a human.
2. Implementation description: Write a sequence of steps, possibly enclosed in loops, so that a Turing
machine can do the task of each step in a single, mostly-forward or mostly-backward pass. A mostly-
forward (resp. mostly backward) pass is a sequence of transitions where the head moves right (resp.
left), except for a constant number of transitions (that is independent of the length of the tape’s
content). Feel free to “call” other Turing Machines and to “abort” a call (if it takes too long to
complete). If using more than one tape (but a constant number of tapes) and nondeterminism helps
simplify the description, do so and specify your choice upfront. While designing Turing machines with
more than one tape, explain the purpose of each tape (eg. “We store the value of variable v on tape
2”).
3. High-level description: This is just an algorithm – like the ones you wrote in COL106 or COL351.
We rely on the Church-Turing thesis which states that any such algorithm can be turned into a Turing
Machine.
Unless specifically asked to define some Turing Machine formally, you should prefer writing an implementa-
tion description or a high-level description. For the purpose of this homework, stick to implemen-
tation descriptions.

1. [1 mark] We proved in class that the language ETM = {w | L(Mw ) = ∅} is unrecognisable. (Here Mw
denotes the Turing machine whose description is w.) Prove that ETM is recognisable.

Note that we have ETM = {hM i | L(M ) 6= ∅}. (I prefer to use hM i in place of w and denote TM as
M instead of Mw . This is more intuitive to me and also the standard notation according to Sipser.)
So we have to check non-emptiness of any arbitrary language M . To check that, we somehow have
to run all strings in Σ∗ and check if any of the strings are accepted by M . We also observe that the
number of strings in Σ∗ is countable (as discussed in class) and thus we can establish a bijection
with the natural numbers, i.e., we can number the strings such that {s1 , s2 , s3 , s4 , ...} is the set of
all strings in Σ∗ . But if we run the strings one-by-one then there might be a string sk which may
not halt on the machine M thus blocking any string sl (l > k) from running on the TM M . So we
sort of design an incremental algorithm which limits the number of steps to run on machine M and
ensure that all strings get their chance to run on M . We design a new TM S such that, at the i-th
iteration we run s1 , s2 , ..., si for i steps and continue the iterations until we accept any string sk .
Note that, if we don’t have any string belonging to M , then we simply go on computing through the
iterations without halting or we say that the machine M doesn’t halt (or diverges). So we either
accept the TM M or we don’t halt on it (without rejecting any TM M ). Formally, we have the TM
S as:

Turing Machine S: (input hM i)


For i = 1, 2, ...:
1. Run s1 , s2 , ..., si for i steps on M .
2. If any of the strings is accepted by M in the i steps then accept hM i.

We see that TM S recognises ETM thus we are done.

2. [1 mark] An enumerator is a 2-tape DTM connected to a printer. One of its tapes is called the
“work tape” and the other is called the “print tape”. The enumerator has a special state qprint . The
computation of an enumerator proceeds just like a usual 2-tape DTM, except that it starts with both
tapes being empty, and whenever the enumerator enters state qprint , the (non-blank) content of the print
tape is sent to the printer. A language L is said to be enumerable if there exists an enumerator E such
that
• For every x ∈ L, E prints x at least once.
• For every x ∈
/ L, E never prints x.

Prove that a language is enumerable if and only if it is recognisable. For the ‘if’ part, the following
observation might be useful. An enumerator with k work tapes can be simulated by an enumerator with
one work tape, just like a k tape Turing machine can be simulated by a single tape Turing machine. You
should be able to prove this, although you don’t have to give the proof in the homework. Proving one
direction of the ‘if and only if’ is harder than the other. A correct proof of the harder direction gets the
one mark.

First consider proof in forward direction, that is any language that is enumerable is recognisable.
Let L be a language that is enumerable, that is ∃ an enumerator E such that L = { w k w is printed
atleast once by E during simulation }. We aim to construct a turing machine M such that L(M) =
L, that is language accepted by M is L. This machine is easy to construct, let M be:

Turing Machine M(Given Enumerator E and word w):


1. M starts simulating E.
2. Whenever E prints a word w’, check if w’ = w.
3. If yes, then accept w’.
4. Else continue simulation.

This simple turing machine accepts w iff it is printed by E at some point of time, and thus only if w
∈ L. Thus L(M) = L. Hence we have proven forward direction. Now consider the backward direction.

Now consider a turing machine M such that M(L) = L. We aim to construct an enumerator E
such that N(E) = L (N(E) denotes set of words printed by E atleast once). Now we know the set
of strings over a given Σ is countable, and thus lexicographically orderable. Let wi be the ith word
in lexicographic ordering. We simulate the enumerator E as:

Enumerator E:
For i = 1,2,...
For j in 1 to i:
Simulate wj on M for ≤ i steps, it M accepts then print wj .

We see that for iteration i of main loop it takes atmost i2 time, and that any word wj which
is accepted by M in x steps is printed by max(j,x) iterations, and thus every string accepted by M
is eventually printed by E after O(max(j,x)3 ). Hence we have proven the reverse direction as well,
and thus a language is recognisable iff the language is turing recognisable.

3. [1 mark] A two-stack Nondeterministic Pushdown Automaton (2-NPDA) is like an NPDA, except that
it has two stacks. In every transition a 2-NPDA reads 0 or 1 input symbols, pops 0 or 1 symbols from
each stack, changes state, and pushes 0 or 1 symbol on each stack. (The transition relation ∆ is a subset
of Q × Σε × Γ2ε × Q × Γ2ε , where Q is the state space, Σ the input alphabet, and Γ the stack alphabet.)
Prove that if a language is Turing-recognisable if and only if it is recognised by a 2-NPDA. Proving one
direction of the ‘if and only if’ is harder than the other. A correct proof of the harder direction gets the
one mark.
First consider the forward direction proof, that is a turing recognisable language can be recognised by
a 2-NPDA. We know that a turing machine’s transition state is given by δ : Q {qacc , qrej }×Γ ⇒ Q×
Γ × {L, R}. Given TM M defined by (Q, Σ, Γ, δ, q0 , , qacc , qrej ), where is the blank symbol, we con-
struct a 2-NPDA P which can simulate M. Let state space of P be Q’ = {qpreprocess1 , qpreprocess2 }∪Q
with initial state q00 = qpreprocess1 . where we have added the preprocess states to ensure we have
added string gets added to right stack from top to bottom.
First comes the preprocessing part, where P reads the entire string in its say left stack, and empties
the string in left stack in right stack. Due to LIFO ordering in stack, we see that the right stack
has the leftmost character at the top, and the rightmost character at top. The first preprocess state
ensures that the string is read in left stack, and the second preprocess state ensures that the string is
transferred from left to right stack as specified above. Let (qpreprocess1 , a, (, ),qpreprocess1 ,(a,))∈
∆, ∀ a ∈ Σ for adding character to left stack, (qpreprocess1 , , (, ),qpreprocess2 ,(,)) ∈ ∆ for making
non deterministic transition to second preprocessing state once entire string is appended to left
stack, (qpreprocess2 , , (a,),qpreprocess2 ,(,a))∈ ∆, ∀a ∈ Σ for transferring to right stack and finally
(qpreprocess2 , , (, ),q0 ,(,)) where q0 is initial state of Turing machine M for starting simulation
part.
In simulation, for each transition of form (q1 ,c) → (q2 ,d,L) we add to ∆ (q1 , , (,c),q2 ,(,d)), and
for each transition we add (q1 ,c) → (q2 ,d,R) we add to ∆ (q1 , , (,c),q2 ,(d,)). This simulates tran-
sition as on turing string. Set accepting state of 2-NPDA as the accepting state of M. We can see
this 2-NPDA effectively simulates a turing machine by keeping track of left and right halves relative
to current position in 2 different stacks at any time and updating for each transition accordingly
after storing strings in preprocessing step. Hence our forward direction is proven.

Now the reverse direction proof is trivial. Consider a 3 tape non-deterministic turing machine
M with input string s with 2 empty tapes corresponding to the stack of the 2-NPDA P, and simu-
late all transitions for each stack on each tape non-deterministically exactly as they are simulated
on stack. Also as we know that there exists a deterministic Turing machine M’ equivalent to M,
we can see that M’ can simulate P, and thus backward direction holds as well. Hence a language is
Turing-recognisable if and only if it is recognised by a 2-NPDA.

4. Consider the language L = {w | the Turing machine Mw is a decider}. Using mapping reductions, prove
the following statements.
1. [1 mark] L is unrecognisable.
2. [1 mark] L is unrecognisable.
(Note that L is different from the language {w | the Turing machine Mw recognises a decidable language}.
Rice’s Theorem applies to the latter, but not to the former. Moreover, the version of Rice’s Theorem
discussed in class lets you claim undecidability only.)
1. We know that, ALLT M is not a turing-recognisable language. We will describe a reductive
mapping from ALLT M to L using a computable function and use the property that If L1 ≤M L2
and L1 is not a turing recognisable language, then L2 is also not a turing recognisable language.

Claim: ALLT M ≤M L.
We will construct a computable function f , that takes as input w and and produces an output
0
w such that Mw accepts all strings over its input alphabet ⇔ Mw0 is a decider.
Input: w
• Construct a TM Mw0 that on input x does the following
– runs forever if Mw rejects x.
– accepts x if Mw accepts x.
Output: w0

Proof of Correctness:
Now,
Mw accepts all string over its input alphabet =⇒ Mw0 accepts x =⇒ Mw0 halts and decides.
Mw reject x =⇒ Mw0 doesn’t halts and hence doesn’t decides.

Thus, Mw accepts all strings over its input alphabet ⇔ Mw0 is a decider.
Hence, L is not turing-recognisable.

2. We know that, HALT is not a turing-recognisable language. We will describe a reductive map-
ping from HALT to L using a computable function and use the property that If L1 ≤M L2
and L1 is not a turing recognisable language, then L2 is also not a turing recognisable language.

Claim: HALT ≤M L.
We will construct a computable function f , that takes an input < M, w > and produces out
0
w such that M does not halts on w ⇔ Mw0 is not a decider.

Input: < M, w >


• Construct a TM Mw0 that on input x which imitates the result of simulation of w on Mw
that is, it simulation halts, it halts, else if simulation does not halts, it does not halt as
well.
Output: w0

Proof of Correctness:
Now,
Mw halts on w =⇒ Mw0 halts on x
Mw does not halts on w =⇒ Mw0 does not halts on x
0
Thus, < M, w > produces out w such that M does not halts on w ⇔ Mw0 is not a decider.
Hence, L is not turing-recognisable.

5. [1 mark] After an exhausting day of finishing and submitting homeworks (including COL352, of course),
Alice falls into deep sleep, and in her dream, finds herself in Wonderland. She finds that Turing Machines
in Wonderland have 2 tapes – one which has the input initially, and the other one which is called the
“query tape”. Each Wonderland Turing Machine (WTM) also has 3 more special states – qquery , qyes ,
and qno (in addition to the usual q0 , qaccept , qreject ). The computation of a WTM proceeds just like a
usual 2-tape DTM, except that as soon as a WTM enters state qquery , its state changes instantaneously
to qyes or qno depending on the content w of the query tape: if w ∈ DIAG, the machine enters qyes , and if
w∈ / DIAG, the machine enters qno . The definition of the language DIAG in Wonderland is same as that in
real-life: it is the set of all strings x such that the real-life Turing machine whose description is x doesn’t
accept x. (Note that the domain of the transition function of a WTM is (Q \ {qaccept , qreject , qquery }) × Γ,
where Q is its state space and Γ is its tape alphabet.)
Obviously, every language that is recognisable in real-life is Wonderland-recognisable too (don’t have any
transition into qquery ). Give an example of a language which is unrecognisable in real-life but, in fact,
decidable in Wonderland (0 marks for this). More importantly, Alice is wondering whether there exists
a Wonderland-unrecognisable language too. Help her by giving an explicit example of such a language,
and prove that your example language is indeed Wonderland-unrecognisable.

The concept of querying after reaching qquery is quite similar to the concept of oracle Turing Ma-
chine (as discussed in class). An oracle TM also has two tapes - work tape and oracle tape, work
tape which is similar to work tape in one-tape TMs where we read, write data and change states
based on input. Oracle tape is the additional tape (in our problem, the “query tape”) which
we use whenever our state is qquery to perform computation on the contents of the “query tape”
to give an response based on the oracle’s computational function (or if it belongs to oracle set).
Here we need not concern about how the oracle computes the result but we may assume that it
is sort of a blackbox whose input is the content of the “query tape” and the output is encoded in
the resulting state (either qyes or qno ). The oracle in the problem is the set DIAG where DIAG
= {hM i | M doesn’t accept hM i}.

Let us first see an example of a language which is unrecognisable in real-life but is decidable in
Wonderland. We know that DIAG is unrecognisable in real-life. Now we show that it has a decider
in Wonderland. Consider the WTM S which on input string s copies the string to “query tape”
and goes to state qquery . It accepts the string s if response state is qyes and rejects the string s if
the response state is qno (we can make qaccept and qyes coincide and similarly for rejection or add in
-transitions from qyes to qaccept and similarly for rejection). Note that such an existence of oracle
allowed us to build a decider for DIAG.

Now we find languages which are unrecognisable even by WTMs. We use ideas from sir’s initial
classes (where sir was giving introduction to halting problem in lecture-2 or 3 maybe!). Consider the
language SUPERDIAG = {hM i | M , with oracle for DIAG (call it M DIAG ), doesn’t accept hM i}.
We show that SUPERDIAG is unrecognisable in Wonderland. Assume the contrary, then there is
a WTM R which can recognise SUPERDIAG. Define S such that:

S (on input hM i):


if R(with input hM i) accepts then accept else reject.

Now, S(hSi) is accepted ⇔ R(hSi) is accepted ⇔ hSi ∈ SUPERDIAG ⇔ S doesn’t accept hSi.
⇒⇐
Similarly, S(hSi) is not accepted ⇔ R(hSi) is not accepted ⇔ hSi 6∈ SUPERDIAG ⇔ S accepts
hSi. ⇒⇐
Either way we see that we are led to contradictions thus our assumption that SUPERDIAG is
Wonderland-recognisable is wrong thus SUPERDIAG is Wonderland-unrecognisable.

You might also like