Push-Down Memory and Push-Down Automata
Push-Down Memory and Push-Down Automata
Push-Down Memory and Push-Down Automata
PUSH-DOWN AUTOMATA
c k−1 is accessible
only after the removal of c k
c 1 c 2 c 2 ⋅⋅⋅ c k−1
stack = c 1 c 2 ⋅⋅⋅c k−1
addition of c k+1
makes c k inaccessible
c 1 c 2 c 2 ⋅⋅⋅ c k−1 c k c k+1
stack = c 1 c 2 ⋅⋅⋅c k−1 c k c k+1
EXAMPLE OF A PDA
Processing of x = a⋅ab⋅ab b:
Remaining Transition
Stack memory State
input string used
λ q0 aababb λ /a/a
a q0 ababb a/a/aa
aa q0 babb a/b/ λ
a q0 abb a/a/aa
aa q0 bb a/b/ λ
a q0 b a/b/ λ
λ q0 λ
copyright@1995 8.4
EXERCISE.
1. Construct a PDA to accept L bal- par ; λ ∉ L bal- par .
2. For each PDA below, describe the language accepted by it. Which
of the PDAs are deterministic?
λ/a/a, a/a/aa a/b/λ λ/a/a, a/a/aa a/b/λ a/b/λ, a/a/aa
q 0 a/b/λ q 1 q 0 a/b/λ q 1 q λ/a/a q
0 1
λ/a/a, a/a/aa λ/a/a
a/a/aa, a/a/a,
λ/a/λ a/b/λ λ/a/λ a/a/aa a/b/λ
q0 λ/a/a q q 0 λ/a/λ q 1 λ/a/a q 2 a/b/λ q 3
1
4. Show a PDA which accepts all non-empty strings over the alphabet
{0, 1, ×, =} which represent correct multiplications of the form
2m 2n = 2m+n . For m = 2 and n = 3, the input string is
100×1000=100000. (Hint: the symbols ’×’ and ’=’ in the input
string should drive the PDA to different states.)
5. Show that the language described in Problem 4 is not regular.
6. Give the state-diagram for a deterministic PDA which accepts the
language L m=2n = {a m b n : m = 2n, n ≥ 1}. Do the same for the lan-
guage L m=2n+1 , defined in a similar way.
copyright@1995 8.5
CFLs •• {a n b n : n ≥ 1}
•• symmetric strings in {a, b}
RLs
•• balanced parenthetical strings
{a m b n : m ≥ 1, n ≥ 1} • •• bin. mult. of the form 2m 2n = 2m+n
L 3n •
•• {a m b n : m ≥ n ≥ 1}
••• a non-CFL: {a n b n c n : n ≥ 1}
••• a non-CFL: symmetric balanced parenthetical strings
(λ, q 0 , ab)
(a, q 0 , b) (λ, q 1 , b)
non-accepting
(ab, q 0 , λ) (a, q 1 , λ)
non-accepting non-accepting
COMPLEMENT OF {a n b n : n ≥ 1}
λ/a/λ
a/a/aa a/b/λ
λ/a/a q a/b/λ q q 0 handles (1)
q0 2 3 q 1 handles (2)-(3) and (5) for m = n
q 4 handles (4) for m = 0
λ/b/λ λ/b/λ, q 6 handles (4) for m > 0
λ/a/λ q 7 handles (5) for m < n
q1
λ/a/λ, λ/b/λ
EXERCISE.
1. Construct a PDA to accept the complement of L bal- par ; the com-
plement includes λ.
copyright@1995 8.9
λ/a/λ, λa/b/a
/b/ λ , b/a/b b/b/ λ ,
a/a/ λ , b/b/b
a/a/a
q1 A b/b/ λ q1 B
a/a/ λ
a/a/ λ b/b/ λ
Question:
•? Show the tree of all configurations in processing aba.
copyright@1995 8.10
EXERCISE
1. Argue that the union of a CFL and an RL is a CFL.
2. Assume that L a n b n c n = {a n b n c n : n ≥ 1} is not CFL, i.e., it is not
accepted by any PDA. Then, show that {x ∈ (a + b + c)∗ : #(x, a) =
#(x, b) = #(x, c)} is not CFL.
3. Give a PDA for the language L #a=#b = {x ∈ (a + b)∗ : #(x, a) =
#(x, b)}.
4. If L is a CFL and L′ is regular, then argue that L L′ and L′L are
CFL
5. Since L a n b n c n = L a n b n c∗ ∩ L a∗ b n c n and both L a n b n c∗ and L a∗ b n c n are
CFL, it follows that intersection of CFLs need not be a CFL. Thus,
complement of a CFL need not be a CFL either.
copyright@1995 8.11
20 23
24 45
2 1
3
28 34
33
32
Some observations:
• Starting at 1, when the robot reaches 20 (or 23) the stack must tell
us that the robot is one step further north of position 1.
• At 28 (also at 34), the stack should tell us that the maximum north
reached so far was one step higher than the start position, and that
currently the robot is 4 steps south from that max-north position.
• At 45, the stack must tell us we are still south of the max-north
position and it must allow us to get back to position 23, say.
EXERCISE.
1. Design a PDA-control of a robot so that for any initital placement
of it in a linear maze, it will stop at a northmost position. Hints: (1)
First make the robot go to a dead-end. (2) Use the stack to keep
track of north-south motion as it now moves to the other dead-end.
Show the stack for each position of the robot till it stops.
copyright@1995 8.12
1 3