SlideShare a Scribd company logo
04/29/2025 1
Module 4
Push Down Automata
(PDA)
04/29/2025 2
Hierarchy of Languages
Regular Language
(Language for Finite
Automata)
Context Free Language
(Language for Push Down Automata)
Context Sensitive Language
(Language for Low Bound Automata)
Recursively Enumerable Language
(Language for Turing Machine)
04/29/2025 3
Push Down Automata(PDA)
 It is a Finite Automata with STACK
 An added stack provides memory and increases the capacity
of machine
 A context free grammar is recognized by PDA
 Hence the language accepted by PDA is context free
language
 Ex: L(G)={ : n >=0}
L(G)={w : w ϵ {a, b}*}
04/29/2025 4
PDA Block Diagram
1) Read input symbol
2) Perform Stack Operations
-PUSH()
-POP()
-Empty()
-Read TOP
3) Make changes in states
4) Procedure is repeated until string
is scanned completely
Input Symbol reading
Control Unit
Top of the stack
STACK
04/29/2025 5
STACK Operations
1) POP() Operation
deletes topmost
element in Stack
2) PUSH() Operation
inserts element at top
in Stack
a
b
a
z0
a
b
a
z0
3) NOP() Operation
No deletion, no
insertion at top
There are THREE stack operations
a
b
a
z0
a
b
a
az0
b
a
z0
b
a
z0
Before
POP()
operation
After
POP()
Operation
TOP
TOP
TOP
TOP
TOP
TOP
Before
PUSH()
operation
Before
NOP()
operation
After
PUSH()
Operation
After
NOP()
Operation
04/29/2025 6
Transition Function in PDA
Transition Function in PDA depends upon
1) Current State (Qi)
2) Current input (a)
3) TOP of stack (b)
Input String :
ba
Qi Qj
I/P symbol,
Qi Qj
a,
a
b
Z0
b
Z0
Transition Diagram for PUSH(a)
Stack
before
PUSH(a)
Stack
after
PUSH(a)
TOP
TOP
Stack TOP/Stack Content
b/ ab
04/29/2025 7
Non-deterministic PDA Definition
 It is defined by seven tuples:
M=(Q,Σ, ┌, ,q0,z0,F)
Where, Q Set of States
Σ Set of input
┌  Finite set of stack symbols
q0Initial State
z0 ϵ ┌  Stack Start Symbol
F ϵ Q Set of Final States
: Q X (Σ ᴜ {ϵ} ) X ┌  Set of Finite subsets of Q X ┌ *
04/29/2025 8
Transitions
• Transition Function accepts three parameters namely state, input symbol
and stack symbol and returns a new state after changing the top of the stack
δ(state, input symbol, stack symbol)=(next state, stack symbol)
• Eg 1: δ(P, a , z) = (Q, az)
Means PDA in current state P and after reading a with z on top of the stack
PDA enters into new state Q pushing a on to the stack
• Eg 2: δ(P, a , z) = (Q, ∈)
Means PDA in current state P and after reading a with z on top of the stack
PDA enters into new state Q popping z out of the stack
04/29/2025 9
• Eg 3: δ(P, a , z) = (Q, a)
• Means PDA in current state P and after reading a with z on top of the stack PDA
enters into new state Q and z is popped out and a is pushed in
• Eg 4: δ(P, ∈ , b) = (P, ∈ )
Means PDA in current state P and without accepting any input symbol and b on top
of the stack, b is popped out from the stack and PDA remains in the same state P
Practice
δ(A, 1 , z) = (A, 1) ?
δ(Q, ∈ , 0) = (Q, ∈) ?
δ(P, b , z) = (R, bz) ?
04/29/2025 10
04/29/2025 11
Transition Function in PDA
 Transition Function is based on
