Professional Documents
Culture Documents
Unit 4 CFG
Unit 4 CFG
Unit 4 CFG
Syllabus
Unit Contents Lectures
1. Basic Mathematical Objects and Mathematical Induction: Sets, Logic, Functions, Relations, Alphabets, Strings, 5
Language, Principle of Mathematics Induction, Recursive Definition
2. Regular Expression and finite Automata: Regular Language and Regular Expression, Memory required to recognize a 10
language, Finite Automata, Capability and Limitations of finite State Machine, Deterministic Finite Automata, Non
Deterministic Finite Automata, NFA with ϵ moves, Regular Sets and Regular Expressions, Equivalence of DFA and NDFA,
NFA from Regular Expressions, Regular Expressions from DFA, Moore versus Mealy machines, Two way finite automata
with one way, Kleen’s Theorem, Applications of Finite Automata.
3. Regular and No in Regular Languages: Criterion for Regularity, Minimal Finite Automata, Pumping Lemma for Regular 5
Languages, Decision Problems, Regular language and Computers.
4. Context Free Grammars: Introduction, Definition, Regular Grammar, Derivation Trees, Ambiguity, Simplified Forms and 5
Normal Forms, Applications.
5. Pushdown Automata: Definition, Moves, Instantaneous Descriptions, Language Recognized by PDA, Deterministic PDA, 10
Acceptance by Final State and Empty Stack, Equivalence of PDA, Pumping Lemma for CFL, Interaction and
Complements of CFL, Decision Algorithms.
6. Turing Machines: Definitions and Examples, Computing Partial Functions with Turing Machines (TM), Combining Turing 5
Machines, Variations of Turning Machines, Multi Tape Turing Machines, Non Deterministic Turing Machine, Universal
Turing Machine, Church Thesis.
7. Recursively Enumerable Languages: Recursively Enumerable and Recursive enumerating Language, Context Sensitive 5
and Chomsky Hierarchy, Non Recursive Language and Unsolvable Problems, Halting Problem, Rice Theorem, Post
Correspondence Problem, Computational Complexity: Discussion on P, NP, NPC and NP Hard Problems.
Lecture Delivered by Surya Narayan Prasad 2
Introduction
● Let a language L1 = { akbk|k>=0} over {a,b}. “aabb”
● The grammar rules for the language L1 can be defined as
follows:-
● Rule 1: ϵ belongs to L1. (‘ϵ’ zero times symbol ‘a’ and zero
times symbol ‘b’).
● Rule 2: for every string ‘w’ belongs to L1, “awb” belongs to
L1.
● Rule 3: Nothing else belongs to L1. “ab→awb →aabb →
aaabbb”
A A
b A A A A
b A a a A b
a a
b A A b b A a
b A a a
S A B
S A B
Read Head
Pushdown Store
→
Lecture Delivered by Surya Narayan Prasad 61
Pushdown Automata
●APushdown Automata can be defined as a set of 7
tuples (Q, Σ, τ, δ, q0, Z, F), where
●Q is the finite non empty set of states
● Σ is finite non empty set of input symbols
● τ (Tou) is a finite non empty set of stack alphabets
● q0 is the initial state
● Z | Z0 is the initial Stack symbol. It is resident in the stack
from its beginning.
Lecture Delivered by Surya Narayan Prasad 62
Pushdown Automata
●F is the set of final states. A PDA can accept the strings in
two ways, either by a final state or null store. In case of
acceptance by a final state, a string is accepted by the PDA
if, at the end of the string, the read head is in one of the
final states. F is sub set of Q. In acceptance of null store, a
string is accepted by the PDA if, at then end of the string,
the pushdown store is empty. In this case F = φ.
● δ is the transition function which maps Q X (Σ U {ϵ} } X τ
to Q X τ*
Read Head
Pushdown Store
→
Z0
Lecture Delivered by Surya Narayan Prasad 67
Working of Pushdown Automata …
● The instantaneous state of a PDA is defined by three
parameters. They are current state of the read head, part of
the string yet to be processed and the current contents of
the pushdown store.
● Thus the initial state of the PDA M is δ(q0,00001111, Z0).
● The PDA works as follows
Transition is δ(q0,00001111,Z0)→(q1,0001111,0Z0)
Pushdown Store
Transition Function used is δ(q0,0,Z0) Ⱶ(q1, 0Z0)
→
0
Z0
Lecture Delivered by Surya Narayan Prasad 73
Working of Pushdown Automata …
● The initial state of the PDA M is given as follows
ϵ ϵ 0 0 0 0 1 1 1 1 ϵ ϵ
δ(q1,0001111, 0Z0)→(q1,001111,00Z0)
Pushdown Store
→
0
0
Z0
Lecture Delivered by Surya Narayan Prasad 74
Working of Pushdown Automata …
● The initial state of the PDA M is given as follows
ϵ ϵ 0 0 0 0 1 1 1 1 ϵ ϵ
δ(q1,001111, 00Z0)→(q1,01111,000Z0)
Pushdown Store
0
→
0
0
Z0
Lecture Delivered by Surya Narayan Prasad 75
Working of Pushdown Automata …
● The initial state of the PDA M is given as follows
ϵ ϵ 0 0 0 0 1 1 1 1 ϵ ϵ
δ(q1,01111,000Z0)→(q1,1111, 0000Z0)
Pushdown Store
0
0
→
0
0
Z0
Lecture Delivered by Surya Narayan Prasad 76
Working of Pushdown Automata …
● The initial state of the PDA M is given as follows
ϵ ϵ 0 0 0 0 1 1 1 1 ϵ ϵ
Pushdown Store
0
→
0
0
Z0
Lecture Delivered by Surya Narayan Prasad 77
Working of Pushdown Automata …
● The initial state of the PDA M is given as follows
ϵ ϵ 0 0 0 0 1 1 1 1 ϵ ϵ
Pushdown Store
→
0
0
Z0
Lecture Delivered by Surya Narayan Prasad 78
Working of Pushdown Automata …
● The initial state of the PDA M is given as follows
ϵ ϵ 0 0 0 0 1 1 1 1 ϵ ϵ
Pushdown Store
→
0
Z0
Lecture Delivered by Surya Narayan Prasad 79
Working of Pushdown Automata …
● The initial state of the PDA M is given as follows
ϵ ϵ 0 0 0 0 1 1 1 1 ϵ ϵ
Pushdown Store
→
Z0
Lecture Delivered by Surya Narayan Prasad 80
Working of Pushdown Automata …
● The initial state of the PDA M is given as follows
ϵ ϵ 0 0 0 0 1 1 1 1 ϵ ϵ
Pushdown Store
→
ϵ
Lecture Delivered by Surya Narayan Prasad 81
Working of Pushdown Automata …
● Itis surprising that the above transition has occurred without
consumption of an input symbol. A PDA allows for null string
transition.
● The empty pushdown store indicates the acceptance of the
string 00001111 by the PDA M.
1,0/000Z0
0,Z0/0Z0 ϵ,Z0/Z0
q0 q1 q2 q3
a, a*Z0/aa*Z0
b, a/a
a, a*Z0/aa*Z0
b,a/a
a,a/aa
b,a/a
Pushdown Store
0 0
0 0
→
0 0
ϵ 0
Stack1 Stack2
Lecture Delivered by Surya Narayan Prasad 124
Closure Properties of Context Free Language
Context free Languages are closed under the following
properties
● Union
● Concatenation
● Kleene Closure0n1n= 01,0011,000111 …
● Substitution
● Homomorphism
● Reverse Homomorphism
S + S S + S
S + S a a S + S
a a a a