0% found this document useful (0 votes)
230 views30 pages

Push Down Automata

This document outlines a lecture on pushdown automata (PDA). The key points are: - A PDA is like a finite state machine but with a stack, making it more powerful than an FSM and able to recognize context-free languages. - The lecture will cover the components of a PDA, how it works, equivalence between PDAs and context-free grammars, and designing PDAs for example languages. - Students will learn to illustrate PDA designs for context-free languages, analyze PDA/language equivalences, and convert between context-free grammars and PDAs.

Uploaded by

Vishal Varma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
230 views30 pages

Push Down Automata

This document outlines a lecture on pushdown automata (PDA). The key points are: - A PDA is like a finite state machine but with a stack, making it more powerful than an FSM and able to recognize context-free languages. - The lecture will cover the components of a PDA, how it works, equivalence between PDAs and context-free grammars, and designing PDAs for example languages. - Students will learn to illustrate PDA designs for context-free languages, analyze PDA/language equivalences, and convert between context-free grammars and PDAs.

Uploaded by

Vishal Varma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

Unit-4:Push down automata

Date & Time :10-11-20,11AM-12PM

Swarnalatha Prathipati
Assistant Professor
Department of CSE
GITAM Institute of Technology (GIT)
Visakhapatnam – 530045
Email: [email protected]
Ph no:7893210891
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 1
Course objectives

• Designing Push Down Automata

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 2


Learning Outcomes

At the end of this lecture/ session, Students will be able


to
• Illustrate the design of Pushdown Automata for Context
Free Languages(L2)
• Analyze the equivalence of Pushdown Automata with
Context Free Languages(L4)

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 3


Topics

 Pushdown automaton(PDA)
 Equivalence between acceptance by empty store and acceptance by
final state
 Equivalence of CFG and PDA.

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 4


Pushdown Automata
• A Pushdown Automata (PDA) is a way to implement a context free
grammar in a similar way we design finite automata for regular grammar.

• It is more powerful than FSM

• FSM has a very limited memory but PDA has more memory.

• PDA=Finite state machine+ A stack

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 5


Stack
• A stack is away we arrange elements one on top of another

• A stack does two operations

• Push: A new element is added at the top of the stack

• Push: The top of the stack is read and removed

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 6


A Pushdown Automata has 3 components

1. An Input tape
2. Finite control unit
3. Stack structure with infinite size.

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 7


Block diagram of Pushdown Automata

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 8


• A Pushdown Automata is defined by 7 tuples
M=(Q, ∑, Γ, q0, Z0, F, δ)

• Q is the finite set of states


• ∑ is the finite set of input symbols
• Γ is the set of stack symbols (which can be pushed and popped from
stack)
• q0 is the initial state
• Z0 is the stack start symbol (which is initially present in stack)
• F is the finite set of final states
• δ is a transition function which maps Q x {Σ ∪ ∈} x Γ -> Q x Γ*.
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 9
• In a given state, PDA will read input symbol and stack symbol (top of
the stack) and move to a new state and change the symbol of stack.
• The transition function δ is represented by a triple δ(q,a,X)
where
i) q is a state in Q
ii) a is either input symbol or ε
iii) X is a stack symbol that is a member of Γ

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 10


Graphical representation of PDA

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 11


Instantaneous Description

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 12


Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 13
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 14
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 15
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 16
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 17
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 18
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 19
Practice Problems
1. Design a PDA for accepting a language L={WCWR } where W∈(a+b)*
2. Design a PDA for accepting a language equal no of a’s and equal no of
b’s.
3. Design a PDA for accepting a language L={WWR } where W∈(a+b)+
4. Design a PDA for accepting a language L={apbqcm |p+m=q}
5. Design a PDA for accepting a language L={anb2n |n>=1}}

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 20


Conversion of CFG to PDA
• For converting given CFG to PDA by this method the necessary
condition is that the first symbol on R.H.S production must be a
terminal symbol.
• The rules can be used to obtain PDA from CFG is
Rule 1: For non terminal symbols, add following rule
δ(q, ε,A)=(q,α) where the production rule is A-> α
Rule 2: For each terminal symbols, add following rule
δ(q,a,a)=(q,ε) for every terminal symbol.

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 21


1.Construct PDA for the given CFG.
S->0BB
B->0S|1S|0 test whether 010000 is acceptable by this PDA or not.
Solution:
Let PDA A= {{q},{0,1},{S,B,0,1}, δ, q, S, Φ}
The production rules δ can be given as
R1: δ(q, ε,S)={(q,0BB)}
R2: δ(q, ε,B)={(q,0S),(q,1S),(q,0)}
R3: δ(q,0,0)={(q, ε)}
R4: δ(q,1,1)={(q, ε)}

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 22


• Test 010000 is accepted by PDA or not.
δ(q,010000,S) |- δ(q,010000,0BB)
|- δ(q,10000,BB)
|- δ(q,10000,1SB)
|- δ(q,0000,0BBB)
|- δ(q,000,BBB)
|- δ(q,000,0BB)
|- δ(q,00,BB)
|- δ(q,00,0B)
|- δ(q,0,B)
|- δ(q,0,0)
|- δ(q, ε,Z0) => Accepted

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 23


Practice Problems
1.Construct PDA for the given CFG
S->ASB|ab
A->aA|a
B->bB|b
test whether the string aaabbb is acceptable by this PDA or not.
2. Construct PDA for the given CFG
S->0S1|A
A->1A0|S| ε
test whether the string 001011 is acceptable by this PDA or not.
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 24
Construction of CFG from given PDA

•We can construct a PDA from given CFG similarly we can obtain a CFG
from given PDA.

•The algorithm for this is given with the help of following theorem.

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 25


Theorem:

If A=(Q, ∑, Γ, q0, Z0, F, δ) is a PDA then there exists CFG G which is accepted
by PDA A.

Let G be a context free grammar which could be generated by PDA A. The G


can be defined as G=(V,T,P,S) where S is a start symbol. The set of non
terminals V={S,q,qI ,Z) where q and qI ∈ Q and Z ∈ Γ

And for getting the production rules P we will apply the following algorithm

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 26


Algorithm for getting Production rules of CFG
• Rule 1: The start symbol production can be
S -> [q0 , Z0 ,q]
where q indicates the next state and q0 is a start state. q and q0 ∈ Q

• Rule 2: If there exists a move of PDA


δ(q,a,Z)= {(q0 , ε)}
then the production rule can be written as
δ(q,Z,q0 ) -> a

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 27


• Rule 3: If there exists a move of PDA as
δ(q,a,Z)= {(q0 , Z1, Z2,….ZN)}

Then the production rule of CFG can be written as


δ(q,Z, q0)= a[q1 , Z1, q2 ] [q2 , Z2 , q3 ] [q3 , Z3, q4 ]……[qm-1 , Zm , qm ]

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 28


Problem
• The PDA is as given below A=({q0 , q1 },{0,1},{S,A}, q0, S, δ, Φ}
where δ is given below
δ(q0 ,1,S)= {(q0 ,AS)}
δ(q0 , ε,S)= {(q0 , ε)}
δ(q0 ,1,A)= {(q0 ,AA)}
δ(q0 ,0,A)= {(q1 ,A)}
δ(q1 ,1,A)= {(q1 , ε)}
δ(q1 , 0,S)= {(q0 , S)}
Construct equivalent CFG to the PDA.
Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 29
THANK YOU

Tuesday, January 05, 2021 Department of CSE, GIT ECS301_FLAT UNIT-4 30

You might also like