Professional Documents
Culture Documents
Pushdown Automata: CIS 5513 - Automata and Formal Languages - Pei Wang
Pushdown Automata: CIS 5513 - Automata and Formal Languages - Pei Wang
Pushdown Automata
5
Instantaneous descriptions of PDA
The configuration, or instantaneous description
(ID), of a PDA: (q, w, r), where q is the state, w
is the remaining input, and r is the stack contents
Here “state” only specifies the “control unit”, not
the stored “data” in stack
If the value of δ(q, a, X) contains (p, α), then the ID
transition is (q, aw, Xβ) ˫ (p, w, αβ), for arbitrary
w and β
6
ID transitions: an example
7
Properties of ID transitions
ID transition with multiple moves is shown as ˫*
Symbols may be added or removed to input or
stack in ID transitions
8
Exercise 6.1.1
Solution
9
Two types of acceptance
A PDA can define a language in two ways
10
From Empty Stack to Final State
11
From Final State to Empty Stack
PN can be obtained by popping out all stack symbols in final states in PF,
with the help of a new stack-symbol below Z0
12
Exercises for Section 6.2
Solutions:
http://infolab.stanford.edu/~ullman/ialcsols/sol6.html#sol62
13
CFG to PDA
From a given CFG G = (V, T, Q, S), a PN =
({q},T, VT, , q, S) can accept L(G) by
simulating the leftmost derivation to expand
the symbols in stack to match the input
When PN is in ID (q, y, Aα) where A is a variable
and there is a rule A→β in Q, the next ID can
be (q, y, βα). Remove the common prefix of βα
and y. Repeat until the stack is empty
14
CFG to PDA: example
15
PDA to CFG : simple case
If a PDA is P = ({q}, Σ, Γ, δ, q, Z), the
equivalent CFG G = (Γ{S}, Σ, R, S),
where R contains S → Z, and for each
(q, Y1Y2…Yk) in δ(q, a, X), R contains X
→ aY1Y2…Yk, where k ≥ 0, and Yi can
be a variable, a terminal, or ε
16
PDA to CFG: general case
Use a grammar variable [pXq] to
represent the state change from p to q
for the popping out of a stack symbol X
17
PDA to CFG (cont.)
18
PDA to CFG: example
19
PDA to CFG: example (2)
20
PDA to CFG: example (3)
21
Exercises for Section 6.3
Solutions: http://infolab.stanford.edu/~ullman/ialcsols/sol6.html#sol63
22
Deterministic pushdown automata
A PDA is deterministic (DPDA), if
Each δ(q, a, X) has at most one element
If δ(q, a, X) is
nonempty, then
δ(q, ɛ, X) must be
empty
Lwcwr = {wcwR}
with a marker c
23
PDA, DPDA, and DFA
The set of language accepted by DPDA is a
subset of CFL, and a super set of regular
language, so the capability of DPDA is
between those of PDA and DFA
DPDA accept all regular languages, but only the
context-free languages that have
unambiguous CFG
24