Grammar for a language

Grammar for a language

by SARA NIKNAM HESAR -
Number of replies: 1

Hello professor, I have a question. I was trying to solve this question and write a grammar for it    I have a language L={A^nB^m| n,m>=0} . The answer of was S->aS|B|ε and B->bB|ε and i solved like this S->aSB|ε and B->bB|ε and i tried to get help from Chatgpt and It responded to me it is not correct because it  cannot for example design the string {aaa} which the above grammar can, why i cannot have it if  in the second grammar I put ε every time instead of B I can generate three {aaa} . As the matter of fact I did not understand the intuition of the Chatgpt. Thanks in advance 

Attachment a.jpg
In reply to SARA NIKNAM HESAR

Re: Grammar for a language

by Giorgio Satta -
Dear Sara, your grammar is correct. ChatGPT is wrong here.

However notice that your grammar is unnecessarily complex, you generate many B's that may have later to turn into epsilon.