Introduction Pushdown Automata
Introduction Pushdown Automata
Turnstile notation
⊢ sign is called a “turnstile notation” and represents
one move.
⊢* sign represents a sequence of moves.
Eg- (p, b, T) ⊢ (q, w, α)
This implies that while taking a transition from state p to state q, the input symbol ‘b’ is
consumed, and the top of the stack ‘T’ is replaced by a new string ‘α’
Note :
The e above pushdown au utomaton is determinisstic in nature because there is only
one e move fromm a state on an input symbol
s andd stack sym mbol.
The e non-deterrministic pu
ushdown au utomata can n have morre than one e move fromma
staate on an input symbol and stack symbol.
It iss not alway
ys possible to
t convert non-determ
n ministic push hdown auto omata to
detterministic pushdown
p a
automata.
Exp pressive Poower of nonn-determinisstic PDA is more as co ompared too expressivee
detterministic PDA
P as somme languag ges which are
a accepte ed by NPDA A but not byy
detterministic PDA
P which will be disccussed in next
n article.
The e push dowwn automata a can eithe
er be implem
mented usin ng accepeta ance by emmpty
staack or acceppetance by final state and one caan be conve erted to ano
other.
Examples:
Input : 0 0 1 1 1 2 2 2 3 3
Result : ACCEPTED
Input : 0 0 0 1 1 2 2 2 3 3
Result : NOT ACCEPTED
Q) Construct a PDA for language L = {0n1m | n >= 1, m >= 1, m > n+2}
Approach used in this PDA –
First 0’s are pushed into stack.When 0’s are finished, two 1’s are ignored. Thereafter for
every 1 as input a 0 is popped out of stack. When stack is empty and still some 1’s are
left then all of them are ignored.
Step-1: On receiving 0 push it onto stack. On receiving 1, ignore it and goto next
state
Step-2: On receiving 1, ignore it and goto next state
Step-3: On receiving 1, pop a 0 from top of stack and go to next state
Step-4: On receiving 1, pop a 0 from top of stack. If stack is empty, on receiving 1
ingore it and goto next state
Step-5: On receiving 1 ignore it. If input is finished then goto last state
Examples:
Input : 0 0 0 1 1 1 1 1 1
Result : ACCEPTED
Input : 0 0 0 0 1 1 1 1
Result : NOT ACCEPTED
Closure Properties of Context Free Languages
Context Free languages are accepted by pushdown automata but not by finite
automata. Context free languages can be generated by context free grammar which has
the form :
A -> ρ (where A ∈ N and ρ ∈ (T ∪ N)* and N is a non-terminal and T is a terminal)
KleeneClosure : If L1 is context free, its Kleene closure L1* will also be context free.
For example,
L1 = { anbn | n >= 0 }
L1* = { anbn | n >= 0 }* is also context free.
Note :So CFL are closed under Kleen Closure.
Question : Which one of the following grammars generate the language L = { aibj | i ≠ j }
S -> AC | CB, C ->aCb | a | b, A ->aA | ɛ, B -> Bb | ɛ
S ->aS | Sb | a | b
S -> AC | CB, C ->aCb | ɛ, A ->aA | ɛ, B -> Bb | ɛ
S -> AC | CB, C ->aCb | ɛ, A ->aA | a, B -> Bb | b
Solution : The best way to solve these type of questions is to eliminate options which
do not satisfy conditions. The conditions for language L is no. of a’s and no. of b’s
should be unequal.
In option (B), S =>aS => ab. It can generate strings with equal a’s and b’s. So, this
option is incorrect.
In option (C), S => AC => C => ɛ. In ɛ, a’s and b’s are equal (0), so it is not correct
option.
In option (A), S will be replaced by either AC or CB. C will either generate no. of a’s
more than no. of b’s by 1 or no. of b’s more than no. of a’s by 1. But one more a or one
more b can be compensated by B ->bB | ɛ or A ->aA | ɛ respectively. So it may give
strings with equal no. of a’s and b’s. So, it is not a correct option.
In option (D), S will be replaced by either AC or CB. C will always generate equal no. of
a’s and b’s. If we replace S by AC, A with add atleast one extra a. and if we replace S
by CB, B will add atleast one extra b. So this grammar will never generate equal no. of
a’s and b’s. So, option (D) is correct.