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

Flat Module 5

The document discusses Turing machines and their properties. It can be summarized as: 1. A Turing machine consists of a tape, head, finite state control, and transition function. It can accept recursively enumerable languages by halting or looping on all inputs. 2. Examples show how Turing machines work for specific languages like "aba" and strings containing equal numbers of 0s, 1s, and 2s. 3. Recursive languages are decidable by Turing machines that always halt, while recursively enumerable languages may not halt on some inputs. Closure properties allow unions, intersections, and more of recursive languages to also be recursive.

Uploaded by

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

Flat Module 5

The document discusses Turing machines and their properties. It can be summarized as: 1. A Turing machine consists of a tape, head, finite state control, and transition function. It can accept recursively enumerable languages by halting or looping on all inputs. 2. Examples show how Turing machines work for specific languages like "aba" and strings containing equal numbers of 0s, 1s, and 2s. 3. Recursive languages are decidable by Turing machines that always halt, while recursively enumerable languages may not halt on some inputs. Closure properties allow unions, intersections, and more of recursive languages to also be recursive.

Uploaded by

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

Module 5

Turing Machine

Basic Model of Turing machine

The turning machine can be modelled with the help of the following representation.

1. The input tape is having an infinite number of cells, each cell containing one input symbol and
thus the input string can be placed on tape. The empty tape is filled by blank characters.

2. The finite control and the tape head which is responsible for reading the current input symbol.
The tape head can move to left to right.

3. A finite set of states through which machine has to undergo.

4. Finite set of symbols called external symbols which are used in building the logic of turing
machine.

Language accepted by Turing machine

The turing machine accepts all the language even though they are recursively enumerable.
Recursive means repeating the same set of rules for any number of times and enumerable means
a list of elements. The TM also accepts the computable functions, such as addition,
multiplication, subtraction, division, power function, and many more.

Example:

Construct a turing machine which accepts the language of aba over ∑ = {a, b}.

Solution:

We will assume that on input tape the string 'aba' is placed like this:

e tape head will read out the sequence up to the Δ characters. If the tape head is readout 'aba'
string then TM will halt after reading Δ.

Now, we will see how this turing machine will work for aba. Initially, state is q0 and head points
to a as:

The move will be δ(q0, a) = δ(q1, A, R) which means it will go to state q1, replaced a by A and
head will move to right as:

The move will be δ(q1, b) = δ(q2, B, R) which means it will go to state q2, replaced b by B and
head will move to right as:

The move will be δ(q2, a) = δ(q3, A, R) which means it will go to state q3, replaced a by A and
head will move to right as:
The move δ(q3, Δ) = (q4, Δ, S) which means it will go to state q4 which is the HALT state and
HALT state is always an accept state for any TM.

The same TM can be represented by Transition Table:

States a b Δ

q0 (q1, A, R) – –

q1 – (q2, B, R) –

q2 (q3, A, R) – –

q3 – – (q4, Δ, S)

q4 – – –

The same TM can be represented by Transition Diagram:

Example 1:

Construct a TM for the language L = {0n1n2n} where n≥1

Solution:
L = {0n1n2n | n≥1} represents language where we use only 3 character, i.e., 0, 1 and 2. In this,
some number of 0's followed by an equal number of 1's and then followed by an equal number of
2's. Any type of string which falls in this category will be accepted by this language.

The simulation for 001122 can be shown as below:

Now, we will see how this Turing machine will work for 001122. Initially, state is q0 and head
points to 0 as:

The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by A and
head will move to the right as:

The move will be δ(q1, 0) = δ(q1, 0, R) which means it will not change any symbol, remain in
the same state and move to the right as:

The move will be δ(q1, 1) = δ(q2, B, R) which means it will go to state q2, replaced 1 by B and
head will move to right as:
The move will be δ(q2, 1) = δ(q2, 1, R) which means it will not change any symbol, remain in
the same state and move to right as:

The move will be δ(q2, 2) = δ(q3, C, R) which means it will go to state q3, replaced 2 by C and
head will move to right as:

Now move δ(q3, 2) = δ(q3, 2, L) and δ(q3, C) = δ(q3, C, L) and δ(q3, 1) = δ(q3, 1, L) and δ(q3,
B) = δ(q3, B, L) and δ(q3, 0) = δ(q3, 0, L), and then move δ(q3, A) = δ(q0, A, R), it means will
go to state q0, replaced A by A and head will move to right as:

