- Pushdown automaton
In
automata theory , a pushdown automaton (PDA) is a finite automaton that can make use of a stack containing data.Operation
Pushdown automata differ from normal finite state machines in two ways:
# They can use the top of the stack to decide which transition to take.
# They can manipulate the stack as part of performing a transition.Pushdown automata choose a transition by indexing a table by input signal, current state, and the top of the stack. Normal finite state machines just look at the input signal and the current state: they have no stack to work with. Pushdown automata add the stack as a parameter for choice. Given an input signal, current state, and a given symbol at the top of the stack, a transition path is chosen.
Pushdown automata can also manipulate the stack, as part of performing a transition. Normal finite state machines choose a new state, the result of following the transition. The manipulation can be to push a particular symbol to the top of the stack, or to pop off the top of the stack. The automaton can alternatively ignore the stack, and leave it as it is. The choice of manipulation (or no manipulation) is determined by the transition table.
Put together: Given an input signal, current state, and stack symbol, the automaton can follow a transition to another state, and optionally manipulate (push or pop) the stack.
The (underlying) finite automation is specifically a
nondeterministic finite state machine , giving what is technically known as a "nondeterministic pushdown automaton" (NPDA). If adeterministic finite state machine is used, then the result is adeterministic pushdown automaton (DPDA), a strictly weaker device. Nondeterminism means that there may be more than just one transition available to follow, given an input signal, state, and stack symbol.If we allow a finite automaton access to two stacks instead of just one, we obtain a more powerful device, equivalent in power to a
Turing machine . Alinear bounded automaton is a device which is more powerful than a pushdown automaton but less so than a Turing machine.Pushdown automata are equivalent to
context-free grammars : for every context-free grammar, there exists a pushdown automaton such that the language generated by the grammar is identical with the language generated by the automaton, and for every pushdown automaton there exists a context-free grammar such that the language generated by the automaton is identical with the language generated by the grammar.Formal Definition
A PDA is formally defined as a 7-tuple:
where
* is a finite set of states
* is a finite set which is called the input alphabet
* is a finite set which is called the stack alphabet
*: is the transition function, where denotes thepower set of .
* is the start state
* is the initial stack symbol
* is the set of accepting states
*
*"Computation Definition 1"
For any PDA, , a computation path is an ordered
(n+1)-tuple, , where Q, n 0, which satisfies the following conditions:
(i) for i = 0, 1, 2,......, n-1, :where
(ii) such that
:
Intuitively, a PDA, at any point in the computation process, faces multiple possibilities of whether to read a symbol from the top of the stack and replace it with another symbol, or read a symbol from the top of the stack and remove it without replacement, or not read any symbol from the stack but only push another symbol to it, or to do nothing. All these are governed by the simutaneous equations and . is called the stack content immediately before the transitional move and is the symbol to be removed from the top of the stack. is the stack content immediately after the transitional move and is the symbol to be added to the stack during the transitional move.
Both and can be .
If and , the PDA reads a symbol from the stack and replace it with another one.
If and , the PDA reads a symbol from the stack and remove it without replacement.
If and , the PDA simply adds a symbol to the stack.
If and , the PDA leaves the stack unchanged.
Note that when n=0, the computation path is just the singleton (q0).
"Computation Definition 2"
For any input w = w1w2...wm, wi , m0, M accepts w if a computation path and a finite sequence r0, r1, r2,...rm Q, mn, such that
(i) For each i = 0, 1, 2,...m, ri is on the computation path. That is,: f(i) where if(i)n such that ri = qf(i)
(ii) (qf(i)+1, bf(i)+1) (ri, wi+1, af(i)+1) for each i = 0, 1, 2,...m-1.:where af(i)+1 and bf(i)+1 are defined as in Computation Definition 1.
(iii) (qj+1, bj+1) (qj, , aj+1) if qj {r0, r1,...rm}:where aj+1 and bj+1 are defined as in Computation Definition 1.
(iv) rm = qn and rm F
Note that the above definitions do not provide a mechanism to test for an empty stack. To do so, one would need to write a special symbol on the stack at the beginning of every computation so that the PDA would recognize that the stack is effectively empty whenever it detects the special symbol. Formally, this is done by introducing the transition (q0, = {(q1, $)} where $ is the special symbol.
Example
The following is the formal description of the PDA which recognizes the language nato :
Q = {q1, q2, q3, q4}
= {0, 1}
= {0, $}
F = {q1, q4}
(q1, , ) = {(q2, $), (q1, )}
(q2, 0, ) = {(q2, 0)}
(q2, 1, 0) = {(q3, )}
(q3, 1, 0) = {(q3, )}
(q3, , $) = {(q4, )}
(q, w, a) = for any other values of state, input and stack symbols.
Understanding the computation process
The following illustrates how the above PDA computes on different input strings.
(a) Input string = 0011: (i) write (q1, , ) (q2, $) to represent (q2, $) (q1, , )
:: s0 = , s1 = $, t = , a = , b = $
:: set r0 = q2
: (ii) (r0, 0, ) = (q2, 0, ) (q2, 0)
:: s1 = $, a = , t = $, b = 0, s2 = 0$
:: set r1 = q2
: (iii) (r1, 0, ) = (q2, 0, ) (q2, 0)
:: s2 = 0$, a = , t = 0$, b = 0, s3 = 00$
:: set r2 = q2
: (iv) (r2, 1, 0) = (q2, 1, 0) (q3, )
:: s3 = 00$, a = 0, t = 0$, b = , s4 = 0$
:: set r3 = q3
: (v) (r3, 1, 0) = (q3, 1, 0) (q3, )
:: s4 = 0$, a = 0, t = $, b = , s5 = $
: (vi) (q3, , $) (q4, )
:: s5 = $, a = $, t = , b = , s6 =
:: set r4 = q4
: Since q4 is an accept state, 0011 is accepted.
: In summary, computation path = (q1, q2, q2, q2, q3, q3, q4)
: and (r0, r1, r2, r3, r4) = (q2, q2, q2, q3, q4)
(b) Input string = 001
: Computation moves (i), (ii), (iii), (iv) would have to be the same as in case (a), otherwise, the PDA would have come to a dead end before reaching (v).
: (v) (r3, , a) = (q3, , a)
:: Since s4 = 0$, either a = or a = 0
:: In either case, (q3, , a) =
:: Therefore, computation comes to an end at r3 = q3 which is not an accept state. Therefore, 001 is rejected.
(c) Input string =
: Set r0 = q1, r1 = q1
: (r0, , ) (q1, )
: Since q1 is an accept state, is accepted.
Generalized Pushdown Automaton (GPDA)
A GPDA is a PDA which writes an entire string to the stack or removes an entire string from the stack in one step.
A GPDA is formally defined as a 6-tuple
: where Q, , , q0 and F are defined the same way as a PDA.
:: is the transition function.
Computation rules for a GPDA are the same as a PDA except that the ai+1's and bi+1's are now strings intead of symbols.
GPDA's and PDA's are equivalent in that if a language is recognized by a PDA, it is also recognized by a GPDA and vice versa.
One can formulate an analytic proof for the equivalence of GPDA's and PDA's using the following simulation:
Let (q1, w, x1x2...xm) (q2, y1y2...yn) be a transition of the GPDA
where q1, q2 Q, w , x1x2...xm , m0, y1y2...yn , n0.
Construct the following transitions for the PDA:
::(q1, w, x1) (p1, )
::(p1, , x2) (p2, )
::::
::(pm-1, , xm) (pm, )
::(pm, , ) (pm+1, yn)
::(pm+1, , ) (pm+2, yn-1)
::::
::(pm+n-1, , ) (q2, y1)
ee also
*
Stack machine
*Context-free grammar
*Finite automaton
*Nondeterministic finite state machine External links
* [http://planetmath.org/encyclopedia/PushdownAutomaton.html non-deterministic pushdown automaton,] on Planet Math.
* [http://www.jflap.org JFLAP] , simulator for several types of automata including nondeterministic pushdown automataReferences
* Section 2.2: Pushdown Automata, pp.101–114.
Wikimedia Foundation. 2010.