0% found this document useful (0 votes)
24 views

5. Turing Machine (1)

A Turing machine is a powerful computational model with a finite number of states and an unbounded tape, capable of solving problems that pushdown automata cannot. It operates using a read-write head that manipulates symbols on the tape according to a defined transition function. Variations of Turing machines include multitape, non-deterministic, and machines with different movement options, all of which maintain equivalent computational power to the standard Turing machine.

Uploaded by

Yash Tulsyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

5. Turing Machine (1)

A Turing machine is a powerful computational model with a finite number of states and an unbounded tape, capable of solving problems that pushdown automata cannot. It operates using a read-write head that manipulates symbols on the tape according to a defined transition function. Variations of Turing machines include multitape, non-deterministic, and machines with different movement options, all of which maintain equivalent computational power to the standard Turing machine.

Uploaded by

Yash Tulsyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

5 Turing Machine

Chapter 5
5.1 BASICS OF TURING MACHINE
Introduction:
y A Turing machine is a control unit with a finite number of states and
unbounded tape(s).
y Although, the Turing machine seems to be very simple from the
structural point of view, it is as powerful as simple it looks.
y There are so many problems that are unsolvable by push down
automaton. Such problems are solved using a Turing Machine.
y According to the Turing thesis, the only general type of automaton
whose power almost matches with a computer is nothing but the
Turing machine.

Standard turing machine:


y Turing machine uses the tape as a buffer, in other words, we can say
that it is a temporary storage area.
y There is a read-write head which is a part of the Turing machine, and it
is associated with the tape to read and write one symbol at a time onto
the tape at the time of traversing the tape in the right or left direction.

Fig. 5.1 Diagram of a Turing Machine

If M is a Turing machine, then the definition of M should be


M = (Q, ∑, Γ, δ, q0, B, F)

Where
Q is the set of finite states,
∑ is the set of input alphabets,
Γ is a finite set of symbols called the tape alphabet,
δ is the transition function, defined as
δ: Q × Γ → Q × Γ × {L, R}
where L = left movement & R = right movement,
B ∈ Γ is a special symbol called the blank,
Turing Machine

q0 ∈ Q is the initial state,


F ⊆ Q is the set of final states.

187
Chapter 5

Note: In the definition of a Turing machine, we assume that E Σ ⊆ Γ- {B}, that


the input alphabet is a subset of the tape alphabet, not including the blank.
y The interpretation of the transition function δ on Q × Γ states the
working principle of the Turing machine.
y The present state and the recent tape symbol, which is being read, are
passed as the arguments of the transition function.
y As a result, the control of the Turing machine will move to a new state,
the previous tape symbol may be changed with a new one, and the read
write head will be shifted to the left or to the right.
y The shift or move symbol will decide about the movement of the read
write head after the write of the new symbol in the place of the old one,
whether to shift left or right by one cell.
Note: Turing machine can’t accept epsilon.

Turing machine as acceptor:

SOLVED EXAMPLES

Sol:

Transition diagram
Turing Machine

188
Chapter 5
The transition means q0 by getting ‘a’; it is replacing ‘a’ with
‘X’ & going to state q1 and read-write head move one cell right.
We can even give transition table for L = anbn/n ≥ 1 as shows below:
δ(q0, a) → (q1, X, R)
δ(q0, Y) → (q3, Y, R)
δ(q1, a) → (q1, a, R)
δ(q1, Y) → (q1, Y, R)
δ(q1, b) → (q2, Y, L)
δ(q2, a) → (q2, a, L)
δ(q2, Y) → (q2, Y, L)
δ(q2, X) → (q0, X, R)
δ(q3, Y) → (q3, Y, R)
δ(q3, B) → (q4, B, L)
If the string will be in language then it will get accepted and halt at state q4
otherwise it will either go dead state or dead configuration.

Note: The transition table and transition diagram both are equivalent in power.

Sol:

Transition diagram
Turing Machine

The transition table for L = {anbncn | n ≥ 1} is given below:


δ(q0, a) → (q1, X, R)

189
Chapter 5

δ(q0, Y) → (q4, Y, R)
δ(q4, Y) → (q4, Y, R)
δ(q4, Z) → (q4, Z, R)
δ(q4, B) → (qf, B, L)
δ(q1, b) → (q2, Y, R)
δ(q1, a) → (q1, a, R)
δ(q1, Y) → (q1, Y, R)
δ(q2, b) → (q2, b, R)
δ(q2, Z) → (q2, Z, R)
δ(q2, c) → (q3, Z, L)
δ(q3, b) → (q3, b, L)
δ(q3, Z) → (q3, Z, L)
δ(q3, Y) → (q3, Y, L)
δ(q3, a) → (q3, a, L)
δ(q3, X) → (q0, X, R)

