Non-deterministic Pushdown Automata



We know that pushdown automata are a powerful model of computation that extends finite automata by adding a stack. Non-deterministic finite automata are powerful than deterministic finite automata. Read this chapter to get a clear understanding of the concept.

What is Non-Determinism?

In some cases, a machine must face a choice to select the next state; it can either move to one state or another. In a non-deterministic pushdown automata (NPDA), this machine has the freedom to explore all possible paths. It can simultaneously follow multiple paths based on the input and the stack's content. This means that the machine can accept a string if even one of its possible paths leads to an accepting state.

To illustrate this, think of a finite automaton where an input symbol leads to multiple transitions. In a non-deterministic finite automaton, the machine accepts the input if at least one of the transitions leads to an accepting state.

Similarly, in an NPDA, even if one path leads to an accepting state, the entire NPDA is considered to have accepted the input string.

Use of Stacks in Pushdown Automata

In DPDA and NPDA also the stacks are used. The stack in a PDA is an important component in PDA. It acts like a memory, allowing the machine to remember past input symbols. It can push symbols onto the stack, pop symbols off the stack, or read the symbol on top of the stack.

This ability to manipulate the stack empowers the PDA to recognize languages that require keeping track of the order or the number of symbols encountered in the input string.

Defining a Non-Deterministic Pushdown Automata (NPDA)

Formally, an NPDA is defined as a tuple −

  • Q − A finite set of states
  • − A finite set of input symbols
  • − A finite set of stack symbols
  • − A transition function: $\mathrm{\mathrm{\delta \::\: Q\: \times\: \Sigma\: \times\: \Gamma\: \rightarrow\: 2^{(Q \times \Gamma^* )}}}$
  • q0 − The initial state
  • Z0 − The initial stack symbol
  • F − A set of final states

The transition function δ takes a state q, an input symbol a, and a stack symbol X, and returns a set of possible transitions (q', γ), where q' is the next state and γ is a string of stack symbols to be pushed onto the stack.

How Does an NPDA Work?

The following steps highlight how a non-deterministic pushdown automaton works

  • Initialization − The NPDA starts in the initial state q0 with the stack containing only the initial stack symbol Z0.
  • Reading input − The NPDA reads the input symbol one at a time.
  • Transition − For each input symbol a and the current stack top X, the transition function δ is consulted. It provides a set of possible transitions. The NPDA can choose any of these transitions. This choice is non-deterministic.
  • Stack manipulation − The NPDA modifies the stack according to the chosen transition. It can push symbols onto the stack, pop symbols from the stack, or leave the stack unchanged.
  • State change − The NPDA moves to the new state q' specified by the chosen transition.
  • Acceptance − The NPDA accepts the input string if it reaches a final state after reading the entire input string.

Examples of Non-deterministic Pushdown Automata

Here's an example language that can be recognized by a NPDA but not by a finite automaton −

$\mathrm{L = \{ a^n b^n \mid n \geq 0 \}}$ : This language consists of strings with an equal number of 'a's and 'b's.

NDFA can recognize this using −

  • For each 'a' in the input, the NPDA pushes an 'a' onto the stack.
  • When a 'b' is encountered, the NPDA pops an 'a' from the stack.
  • If the NPDA reaches the end of the input string and the stack is empty, the string is accepted.

Conclusion

Non-deterministic pushdown automata are complex than the deterministic pushdown automata. In this chapter, we explained the concept of NPDA with examples where NPDA can be used.

Advertisements