Professional Documents
Culture Documents
Chapter Five - PDA
Chapter Five - PDA
Campus
Department of Computer
Automata and complexity
Science
theory
01
Mekonen M. # CoSc3071 Unit 3 – Regular Expression 3
Why Pushdown Automata?
Exercise
• Draw Finite automata for language
b
Not
Possible??
Finite
Stack Accept | Reject
Input Control
Input tape
Stack
• A PDA can write an unbounded no. of symbols on the stack and read these
symbols later.
• Writing a symbol on to the stack is called “PUSH” operation.
• Removing a symbol off the stack is called “POP” operation.
Finite
Stack Accept | Reject
Input Control
Input tape
Stack
• Input tape: The input tape is divided in many cells or symbols. The input head is read-only and
may only move from left to right, one symbol at a time.
• Finite control: The finite control has some pointer which points the current symbol which is to be
read.
• Stack: The stack is a structure in which we can push and pop the items from one end only. It has
an infinite size. In PDA, the stack is used to store the items temporarily.
𝒃
𝒃
𝒃
𝒛𝟎
Mekonen M. # CoSc3071 Unit 5 – Pushdown Automata 12
How to Represent PDA?
Move No State Input Stack Symbol Move(s)
𝑞0 𝑞1
b, a |
FIRST 2 SYMBOLS
^
OF THE STACK
a, a | aa
a, z0|az0 b, a |
𝑞1
,z0 | z0
𝑞0
b, a |
𝑞2
a, a | aa ,z0 | z0
Mekonen M. # CoSc3071 Unit 5 – Pushdown Automata 14
Design DPDA for L={anbn|a,b ∈ Ʃ, n≥0}
Move No State Input Stack Symbol Move(s)
a, z0|az0 b, a |
𝑞1
,z0 | z0
𝑞0
b, a |
𝑞2
a, a | aa ,z0 | z0
Mekonen M. # CoSc3071 Unit 5 – Pushdown Automata 15
Design PDA for palindrome with middle symbol c 𝒂
𝒃
𝒂
a b a ca b a
𝒂
𝒃
𝒂
𝒛𝟎
Mekonen M. # CoSc3071 Unit 5 – Pushdown Automata 16
Design PDA for palindrome with middle symbol c
• Design a PDA for following CFG.
SaSa/bSb/c
• Design PDA for L={xcxr/x∈{a,b}*}. The string in L are odd length palindromes
over {a,b}
• Strings accepted in the language are:
1.aba c aba
2.aaa c aaa
3.bab c bab
4.ab c ba
b, z0|bz0
a, z0|az0 a, a | aa
𝑞0
b, b | bb b, a | ba
a, b | ab
b, z0|bz0
a, z0|az0 a, a | aa c,a | a
𝑞1
c,b | b
𝑞0 c,z0 | z0
b, b | bb b, a | ba
a, b | ab
b, z0|bz0 b, b |
a, z0|az0 a, a | aa
c,a | a
𝑞0 c,b | b
c,z0 | z0
𝑞1 ,z0 | z0
𝑞2
b, b | bb b, a | ba
a, b | ab a, a |
𝑞0 c,b | b
c,z0 | z0
𝑞1 ,z0 | z0
𝑞2 ⊢ (, , )
⊢ (, , )
b, b | bb b, a | ba ⊢ (,, )
a, b | ab a, a |
⊢ (,, )
Move No Resulting State Unread Input Stack
𝒒
𝑞𝟐2
a, z0|az0
a, b| b, z0|bz0
b, a|
𝑞0 𝑞1
,z0 | z0
a, a | aa
b, b | bb
= a 2 b2 b3 c 3
= aa bb bbb ccc
a,a,a|a|aa b, a| b, b| bb
aa
b, z0| bz0
𝑞0
a, z00| az0.0
𝑞1
b, a|
𝑞2 𝑞3
a, a| aa b, a| b, b| bb c, b|
𝑞4
b, z0| bz0
𝑞3
c, b|
𝑞0
a, z0| az0
𝑞1
b, a|
𝑞2
, z0| z0
𝑞5
Mekonen M. # CoSc3071 Unit 5 – Pushdown Automata 27
Exercise: Design PDA
1. Design PDA for anbncmdm , n,m>=1
2. Design PDA for anbmcmdn , n,m>=1
3. Design PDA for an+mbncm , n,m>=1