6

Pushdown Automata

6.1 BASICS OF PUSHDOWN AUTOMATA

Q. What is Pushdown Automata? Describe the Block diagram or Mechanical diagram of Pushdown Automata. Why is it so named 'Pushdown'?

Ans. Pushdown Automata (PDA) is the machine format of context free language (CFL). It is one type of finite state machine (FSM) which is used to accept only CFLs.

Mechanical diagram:

images

(a) Input Tape: Input tape contains the input symbols. The tape is divided into a number of squares. Each square contains a single input character. The string placed in the input tape is traversed from left to right. Two end sides of the input string contain infinite number of blank symbol.

(b) Reading Head: The head scans each square in the input tape and reads the input from the tape. The head moves from left to right. The input scanned by the reading head is sent to the finite control of the PDA.

(c) Finite Control: Finite control can be considered as a control unit of a PDA. An automaton always resides in a state. The reading head scans the input from the input tape and sends it to finite control. One two way head is also added with the finite control to the stack top. Depending on the input taken from input tape and input from stack top, finite control decides in which state the PDA will move and which stack symbol it will push to the stack or pop from the stack or do nothing on the stack.

(d) Stack: A stack is a temporary storage of stack symbols. Every move of PDA indicates one of the followings to the stack

(i) One stack symbol may be added to the stack [Push]

(ii) One stack symbol may be deleted from the top of the stack [Pop]

Stack is the component of PDA which differentiates it from finite automata. In stack there is always a symbol z0 which denotes the bottom of the stack.

Why Pushdown: Push is an operation related to stack. By this operation one symbol is added to the stack top.

In finite automata, states act as a form of primitive memory. States memorize the non-terminals encountered at the time of derivation of a string. Hence only state is suitable for traversing a regular expression as in the case of finite automata. Now lets consider a case of L = {anbn where n≥ 1}. It is not a regular expression but a CFL. Here n is any number. In the string there is equal number of 'a' and 'b'. In the string 'a' will occur before 'b'. In case of traversing anbn, the machine has to remember n number of a's to traverse equal number of 'b'. The 'n' is any number. Therefore, to memorize number of a's in the string the machine requires infinite number of states, i.e. the machine will not be a finite state machine.

To remove this difficulty we need to add an auxiliary memory in the form of stack. For each occurrence of 'a' in the string L one symbol is pushed into the stack. For each occurrence of b (After finishing 'a') one symbol will be popped from the stack. By this process the matching of 'a' and 'b' will be done.

By adding a stack to a finite automata, PDA is generated.

Q. Define PDA in mathematical notation.

Ans. A PDA consists of 7-touple images where

Q denotes Finite set of states.

images denotes Finite set of input symbols

images denotes Finite set of pushdown symbols or stack symbols.

images denotes transitional functions.

q0 is the initial state of PDA [q0 images Q]

z0 is the stack bottom symbol.

F is the final state of PDA.

In PDA transitional function images is in the form

images

(From one state with an input symbol on the tape and with the stack top symbol, the PDA moves to one right, may change its state, and push some symbol in the stack or pop symbol from the stack top.)

Q. Define Instantaneous Description (ID) in the respect of PDA.

Ans. Instantaneous Description (ID) describes the configuration of PDA at a given instant. Instantaneous Description remembers the information of state and stack content at a given instance of time.

An ID is a format of triple (q,w,k), where q images Q (finite set of states), w images images (Finite set of input alphabets) and images (Finite set of stack symbols).

6.2 ACCEPTANCE BY A PDA

Q. What are the conditions to declare a string accepted by PDA?

Ans. There are two ways to declare a string accepted by a PDA (a) Accepted by empty stack (store) (b) Accepted by final state.

(a) Accepted by empty stack (store): We know in each PDA there is a stack attached. In the stack at the bottom there is a symbol called stack bottom symbol. In each move of the PDA one symbol called stack symbol is either pushed in or popped from the stack. But the symbol z0 still remains in the stack.

A string w may be declared accepted by empty stack after processing all the symbols of w, if the stack is empty after reading the rightmost input character of the string w. In mathematical notation we can say images be a PDA, the string w is declared accepted by empty stack if

images

In general we can say that a string is accepted by a PDA by empty stack if both the following conditions are fulfilled.

(i) The string is finished (Totally Traversed)

(ii) The stack is empty.

(b) Accepted by final state: A string w may be declared accepted by Final state if after total traversal of the string w the PDA enters into its Final state. In Mathematical notation we can say images be a PDA, the string w is declared accepted by Final State if images for images and z0 is the stack bottom symbol}.

In general we can say that a string is accepted by a PDA by Final State if both the following conditions are fulfilled

(i) The string is finished (totally traversed)

(ii) The PDA enters into its final state.

(Though there are two way to declare a string accepted by a PDA, but it can be proved that both the ways are equivalent. In general for both the cases all the steps are same, except the last step. In the last step it is differentiated whether the string is accepted by empty stack or by final state.

if in the last step images it is accepted by empty stack

if                 images it is accepted by final state.)

Q. Prove that a Language is accepted by a PDA by empty stack if and only if the language is accepted by a PDA by final state.

Ans. Let images is a PDA. Let it accept a language L by final state. Let there exist another PDA M2, which accepts the same language L by empty stack.

Let images

Where images

The transitional function images is defined as follows

(a) images contains images

(b) images is the same as images for all images and images

(c) images contains images and for all images

(d) images contains images for all images

(Here (a) describes that M2 enters in the initial configuration of M1 with images as the leftmost push down symbol.

(b) describes to make M2 to simulate the behavior of M1, thus reading an input word w if M1 reads w and enters a final state. Once w is read and M2 enter a final state of M1, the effect of 3 and 4 are to empty the pushdown store.)

Here images if and only if

images

where qf is the fi nal state of machine M1.

By rule (a) we can write

images

i.e. images i.e. L is accepted by empty store by M2.

Conversely, let images be a PDA accepting L by empty store

Then images

Where images

1. images contains images

2. images is the same as images for all images

3. images contains images for all images

From these two it can be proved that a language is accepted by a PDA by empty stack if and only if the language is accepted by a PDA by final state.

6.3 EXAMPLES

Q. Construct a PDA to accept a given language L by empty stack and final state both where L = (anbn, where n≥1)

Ans. The string is anbn where n≥1. The remarks we can draw from seeing the string anbn where n ≥ 1 are the following.

(a) The string consists of two alphabets 'a' and 'b'.

(b) 'a' will occur before 'b'.

(c) Number of 'a' are equal to number of 'b'.

(d) There will be at least one 'a' and one 'b' in the string.