Transducer:
This is a more general automaton,which is able to produce strings of symbols as output and
it is called a transducer.

Turing machine as transducer:

SOLVED EXAMPLES

Sol:
Turing Machine

190
Chapter 5
Sol:

Note: Always, the read-write head of Turing machine will point to starting of the input.

Sol: Ex.: 3 + 4 can be represented as input tape as BB00010000BB and the output will
be BB0000000BB.
So, it is the same as a concatenation of two numbers.

Sol: Here, we have three cases:


Case 1:
When a = b, it means that it should halt in a state which will indicate both are
equal.
Case 2:
When a > b, it means that it should halt in a state which will indicate ‘a’ is greater
than b.
Case 3:
When a < b, it means that it should halt in a state which will indicate ‘b’ is
Turing Machine

greater than ‘a’.

191
Chapter 5

Note:

y Turing machine is capable of doing addition and comparison.


y So, if we could do addition and comparison we could do any other mathematical
operation. So, every mathematical function either multiplication, division, logarithm or
exponential can be written in terms of comparison and addition.
y So, Turing machine can implement any mathematical function. Therefore, Turing machine
is mathematical complete.
y Turing machine can compute mathematical function even using any other number system.

Sol:
Turing Machine

192
Chapter 5
Rack Your Brain

1) For ∑ = {0, 1}, design a Turing machine that accepts the language
denoted by the regular expression 00*.
2) What language is accepted by the Turing machine whose transition
graph is in the figure below?

Main features of standard turing machine:


Apart from all the different descriptions of a Truing machine, the standard
one can be defined as
y As δ defines at most one move always for each configuration, the Turing
machine becomes deterministic by default.
y The definition doesn’t incorporate any specific input or output file.
There is an assumption that- initially, the tape holds some characters.
A specific number of these characters can be treated as an input. In
a similar manner, a definite series of characters belonging to the tape
maybe visualized as the output.

Turing machine as language accepters:


The Turing machine M (Q, ∑, Γ, δ, q0, B, F) will accept the language called
L(M) = {w∈∑+ : q0w x1qfx2 for some qf∈F,x1,x2 ∈Γ*}

Computable:
The necessary condition of Turing computable or computable for a function
with a given domain is, there should be some Turing machine M(Q, ∑, Γ, δ,
q0, B, F) such that,
Turing Machine

q0w qff(w), qf ∈F, for all w ∈ D.


M

193
Chapter 5

Halting problem:
y There are some Turing machines which never halt. It may go into infinite
loop.
Example:

y In a Turing machine, the not halting issue i.e whether the TM is ever
halted or not, which is commonly known as the halting problem.
y This type of problem does not occur either in Finite Automata and
Pushdown Automata because there we have only one move in a forward
direction.
y So, when input gets over, either the FA or PDA will definitely halt, but in
the case of TM it can go either forward or backwards.

Variations of turing machines:


Equivalence of classes of automata:
If two automatons have acceptance for the same language, then they are
called equivalent. For example, suppose there are two automata classes,
C1 and C2 and two automatons M1 and M2. If for every M1 in C1 there is an M2
in C2 such that L(M1) = L(M2) then we can equalize the power of both the
classes. And, if the vice versa is also hold then the automata classes, i.e. C1
and C2 are equivalent.

Turing machines with a stay-option:


y The standard Turing machine definition says that the movement of the
read-write head must be to the left or to the right.
y Another most convenient option provided, is to do nothing or to stay at
the current place even after updating the symbol.
y Hence, the Turing machine with a do-nothing or stay option can be
defined by modifying δ
δ : Q × Γ → Q × Γ × {L,R, S}

S represents do-nothing or no movement of the R/W head.


Turing Machine

y Anyway, this option will not add extra power to the automaton.

194
Chapter 5
Turing machines with semi-infinite tape:
y The tape is bounded only in one direction.
y Let’s visualize a tape with a left boundary.

Fig. 5.2 Diagram of Turing machine with Semi-Infinite Tape

The off-line turing machine:


y Here, input is given in a separate file, and we are not allowed to modify
the input.
y In case, we have to do some modification on input, then we have to 1st
copy entire input into the tape, and then we have to do modifications
to the tape.
y Even after computation is over, the input is going to remain intact on
the input file.

Fig. 5.3 Diagram of The off-Line Turing Machine

y This modified TM is also equivalent in power to standard TM.

Multitape turing machines:


