Grammar for ${a^n b^n c^{n+m}}$

Problem Detail: Can we define a grammar for the following language? $$L = {a^n b^n c^{n+m} | n,m>=0},. $$ I can define one for this:
$$L={a^nb^n|n,m>=0} $$

S –> aSb | λ

or this one: $$L={b^nc^{n+m}|n,m>=0} $$

S –> Ac
A –> bSc | Sc | λ

but I can’t solve the first one, any hint?

Asked By : Amen

Answered By : d’alar’cop

This gives the language: $L = {a^n b^n c^n c^m | n,m>=0},. $

  1. S → a b c C | N | ε
  2. N → a N B c C | a b c
  3. c B → W B
  4. W B → W X
  5. W X → B X
  6. B X → B c
  7. b B → b b
  8. C → cC | ε
Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/30331

Leave a Reply