TOC (Unit 1 to Unit 3)
TOC (Unit 1 to Unit 3)
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Topic: Introduction
DISCOVER . LEARN .
University Institute of Engineering (UIE) EMPOWER
Department of Computer and Science Engineering (CSE)
Outcome:
• Student will understand the
Basics of automata
3
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
• English mathematician
4
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
F: final state
δ: Transition function
Alphabet
15
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Powers of an alphabet
Let ∑ be an alphabet.
– ∑* = ∑0 U ∑1 U ∑2 U …
– ∑+ = ∑1 U ∑2 U ∑3 U …
16
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Strings
17
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Summary
• Automata theory & a historical perspective
• Chomsky hierarchy
• Finite automata
18
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
FAQ :
References :
• Martin J.C., “Introduction to Languages and Theory of
Computation”, Tata McGraw-Hill Publising Company
Limited, 3rd Edition.
• https://youtu.be/S3cOulqSAmU
• Https://en.wikipedia.org/wiki/Finite-state_machine
• https://www.safaribooksonline.com
• https://nptel.ac.in/courses/106/103/106103070/
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Topic: Introduction
DISCOVER . LEARN .
University Institute of Engineering (UIE) EMPOWER
Department of Computer and Science Engineering (CSE)
Outcome:
• Student will understand the
Formal Language
Operation on formal language
Languages
L is a said to be a language over alphabet ∑, only if L ∑*
this is because ∑* is the set of all strings (of all possible length
including 0) over the given alphabet ∑
Examples:
1. Let L be the language of all strings consisting of n 0’s followed by n
1’s:
L = {,01,0011,000111,…}
2. Let L be the language of all strings of with equal number of 0’s and
1’s:
L = {,01,10,0011,1100,0101,1010,1001,…}
Language:
A language is a collection of appropriate string. A language
which is formed over Σ can be Finite or Infinite.
Example: 1
• L1 = {Set of string of length 2}
= {aa, bb, ba, bb} Finite Language
Example: 2
• L2 = {Set of all strings starts with 'a'}
= {a, aa, aaa, abb, abbb, ababb} Infinite Language
Finite Automata
• Some Applications
– Software for designing and checking the behavior of
digital circuits
– Lexical analyzer of a typical compiler
– Software for scanning large bodies of text (e.g., web
pages) for pattern finding
– Software for verifying systems of all types that have a
finite number of states (e.g., stock market transaction,
communication/network protocol)
5
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Example: 1
• L1 = {Set of string of length 2}
= {aa, bb, ba, bb} Finite Language
Example 2 :
• Example of Finite Language: L1 = { set of string of 2 } L1 = { xy,
yx, xx, yy }
Example: 3
• L2 = {Set of all strings starts with 'a'}
Example 4 :
• Example of Infinite Language: L1 = { set of all strings
starts with 'b' } L1 = { babb, baa, ba, bbb, baab, ....... }
Summary
• Operations on Formal language
• Alphabets
• strings
• languages
10
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
FAQ :
References :
• Martin J.C., “Introduction to Languages and Theory of
Computation”, Tata McGraw-Hill Publising Company
Limited, 3rd Edition.
• https://youtu.be/S3cOulqSAmU
• Https://en.wikipedia.org/wiki/Finite-state_machine
• https://www.safaribooksonline.com
• https://nptel.ac.in/courses/106/103/106103070/
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Equivalence of DFA and NDFA
NFA with null transition
• Theorem:
– A language L is accepted by a DFA if and only if it is
Should be accepted by an NFA.
true for
any L • Proof:
1. If part:
• Prove by showing every NFA can be converted to an
equivalent DFA (in the next few slides…)
3
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
4
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
5
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
δD 0 1 δD 0 1
δN 0 1
Ø Ø Ø {q0} {q0,q1} {q0}
q0 {q0,q1} {q0} {q0} {q0,q1} {q0} {q0,q1} {q0,q1} {q0,q2}
q1 Ø {q2} {q1} Ø {q2} *{q0,q2} {q0,q1} {q0}
*q2 Ø Ø *{q2} Ø Ø
{q0,q1} {q0,q1} {q0,q2} 0. Enumerate all possible subsets
*{q0,q2} {q0,q1} {q0} 1. Determine transitions
*{q1,q2} Ø {q2} 2. Retain only those states
reachable from {q0}
*{q0,q1,q2} {q0,q1} {q0,q2}
6
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
δN 0 1 δD 0 1
q0 {q0,q1} {q0} {q0} {q0,q1} {q0}
q1 Ø {q2} {q0,q1} {q0,q1} {q0,q2}
*q2 Ø Ø *{q0,q2} {q0,q1} {q0}
7
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
8
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
9
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Applications
• Text indexing
– inverted indexing
– For each unique word in the database, store all locations
that contain it using an NFA or a DFA
• Find pattern P in text T
– Example: Google querying
• Extensions of this idea:
– PATRICIA tree, suffix tree
10
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
11
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
FA with -Transitions
12
University Institute of Engineering (UIE)
Example of an -NFA
0 1
• -closure of a state q,
q0 q1 q2 ECLOSE(q), is the set of
all states (including
start q’0 itself) that can be
δE 0 1
reached from q by
*q’0 Ø Ø {q’0,q0} repeatedly making an
q0 {q0,q1} {q0} {q0} arbitrary number of -
q1 Ø {q2} {q1} transitions.
*q2 Ø Ø {q2}
0 1
Simulate for w=101:
q0 q1 q2
q0’
start q’0
q0’ q0
δE 1 1
0 1
Ø q0
*q’0 Ø Ø {q’0,q0} x 0
ECLOSE(q’0)
q0 {q0,q1} {q0} {q0} q1
q1 Ø {q2} {q1} ECLOSE(q0) 1
*q2 Ø Ø {q2} q2
start q’0 q3
δE 0 1
*q’0 Ø Ø {q’0,q0,q3}
q0 {q0,q1} {q0} {q0,q3}
q1 Ø {q2} {q1}
*q2 Ø Ø {q2}
q3 Ø {q2} {q3}
15
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
• Implication:
– DFA ≡ NFA ≡ -NFA
– (all accept Regular Languages)
16
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Eliminating -transitions
Let E = {QE,∑,δE,q0,FE} be an -NFA
Goal: To build DFA D={QD,∑,δD,{qD},FD} s.t. L(D)=L(E)
Construction:
1. QD= all reachable subsets of QE factoring in -closures
2. qD = ECLOSE(q0)
3. FD=subsets S in QD s.t. S∩FE≠Φ
4. δD: for each subset S of QE and for each input symbol a∑:
• Let R= U δE(p,a) // go to destination states
r in R
17
University Institute of Engineering (UIE)
Example: -NFA DFA
0 1
q0 q1 q2
start q’0
δE 0 1
δD 0 1
*q’0 Ø Ø {q’0,q0}
q0 {q0,q1} {q0} {q0} *{q’0,q0}
q1 Ø {q2} {q1} …
*q2 Ø Ø {q2}
Summary
• Equivalency of DFA & NFA
• Removal of redundant states and including dead states
• -transitions in NFA
• Pigeon hole principles
• Text searching applications
19
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
References
• Https://en.wikipedia.org/wiki/Finite-state_machine
• https://www.safaribooksonline.com
• http://studentsfocus.com/
• http://www.francisxavier.ac.in/
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Arden’s Theorem
Arden’s Theorem
PROOF
• Solution −
• Here the initial state is q1 and the final state is q2
• Now we write down the equations −
• q1 = q10 + ε
• q2 = q11 + q20
• q3 = q21 + q30 + q31
• Now, we will solve these three equations −
• q1 = ε0* [As, εR = R]
• So, q1 = 0*
• q2 = 0*1 + q20
• So, q2 = 0*1(0)* [By Arden’s theorem]
• Hence, the regular expression is 0*10*.
• Solution −
• Here the initial state and final state is q1.
• The equations for the three states q1, q2, and q3 are as follows
−
• q1 = q1a + q3a + ε (ε move is because q1 is the initial state0
• q2 = q1b + q2b + q3b
• q3 = q2a
• Now, we will solve these three equations −
• q2 = q1b + q2b + q3b
• = q1b + q2b + (q2a)b (Substituting value of q3)
• = q1b + q2(b + ab)
• = q1b (b + ab)* (Applying Arden’s Theorem)
• q1 = q1a + q3a + ε
• Solution-
•
• Step-01:
•
• Form a equation for each state-
• A = ∈ + B.1 ……(1)
• B = A.0 ……(2)
•
• Step-02:
•
• Bring final state in the form R = Q + RP.
•
• Using (1) in (2), we get-
• B = (∈ + B.1).0
• B = ∈.0 + B.1.0
• B = 0 + B.(1.0) ……(3)
•
• Using Arden’s Theorem in (3), we get-
• B = 0.(1.0)*
•
• Thus, Regular Expression for the given DFA = 0(10)*
Summary
• Arden’s Theorem
– Conversion of FA to R.E
References
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Regular Language
Regular expression
Arden’s Theorem
Regular Languages
Definition
• We define regular languages as the smallest class of
languages which contains all finite languages and closed
with respect to union, concatenation and Kleene closure.
• Every regular expression denotes a regular language.
Example
• (a*b) is a regular expression that denotes the set of
strings formed by a sequence, also empty, of a's followed
by a b.
4
University Institute of Engineering (UIE)
Regular Expressions
Regular
Languages
Formal language
classes
Language Operators
6
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
7
University Institute of Engineering (UIE)
Kleene Closure (special notes)
9
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
10
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Precedence of Operators
• Highest to lowest
– * operator (star)
– . (concatenation)
– + operator
• Example:
– 01* + 1 =( 0 . ((1)*) ) + 1
11
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
-NFA NFA
Theorem 2 Kleene Theorem
Reg Ex DFA
12
University Institute of Engineering (UIE)
DFA to RE construction
DFA Reg Ex
Theorem 1
Informally, trace all distinct paths (traversing cycles only once)
from the start state to each of the final states
and enumerate all the expressions along the way
Example: 1 0 0,1
q0 0 q1 1 q2
1* 00* 1 (0+1)*
1*00*1(0+1)*
University Institute of Engineering (UIE) 13
RE to -NFA construction
Reg Ex -NFA
Theorem 2
Example: (0+1)*01(0+1)*
(0+1)* 01 (0+1)*
0
0
0 1
1
1
• Commutative:
– E+F = F+E
• Associative:
– (E+F)+G = E+(F+G)
– (EF)G = E(FG)
• Identity:
– E+Φ = E
– E=E=E
• Annihilator:
– ΦE = EΦ = Φ
15
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Algebraic Laws…
• Distributive:
– E(F+G) = EF + EG
– (F+G)E = FE+GE
• Idempotent: E + E = E
• Involving Kleene closures:
– (E*)* = E*
– Φ* =
– * =
– E+ =EE*
– E? = +E
16
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
True or False?
1. ((R*)*)* = R* ?
2. (R+S)* = R* + S*?
17
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Summary
• Regular expressions
• DFA to regular expression conversion
• Regular expression to -NFA conversion
• Algebraic laws of regular expressions.
18
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
FAQ
References
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Minimization of DFA
Myhill Nerode Theorem
Applications of interest
3
When to call two states in a DFA
“equivalent”?
Two states p and q are said to be equivalent iff:
i) Any string w accepted by starting at p is also accepted by starting
at q;
p
w
AND
q
i) Any string w rejected by starting at p is also rejected by starting at
q.
p
w
q
p≡q
4
Computing equivalent states in a DFA
(Myhill- Nerode Theorem )
A =
0 1
B = =
0 1 0
A C E G C x x =
1 0 1
0 1 D x x x =
1 1 0 E x x x x =
B D F H
Pass #0 1 0 F x x x x x =
1. Mark accepting states ≠ non-accepting states
0
Pass #1 G x x x = x x =
1. Compare every pair of states
2. Distinguish by one symbol transition H x x = x x x x =
3. Mark = or ≠ or blank(tbd) A B C D E F G H
Pass #2
1. Compare every pair of states
2. Distinguish by up to two symbol transitions (until different or same or tbd)
….
(keep repeating until table complete)
5
Table Filling Algorithm - step by step
A =
0 1
B =
0 1 0
A C E G C =
1 0 1
0 1 D =
1 1 0 E =
B D F H
1 0 F =
0
G =
H =
A B C D E F G H
6
Table Filling Algorithm - step by step
A =
0 1
B =
0 1 0
A C E G C =
1 0 1
0 1 D =
1 1 0 E X X X X =
B D F H
1 0 F X =
0
G X =
1. Mark X between accepting vs. non-accepting state H X =
A B C D E F G H
7
Table Filling Algorithm - step by step
A =
0 1
B =
0 1 0
A C E G C X =
1 0 1
0 1 D X =
1 1 0 E X X X X =
B D F H
1 0 F X =
0
G X X =
1. Mark X between accepting vs. non-accepting state H X X =
2. Look 1- hop away for distinguishing states or strings A B C D E F G H
8
Table Filling Algorithm - step by step
A =
0 1
B =
0 1 0
A C E G C X X =
1 0 1
0 1 D X X =
1 1 0 E X X X X =
B D F H
1 0 F X =
0
G X X X =
1. Mark X between accepting vs. non-accepting state H X X X =
2. Look 1- hop away for distinguishing states or strings A B C D E F G H
9
Table Filling Algorithm - step by step
A =
0 1
B =
0 1 0
A C E G C X X =
1 0 1
0 1 D X X X =
1 1 0 E X X X X =
B D F H
1 0 F X X =
0
G X X X X =
1. Mark X between accepting vs. non-accepting state H X X = X =
2. Look 1- hop away for distinguishing states or strings A B C D E F G H
10
Table Filling Algorithm - step by step
A =
0 1
B =
0 1 0
A C E G C X X =
1 0 1
0 1 D X X X =
1 1 0 E X X X X =
B D F H
1 0 F X X X =
0
G X X X = X =
1. Mark X between accepting vs. non-accepting state H X X = X X =
2. Look 1- hop away for distinguishing states or strings A B C D E F G H
11
Table Filling Algorithm - step by step
A =
0 1
B =
0 1 0
A C E G C X X =
1 0 1
0 1 D X X X =
1 1 0 E X X X X =
B D F H
1 0 F X X X =
0
G X X X = X X =
1. Mark X between accepting vs. non-accepting state H X X = X X X =
2. Look 1- hop away for distinguishing states or strings A B C D E F G H
12
Table Filling Algorithm - step by step
A =
0 1
B =
0 1 0
A C E G C X X =
1 0 1
0 1 D X X X =
1 1 0 E X X X X =
B D F H
1 0 F X X X =
0
G X X X = X X =
1. Mark X between accepting vs. non-accepting state H X X = X X X X =
2. Look 1- hop away for distinguishing states or strings A B C D E F G H
13
Table Filling Algorithm - step by step
A =
0 1
B = =
0 1 0
A C E G C X X =
1 0 1
0 1 D X X X =
1 1 0 E X X X X =
B D F H
1 0 F X X X X X =
0
G X X X = X X =
1. Mark X between accepting vs. non-accepting state H X X = X X X X =
2. Pass 1: A B C D E F G H
Look 1- hop away for distinguishing states or strings
3. Pass 2:
Look 1-hop away again for distinguishing states or strings
continue….
14
Table Filling Algorithm - step by step
A =
0 1
B = =
0 1 0
A C E G C X X =
1 0 1
0 1 D X X X =
1 1 0 E X X X X =
B D F H
1 0 F X X X X X =
0
G X X X = X X =
1. Mark X between accepting vs. non-accepting state H X X = X X X X =
2. Pass 1: A B C D E F G H
Look 1- hop away for distinguishing states or strings
3. Pass 2:
Look 1-hop away again for distinguishing states or strings Equivalences:
continue…. • A=B
• C=H
• D=G
15
Table Filling Algorithm - step by step
0 1 0 1
0 1 0 0 1
A C E G A C E
1 0 1 1 0
0 1 0
1 1 0 1
B D F H D F
1 0 1 0
0
Equivalences:
• A=B
• C=H
• D=G
16
Table Filling Algorithm – special case
A =
0 1
B =
0 1 0
A C E G C =
1 0 1
0 1 D =
1 1 0 E ? =
B D F H
1 0 F =
0
G =
H =
A B C D E F G H
17
How to minimize a DFA?
• Goal: Minimize the number of states in a DFA
• Algorithm:
1. Eliminate states unreachable from the start state
2. Identify and remove equivalent states
3. Output the resultant DFA
18
Department of Computer and Science Engineering (CSE)
• Example
• Let us consider the following DFA −
Department of Computer and Science Engineering (CSE)
q δ(q,0) δ(q,1)
a B C
b A D
c E F
d E F
e E f
f F f
Department of Computer and Science Engineering (CSE)
Q δ(q,0) δ(q,1)
Outcomes
• Knowledge of DFA
– Minimization of DFA
– Myhill Nerode Theorem
23
FAQ
1. Obtain the Greibach Normal form A1àA2 A3, A2àA3 A1/ b , A3àA1A2/ a.
2. Let G = {{s , c }, {a , b }, P , s },P = S ® asb / a , A ® SbA / ss / ba .Find a derivation
tree whose yield aabbaa.
24
REFERENCES
•Sipser,” Theory Of Computation, Cengage Learning.
•K.L.P MISHRA, “Introduction to computer Theory” .
•Martin J.C., “Introduction to Languages and Theory of
Computation”, Tata McGraw-Hill Publising Company Limited, 3rd
Edition.
•https://youtu.be/cFd3pz5H-TA
• https://youtu.be/qmX7DJ9j1-A
•https://en.wikipedia.org
25
Department of Computer and Science Engineering (CSE)
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
FSM To get basic knowledge of pumping lemma
To get knowledge of regular language
To get knowledge of DFA
The Pumping Lemma for
Regular Sets
3
Pumping Lemma for Regular Sets
4
Pumping Lemma: Proof
5
Pumping Lemma: Proof…
6
Pumping Lemma: Proof…
• For part (1): yk (for k loops)
– Since i<j, y ≠ x z
p0 pi pm
=pj
• For part (2):
– By PHP, the repetition of states has to occur within the first N
symbols in w
– ==> |xy|≤N
7
The Purpose of the Pumping Lemma for RL
8
How to use the pumping lemma?
Think of playing a 2 person game
– Role 1: You claim that the language cannot be
regular
– You win!!
9
Note: This N can be anything (need not necessarily be the #states in the DFA.
It’s the adversary’s choice.)
10
Template string w = 0N1N = 00 …. 011 … 1
N N
Proof…
Because |xy|≤N, xy should contain only 0s
you
(This and because y≠ , implies y=0+)
Therefore x can contain at most N-1 0s
Also, all the N 1s must be inside z
By (3), any string of the form xykz Leq for all k≥0
Case k=0: xz has at most N-1 0s but has N 1s
Therefore, xy0z Leq
Setting k=0 is
referred to as
“pumping down”
This violates the P/L (a contradiction)
12
Closure properties of Regular
Sets
13
Closure properties for Regular Sets (RL)
This is different
• Closure property:
from Kleene
closure
– If a set of regular languages are combined using an
operator, then the resulting language is also regular
• Regular languages are closed under:
– Union, intersection, complement, difference
– Reversal
– Kleene closure
– Concatenation
– Homomorphism Now, lets prove all of this!
– Inverse homomorphism
14
RLs are closed under union
q0 qi qF2 q0 qi qF2
…
…
qFk qFk
17
DFA construction for L ∩ M
18
DFA construction for L ∩ M
a a
q0 qi qj qF2 p0 pi pj pF2
…
DFA for LM
(qF1 ,pF1)
…
(q0 ,p0) (qi ,pi) (qj ,pj)
19
RLs are closed under set difference
20
RLs are closed under reversal
Reversal of a string w is denoted by wR
– E.g., w=00111, wR=11100
Reversal of a language:
• LR = The language generated by reversing all strings in L
21
-NFA Construction for L R
DFA for L
qF1
q0 qi
a
qj qF2 q’0 New start
state
…
Make the
old start state
as the only new qFk
final state
23
Department of Computer and Science Engineering (CSE)
Outcomes
• Knowledge of Regular language and pumping lemma
• Knowledge of DFA
24
FAQ
1. Obtain the Greibach Normal form A1àA2 A3, A2àA3 A1/ b , A3àA1A2/ a.
2. Let G = {{s , c }, {a , b }, P , s },P = S ® asb / a , A ® SbA / ss / ba .Find a derivation
tree whose yield aabbaa.
25
REFERENCES
•Sipser,” Theory Of Computation, Cengage Learning.
•K.L.P MISHRA, “Introduction to computer Theory” .
•Martin J.C., “Introduction to Languages and Theory of
Computation”, Tata McGraw-Hill Publising Company Limited, 3rd
Edition.
• https://youtu.be/bBSM3rs3hDw
• https://youtu.be/AG72s-aFqFs
• https://youtu.be/cFd3pz5H-TA
• https://youtu.be/qmX7DJ9j1-A
•https://en.wikipedia.org
26
Department of Computer and Science Engineering (CSE)
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
FSM
Moore and mealy machine
Equivalence of Moore and Mealy Machines
Finite State Machines with Output (Mealy
and Moore Machines)
• Finite automata Machine receive input and process the
input by changing states.
• The only output that we have seen finite automata
produce so far is a yes/no at the end of processing.
• We will now look at two models of finite automata that
produce more output than a yes/no.
Moore machine
• Basically a Moore machine is just
a FA with two extras.
1. It has TWO alphabets, an input and output alphabet.
2. It has an output letter associated with each state. The machine writes
the appropriate output letter as it enters each state.
11
Department of Computer and Science Engineering (CSE)
• Example 1:
• Convert the following Mealy machine into equivalent
Moore machine.
Department of Computer and Science Engineering (CSE)
• Solution:
• Transition table for above Mealy machine is as follows:
Department of Computer and Science Engineering (CSE)
• For state q1, there is only one incident edge with output
0. So, we don't need to split this state in Moore machine.
• For state q2, there is 2 incident edge with output 0 and 1.
So, we will split this state into two states q20( state with
output 0) and q21(with output 1).
• For state q3, there is 2 incident edge with output 0 and 1.
So, we will split this state into two states q30( state with
output 0) and q31( state with output 1).
• For state q4, there is only one incident edge with output
0. So, we don't need to split this state in Moore machine.
• Transition table for Moore machine will be:
Department of Computer and Science Engineering (CSE)
Department of Computer and Science Engineering (CSE)
• Example 1:
• Convert the following Moore machine into its equivalent
Mealy machine.
Department of Computer and Science Engineering (CSE)
Solution:
The transition table of given Moore machine is as follows:
Q A b Output(λ)
q0 q0 q1 0
q1 q0 q1 1
Department of Computer and Science Engineering (CSE)
Outcomes
FAQ :
REFERENCES :
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
To know about CFG and its definition
Department of Computer and Science Engineering (CSE)
• S→0S1∣ε
(ε to denote the empty or null string.)
Department of Computer and Science Engineering (CSE)
Example #2
G:
S => (S) | SS |
How would you “interpret” the string “(((()))()())” using this grammar?
5
Department of Computer and Science Engineering (CSE)
Example #3
• CFG?
G:
S => 0S1 | A
A => 0A |
6
Department of Computer and Science Engineering (CSE)
7
Department of Computer and Science Engineering (CSE)
Derivation trees
Example :
Production rules:
• E=E+E
• E=E*E
• E=a|b|c
Input
• a*b+c
Department of Computer and Science Engineering (CSE)
Step 1:
Step 2:
Department of Computer and Science Engineering (CSE)
Step 3:
Step 4:
Department of Computer and Science Engineering (CSE)
Step 5:
Department of Computer and Science Engineering (CSE)
13
Department of Computer and Science Engineering (CSE)
15
Department of Computer and Science Engineering (CSE)
Parse Trees
• Each CFG can be represented using a parse tree:
– Each internal node is labeled by a variable in V
– Each leaf is terminal symbol
– For a production, A==>X1X2…Xk, then any internal node labeled A
has k children which are labeled from X1,X2,…Xk from left to right
X1 … Xi … Xk
16
Examples
Recursive inference
A
E + E
0 A 0
F F
Derivation
1 A 1
a 1
Derivation
… …
Recursive
X1 Xi Xk
inference
Derivation Right-most
Recursive
derivation
inference
18
Department of Computer and Science Engineering (CSE)
19
Department of Computer and Science Engineering (CSE)
Outcomes
FAQ :
REFERENCES :
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
CNF
GNF
Chomsky Normal Form
• A context free grammar is said to be in Chomsky Normal
Form if all productions are in the following form:
A → BC
A→α
• A, B and C are non terminal symbols
• α is a terminal symbol
Department of Computer and Science Engineering (CSE)
Preliminary Simplifications
2 Eliminate ε productions
• X is generating if X
* ω for some terminal string ω.
• X is reachable if there is a derivation X
* αXβ
for some α and β
Department of Computer and Science Engineering (CSE)
S → AB | a
A→b Initial CFL grammar
S → AB | a
Identify generating symbols
A→b
S→a
Remove non-generating
A→b
Department of Computer and Science Engineering (CSE)
S→a
Identify reachable symbols
A→b
S → AB | a S→a
A→b A→b
Department of Computer and Science Engineering (CSE)
Eliminate ε Productions
A
* ε
Nullable variable
Department of Computer and Science Engineering (CSE)
If A is a nullable variable
S → ASA | aB
A→B|S Nullable: {A, B}
B→b|ε
Department of Computer and Science Engineering (CSE)
Eliminate ε Productions
S → ASA | aB S → ASA | aB | AS | SA | S | a
A→B|S A→B|S
B→b|ε B→b
Department of Computer and Science Engineering (CSE)
Eliminate ε Productions
S → ASA | aB S → ASA | aB | AS | SA | S | a
A→B|S A→B|S
B→b|ε B→b
Department of Computer and Science Engineering (CSE)
Eliminate ε Productions
S → ASA | aB S → ASA | aB | AS | SA | S | a
A→B|S A→B|S
B→b|ε B→b
Department of Computer and Science Engineering (CSE)
A
* B
A → B, B → ω, then A → ω
Department of Computer and Science Engineering (CSE)
Example:
T = {*, +, (, ), a, b, 0, 1} Pairs Productions
( E, E ) E→E+T
I → a | b | Ia | Ib | I0 | I1 ( E, T ) E→T*F
F → I | (E) ( E, F ) E → (E)
T→F|T*F ( E, I ) E → a | b | Ia | Ib | I0 | I1
E→T|E+T ( T, T ) T→T*F
( T, F ) T → (E)
( T, I ) T → a | b | Ia |Ib | I0 | I1
Basis: (A, A) is a unit pair ( F, F ) F → (E)
of any variable A, if ( F, I ) F → a | b | Ia | Ib | I0 | I1
A * A by 0 steps. ( I, I ) I → a | b | Ia | Ib | I0 | I1
Department of Computer and Science Engineering (CSE)
Example:
Pairs Productions
… …
( T, T ) T→T*F
( T, F ) T → (E)
( T, I ) T → a | b | Ia |Ib | I0 | I1
… …
I → a | b | Ia | Ib | I0 | I1
E → E + T | T * F | (E ) | a | b | la | lb | l0 | l1
T → T * F | (E) | a | b | Ia | Ib | I0 | I1
F → (E) | a | b | Ia | Ib | I0 | I1
Department of Computer and Science Engineering (CSE)
Final Simplification
Chomsky Normal Form (CNF)
A → αX
Example:
S → XA | BB S = A1 A1 → A2A3 | A4A4
B → b | SB X = A2 A4 → b | A1A4
X→b A = A3 A2 → b
A→a B = A4 A3 → a
Example:
A4 → A1A4
Department of Computer and Science Engineering (CSE)
Example:
Example:
A4 → A4A4A4
Department of Computer and Science Engineering (CSE)
Example:
Second Step
Eliminate Left
Recursions
Example:
A1 → A2A3 | A4A4
A4 → bA3A4 | b | bA3A4Z | bZ A → αX
Z → A4A4 | A4A4 Z
A2 → b GNF
A3 → a
Department of Computer and Science Engineering (CSE)
Example:
A1 → A2A3 | A4A4
A4 → bA3A4 | b | bA3A4Z | bZ
Z → A4A4 | A4A4 Z
A2 → b
A3 → a
Example:
FAQ :
1. Convert the following grammar to the Chomsky Normal Form.
S→P
P → aPb | ε
2. Is the following grammar context-free?
S → aBSc | abc
Ba → aB
Bb → bb
3. Prove that the language L = { anbncn | n ≥ 1 } is not context-free.
4. Convert the following grammar to the Greibach Normal Form.
S -> a | CD | CS
A -> a | b | SS
C -> a
D -> AS
Department of Computer and Science Engineering (CSE)
REFERENCES :
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
To know about Simplifying CFGs, Normal forms
Department of Computer and Science Engineering (CSE)
Regular Grammar
5
Three ways to simplify/clean a CFG
2. Eliminate -productions
6
Eliminating useless symbols
A symbol X is reachable if there exists:
– S * X
7
Algorithm to detect useless
1.
symbols
First, eliminate all symbols that are not generating
8
Example: Useless symbols
• SAB | a
• A b
1. A, S are generating
2. B is not generating (and therefore B is useless)
3. ==> Eliminating B… (i.e., remove all productions that involve B)
1. S a
2. A b
4. Now, A is not reachable and therefore is useless
5. Simplified G:
1. S a What would happen if you reverse the order:
i.e., test reachability before generating?
Will fail to remove: A
b
9
X * w
Algorithm to find all generating symbols
• Given: G=(V,T,P,S)
• Basis:
– Every symbol in T is obviously generating.
• Induction:
– Suppose for a production A , where is generating
– Then, A is also generating
10
S * X
Algorithm to find all reachable symbols
• Given: G=(V,T,P,S)
• Basis:
– S is obviously reachable (from itself)
• Induction:
– Suppose for a production A 1 2… k, where A is reachable
– Then, all symbols on the right hand side, {1, 2 ,… k} are also
reachable.
11
Eliminating -productions
A =>
12
Eliminating -productions
It is not possible to eliminate -productions for languages
which include in their word set
13
Algorithm to detect all nullable
• Basis:
variables
– If A is a production in G, then A is nullable
(note: A can still have other productions)
• Induction:
– If there is a production B C1C2…Ck, where every Ci is nullable, then
B is also nullable
14
Eliminating -productions
Given: G=(V,T,P,S)
Algorithm:
1. Detect all nullable variables in G
2. Then construct G1=(V,T,P1,S) as follows:
i. For each production of the form: AX1X2…Xk, where k≥1,
suppose m out of the k Xi’s are nullable symbols
ii. Then G1 will have 2m versions for this production
i. i.e, all combinations where each Xi is either present or absent
iii. Alternatively, if a production is of the form: A, then
remove it
15
Example: Eliminating -productions
• Let L be the language represented by the following CFG G:
i. SAB
ii. AaAA |
iii. BbBB |
Simplified
Goal: To construct G1, which is the grammar for L-{} grammar
16
Eliminating unit productions
18
The Unit Pair Algorithm: to remove unit productions
– Induction: If (A,B) and (B,C) are unit pairs, and AC is also a unit pair.
19
The Unit Pair Algorithm: to remove unit productions
Input: G=(V,T,P,S)
Goal: to build G1=(V,T,P1,S) devoid of unit
productions
Algorithm:
1. Find all unit pairs in G
2. For each unit pair (A,B) in G:
1. Add to P1 a new production A, for every B which is a
non-unit production
2. If a resulting production is already there in P, then there is no
need to add it.
20
Example: eliminating unit
productions
Unit pairs Only non-unit
productions to be
added to P1
G:
1. E T | E+T (E,E) E E+T
2. T F | T*F
3. F I | (E) (E,T) E T*F
4. I a | b | Ia | Ib | I0 | I1 (E,F) E (E)
(E,I) E a|b|Ia | Ib | I0 | I1
(T,T) T T*F
(T,F) T (E)
(T,I) T a|b| Ia | Ib | I0 | I1
G1:
1. E E+T | T*F | (E) | a| b | Ia | Ib | I0 | I1 (F,F) F (E)
2. T T*F | (E) | a| b | Ia | Ib | I0 | I1
3. F (E) | a| b | Ia | Ib | I0 | I1 (F,I) F a| b| Ia | Ib | I0 |
4. I a | b | Ia | Ib | I0 | I1 I1
(I,I) I a| b | Ia | Ib | I0 |
I1
21
Putting all this together…
• Theorem: If G is a CFG for a language that contains at
least one string other than , then there is another CFG
G1, such that L(G1)=L(G) - , and G1 has:
– no -productions
– no unit productions
– no useless symbols
• Algorithm:
Step 1) eliminate -productions
Step 2) eliminate unit productions
Step 3) eliminate useless symbols
22
Why normal forms?
• If all productions of the grammar could be
expressed in the same form(s), then:
23
Chomsky Normal Form (CNF)
Let G be a CFG for some L-{}
Definition:
G is said to be in Chomsky Normal Form if all its
productions are in one of the following two
forms:
i. A BC where A,B,C are variables, or
ii. Aa where a is a terminal
– G has no useless symbols
– G has no unit productions
– G has no -productions
24
CNF checklist
Is this grammar in CNF?
G1:
1. E E+T | T*F | (E) | Ia | Ib | I0 | I1
2. T T*F | (E) | Ia | Ib | I0 | I1
3. F (E) | Ia | Ib | I0 | I1
4. I a | b | Ia | Ib | I0 | I1
Checklist:
• G has no -productions
• G has no unit productions
• G has no useless symbols
• But…
• the normal form for productions is violated
B2 C2
– AB1C1 C1B2C2 … Ck-3Bk-2Ck-2 Ck-2Bk-1Bk
B1 C1
26
Example #1
G in CNF:
G:
X0 => 0
S => AS | BABC
X1 => 1
A => A1 | 0A1 | 01
S => AS | BY1
B => 0B | 0 Y1 => AY2
C => 1C | 1 Y2 => BC
A => AX1 | X0Y3 | X0X1
Y3 => AX1
B => X0B | 0
C => X1C | 1
27
Example #2
28
Languages with
G in CNF:
E.g., consider:
X0 => 0
G:
X1 => 1
S => AS | BABC
S => AS | BY1 |
A => A1 | 0A1 | 01 |
B => 0B | 0 | Y1 => AY2
C => 1C | 1 | Y2 => BC
29
C => X1C | 1
Other Normal Forms
30
Return of the Pumping Lemma !!
31
Why pumping lemma?
32
Observe that any parse tree generated by a CNF will be a
binary tree, where all internal nodes have exactly two children
(except those nodes connected to the leaves).
h
Ind. Step: h = k = height
S will have exactly two children:
SAB
Fact:
– If the height of a parse tree is h, then
• ==> |w| ≤ 2h-1
Implication:
– If |w| ≥ 2h, then
• Its parse tree’s height is at least h+1
35
The Pumping Lemma for CFLs
Let L be a CFL.
Then there exists a constant N, s.t.,
– if z L s.t. |z|≥N, then we can write z=uvwxy, such that:
1. |vwx| ≤ N
2. vx≠
3. For all k≥0: uvkwxky L
36
Proof: Pumping Lemma for CFL
• If L=Φ or contains only , then the lemma is
trivially satisfied (as it cannot be violated)
37
Meaning:
Repetition in the
Parse tree for z last m+1 variables
h-m≤ i < j ≤ h
S = A0 S = A0
+
A1 Ai = Aj
A2 Ai
h ≥ m+1 h ≥ m+1
Aj
m+1
Ah-1
u v x y
Ah=a
w
z z = uvwxy
• Therefore, vx≠
38
Extending the parse tree…
S = A0
S = A0
Ai
w
Ai u y
u v x y
z = uwy
v x
w ==> For all k≥0: uvkwxky L
z = uvkwxky 39
Proof contd..
But, 2m =N
==> |vwx| ≤ N
40
Application of Pumping Lemma for CFLs
41
Proof contd…
– z = uvwxy
– As z = aNbNcN and |vwx| ≤ N and vx≠
• ==> v, x cannot contain all three symbols (a,b,c)
• ==> we can pump up or pump down to build another string
which is L
42
Example #2 for P/L application
• L = { ww | w is in {0,1}*}
43
Example 3
2
• L={ 0k | k is any integer)
44
Example 4
• L = {aibjck | i<j<k }
45
CFL Closure Properties
46
Closure Property Results
• CFLs are closed under:
– Union
– Concatenation
– Kleene closure operator
– Substitution
– Homomorphism, inverse homomorphism
– reversal
• CFLs are not closed under: Note: Reg languages
– Intersection are closed
under
– Difference these
– Complementation operators
47
Strategy for Closure Property Proofs
• First prove “closure under substitution”
• Using the above result, prove other closure properties
• CFLs are closed under:
– Union
– Concatenation
– Kleene closure operator
– Substitution
Prove
– Homomorphism, inverse homomorphism
this first
– Reversal
48
Note: s(L) can use
a different alphabet
49
CFLs are closed under Substitution
What is s(L)?
L s(L)
w1 s(w1) Note: each s(w)
w2 s(L) s(w2) is itself a set of strings
w3 s(w3)
w4 s(w4)
… …
50
CFLs are closed under Substitution
…
x1 x2 xn
51
Substitution of a CFL: example
S=> S0SS0 | S1 S S1 |
S0=> aS0b | ab
S1=> xx | yy
52
CFLs are closed under union
Let L1 and L2 be CFLs
To show: L2 U L2 is also a CFL
Let us show by using the result of Substitution
• Make a new language:
– Lnew = {a,b} s.t., s(a) = L1 and s(b) = L2
==> s(Lnew) == same as == L1 U L2
• A more direct, alternative proof
– Let S1 and S2 be the starting variables of the grammars
for L1 and L2
• Then, Snew => S1 | S2
53
CFLs are closed under concatenation
• Let L1 and L2 be CFLs
Let us show by using the result of Substitution
• Make Lnew= {ab} s.t.,
s(a) = L1 and s(b)= L2
==> L1 L2 = s(Lnew)
54
CFLs are closed under Kleene Closure
• Let L be a CFL
– Then, L* = s(Lnew)
55
CFLs are closed under Reversal
56
CFLs are not closed under Intersection
• Existential proof:
– L1 = {0n1n2i | n≥1,i≥1}
– L2 = {0i1n2n | n≥1,i≥1}
• Both L1 and L1 are CFLs
– Grammars?
• But L1 L2 cannot be a CFL
– Why?
• We have an example, where intersection is not
closed.
• Therefore, CFLs are not closed under
intersection
57
CFLs are not closed under complementation
• Follows from the fact that CFLs are not closed under
intersection
• L1 L2 = L1 U L2
58
Department of Computer and Science Engineering (CSE)
Outcomes
FAQ
References
• Hopcroft J.E. and Ullman J.D., “Introduction to Automata
Theory Languages and Computation”, Narosa
Publications.
• Sipser,” Theory Of Computation, Cengage Learning.
• https://youtu.be/qmX7DJ9j1-A
• http://studentsfocus.com/
THANK YOU
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Topic: Undecidability
DISCOVER . LEARN .
University Institute of Engineering (UIE) EMPOWER
Department of Computer and Science Engineering (CSE)
Outcome:
Student will understand the
• To know about Context sensitive language and
grammar.
• Relation between languages of classes.
Context-Sensitive Grammar –
A Context-sensitive grammar is an Unrestricted grammar in
which all the productions are of form –
Where
N = Set of non-terminal symbols
Σ = Set of terminal symbols
S = Start symbol of the production
P = Finite set of productions
Example –
Consider the following CSG.
S → abc/aAbc
Ab → bA
Ac → Bbcc
bB → Bb
aB → aa/aaA
• Explanation
• Using S->a and S->b,
• a and b can be generated.
• Similarly by using S->aSa
• ->aba
• aba can be generated.
• Other strings which can be generated from grammar are
as follows −
• a,b,aba,bab,aaa,bbb,ababa,.....
• Therefore, the language generated for the given grammar
over the alphabet {a,b} is the set of all odd length
palindromes.
Outcomes
• To know about Context sensitive language and
grammar.
• Relation between languages of classes.
9
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
FAQ
1. Convert the given expression to PDA
I --> a | b | Ia | Ib | I0 | I1
2. Design a PDA for accepting a language {L= anbn | n >=1}
3. What is the language generated by the grammar
G=(V,T,P,S) where P={S->aSb, S->ab}?
REFERENCES
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Push down automata
Applications of Push Down Automata
• What is?
– FA to Reg Lang, PDA is to CFL
• PDA == [ -NFA + “a stack” ]
• Why a stack?
4
University Institute of Engineering (UIE)
old state input symb. Stack top new state(s) new Stack top(s)
δ : Q x ∑ x => Q x
δ : The Transition Function
δ(q,a,X) = {(p,Y), …}
1. state transition from q to p
2. a is the next input symbol a X Y
3. X is the current stack top symbol q p
4. Y is the replacement for X;
it is in * (a string of stack Y=? Action
symbols)
i. Set Y = for: Pop(X) i) Y= Pop(X)
ii. If Y=X: ii) Y=X Pop(X)
stack top is unchanged Push(X)
iii. If Y=Z1Z2…Zk: X is popped
and is replaced by Y iii) Y=Z1Z2..Zk Pop(X)
in Push(Zk)
reverse order (i.e., Z1 will be Push(Zk-1)
the …
Push(Z2)
new stack top) Push(Z1)
7
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
(q0,1,111Z0) (q1,11,11Z0)
11
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
13
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
14
University Institute of Engineering (UIE)
Example: Matching parenthesis “(” “)”
PN: ( {q0}, {(,)}, {Z0,Z1}, δN, q0, Z0 ) Pf: ( {p0,q0 ,pf}, {(,)}, {X0,Z0,Z1}, δf, p0, X0 , pf)
start
q0
start
,X0/Z0X0 ,X0/ X0
p0 q0 pf
PF==> PN construction
• Main idea:
– Whenever PF reaches a final state, just make an -transition into a new
end state, clear out the stack and accept
– Danger: What if PF design is such that it clears the stack midway without
entering a final state?
to address this, add a new start symbol X0 (not in of PF)
PN = (Q U {p0,pe}, ∑, U {X0}, δN, p0, X0)
PN:
, X0/Z0X0 , any/ , any/
New
p0 q0 , any/ pe
start
…
, any/
PF
16
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
PDA by PDA by
≡
final state empty stack
?
CFG
17
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Example 1
18
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Initial state of the PDA:
19
University Institute of Engineering (UIE)
PDA as a state diagram
δ(qi,a, X)={(qj,Y)}
a, X / Y Next
qi qj state
, Z0/Z0 q0 q1 q2
, Z0/Z0 , Z0/Z0
, 0/0
, 1/1 Go to acceptance
Switch to
popping mode
This would be a non-deterministic PDA
q0 q1 q2
, Z0 / Z0 ), ( / , Z0 / Z0
, Z0 / Z0 Go to acceptance (by final state)
when you see the stack bottom symbol
Switch to
(, ( / ( (
popping mode
(, Z0 / ( Z0 To allow adjacent
blocks of nested paranthesis
∑ = { (, ) }
(,Z0 / ( Z0 = {Z0, ( }
(,( / ( (
), ( /
Q = {q0,q1}
start ,Z0/ Z0
q0 q1
,Z0/ Z0
We are going to design the first part i.e. 1 comes before 0's. The
logic is that read single 1 and push two 1's onto the stack.
Thereafter on reading two 0's, POP two 1's from the stack. The δ
can be
δ(q0, 1, Z) = (q0, 11, Z) Here Z represents that stack is empty
δ(q0, 0, 1) = (q0, ε)
Now, consider the second part i.e. if 0 comes before 1's. The logic
is that read first 0, push it onto the stack and change state from q0
to q1. [Note that state q1 indicates that first 0 is read and still
second 0 has yet to read].
University Institute of Engineering (UIE) 24
Continue..
Being in q1, if 1 is encountered then POP 0. Being in q1, if 0 is
read then simply read that second 0 and move ahead. The δ will
be:
δ(q0, 0, Z) = (q1, 0Z)
δ(q1, 0, 0) = (q1, 0)
δ(q1, 0, Z) = (q0, ε) (indicate that one 0 and one 1 is already r
ead, so simply read the second 0)
δ(q1, 1, 0) = (q1, ε)
Now, summarize the complete PDA for given L is:
δ(q0, 1, Z) = (q0, 11Z)
δ(q0, 0, 1) = (q1, ε)
δ(q0, 0, Z) = (q1, 0Z)
δ(q1, 0, 0) = (q1, 0)
δ(q1, 0, Z) = (q0, ε)
δ(q0, ε, Z) = (q0, ε) ACCEPT state
Application of PDA
Summary
• Applications of PDA
27
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
FAQ :
REFERENCES :
• https://www.geeksforgeeks.org/introduction-of-
pushdown-automata/
• Martin J.C., “Introduction to Languages and Theory of
Computation”, Tata McGraw-Hill Publishing Company
Limited, 3rd Edition.
• https://www.tutorialspoint.com
• https://en.wikipedia.org
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Finite Automata- DFA, NFA
3
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
4
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
• Input: a word w in ∑*
• Question: Is w acceptable by the DFA?
• Steps:
– Start at the “start state” q0
– For every input symbol in the sequence w do
• Compute the next state from the current state, given the current
input symbol in w and the transition function
– If after all symbols in w are consumed, the current state
is one of the final states (F) then accept w;
– Otherwise, reject w.
5
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Regular Languages
6
University Institute of Engineering (UIE)
The Chomsky Hierachy
• A containment hierarchy of classes of formal languages
Regular Context-
(DFA) Context- Recursively-
free
sensitive enumerable
(PDA)
(LBA) (TM)
Example #1
• Build a DFA for the following language:
– L = {w | w is a binary string that contains 01 as a substring}
• Steps for building a DFA to recognize L:
– ∑ = {0,1}
– Decide on the states: Q
– Designate start state and final state(s)
– δ: Decide on the transitions:
• Final states == same as “accepting states”
• Other states == same as “non-accepting states”
8
University Institute of Engineering (UIE)
Regular expression: (0+1)*01(0+1)*
DFA for strings containing 01
q1 q1 q2
empty strings? *q2 q2 q2
Example #2
Clamping Logic:
– A clamping circuit waits for a ”1” input, and turns on forever.
However, to avoid clamping on spurious noise, we’ll design a DFA
that waits for two consecutive 1s in a row before clamping on.
• Build a DFA for the following language:
L = { w | w is a bit string which contains the
substring 11}
• State Design:
– q0 : start state (initially off), also means the most recent input was
not a 1
– q1: has never seen 11 but the most recent input was a 1
– q2: has seen 11 at least once
10
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Example #3
11
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
• δ (q,wa) = δ (δ(q,w), a)
• δ (q0,wa) = ?
12
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Language of a DFA
A DFA A accepts string w if there is a path from q0 to an
accepting (or final) state that is labeled by w
13
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
1 qj
qi • Each transition function therefore
…
1 maps to a set of states
qk
14
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
15
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
16
University Institute of Engineering (UIE)
Regular expression: (0+1)*01(0+1)*
NFA for strings containing 01
w h i l e
q0 q1 q2 q3 q4 q5
w h i l e
q0 q1 q2 q3 q4 q5
18
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Example #2
19
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
• Induction:
– Let δ (q0,w) = {p1,p2…,pk}
– δ (pi,a) = Si for i=1,2...,k
– Then, δ (q0,wa) = S1 U S2 U … U Sk
20
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Language of an NFA
21
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
22
University Institute of Engineering (UIE)
DFAs and NFAs are equivalent in their power to capture langauges !!
Summary
• DFA
– Definition
– Transition diagrams & tables
• Regular language
• NFA
– Definition
– Transition diagrams & tables
• DFA vs. NFA
• NFA to DFA conversion using subset construction
24
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
FAQ
1. How a Non deterministic finite state automaton (NFA)
differs from a Deterministic finite state automaton
(DFA).
2. Write RE which denotes the language L over the set =
{a,b} such that all the strings do not contain the substring
ab.
3. Give a regular expression for the set of all strings having
odd number of 1’s
4. Prove that 12 +22+32+……+ n2= ∑n2 =
(n(n+1)(2n+1))/6.
References
• Https://en.wikipedia.org/wiki/Finite-state_machine
• https://www.safaribooksonline.com
• http://studentsfocus.com/
• http://www.francisxavier.ac.in/
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Finite Automata- DFA, NFA
Properties of FA
Transition table
Transition function
• State Properties
• Transition properties
References
• Https://en.wikipedia.org/wiki/Finite-state_machine
• https://www.safaribooksonline.com
• http://studentsfocus.com/
• http://www.francisxavier.ac.in/
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Kleene’s Theorem
Kleene’s Theorem
Theorem 1 (Part 1 of Kleene's theorem): Any regular
language is accepted by a finite automaton.
3
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)
Inductive Step
Qc = Q1 ∪ Q2
qc,0 = q1,0
δ c = δ 1 ∪ δ 2 ∪ { (q, ʌ , { q2,0 } ) | q ∈ A1 }
Ac = A2
Summary
• Kleene’s Theorem
– Part 1
– Part 2
References
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Ambiguity
Ambiguous and unambiguous grammar
Department of Computer and Science Engineering (CSE)
Types of Grammar
Ambiguous Grammar
• Parse tree
• Or derivation tree
• Or syntax tree
• Or leftmost derivation
• Or rightmost derivation
Department of Computer and Science Engineering (CSE)
• Example-
• Consider the following grammar-
• E → E + E / E x E / id
Since two parse trees exist for string w, therefore the grammar is
ambiguous.
Ambiguity in CFGs and CFLs
6
Ambiguity in CFGs
Example:
S ==> AS | LM derivation #1: LM derivation #2:
A ==> A1 | 0A1 | 01 S => AS S => AS
=> 0A1S => A1S
=>0A11S => 0A11S
Input string: 00111 => 00111S => 00111S
Can be derived in two ways => 00111 => 00111
7
Why does ambiguity matter?
Values are
E ==> E + E | E * E | (E) | a | b | c | 0 | 1 different !!!
string = a * b + c
E
• LM derivation #1:
•E => E + E => E * E + E E + E (a*b)+c
==>* a * b + c
E * E c
a b
E
• LM derivation #2
•E => E * E => a * E => E * E a*(b+c)
a * E + E ==>* a * b + c
a E + E
The calculated value depends on which
of the two parse trees is actually used. b c
8
Removing Ambiguity in Expression Evaluations
9
Inherently Ambiguous CFLs
10
Department of Computer and Science Engineering (CSE)
Unambiguous Grammar-
• Parse tree
• Or derivation tree
• Or syntax tree
• Or leftmost derivation
• Or rightmost derivation
Department of Computer and Science Engineering (CSE)
Example 1:
• Consider a grammar G is given as follows:
• S → AB | aaB
• A → a | Aa
• B→b
Determine whether the grammar G is ambiguous or not. If G
is ambiguous, construct an unambiguous grammar
equivalent to G.
Department of Computer and Science Engineering (CSE)
Solution:
Let us derive the string "aab"
Department of Computer and Science Engineering (CSE)
• Example-
• Consider the following grammar-
• E→E+T/T
• T→TxF/F
• F → id
Outcomes
• Knowledge of ambiguity.
• Knowledge of ambiguous and unambiguous grammar.
Department of Computer and Science Engineering (CSE)
FAQ :
REFERENCES :
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Recursively Enumerable and Recursive Languages,
Unrestricted Grammars
Chomsky hierarchies of grammars.
Ld = L(M) (2)
Case 1) wj is in Ld (4)
By definition of Ld given in (1), either wj does not encode a TM, or wj does encode a TM, call it M, and wj is not in
L(M). But we know that wj encodes a TM (3: that’s where it came from). Therefore:
But then (2) and (5) imply that wj is not in Ld contradicting (4).
wj is in L(M) (7)
Since both case 1) and case 2) lead to a contradiction, no TM M such that Ld = L(M) can exist. Therefore Ld is not
recursively enumerable. •
5
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Note:
Ld
6
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Theorem: Lu is not recursive.
Suppose that Lu = L(M’) where M’ is a TM that always halts. Construct an algorithm (i.e., a TM
that always halts)Ldfor as follows:
7
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
If a given string is in Lu, then the above algorithm will correctly determine that, halt and say
yes.
If the given string is not in Lu, then there are three cases:
1) the string doesn't have a TM as a prefix. In this case the above algo correctly detects this
fact, and reports the string is not in Lu.
2) the string has a TM prefix, and the TM halts and rejects on the suffix. In this case the above
algo correctly reports the string is not in Lu.
3) the string has a TM prefix, and the TM goes into an infinite loop on the suffix. In this case
the above algo also goes into an infinite loop, but that’s ok since the string as a whole is not in
Lu anyway, and we are just trying to show there exists a TM for only accepting strings in Lu.
2. is not recursive
Ld
3. It follows that Lu is not recursive.
Ld
The second point was established by the corollary.
The first point was established by the theorem on the preceding slide.
This type of proof is commonly referred to as a reduction. Specifically, the problem
of recognizing was reduced to the problem of recognizing Lu
Ld
9
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
(P2):
Input: Turing machine M with input alphabet Σ and string w in Σ*.
Question: Does M halt on w?
10
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Theorem: Lh is not recursive.
Suppose that Lh = L(M’) where M’ is a TM that always halts. Construct an algorithm (i.e., a TM
that always halts) for Lu as follows:
11
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
1. If Lh is recursive, then so is Lu
2. Lu is not recursive
[Lu and Lh both are recursively enumerable: for proof see Dr. Shoaff!]
12
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Define another language Lt:
Or equivalently:
Note that:
Lt
= {x | x is in {0, 1}*, and either x does not encode a TM, or it does encode a TM, call it M,
and there exists a string w in {0, 1}* such that M does not terminate on w}
(P0):
Input: Program P.
Question: Does P contain an infinite loop?
13
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Unrestricted grammars
Type 0 Grammar
Type 1 Grammar
• Type 1 grammar is known as Context Sensitive Grammar. The
context sensitive grammar is used to represent context
sensitive language. The context sensitive grammar follows the
following rules:
• The context sensitive grammar may have more than one
symbol on the left hand side of their production rules.
• The number of symbols on the left-hand side must not exceed
the number of symbols on the right-hand side.
• The rule of the form A → ε is not allowed unless A is a start
symbol. It does not occur on the right-hand side of any rule.
• The Type 1 grammar should be Type 0. In type 1, Production is
in the form of V → T
• Where the count of symbol in V is less than or equal to T.
Type 2 Grammar
Type 3 Grammar
REFERENCES :
•Hopcroft J.E. and Ullman J.D., “Introduction to Automata Theory
Languages and Computation”, Narosa Publications.
•https://www.geeksforgeeks.org/recursive-and-recursive-
enumerable-languages-in-toc/
•https://www.javatpoint.com/automata-chomsky-hierarchy
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Turing machines
Examples: 1
3
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Examples: 2
4
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Examples: 3
5
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Examples: 4
Construct TM for the addition function for the unary number system.
6
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Examples: 5
7
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Summary
• Turing machine
– Examples of Turing Machines
REFERENCES :
•Hopcroft J.E. and Ullman J.D., “Introduction to Automata Theory
Languages and Computation”, Narosa Publications.
•https://www.javatpoint.com/examples-of-turing-machine
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Turing machines.
Hierarchy of Turing machine
Recursive Languages
Context-Free Languages
Regular Languages
3
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Recursive Languages
Context-Sensitive Languages
Context-Free Languages - ε
Regular Languages - ε
4
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
5
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Finite
Control
• Two-way, infinite tape, broken into cells, each containing one symbol.
• Two-way, read/write tape head.
• Finite control, i.e., a program, containing the position of the read head,
current symbol being scanned, and the current state.
• An input string is placed on the tape, padded to the left and right infinitely
with blanks, read/write head is positioned at the left end of input string.
• In one move, depending on the current state and the current symbol being
scanned, the TM 1) changes state, 2) prints a symbol over the cell being
scanned, and 3) moves its’ tape head one cell left or right.
• Many modifications possible.
7
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• A DTM is a seven-tuple:
M = (Q, Σ, Γ, δ, q0, B, F)
Intuitively, δ(q,s) specifies the next state, symbol to be written, and the direction of
tape head movement by M after reading symbol s while in state q.
8
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
0 1 X Y B
q0 (q1, X, R) - - (q3, Y, R) -
q1 (q1, 0, R) (q2, Y, L) - (q1, Y, R) -
q2 (q2, 0, L) - (q0, X, R) (q2, Y, L) -
q3 - - - (q3, Y, R) (q4, B, R)
q4 - - - - -
• Other Examples:
000111 00
11 001
011
11
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
0
00
10
10110
Not ε
0 1 B
q0 (q0, 0, R) (q0, 1, R) (q1, B, L)
q1 (q2, 0, R) - -
q2 - - -
12
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
13
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
14
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
x1x2…xi-1qxixi+1…xn
x1x2…xi-1qxixi+1…xn |— x1x2…xi-1ypxi+1…xn
x1x2…xnq |— x1x2…xnyp
15
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Definition: Let M = (Q, Σ, Г, δ, q0, B, F) be a TM, and let w be a string in Σ*. Then w is
accepted by M iff
{w | w is in Σ* and w is accepted by M}
• Notes:
– In contrast to FA and PDAs, if a TM simply passes through a final state then the
string is accepted.
– Given the above definition, no final state of an TM need have any exiting
transitions. Henceforth, this is our assumption.
– If x is not in L(M) then M may enter an infinite loop, or halt in a non-final state.
– Some TMs halt on all inputs, while others may not. In either case the language
defined by TM is still well defined.
16
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Notes:
– The set of all recursive languages is a subset of the set of all recursively enumerable
languages
17
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Recursive Languages
Context-Sensitive Languages
Context-Free Languages - ε
Regular Languages - ε
18
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Observation: Let L be an r.e. language. Then there is an infinite list M0, M1, … of TMs
such that L = L(Mi).
• Question: Let L be a recursive language, and M0, M1, … a list of all TMs such that L
= L(Mi), and choose any i>=0. Does Mi always halt?
• Answer: Maybe, maybe not, but at least one in the list does.
• Question: Let L be a recursive enumerable language, and M0, M1, … a list of all
TMs such that L = L(Mi), and choose any i>=0. Does Mi always halt?
• Answer: Maybe, maybe not. Depending on L, none might halt or some may halt.
L is Recursively enumerable:
TM exist, M0, M1, …
L is Recursive:
at least one TM halts on L and on ∑* - L, others may or may not
L is not R.E:
no TM exist
• Let M be a TM.
21
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
22
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Let M be a TM.
– Question: Suppose that L(M) is recursive. Does that mean that M always
halts?
– Answer: Not necessarily. However, some TM M’ must exist such that
L(M’) = L(M) and M’ always halts.
23
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
24
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
25
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
REFERENCES :
•Hopcroft J.E. and Ullman J.D., “Introduction to Automata Theory
Languages and Computation”, Narosa Publications.
UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)
Outcome:
• Student will understand the
Decidable and undecidable problem.
Halting problem
PCP
MPCP
Introduction to Undecidability
Undecidable Languages
From a practical perspective, many decision problems do not seem all that interesting.
However, from a theoretical perspective they are for the following two reasons:
– Decision problems are more convenient/easier to work with when proving complexity results.
– Non-decision counter-parts are typically at least as difficult to solve.
• Notes:
– The following terms and phrases are analogous:
6
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Analogy:
Input: DFA M with input alphabet Σ and string w in Σ*.
Question: Is w in L(M)?
Is this problem (regular language) decidable? Yes! DFA always accepts or rejects.
7
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Over-All Approach:
• As We Will See:
– P3 will correspond to the language Lu
– Proving P3 (un)decidable is equivalent to proving Lu (non)recursive
8
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Encode:
111code111code211code311 … 11coder111
where each codei is one transitions’ encoding. Let this encoding of M be denoted by <M>.
9
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Less Formally:
– Every state, tape symbol, and movement symbol is encoded as a sequence of 0’s:
q1, 0
q2, 00
q3 000
:
0 0
1 00
B 000
L 0
R 00
– Note that 1’s are not used to represent the above, since 1 is used as a special separator symbol.
– Example:
δ(q2, 1) = (q3 , 0, R)
Is encoded as:
00100100010100
10
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
0 1 B
q1 (q1, 0, R) (q1, 1, R) (q2, B, L)
q2 (q3, 0, R) - -
q3 - - -
1110101010100110100101001001101000100100010110010100010100111
01100001110001
111111
11
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Definition:
– Question: Is Lt recursive?
– Answer: Yes. [Check for format, i.e. order and number of 0’s and 1’s, syntax
checking]
– Question: Is Lt decidable:
– Answer: Yes (same question).
12
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
13
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Recall:
0 1 B
q1 (q1, 0, R) (q1, 1, R) (q2, B, L)
q2 (q3, 0, R) - -
q3 - - -
1110101010100110100101001001101000100100010110010100010100111
111010101010011010010100100110100010010001011001010001010011101110
11101010101001101001010010011010001001000101100101000101001110011011
1
01100001110001
111111
14
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
(P3):
Input: Turing machine M with input alphabet Σ and one final state, and string w in
Σ*.
Question: Is w in L(M)?
15
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
16
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
• Recall:
0 1 B
q1 (q1, 0, R) (q1, 1, R) (q2, B, L)
q2 (q3, 0, R) - -
q3 - - -
11101010101001101001010010011010001000100010110010100010100111
01100001110001
111111
17
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Example 1: PCP
x1 x2 x3
M abb aa aaa
N bba aaa aa
• Here,
• x2x1x3 = ‘aaabbaaa’
• and y2y1y3 = ‘aaabbaaa’
• We can see that
• x2x1x3 = y2y1y3
• Hence, the solution is i = 2, j = 1, and k = 3.
Why MPCP ?
REFERENCES :
•Hopcroft J.E. and Ullman J.D., “Introduction to Automata Theory
Languages and Computation”, Narosa Publications.
•https://www.javatpoint.com/introduction-to-undecidability
•https://www.tutorialspoint.com/automata_theory/post_correspondence_
problem.htm
•https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.721.2199&r
ep=rep1&type=pdf