y More than one tape is there in the case of a multitape Turing machine,
and the most important part is every tape has its dedicated R/W head.
y We define an n-tape machine by M=(Q,∑,Γ,δ,q0,B,F) where Q, ∑, Γ, q0, F
Turing Machine

are the same as standard TM, but where


n
δ : Q × Γn → Q × Γn × {L,R}

195
Chapter 5

Fig. 5.4 Diagram of Multitape Turing Machines

y Multitape turing machine is also equivalent to standard turing machine.

Multidimensional turing machines:


y In such Turning architecture, infinite extension of the tape is allowed in any direction.

Fig. 5.5 A Diagram Of A Two-Dimensional Turing Machine Is Shown Above.

y The transition function δ of a 2D Turing machine can be defined as

δ : Q × Γ → Q × Γ × {L,R,U,D}

where, U represents the up movement of the read-write head and D represents the down
movement.
Turing Machine

y Multidimensional Turing machine is equivalent to the standard Turing machine.

196
Chapter 5
Jumping turing machine:
y In this jumping TM, instead of moving just one step ahead either to the
left or to the right, it can move many steps in one go.
y Here, the δ is given below

δ : Q × Γ → Q × Γ × {L,R} × {n}


Here, ‘n’ number of steps.
y This jumping TM is also equivalent in power to standard TM.

Non erasing turing machine:


y In non-erasing TM, on the input symbol, we are not allowed to write
Blank(B) but we can write any other symbol.
y This non-erasing TM is also equivalent in power to standard TM.

Always writing TM:


y In always writing Turing machine, it is always needed to
modify the input with different symbols whenever the Turing
Machine sees any input. Turing Machine cannot leave it as it is.
Example: if TM get ‘a’ as input, then it will write something which is not ‘a’.
y This Turing machine is also equivalent to standard TM.

Multihead TM:
y This modified TM have more than 1 read-write head.
y Multiple heads simultaneously look after the scanned symbol and make
the needful, i.e. move or write onto the tape independently.
y A Single head Turing machine can simulate a multi head Turing machine.

Automata with a queue:


y If there are finite Automata, and if we are adding a queue, then it is
equivalent to standard TM.

Turing machine with only 3 states:


y Any Turing machine can be minimized to a Turing machine which has
only 3 states.
y If a Turing machine has only three states, then it is also equivalent to a
standard Turing machine.
Turing Machine

197
Chapter 5

Multitape TM with stay option and atmost 2 states:


y Any Turing machine can be as multitape TM with stay option and almost
2 states.
y This modified TM also have the same power as standard TM.

Non deterministic turing machine:


y A non deterministic Turing machine is an automaton is defined by
M
= (Q, Σ, Γ, δ, q0 ,B,F)

Where
Q = finite set of internal states
∑ = finite set of input alphabets
Γ = Finite set of symbols or tape alphabets
δ = the transition function

δ : Q × Γ → 2QxΓ×{L,R}

B = blank space (special symbol) from tape symbol.


q0 = initial state ∈ Q
F = Set of final states ⊆ Q
y In a non-deterministic machine, the range of δ is a set of all possible
paths, so the machine can take any path out of all possible paths.
y The deterministic Turing machines classes are equivalent to the non
deterministic Turing machines classes.
y If at least one configuration of a non deterministic Turing machine
accepts a string w belongs to L then that language L is said to be
accepted by the same Turing Machine.
y “A non deterministic Turing machine M is said to decide a language L if,
for all w ∈ ∑*, There is a path that leads either to the acceptance or
rejection.”

Note: A NPDA with one extra independent stack. The δ is given below:-
δ: Q × (U{∈}) × Γ × Γ 2Q×Γ*×Γ*
This is also equivalent to standard TM.

Multistack machines:
y The tapes of a multi tape Turing machine in such a way, that it starts
behaving like a stack.
y A one-stack machine is a DPDA, while a machine with two stacks is a
Turing Machine

Turing Machine.

198
Chapter 5
Grey Matter Alert!

Simulating a Turing Machine by a real computer


y It is possible, in principle, to simulate a TM by a real computer if we accept that
there is a potentially infinite supply of a removable storage device such as a disk,
to simulate the non-blank will be better portion of the TM tape.
y Since the physical resources to make disks are not infinite, this argument is
questionable.
y However, since the limits on how much storage exists in the universe are unknown
and undoubtedly vast, the assumption of an infinite resource, as in the TM tape,
is realistic in practice and generally accepted.

Simulating a computer by a turing machine:


