ToC Test 3 Notes
ToC Test 3 Notes
B → c | Tc C
C → Tc C | c
Ta → a
Tc→ c
Therefore CFG in CNF is G = (V, Σ, R, S), V={S, S1, S2, S3, S4, A, B, C, Ta, Tc, a, c}, Σ = {a,
c}
R={
S→ Ta S1 S→ Ta S3 S→ Ta S4 S→ Ta Ta
S1 → A S2 S2 → CTa S3 → A Ta S4 → CTa
A→ a | c | Tc C
B → c | Tc C
C → Tc C | c
Ta → a
Tc→ c
}
S is the start symbol.
Ex 2:
CFG to PDA
Turing Machine(TM)
Turing machine model
The Turing machine can be thought of as finite control connected to a R/W head. It has
one tape which is divided into a number of cells. The block diagram of the basic model for the
Turing machine is given below:
Definition of TM: Turing machine M is a 7-tuple, namely (Q, Σ, 𝚪, 𝛅, q0, B, F), where
1. Q is a finite nonempty set of states.
2. 𝚪 is a finite nonempty set of tape symbols,
3. B ∈ 𝚪 is the blank
4. Σ is a nonempty set of input symbols and is a subset of 𝚪 and B ∉ Σ.
5. 𝛅 is the transition function mapping (q, x) onto (q’, y, D) where D denotes the direction of
movement of R/W head; D = L or R according as the movement is to the left or right.
6. q0 ∈ Q is the initial state, and
7. F ⊆ Q is the set of final states.
Note: The acceptability of a string is decided by the reachability from the initial state to some
final state. So the final states are also called the accepting states. 𝛅 may not be defined for some
elements of Q X 𝚪.
Ex 1:
Ex 2:
Ex 3:
Ex 4:
Ex 5:
Ex 6:
Ex 7:
✓ Subroutines
We know that subroutines are used in computer languages, when some task has to be
done repeatedly. We can implement this facility for TMs as well.
First a TM program for the subroutine is written. This will have an initial state and a 'return'
state. After reaching the return state, there is a temporary halt. For using a subroutine, new states
are introduced. When there is a need for calling the subroutine, moves are affected to enter the
initial state for the subroutine (when the return state of the subroutine is reached) and to return to
the main program of TM.