We have to check equal number of 'a' and 'b'. Let take a stack symbol z1, which is pushed into the stack as an 'a' is traversed from the input tape. At the beginning, the PDA is in state q0 and stack top is z0 as at the beginning there is no other symbol in the stack. In this state it will get an input 'a' from the input tape (the string starts with 'a'). So a stack symbol z1 will be pushed to the stack. The δ function will be

images

(At the right-hand-side the stack denotes the placement of the symbols. z1z0 denotes that there was z0 in the stack. Now the symbol z1 is pushed into the stack. It is given for better understanding of the placement of stack symbols)

From the next input 'a' from the input tape, the PDA is in state q0 and stack top is z1, so another z1 will be pushed into the stack. The δ function will be

images

By this δ function all the remaining 'a's will be traversed. After the end of 'a' in the input tape, 'b' will occur. When first 'b' will occur on the input tape at that time the PDA is in state q0 with stack top z1 (Just before it 'a' s are traversed). When 'b' will traversed the stack top z1 will be popped and the PDA will change its state to q1. (So that there will be no chance to push z1 in the stack if any 'a' occur. The PDA is designed only for string anbn, but the input string may not be in the form of anbn. In that case the string will not be accepted by the PDA.) The δ function will be

images

When next 'b' will occur, the PDA is in state q1 with stack top z1. That z1 will be popped. The δ function will be

images

By this δ function all the remaining 'b' will be traversed.

If the input string is in the form of anbn where n ≥ 1 then after traversing the last 'b' the PDA will be in state q1 with stack top z0 (All other stack symbols are removed).

If we have to design the PDA accepted by Empty stack the δ function will be

images

If we have to design the PDA accepted by Final State the δ function will be

images

So the PDA for L = (anbn, where n ≥ 1) is

images

δ is defined as follows:

images

Q. Construct a PDA to accept L = (a,b)* with equal number of 'a' and 'b', i.e. na(L) = nb(L) by empty stack and final state.

Ans. The string is any combination of 'a' and 'b' including null and number of 'a' is equal to number of 'b'. In the language set a string may start with 'a' or a string may start with 'b'. An 'a' can come after 'a' or 'b' can come after 'a', same like 'a' can come after 'b' or 'b' can come after 'b'. If a string start with 'a' then push a stack symbol z1 in the stack. If a string start with 'b' then push a stack symbol z2 in the stack. For these two cases the PDA is in state q0. The δ function for these two cases will be

images

If the string starts with 'a' and 'a comes after 'a' then the PDA is in state q0 with stack top z1. Another z1 will be pushed to the stack. The δ function will be

images

If the string starts with 'a', and 'b' comes after 'a' then the PDA is in state q0 with stack top z1. The stack top will be popped from the stack as one 'b' is found after one 'a'. The δ function will be

images

If the string starts with ' b' and 'b' comes after 'b' then the PDA is in state q0 with stack top z2. Another z2 will be pushed to the stack. The δ function will be

images

If the string starts with 'b', and 'a' comes after 'b' then the PDA is in state q0 with stack top z2. The stack top will be popped from the stack as one 'a' is found after one 'b'. The δ function will be

images

By these δ functions all the input symbols of the input tape will be traversed. The PDA will be in state q0 with stack top z0.

If we have to design the PDA accepted by empty stack the δ function will be

images

If we have to design the PDA accepted by Final State the δ function will be

images

(In the Language set null string can occur. If null string occurs in the language set, then it will also be accepted by the last two δ functions directly.)

So the PDA for L = (a,b)* with equal number of 'a' and 'b', i.e. na(L) = nb(L) is

images

δ is defined as follows:

images

Q. Construct a PDA to accept L = (a,b)+ with equal number of 'a' and 'b', i.e. na(L) = nb(L) by empty stack and final state.

In the string (a,b)+ there will be at least one 'a' and one 'b' with equal number of 'a', and 'b'. So the δ functions of the PDA will be made such that null string will not be accepted. All the conditions are same like (a,b)* but to avoid null occurrence the transitions will be like this

By getting 'a' at the beginning, change the state from q0 to q1 and push z1 in the stack. From the next input all the transitions will be on state q1.

Same like, if the string start with 'b', change the state from q0 to q1 and push z2 in the stack. From the next input all the transitions will be on state q1.

The transitional functions (δ) will be

images

.(If in the language set there is a null string, there exists no transitional function in the PDA, because the null string will only be traversed if the machine in state q1. For coming to q1, it needs to traverse atleast one a ' or one b '. It is clear from the discussion that the PDA will not accept null string, i.e. it is for L = (a,b)+ with equal number of 'a' and 'b'.)

Q. Construct a PDA to accept the language L = {WCWR, where W images (a,b)+ and WR is the reverse of W} by empty stack and by final state.

Ans. The W is a string consists of any combination of 'a' and 'b' not including null. The string W may start with 'a' or may start with 'b'. In the string, 'a' may come after 'a' (E.g. aa) or 'b' may come after 'a' (E.g. ab). Or 'a' may come after 'b' [ba] or 'b' may come after 'b' (E.g. bb).

The WR is the reverse of W. It means if 'a' appears at the ith place from the beginning in WR, then 'a' must appeared at the ith place from the end in W. The C is the marker which denotes the end of W and beginning of WR.

The PDA will be designed as follows:

The PDA is in state q0 with stack top z0 In the string W if 'a' is traversed as start symbol, a stack symbol z1 will be pushed and the PDA will change its state to q1 (To avoid accepting null string). If 'b' is traversed, a stack symbol z2 will be pushed and the PDA will change its state to q (To avoid accepting null string) .The δ function will be

images

If in W, 'a' occurs after 'a', then state is q1 and stack top is z1. One z1 will be pushed to the stack. If 'b' occurs after 'a' , then state is q1 and stack top is z1. One z2 will be pushed to the stack. The δ function will be

images

If in W, 'a' occurs after 'b', then state is q1 and stack top is z2. One z1 will be pushed to the stack. If 'b' occurs after 'b', then state is q1 and stack top is z2. One z2 will be pushed to the stack. The δ function will be

images

By the already given transitional functions the string W will be traversed.

At the end of W the input head will come to the symbol C to traverse it. The C indicates that the string W is finished and WR will start. Before traversing C, either 'a' or 'b' is traversed. When C is going to be traversed, at the stack top there will be either z1 (if just before 'a' is traversed) or z2 (if just before 'b' is traversed). Upon traversing C only there will be a state change from q1 to q2 but no operation will be done on stack. The δ function will be

images

After traversing C the reverse string of W, i.e. WR will come. If 'a' comes at the ith place from the beginning then 'a' will come at the ith place from the end in W. If for the string WR as an input 'a' comes, the stack top will be z1 and state will be q2. If for the string WR as an input 'b' comes, the stack top will be z2 and state will be q2. This stack top will be popped from the stack. The δ function will be

