COMP3630/6360: Theory of Computation Semester 1, 2020 The Australian National University Pushdown Automata
1 / 28
COMP3630/6360: Theory of Computation Semester 1, 2020 The - - PowerPoint PPT Presentation
COMP3630/6360: Theory of Computation Semester 1, 2020 The Australian National University Pushdown Automata 1 / 28 This lecture covers Chapter 6 of HMU: Pushdown Automata Pushdown Automata (PDA) Language accepted by a PDA Equivalence
1 / 28
Pushdown Automata
3 / 28
Pushdown Automata
Present state Stack symbol on top Next state The string replacing A on top of the stack The number of possible transitions Input symbol (or ›)
i; ‚i) : i = 1; : : : ; ‘}
4 / 28
Pushdown Automata
5 / 28
Language Accepted by a PDA
P, indicates configuration change
P (q′, w, γα),
∗
P, indicates configuration change due to zero
∗
P ID′ if there are k IDs ID1, . . . , IDk (for some k ≥ 2) such that:
P IDi+1. 6 / 28
Language Accepted by a PDA
∗
P (q′, y, β)
∗
P (q′, yw, β)
∗
P (q′, y, β)
∗
P (q′, y, βγ)
∗
P (q′, y, β) must
7 / 28
Language Accepted by a PDA
∗
P (q, ǫ, α) for some q ∈ F, α ∈ Γ∗
∗
P (q, ǫ, ǫ) for some q ∈ Q
8 / 28
Language Accepted by a PDA
PDA P
PDA P ›; Z0; Z0X0 ›; X0=› ›; X0=› ›; X0=› ›; X =› PDA P 00
9 / 28
Language Accepted by a PDA
PDA P
PDA P ›; Z0; Z0X0 ›; any=› ›; any=› ›; any=› PDA P 0 ›; any=›
10 / 28
CFGs and PDAs
11 / 28
CFGs and PDAs
∗
LM w.
w2 w3 w4 V2 V3 V4 ¸2 ¸3 ¸4 V2 → ‚2 V3 → ‚3 V4 → ‚4
⇒
LM
S
⇒
LM
⇒
LM
⇒
LM
⇒
LM
wi ∈ T ∗ ¸i ∈ (V ∪ T)∗ Vi ∈ V
Stack Stack Symbols that have been popped
wk = w S › [Type 2] [Type 1] ‚1 S → ‚1
Unread Part of Input Tape
› V3¸3 V2¸2 w3 ‚2¸2 ‚3¸3 V4¸4 wk w4 › › ‚k−1¸k−1 wk−1 w3 w2 w2 [Type 2] [Type 1] [Type 2] [Type 1] [Type 2] [Type 1] A \ B := The suffix of B in A
[Start]
Leftmost Derivation in Grammar G Configurations in PDA P w w w \ w2 w \ w2 w \ w3 w \ w3 w \ w4 w \ wk−1
12 / 28
CFGs and PDAs
∗
G w ⇔ (q, w, X)
∗
P (p, ǫ, ǫ). The proof is complete by choosing
13 / 28
CFGs and PDAs
∗
P (p, ǫ, ǫ) ⇒ [qXp]
∗
G w. (Induction on # of steps of computation)
P (p, ǫ, ǫ).
∗
P (p, ǫ, ǫ). Let a be read in the first step of the computation,
∗
(r1;
=x
z }| { w1w2 · · · w‘; Y1Y2 · · · Yk) `
P
∗ (r2; w2 · · · wk; Y2 · · · Yk) (r3; w3 · · · wk; Y3 · · · Yk) (rk; wk; Yk) `
P
∗ `
P
∗ `
P
∗ (p; ›; ›) (r1; w1; Y1) (r2; ›; ›) (r2; w2; Y2) (r3; ›; ›) `
P
∗
w=ax
Induc. Induc.
· · · · · ·
Induc.
[r1Y2r2] w1
∗ )
G
[r2Y3r3] w2
∗ )
G
[rkYkp] wk
∗ )
G
A portion of x is read, and Y1 is popped; more is read, Y2 is popped,: : : (q; w; X) `
P (r1; x; Y1; : : : ; Yk) ∗
`
P (p; ›; ›)
| {z }
14 / 28
CFGs and PDAs
∗
G w ⇒ (q, w, X)
∗
P (p, ǫ, ǫ). (Induction on # of steps of derivation)
∗
G w in one step. Then, [qXp] −
P (p, ǫ, ǫ).
∗
G w.
LM
LM
LM
LM
Induc.
Induc. Induc.
P
P
P
P
w
P
P
P
P
LM
Lemma 6.2.1 Lemma 6.2.1 Lemma 6.2.1
15 / 28
Deterministic PDAs
›; Z0=Z0 0; Z0=0Z0 0; 0=00
q0 q1 q2 1; 0=› P :
16 / 28
Deterministic PDAs
17 / 28
Deterministic PDAs
∗
P (p, ǫ, ǫ) for some p ∈ Q. The DPDA hangs at this state since the stack
PDA P
PDA P ›; Z0; Z0X0 ›; X0=› ›; X0=› ›; X =› ›; X0=› PDA P 00
18 / 28
Deterministic PDAs
∗
P (p, ǫ, γ) for some p ∈ F, and
PDA P 00 PDA P 00
a n y =›
19 / 28
Deterministic PDAs
20 / 28
Deterministic PDAs
21 / 28
Additional Slides
∗
LM w.
22 / 28
Additional Slides
P (q0, w, w2V2α2).
P (q0, w, w2V2α2)
∗
P (q0, w \ w2, V2α2),
P (q0, w, w2V2α2)
∗
P (q0, w \ w2, V2α2) ⊢ P (q0, w \ w2, (w3 \ w2)V3α3),
23 / 28
Additional Slides
24 / 28
Additional Slides
∗
P (p, ǫ, ǫ) ⇒ [qXp]
∗
G w based on length of computation.
∗
P (p, ǫ, ǫ) be a one-step computation. Thus, w has to be an
∗
G w.
∗
P (p, ǫ, ǫ) in say k > 1 steps. Let us assume that the in the first
25 / 28
Additional Slides
∗
P (r2, x \ w1, Y2, · · · Yk)
∗
P (p, ǫ, ǫ),
∗
P (r2, x \ w1, Y2, · · · Yk)
∗
P (r3, x \ (w1w2), Y3, · · · Yk)
∗
P (p, ǫ, ǫ).
∗
P (r2, x \ w1, Y2, · · · Yk) ⇒ (r1, w1, Y1)
∗
P (r2, ǫ, ǫ).
26 / 28
Additional Slides
∗
P (r3, w2 · · · wk, Y3 · · · Yk) ⇒ (r2, w2, Y2)
∗
P (r3, ǫ, ǫ). (4)
∗
P (ri+1, ǫ, ǫ) for i = 1, . . . , k − 1.
∗
P (ri+1, ǫ, ǫ) for i = 1, . . . , k − 1 contain
∗
G wi, i = 1, . . . , k − 1.
∗
G wk.
∗
G aw1 · · · wk = ax = w. 27 / 28
Additional Slides
∗
P (p, ǫ, ǫ) ⇐ [qXp]
∗
G w based on length of leftmost
∗
LM w be a one-step derivation. This can be possible only if
P (p, ǫ, ǫ).
∗
G w in k > 1 steps. As in the previous direction, let us split the
∗
LM wi for i = 1, . . . , k in k − 1 steps or less (I’ve set rk = p here).
∗
P (ri, ǫ, ǫ).
∗
P (ri, wi+1 · · · wk, Yi+1 · · · Yk). Thus,
P (r0, w1 · · · wk, Y1 · · · Yk)
∗
P (r1, w2 · · · wk, Y2 · · · Yk)
∗
P (rk, ǫ, ǫ) = (p, ǫ, ǫ).
28 / 28