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

Theory of Computation

Lecture #5
Sarmad Abbasi
Virtual University

Sarmad Abbasi (Virtual University)

Theory of Computation

1 / 25

Lecture 5: Overview

Variants of Turing Machines.


k -tape TMs.
Show that k -tape TMs have the same power as 1-tape TMs.
Study enumerators.
Prove equivalence of enumerators and TMs.
Dovetailing.

Sarmad Abbasi (Virtual University)

Theory of Computation

2 / 25

Variants of TMs

We will show that multi-tape TMs are not more powerful than single
tape TMs.

Sarmad Abbasi (Virtual University)

Theory of Computation

3 / 25

Variants of TMs

Sarmad Abbasi (Virtual University)

Theory of Computation

4 / 25

The Acceptance Problem for DFAs

Theorem
Every multi-tape TM has an equivalent single tape TM.
A single tape TM can actually simulate a multi-tape TM.

Sarmad Abbasi (Virtual University)

Theory of Computation

5 / 25

Variants of TMs
Let us look at a 3-tape TM.

How can we describe its configuration?

Sarmad Abbasi (Virtual University)

Theory of Computation

6 / 25

Variants of TMs

The congfiguration of this TM is described as follows:

q3 #aaaab#baa
ab#a
aaab
The main point is that this configuration can be written on a single tape.

Sarmad Abbasi (Virtual University)

Theory of Computation

7 / 25

Multi-tape TMs

The method for writing a configuration on a single tape is:


1

write the state first followed by #.

write the contents of the first tape followed by a #.

write the contents of the second tape followed by a #.

write the contents of the third tape followed by a #.

place dots on all symbols that are currently been scanned by the
TM.

Sarmad Abbasi (Virtual University)

Theory of Computation

8 / 25

Multi-tape TMs

Suppose that I have only a single tape. I want to know what a


multi-tape TM will do on input w. I can write


q0 #w 0 ##
Which denotes the initial configuration of M on w.

Sarmad Abbasi (Virtual University)

Theory of Computation

9 / 25

Multi-tape TMs

Here w 0 is the same string as w except the first character has a dot
placed on top of it.
Now, I can keep scanning the entire tape to find out which symbols are
being read by M. In the second pass I can make all the modifications
that M would have done in one step.

Sarmad Abbasi (Virtual University)

Theory of Computation

10 / 25

Multi-tape TMs

Given a k tape TM M we descibe a single tape TM S. S is going to


simulate M by using only one tape.

Sarmad Abbasi (Virtual University)

Theory of Computation

11 / 25

Simulating multi-tape TMs


Description of S:
On input w = w1 wn
1

Put the tape in the format that represents the initial configuration
of M; that is,

##

#q0 w1 w2 wn ##

To simulate a single move of M, S scans it tape from left to right.


In order to determine the symbols that are placed under its
virtual heads. Then it makes a second pass to update the
contents of the tapes according to the transition function of M.

If at any point S has to move a head to the right on to # that is if


by
M is moving to a previously unread black. Then S inserts 
shifting symbols to the right.

If S reaches an accepting configuration then it accepts and if it


reaches a rejecting configuration then it rejects.

Sarmad Abbasi (Virtual University)

Theory of Computation

12 / 25

Simulating multi-tape TMs


Suppose we have a three tape Turing machine and we give it the input
aabb. The machine is in the following configuration:

Sarmad Abbasi (Virtual University)

Theory of Computation

13 / 25

Simulating multi-tape TMs


This configuration will be written on a single tape of S as:
#

#q0 aabb#
#
and suppose (q0 , a, , ) = (q2 , b, c, a, R, R, R). That means the next
configuration will be written as:

#q2 babb#c
#a
#
This represents the machine in the following configuration:

Sarmad Abbasi (Virtual University)

Theory of Computation

14 / 25

Simulating multi-tape TMs


Now, if (q2 , a, , ) = (q3 , c, b, b, R, L, R) then

#q3 bc bb#
cb#ab
#
represents the next configuration.

Sarmad Abbasi (Virtual University)

Theory of Computation

15 / 25

Simulating multi-tape TMs

In order for S to simulate a single step of M it has to make two passes.


1

In the first pass it finds out the current symbols being scanned by
Ms heads.

In the second pass it makes the required changes to the tape


contents.

Theorem
M accepts w if and only if S accepts w.

Sarmad Abbasi (Virtual University)