i) Current State
ii) Input Symbol (including ϵ)
iii) Top of the stack
a) Read input with NOP() operation on Stack:
(q1, b, a) = (q2, a)
q1  Current state
b  Current Input
a  Top of the stack
q2  Next State
04/29/2025 12
Transition Function in PDA continue..
b) Read input with POP() operation on Stack:
(q1, b, a) = (q2, ϵ)
q1  Current state
b  Current Input
a  Top of the stack
q2  Next State
c) Read input with PUSH() operation on Stack:
(q1, a, b) = (q2, ab)
q1  Current state
a  Current Input
b  Top of the stack
q2  Next State
04/29/2025 13
Instantaneous Description of PDA
• Current configuration of PDA at any given instant is the instantaneous description
(ID)
ID is defined as triplet (q,w,α)
q current state
w remaining string to be processed
α  is the current contents of the stack
Eg. If string is aabb
(q0,aabb,z0)
Ⱶ (q0,abb,az0)
Ⱶ (q0,bb,aaz0) etc
04/29/2025 14
PDA Example 1
1) Obtain PDA to accept language L(G)={ : n>=1, Σ={a, b}* }
Solution:
Accepting Strings={ab, aabb, aaabbb, aaaabbbb,……}
Rejecting Strings={a,b,aab,baa,abab,aabbb,……}
Let sample String is aabb
Z0
Initially Stack
is empty()
TOP
a
Z0
push(a)
TOP
a
a
Z0
push(a)
TOP
a
Z0
pop(a)
TOP
Z0
pop(a)
TOP
The number of times
push(a) is equals to pop(a)
Hence count of ‘a’ is equals
to count of ‘b’
04/29/2025 15
PDA Example 1 continue..
Now PDA is M=(Q,Σ, ┌ , ,q0,z0,F)
q0Start State
qf Accepting State
z0Stack Initial Symbol
Σ={a, b}
Transition Function ()
1. (q0, a, z0)= (q0, az0)
2. (q0, a, a)= (q0, aa)
3. (q0, b, a)= (q1, ϵ)
4. (q1, b, a)= (q1, ϵ)
5. (q1, ϵ,z0)= (qf, z0)
┌ = {z0,a}Stack Symbols
q0
a, z0/az0
a, a/aa
ϵ, z0/z0
qf
Transition Diagram
q1
b, a/ϵ
b, a/ϵ
04/29/2025 16
PDA Example 1 continue..
Sample Accepting String : aabb
(q0, aabb, z0)
|-- (q0, abb,az0) -----push(a)
|--(q0, bb, aaz0) -----push(a)
|--(q1, b, az0) -----pop(a)
|--(q1, ϵ,z0) -----pop(a)
|--(qf, z0)
Reached Final State with empty
stack
Therefore, aabb is accepted
Sample Rejecting String : abab
(q0, abab, z0)
|-- (q0, bab,az0) ----push(a)
|-- (q1, ab, z0) ----pop(a)
String is not processed completely
but stack is empty.
Therefore, abab is rejected
04/29/2025 17
PDA Example2
3) Obtain NPDA to accept language L(G)={w : w ϵ {a, b}*}
Solution:
Accepting Strings={aa , bb , abba , baab , abbbba , abaaba , ……}
Rejecting Strings={a, b , aba , bab ,aab , baa , abab, aabbb,……}
Let sample String is baab
Z0
Initially Stack
is empty()
TOP
b
Z0
push(b)
TOP
b
Z0
pop(a)
TOP
push(a)
TOP
Scan first symbol & push() into
stack, scan next symbol, push()
into stack, repeat push() until u
reach middle of string, after mid
if scanning symbol is matching
with top of stack, do pop()
Z0
TOP
pop(b)
a
b
Z0
18
PDA Example2 continue..
Now PDA is M=(Q,Σ, ┌, ,q0,z0,F)
q0Start State qf Accepting State
z0Stack Initial Symbol Σ={a, b}
Transition Function ()
1. (q0, a, z0)= (q0, az0)------ push(a)
2. (q0, b, z0)= (q0, bz0)------push(b)
3. (q0, a, b)= (q0, ab)--------push(a)
4. (q0, b, a)= (q0, ba)--------push(b)
5. (q0, a, a)={ (q0, aa),(q1, ϵ)}
6. (q0, b, b)= {(q0 , bb),(q1, ϵ)}
7. (q1, a, a)= (q1, ϵ)
8. (q1, b, b)= (q1, ϵ)
9. (q1, ϵ,z0)= (qf, z0) ┌= {z0,b,a}Stack Symbols
q1
a, a/ϵ
b, b/ϵ
ϵ, z0/z0
qf
Transition Diagram
q0
a, z0/az0
b, z0/bz0
a, a/aa
b, b/bb
a, b/ab
b, a/ba
a, a/ϵ
b, b/ϵ
04/29/2025 19
PDA Example 2 continue..
Sample Accepting String : baab
(q0, baab, z0)
|- (q0, aab,bz0) ----push(b)
(q0, ab, ab0) ----push(a)
(q1, b, bz0) ----pop(a)
(q1, ϵ,z0) ----pop(b)
(qf, z0)
Reached Final State with empty
stack
Therefore, baab is accepted
Sample Rejecting String : aaab
(q0, aaab, z0)
(q0, aab,az0) ----push(a)
(q0, ab, aaz0) ----push(a)
(q1, b, az0) ----pop(a)
(q1, b, az0)
Reached end of string without
empty stack
Therefore, aaab is rejected

