lecture pushdown automata
TRANSCRIPT
![Page 1: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/1.jpg)
Lecture Pushdown Automata
![Page 2: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/2.jpg)
stack
stack head
finitecontrol
tape head
tape
![Page 3: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/3.jpg)
The tape is divided into finitely many cells. Each cell contains a symbol in an alphabet Σ.
a l p h a b e t
![Page 4: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/4.jpg)
The stack head always scans the topsymbol of the stack. It performs two basic operations:
Push: add a new symbol at the top.
Pop: read and remove the top symbol.
Alphabet of stack symbols: Γ
![Page 5: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/5.jpg)
• The head scans at a cell on the tape and can read a symbol on the cell. In each move, the head can move to the right cell.
a
![Page 6: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/6.jpg)
• The finite control has finitely many states which form a set Q. For each move, the state is changed according to the evaluation of a transition function
δ : Q x (Σ U {ε}) x (Γ U {ε}) → 2 .Q x (Γ U {ε})
![Page 7: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/7.jpg)
• (p, u) δ(q, a, v) means that if the tape head reads a, the stack head read v, and the finite control is in the state q, then one of possible moves is that the next state is p, v is replaced by u at stack, and the tape head moves one cell to the right.
pq
a a
v u
![Page 8: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/8.jpg)
• (p, u) δ(q, ε, v) means that this a ε-move.
pq
a
v u
a
![Page 9: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/9.jpg)
• (p, u) δ(q, a, ε) means that a push operation performs at stack.
pq
a a
u
![Page 10: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/10.jpg)
• (p, ε) δ(q, a, v) means that a pop operation performs at stack
pq
a a
v
![Page 11: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/11.jpg)
• There are some special states: an initial state s and a final set F of final states.
• Initially, the PDA is in the initial state s and the head scans the leftmost cell. The tape holds an input string. The stack is empty.
s
![Page 12: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/12.jpg)
• When the head gets off the tape, the PDA stops. An input string x is accepted by the PDA if the PDA stops at a final state and the stack is empty.
• Otherwise, the input string is rejected.
f
x
![Page 13: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/13.jpg)
• The PDA can be represented by M = (Q, Σ, Γ, δ, s, F) where Σ is the alphabet of input symbols
and Γ is the alphabet of stack symbols.• The set of all strings accepted by a PDA M
is denoted by L(M). We also say that the language L(M) is accepted by M.
![Page 14: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/14.jpg)
• The transition diagram of a PDA is an alternative way to represent the PDA.
• For M = (Q, Σ, Γ, δ, s, F), the transition diagram of M is an edge-labeled digraph G=(V, E) satisfying the following:
V = Q (s = , f = for f F)
E = { q p | (p,u) δ(q, a, v) }.
a, v/u
![Page 15: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/15.jpg)
Example 1. Construct PDA to accept L= {0 1 | n > 0}n n
Solution 1.
0, ε/0
1, 0/ε
1, 0/ε
![Page 16: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/16.jpg)
Solution 2.
Consider a CFG G = ({S}, {0,1}, {S → ε | 0S1}, S).
ε, ε/S ε, ε/S
ε, S/ε
ε, ε/0
ε, S/1
0, 0/ε
1, 1/ε
![Page 17: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/17.jpg)
Theorem Every CFL can be accepted by a PDA.
Proof. Consider a CFL L = L(G) for a CFG G = (V, Σ, R, S).
ε, ε/S
a, a/ε for a in Σ
ε, A/xn A → x1 x2 …xn in R
ε, ε/x1
PDA. aby accepted becan it CFL is languageA L
Theorem
![Page 18: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/18.jpg)
Sometimes, constructing the PDA is easier thanconstructing CFG.
![Page 19: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/19.jpg)
CFL a is )}(#2)(#)(# |},{{ that Show xxxbax bab
Construct a PDA or a CFG?
PDA!!!
Sometimes, constructing the PDA is easier thanconstructing CFG.
Example 2
![Page 20: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/20.jpg)
Idea
accepted! be would stringinput theexists, choicecorrect a as long As : trouble thissolves
ncomputatio nisticnondetermi ofconcept theNo, on?cancellatieach at choice ticdeterminis a make toneed weDo . two
sometimes and one sometimes cancel toneed we,each For . with cancel toneed we),(#2)(#)( ifcheck To
x
aab
baxxx# bab
![Page 21: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/21.jpg)
• (p, s) δ(s, ε, ε)
ps
a
s
a
s/,
![Page 22: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/22.jpg)
(q, s) δ(p, a, s)
pp
a
a
a
ssa /,
ss
(p, a) δ(q, ε, ε)
a/,
![Page 23: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/23.jpg)
(q1, a) δ(p, a, a)
pp
a
a
a
aaa /,
aa
(p, a) δ(q1, ε, ε)
a/,
![Page 24: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/24.jpg)
(p, ε) δ(p, a, b)
pp
a a
b
/,ba
![Page 25: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/25.jpg)
(p, b’) δ(p, a, b)
pp
a a
b
'/, bba
b’
![Page 26: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/26.jpg)
(p, ε) δ(p, a, b’)
pp
a a
b’
/',ba
![Page 27: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/27.jpg)
(r1, s) δ(p, b, s)
pp
b
b
b
ssb /,
ss
(p, b) δ(r1, ε, ε)
b/,
![Page 28: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/28.jpg)
(r2, b) δ(p, b, b)
pp
b
b
b
bbb /,
bb
(p, b) δ(r2, ε, ε)
b/,
![Page 29: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/29.jpg)
(r3, b’) δ(p, b, b’)
pp
b
b
b
'/', bbb
b’b’
(p, b) δ(r3, ε, ε)
b/,
![Page 30: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/30.jpg)
(p, ε) δ(p, b, a)
pp
b b
a
/,ab
![Page 31: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/31.jpg)
(t, ε) δ(p, b, a)
pp
b b
/,ab
a
(p, ε) δ(t, ε, a)
/,a
a
![Page 32: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/32.jpg)
(t, ε) δ(p, b, a)
pp
b b
/,ab
a
(u, x) δ(t, ε, x)
/',b
z z≠a z
b’
(p, b’) δ(u, ε, ε)
azzz
/,
![Page 33: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/33.jpg)
(p, ε) δ(p, ε, s)
pp
s
/, s
![Page 34: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/34.jpg)
s/,
a/,
zza /,
',bbz
/',ba
'/, bba
/,ba
b/,
az
zzb /,
/,ab
/,ab
/,azz /,
'/, baz
/, s
![Page 35: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/35.jpg)
)}.(#2)(#)(# |},{{ acceptingPDA Construct xxxbax bab
job. thedo first Let the.' twocancel which a havemust we),(#)(# have To
bsabxx ab
Idea
Example 3
![Page 36: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/36.jpg)
1s/,
a/,
zza /,
',bbz
/',ba'/, bba
/,ba
b/,
az
zzb /,/,ab
/,ab
/,azz /,
'/, baz
/, s
Solution'/, bba
/,ab /,a'/, b
zz /,az
1
1zza /,
',bbz
a/,
1zzb /,az
b/,
![Page 37: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/37.jpg)
)}.(#2)(#)(# |},{{ acceptingPDA Construct xxxbax bab
job. thedo first Let the. one cancel which a havemust we),(#2)(# have To
babxx ba
Idea
Example 4
![Page 38: Lecture Pushdown Automata](https://reader036.vdocuments.mx/reader036/viewer/2022081421/586b81b61a28ab086c8b972d/html5/thumbnails/38.jpg)
1s/,
a/,
zza /,
',bbz
/',ba/,ba
/,ba
b/,
az
zzb /,/,ab
/,ab
/,azz /,
'/, baz
/, s
Solution'/, bba
1
1zza /,
',bbz
a/,
1zzb /,az
b/,
/,ab