Theory of Computing
Theory of Computing
Dr. K. Umamaheswari
Professor,
Dept. of Information Technology,
PSG College of Technology,
Coimbatore
- Noam Chomsky
• Theorem: Let L be a CFL not containing {ε}. Then there exists a GNF
grammar G such that L = L(G).
T1
T2 GNF
T3
CNF
S aBS | l S aS | aBS | l
B bB | l B bB | b
L( B) b * L( B) b
L( S ) (ab*) * L( S ) (ab*) *
S 7 aaa S 4 aaa
Department of Information Technology
PSG College of Technology 30
Example
S AB S' S | l
B bB | l S AB | A | B
A aA | l B bB | b
S' S A aA | a
S AB | A | B
a *b*
B bB | l | b
l a b a b
A aA | l | a
Department of Information Technology
PSG College of Technology 31
Elimination of useless symbols
u,v (V ) *
S AC A aA | C
C cC | l B AbC
A aA | a | B
B bB | b | C
Cc
A aA | a | bB | b | c
B bB | b | c
Cc
Top-down flow of information
S AB | A | B S AB | aA | a | b
A aA | a | B A aA | a | b
Bb Bb
S aA | b | A S aA | b | Sa | bB
A Sa | B A Sa | bB | aA | b
B bB | S B bB | aA | b | Sa
A β A’
A’ λ / α A’
A A α1 / A α2 /….. / A αn / β1 / β2 A β1 A’ / β2 A’/ …… / βm A’
/ …… / βm A’ λ / α1 A’ / α2 A’ /….. / αn A’
Department of Information Technology
PSG College of Technology 42
• E E + E / E * E / (E) / a / b
E (E) E’ / a E’ / b E’
E’ + E E’ / * E E’ / λ
E’ + E E’ / * E E’ / + E / * E
Department of Information Technology
PSG College of Technology 45
1 2 3 4 5 6
E (E) E’ / a E’ / b E’ / (E) / a / b
7 8 9 10
E’ + E E’ / * E E’ / + E / * E
VT + , * , ( , ) , a , b VN E , E’
4 1
E(E) E (E) E’
A) E ( E A E’
E(EA
S → aTXP | aXP
T → aTS| bTS | aS | bS
X→a|b
P→b
X→a|b
T → aTS| bTS | aS | bS
S → aTXb | aXb
P→b
S → aTXP | aXP
Department of Information Technology
PSG College of Technology 53
GNF
G = ({ S, T, X }, { a, b }, R, S)
S→aTXb | aXb, T→XTS | XS, X→ a | b
S → aTXP | aXP
T → aTS| bTS | aS | bS
X→a|b
P→b
• Theorem: Let L be a CFL not containing {ε}. Then there exists a GNF
grammar G such that L = L(G).
TAPE
Determine if an input x is in a
language.
• That is, answer if the answer of a problem P
for the instance x is “yes”. ACCEPTOR
Compute a function
• Given an input x, what is f(x)? TRANSDUCER
At the beginning,
• A TM is in the start state (initial
state)
• its tape head points at the first cell
• The tape contains , following by
input string, and the rest of the
tape contains .
Department of Information Technology
JarulojPSG
Chongstitvatana 2301379
College of Technology 89
How does a TM work?
A TM stops working,
• when it gets into the special state
called halt state. (halts)
• The output of the TM is on the tape.
• when the tape head is on the leftmost
cell and is moved to the left. (hangs)
• when there is no next state. (hangs)
Department of Information Technology
PSG College of Technology 91
THE ORIGIN OF TURING MACHINE
But Turing’s a-machine became famous for
something else other than its original intentions.
• 1. a head which can read or write a symbol and can move left or right or
stay in position, corresponding to square cells marked-off on a tape
• 2.an infinite tape, extending on either side of the head, marked-off into
square cells, on which symbols from an alphabet can be written.
• Simple operations must include
• i. changes of the symbol on one of the observed squares
• ii. Changes of one of the squares observed to another square
• a. A possible change of symbol together with a possible change of state of
mind
• b. A possible change of observed squares together with a possible change
of state of mind.
Department of Information Technology
PSG College of Technology 94
Tape String
b a c n r
Blank tape Blank
Tape
Read/Write Head
States
(α, β, γ,…)
Turing Machine
Department of Information Technology
PSG College of Technology 95
Definition of Turing Machine
A Turing Machine is a 5-tuple T = (Q, ∑, Γ, q0, δ)
Q A finite set of states excluding halt state {h}
∑ A finite set of input alphabet
Γ A finite set of tape alphabet
∑ Ϲ Γ Γ is assumed not to contain blank {Δ}
q0 Initial state is an element of Q
δ δ : Q X (Γ U {Δ}) → (Q U {h}) X (Γ U {Δ}) X (R, L, S) is a partial
function (that is possibly undefined at certain points)
The tape may also be viewed as having a left end.
Each square of the tape contains a single symbol of Γ U {Δ}
If q є Q, r є Q U {h} X, Y є Γ U {Δ} and D є {R, L, S} the computation
step is
δ(q, X) = (r, Y, D)
If the tape is at left end and D = L then the TM crashes.
If r = h then TM halts because δ (h, X) is not defined.
Department
3/14/2020 of Information Technology
PSG College of Technology 98
The Church-Turing Hypothesis
Everything computable is computable by a Turing machine
– Physical interpretation
– Conceptual interpretation
– Definition of Computation
– Everything computable is computable by a Java program
– All “good enough” computers are equivalent
Partial recursive functions are the only computable functions, and these
are the functions computable by TMs.
Department
3/14/2020 of Information Technology
PSG College of Technology 99
The Turing machine: Computability
What cannot be computed by TMs?
• There are only countably many TM
machines -> there exist uncountably many
real numbers that are not computable
• Uncomputable functions, e.g. Halting
Problem
Department
3/14/2020 of Information Technology
PSG College of Technology 100
Equivalent TM Models
Many variations on TMs are equivalent.
1. Stay option. Read-write can stay at current
square.
2. Semi-infinite tape. Tape is infinite to the right,
but not the left.
3. Off-line TM. Two tapes, one for input, and the
other for working storage.
4. Multitape TMs. TM has a finite number of tapes.
5. Multidimensional TMs. Tape is two-dimensional
like a matrix.
6. Non-deterministic TM
7. Universal TM
Department
3/14/2020 of Information Technology
PSG College of Technology 101
Robustness
Other models of TM like, k-tape TMs,
nondeterministic Turing machines are not more
powerful than simple TMs:
Every nondeterministic TM has an equivalent
3-tape Turing machine, which –in turn– has an
equivalent 1-tape Turing machine.
Department
3/14/2020 of Information Technology
PSG College of Technology 116
References
John E.Hopcroft, Rajeev Motwani, Jeffery D
Ullman, “Introduction to automata theory,
languages and computation”, Pearson, 2012