y A Turing Machine can simulate the storage and control of a real computer
if it uses one tape to store all the locations and their contents registers,
main memory, disk and other storage devices.
y Thus, we can surely say that something that cannot be done by a TM
also cannot be done by a real computer.

Rack Your Brain

Consider the nondeterministic Turing machine


M = ({qo, q1, q2, qf}, {O, 1}, {O, 1, B}, d, qo, B, {qf})
Informally but clearly describe the language L(M) if 8 consists of the
following sets of rules:
d(q0, O) = {(q0, 1, R), (q1, 1, R)}
d(q1, 1) = {(q2, 0, L)}
d(q2, 1) = {(q0, 1, R)}
d(q1, B) = {(qf, B, R)}

Universal turing machine:


y In a universal Turing machine Mu, a standard Turing machine(M) will
be given as input along with an input string w. We can simulate the
computation of M on w.
y To give a standard Turing machine as an input, first, a standard
representation of a Turing machine is required.
Turing Machine

y Assume Q = {q1, q2,......,qn}


y where, q1 = initial state, q2 = single final state, and

199
Chapter 5

Γ = {a , a ,......,a },
1 2 m

Where, a1 represents the blank symbol.


y Suppose, there is an encoding where q1 can be represented as 1, q2 can
be represented as 11 and so on.
y Similarly, the tape input symbols can be encoded as a1 = 1, a2 = 11, and
so on.
y To separate the 1’s or the strings of 1’s can be distinguished using 0 as
a symbol.
y Any Turing machine can be defined by the transition function δ along
with the initial, final state and the blank symbol defined.
y “The transition function is encoded according to this scheme, with the
arguments and result in some prescribed sequence”. For example, δ
(q1,a2) = (q2,a3,L) might appear as
…10110110111010…….

Fig. 5.6

Note:
y It follows from this that any turing machine has a finite encoding as
a string on {0,1}+ and that, given any encoding of M, we can decode it
uniquely.
y But any combination of strings will not represent any Turing machine
(e.g. the string 00011).
Turing Machine

200
Chapter 5
Working procedure of universal turing machine:
y The encoded definition of M will be kept in the tape 1, given an input M
and w.
y The tape symbols of M will be placed in the tape 2 and tape 3 will
contain the states of M.
y The universal Turing machine identifies the configuration of M by looking
at the tape 2 and tape 3.
y The tape 1 will help for the transition by seeing tape 2 and tape 3.
y Finally, the changes will be reflected on the tape 2 and tape 3, the
results will be reflected in tape 2.
y As it can be implemented using any programming language, we can
implement the same using any standard Turing machine also.

Previous Years’ Question

A single tape Turing Machine M has two states q0 and q1, of which q0 is the starting
state. The tape alphabet of M is {0, 1, B} and its input alphabet is {0, 1}.
The symbol B is the blank symbol used to indicate end of an input string. The transition
function of M is described in the following table. (GATE-2003)

The table is interpreted as illustrated below.


The entry (q1, 1, R) in row q0 and column 1 signifies that if M is in state q0 and reads 1
on the current page square, then it writes 1 on the same tape square, moves its tape
head one position to the right and transitions to state q1.
Which of the following statements is true about M?
1) M does not halt on any string in (0 + 1)+
2) M does not halt on any string in (00 + 1)*
3) M halts on all strings ending in a 0.
4) M halts on all strings ending in a 1.
Sol: Option 1)
Turing Machine

201
Chapter 5

Note:
y FA + tape = FA + 2stack = FA + queue = TM
y TM = FA+ 2 stack
  = FA +3 stack
  = FA + 4 stack
.
.
.
  = FA+ n stack (n ≥ 2)

Recursively enumerable:
y To ensure a language L is recursively enumerable, we have to find a
Turing machine for it.
y Recursive Enumerable can be defined as a Turing machine M, where, for
every w ∈ L,
q0w |-*M x1 qf x2,
with qf a final state.
y If string w is not in the language, then the definition doesn’t say whether
it will go in a non-final state and halt or it may go into an infinite loop.

Fig. 5.7

Recursive language:
1) A formal language for which a standard Turing machine exists, i.e., any
Turing Machine

strings from that language will be accepted by the Turing machine and
the machine halts as well is called recursive language.

202
Chapter 5
2) “The Turing machine that always halt is called Halting TM/decider/Total
Turing machine.”

Fig. 5.8

Conclusion

Fig. 5.9

“Recursive Language is a subset of recursively enumerable language”.


Turing Machine

203
Chapter 5

Chomsky hierarchy:
1) All formal languages are divided into 4 classes by Chomsky and those
class hierarchy known as “Chomsky Hierarchy”.

