0

I am writing this CFG to solve the problem:

$S \to ASBSC$

$A \to aAe ~|~ ε$

$B \to aBd ~|~ ε$

$C \to bcC ~|~ ε$

Is this correct or not?

Kai
  • 865
  • 5
  • 16
Yousaf
  • 1
  • 1
  • 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. – D.W. Apr 09 '23 at 20:57
  • 1
    The way to verify that your grammar is correct is to prove it correct. See https://cs.stackexchange.com/q/11315/755 for the techniques. – D.W. Apr 09 '23 at 21:16
  • Sorry, but your grammar is totally wrong. I mean really completely totally wrong. For example, the last rule creates strings like bcbcbcbc which are not in the language. Looks like you asked some "Artificial Idiocy" like ChatGPT for an answer and try to check it. – gnasher729 Nov 24 '23 at 10:31

1 Answers1

0

Strings in your grammar could potentially terminate with a sequence of $bc$s because of the following, which is not desired.

$S \rightarrow ASBSC$

$C \rightarrow bcC \ | \ \epsilon$


The correct grammar in this case would be:

$S \rightarrow aSe \ | \ A \ | \ \epsilon$

$A \rightarrow aAd \ | \ B \ | \ \epsilon$

$B \rightarrow bBc \ | \ \epsilon$

ihsingh2
  • 35
  • 6