Pushdown automaton
   HOME

TheInfoList



OR:

In the
theory of computation In theoretical computer science and mathematics, the theory of computation is the branch that deals with what problems can be solved on a model of computation, using an algorithm, how algorithmic efficiency, efficiently they can be solved or t ...
, a branch of
theoretical computer science computer science (TCS) is a subset of general computer science and mathematics that focuses on mathematical aspects of computer science such as the theory of computation, lambda calculus, and type theory. It is difficult to circumscribe the ...
, a pushdown automaton (PDA) is a type of
automaton An automaton (; plural: automata or automatons) is a relatively self-operating machine, or control mechanism designed to automatically follow a sequence of operations, or respond to predetermined instructions.Automaton – Definition and More ...
that employs a
stack Stack may refer to: Places * Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group * Blue Stack Mountains, in Co. Donegal, Ireland People * Stack (surname) (including a list of people ...
. Pushdown automata are used in theories about what can be computed by machines. They are more capable than
finite-state machine A finite-state machine (FSM) or finite-state automaton (FSA, plural: ''automata''), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number o ...
s but less capable than
Turing machine A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer alg ...
s (see
below Below may refer to: *Earth * Ground (disambiguation) *Soil *Floor * Bottom (disambiguation) *Less than *Temperatures below freezing *Hell or underworld People with the surname *Ernst von Below (1863–1955), German World War I general *Fred Below ...
). Deterministic pushdown automata can recognize all deterministic context-free languages while nondeterministic ones can recognize all
context-free language In formal language theory, a context-free language (CFL) is a language generated by a context-free grammar (CFG). Context-free languages have many applications in programming languages, in particular, most arithmetic expressions are generated by ...
s, with the former often used in
parser Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from Lat ...
design. The term "pushdown" refers to the fact that the
stack Stack may refer to: Places * Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group * Blue Stack Mountains, in Co. Donegal, Ireland People * Stack (surname) (including a list of people ...
can be regarded as being "pushed down" like a tray dispenser at a cafeteria, since the operations never work on elements other than the top element. A stack automaton, by contrast, does allow access to and operations on deeper elements. Stack automata can recognize a strictly larger set of languages than pushdown automata. A nested stack automaton allows full access, and also allows stacked values to be entire sub-stacks rather than just single finite symbols.


Informal description

A
finite-state machine A finite-state machine (FSM) or finite-state automaton (FSA, plural: ''automata''), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number o ...
just looks at the input signal and the current state: it has no stack to work with. It chooses a new state, the result of following the transition. A pushdown automaton (PDA) differs from a finite state machine in two ways: # It can use the top of the stack to decide which transition to take. # It can manipulate the stack as part of performing a transition. A pushdown automaton reads a given input string from left to right. In each step, it chooses a transition by indexing a table by input symbol, current state, and the symbol at the top of the stack. A pushdown automaton can also manipulate the stack, as part of performing a 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. Put together: Given an input symbol, current state, and stack symbol, the automaton can follow a transition to another state, and optionally manipulate (push or pop) the stack. If, in every situation, at most one such transition action is possible, then the automaton is called a deterministic pushdown automaton (DPDA). In general, if several actions are possible, then the automaton is called a general, or nondeterministic, PDA. A given input string may drive a nondeterministic pushdown automaton to one of several configuration sequences; if one of them leads to an accepting configuration after reading the complete input string, the latter is said to belong to the ''language accepted by the automaton''.


Formal definition

We use standard formal language notation: \Gamma^ denotes the set of finite-length strings over alphabet \Gamma and \varepsilon denotes the
empty string In formal language theory, the empty string, or empty word, is the unique string of length zero. Formal theory Formally, a string is a finite, ordered sequence of characters such as letters, digits or spaces. The empty string is the special c ...
. A PDA is formally defined as a 7-tuple: M=(Q, \Sigma, \Gamma, \delta, q_, 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 is a finite subset of Q \times (\Sigma \cup \) \times \Gamma \times Q \times \Gamma^*, the ''transition relation'' *q_ \in Q is the ''start state'' *Z \in \Gamma is the ''initial stack symbol'' *F \subseteq Q is the set of ''accepting states'' An element (p,a,A,q,\alpha) \in \delta is a transition of M. It has the intended meaning that M, in state p \in Q, on the input a \in \Sigma \cup \ and with A \in \Gamma as topmost stack symbol, may read a, change the state to q, pop A, replacing it by pushing \alpha \in \Gamma^*. The (\Sigma \cup \) 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 * \delta is the ''transition function'', mapping Q \times (\Sigma \cup \) \times \Gamma into finite subsets of Q \times \Gamma^* Here \delta(p, a, A) contains all possible actions in state p with A on the stack, while reading a on the input. One writes for example \delta(p, a, A) = \ precisely when (q, BA) \in \, (q, BA) \in \delta(p, a, A), because ((p, a, A), \) \in \delta. Note that ''finite'' in this definition is essential. ''Computations'' In order to formalize the semantics of the pushdown automaton a description of the current situation is introduced. Any 3-tuple (p,w,\beta) \in Q \times \Sigma^* \times \Gamma^* is called an instantaneous description (ID) of 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 \delta defines the step-relation \vdash_ of M on instantaneous descriptions. For instruction (p,a,A,q,\alpha) \in \delta there exists a step (p,ax,A\gamma) \vdash_ (q,x,\alpha\gamma), for every x\in\Sigma^* and every \gamma\in \Gamma^*. In general pushdown automata are nondeterministic meaning that in a given instantaneous description (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 q_ with the initial stack symbol Z on the stack, and a string w on the input tape, thus with initial description (q_,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 F), or it accepts by empty stack (\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 # L(M) = \ (final state) # N(M) = \ (empty stack) Here \vdash_M^* represents the reflexive and
transitive closure In mathematics, the transitive closure of a binary relation on a set is the smallest relation on that contains and is transitive. For finite sets, "smallest" can be taken in its usual sense, of having the fewest related pairs; for infinite ...
of the step relation \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 M one may construct a pushdown automaton M' such that L(M)=N(M'), and vice versa, for each pushdown automaton M one may construct a pushdown automaton M' such that N(M)=L(M')


Example

The following is the formal description of the PDA which recognizes the language \ by final state: M=(Q,\ \Sigma,\ \Gamma,\ \delta, \ q_,\ Z, \ F), where *states: Q = \ *input alphabet: \Sigma = \ *stack alphabet: \Gamma = \ *start state: q_ = p *start stack symbol: *accepting states: F = \ The transition relation \delta consists of the following six instructions: :(p,0,Z,p,AZ), :(p,0,A,p,AA), :(p,\epsilon,Z,q,Z), :(p,\epsilon,A,q,A), :(q,1,A,q,\epsilon), and :(q,\epsilon,Z,r,Z). In words, the first two instructions say that in state any time the symbol is read, one is pushed onto the stack. Pushing symbol on top of another is formalized as replacing top by (and similarly for pushing symbol on top of a ). The third and fourth instructions say that, at any moment the automaton may move from state to state . The fifth instruction says that in state , for each symbol read, one is popped. Finally, the sixth instruction says that the machine may move from state to accepting state only when the stack consists of a single . There seems to be no generally used representation for PDA. Here we have depicted the instruction (p,a,A,q,\alpha) by an edge from state to state labelled by a; A/\alpha (read ; replace by \alpha).


Understanding the computation process

The following illustrates how the above PDA computes on different input strings. The subscript from the step symbol \vdash is here omitted.


PDA and context-free languages

Every
context-free grammar In formal language theory, a context-free grammar (CFG) is a formal grammar whose production rules are of the form :A\ \to\ \alpha with A a ''single'' nonterminal symbol, and \alpha a string of terminals and/or nonterminals (\alpha can be em ...
can be transformed into an equivalent nondeterministic 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 has a single state, 1, and its transition relation is constructed as follows. # (1,\varepsilon,A,1,\alpha) for each rule A\to\alpha (''expand'') # (1,a,a,1,\varepsilon) for each terminal symbol a (''match'') The PDA accepts by empty stack. Its initial stack symbol is the grammar's start symbol. For a context-free grammar in
Greibach normal form In formal language theory, a context-free grammar is in Greibach normal form (GNF) if the right-hand sides of all production rules start with a terminal symbol, optionally followed by some variables. A non-strict form allows one exception to this f ...
, defining (1,γ) ∈ δ(1,''a'',''A'') for each grammar rule ''A'' → ''a''γ also yields an equivalent nondeterministic pushdown automaton. 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 M one may construct a context-free grammar G such that The language of strings accepted by a deterministic pushdown automaton (DPDA) is called a deterministic context-free language. Not all context-free languages are deterministic. As a consequence, the DPDA is a strictly weaker variant of the PDA. Even for
regular language In theoretical computer science and formal language theory, a regular language (also called a rational language) is a formal language that can be defined by a regular expression, in the strict sense in theoretical computer science (as opposed to ...
s, there is a size explosion problem: for any recursive function f and for arbitrarily large integers n, there is a PDA of size n describing a regular language whose smallest DPDA has at least f(n) states. For many non-regular PDAs, any equivalent DPDA would require an unbounded number of states. A finite automaton with access to two stacks is a more powerful device, equivalent in power to a
Turing machine A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer alg ...
. A linear bounded automaton is a device which is more powerful than a pushdown automaton but less so than a Turing machine.


PDA and Turing machines

A pushdown automaton is computationally equivalent to a 'restricted' Turing Machine (TM) with two tapes which is restricted in the following manner- On the first tape, the TM can only read the input and move from left to right (it cannot make changes). On the second tape, it can only 'push' and 'pop' data. Or equivalently, it can read, write and move left and right with the restriction that the only action it can perform at each step is to either delete the left-most character in the string (pop) or add an extra character left to the left-most character in the string (push). That a PDA is weaker than a TM can be brought down to the fact that the procedure 'pop' deletes some data. In order to make a PDA as strong as a TM, we need to save somewhere the data lost through 'pop'. We can achieve this by introducing a second stack. In the TM model of PDA of last paragraph, this is equivalent to a TM with 3 tapes, where the first tape is the read-only input tape, and the 2nd and the 3rd tape are the 'push and pop' (stack) tapes. In order for such a PDA to simulate any given TM, we give the input of the PDA to the first tape, while keeping both the stacks empty. It then goes on to push all the input from the input tape to the first stack. When the entire input is transferred to the 1st stack, now we proceed like a normal TM, where moving right on the tape is the same as popping a symbol from the 1st stack and pushing a (possibly updated) symbol into the second stack, and moving left corresponds to popping a symbol from the 2nd stack and pushing (a possibly updated) symbol into the first stack. We hence have a PDA with 2 stacks that can simulate any TM.


Generalized pushdown automaton (GPDA)

A GPDA is a PDA that 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: :M=(Q,\ \Sigma,\ \Gamma,\ \delta, \ q_, \ F) where Q, \Sigma\,, \Gamma\,, q_0, and are defined the same way as a PDA. :\,\delta: Q \times \Sigma_ \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 a_'s and b_'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 \delta (q_, w, x_ x_ \cdot x_) \longrightarrow (q_, y_ y_...y_) be a transition of the GPDA where q_1, q_2 \in Q, w \in\Sigma_, x_1, x_2,\ldots,x_m\in\Gamma^, m\geq 0, y_1, y_2,\ldots, y_n\in\Gamma^, n\geq 0. Construct the following transitions for the PDA: :\begin \delta'(q_, w, x_) &\longrightarrow& (p_, \epsilon) \\ \delta'(p_, \epsilon, x_) &\longrightarrow& (p_, \epsilon) \\ &\vdots& \\ \delta'(p_, \epsilon, x_) &\longrightarrow& (p_, \epsilon) \\ \delta'(p_, \epsilon, \epsilon ) &\longrightarrow& (p_, y_) \\ \delta'(p_, \epsilon, \epsilon ) &\longrightarrow& (p_, y_) \\ &\vdots& \\ \delta'(p_, \epsilon, \epsilon ) &\longrightarrow& (q_, y_). \end


Stack automaton

As a generalization of pushdown automata, Ginsburg, Greibach, and Harrison (1967) investigated stack automata, which may additionally step left or right in the input string (surrounded by special endmarker symbols to prevent slipping out), and step up or down in the stack in read-only mode. A stack automaton is called ''nonerasing'' if it never pops from the stack. The class of languages accepted by nondeterministic, nonerasing stack automata is ''
NSPACE In computational complexity theory, non-deterministic space or NSPACE is the computational resource describing the memory space for a non-deterministic Turing machine. It is the non-deterministic counterpart of DSPACE. Complexity classes The mea ...
''(''n''2), which is a superset of the context-sensitive languages. The class of languages accepted by deterministic, nonerasing stack automata is ''
DSPACE DSpace is an open source repository software package typically used for creating open access repositories for scholarly and/or published digital content. While DSpace shares some feature overlap with content management systems and document manag ...
''(''n''⋅log(''n'')).


Alternating pushdown automata

An alternating pushdown automaton (APDA) is a pushdown automaton with a state set * Q=Q_\exists \cup Q_\forall where Q_\exists \cap Q_\forall=\emptyset. States in Q_\exists and Q_\forall are called ''existential'' resp. ''universal''. In an existential state an APDA nondeterministically chooses the next state and accepts if ''at least one'' of the resulting computations accepts. In a universal state APDA moves to all next states and accepts if ''all'' the resulting computations accept. The model was introduced by
Chandra Chandra ( sa, चन्द्र, Candra, shining' or 'moon), also known as Soma ( sa, सोम), is the Hindu god of the Moon, and is associated with the night, plants and vegetation. He is one of the Navagraha (nine planets of Hinduism) an ...
, Kozen and Stockmeyer. Ladner,
Lipton Lipton is a British brand of tea, owned by Ekaterra. Lipton was also a supermarket chain in the United Kingdom, later sold to Argyll Foods, after which the company sold only tea. The company is named after its founder, Sir Thomas Lipton, wh ...
and Stockmeyer proved that this model is equivalent to
EXPTIME In computational complexity theory, the complexity class EXPTIME (sometimes called EXP or DEXPTIME) is the set of all decision problems that are solvable by a deterministic Turing machine in exponential time, i.e., in O(2''p''(''n'')) time, wh ...
i.e. a language is accepted by some APDA
if, and only if In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false. The connective is bicon ...
, it can be decided by an exponential-time algorithm. Aizikowitz and Kaminski introduced ''synchronized alternating pushdown automata'' (SAPDA) that are equivalent to conjunctive grammars in the same way as nondeterministic PDA are equivalent to context-free grammars.


See also

*
Stack machine In computer science, computer engineering and programming language implementations, a stack machine is a computer processor or a virtual machine in which the primary interaction is moving short-lived temporary values to and from a push down ...
*
Context-free grammar In formal language theory, a context-free grammar (CFG) is a formal grammar whose production rules are of the form :A\ \to\ \alpha with A a ''single'' nonterminal symbol, and \alpha a string of terminals and/or nonterminals (\alpha can be em ...
*
Finite automaton A finite-state machine (FSM) or finite-state automaton (FSA, plural: ''automata''), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number o ...
* Counter automaton * Queue automaton


Notes


References

* 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.


External links


JFLAP
simulator for several types of automata including nondeterministic pushdown automata
CoAn
another simulator for several machine types including nondeterministic pushdown automata (C++, Windows, Linux, MacOS) {{Formal languages and grammars Automata (computation) Models of computation