Header Ads Widget

Pushdown Automata

Pushdown Automata(PDA)

  • Pushdown automata is a way to implement a CFG in the same way we design DFA for a regular grammar. A DFA can remember a finite amount of information, but a PDA can remember an infinite amount of information.
  • Pushdown automata is simply an NFA augmented with an "external stack memory". The addition of stack is used to provide a last-in-first-out memory management capability to Pushdown automata. Pushdown automata can store an unbounded amount of information on the stack. It can access a limited amount of information on the stack. A PDA can push an element onto the top of the stack and pop off an element from the top of the stack. To read an element into the stack, the top elements must be popped off and are lost.
  • A PDA is more powerful than FA. Any language which can be acceptable by FA can also be acceptable by PDA. PDA also accepts a class of language which even cannot be accepted by FA. Thus PDA is much more superior to FA.
Pushdown Automata

PDA Components:

Input tape: The input tape is divided in many cells or symbols. The input head is read-only and may only move from left to right, one symbol at a time.

Finite control: The finite control has some pointer which points the current symbol which is to be read.

Stack: The stack is a structure in which we can push and remove the items from one end only. It has an infinite size. In PDA, the stack is used to store the items temporarily.

Formal definition of PDA:

The PDA can be defined as a collection of 7 components:

Q: the finite set of states

∑: the input set

Γ: a stack symbol which can be pushed and popped from the stack

q0: the initial state

Z: a start symbol which is in Γ.

F: a set of final states

δ: mapping function which is used for moving from current state to next state.

Instantaneous Description (ID)

ID is an informal notation of how a PDA computes an input string and make a decision that string is accepted or rejected.

An instantaneous description is a triple (q, w, α) where:

q describes the current state.

w describes the remaining input.

α describes the stack contents, top at the left.

Turnstile Notation:

⊢ sign describes the turnstile notation and represents one move.

⊢* sign describes a sequence of moves.


Example 1:

Design a PDA for accepting a language {anb2n | n>=1}.

Solution: In this language, n number of a's should be followed by 2n number of b's. Hence, we will apply a very simple logic, and that is if we read single 'a', we will push two a's onto the stack. As soon as we read 'b' then for every single 'b' only one 'a' should get popped from the stack.

The ID can be constructed as follows:

δ(q0, a, Z) = (q0, aaZ)  

δ(q0, a, a) = (q0, aaa)  

Now when we read b, we will change the state from q0 to q1 and start popping corresponding 'a'. Hence,

δ(q0, b, a) = (q1, Îµ)  

Thus this process of popping 'b' will be repeated unless all the symbols are read. Note that popping action occurs in state q1 only.

δ(q1, b, a) = (q1, Îµ)  

After reading all b's, all the corresponding a's should get popped. Hence when we read ε as input symbol then there should be nothing in the stack. Hence the move will be:

δ(q1, Îµ, Z) = (q2, Îµ)  

Where

PDA = ({q0, q1, q2}, {a, b}, {a, Z}, δ, q0, Z, {q2})

We can summarize the ID as:

δ(q0, a, Z) = (q0, aaZ)  

δ(q0, a, a) = (q0, aaa)  

δ(q0, b, a) = (q1, Îµ)  

δ(q1, b, a) = (q1, Îµ)  

δ(q1, Îµ, Z) = (q2, Îµ)  

Now we will simulate this PDA for the input string "aaabbbbbb".

δ(q0, aaabbbbbb, Z)  Î´(q0, aabbbbbb, aaZ)  

                     Î´(q0, abbbbbb, aaaaZ)  

                     Î´(q0, bbbbbb, aaaaaaZ)  

                     Î´(q1, bbbbb, aaaaaZ)  

                     Î´(q1, bbbb, aaaaZ)  

                     Î´(q1, bbb, aaaZ)  

                     Î´(q1, bb, aaZ)  

                     Î´(q1, b, aZ)  

                     Î´(q1, Îµ, Z)  

                     Î´(q2, Îµ)        

                      ACCEPT 

Example 2:

Design a PDA for accepting a language {0n1m0n | m, n>=1}.

Solution: In this PDA, n number of 0's are followed by any number of 1's followed n number of 0's. Hence the logic for design of such PDA will be as follows:

Push all 0's onto the stack on encountering first 0's. Then if we read 1, just do nothing. Then read 0, and on each read of 0, pop one 0 from the stack.

For instance:

Pushdown Automata

This scenario can be written in the ID form as:

δ(q0, 0, Z) = Î´(q0, 0Z)  

δ(q0, 00) = Î´(q0, 00)  

δ(q0, 10) = Î´(q1, 0)  

δ(q0, 10) = Î´(q1, 0)  

δ(q1, 00) = Î´(q1, Îµ)  

δ(q0, Îµ, Z) = Î´(q2, Z)      (ACCEPT state)  

Now we will simulate this PDA for the input string "0011100".

δ(q0, 0011100, Z)  Î´(q0, 011100, 0Z)  

                   Î´(q0, 11100, 00Z)  

                   Î´(q0, 1100, 00Z)  

                   Î´(q1, 100, 00Z)  

                   Î´(q1, 00, 00Z)  

                   Î´(q1, 0, 0Z)  

                   Î´(q1, Îµ, Z)  

                   Î´(q2, Z)  


Post a Comment

0 Comments