Deterministic Pushdown Automata



Context-free grammars can be detected using Pushdown Automata. Suppose there is a machine that not only processes the input symbols but also has a special memory called a "stack" that allows the machine to store information and recall it later. This feature makes the machine more powerful than a simple finite automaton. We would call such machines as Pushdown Automata (PDA).

In this chapter, we will explain the deterministic version of pushdown automata with details.

Properties of Pushdown Automata

A Pushdown Automata operates by reading an input string one symbol at a time. It can then perform one of several actions −

  • Move to a new state − Transitioning to a different internal configuration based on the current state and the input symbol.
  • Push a symbol onto the stack − Storing a symbol in the memory for later retrieval.
  • Pop a symbol from the stack − Retrieving a symbol from the memory and discarding it.

Deterministic Pushdown Automata

A Pushdown Automata (PDA) can be classified as deterministic if all derivations in the design have to give only a single move. This means that for each combination of state and input symbol, there is only one possible action that the PDA can take.

To understand the difference between deterministic and non-deterministic PDAs, consider the example of finite automata −

Deterministic Finite Automata (DFA)

If we take an input symbol and apply that input symbol on a state, we have to move only to one single move. Single move has to be happened. If we are moving to two different states, that is not deterministic finite automata.

In a DFA, for every combination of state and input symbol, there is only one possible next state. If there are multiple possibilities, the DFA is considered non-deterministic.

Deterministic Pushdown Automata (DPDA)

A DPDA is similar, but it also considers the top symbol on the stack when making a transition. For each combination of state, input symbol, and stack symbol, there is only one possible action.

Properties of Deterministic Pushdown Automata

DPDAs have several important properties that distinguish them from non-deterministic PDAs −

  • Uniqueness of Transitions − Every transition is unique, meaning there are no duplicate actions for the same combination of state, input symbol, and stack symbol.
  • Predictability − The behaviour of a DPDA is completely predictable, as there is only one possible action for every situation.
  • Ease of Implementation − DPDAs are easier to implement than non-deterministic PDAs, as there is no need to handle multiple possible transitions.

Examples of Deterministic Pushdown Automata

Here are two examples of languages that can be recognized by DPDAs −

L = anb2n, n > 0: This language consists of strings where the number of 'b's is twice the number of 'a's, and the number of 'a's is greater than 0.

So how to solve this using PDA?

  • For every 'a', push it onto the stack.
  • For every 'b', pop two 'a's from the stack.
  • If the stack is empty at the end of the input, the string is accepted.

L = wcwR: This language takes any string made up of 0s or 1s (represented by 'w'), adds a 'c' in the middle, followed by the reverse of the first string ('wR').

So, how to solve this using PDA?

  • For every '0' or '1', push it onto the stack.
  • When 'c' is encountered, continue pushing symbols onto the stack until the end of the input is reached.
  • For every '1' or '0' encountered after 'c', pop the corresponding symbol from the stack.
  • If the stack is empty at the end of the input, the string is accepted.

Applications of Deterministic Pushdown Automata

DPDAs have applications in various areas of computer science, including −

  • Formal Language Theory − DPDAs are used to define and recognize a class of languages known as deterministic context-free languages.
  • Compilers and Interpreters − DPDAs are used in parsing, the process of converting source code into a form that can be understood by a computer.
  • Natural Language Processing − DPDAs are used in analyzing and understanding human language.

Conclusion

Deterministic Pushdown Automata are used for contextfree grammars, which are not equivalent to non-deterministic finite automata. It is a powerful tool for recognizing patterns in strings. In this article we have seen the idea of DPDA in detail with definitions and examples with two distinct problems.

Advertisements