FLAT - Ch. 4 (Lecture Notes)
FLAT - Ch. 4 (Lecture Notes)
I. Introduction
The model we will study instead was designed in the 1930s by the English
mathematician Alan Turing and is referred to today as a Turing machine. It was not
obtained by adding data structures onto a finite automaton, and it predates the finite-
automaton and pushdown-automaton models. Turing’s objective was to demonstrate
the inherent limitations of algorithmic methods. He began with the idea of formulating a
model capable in principle of carrying out an algorithm whatsoever; this allowed him to
assert that any deficiencies of the model were in fact deficiencies of the algorithmic
method. The Turing machine was intended as a theoretical model, not as a practical
way to carry out a computation. However, it anticipated in principle many of the features
of modern electronic computers.
Turing considered a human-computer working with a pencil and paper. He decided that
without any loss of generality, the human-computer could be assumed to operate under
simple rules: First, the only things written on the paper are symbols from some fixed
finite alphabet; second, each step taken by the computer depends only on the symbol
he is currently examining and on his “state of mind” at the time; third, although his state
of mind may change as a result of his examining different symbols, only a finite number
of distinct states of mind are possible.
With these principles in mind, Turing isolated what he took to be the primitive steps that
a human-computer carries out during a computation:
1. Examining an individual symbol on the paper;
2. Erasing a symbol or replacing it by another;
3. Transferring attention from one symbol to another nearby symbol.
➢ In our version of a Turing machine, which is similar though not identical to the
one proposed by Turing, a single move is determined by the current state and
the current tape symbol, and consists of three parts:
1. Changing from the current state to another, possibly different state;
2. Replacing the symbol in the current square by another, possibly different symbol;
3. Leaving the tape head on the current square, or moving it one square to the right, or
moving it one square to the left if it is not already on the leftmost square.
➢ Formally, a Turing machines a 7- tuple M= (Q, Σ , Γ, δ, q0, B, F) where
Q is the finite set of states of the finite control
Σ is the finite set of input symbols.
Γ is the finite set of tape symbols; Σ⊂Γ.
δ: Q × Γ → Q × Γ × {L, R} is the transition function, which is a partial function.
q ∈ Q is the start state.
B ∈ Γ is the blank symbol; B ∈/ Σ.
F ⊆ Q is the set of final or accepting states.
For example
➢ TM that checks its third symbol is 0, accepts if so, and runs forever, if not (note it
never rejects).
M=({p,q,r,s,t},{0,1,},{0,1,B},p,s,d)
δ(p,X) = (q,X,R) for X=0,1
δ(q,X) = (r, X , R) for X=0,1
δ(r,0) = (s,0,L)
δ(r,1) = (t,1,R)
δ(t,X) = (t,X,R) for X=0,1,B
Read Update
Shift (L or R)
➢ Ex2
TM for {0n1n : n >= 1}
M = ({q0, q1, q2, q3, q4}, {0, 1}, {0, 1,X, Y,B}, ±, q0,B, {q4})
➢ Ex3
A Turing machine accepting {xx|x∈{a, b}∗}
➢ Ex4
➢ A Turing machine accepting { a i b a j | 0 ≤ I , j}
➢ Ex5
A Turing machine computing the reverse function.
➢ Ex6
A Turing machine to copy strings.
➢ Turing Recognizable and Decidable
A Turing machine M recognizes language L if L=L(M). We say L is Turing-recognizable
(or simply recognizable) if there is a TM M such that L=L(M).
A Turing machine decides language L if L=L(M) and M halts on all inputs. We say L is
decidable if there is a TM M that decides L.
Both types of machines halt in the Accept state on strings that are in the language.
A Decider also halts if the string is not in the language.
A Recognizer MAY or MAY NOT halt on strings that are not in the language.
On all input:
A Decider MUST halt (in Accept or Reject state)
A Recognizer MAY or MAY NOT halt on some strings.
➢ Closure properties
1. Union
Both decidable and Turing recognizable languages are closed under union.
For decidable languages the proof is easy. Suppose L1 and L2 are two decidable
languages accepted by halting TMs M1 and M2 respectively. The machine for L1 ∪ L2
is designed as follows:
Given an input x, simulate M1 on x. If M1 accepts then accept, else simulate M2 on x. If
M2 accepts then accept else reject.
Now suppose L1 and L2 are two Turing recognizable languages accepted by TMs
M1and M2 respectively. Since L1 and L2 are Turing recognizable languages, therefore
for strings that do not belong to these languages, the corresponding machines may not
even halt. The previous strategy will not work because we can have a scenario where
M2 accepts x but M1 loops forever.
2. Concatenation
Both decidable and Turing recognizable languages are closed under concatenation.
I will give the proof for Turing recognizable languages. The proof for decidable
languages is similar. Let L1and L2 be two Turing recognizable languages. Given an
input w, use non-determinism and guess a partition w (say w=xy). Now run the
respective Turing machines of L1and L2 on x and y respectively. If both accepts then
accept else reject.
3. Star
Both decidable and Turing recognizable languages are closed under star operation.
This is also similar to concatenation. Non deterministically first guess a number k, and
then guess a k partition of the given input. Now for each string in the partition, check
whether it belongs to the original language.
4. Intersection
Both decidable and Turing recognizable languages are closed under intersection. Run
the TMs of both the languages on the given input. Accept if and only if both the
machines accept. In the case of an intersection, we can run the TMs of L1 and L2 one
after the other (as opposed to the union).
5. Complementation
Decidable languages are closed under complementation. To design a machine for the
complement of a language L, we can simulate the machine for L on an input. If it
accepts then accept and vice versa.
➢ TMS Enumerator.
An enumerator is a multi-tape Turing Machine, with a special output tape which is write-
only.
Write only means (a) symbol on output tape does not affect transitions, and (b) tape
head only moves right.
Initially, all tapes blank (no input). During computation, the machine adds symbols to the
output tape. Output considered being a list of words (separated by special symbol #).
Definition: An enumerator M is said to enumerate a string W if and only if at some point
M writes a word W on the output tape.
Enumerate all the strings for L={an bn cn |n≥0}
Solution. The L can be generated by two-tape TM E with the following steps:
(1) Write # # on tape 1 and 2 for ε.
(2) Add an on tape 2,
(3)Copy an equal to the size of tape 2 on tape 1, then by the same size the b is written
on tape 1, then by same size c is written tape 1, followed with #
(4) go to step 2.