More Related Content

PPTX
PPTX
Pushdown Automata toc presentation 2025.pptx
PPTX
unit 3.pptx-theory of computation unit 3 notes
PPTX
539_PDA push down automata_ d_b_m_s.pptx
PPT
Turing Machine push down automata-examples
PPTX
Push down automata
PPT
Description of Finite Automata and Languages Accepted by Push Down Automata
PPT
Push Down Automata (PDA) Definition, Problems and State Diagrams including tr...
Pushdown Automata toc presentation 2025.pptx
unit 3.pptx-theory of computation unit 3 notes
539_PDA push down automata_ d_b_m_s.pptx
Turing Machine push down automata-examples
Push down automata
Description of Finite Automata and Languages Accepted by Push Down Automata
Push Down Automata (PDA) Definition, Problems and State Diagrams including tr...

Similar to Module 4 PDA updated Theory of computation.pptx (20)

PPT
2-stack-Push Down Automata(PDA)_TOComp.ppt
PPTX
PDA (1) (1).pptx
PPTX
AUTOMATA AUTOMATA AUTOMATAAutomata7Chapter6.pptx
PPTX
16 PDA push down autometa push down.pptx
PPTX
Theory of automata
PPTX
Automata theory - Push Down Automata (PDA)
PPTX
csc218pushdownautomata-160627235627.pptx
PPTX
push down automata
PDF
Formal Languages and Automata Theory unit 3
PPT
finitw automata2, Computer theory computure science
PPTX
PUSH DOWN AUTOMATA VS TURING MACHINE
PPT
Lec 3 ---- dfa
PPT
Finite automata examples
PPT
Finite automata examples
PDF
Automata theory
PDF
push down automata- theoretical foundations of computations
PPTX
Stack data structure
PPT
deterministic finite state automata related
PPT
Designing of a Determinstic Push Down Atomaton
2-stack-Push Down Automata(PDA)_TOComp.ppt
PDA (1) (1).pptx
AUTOMATA AUTOMATA AUTOMATAAutomata7Chapter6.pptx
16 PDA push down autometa push down.pptx
Theory of automata
Automata theory - Push Down Automata (PDA)
csc218pushdownautomata-160627235627.pptx
push down automata
Formal Languages and Automata Theory unit 3
finitw automata2, Computer theory computure science
PUSH DOWN AUTOMATA VS TURING MACHINE
Lec 3 ---- dfa
Finite automata examples
Finite automata examples
Automata theory
push down automata- theoretical foundations of computations
Stack data structure
deterministic finite state automata related
Designing of a Determinstic Push Down Atomaton
Ad

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Machine learning based COVID-19 study performance prediction
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
MYSQL Presentation for SQL database connectivity
Machine learning based COVID-19 study performance prediction
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
NewMind AI Weekly Chronicles - August'25 Week I
Network Security Unit 5.pdf for BCA BBA.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Spectroscopy.pptx food analysis technology
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Ad

