Upload
kirby-fletcher
View
72
Download
0
Embed Size (px)
DESCRIPTION
CS 3240 – Chapter 7. Pushdown Automata. Where Are We?. A Pushdown Automaton Machine for Context-Free Languages. Take an FA and add a stack A restricted form of unbounded memory Operations: Pop Push Ignore ( λ ) (Pop always precedes push). PDA Operations. - PowerPoint PPT Presentation
Citation preview
CS 3240 – Chapter 7
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
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
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
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
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)
7CS 3240 - Pushdown Automata
8CS 3240 - Pushdown Automata
How would you do a2nbn?
CS 3240 - Pushdown Automata 9
Each b must pop 2 X’s
Is this deterministic?
Trace the string abaacaaba.
10CS 3240 - Pushdown Automata
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
Is this deterministic?Trace the string abaaaaaba.Trace the string abaabaaba.Trace the string abaaaaba.
12CS 3240 - Pushdown Automata
CS 3240 - Pushdown Automata 13
Trace aaabbbb
The grammar:
S → aSb | aSbb | λ
CS 3240 - Pushdown Automata 14
Trace ababbaab
CS 3240 - Pushdown Automata 15
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
CS 3240 - Pushdown Automata 17
CS 3240 - Pushdown Automata 18
CS 3240 - Pushdown Automata 19
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
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
CS 3240 - Pushdown Automata 22
CS 3240 - Pushdown Automata 23