Fig. 5.10

2) Actually Type 0 represents recursively enumerable language, type 1


represents context-sensitive language, type 2 represents context free
language and type 3 represents regular language.

Note:
Recursive language is not type (0) language. Only recursively enumerable
language is type (0) language.
Turing Machine

204
Chapter 5
Extended Version of Chomsky Hierarchy:

Fig. 5.11

Language and their corresponding grammar:

Turing Machine

Fig. 5.12

205
Chapter 5

Theorem 1:
“If a language L and its complement L are both recursively enumerable
then both languages are recursive.”

Theorem 2:
“If L is recursive, then L is also recursive and consequently both are
recursively enumerable.”

Unrestricted grammar/type 0 grammar:


When all the productions in a grammar are of the form X → Y
where X ∈(V + T)+ and Y ∈ (V + T)*
[Here, V indicate set of variables and ‘T’ indicate set of terminals]
y Unrestricted grammar can be defined ‘∈’ but TM is not configured in
order to accept a ‘∈’ string. So, we assume that we don’t consider
language deriving ‘∈’.

Ex.: S → S1B
S1 → aS1b
bB → bbB
aS1B → aa
B→∈
Closure properties of Recursive and Recursive Enumerable Language
Turing Machine

206
Chapter 5
l

Table 5.1 Cosure Properties

Theorem 1:
“For all recursive language ‘L’ there is an enumeration technique for it.”
Proof:
m
Turing Machine

Fig. 5.13

207
Chapter 5

~
If the alphabet is {a, b} then M enumerate strings as follows:
‘a’
‘b’
‘aa’
‘ab’
‘ba’
‘bb’
‘aaa’
‘aab’

Enumeration Procedure
Repeat:
~
M generates a string w
M checks if w ∈ L
Yes: Print w to output
No: Ignore w
End of proof.

Example: L = {b, ab, bb, aaa, …}

~
M L(M) Enumeration Output

b b b

aa

ab ab ab

ba

bb bb bb

aaa aaa aaa


Turing Machine

aab

208
Chapter 5
Note:
Theorem 2:
“A language is recursively enumerable if and only if there is an enumeration
procedure for it.”

Previous Years’ Question

Define languages L0 and L1 as follows: (GATE-2003)


L0 = {<M, w, 0> | M halts on w}
L1 = {<M, w, 1> | M does not halts on w}
Here <M, w, i> is a triplet, whose first component M is an encoding of a Turing
Machine, second component w is a string, and third component i is a bit.
Let L = L0 U L1. Which of the following is true?
1) L is recursively enumerable, but L′ is not.
2) L′ is recursively enumerable, but L is not.
3) Both L and L′ are recursive.
4) Neither L and L′ is recursively enumerable.
Sol: Option 4)

Previous Years’ Question

Consider the following languages. (GATE-2016 (set 2))


y L1 = {<M> | M takes at least 2016 steps on some input},
y L2 = {<M> | M takes at least 2016 steps on all inputs} and
y L3 = {<M> | M accepts ∈},
where for each Turing machine M, <M> denotes a specific encoding of M.
Which one of the following is TRUE?
1) L1 is recursive and L2, L3 are not recursive
2) L2 is recursive and L1, L3 are not recursive
3) L1, L2 are recursive and L3 is not recursive
4) L1, L2, L3 are recursive
Sol: Option 3)

Linear bound automata:


y We can limit the power of a Turing machine by restricting the way in
which we are going to use tape.
Turing Machine

y If we limit the Non-deterministic TM in such a way that it can use the


tape like a stack then it converges to a PDA.

209
Chapter 5

y If we limit the Turing machine to use only finite amount of cell and only
unidirectional tape movement is allowed then it can converges into
finite automata.
y If we limit tape of Turing machine to use only that part of the tape
where the input is present and not beyond it, then it converge to LBA
(Linear Bounded Automata).
y A linear bounded automata is designed with an unbounded tape. It
extents up to which the tape needs to be made use of purposely, with
an instant of the input. Practically, the unbounded tape is restricted by
the input string.
y To enforce this, we can envision the input as bracketed by the two
special symbols, the left-end marker and the right-end marker.
y LBA is less powerful than TM and it is more powerful than PDA. Ex.:
anbncn | n ³ 1 is accepted by LBA but not by PDA.
y Here, we don’t know whether the deterministic LBA are equivalent in
power to non-deterministic LBA. It is undecidable.
y Complement of the CFL is CSL.
y Language accepted by LBA is called context sensitive language.
y LBA is halting, Turing machine as context sensitive language is also a
recursive language.

Countability

