grammarcontext-free-grammarautomata

How can I construct a grammar that generates this language?


I'm studying for a finite automata & grammars test and I'm stuck with this question:

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

I believe my productions should go along this lines:

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

How can my production for C remember the numbers of m and n? I'm guessing this must rather be a context-free grammar, if so, how should it be?


Solution

  • Seems like it should be like:

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

    You need to force C'c to be counted during construction process. In order to show it's context-free, I would consider to use Pump Lemma.