How can I build a grammar that generates this language?

I am studying finite tests of automata and grammars, and I am stuck on this question:

Construct a grammar that generates L:
L = {a^n b^m c^m+n|n>=0, m>=0}

I believe that my productions should go like this:

    S->aA | aB
    B->bB | bC
    C->cC | c Here where I have doubts

How do my products for C remember the numbers m and n? I guess this is more of a non-contextual grammar, if so, how should it be?

+3
source share
5 answers

It looks like it should be like:

A->aAc | aBc | ac | epsilon
B->bBc | bc | epsilon

You need to get C'c to count during the construction process. To show this without context, I would consider using the "Pump Tray."

+6
source

Yes, that sounds like homework, but a hint:

, "a", "c". "b".

+2
S -> X
X -> aXc | Y
Y -> bYc | e

where e == epsilonand Xare not required but for clarity added

+2
source

S-> Asc | A-> BAC | λ

This means that when you get at least 1 c or get a and b, you must have 2 c. i hope this was helpful

0
source

Well guys, here's how I do it:

P={S::=X|epsilon,
   X::=aXc|M|epsilon,
   M::=bMc|epsilon}
0
source

Source: https://habr.com/ru/post/1710916/


All Articles