Pushdown Automata Graphical Notation



In context-free grammars, we have understood about a machine called Pushdown Automaton. A Pushdown Automaton is a powerful machine than a Finite Automaton which accepts context free grammars.

With Pushdown Automata, we can handle more complex language patterns. In this chapter, we will have a closer look at the concept of Pushdown Automata along with their graphical notation to have a better understanding of PDA in action.

Components of a Pushdown Automata

A PDA has several parts working together:

  • An input tape − This holds the string we want to check.
  • A reading head − It reads symbols from the input tape.
  • A finite control − This is like the brain of the PDA.
  • A stack − This is a special storage area that helps the PDA remember things.

Mathematical Representation of Pushdown Automata

We can describe a PDA using a set of seven things. We call this a 7-tuple: (Q, Σ, Γ, δ, q0, z0, F)

  • Q − All the states the PDA can be in
  • Σ − The input alphabet (symbols it can read)
  • Γ − The stack alphabet (symbols it can put on the stack)
  • δ − Rules for moving between states
  • q0 − The starting state
  • z0 − The symbol at the bottom of the stack
  • F − The final or accepting states

Graphical Notation for Pushdown Automata

Now, let's talk about how we can draw a Pushdown Automata. It's often easier to understand when we can see it!

Basic Elements

  • States − We draw these as circles.
  • Start State − This is a circle with an arrow pointing to it.
  • Final State − We use a double circle for this.
  • Transitions − These are arrows between states.

Transition Labels

The labels on the arrows are very important. They tell us three things:

  • The input symbol being read
  • The symbol at the top of the stack before the move
  • What happens to the stack after the move

We write these as: input symbol, stack top / new stack top

Let us see the idea of drawing PDA with some examples.

Example 1: PDA for Equal 'a's and 'b's

We want to build a PDA for the language L = (a, b)* where the number of 'a's equals the number of 'b's.

PDA Design

Here's how our PDA will work:

  • Start with an empty stack (just z0 at the bottom).
  • When we see an 'a', push z1 onto the stack.
  • When we see a 'b', push z2 onto the stack.
  • If we see 'b' after 'a', pop z1 from the stack.
  • If we see 'a' after 'b', pop z2 from the stack.
  • If we see 'a' after 'a', push another z1.
  • If we see 'b' after 'b', push another z2.
PDA Design

How to Read the Transitions?

  • (a, z0/z1z0): Read 'a', replace z0 with z1z0
  • (b, z0/z2z0): Read 'b', replace z0 with z2z0
  • (a, z1/z1z1): Read 'a', push another z1
  • (b, z2/z2z2): Read 'b', push another z2
  • (b, z1/λ): Read 'b', pop z1 (λ means remove)
  • (a, z2/λ): Read 'a', pop z2
  • (λ, z0/z0): Empty input, z0 on stack, go to final state

Example 2: Pushdown Automata for WCWR

Let's look at another example. This time, we'll create a PDA for the language L = {WCWR}, where W is any string of 'a's and 'b's, and WR is W reversed.

Pushdown Automata Design

Here's how our PDA will work:

  • Start with z0 at the bottom of the stack.
  • For the first part (W), push z1 for 'a' and z2 for 'b'.
  • When we see 'C', don't change the stack, just move to the next state.
  • For the second part (WR), pop z1 for 'a' and z2 for 'b'.
  • If we end with just z0 on the stack, accept the string.
Pushdown Automata Design

How to Read the Transitions?

  • (a, z0/z1z0): Start of W, read 'a', push z1
  • (b, z0/z2z0): Start of W, read 'b', push z2
  • (a, z1/z1z1), (b, z2/z2z2): Continue W, push corresponding symbol
  • (b, z1/z2z1), (a, z2/z1z2): Handle alternating 'a' and 'b' in W
  • (C, z1/z1), (C, z2/z2): Read 'C', don't change stack
  • (a, z1/λ), (b, z2/λ): For WR, pop matching symbol
  • (λ, z0/z0): Empty input, z0 on stack, go to final state

Conclusion

Graphical notation for PDAs helps us visualize how these machines work. It shows us the states, the transitions between them, and how the stack changes. This makes it easier to understand and design PDAs for different languages.

In this chapter, we explained the graphical notations and presented two examples with steps and suitable state transition diagrams for a clear understanding.

Advertisements