Module 4 PDA updated Theory of computation.pptx

  • 1. 04/29/2025 1 Module 4 Push Down Automata (PDA)
  • 2. 04/29/2025 2 Hierarchy of Languages Regular Language (Language for Finite Automata) Context Free Language (Language for Push Down Automata) Context Sensitive Language (Language for Low Bound Automata) Recursively Enumerable Language (Language for Turing Machine)
  • 3. 04/29/2025 3 Push Down Automata(PDA)  It is a Finite Automata with STACK  An added stack provides memory and increases the capacity of machine  A context free grammar is recognized by PDA  Hence the language accepted by PDA is context free language  Ex: L(G)={ : n >=0} L(G)={w : w ϵ {a, b}*}
  • 4. 04/29/2025 4 PDA Block Diagram 1) Read input symbol 2) Perform Stack Operations -PUSH() -POP() -Empty() -Read TOP 3) Make changes in states 4) Procedure is repeated until string is scanned completely Input Symbol reading Control Unit Top of the stack STACK
  • 5. 04/29/2025 5 STACK Operations 1) POP() Operation deletes topmost element in Stack 2) PUSH() Operation inserts element at top in Stack a b a z0 a b a z0 3) NOP() Operation No deletion, no insertion at top There are THREE stack operations a b a z0 a b a az0 b a z0 b a z0 Before POP() operation After POP() Operation TOP TOP TOP TOP TOP TOP Before PUSH() operation Before NOP() operation After PUSH() Operation After NOP() Operation
  • 6. 04/29/2025 6 Transition Function in PDA Transition Function in PDA depends upon 1) Current State (Qi) 2) Current input (a) 3) TOP of stack (b) Input String : ba Qi Qj I/P symbol, Qi Qj a, a b Z0 b Z0 Transition Diagram for PUSH(a) Stack before PUSH(a) Stack after PUSH(a) TOP TOP Stack TOP/Stack Content b/ ab
  • 7. 04/29/2025 7 Non-deterministic PDA Definition  It is defined by seven tuples: M=(Q,Σ, ┌, ,q0,z0,F) Where, Q Set of States Σ Set of input ┌  Finite set of stack symbols q0Initial State z0 ϵ ┌  Stack Start Symbol F ϵ Q Set of Final States : Q X (Σ ᴜ {ϵ} ) X ┌  Set of Finite subsets of Q X ┌ *
  • 8. 04/29/2025 8 Transitions • Transition Function accepts three parameters namely state, input symbol and stack symbol and returns a new state after changing the top of the stack δ(state, input symbol, stack symbol)=(next state, stack symbol) • Eg 1: δ(P, a , z) = (Q, az) Means PDA in current state P and after reading a with z on top of the stack PDA enters into new state Q pushing a on to the stack • Eg 2: δ(P, a , z) = (Q, ∈) Means PDA in current state P and after reading a with z on top of the stack PDA enters into new state Q popping z out of the stack
  • 9. 04/29/2025 9 • Eg 3: δ(P, a , z) = (Q, a) • Means PDA in current state P and after reading a with z on top of the stack PDA enters into new state Q and z is popped out and a is pushed in • Eg 4: δ(P, ∈ , b) = (P, ∈ ) Means PDA in current state P and without accepting any input symbol and b on top of the stack, b is popped out from the stack and PDA remains in the same state P Practice δ(A, 1 , z) = (A, 1) ? δ(Q, ∈ , 0) = (Q, ∈) ? δ(P, b , z) = (R, bz) ?
  • 11. 04/29/2025 11 Transition Function in PDA  Transition Function is based on i) Current State ii) Input Symbol (including ϵ) iii) Top of the stack a) Read input with NOP() operation on Stack: (q1, b, a) = (q2, a) q1  Current state b  Current Input a  Top of the stack q2  Next State
  • 12. 04/29/2025 12 Transition Function in PDA continue.. b) Read input with POP() operation on Stack: (q1, b, a) = (q2, ϵ) q1  Current state b  Current Input a  Top of the stack q2  Next State c) Read input with PUSH() operation on Stack: (q1, a, b) = (q2, ab) q1  Current state a  Current Input b  Top of the stack q2  Next State
  • 13. 04/29/2025 13 Instantaneous Description of PDA • Current configuration of PDA at any given instant is the instantaneous description (ID) ID is defined as triplet (q,w,α) q current state w remaining string to be processed α  is the current contents of the stack Eg. If string is aabb (q0,aabb,z0) Ⱶ (q0,abb,az0) Ⱶ (q0,bb,aaz0) etc
  • 14. 04/29/2025 14 PDA Example 1 1) Obtain PDA to accept language L(G)={ : n>=1, Σ={a, b}* } Solution: Accepting Strings={ab, aabb, aaabbb, aaaabbbb,……} Rejecting Strings={a,b,aab,baa,abab,aabbb,……} Let sample String is aabb Z0 Initially Stack is empty() TOP a Z0 push(a) TOP a a Z0 push(a) TOP a Z0 pop(a) TOP Z0 pop(a) TOP The number of times push(a) is equals to pop(a) Hence count of ‘a’ is equals to count of ‘b’
  • 15. 04/29/2025 15 PDA Example 1 continue.. Now PDA is M=(Q,Σ, ┌ , ,q0,z0,F) q0Start State qf Accepting State z0Stack Initial Symbol Σ={a, b} Transition Function () 1. (q0, a, z0)= (q0, az0) 2. (q0, a, a)= (q0, aa) 3. (q0, b, a)= (q1, ϵ) 4. (q1, b, a)= (q1, ϵ) 5. (q1, ϵ,z0)= (qf, z0) ┌ = {z0,a}Stack Symbols q0 a, z0/az0 a, a/aa ϵ, z0/z0 qf Transition Diagram q1 b, a/ϵ b, a/ϵ
  • 16. 04/29/2025 16 PDA Example 1 continue.. Sample Accepting String : aabb (q0, aabb, z0) |-- (q0, abb,az0) -----push(a) |--(q0, bb, aaz0) -----push(a) |--(q1, b, az0) -----pop(a) |--(q1, ϵ,z0) -----pop(a) |--(qf, z0) Reached Final State with empty stack Therefore, aabb is accepted Sample Rejecting String : abab (q0, abab, z0) |-- (q0, bab,az0) ----push(a) |-- (q1, ab, z0) ----pop(a) String is not processed completely but stack is empty. Therefore, abab is rejected
  • 17. 04/29/2025 17 PDA Example2 3) Obtain NPDA to accept language L(G)={w : w ϵ {a, b}*} Solution: Accepting Strings={aa , bb , abba , baab , abbbba , abaaba , ……} Rejecting Strings={a, b , aba , bab ,aab , baa , abab, aabbb,……} Let sample String is baab Z0 Initially Stack is empty() TOP b Z0 push(b) TOP b Z0 pop(a) TOP push(a) TOP Scan first symbol & push() into stack, scan next symbol, push() into stack, repeat push() until u reach middle of string, after mid if scanning symbol is matching with top of stack, do pop() Z0 TOP pop(b) a b Z0
  • 18. 18 PDA Example2 continue.. Now PDA is M=(Q,Σ, ┌, ,q0,z0,F) q0Start State qf Accepting State z0Stack Initial Symbol Σ={a, b} Transition Function () 1. (q0, a, z0)= (q0, az0)------ push(a) 2. (q0, b, z0)= (q0, bz0)------push(b) 3. (q0, a, b)= (q0, ab)--------push(a) 4. (q0, b, a)= (q0, ba)--------push(b) 5. (q0, a, a)={ (q0, aa),(q1, ϵ)} 6. (q0, b, b)= {(q0 , bb),(q1, ϵ)} 7. (q1, a, a)= (q1, ϵ) 8. (q1, b, b)= (q1, ϵ) 9. (q1, ϵ,z0)= (qf, z0) ┌= {z0,b,a}Stack Symbols q1 a, a/ϵ b, b/ϵ ϵ, z0/z0 qf Transition Diagram q0 a, z0/az0 b, z0/bz0 a, a/aa b, b/bb a, b/ab b, a/ba a, a/ϵ b, b/ϵ
  • 19. 04/29/2025 19 PDA Example 2 continue.. Sample Accepting String : baab (q0, baab, z0) |- (q0, aab,bz0) ----push(b) (q0, ab, ab0) ----push(a) (q1, b, bz0) ----pop(a) (q1, ϵ,z0) ----pop(b) (qf, z0) Reached Final State with empty stack Therefore, baab is accepted Sample Rejecting String : aaab (q0, aaab, z0) (q0, aab,az0) ----push(a) (q0, ab, aaz0) ----push(a) (q1, b, az0) ----pop(a) (q1, b, az0) Reached end of string without empty stack Therefore, aaab is rejected