images

By these δ functions all the input symbols of the input tape will be traversed. The PDA will be in state q2 with stack top z0.

If we have to design the PDA accepted by Empty stack the δ function will be

images

If we have to design the PDA accepted by Final State the δ function will be

images

The PDA for L = {WCWR, where W images (a,b)+ and WR is the reverse of W} is

images

δ is defined as follows:

images

Q. Construct a PDA to accept the language L = { WCWR, where W images (a, b)* and WR is the reverse of W} by Empty stack and by Final state.

Ans. The string W may contain null string. If W is null then WR is null. It means in the language set there will be only C if W is null. The PDA will always be in state q0 at the time of traversing the string W. The δ functions for traversing W will be

images

Here C indicates the end of W and beginning of WR. When C will be traversed a state change from q0 to q1 will occur. The string W may be null. The set L may contain only C. So, stack top will one of the followings at the time of traversing C

May be z1 (if just before 'a' is traversed)

May be z2 (if just before 'b' is traversed)

May be z0 (if no input alphabet is traversed, i.e. W is null).

The δ function for traversing C will be

images

By the previous given δ functions all the input symbols of the input tape will be traversed. The PDA will be in state q1 with stack top z0.

If we have to design the PDA accepted by Empty stack the δ function will be

images

If we have to design the PDA accepted by Final State the δ function will be

images

Q. Construct a PDA to accept the language L = {anbmcmdn, where m,n ≥ 1} by empty stack and by final state.

Ans. The string is anbmcmdn, where m,n1. The remarks we can draw from the string are as follows

(a) The string consists of a, b, c and d.

(b) 'b' will follow 'a', 'c' will follow 'b' and 'd' will follow 'c'.

(c) Number of 'a' is equal to number of 'd' and number of 'b' is equal to number of 'c'.

(d) In all the strings of the language set there will be at least one 'a' , one 'b', one 'c' and one 'd'.

We need to check equal number of 'a' and 'd' and equal number of 'b' and 'c'. The string starts with 'a', so in the input tape 'a' will come first with state q0 and stack top z0. A stack symbol z1 will be pushed to the stack. From the next appearance of 'a' in the input tape, stack top will be z1. Another z1 will be pushed to the stack. The δ function for traversing 'a' will be

images

After complete traversal of 'a' in the input tape, 'b' will come to be traversed. At the time of traversal of first 'b' in the input tape, the PDA will be in state q0 with stack top z1 (Before it all 'a's are traversed). A state change from q0 to q1 will occur and a stack symbol z2 will be added to the stack. From the next appearance of 'b' in the input tape, the state will be q1 and stack top will be z2. Another z2 will be pushed to the stack. The δ function for traversing 'b' will be

images

After complete traversal of 'b' in the input tape, 'c' will come to be traversed. The number of 'b' and number of 'c' are equal in all strings belongs to the Language set L. At the time of traversal of first 'c' in the input tape, the PDA will be in state q1 with stack top z2 (Before it all 'b's are traversed). A state change from q1 to q2 will occur and stack top symbol z2 will be popped from the stack. From the next appearance of 'b' in the input tape, the state will be q2 and stack top will be z2.The symbol z2 will be popped from the stack. The δ function for traversing 'b' will be

images

When all the 'c' will be traversed, the stack top will be z1, which was added at the time of traversal of 'a' and the PDA will be in state q2. At the time of traversal of first 'd' in the input tape, the PDA will be in state q2 with stack top z1. A state change from q2 to q3 will occur and stack top symbol z1 will be popped from the stack. From the next appearance of 'd' in the input tape, the state will be q3 and stack top will be z1. The symbol z1 will be popped from the stack. The δ function for traversing 'b' will be

images

By the previous given δ functions all the input symbols of the input tape will be traversed. The PDA will be in state q3 with stack top z0.

If we have to design the PDA accepted by Empty stack the δ function will be

images

If we have to design the PDA accepted by Final State the δ function will be

images

The PDA for L = {anbmcmdn, where m,n ≥ 1} is

images

δ is defined as follows:

images

Q. Construct a PDA to accept the language L = {anbncmdm, where m,n ≥ 1} by Empty Stack and by Final State.

Ans. Here number of 'a' and number of 'b' are same and number of 'c' and number of 'd' are same. State change will occur in transition from 'a' to 'b', 'b' to 'c' and 'c' to 'd'. Upon traversing 'a', stack symbol z1 will be pushed to the stack. Number of 'b' are same as number of 'a'. Number of z1 pushed to the stack will be equal to number of 'a', i.e. number of 'b'. For traversal of each 'b' in the input tape one z1 will be popped from the stack.

When first 'c' will be traversed the stack top will be z0.Upon traversing 'c', stack symbol z2 will be pushed to the stack. Upon traversing ' d' those z2's will be popped from the stack.

By these process all the string will be traversed. The PDA for accepting the string anbncmdm/m,n ≥ 1 will be

images

The transition function for constructing PDA for the string anbncmdm/m,n ≥ 1 will be

images

Q. Construct a PDA to accept the language L = {anb2n, where n ≥ 1} by empty stack and by final state.

Ans. In the language set L each string is in the form anb2n where n ≥ 1. Number of 'b' is double to number of 'a'. At the time of traversing a single 'a' from the input tape two z1 as stack symbol will be pushed to the stack.

images

These two z1 will be popped at the time of traversing two 'b'. [Single 'a' is equal to two 'b'].

The δ function for traversing 'b' will be

images

By the previous given δ functions all the input symbols of the input tape will be traversed. The PDA will be in state q1 with stack top z0.

If we have to design the PDA accepted by Empty stack the δ function will be

images

If we have to design the PDA accepted by Final State the δ function will be

images

The PDA will be as follows:

images

The transitional function will be

images

Q. Construct a PDA for the language L = {anCb2n, where n ≥ 1}.

Ans. In the language set number of 'b' is twice of 'a'. The 'C' is the middle element, which indicates the end of 'a' and beginning of 'b'. For each 'a', two z1 are inserted in the stack, for each 'b', one z1 is popped from the stack.

The transitional functions are

images

Q. Construct a PDA for the language L = {ambn where mn and m,n ≥ 1}

Ans. In the language set number of 'a' is less than number of 'b'. At the time of traversing 'a', one z1 is added to the stack. For m number of 'a', m number of z1 are added to the stack. At the time of traversing m number of 'b', stack top is z1, which is popped. If n > m, then at the time of traversing last (n–m) number of 'b', stack top is z0.

The transitional functions are

images

Q. Construct a PDA to accept the language L = {anbmcn+m, where n > 0, m > 0}