y Countable set definition: “A set ‘s’ is said to be countable, if the


elements of the set can be put in one to one correspondence with the
set of natural numbers.”
y By this we mean that the elements of the set can be written in some order,
say, x1, x2, x3, …, so that every element of the set has some finite index.
for ex.: E = set of even number = {0, 2, 4, 6, 8…}
For any element in E of form 2i (i starts with 0) we give a corresponding
element (i + 1) in N (Natural Number). So, for every element in even number
set we can associate a natural number as a correspondence. Therefore, we
can say that set of even number is countable.
eg.: O = set of odd number
= {1, 3, 5, 7, 9, 11, …}
Turing Machine

Here, we can represent set of odd number in terms of (2i + 1) (i ³ 0). We


can map every odd number of the form (2i + 1) with (i + 1) (Natural number).

210
Chapter 5
Hence, the set of odd number is countable.
Uncountable set definition: “A set is uncountable if it is infinite and not
countable.”

Rack Your Brain

Given R = set of real number. Is R countable set?

Alternative definition of countability:


y A set is said to be countable if there exists an enumeration method
using which all the elements of the set can be generated and for any
particular element, it takes only a finite number of steps to generate it.
y The finite number of steps taken to generate an element can be used
as its index and hence a mapping into a natural number set.
for ex.:
i) Set of even number
Enumeration procedure: for (q = 0 to ¥)
printf (2 × q);

Output : 0 2 4 6 8 ...
Steps : 1 2 3 4 5 ...

So, the index for (0, 2, 4, 6, 8, … ) is (1, 2, 3, 4, 5, …).


Hence, set of even number is countable.
Similarly;
ii) Set of odd number
for (q = 0 to ¥)
printf (2 × q + 1)

Output : 1 3 5 7 9 11 ...
Steps : 1 2 3 4 5 6
Turing Machine

211
Chapter 5

SOLVED EXAMPLES

Sol: T he set S is countable since we are having an enumeration procedure for set S.
 ere, we don’t go either in increasing order of numerator or denominator, we just
H
add numerator and denominator and we just go in the increasing order of sum.
Here, the smallest number is 1/1.
So, the 1st sum is 2.
Within the sum we can enumerate in increasing order.
1 1 2 1 2 3
So, the enumeration order is , , , , , , ...
1 2 1 3 2 1
Hence, it is countable.

Lexicographic ordering:
y Lexicographic ordering is nothing but the alphabetical order, i.e., the sequence of letters
present in the dictionary.
y Suppose we have a set S = {a, b} and S* in lexicographical order will be {∈, a, b, aa, ab,
ba, bb, aaa, aab, …}

Rack Your Brain

Given a set S = set of all string over {a, b} is


1) Countable
2) Uncountable
3) Finite
4) Neither countable nor uncountable

Note:
y Set of all string possible over any alphabet is countable.
y So, Σ* = set of all string over Σ is countable.
y Every subset of countable set is either finite or countable.
y Since every language is a subset of Σ*. Therefore, every language is countable.
y It means given any language it is definitely either countable language or finite language.
Turing Machine

212
Chapter 5
Sol: Since every Turing machine can be encoded as a string of 0’s and 1’s.
Let S = {0, 1} then S* = set of all strings over {0, 1}.
Since, S* is countable and T is subset of S*.
Hence, T = set of all Turing machines.

Implication of the fact that the set of all turing machines are countable:
y Since we know that the set of Turing machines are countable, then the set of recursively
enumerable language are also countable.
y Since the set of recursive language is subset of the set of recursively enumerable
language. Hence, a set of recursive languages is countable.
y Similarly, a set of context free language, a set of context sensitive language, and the set
of regular language are also countable.
y We can also modify a turing machine in such a way that it can act as
PDA. Therefore, if set of TM is countable it implies that the set of PDA is also countable.
y Since, all machines are subset of set of Turing machine. So, the set of LBA, and set of
FA are also countable.

Theorem: Set of all languages possible are uncountable.


Implication from theorem:
y Set of TM is countable, and the set of all languages possible is
uncountable.
y Therefore, there are some languages for which there are no machines
yet. It means there are some languages which are not even recursively
enumerable.

Turing Machine

Fig. 5.14

213
Chapter 5

Theorem:
“set of all languages are uncountable”.

Proof:
Suppose there is a set S = {a, b}.
We need to prove that, 2S* is uncountable.
Let us assume, 2S* is countable.
As, S = {a, b}
S* = {∈, a, b, aa, ab, ba, bb, aaa, aab,....}

Let us represent each string using 0 or 1, if the string is present in the


