Pushdown automaton

From Wikipedia, the free encyclopedia

In automata theory, a pushdown automaton (PDA) is a finite automaton that can make use of a stack containing data.

Contents

[edit] Operation

Pushdown automata differ from normal finite state machines in two ways:

  1. They can use the top of the stack to decide which transition to take.
  2. 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 a deterministic finite state machine is used, then the result is a deterministic 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. 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, 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.

[edit] Formal Definition

A PDA is formally defined as a 7-tuple:

M=(Q,\  \Sigma,\  \Gamma,\  \delta, \ q_{0},\ Z, \ F) where

  • \, Q is a finite set of states
  • \,\Sigma is a finite set which is called the input alphabet
  • \,\Gamma is a finite set which is called the stack alphabet
  • \,\delta: Q \times  \Sigma_{\epsilon}  \times \Gamma_{\epsilon} \longrightarrow \mathcal{P}(Q \times \Gamma_{\epsilon} ) is the transition function, where \mathcal{P}(S) denotes the power set of S.
  • \,q_{0}\in\, Q is the start state
  • \ Z is the initial stack symbol
  • F\subset Q is the set of accepting states
  • \Gamma_{\epsilon} = \Gamma\cup\{\epsilon\}
  • \Sigma_{\epsilon} = \Sigma\cup\{\epsilon\}

Computation Definition 1

For any PDA, M=(Q,\  \Sigma,\  \Gamma,\  \delta, \ q_{0}, \ F), a computation path is an ordered

(n+1)-tuple,  (q_{0},\, q_{1}, ...., \,q_{n}) , where qi\in Q, n\geq 0, which satisfies the following conditions:

(i) \ \  (q_{i+1}, b_{i+1}) \in \delta (q_{i}, w_{i+1}, a_{i+1}) for i = 0, 1, 2,......, n-1,

where w_{i+1}\in \Sigma_{\epsilon}, \ a_{i+1}, \ b_{i+1}\in \Gamma_{\epsilon}

(ii) \exists\, s_{0},\, s_{1},\,s_{2},\,s_{3},\,\cdots,\,s_{n}\,\in\Gamma^{*} such that

s_{i} = a_{i+1}t_{i},\,s_{i+1} = b_{i+1}t_{i},\, t_{i}\in\Gamma^{*}

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 si = ai + 1ti and si + 1 = bi + 1ti. si is called the stack content immediately before the (i + 1)th transitional move and ai + 1 is the symbol to be removed from the top of the stack. si + 1 is the stack content immediately after the (i + 1)th transitional move and bi + 1 is the symbol to be added to the stack during the (i + 1)th transitional move.

Both ai + 1 and bi + 1 can be ε.

If \,a_{i+1}\neq\epsilon and \,b_{i+1}\neq\epsilon, the PDA reads a symbol from the stack and replace it with another one.

If \,a_{i+1}\neq\epsilon and \,b_{i+1} = \epsilon, the PDA reads a symbol from the stack and remove it without replacement.

If \,a_{i+1} = \epsilon and \,b_{i+1}\neq\epsilon, the PDA simply adds a symbol to the stack.

If \,a_{i+1} = \epsilon and \,b_{i+1} = \epsilon, 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 \in\,\Sigma, m\geq0, M accepts w if \exists a computation path (q_{0},\, q_{1}, ...., \,q_{n}) and a finite sequence r0, r1, r2,...rm \in Q, m\leqn, such that

(i) For each i = 0, 1, 2,...m, ri is on the computation path. That is,

\exists f(i) where i\leqf(i)\leqn such that ri = qf(i)

(ii) (qf(i)+1, bf(i)+1) \in δ(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) \in δ(qj, ε, aj+1) if qj \notin {r0, r1,...rm}

where aj+1 and bj+1 are defined as in Computation Definition 1.

(iv) rm = qn and rm \in 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, \epsilon,\,\epsilon) = {(q1, $)} where $ is the special symbol.

[edit] Example

The following is the formal description of the PDA which recognizes the language \{0^n1^n | n \ge 0 \}:

M=(Q,\  \Sigma,\  \Gamma,\  \delta, \ q_{1}, \ F)

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.

[edit] Understanding the computation process

The following illustrates how the above PDA computes on different input strings.

(a) Input string = 0011

(i) write δ(q1, ε, ε) \rightarrow (q2, $) to represent (q2, $) \in δ(q1, ε, ε)
s0 = ε, s1 = $, t = ε, a = ε, b = $
set r0 = q2
(ii) δ(r0, 0, ε) = δ(q2, 0, ε) \rightarrow (q2, 0)
s1 = $, a = ε, t = $, b = 0, s2 = 0$
set r1 = q2
(iii) δ(r1, 0, ε) = δ(q2, 0, ε) \rightarrow (q2, 0)
s2 = 0$, a = ε, t = 0$, b = 0, s3 = 00$
set r2 = q2
(iv) δ(r2, 1, 0) = δ(q2, 1, 0) \rightarrow (q3, ε)
s3 = 00$, a = 0, t = 0$, b = ε, s4 = 0$
set r3 = q3
(v) δ(r3, 1, 0) = δ(q3, 1, 0) \rightarrow (q3, ε)
s4 = 0$, a = 0, t = $, b = ε, s5 = $
(vi) δ(q3, ε, $) \rightarrow (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, ε, ε) \rightarrow (q1, ε)
Since q1 is an accept state, ε is accepted.

[edit] 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 M=(Q,\  \Sigma,\  \Gamma,\  \delta, \ q_{0}, \ F)

where Q, \Sigma\,, \Gamma\,, q0 and F are defined the same way as a PDA.
\,\delta: 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 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) \longrightarrow (q2, y1y2...yn) be a transition of the GPDA

where q1, q2 \in Q, w \in\Sigma_{\epsilon}\,, x1x2...xm \in\Gamma^{*}, m\geq0, y1y2...yn \in\Gamma^{*}, n\geq0.

Construct the following transitions for the PDA:

δ'(q1, w, x1) \longrightarrow (p1, ε)
δ'(p1, ε, x2) \longrightarrow (p2, ε)
\vdots
δ'(pm-1, ε, xm) \longrightarrow (pm, ε)
δ'(pm, ε, ε ) \longrightarrow (pm+1, yn)
δ'(pm+1, ε, ε ) \longrightarrow (pm+2, yn-1)
\vdots
δ'(pm+n-1, ε, ε ) \longrightarrow (q2, y1)

[edit] See also

[edit] External links

[edit] References

Automata theory: formal languages and formal grammars
Chomsky
hierarchy
Grammars Languages Minimal
automaton
Type-0 Unrestricted Recursively enumerable Turing machine
n/a (no common name) Recursive Decider
Type-1 Context-sensitive Context-sensitive Linear-bounded
n/a Indexed Indexed Nested stack
n/a Tree-adjoining etc. (Mildly context-sensitive) Embedded pushdown
Type-2 Context-free Context-free Nondeterministic pushdown
n/a Deterministic context-free Deterministic context-free Deterministic pushdown
Type-3 Regular Regular Finite
n/a Star-free Counter-Free
Each category of languages or grammars is a proper subset of the category directly above it,
and any automaton in each category has an equivalent automaton in the category directly above it.