Pushdown Automata (PDA - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Pushdown Automata (PDA

Description:

Lecture 33 Pushdown Automata (PDA s) definition example Pushdown Automata Definition and Motivating Example PDA s In this presentation we introduce the PDA model ... – PowerPoint PPT presentation

Number of Views:159
Avg rating:3.0/5.0
Slides: 20
Provided by: EricT67
Learn more at: http://www.cse.msu.edu
Category:

less

Transcript and Presenter's Notes

Title: Pushdown Automata (PDA


1
Lecture 33
  • Pushdown Automata (PDAs)
  • definition
  • example

2
Pushdown Automata
  • Definition and Motivating Example

3
PDAs
  • In this presentation we introduce the PDA model
    of computation (programming language).
  • We first begin with an example NFA
  • We augment this NFA with external memory in the
    form of a counter
  • We then transform the counter into a stack to
    produce a PDA
  • We define configurations and computations of
    these new computational models
  • We define L(M) for these new computational models

4
NFA for ambn m,n gt 0
  • Consider the language anbn n gt 0.
  • This NFA can recognize strings which have the
    correct form,
  • as followed by bs.
  • However, the NFA cannot remember the relative
    number of as and bs seen at any point in time.
  • What strings end up in each state of the above
    NFA?
  • A The set of strings in a.
  • B The set of strings in ab.
  • C The set of strings in ab.

5
NFA for anbn n gt0
Imagine we now have memory in the form of a
counter which we can increment or decrement every
time we see an input character. When we see an a
in state A, we do the following two actions 1)
We increment the counter value by 1. 2) We stay
in state A. When we see a b in state B, we do
the following two actions 1) We decrement the
counter value by 1. 2) We stay in state B. From
state B, we allow a /\-transition to state C only
if 1) The counter has value 0. Finally, when we
begin, the counter should have value 0.

6
Defining Configurations of NFA
  • The following information needs to be recorded in
    a configuration of a computation of an NFA M on
    an input string x.
  • 1) Current state
  • 2) Remaining input to be processed
  • 3) Current counter value
  • Note, the counter is NOT part of the input.
  • It is part of the computational model.
  • Its current value needs to be recorded in a
    configuration.


7
Computation Tree of NFA
Computation Tree for this NFA on the input
string aabb
(A,aabb,0)
8
Questions about NFA
1) Why can this NFA accept anbn n gt 0?
That is, how do we get around the Myhill-Nerode
Theorem? 2) What happens if the counter has a
finite capacity? For example, it can only go
up to 10. Can some NFA still accept anbn
n gt 0? 3) Suppose that we have a stack data
structure instead of a counter. Can we do
anything we could with the counter? Can we
do something we could not do with only a counter?
9
PDA for anbn n gt 0
Here is a pushdown automaton (PDA) for this
language. A PDA is essentially an NFA augmented
with an infinite capacity stack. The pushdown
part of the name supposedly comes from the
stacks trays in cafeterias where you have to
pushdown on the stack to add a tray to it. In
this example, only one character a is ever pushed
onto the stack.

NFA
10
Defining Configurations of PDA
The following information needs to be recorded in
a configuration of a computation of an PDA M on
an input string x. 1) Current state 2) Remaining
input to be processed 3) Current stack
contents. Note again, the stack is NOT part of
the input. It is part of the computational
model. However, its current value needs to be
recorded in a configuration. We will represent
the stack contents by a string of
characters. The leftmost character is on top of
the stack. The rightmost character is at the
bottom of the stack. We will represent an empty
stack with the string /\.

11
Computation Graph of PDA
Computation graph for this PDA on the input
string aabb
(A,aabb,/\)
12
PDA for anbn n gt 0
1) The first black character is the current input
symbol. 2) The second red character is the
current top stack symbol. 3) The third string of
characters is the stack update action. The stack
character Z is a special character which we
will always keep on the bottom of the stack.
Note it is part of G, though, so it may be used
other places as well.

13
Computation Graph of PDA
Computation graph for this PDA on the input
string aabb
(A,aabb,Z)
14
Formal Definition of PDA
A PDA M (Q, S, G, q0, Z, A, d) Items common to
NFAs Q is the set of states S is the input
alphabet q0 is the initial state A is the set
of accepting states Modified items G is the
stack alphabet - Z is a special character in
G - The stack always begins containing 1 Z d
modified as follows pops/reads top stack
symbol as well as current input
character describes how to update stack note
push /\ results in pop!
Q I, B, C S a,b G Z, a q0 I Z is
the initial stack character A
C d state input top stack next state stack
update I a a I push aa I a Z I push
aZ I /\ a B push a I /\ Z B push Z B b a B push
/\ B /\ Z C push Z
15
Nondeterministic vs Deterministic
  • PDA M (Q, S, G, q0, Z, A, d)
  • A PDA is deterministic if
  • For all q in Q and a in S,
  • d(q,a) p (or is undefined) AND
  • if d(q,/\) is defined, then d(q,a) is undefined
  • A PDA is nondeterministic otherwise
  • This is our default assumption

16
L(M) for a PDA
A string x is in L(M) if and only if it there
exists an accepting configuration (q, /\,
anything) in the computation graph of M on x
. An accepting configuration satisfies the
following two conditions 1) The PDA must be in
an accepting state 2) The input string must be
completely processed Note, the stack contents is
unimportant. This is known as acceptance by
final state.
17
Deterministic PDAs
  • A PDA is deterministic if its transition function
    satisfies both of the following properties
  • For all q in Q, a in S union l, and X in G,
  • the set d(q,a) has at most one element
  • For all q in Q and X in G,
  • if d(q, l, X) lt gt , then d(q,a,X) for
    all a in S
  • A computation graph is now just a path again

18
LPDA and DCFL
  • A language L is in language class LPDA if and
    only if there exists a PDA M such that L(M) L
  • A language L is in language class DCFL
    (Deterministic Context-Free Languages) if and
    only if there exists a deterministic PDA M such
    that L(M) L
  • To be proven
  • LPDA CFL which is a proper superset of DCFL

19
PDA Comments
  • Note, we can use the stack for much more than
    just a counter
  • See examples in section 6.1 for some details
Write a Comment
User Comments (0)
About PowerShow.com