language ∈ 2S* then mark that string using ‘1’ otherwise ‘0’.

Now, if we consider the diagonal, then we will find a string S = 0 0 1 1 1 ......


Complement of the diagonal 00111... will be S’ = 1 1 0 0 0..... which is not
in the language.
This particular language S is not included in that list as it is a different
form all the languages by at least one string.
So, our assumption was incorrect.
Hence, 2S* is uncountable. (Proved)

Note:
This kind of argument, because it involves a manipulation of the diagonal
elements of a table is called diagonalization.
Turing Machine

214
Chapter 5
Note:
Theorem:
“There exists a recursively enumerable language whose complement is not
recursively enumerable.”
Theorem:
“There exists a recursively enumerable language that is not recursive i.e., the
family of recursive languages is a proper subset of the family of recursively
enumerable languages.”
y Diagonalization method is used to prove that a language is not
recursively enumerable because if for a language, we proved that it
is not countable then it means there is no enumeration procedure for
that language.
And theorem says that a language is Recursive Enumerable Language if
and only if there is enumeration procedure for it. Hence, that language
is not recursively enumerable.
Theorem:
“If S1 and S2 are countable sets, then S1 U S2 and S1 × S2 are countable and
union and cross-product can be extended to any number of finite sets.”
Theorem:
“The set of all languages that are not recursively enumerable is uncountable.”

Proof:
The set of all languages is 2S* (set of all subsets of S*), and out of that some
languages are already recursive enumerable, because if there is TM for a
language then that language is recursively enumerable and we already know
that the number of TM is countable. Therefore, the number of languages in
the total language which is recursively enumerable are countable and that
will be equal to a number of Turing machines.
And in the remaining set, we don’t know anything, so we are just assuming
that it is countable. So, the resulting set is the union of a countable set;
therefore overall, that should be countable. And if that is true, then our
*
initial proof that 2Σ is uncountable is a failure as we know that set of
*
all languages 2Σ is uncountable. Therefore, our assumption that, the
remaining language i.e., the set of all languages that are not- recursively
enumerable is countable, is false. So, set of all languages which are not
recursively enumerable, must be uncountable.
Turing Machine

215
Chapter 5

Previous Years’ Question

Consider the following sets:


S1: Set of all recursively enumerable languages over the alphabet {O, 1}
S2: Set of all syntactically valid C programs
S3: Set of all language over the alphabet {O. 1}
S4: Set of all non-regular languages over the alphabet {O, 1)}
Which of the above sets are uncountable? (GATE-2019)
1) S1 and S2
2) S3 and S4
3) S2 and S3
4) S1 and S4

Previous Years’ Question

Let N be the set of natural numbers. Consider the following sets,


P: Set of Rational numbers (positive and negative) (GATE-2018)
Q: Set of functions from {O, 1} to N
R: Set of functions from N to {O, 1}
S: Set of finite subset of N
Which of the above set are countable?
1) Q and S only
2) P and S only
3) P and R only
4) P, Q and S only
Turing Machine

216
Chapter 5
Grey Matter Alert!

Function

y A function is a rule that assigns to elements of one set a unique element of


another set.
OR
In mathematics, a function is a relation between sets, that associates every
element of a first set with exactly one element of the second set.
Ex.: X = {1, 2, 3} & Y = {A, B, C, D}
t = {(1, D), (2, C), (3, C)}

y If f denotes a function, then the first set is called the domain of f and the second
set is its range. We write
f : S1 → S2
to indicate that the domain of f is a subset of S1 and that the range of f is a subset
of S2.
y If the domain of f is all of S1, we say that f is a total function on S1, otherwise f is
said to be a partial function.

Turing Machine

217
Chapter 5

SOLVED EXAMPLES

Sol: 1) Explanation: It is accepting L = {a b


n n
| n ³ 1}. So, (1) is the correct option.

Sol: 1) E xplanation: It is a CSL because we can give a linear bound automata. We cannot
compare number of X’s and number of Y’s using one stack here.
Turing Machine

218
Chapter 5
Sol: 2) E xplanation: Statement S1 is incorrect because set of all irrational number are
uncountable.
Statement S2: Since L is finite language. So, it is regular. All regular language
are recursively enumerable language and recursively enumerable language are
closed under Kleene closure. Hence, L* is recursively enumerable language.

Sol: 3) Explanation:
S1 : L2 − L1 =
L2  L1
= REL  Rec L
= REL  Rec L
= RE L.
So, statement S1 is correct.
S2 : L = {wwwk | w∈ (a, b)+} is CSL because for this we can give a LBA.
It needs more than one stack to accept this language L, so it is CSL.
Turing Machine

