Question

Q.5 Are the context-free languages closed under reversal? Answer yes or no, and explain. (Reversal means...

Q.5 Are the context-free languages closed under reversal? Answer yes or no, and explain. (Reversal means to form the language containing the reverse of every string in the original.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Yes, context-free language (CFL) are closed under the reversal operation, that is if L is a CFL with grammar G,form a grammar for LR by reversing the right side of every production.

example let the CFG be S -> 0S1 | 01, then the reversal of the L(G) has the grammar S -> 1S0 | 10.

Now let us prove that is L is CFL then LR is also CFL.

Proof :- Let L be a language for some context free language L(G), G = {V, T, P ,S}

For the reversal all the production of the grammar will be reversed such that the new grammar for the reversal will become GR = {V, T, PR, S} ,where PR is the reverse of each production in P that is if A -> x is a production of G then A -> xR is the production of GR where A is a variable and x is the string of variables and terminals.

It is clearly seen that any string w is generated from the grammar G if and only if the string wR is generated by the grammar GR therefore GR generates the language LR and thus the language LR is also context free language(CFL).

and hence it is proved that the Context free language are closed under reversal.

Example let a CFL be L(G) = {w E {a,b}* |wa| = |wb|} that is we have to design an CFL which accepts the string that starts with a and ends with b and the size of a's and b's are same, that is L= anbn for such language the CFG will be S -> aSb ,S -> E

For the reversal of the above language we have to reverse all the production rules that is the grammar for the new language will become GR => S -> bSa , S -> E

Clearly this grammar will generate all the strings which starts with b and ends with a and the size of b's and a's are same, that is LR = bnan which is the reverse of the above language.

therefore the CFG are closed under reversal operation.

Add a comment
Know the answer?
Add Answer to:
Q.5 Are the context-free languages closed under reversal? Answer yes or no, and explain. (Reversal means...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT