Pushdown Automata
-
Upload
kirby-fletcher -
Category
Documents
-
view
65 -
download
0
description
Transcript of Pushdown Automata
![Page 1: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/1.jpg)
CS 3240 – Chapter 7
![Page 2: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/2.jpg)
Language Machine Grammar
Regular Finite Automaton Regular Expression,Regular Grammar
Context-Free Pushdown Automaton
Context-Free Grammar
Recursively Enumerable
Turing Machine Unrestricted Phrase-Structure Grammar
2CS 3240 - Introduction
![Page 3: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/3.jpg)
Take an FA and add a stack A restricted form of unbounded memory
Operations: Pop Push Ignore (λ) (Pop always precedes push)
3CS 3240 - Pushdown Automata
![Page 4: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/4.jpg)
Three items per transition edge <read>,<pop>,<push> any or all could be λ
A PDA accepts when: An accepting state is reached, and The stack is empty
▪ Different from book!
▪ The machine crashes when no move is possible▪ implicit jail
4CS 3240 - Pushdown Automata
![Page 5: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/5.jpg)
A deterministic PDA (no choices; λ is okay sometimes). The stack alphabet (Γ = {X}) can differ from the input alphabet (Σ = {a, b}) .
Trace aabb…
5CS 3240 - Pushdown Automata
![Page 6: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/6.jpg)
q0 aabb λq0 abb Xq0 bb XXq1 b Xq1 λ λ
6CS 3240 - Pushdown Automata
Traditional notation (see book):
(q0,aabb, λ) ⊢ (q0,abb,X) ⊢ (q0,bb,XX) ⊢ (q1,b,X) ⊢ (q1,λ, λ)
Also: (q0,aabb,λ) ⊢* (q1,λ, λ) (⇒ aabb ∈ L)
![Page 7: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/7.jpg)
7CS 3240 - Pushdown Automata
![Page 8: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/8.jpg)
8CS 3240 - Pushdown Automata
How would you do a2nbn?
![Page 9: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/9.jpg)
CS 3240 - Pushdown Automata 9
Each b must pop 2 X’s
![Page 10: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/10.jpg)
Is this deterministic?
Trace the string abaacaaba.
10CS 3240 - Pushdown Automata
![Page 11: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/11.jpg)
Input: (state-1, input character, pop character)
Output: (state-2, push character(s))
Example: The edge (a,λ,a) on previous slide:
δ(q0,a,λ) = (q0,a)
Exercise: Rewrite wcwR in functional form
CS 3240 - Pushdown Automata 11
![Page 12: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/12.jpg)
Is this deterministic?Trace the string abaaaaaba.Trace the string abaabaaba.Trace the string abaaaaba.
12CS 3240 - Pushdown Automata
![Page 13: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/13.jpg)
CS 3240 - Pushdown Automata 13
Trace aaabbbb
The grammar:
S → aSb | aSbb | λ
![Page 14: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/14.jpg)
CS 3240 - Pushdown Automata 14
Trace ababbaab
![Page 15: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/15.jpg)
CS 3240 - Pushdown Automata 15
![Page 16: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/16.jpg)
CS 3240 - Pushdown Automata 16
Try abababbbb.How would you do Twicea?
Reasoning: There must be 2 b’s for every a. When we read an a, there are three possibilities:
1)Its 2 b’s have already been read2)1 b has been read and 1 remains3)Both b’s are yet to be read
![Page 17: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/17.jpg)
CS 3240 - Pushdown Automata 17
![Page 18: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/18.jpg)
CS 3240 - Pushdown Automata 18
![Page 19: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/19.jpg)
CS 3240 - Pushdown Automata 19
![Page 20: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/20.jpg)
Q: set of states∑: input alphabetΓ: stack alphabetδ: Q x (∑∪λ) x (Γ∪λ) → finite subsets
of Q x Γ*
q0: start stateF ⊆ Q: final states
(z ⋲ Γ: optional stack start symbol)CS 3240 - Pushdown Automata 20
![Page 21: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/21.jpg)
Not strictly necessary Can serve as a “bottom marker” to allow
detection of an empty stack A convenience
Can make things easier to design/understand
Sometimes handy when seeking an associated CFG
Can eliminate some lambda pops▪ Handy later
CS 3240 - Pushdown Automata 21
![Page 22: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/22.jpg)
CS 3240 - Pushdown Automata 22
![Page 23: Pushdown Automata](https://reader030.fdocuments.us/reader030/viewer/2022012404/56812a46550346895d8d7fc4/html5/thumbnails/23.jpg)
CS 3240 - Pushdown Automata 23