Ans. In the language set total number of 'c' is equal total number of 'a' and 'b'. The PDA can be designed in the following way, at the time of traversing n number of 'a', n number of 'z1' are added to the stack and for traversing m number of 'b', m number of z1 are added to the stack. At the time of traversing (n + m) number of c all the z1 are popped from the stack.

The transitional functions are:

images

Q. Construct a PDA to accept the language L = {anbmcn + m, where n ≥ 0, m > 0}

Ans. The string is same as the previous but in the language set number of 'a' may be zero. In the case when number of 'a' is zero, then the string starts from 'b'.

The transitional functions are

images

Q. Construct a PDA to accept the language L = {anbn+mcm, where n,m > 0}

Ans. In the language set number of 'b' is total number of 'a' and 'c'. At the time of traversal of n number of 'a', n number of z1 are pushed in the stack, at the time of traversal of n number of 'b', n number of z1 are popped from the stack. At the time of traversal of rest m number of 'b', m number of z2 are pushed into the stack, which are popped at the time of traversal of m number of 'c'.

The transitional functions are

images

Q. Construct a PDA to accept the language L = {anbn+mcm, where n ≥ 0 m > 0 }

Ans. The string is same as the previous but in the language set number of ' a may be zero. In the case when number of 'a is zero, then the string starts from 'b'.

The transitional functions are

images

images

Q. Construct a PDA to accept the following language L = {a2nbn, where n > 0 }

Ans. In the language set number of 2n number of 'a' and n number of 'b'. The PDA can be designed as follows – at the time of traversing first 'a', two z1 are added to the stack with a state changed from q0 to q1. At the time of traversing second 'a' one z1 is popped from the stack with a state change from q1 to q0. By this process after traversing 2n number of 'a only n number of z1 exist in the stack. At the time of traversing first 'b' stack top is z1 and state q0. Those z1 are popped at the time of traversing n number of 'b'.

The transitional functions are

images

Q. Construct a PDA to accept the language L = {anbncm, where n,m ≥ 1} by empty stack and by final state.

Ans. The language is in the form anbncm, where n,m ≥ 1. In the language set number of 'a' and number of 'b' are same, but number of 'c' is different. All the strings in the language set starts with n number of 'a's followed by n number of 'b's and ends with m number of 'c's. Here m and n both ≥ 1, null string does not belongs to the language set.

The PDA for the language can be designed in the following way.

When traversing 'a's from the input tape, one by one z1 are pushed in the stack. At the time of traversing 'b's, all the z1's which were pushed into the stack are popped one by one. When first 'c' will be traversed, at that time the machine is in state q1 and stack top z0. At the time of traversal of m number of 'c's, no operation is done on stack.

The transition function for constructing PDA for the string anbncm where m,n1 are

images

Q. Construct a PDA to accept the language L = {anbmcn, where n,m ≥ 1} by empty stack and by final state.

Ans: The language is in the form anbmcn, where n,m1 . In the language set, number of 'a's are equal to number of 'c's. In the language set, 'a's are separate with 'c's by m number of 'b's. As m,n ≥ 1, null string does not belong to the language set. In the language set number of 'a' are equal to number of 'c' but not with number of 'b'.

The PDA can be designed in the following way:

When traversing 'a's from the input tape, one by one z1 are pushed in the stack. When the first 'b' is read by the input head, the machine is in state q0 and stack top z1. One state change has occurred. (If after 'b' again 'a' comes as input, the language is in wrong format. But that 'a' will also be traversed as there will be a function images

to traverse that 'a'. To avoid this mismatch and to guarantee that the PDA is only for accepting an-' bmcn, where n,m1, the state change is required.) At the time of traversing 'b', no operation is done on the stack.

When 'c' will going to be traversed, the machine is in state q1, with stack top z1. The stack top is popped and a state change has occurred. (To avoid appearance of 'b' after 'c').

The transition function for constructing PDA for the string anbncm where m,n1 will be

images

Q. Construct a PDA to accept the language L = {w, where number of 'a' + number of 'b' = number of 'c'}

Ans. According to the given specification any string belong to the language set consists of any combination of 'a', 'b' and 'c' and number of 'c' is equal to number of 'a' and number of 'b'. In the string 'a', 'b' and 'c' can occur in any sequence with fulfilling the given condition.

The transitional functions are

images

6.4 DETERMINISTIC PDA AND NON-DETERMINISTIC PDA

Q. How many types of PDA are there? Describe each of them by suitable example.

Ans: There are two types of PDA:

(a) Deterministic PDA (DPDA)

(b) Non-Deterministic PDA (NPDA)

(a) Deterministic PDA (DPDA): A PDA is said to be a DPDA if all derivations in the design give only single move.

If a PDA being in a state with a single input and single stack symbol gives a single move, then the PDA is called Deterministic PDA.

As an example for L = {anbn, where n ≥ 1} can be designed a DPDA if the transitional functions are as following.

images

In the previous PDA, in a single state with a single input and single stack symbol there is only one move. So the PDA is deterministic.

(b) Non-Deterministic PDA (NPDA): A PDA is called non-deterministic if one of the derivations generates more than one move.

If a PDA being in a state with a single input and single stack symbol gives more than one move for any of its transitional functions, then the PDA is called Non-Deterministic PDA.

Q. Design a non-deterministic PDA for accepting the string {WWR where W images (a,b)+ and WR is the reverse of W} by empty stack and by final state.

Ans. The W is a string consists of 'a' and 'b'. The WR is the reverse string of W Let W = abaa, then WR will be aaba. WWR will be abaaaaba. Traversing input symbol 'a' from the input tape, z1 will be pushed into the stack and traversing input symbol ' b' from the input tape, z2 will be pushed into the stack. When WR will start, for the traversal of first symbol the state of the PDA will be changed and the stack top will be popped. From the next input symbols belong to WR the stack top will be popped.

But here is a problem. In the PDA it is not assigned where W is ended and WR is started. The PDA will traverse the total string assuming it as W. Some attempt has been done to differentiate W and WR by traversing a λ symbol and changing the state in between Wand WR. But this is also wrong, as all the input symbols are placed on the input tape from left to right in a continuous fashion. There is no gap in between two input symbols, as they are placed one by one in each square from left to right on the input tape.

From the above discussion it is clear that a Deterministic PDA cannot be designed for WWR.

But this is possible for Non-deterministic PDA. Our problem is to find the middle of the string where W ends and WR starts. In the string where consecutive two 'a' and two 'b' appear, that may be the middle of the string, because the last alphabet of Wis the first alphabet of WR. Make two transitional functions when stack top is z1 and 'a' is traversed as input and stack top is z2 and ' b' is traversed as input. (All the other δ functions are same as WCWR). The PDA for accepting the string WWRI We (a,b)+ and WR is the reverse of W is

images

The transitional function will be

images

images

Q. Design a non-deterministic PDA for accepting the string { WWR where W images (a,b)* and WR is the reverse of W} by empty stack and by final state.

Ans. Null string may belong to the Language set. The PDA will be designed in such a way that null string can be accepted by the PDA. The transitional functions will be:

images

Q. Design a Non-Deterministic PDA for accepting the string L = {(Set of all palindromes over a, b)} by empty stack and by final state.

Ans. A string read from left to right and right to left gives the same result is called palindrome. Palindrome can be of two types (a) Odd Palindrome (b) Even Palindrome. Odd palindromes are those where number of characters is odd and even palindromes are those where number of characters is even.

The string 'a' is a palindrome, 'b' is a palindrome. 'aa' is a palindrome, 'bb' is a palindrome. The string 'aba' is a palindrome, 'aaa', 'bbb' are also palindrome. Null string is also a palindrome.

The PDA will be

images

Transitional functions are as follows

images

6.5 PUSHDOWN AUTOMATA FROM CONTEXT FREE GRAMMAR

Q. How to construct an equivalent PDA of a context free grammar.

Ans.

Step I: Convert the PDA into Greibach Normal Form (GNF).

Step II: First the start symbol S of the CFG is put to the stack by transition function

images

Step III: For a production in the form {NT1} images {Single T}{String of NT}, the transitional function will be

images

Step IV: For a production in the form {NT1} images {Single T}, the transitional function will be δ(q1, T, NT1) images (q1, λ).

Step V: For accepting a string two transitional functions are added, one for accepted by empty stack and one for accepted by final state.

Q. Construct a PDA that accept the language generated by the following grammar

images

Show an ID for the string abab for the PDA generated.

Ans.

The Context Free Grammar is in GNF.

First the start symbol S is pushed into the stack by the following production

images

For the production S images aB the transitional function is

images

For the production A images aB the transitional function is

images

For the production B images bA/b the transitional function is

images

So, the PDA for the above CFG is

images

δ functions are defined as follows:

images

Id for the string abab.

images

(The process is very easy. First try to generate the string from the given grammar by left most derivation. Then according to the non terminal symbols replaced use the particular transitional function to give the ID

For the previous case the string ‘abab’ is generated like the derivation(Left Most) given below S images images

First transitional function is adding S in the stack. After that S is replaced by B for the input ‘a’ using the transitional function δ (q1, a, S) images (q1, B)

The process continues like this till the end of the string.)

Q. Construct an equivalent PDA for the following Context Free Grammar.

images

Show an ID for the string abbaaabbbbab for the PDA generated with stack description.

Ans. The CFG is in GNF.

First the start symbol S is pushed into the stack by the following production

images

For the production S images aAB, the transitional function is

images

For the production S images bBA, the transitional function is

images

For the production A images bS, the transitional function is

images

For the production B images aS, the transitional function is

images

For the production A images a, the transitional function is

images

For the production B images b, the transitional function is

images

For acceptance transitional function is

images

Id for the string abbaaabbbbab

images

Q. Construct an equivalent PDA for the following CFG.
S images 0BB
B images 0S/1S/0

Show an ID for the string 010000 for the PDA generated.

Ans. First the start symbol S is pushed into the stack by the following production

images

For the production S images 0BB, the transitional function is

images

For the production B images 0S, the transitional function is

images

For the production B images 1S, the transitional function is

images

For the production B images 0, the transitional function is

images

For acceptance transitional function is

images

Id for the string 010000

images

Q. Construct an equivalent PDA for the following CFG.

S images aA

A images aABC/bB/a

C images c

Show an ID for the string aabbbc for the PDA generated.

Ans.

First the start symbol S is pushed into the stack by the following production

images

For the production S images aA, the transitional function is

images

For the production A images aABC, the transitional function is

images

For the production A images bB, the transitional function is

images

For the production A images a, the transitional function is

images

For the production C images c, the transitional function is

images

For acceptance transitional function is

images

Id for the string aabbbc

images

Q. Construct an equivalent PDA for the following CFG.

S images aSbb/aab

Show an ID for the string aaabbb for the PDA generated.

Ans. The given grammar is not in GNF. First we need to convert the grammar into GNF. Replace ‘b’ by Band ‘a’ by A. The converted grammar in GNF is

S images aSBB/aAB

A images a

B images b

Now the grammar can be easily converted into PDA.

The transitional functions for the PDA accepted by the language generated by the grammar are

images

ID for the string aaabbb

images

6.6 GRAPHICAL NOTATION FOR PDA

Q. How a PDA can be denoted by graphical notation?

Ans. The mathematical notation for a PDA is images In a PDA the transitional function δ consists of three touples, first is a present state, second is present input and the third is stack top symbol; which generates one next state and stack symbol(s) if a symbol is pushed into the stack or ε, if the top most symbol is popped from the stack.

In the graphical notation of PDA there are states. Among them a circle with an arrow indicates a beginning state and a state with double circle indicates a final state. The state transitions are denoted by arrow. The labels of the state transitions consists of input symbol, stack top symbol and the stack top symbol which is added after the transitions or null is a symbol is popped.

Q. Construct a PDA with graphical notation to accept L = (a, b)* with equal number of ‘a’ and ‘b’, i.e. na(L) = nb(L) by final state.

Ans. At the beginning of transition the PDA is in state q0 with stack to z0. The string may start with 'a’ or ‘b'. If the string start with ‘a', one z1 is pushed into the stack. If the string start with ‘b’, one z2 is pushed into the stack. If ‘b’ is traversed after ‘a’, and stack top is z1, and that stack top is popped. If ‘a’ is traversed after ‘b’, and stack top is z2, and that stack top is popped. If ‘a’ is traversed after ‘a’, and stack top is z1, and one ‘z1’ is pushed into the stack. If ‘b’ is traversed after ‘b’, and stack top is z2, and one ‘z2’ is pushed into the stack.

The PDA in graphical notation is

images

Q. Construct a PDA with graphical notation to accept the language L = {WCWR, where W ∈ (a,b)+ and WR is the reverse of W} by Final state.

Ans. At the beginning of the transition the machine is in state q0 and stack top symbol z0. If it gets input symbol ‘a’, one z1 is pushed into the stack, if it gets input symbol ‘b’, one z2 is pushed into the stack and state is changed from q0 to q1. In state q1 if it gets input ‘a’ and stack top z1 or z2 another z1 or z2 is pushed into the stack, respectively. In state q1 if it gets input 'b’ with stack top z2 or z1, another z2 or z1 is pushed into the stack, respectively.

The C is the symbol which differentiate W with WR. Before C, W is traversed. Therefore, at the time of traversing C, stack top symbol may be z1 or z2. In state q1 if the PDA gets C as input and stack top z1 or z2, no operation is done on the stack, only state is changed from q1 to q2. After C the string WR is traversed. If the machine gets ‘a’ as input, stack top must be z1. And that z1 is popped from the stack top. If the machine gets ‘ b’ as input, stack top must be z2. And that z2 is popped from the stack top. The state is not changed. By this process the whole string WCWR is traversed. In state q2 if the machine gets no input but stack top zo, the machine goes to its final state qf.

The graphical notation for the PDA is

images

WHAT WE HAVE LEARNED SO FAR

1. PDA (in short PDA) is the machine format of CFL.

2. The mechanical diagram of a PDA contains Input tape, Reading head, Finite control and a stack.

3. A PDA consists of 7-touple M = (Q, ∑, Γ, δ, qo, zo, F), where Q, ∑, qo and F has their original meaning, Γ is finite set of stack symbols and zo is the stack bottom symbol.

4. In PDA transitional function δ is in the form images

5. Instantaneous Description (ID) remembers the information of state and stack content at a given instance of time.

6. There are two ways to declare a string accepted by a PDA (a) accepted by empty stack (store) (b) accepted by final state.

7. A string is declared accepted by a PDA by empty stack if the string is totally traversed and the stack is empty.

8. A string is declared accepted by a PDA by Final state if the string is totally traversed and the machine reaches to its final state.

9. A string accepted by a PDA by empty stack if and only if the language is accepted by that PDA by final state.

10. If a PDA being in a state with a single input and single stack symbol gives a single move, then the PDA is called Deterministic PDA.

11. If a PDA being in a state with a single input and single stack symbol gives more than one move for any of its transitional functions, then the PDA is called Non Deterministic PDA.

12. From Context free grammar NPDA can be directly constructed.

SOLVED PROBLEMS

1. Design a PDA to accept the language of nested balanced parentheses.[Where number of opening and close parenthesis is greater than 0]

Ans. Nested balanced parenthesis is in the form ((())). More precisely

   (
    (
     (
     )
    )
   )

This type of nested balanced parentheses has two types of symbol open parenthesis ‘(’ and close parenthesis ‘)’. As it is nested, first the PDA has to traverse open parenthesis after that the close parenthesis.

The transitional function for traversing the first open parenthesis is (The beginning state is q0, input symbol is ‘(’ and stack top is z0. )

images

From then on the state is q0, input symbol is ‘(’ [if number of open parenthesis is > 1] and stack top is z0. The transitional function for traversing the next open parenthesis is

images

By using the previous transitional function all the remaining open parenthesis will be traversed.

After traversing all open parentheses the PDA will get the first close parenthesis. At that time the state is q0, input symbol is ‘)’, and stack top is z1. After getting the ‘)’ as an input symbol the stack top [here z1] will be popped from the stack and state will be changed to q1. The transitional function is

images

After that the state is q1, input symbol is ‘)’ and stack top is z1. (If the string contain multiple open and close parentheses). The transitional function is