Theory of Computation

16 / 25

Simulating multi-tape TMs

Thus we have proved the our theorem:

Theorem
Every multi-tape TM has an equivalent single tape TM.
A few words about this theorem:

Sarmad Abbasi (Virtual University)

Theory of Computation

17 / 25

Simulating multi-tape TMs

We have only given a high level description of S. You should


convince yourself that given any k -tape TM you can come up with
a exact and formal definition of S. Which essentially means you
can fill all the details in the above proof.

Work alphabet of S will be much larger than that of M.

Sarmad Abbasi (Virtual University)

Theory of Computation

18 / 25

Simulating multi-tape TMs

Another important point to note in this proof:


It seems like S is not very efficient. To perform one step of M it makes
two passes over the entire tape. However, efficiency is not our concern
in computability theory (it will be when we study complexity theory).

Sarmad Abbasi (Virtual University)

Theory of Computation

19 / 25

Simulating multi-tape TMs

It is your homework to prove the following theorem:

Theorem
Every k-head TM has an equivalent single tape TM.
The proof of this theorem is almost a ditto copy of the previous
theorem. However, there are some subtle differences. You must write
the proof in detail to understand these differences.

Sarmad Abbasi (Virtual University)

Theory of Computation

20 / 25

Multi-tape TMs

Can we use this theorem to make our lives simpler? Yes.


Suppose someone asks you if the language
L = {w#w : w {0, 1} }
is decidable. It is much simpler to design a two tape TM for this
language.

Sarmad Abbasi (Virtual University)

Theory of Computation

21 / 25

Multi-tape TMs

Description of a 2-tape TM that accepts L.


1

In the first pass make sure the input is of the form w1 #w2 .

Cope the contents after # to the second tape.

Bring both tape heads all the way to the left.

Match symbols of w1 and w2 one by one to make sure they are


equal.

Note that this is a much more natural solution than matching symbols
by shuffling over the input.

Sarmad Abbasi (Virtual University)

Theory of Computation

22 / 25

Multi-tape TMs

From now on we will mostly describe multi-tape TMs. By this theorem


we can always find a one-tape TM that is equivalent to our multi-tape
TM. This theorem is going to be extremely useful.

Sarmad Abbasi (Virtual University)

Theory of Computation

23 / 25

Enumerators
Let us now look at another model of computation called enumerators.
Enumerators are devices that do not take any input and only produce
output. Here is a picture of an enumerator:

Sarmad Abbasi (Virtual University)

Theory of Computation

24 / 25

Enumerators
Enumerators are another model of computation. They do not take any
input and only produce output. Let us define them formally: An
enumerator E = (Q, , , q0 , ).
1

Q is the set of states.

is the output alphabet and #,  6 .

is the work alphabet and  .

q0 is the start state.

is the transition function.

Well what is the domain and range of .


: Q 7 Q {L, R} ( {, #})

Sarmad Abbasi (Virtual University)

Theory of Computation

25 / 25

Enumerators

L(E) the language enumerated by E is the set of all strings that it


outputs.

Sarmad Abbasi (Virtual University)

Theory of Computation

26 / 25

Enumerators

Given an enumerator E Can we make a TM M such that


L(E) = L(M);
that is, the language accepted by M is the same as the one
enumerated by E.

Sarmad Abbasi (Virtual University)

Theory of Computation

27 / 25

Enumerators

This is easy M simply has E encoded in it. On input x it runs E and


waits for x to appear. If it appears it accepts.

Sarmad Abbasi (Virtual University)

Theory of Computation

28 / 25

Enumerators
The answer is yes. Consider a TM M and suppose:
1

 is accepted by M.

0 is rejected by M.

1 is accepted by M.

On 00 M loops forever.

01 is accepted by M.

We want to make an enumerator that outputs


, 1, 01, . . . .

Sarmad Abbasi (Virtual University)

Theory of Computation

29 / 25

Enumerators

We can try to make an enumerator as follows:


1

For each string x = , 0, 1, 00, 01, 10, 11,

run M on x; if M accepts output x

This does not work. Since, M loops for ever on 00 thus it will never
output 01!

Sarmad Abbasi (Virtual University)

Theory of Computation

30 / 25

Dovetailing

We can use dovetailing to get over this problem. The idea is to use
time sharing so that one bad string does not take up all the time.

Sarmad Abbasi (Virtual University)

Theory of Computation

31 / 25

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