Module 5
Module 5
Module 5
Rijin IK
Assistant Professor
Department of Computer Science and Engineering
Vimal Jyothi Engineering College
Chemperi
Closure properties
Context Sensitive Languages are closed under
1 Union
2 Intersection
3 Complement
4 Concatenation
5 Kleene closure
6 Reversal
Formal definition
Formally Linear Bounded Automata is a non-deterministic Turing
Machine, M = (Q, Σ, Γ, δ, B, ⊢, ⊣, q0 , t, r )
Q is set of all states
Σ is set of all terminals
Γ is set of all tape alphabets Σ ⊂ Γ
δ is set of transitions (Q × Γ) → (Q × Γ × {R, L})
B is blank symbol (B ∈ Γ)
⊢ is left marker and ⊣ is right marker (⊢ and ⊣ ∈ Γ)
q0 is the initial state (q0 ∈ Q)
t is accept state (t ∈ Q)
r is reject state (r ∈ Q)
S → ACaB
CaBc → aaC
CB → DB
aD → Da
aEC → Ea
AE → ϵ
Here LHS and RHS can contain any set of terminals and non terminals.
The basic model has a finite control, an input tape that is divided into
cells, and a tape head that scans one cell of the tape at a time.
Rijin IK (VJEC) CST 301 M5 November 15, 2023 17 / 89
Turing Machine (TM)
Tape
The tape has a leftmost cell but is infinite to the right.
Each cell of the tape may hold exactly one of a finite number of tape
symbols.
Initially, the n leftmost cells, for some finite n ≥ 0, hold the input,
which is a string of symbols chosen from a subset of the tape symbols
called the input symbols.
The remaining infinity of cells each hold the blank, which is a special
tape symbol that is not an input symbol.
Finite control
At a particular instant, finite control is in a state. States are divided
into,
Start state (q0),
Halt state (h),
Intermediate states (q1, q2, .....).
Tape head
Tape head points to one of the tape cells. It communicates between
finite control and tape. It can move left , right or remain stationary.
Rijin IK (VJEC) CST 301 M5 November 15, 2023 18 / 89
Turing Machine (TM)
Define a move in TM
Let X1 X2 . . . Xi−1 qXi . . . Xn be an ID.
The left move is: if δ(q, Xi ) = (p, Y , L) ,if i > 1 then
X1 X2 . . . Xi−1 qXi . . . Xn ⊢ X1 X2 . . . Xi−2 pXi−1 YXi+1 . . . Xn .
The right move is: if δ(q, Xi ) = (p, Y , R) ,if i > 1 then
X1 X2 . . . Xi−1 qXi . . . Xn ⊢ X1 X2 . . . Xi−1 YpXi+1 . . . Xn .
L(M) = {w ∈ Σ∗ |M accepts w }
Figure: A computation of M
TM as transducers
A TM can function as a transducer. That is, a string is given as input to
TM, it produces some output.
Input to the computation is a set of symbols on the tape.
At the end of computation, whatever remains on the tape is the
output.
A TM can be viewed as a transducer for the implementation of function f
defined as,y = f (x) for strings x, y ∈ Σ∗
A function, f is said to be computable or Turing computable, if there
exists a TM M such that q0 x ⊢∗ qf f (x)
where x is in the domain of f.
Unary Representation
In computing functions using a Turing machine (TM) where inputs
are represented using unary notation, a non-negative integer n is
indeed represented as a sequence of 1s or 0s.
For example:
If n = 2, it is represented as ”11” or ”00”
If n = 4, it is represented as ”1111” or ”0000”
f (m, n) = m + n.
After addition, tape will contain the results of addition as shown below
Theorem:
Every language accepted by a k-tape TM M1 is also accepted by a single
tape TM M2
Proof by construction
Let L be accepted by M1 ,a TM with k-tapes. We can construct M2,
a one-tape TM with 2k tracks, two tracks for each of M1’s tapes.
One track records the contents of the corresponding tape of M1
and the other is blank, except for a marker in the cell that holds the
symbol scanned by the corresponding head of M1.
The finite control of M2 stores the state of M1 ,along with a count of
the number of head markers to the right of M2’s tape head.H
The count of markers to the right enables M2 to tell when it has gone
for enough.
As M2 passes each head marker on the leftward pass, it updates the
tape symbol of M1 “scanned”by that head marker, and it moves the
head marker one symbol left or right to simulate themove of M1.
Finally, M2 changes the state of M1 recorded in M2’s control to
complete thesimulation of one move of M1.
If the new state of M1 is accepting, then M2 accepts.
How M2 works :
1 Generate the next sequence on tape 2
2 Copy tape 1 (input) to tape 3 (scratch copy)
3 Simulate M1 on tape 3, making choices according to the sequence on
tape 2.
4 If M1 accepts, then accept;
5 Otherwise, go to step 1.
Halting Problem of TM
In computability theory, the halting problem is the problem of
determining, from a description of an arbitrary computer program and
an input, whether the program will finish running, or continue to run
forever.
Alan Turing proved in 1936 that a general algorithm to solve the
halting problem for all possible program-input pairs cannot exist.
Halting problem is undecidable.
Problem
Given the description of a Turing machine M and an input w, does M,
when started in the initial configuration q0 w , perform a computation
that eventually halts?
Input: A Turing machine and an input string w.
Problem: Does the Turing machine finish computing of the string w
in a finite number of steps? The answer must be either yes or no
Recursive set
A set is called recursively enumerable if there’s a step-by-step
method, like using a specific rule or algorithm, that can eventually list
out all the numbers in that set.
However, this method might take a while, and it can’t quickly tell you
whether a specific number is in the set or not. So, it’s a way to
gradually list the numbers but not a straightforward way to decide if a
particular number belongs to the set.
The union and intersection of two recursively enumerable sets are also
recursively enumerable.
Recursive set
A set S of integers is said to be recursive if there is a total recursive
function f (x) such that f (x) = 1 for x in S and f (x) = 0 for x not in
S.
Any recursive set is also recursively enumerable.
Finite sets, sets with finite complements, the odd numbers, and the
prime numbers are all examples of recursive sets.
The union and intersection of two recursive sets are themselves
recursive, as is the complement of a recursive set.
Recursive Language
A language is said to be recursive if there exists a Turing Machine
that accepts every string of the language and rejects the string that
are not in the language.
A TM of a recursive language never goes into a loop and always halts
in every case. Recursive languages are hence also called Turing
decidable languages.
Complement:
The complement of a recursive language L1 is also a recursive
language.
That is, if the TM accepts L1 it rejects it as a final output.
Kleene’s closure:
The Kleene’s closure of a recursive language L1 is also recursive
That is, if L1 = {o i 1j } is recursive, then L∗1 = {o i 1j }∗ is also
recursive.
Theorem:
If L is recursively enumerated and L̄ is recursively enumerable then L is
recursive. Proof
Let M and M’ be TMs that accept L and L̄, respectively.
Run M and M’ simultaneously.
For any word x, it must be accepted by one of M or M’
So, either M or M’ will halt and accept
If M halts and accepts then M’ halt and reject
If M halts and reject then M’ halt and accepts
The TM that runs M and M’ simultaneously always halts and accepts or
rejects so it decides L and L is recursive.
Type 2
It should be Type 1
It is Context-Free Grammar (CFG)
It is recognized by a Pushdown automata
The left-hand side of production can have only one variable and there
is no restriction on right side
Production is of the form A → α,
where A is a variable and α is a string of symbols from (V ∪ T )∗ .
For Example:
S → AB
A→a
B→b