images

When all input symbols are traversed the PDA is in state q1, input symbol is λ and stack top is z0.

If we have to design the PDA accepted by empty stack the δ function will be

images

If we have to design the PDA accepted by final State the δ function will be

images

The transitional functions for the PDA is

images

images

2. Design a PDA to accept the language of balanced parentheses. (Where number of opening and close parenthesis is greater than 0.)

Ans. There are two types of parentheses - open parentheses and close parentheses. Balanced parenthesis means for each open parenthesis there is a close parenthesis. It may be nested like ( ( ( ) ) ) or may be non nested like ( ( ) ( ) ) or ( )( )( ) or any other form. But for each open parenthesis there is a close parenthesis. (The definition that balanced parenthesis means equal number of open and close parentheses is wrong. As an example, ) ( )( ) ( is not a balanced parenthesis). The string must start with an open parenthesis and after that open parenthesis or close parenthesis can appear, but for any position of the string, number of open parenthesis is greater than or equal to number of close parenthesis.

The transitional function for traversing the first open parenthesis is (The beginning state is q0, input symbol is ‘(’ and stack top is z0.)

images (As null string is not accepted by the PDA).

After the first open parenthesis, there may be open parenthesis or close parenthesis. If open parenthesis is to be traversed then a z1 is added at the stack top. The transitional function is

images

If close parenthesis is to be traversed then one z1 is popped from the stack top. The transitional function is

images

It may happen that the state is q1, and stack top is z0 and the input symbol is ‘(’. [As an example for the case (())()] The transitional function for the case is

images

(But this type of case can not appear -where the state is q1, and stack top is z0 and the input symbol is’)’)

If we have to design the PDA accepted by empty stack the δ function is

images

If we have to design the PDA accepted by final state the δ function is

images

The transitional functions for the entire PDA is

images

3. Design a PDA to accept the language L = ambncm-n, where m > = n and m, n > 0

Ans. The language consists of 'a’, ‘b’ and ‘c’. Here in every string all ‘a’ will appear before ‘b’ and after ‘b’, ‘c will appear. Number of ‘c is the subtraction of number of ‘a’ and number of ‘b’. At the beginning the machine is in state qo with stack top zo and input is ‘a’. After traversing, the machine will add z1 in the stack. The transitional function is

images

If number of ‘a’ is greater than one then the machine have to traverse ‘a’ with state qo and stack top z1. Another z1 is added to the stack top. The transitional function is

images

After traversal of all ‘a', b will appear. When ‘b’ will come at that time state is qo, stack top is z1 .The stack top is popped from the top. The transitional function is.

images

If number of ‘ b’ is greater than one then the machine has to traverse ‘b’ with state q1 and stack top z1. (Number of ‘b’ greater than one means number of ‘a’ was greater than one.) The stack top is popped from the top. The transitional function is.

images

If number of ‘b’ is less than number of ‘a’, then ‘c’ will appear after fully traversal of all ‘b's. At that time the state is q1, and stack top is z1. After traversal of ‘c’, the stack top is popped. The transitional function is.

images

If number of ‘c’ is greater than one then the machine have to traverse ‘c’ with state q2 and stack top z1. (Number of ‘c’ greater than one means number of ‘a’ was greater than one.) The stack top is popped. The transitional function is.

images

If we have to design the PDA accepted by empty stack the δ function is

images

If we have to design the PDA accepted by Final State the δ function is

images

It may also happen that m = n, i.e. number of ‘a’ is equal to number of ‘b’. At that case there is no ‘c’ in the language. The string ends after fully traversal of all ‘b’. After traversal of all ‘b’ s the state of the machine is q1. If we have to design the PDA accepted by empty stack the δ function is

images

If we have to design the PDA accepted by final state the δ function is

images

The transitional functions for the entire PDA is

images

4. Design a PDA to accept the language L = anbmcm-n where m > n and m, n > 0.

Show an ID for the string aabbbbcc.

Ans. The language consists of ‘a', 'b' and ‘c . Here in every string all ‘a’ will appear before ‘b’ and after ‘b’, ‘c’ will appear. Number of ‘c’ is the subtraction of number of ‘b’ and number of ‘a’. In the string number of 'b’ is the sum of number of ‘a’ and number of ‘c’. It can be designed as follows: For n number of 'a’ , n number of z1 are added to the stack. For next n number of b, those z1 are popped from the stack and z0 becomes the stack top. For the remaining (m-n) number of ‘b', (m-n) number of z2 are added to the stack. For (m-n) number of 'c’, (m-n) number of z2 are popped from the stack.

The transitional functions are designed as follows.

At the beginning the machine is in state q0 with stack top z0 and input is ‘a'. After traversing, the machine will add z1 in the stack. The transitional function is

images

If number of 'a’ is greater than one then the machine have to traverse 'a’ with state q0 and stack top z1 Another z1 is added to the stack top. The transitional function is

images

After traversal of all 'a’, ‘b' will appear. When 'b' will come at that time state is q0, stack top is zr The stack top is popped from the top. The transitional function is.

images

If number of 'a’ is greater than one then number of 'b' is also greater than one because m = (m-n) + n. The machine has to traverse 'b' with state ql and stack top z1 The stack top is popped from the top. The transitional function is.

images

After some time all z1 s are popped from the stack. The stack top becomes z0. As m is greater than n, till the input symbol is 'b' with machine state q1. In this situation z2 is pushed into the stack. The transitional function is

images

If m-n is greater that one, i.e. number of ‘c’ is more than one then machine state q1, input symbol 'b' and stack top z2. Another z2 is pushed into the stack. The transitional function is

images

After fully traversal of all ‘ b's,'c’ appears in the string. When ‘c' appears machine state is q1 and stack top is z2. The stack top z2 is popped from the stack. The transitional function is.

images

If m-n is greater that one, i.e. number of ‘c’ is more than one the machine has to traverse ‘c’ with state q2 and stack top z2. The stack top z2 is popped from the stack. The transitional function is

images

If we have to design the PDA accepted by empty stack the δ function is

images

If we have to design the PDA accepted by final State the δ function is

images

The transitional functions for the entire PDA is

images

ID for the string aabbbc

images

5. Design a PDA for Hypertext Markup Language (HTML) consisting of all tags having immediate closing tags within the <BODY></BODY> tag.

Show an ID for the following language

 <HTML>
   <HEAD>
    <TITLE>
    My First Web Page
    </TITLE>
   </HEAD>

 <BODY>
  <B>First Web Page</B>
  <p><B>HTML</B> is an <I>interpreted language.</I> No error is produced in HTML.
  </p>
  </BODY>
</HTML>

Ans. Hypertext Markup Language (HTML) is a language used for webpage designing. This language is an interpreted language and produces no error. The language has a basic structure in the following form

<HTML>
  <HEAD>
   <TITLE>
   ----------
   </TITLE>
  </HEAD>
  <BODY>
  Some other tags with closing tags 
  </BODY>
<HTML>

The tags can be of capital letter, small letter or mixture of both. The tags within <> is called open tag and the tags within </> is called closing tags. Most of the tags in HTML has closing tags, but some of the tags like <BR>, <HR> has no closing tags.

In <BODY> </BODY> tag all the other tags appear. The tags may appear in any order. But for all the opening tags there is a closing tag except the tags which do not have any closing tag. For the line <B>HTML</B> is an <I>interpreted language.</I>, the output is

HTML is an interpreted language.

If the line is in the form <B>HTML is an <I>interpreted</B> language.</I>, the output:

HTML is an mterpreted language.

In this section we are interested in tags with immediate closing tags like the first example, i.e., the tag within the body which has opened first will close at last.

Every HTML file starts with <HTML> tag. At state q0, when the machine gets <HTML> as input it pushes Z<HTML> in the stack. The transitional function is

images

In every HTML document after <HTML>, <HEAD> tag comes. The transitional function for traversing <HEAD> is

images

In every HTML document after <HEAD>, <TITLE> tag comes. The transitional function for traversing <TITLE> is

images

When the machine gets closing </TITLE> tag it pops the stack top symbol Z<TITLE>. The transitional function

images

When the machine gets closing </HEAD> tag it pops the stack top symbol Z<HEAD> The transitional function is

images

Now the stack top is Z<HTML> The next symbol is <BODY>. The transitional function for traversing <BODY> tag is

images

Within <BODY> tag any tag can come. Let a tag named <tag j> has come. Let the state of the PDA is qi, where i is greater than or equal to 4. For traversing that tag the transition function is

images

If <tag j> appears with immediate closing tags then its closing tag will get the symbol Z<tag j> as stack top. That stack top is popped.

images

The last two tags are </BODY> and </HTML>. When </BODY> is traversed the stack top is Z<BODY>. The stack top is popped by the following transitional function.

images

When </HTML> is traversed the stack top is Z<HTML>. The stack top is popped by the following transitional function.

images

If we have to design the PDA accepted by empty stack the δ function is

images

If we have to design the PDA accepted by final state the δ function is

images

ID for the given HTML document:

It is not possible to show the string in each phase. Only the state and the stack condition is shown in the description.

images

images

6. Design a PDA for the language L = {anbmambn, where m, n ≥ 1}

Ans. The language is a CFL. The CFG for the language is S images aSb/ aAb

A images bAa/ ba

The grammar is not in GNF. So, first we need to convert the grammar into GNF. Take two nonterminals Ca and Cb and two productions Ca images a and Cb images b. Replacing in appropriate positions the modified context free grammar is

S images aSCb

S images aACb

A images bACa

A images bCa

Ca images a

Cb images b

The CFG is in GNF.

First the start symbol S is pushed into the stack by the following production

images

For the production S images aSCb the transitional function is

images

For the production S images aACb the transitional function is

images

For the production A images bACa the transitional function is

images

For the production A images bCa the transitional function is

images

For the production Ca images a the transitional function is

images

For the production Cb images b the transitional function is

images

If we have to design the PDA accepted by empty stack the δ function is

images

If we have to design the PDA accepted by final state the δ function is

images

7. Construct PDA for the language images

Ans. The given language is the union of two languages (ab)n and (ba)n. The grammar for the first language is S1 images abS1/ab. Grammar for the second language is S2 images baS1/ba. Here we have considered two start symbols S1 and S2, respectively. As two languages are connected with union symbol, consider another start symbol for the entire language as S. Make a production rule S images S1/S2. The production rule for the grammar satisfying the language is

images

The production rule after removing unit productions and useless symbol is

images

The grammar is not in GNF. Consider two non-terminals Ca and Cb and two productions Ca images a and Cb images b. The modified production rule become

images

The CFG is in GNF.

First the start symbol S is pushed into the stack by the following production

images

For the production S images aCb the transitional function is

images

For the production S images bCa the transitional function is

images

For the production S images aCbS1 the transitional function is

images

For the production S images bCaS2 the transitional function is

images

For the production S1 images aCb the transitional function is

images

For the production S1 images aCbSl the transitional function is

images

For the production S2 images bCa the transitional function is

images

For the production S2 images bCaS2 the transitional function is

images

For the production Ca images a the transitional function is

images

For the production Cb images b the transitional function is

images

If we have to design the PDA accepted by Empty stack the δ function is

images

If we have to design the PDA accepted by final state the δ function is

images

8. Construct PDA for the language images

Ans. The given language is the union of two languages anbn and amb2m. The grammar for the first language is A images aAb and A images ab.

Grammar for the second language is B images aBbb and B images abb. Here we have considered two start symbols A and B, respectively. As two languages are connected with union symbol, consider another start symbol for the entire language as S. Make a production rule S images A/B. The production rule for the grammar satisfying the language is

S images A/B
A images aAb/ab
B images aBbb/abb

The grammar contains two unit productions S images A and S images B. After removing the unit productions the production rules become

S images aAb/aBbb/abb/ab
A images aAb/ab
B images aBbb/abb

The CFG is not in GNF. Consider two non-terminals Sa and Sb and two extra production rules Sa images a and Sb images b. Replacing a and b by Sa and Sb, respectively in suitable places, the modified production rules become.

images

The CFG is in GNF.

First the start symbol S is pushed into the stack by the following production

images

For the production S images aASb the transitional function is

images

For the production S images aBSbSb the transitional function is

images

For the production S images aSbSb the transitional function is

images

For the production S images aSb the transitional function is

images

For the production A images aASb the transitional function is

images

For the production A images aSb the transitional function is

images

For the production B images aBSbSb the transitional function is

images

For the production B images aSbSb the transitional function is

images

If we have to design the PDA accepted by empty stack the δ function is

images

If we have to design the PDA accepted by final state the δ function is

images

MULTIPLE CHOICE QUESTIONS

1. PDA is the machine format of

(a) Type o language    (b) Type 1 language    (c) Type 2 language    (d) Type 3 language.

2. Which is not true for mechanical diagram of PDA?

(a) PDA contains a stack

(b) The head reads as well as writes

(c) The head moves from left to right

(d) Input string is surrounded by infinite number of blank in both side.

3. The difference between finite automata and PDA is in .

(a) Reading Head    (b) Input tape    (c) Finite Control    (d) Stack

4. In PDA transitional function δ is in the form

(a) images     (b) Q X Σ images Q     (c) images    (d)images (Where Q is the finite set of states, ∑ is the set of input alphabets, ┌ is the stack symbols.)

5. Instantaneous Description remembers

(a) the information of state and input tape content at a given instance of time.

(b) the information of state and stack content at a given instance of time.

(c) the information of input tape and stack content at a given instance of time.

(d) the information of state, input tape and stack content at a given instance of time

6. Which of the following is not possible algorithmically?

(a) RE to CFG     (b) NFA to DFA    (c) CFG to PDA    (d) NPDA to DPDA

7. Which of the following is not accepted by DPDA but accepted by NPDA?

(a) L = anbn, where n > 0    (b) L = WCWR, where W ∈ (a, b)*    

(c) L = WWR, where W ∈ (a, b)+    (d) L = anbmcmdn, where m,n > 0

8. Which of the followings cannot be designed by PDA?

(a) anbnci, where n, i > 0 (b) anbncn, where n > 0,

(c) ancibn, where n, i > 0 (d) cianbn, where n, i > 0.

Ans. 1. c,   2.b,    3.d,   4. a,   5. b,   6. d,   7. c,   8. b.

EXERCISES

1. Construct PDA to accept the following languages by empty store and final state.

(a) L = {an, where n > 0}

(b) L = {an, where n ≥ 0}

(c) L = {anbcn, where n > 0}

(d) L = {anb2n, where n > 0}

(e) L = {anbmcm + n, where m, n > 0}

(f) L = {anban, where n > 0}

(g) L = {anbnci, where n, i > 0}

(h) L = {ambm+n cn, where m, n > 0}.

(Hints: For m number of ‘a’, m number of Z1 are pushed into the stack. For first m number of 'b', m number of Zl are popped from the stack. For next n number of ‘b’, n number of Z2 are pushed into the stack, which will be popped for next n number of ‘c'.)

(i) L = {ambm+nan, where m, n > 0}

(j) L = {WCW, where W ∈ (a, b)+}

(k) L = {WCW, where W ∈ (a, b)*}.

2. Construct an equivalent PDA for the following Context Free Grammars.

(a) S images aB/bA
A images aS/bAA/a
B images bS/aBB/b

(b) S images bA/aB
A images bA/aS/a
B images aB/bS/b

(c) S images Abb/a
A images aaA/B
B images bAb

3. Construct PDA with graphical notation to accept the following languages by graphical notation

(a) L = {anbncmdm, where m,n ≥ 1}

(b) L = {anbncm, where n,m ≥ 1}.

FILL IN THE BLANKS

1. Full form of PDA is__________.

2. __________ is the machine format of Context Free Language.

3. The mechanical diagram of Pushdown Automata is similar to Finite Automata but difference is in __________.

4. __________ of PDA describes the configuration of PDA at a given instant.

5. There are two ways to declare a string accepted by a Pushdown Automata a)__________ and b) __________.

6. For directly constructing PDA from a given grammar we first need to convert the grammar into __________ normal form.

7. If a PDA being in a state with a single input and single stack symbol gives a single move, then the PDA is called __________ -Pushdown automata.

8. If a PDA being in a state with a single input and single stack symbol gives more than one move for any of its transitional functions, then the PDA is called __________ Pushdown automata.

9. The PDA for the string L = {(Set of all palindromes over a, b)} can be designed by __________ Pushdown automata not by __________ Pushdown automata.

ANSWERS

1. Pushdown Automata

2. Pushdown Automata

3. stack

4. Instantaneous Description (ID)

5. Accepted By Empty Stack,

6. Greibach

7. Deterministic

8. Accepted by Final State Non Deterministic

9. Non Deterministic Deterministic

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.27.171