The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by A, and
head will move to right as:

The move will be δ(q1, B) = δ(q1, B, R) which means it will not change any symbol, remain in
the same state and move to right as:

The move will be δ(q1, 1) = δ(q2, B, R) which means it will go to state q2, replaced 1 by B and
head will move to right as:
The move will be δ(q2, C) = δ(q2, C, R) which means it will not change any symbol, remain in
the same state and move to right as:

The move will be δ(q2, 2) = δ(q3, C, L) which means it will go to state q3, replaced 2 by C and
head will move to left until we reached A as:

immediately before B is A that means all the 0's are market by A. So we will move right to
ensure that no 1 or 2 is present. The move will be δ(q2, B) = (q4, B, R) which means it will go to
state q4, will not change any symbol, and move to right as:

The move will be (q4, B) = δ(q4, B, R) and (q4, C) = δ(q4, C, R) which means it will not change
any symbol, remain in the same state and move to right as:

The move δ(q4, X) = (q5, X, R) which means it will go to state q5 which is the HALT state and
HALT state is always an accept state for any TM.
The same TM can be represented by Transition Diagram:

Recursive and Recursive Enumerable Languages in TOC


Recursive Enumerable (RE) or Type -0 Language
RE languages or type-0 languages are generated by type-0 grammars. An RE language can be
accepted or recognized by Turing machine which means it will enter into final state for the
strings of language and may or may not enter into rejecting state for the strings which are not
part of the language. It means TM can loop forever for the strings which are not a part of the
language. RE languages are also called as Turing recognizable languages.
Recursive Language (REC)
A recursive language (subset of RE) can be decided by Turing machine which means it will
enter into final state for the strings of language and rejecting state for the strings which are not
part of the language. e.g.; L= {a nbncn|n>=1} is recursive because we can construct a turing
machine which will move to final state if the string is of the form a nbncn else move to non-final
state. So the TM will always halt in this case. REC languages are also called as Turing
decidable languages.
Closure Properties of Recursive Languages
 Union: If L1 and If L2 are two recursive languages, their union L1 ∪L2 will also be
recursive because if TM halts for L1 and halts for L2, it will also halt for L1∪L2.
 Concatenation: If L1 and If L2 are two recursive languages, their concatenation L1.L2
will also be recursive. For Example:

L1= {anbncn|n>=0}
L2= {dmemfm|m>=0}
L3= L1.L2
= {anbncndm emfm|m>=0 and n>=0} is also recursive.
 L1 says n no. of a’s followed by n no. of b’s followed by n no. of c’s. L2 says m no. of d’s
followed by m no. of e’s followed by m no. of f’s. Their concatenation first matches no. of
a’s, b’s and c’s and then matches no. of d’s, e’s and f’s. So it can be decided by TM.
 Kleene Closure: If L1is recursive, its kleene closure L1* will also be recursive. For
Example:
L1= {anbncn|n>=0}
L1*= { a nbncn||n>=0}* is also recursive.
 Intersection and complement: If L1 and If L2 are two recursive languages, their
intersection L1 ∩ L2 will also be recursive. For Example:
L1= {anbncndm|n>=0 and m>=0}
L2= {anbncndn|n>=0 and m>=0}
L3=L1 ∩ L2
= { anbncndn |n>=0} will be recursive.

L1 says n no. of a’s followed by n no. of b’s followed by n no. of c’s and then any no. of d’s.
L2 says any no. of a’s followed by n no. of b’s followed by n no. of c’s followed by n no. of
d’s. Their intersection says n no. of a’s followed by n no. of b’s followed by n no. of c’s
followed by n no. of d’s. So it can be decided by turing machine, hence recursive.
Similarly, complement of recursive language L1 which is ∑*-L1, will also be recursive.
Language Decidability
A language is called Decidable or Recursive if there is a Turing machine which accepts and
halts on every input string w. Every decidable language is Turing-Acceptable.

A decision problem P is decidable if the language L of all yes instances to P is decidable.


For a decidable language, for each input string, the TM halts either at the accept or the reject
state as depicted in the following diagram −

Example 1
Find out whether the following problem is decidable or not −
Is a number ‘m’ prime?
Solution
Prime numbers = {2, 3, 5, 7, 11, 13, …………..}
Divide the number ‘m’ by all the numbers between ‘2’ and ‘√m’ starting from ‘2’.
If any of these numbers produce a remainder zero, then it goes to the “Rejected state”, otherwise
it goes to the “Accepted state”. So, here the answer could be made by ‘Yes’ or ‘No’.
Hence, it is a decidable problem
Variation of Turing Machine

1. Multiple track Turing Machine:

 A k-track Turing machine(for some k>0) has k-tracks and one R/W head that reads and
writes all of them one by one.
 A k-track Turing Machine can be simulated by a single track Turing machine
2. Two-way infinite Tape Turing Machine:

 Infinite tape of two-way infinite tape Turing machine is unbounded in both directions left
and right.
 Two-way infinite tape Turing machine can be simulated by one-way infinite Turing
machine(standard Turing machine).
3. Multi-tape Turing Machine:

 t has multiple tapes and is controlled by a single head.


 The Multi-tape Turing machine is different from k-track Turing machine but expressive
power is the same.
 Multi-tape Turing machine can be simulated by single-tape Turing machine.
4. Multi-tape Multi-head Turing Machine:

 The multi-tape Turing machine has multiple tapes and multiple heads
 Each tape is controlled by a separate head
 Multi-Tape Multi-head Turing machine can be simulated by a standard Turing machine.
5. Multi-dimensional Tape Turing Machine:

 It has multi-dimensional tape where the head can move in any direction that is left, right,
up or down.
 Multi dimensional tape Turing machine can be simulated by one-dimensional Turing
machine
6. Multi-head Turing Machine:

 A multi-head Turing machine contains two or more heads to read the symbols on the same
tape.
 In one step all the heads sense the scanned symbols and move or write independently.
 Multi-head Turing machine can be simulated by a single head Turing machine.
7. Non-deterministic Turing Machine:
 A non-deterministic Turing machine has a single, one-way infinite tape.
 For a given state and input symbol has at least one choice to move (finite number of
choices for the next move), each choice has several choices of the path that it might follow
for a given input string.
 A non-deterministic Turing machine is equivalent to the deterministic Turing machine.
Non-Deterministic Turing Machine
n a Non-Deterministic Turing Machine, for every state and symbol, there are a group of actions
the TM can have. So, here the transitions are not deterministic. The computation of a non-
deterministic Turing Machine is a tree of configurations that can be reached from the start
configuration.
An input is accepted if there is at least one node of the tree which is an accept configuration,
otherwise it is not accepted. If all branches of the computational tree halt on all inputs, the non-
deterministic Turing Machine is called a Decider and if for some input, all branches are rejected,
the input is also rejected.
A non-deterministic Turing machine can be formally defined as a 6-tuple (Q, X, ∑, δ, q 0, B, F)
where −
 Q is a finite set of states
 X is the tape alphabet
 ∑ is the input alphabet
 δ is a transition function;
δ : Q × X → P(Q × X × {Left_shift, Right_shift}).
 q0 is the initial state
 B is the blank symbol
 F is the set of final states

Unrestricted Grammar
In automaton, Unrestricted Grammar or Phrase Structure Grammar is the most general in
the Chomsky Hierarchy of classification. This is type0 grammar, generally used to
generate Recursively Enumerable languages. It is called unrestricted because no other
restriction is made on this except each of their left hand sides being non-empty. The left hand
sides of the rules can contain terminal and non-terminal, but the condition is at least one of them
must be non-terminal.
A Turning Machine can simulate Unrestricted Grammar and Unrestricted Grammar can
simulate Turning Machine configurations. It can always be found for the language recognized
or generated by any Turning Machine.

Formal Definition
The unrestricted grammar is 4 tuple -
G = (N,Σ,P,S)

N - A finite set of non-terminal symbols or variables,


Σ - It is a set of terminal symbols or the alphabet of the language being described, where N ∩ Σ
= φ,
P - It is a finite set of "productions" or "rules",
S - It is a start variable or non-terminal symbol.
If, α and β are two strings over the alphabet N ∪ Σ. Then, the rules or productions are of the
form α → β. The start variable S appears on the left side of the rule.

What is a Turing machine enumerator?


An enumerator is a Turing machine with an attached printer. The Turing machine can use
that printer as an output device to print strings. Every time the Turing machine wants to add a
string to the list, it sends the string to the print

You might also like