[Overview] [Previous] [Next]
Accepting Strings with an NPDA
Suppose you have the npda M = (Q,
,
,
,
q0, z, F).
How do you use this npda to recognize strings?
To recognize string w,
begin with the instantaneous description
(q0, w, z)
where
- q0 is the start state,
- w is the entire string to be processed, and
- z is the start stack symbol.
Starting with this instantaneous description,
make zero or more moves, just as you would with an nfa.
There are two kinds of moves that you can make:
-transitions.
If you are in state q1, x is the top (leftmost) symbol in the stack,
and
(q1,
, x)
= {(q2, w2), ...}, then you can replace the symbol x
with the string w2 and move to state q2.
- Nonempty transitions. If you are in state q1, a is the next unconsumed
input symbol, x is the top (leftmost) symbol in the stack, and
(q1,
a, x) = {(q2, w2), ...}, then you can remove the a from
the input string, replace the symbol x with the string w2, and
move to state q2.
If you are in a final state when you reach the end of the string (and maybe make
some
transitions
after reaching the end), then the string is accepted by the npda. It doesn't matter
what is on the stack.
As usual with nondeterministic machines, the string is accepted if there is any way it could be accepted.
If we take the "oracle" viewpoint, then every time we have to
make a choice, we magically always make the right choice,
so we will end in a final state if at all possible.
Copyright © 1996 by David Matuszek
Last modified Mar 7, 1996