0
$\begingroup$

Given the following language, I am tasked with giving a context-free grammar that generates it.

$\left \{ a^{3n}b^{m}c^{n}|n>0, m>0\right \}$

Would this be correct?

$A \rightarrow aaaA$
$B\rightarrow Bb | b$
$C\rightarrow Cc|c$
$S\rightarrow ASBSCS|\epsilon $

$\endgroup$
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$
    – D.W.
    Commented Nov 19, 2020 at 19:26

1 Answer 1

2
$\begingroup$

Unfortunately your grammar generates only $\epsilon$ (which is not in the language, since $n$ and $m$ are greater than 0), as you don't delete the $A$; moreover you don't control that the number of $A$'s is thrice the numeber of $C$'s.

You can try something like this:

$S\rightarrow aaaS'c$
$S' \rightarrow aaaS'c | B$
$B\rightarrow Bb | b$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.