$L_2$ is a set of all words where $w$ is an element of $A^*$ such that $w$ is a palindrome

22 Views Asked by At

I am not really good at generating grammars, because I find it very hard to come up with rules. However, after a lot of trial and error, this is what I could generate:

A={a,b} Vt={a,b} Vn={S,A,B} R= S->BS S->AS S->e A->a B->b

was this the correct way? if no, what could be improved? thank you!