This question already has an answer here:

I have a language L = {a^n b^m c^k | n = m or m != k} When I was working the problem out this is what I got:

S -> S1|S2

S1 -> AC
A -> aAb|$\lambda$
C -> Cc |$\lambda$

S2 -> BD
B -> aB|$\lambda$
D -> bDcc|E
E -> Ecc|$\lambda$

I feel like this is right but at the same time I am not too certain it is. Is this the correct solution?


marked as duplicate by David Richerby, Hendrik Jan, D.W. Apr 10 '17 at 16:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. $\endgroup$ – David Richerby Apr 10 '17 at 13:26
  • 1
    $\begingroup$ Looks to me like the grammar won't generate $abbc$. You're on the right track, though: think of three starts: one like your $S1$ to generate the $n=m$ part, one to generate the $m<k$ part and one for the $m>k$ part. $\endgroup$ – Rick Decker Apr 10 '17 at 14:14
  • $\begingroup$ Yes, rules for D and E generate a language smaller than required. $\endgroup$ – beroal Apr 10 '17 at 14:58
  • $\begingroup$ It looks like you might have accidentally created two accounts. I encourage you to merge them, to ensure you retain ability to edit and comment on your own question. $\endgroup$ – D.W. Apr 10 '17 at 16:41

Browse other questions tagged or ask your own question.