1

Design the grammar for the following: L = (a^n)w(w^r)(b^n) where n>=0 and w={a,b}

  • Hello! We discourage posts that simply state a problem out of context, and expect the community to solve it. What have you tried? Where did you get stuck? We do not want to just do your exercise for you; we want you to gain understanding. However, as it is we do not know what your underlying problem is, so we can not begin to help. Assuming you tried to solve it yourself and got stuck, it may be helpful if you wrote your thoughts and what you could not figure out. I don't see a question here, just a demand for us to solve this exercise for you. – D.W. Apr 23 '16 at 18:58
  • We get this kind of question a lot, so we have written some reference material to help you with this: http://cs.stackexchange.com/q/1331/755, http://cs.stackexchange.com/questions/18524/how-to-prove-that-a-language-is-context-free/, http://meta.cs.stackexchange.com/a/843/755. Please work through the related questions listed there, try to solve your problem again, and edit to include your attempts along with the specific problems you encountered in the question. Also, it's not clear what you're asking: it's not clear what you mean by w={a,b}. Please edit to clarify what you're asking. – D.W. Apr 23 '16 at 19:00

1 Answers1

0

The answer goes something like this

S->ε/ aSb

S->A

A->ε/ aAa / bAb

here is a sample string for the above with proof

aabaabbb

S=>aSb

S=>aaSbb

S=>aaAbb

S=>aabAbbb

S=>aabaAabbb

S=>aabaεabbb

S=>aabaabbb

here above symbol ε is epsilon