Unit 3 Toc
Unit 3 Toc
Turing machine was invented in 1936 by Alan Turing. It is an accepting device which accepts
Recursive Enumerable Language generated by type 0 grammar.
The mapping function shows the mapping from states of finite automata and input symbol on
the tape to the next states, external symbols and the direction for moving the tape head. This is
known as a triple or a program for turing machine.
1. (q0, a) → (q1, A, R)
That means in q0 state, if we read symbol 'a' then it will go to state q1, replaced a by X and
move ahead right(R stands for right).
Example:
Construct TM for the language L ={0n1n} where n>=1.
Solution:
Now, we will see how this turing machine will works for 0011. 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, L) which means it will go to state q2, replaced 1 by B and
head will move to left as:
Now move will be δ(q2, 0) = δ(q2, 0, L) which means it will not change any symbol, remain
in the same state and move to left as:
The move will be δ(q2, A) = δ(q0, A, R), it means will go to state q0, replaced A by A and
head will move to the 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, L) which means it will go to state q2, replaced 1 by B and
head will move to left as:
The move δ(q2, B) = (q2, B, L) which means it will not change any symbol, remain in the same
state and move to left as:
Now 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 is present. The move will be δ(q2, A) = (q0, A, R) which means it will go
to state q0, will not change any symbol, and move to right as:
The move δ(q0, B) = (q3, B, R) which means it will go to state q3, will not change any symbol,
and move to right as:
The move δ(q3, B) = (q3, B, R) which means it will not change any symbol, remain in the same
state and move to right as:
The move δ(q3, Δ) = (q4, Δ, R) which means it will go to state q4 which is the HALT state and
HALT state is always an accept state for any TM.
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.
4. Finite set of symbols called external symbols which are used in building the logic of turing
machine.
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:
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:
DECIDABILITY
The Church-Turing thesis says that every solvable decision problem can be transformed into
an equivalent Turing machine problem.
It can be explained in two ways, as given below −
The Church-Turing thesis for decision problems.
The extended Church-Turing thesis for decision problems.
Let us understand these two ways.
Proof
A proof by the Church-Turing thesis is a shortcut often taken in establishing the existence of
a decision algorithm.
For any decision problem, rather than constructing a Turing machine solution, let us describe
an effective procedure which solves the problem.
The Church-Turing thesis explains that a decision problem Q has a solution if and only if there
is a Turing machine that determines the answer for every q ϵ Q. If no such Turing machine
exists, the problem is said to be undecidable.
There are two types of languages in the theory of computation (TOC), which are as follows −
Decidable
Undecidable
A problem is called decidable, when there is a solution to that problem and also can construct
algorithms corresponding to that.
Decidability Theorem
A language L over Σ is called decidable if,
There exist a Turing Machine M, that accepts language L
w€Σ*, M halts
Decidability
For the Recursive Language
A language ‘L’ is said to be recursive if there exists a Turing Machine which
will accept all the strings in ‘L’ and reject all the strings not in ‘L’.
The TM will halt every time and give an answer either accepted or rejected for
each and every input.
Recursively Enumerable languages −
A language ‘L’ is said to be recursively enumerable if there exists a TM which
accepts and halt for all input in ‘L’.
But may or may not halt for all input, which are not in ‘L’.
A Language ‘L’ is decidable if it is a recursive language.
All decidable languages are recursive languages and vice versa.
The diagram given below explains the decidable language −
Halting Problem
The Halting Problem is the problem of deciding or concluding based on a given arbitrary
computer program and its input, whether that program will stop executing or run-in an infinite
loop for the given input.
The Halting Problem tells that it is not easy to write a computer program that executes in the
limited time that is capable of deciding whether a program halts for an input.
In addition to that the Halting Problem never says that it is not practicable to determine whether
a given random program is going to halt (stop).
Generally, it asks the question like “Given a random program and an input, conclude whether
the given random program is going to halt when that input is given”.
Example
ATM = {(M,w) | M is a TM and M halts at input w }.
We can build a universal Turing machine which can simulate any Turing machine on any
input.
Let’s consider TM which recognizing the Altering Turing Machine (ATM) −
Recognize-ATM (<M,w>)
Simulate M using UTM till it halts
If M halts and accept then
Accept
Else
Reject
Suppose, if M goes into an infinite loop on input w, then the TM Recognize-ATM is going to
run forever which means TM is only a recognizer, not a decider.
A decider for this problem would call a halt to simulations that loop forever.
Now the question is whether an ATM is TM decidable is equivalent to asking the question
whether we can tell if a TM M will halt on input w.
Because of this, both versions of this question are generally called the halting problem.
Decidable Problems
A problem is decidable if we can construct a Turing machine which will halt in
finite amount of time for every input and give answer as ‘yes’ or ‘no’. A decidable
problem has an algorithm to determine the answer for a given input.
Examples
Equivalence of two regular languages: Given two regular languages,
there is an algorithm and Turing machine to decide whether two regular
languages are equal or not.
Finiteness of regular language: Given a regular language, there is an
algorithm and Turing machine to decide whether regular language is finite
or not.
Emptiness of context free language: Given a context free language, there
is an algorithm whether CFL is empty or not.
Undecidable Problems
A problem is undecidable if there is no Turing machine which will always halt in
finite amount of time to give answer as ‘yes’ or ‘no’. An undecidable problem has
no algorithm to determine the answer for a given input.
Examples
Ambiguity of context-free languages: Given a context-free language,
there is no Turing machine which will always halt in finite amount of time
and give answer whether language is ambiguous or not.
Equivalence of two context-free languages: Given two context-free
languages, there is no Turing machine which will always halt in finite
amount of time and give answer whether two context free languages are
equal or not.
Everything or completeness of CFG: Given a CFG and input alphabet,
whether CFG will generate all possible strings of input alphabet (∑*)is
undecidable.
Regularity of CFL, CSL, REC and REC: Given a CFL, CSL, REC or
REC, determining whether this language is regular is undecidable.
Note: Two popular undecidable problems are halting problem of TM and PCP (Post
Correspondence Problem). Semi-decidable Problems
A semi-decidable problem is subset of undecidable problems for which Turing
machine will always halt in finite amount of time for answer as ‘yes’ and may or
may not halt for answer as ‘no’.
Relationship between semi-decidable and decidable problem has been shown in
Figure 1 as:
Rice’s Theorem
Every non-trivial (answer is not known) problem on Recursive Enumerable
languages is undecidable.e.g.; If a language is Recursive Enumerable, its
complement will be recursive enumerable or not is undecidable.
Reducibility and Undecidability
Language A is reducible to language B (represented as A≤B) if there exists a
function f which will convert strings in A to strings in B as:
w ɛ A <=> f(w) ɛ B
Theorem 1: If A≤B and B is decidable then A is also decidable.
Theorem 2: If A≤B and A is undecidable then B is also undecidable.
Post Correspondence Problem
Post Correspondence Problem is a popular undecidable problem that was
introduced by Emil Leon Post in 1946. It is simpler than Halting Problem. In this
problem we have N number of Dominos (tiles). The aim is to arrange tiles in such
order that string made by Numerators is same as string made by Denominators. In
simple words, lets assume we have two lists both containing N words, aim is to find
out concatenation of these words in some sequence such that both lists yield same
result. Let’s try understanding this by taking two lists A and B
A=[aa, bb, abb] and B=[aab, ba, b]
Now for sequence 1, 2, 1, 3 first list will yield aabbaaabb and second list will yield
same string aabbaaabb. So the solution to this PCP becomes 1, 2, 1, 3. Post
Correspondence Problems can be represented in two ways:
1. Domino’s Form
:
2. Table Form
:
Lets consider following examples. Example-
1:
Explanation –
Step-1: We will start with tile in which numerator and denominator are
starting with same number, so we can start with either 1 or 2. Lets go
with second tile, string made by numerator- 10111, string made by
denominator is 10.
Step-2: We need 1s in denominator to match 1s in numerator so we will
go with first tile, string made by numerator is 10111 1, string made by
denominator is 10 111.
Step-3: There is extra 1 in numerator to match this 1 we will add first tile
in sequence, string made by numerator is now 10111 1 1, string made by
denominator is 10 111 111.
Step-4: Now there is extra 1 in denominator to match it we will
add third tile, string made by numerator is 10111 1 1 10, string made by
denominator is 10 111 111 0.
Final Solution - 2 1 1 3
String made by numerators: 101111110
String made by denominators: 101111110
As you can see, strings are same.
Recursive Theorem