In automata theory, a pushdown automaton (PDA) is a variation of finite automaton that can make use of a stack containing data.
a diagram of the pushdown automaton
Pushdown automata differ from 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 symbol at the top of the stack. This means that those three parameters completely determine the transition path that is chosen. 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.
Pushdown automata can also manipulate the stack, as part of performing a transition. 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.
In general, pushdown automata may have several computations on a given input string, some of which may be halting in accepting configurations while others are not. Thus we have a model which is technically known as a "nondeterministic pushdown automaton" (NDPDA or NPDA). Nondeterminism means that there may be more than just one transition available to follow, given an input signal, state, and stack symbol. If in every situation only one transition is available as continuation of the computation, then the result is a deterministic pushdown automaton (DPDA), a strictly weaker device.
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. A linear 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, which is easy to prove. The reverse is true, though harder to prove: 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.
A PDA is formally defined as a 7-tuple:
Failed to parse (Missing texvc executable; please see math/README to configure.): M=(Q,\ \Sigma,\ \Gamma,\ \delta, \ q_{0},\ Z, \ F)
where
- Failed to parse (Missing texvc executable; please see math/README to configure.): \, Q
is a finite set of states
- Failed to parse (Missing texvc executable; please see math/README to configure.): \,\Sigma
is a finite set which is called the input alphabet
- Failed to parse (Missing texvc executable; please see math/README to configure.): \,\Gamma
is a finite set which is called the stack alphabet
- Failed to parse (Missing texvc executable; please see math/README to configure.): \,\delta
is a finite subset of Failed to parse (Missing texvc executable; please see math/README to configure.): Q \times (\Sigma \cup\{\varepsilon\}) \times \Gamma \times Q \times \Gamma^*
, the transition relation, where Failed to parse (Missing texvc executable; please see math/README to configure.): \Gamma^{*}
denote the set of strings over Failed to parse (Missing texvc executable; please see math/README to configure.): \Gamma
and Failed to parse (Missing texvc executable; please see math/README to configure.): \varepsilon
denotes the empty string.
- Failed to parse (Missing texvc executable; please see math/README to configure.): \,q_{0}\in\, Q
is the start state
- Failed to parse (Missing texvc executable; please see math/README to configure.): \ Z\in\,\Gamma
is the initial stack symbol
- Failed to parse (Missing texvc executable; please see math/README to configure.): F\subseteq Q
is the set of accepting states
An element Failed to parse (Missing texvc executable; please see math/README to configure.): (p,a,A,q,\alpha) \in \delta
is a transition of Failed to parse (Missing texvc executable; please see math/README to configure.): M
. It has the intended meaning that Failed to parse (Missing texvc executable; please see math/README to configure.): M , in state Failed to parse (Missing texvc executable; please see math/README to configure.): p \in Q , with Failed to parse (Missing texvc executable; please see math/README to configure.): a \in \Sigma \cup\{\varepsilon\}
on the input and with Failed to parse (Missing texvc executable; please see math/README to configure.): A \in \Gamma
as topmost stack symbol, may read Failed to parse (Missing texvc executable; please see math/README to configure.): a
, change the state to Failed to parse (Missing texvc executable; please see math/README to configure.): q , pop Failed to parse (Missing texvc executable; please see math/README to configure.): A , replacing it by pushing Failed to parse (Missing texvc executable; please see math/README to configure.): \alpha \in \Gamma^* . The letter Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon
(epsilon) denotes the empty string and the Failed to parse (Missing texvc executable; please see math/README to configure.): (\Sigma \cup\{\varepsilon\})
component of the transition relation is used to formalize that the PDA can either read a letter from the input, or proceed leaving the input untouched.
In many texts the transition relation is replaced by an (equivalent) formalization, where
- Failed to parse (Missing texvc executable; please see math/README to configure.): \,\delta
is the transition function, mapping Failed to parse (Missing texvc executable; please see math/README to configure.): Q \times (\Sigma \cup\{\varepsilon\}) \times \Gamma
into finite subsets of Failed to parse (Missing texvc executable; please see math/README to configure.): Q \times \Gamma^*
.
Here Failed to parse (Missing texvc executable; please see math/README to configure.): \delta(p,a,A)
contains all possible actions in state Failed to parse (Missing texvc executable; please see math/README to configure.): p
with Failed to parse (Missing texvc executable; please see math/README to configure.): A
on the stack, while reading Failed to parse (Missing texvc executable; please see math/README to configure.): a
on the input. One writes Failed to parse (Missing texvc executable; please see math/README to configure.): (q,\alpha) \in \delta(p,a,A)
for the function precisely when Failed to parse (Missing texvc executable; please see math/README to configure.): (p,a,A,q,\alpha) \in\delta
for the relation. Note that finite in this definition is essential.
Computations
a step of the pushdown automaton
In order to formalize the semantics of the pushdown automaton a description of the current situation is introduced. Any 3-tuple Failed to parse (Missing texvc executable; please see math/README to configure.): (p,w,\beta) \in Q \times \Sigma^* \times \Gamma^*
is called an instantaneous description (ID) of Failed to parse (Missing texvc executable; please see math/README to configure.): M
, which includes the current state, the part of the input tape that has not been read, and the contents of the stack (topmost symbol written first). The transition relation Failed to parse (Missing texvc executable; please see math/README to configure.): \delta
defines the step-relation Failed to parse (Missing texvc executable; please see math/README to configure.): \vdash_{M}
of Failed to parse (Missing texvc executable; please see math/README to configure.): M
on instantaneous descriptions. For instruction Failed to parse (Missing texvc executable; please see math/README to configure.): (p,a,A,q,\alpha) \in \delta
there exists a step Failed to parse (Missing texvc executable; please see math/README to configure.): (p,ax,A\gamma) \vdash_{M} (q,x,\alpha\gamma)
, for every Failed to parse (Missing texvc executable; please see math/README to configure.): x\in\Sigma^*
and every Failed to parse (Missing texvc executable; please see math/README to configure.): \gamma\in \Gamma^*
.
In general pushdown automata are nondeterministic meaning that in a given instantaneous description Failed to parse (Missing texvc executable; please see math/README to configure.): (p,w,\beta)
there may be several possible steps. Any of these steps can be chosen in a computation.
With the above definition in each step always a single symbol (top of the stack) is popped, replacing it with as many symbols as necessary. As a consequence no step is defined when the stack is empty.
Computations of the pushdown automaton are sequences of steps. The computation starts in the initial state Failed to parse (Missing texvc executable; please see math/README to configure.): q_{0}
with the initial stack symbol Failed to parse (Missing texvc executable; please see math/README to configure.): Z
on the stack, and a string Failed to parse (Missing texvc executable; please see math/README to configure.): w
on the input tape, thus with initial description Failed to parse (Missing texvc executable; please see math/README to configure.): (q_{0},w,Z)
. There are two modes of accepting. The pushdown automaton either accepts by final state, which means after reading its input the automaton reaches an accepting state (in Failed to parse (Missing texvc executable; please see math/README to configure.): F ), or it accepts by empty stack (Failed to parse (Missing texvc executable; please see math/README to configure.): \varepsilon ), which means after reading its input the automaton empties its stack. The first acceptance mode uses the internal memory (state), the second the external memory (stack).
Formally one defines
- Failed to parse (Missing texvc executable; please see math/README to configure.): L(M) = \{ w\in\Sigma^* | (q_{0},w,Z) \vdash_M^* (f,\varepsilon,\gamma)
with Failed to parse (Missing texvc executable; please see math/README to configure.): f \in F
and Failed to parse (Missing texvc executable; please see math/README to configure.): \gamma \in \Gamma^* \}
(final state)
- Failed to parse (Missing texvc executable; please see math/README to configure.): N(M) = \{ w\in\Sigma^* | (q_{0},w,Z) \vdash_M^* (q,\varepsilon,\varepsilon)
with Failed to parse (Missing texvc executable; please see math/README to configure.): q \in Q \}
(empty stack)
Here Failed to parse (Missing texvc executable; please see math/README to configure.): \vdash_M^*
represents the reflexive and transitive closure of the step relation Failed to parse (Missing texvc executable; please see math/README to configure.): \vdash_M
meaning any number of consecutive steps (zero, one or more).
For each single pushdown automaton these two languages need to have no relation: they may be equal but usually this is not the case. A specification of the automaton should also include the intended mode of acceptance. Taken over all pushdown automata both acceptance conditions define the same family of languages.
Theorem. For each pushdown automaton Failed to parse (Missing texvc executable; please see math/README to configure.): M
one may construct a pushdown automaton Failed to parse (Missing texvc executable; please see math/README to configure.): M'
such that Failed to parse (Missing texvc executable; please see math/README to configure.): L(M)=N(M')
, and vice versa, for each pushdown automaton Failed to parse (Missing texvc executable; please see math/README to configure.): M
one may construct a pushdown automaton Failed to parse (Missing texvc executable; please see math/README to configure.): M'
such that Failed to parse (Missing texvc executable; please see math/README to configure.): N(M)=L(M')
The following is the formal description of the PDA which recognizes the language Failed to parse (Missing texvc executable; please see math/README to configure.): \{0^n1^n \mid n \ge 0 \}
by final state:
PDA for
Failed to parse (Missing texvc executable; please see math/README to configure.): \{0^n1^n \mid n \ge 0\} (by final state)
Failed to parse (Missing texvc executable; please see math/README to configure.): M=(Q,\ \Sigma,\ \Gamma,\ \delta, \ p,\ Z, \ F) , where
Failed to parse (Missing texvc executable; please see math/README to configure.): Q = \{ p,q,r \}
Failed to parse (Missing texvc executable; please see math/README to configure.): \Sigma = \{0, 1\}
Failed to parse (Missing texvc executable; please see math/README to configure.): \Gamma = \{A, Z\}
Failed to parse (Missing texvc executable; please see math/README to configure.): q_{0} = p
Failed to parse (Missing texvc executable; please see math/README to configure.): F = \{r\}
Failed to parse (Missing texvc executable; please see math/README to configure.): \delta
consists of the following six instructions:
Failed to parse (Missing texvc executable; please see math/README to configure.): (p,0,Z,p,AZ) , Failed to parse (Missing texvc executable; please see math/README to configure.): (p,0,A,p,AA) , Failed to parse (Missing texvc executable; please see math/README to configure.): (p,\epsilon,Z,q,Z) , Failed to parse (Missing texvc executable; please see math/README to configure.): (p,\epsilon,A,q,A) , Failed to parse (Missing texvc executable; please see math/README to configure.): (q,1,A,q,\epsilon) , and Failed to parse (Missing texvc executable; please see math/README to configure.): (q,\epsilon,Z,r,Z) .
In words, in state Failed to parse (Missing texvc executable; please see math/README to configure.): p
for each symbol Failed to parse (Missing texvc executable; please see math/README to configure.): 0
read, one Failed to parse (Missing texvc executable; please see math/README to configure.): A
is pushed onto the stack. Pushing symbol Failed to parse (Missing texvc executable; please see math/README to configure.): A
on top of another Failed to parse (Missing texvc executable; please see math/README to configure.): A
is formalized as replacing top Failed to parse (Missing texvc executable; please see math/README to configure.): A
by Failed to parse (Missing texvc executable; please see math/README to configure.): AA
. In state Failed to parse (Missing texvc executable; please see math/README to configure.): q
for each symbol Failed to parse (Missing texvc executable; please see math/README to configure.): 1
read one Failed to parse (Missing texvc executable; please see math/README to configure.): A
is popped. At any moment the automaton may move from state Failed to parse (Missing texvc executable; please see math/README to configure.): p
to state Failed to parse (Missing texvc executable; please see math/README to configure.): q
, while it may move from state Failed to parse (Missing texvc executable; please see math/README to configure.): q
to accepting state Failed to parse (Missing texvc executable; please see math/README to configure.): r
only when the stack consists of a single Failed to parse (Missing texvc executable; please see math/README to configure.): Z
.
There seems to be no generally used representation for PDA. Here we have depicted the instruction Failed to parse (Missing texvc executable; please see math/README to configure.): (p,a,A,q,\alpha)
by an edge from state Failed to parse (Missing texvc executable; please see math/README to configure.): p
to state Failed to parse (Missing texvc executable; please see math/README to configure.): q
labelled by Failed to parse (Missing texvc executable; please see math/README to configure.): a; A/\alpha
(read Failed to parse (Missing texvc executable; please see math/README to configure.): a
- replace Failed to parse (Missing texvc executable; please see math/README to configure.): A
by Failed to parse (Missing texvc executable; please see math/README to configure.): \alpha
).
accepting computation for
Failed to parse (Missing texvc executable; please see math/README to configure.): 0011
The following illustrates how the above PDA computes on different input strings. The subscript Failed to parse (Missing texvc executable; please see math/README to configure.): M
from the step symbol Failed to parse (Missing texvc executable; please see math/README to configure.): \vdash
is here omitted.
(a) Input string = 0011. There are various computations, depending on the moment the move from state Failed to parse (Missing texvc executable; please see math/README to configure.): p
to state Failed to parse (Missing texvc executable; please see math/README to configure.): q
is made. Only one of these is accepting.
- (i) Failed to parse (Missing texvc executable; please see math/README to configure.): (p,0011,Z) \vdash (q,0011,Z) \vdash (r,0011,Z)
. The final state is accepting, but the input is not accepted this way as it has not been read.
- (ii) Failed to parse (Missing texvc executable; please see math/README to configure.): (p,0011,Z) \vdash (p,011,AZ) \vdash (q,011,AZ)
. No further steps possible.
- (iii) Failed to parse (Missing texvc executable; please see math/README to configure.): (p,0011,Z) \vdash (p,011,AZ) \vdash (p,11,AAZ) \vdash (q,11,AAZ)
Failed to parse (Missing texvc executable; please see math/README to configure.): \vdash (q,1,AZ) \vdash (q,\epsilon,Z)
Failed to parse (Missing texvc executable; please see math/README to configure.): \vdash (r,\epsilon,Z)
. Accepting computation: ends in accepting state, while complete input has been read.
(b) Input string = 00111. Again there are various computations. None of these is accepting.
- (i) Failed to parse (Missing texvc executable; please see math/README to configure.): (p,00111,Z) \vdash (q,00111,Z) \vdash (r,00111,Z)
. The final state is accepting, but the input is not accepted this way as it has not been read.
- (ii) Failed to parse (Missing texvc executable; please see math/README to configure.): (p,00111,Z) \vdash (p,0111,AZ) \vdash (q,0111,AZ)
. No further steps possible.
- (iii) Failed to parse (Missing texvc executable; please see math/README to configure.): (p,00111,Z) \vdash (p,0111,AZ) \vdash (p,111,AAZ) \vdash (q,111,AAZ)
Failed to parse (Missing texvc executable; please see math/README to configure.): \vdash (q,11,AZ) \vdash (q,1,Z)
Failed to parse (Missing texvc executable; please see math/README to configure.): \vdash (r,1,Z)
. The final state is accepting, but the input is not accepted this way as it has not been (completely) read.
Every context-free grammar can be transformed into an equivalent pushdown automaton. The derivation process of the grammar is simulated in a leftmost way. Where the grammar rewrites a nonterminal, the PDA takes the topmost nonterminal from its stack and replaces it by the right-hand part of a grammatical rule (expand). Where the grammar generates a terminal symbol, the PDA reads a symbol from input when it is the topmost symbol on the stack (match). In a sense the stack of the PDA contains the unprocessed data of the grammar, corresponding to a pre-order traversal of a derivation tree.
Technically, given a context-free grammar, the PDA is constructed as follows.
- Failed to parse (Missing texvc executable; please see math/README to configure.): (1,\varepsilon,A,1,\alpha)
for each rule Failed to parse (Missing texvc executable; please see math/README to configure.): A\to\alpha
(expand)
- Failed to parse (Missing texvc executable; please see math/README to configure.): (1,a,a,1,\varepsilon)
for each terminal symbol Failed to parse (Missing texvc executable; please see math/README to configure.): a
(match)
As a result we obtain a single state pushdown automaton, the state here is Failed to parse (Missing texvc executable; please see math/README to configure.): 1 , accepting the context-free language by empty stack. Its initial stack symbol equals the axiom of the context-free grammar.
The converse, finding a grammar for a given PDA, is not that easy. The trick is to code two states of the PDA into the nonterminals of the grammar.
Theorem. For each pushdown automaton Failed to parse (Missing texvc executable; please see math/README to configure.): M
one may construct a context-free grammar Failed to parse (Missing texvc executable; please see math/README to configure.): G
such that Failed to parse (Missing texvc executable; please see math/README to configure.): N(M)=L(G)
.
A GPDA is a PDA which writes an entire string of some known length to the stack or removes an entire string from the stack in one step.
A GPDA is formally defined as a 6-tuple:
- Failed to parse (Missing texvc executable; please see math/README to configure.): M=(Q,\ \Sigma,\ \Gamma,\ \delta, \ q_{0}, \ F)
where Q, Failed to parse (Missing texvc executable; please see math/README to configure.): \Sigma\, , Failed to parse (Missing texvc executable; please see math/README to configure.): \Gamma\, , q0 and F are defined the same way as a PDA.
- Failed to parse (Missing texvc executable; please see math/README to configure.): \,\delta
- Failed to parse (Missing texvc executable; please see math/README to configure.): Q \times \Sigma_{\epsilon} \times \Gamma^{*} \longrightarrow P( Q \times \Gamma^{*} )
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 instead 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 Failed to parse (Missing texvc executable; please see math/README to configure.): \delta (q1, w, x1x2...xm) Failed to parse (Missing texvc executable; please see math/README to configure.): \longrightarrow
(q2, y1y2...yn) be a transition of the GPDA
where Failed to parse (Missing texvc executable; please see math/README to configure.): q_1, q_2 \in Q , Failed to parse (Missing texvc executable; please see math/README to configure.): w \in\Sigma_{\epsilon} , Failed to parse (Missing texvc executable; please see math/README to configure.): x_1, x_2,\ldots,x_m\in\Gamma^{*} , Failed to parse (Missing texvc executable; please see math/README to configure.): m\geq0 , Failed to parse (Missing texvc executable; please see math/README to configure.): y_1, y_2,\ldots,y_n\in\Gamma^{*} , Failed to parse (Missing texvc executable; please see math/README to configure.): n\geq 0 .
Construct the following transitions for the PDA:
-
- Failed to parse (Missing texvc executable; please see math/README to configure.): \delta^{'}
(q1, w, x1) Failed to parse (Missing texvc executable; please see math/README to configure.): \longrightarrow
(p1, Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon
)
-
- Failed to parse (Missing texvc executable; please see math/README to configure.): \delta^{'}
(p1, Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon , x2) Failed to parse (Missing texvc executable; please see math/README to configure.): \longrightarrow
(p2, Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon
)
-
-
-
- Failed to parse (Missing texvc executable; please see math/README to configure.): \vdots
-
- Failed to parse (Missing texvc executable; please see math/README to configure.): \delta^{'}
(pm-1, Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon , xm) Failed to parse (Missing texvc executable; please see math/README to configure.): \longrightarrow
(pm, Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon
)
-
- Failed to parse (Missing texvc executable; please see math/README to configure.): \delta^{'}
(pm, Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon , Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon
) Failed to parse (Missing texvc executable; please see math/README to configure.): \longrightarrow
(pm+1, yn)
-
- Failed to parse (Missing texvc executable; please see math/README to configure.): \delta^{'}
(pm+1, Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon , Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon
) Failed to parse (Missing texvc executable; please see math/README to configure.): \longrightarrow
(pm+2, yn-1)
-
-
-
- Failed to parse (Missing texvc executable; please see math/README to configure.): \vdots
-
- Failed to parse (Missing texvc executable; please see math/README to configure.): \delta^{'}
(pm+n-1, Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon , Failed to parse (Missing texvc executable; please see math/README to configure.): \epsilon
) Failed to parse (Missing texvc executable; please see math/README to configure.): \longrightarrow
(q2, y1)
- Michael Sipser (1997). Introduction to the Theory of Computation. PWS Publishing. ISBN 0-534-94728-X. Section 2.2: Pushdown Automata, pp.101–114.
- Jean-Michel Autebert, Jean Berstel, Luc Boasson, Context-Free Languages and Push-Down Automata, in: G. Rozenberg, A. Salomaa (eds.), Handbook of Formal Languages, Vol. 1, Springer-Verlag, 1997, 111-174.
|
|
|
|
Each category of languages is a proper subset of the category directly above it. - Any automaton and any grammar in each category has an equivalent automaton or grammar in the category directly above it.
|
|