219
Chapter 5

Sol: 1) E xplanation: Recursive language is closed under complementation. Hence, L1


is
also recursive language. Recursively enumerable language is not closed under
complementation. Hence, L2 may or may not recursively enumerable language.

So, we can’t say L2 is recursively enumerable language.

Sol: 3) Explanation:
L = (L2  L1 ) − L3
= (Rec L  REL) − CFL
= (Rec L ∩ REL) – CFL
= REL  (CFL)
= REL ∩ CSL = REL.
[Here, Rec L means recursive language,
REL means recursively enumerable language,
CFL means context free language,
Turing Machine

CSL means context sensitive language]

220
Chapter 5
Sol: 1) Explanation: The given grammar is in the form of u → v
where u belongs to (V+T)+ v belongs to (V+T)*
here, V is set of non-terminals and T is set of terminals
Hence, it is unrestricted grammar or type-0 grammar.

Sol: 1) E xplanation:
Recursively enumerable language is not closed under
“complementation” and it is closed under “union”, “intersection”, “concatenation”,
etc.

Sol: 1) E xplanation: In the definition of Turing machine, ‘Q’ represents the “Set of finite
number of states”. Turing Machine

221
Chapter 5

Chapter Summary

y A Turing machine M is defined by M = (Q, S, G, d, q0, B, F) where Q is the set of


internal states, S is the input alphabets, G is a finite set of symbols called the tape
alphabet, d is the transition function, defined as
d: {Q × G → Q × G × {L, R}} where L = left and R = right, B ∈ G is a special symbol
called the blank, q0 ∈ Q is the initial state, F ⊆ Q is the set of final states.
y Turing machine can’t accept epsilon.
y Turing machine can act both as a transducer as well as acceptor.
y Turing machine is mathematically complete. It can do any mathematical function.
y Halting Problem: Some times Turing machine goes into an infinite loop. This
problem of not halting of Turing machine is called the halting problem in the Turing
machine.
y There are different variations of Turing machines as shown below:
i) Turing machine with a stay option.
ii) Turing machine with semi-infinite tape.
iii) The off-line Turing machines.
iv) Multitape Turing machines.
v) Multidimensional Turing machines
vi) Jumping Turing machine
vii) Non Erasing Turing machine
viii) Always writing Turing Machine
ix) Multi head Turing Machine
x) Turing machine with only 3 states.
xi) Multitape Turing Machine with stay option and at most 2 states.
xii) Non-deterministic Turing machine
All these variations of the Turing machines are equivalent in power to the standard
Turing machines.
y We can represent any Turing machine in terms of 0’s and 1’s but any combination
of 0’s and 1’s is not a Turing machine.
y Finite Automata + n stack (n ³ 2) = TM
y Finite automata + queue = TM.
y Recursively Enumerable Language: For a language L, if there is a Turing machine
that can accept L, then the language L is known as recursively enumerable.
y Halting TM: Turing machine that always halts is called Halting TM/decider/Total
Turing machine.
y Chomsky Hierarchy: All formal languages are divided into 4 classes by Chomsky
Turing Machine

and those class hierarchy known as “Chomsky Hierarchy”.

222
y Unrestricted Grammar/Type 0 Grammar: A grammar is called unrestricted if all Chapter 5
the productions are of the form X → Y
y where X is in (V + T)+ and Y is in (V + T)*
[Here, V indicates set of variables and T indicates set of terminals]
y Closure Property of Recursive and Recursively Enumerable Language
Turing Machine

223
Chapter 5

y Linear Bound Automata: If we limit the tape of the Turing machine to use only
where the input is present and not beyond it, then it converges to LBA.
y In LBA, whether deterministic LBA is equivalent to non-deterministic LBA is not
known.
y Language accepted by LBA is called context-sensitive language.
y Countable Set: If there persists a one-to-one mapping from the elements of a set
to the set of positive integers, such a set is classified as countable.
y Uncountable Set: A set S is uncountable if it is infinite and not countable.
Turing Machine

y Set of all strings possible over any alphabet is countable.

224
Chapter 5
y Set of all languages possible is uncountable.
y There exists a recursively enumerable language whose complement is not
recursively enumerable.
y There exists a recursively enumerable language that is not recursive i.e., the family
of recursive language is a proper subset of the family of recursively enumerable
language.
y If S1 and S2 are countable sets, then S1 U S2 and S1 × S2 are countable, and union
and cross-product can be extended to any number of finite sets.
y The set of all languages that are not recursively enumerable is uncountable.

Turing Machine

225

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy