0
$\begingroup$

i can't find s-grammar(Simple grammar) for this language and s-grammar has the restricted form like

A -> ax

where A∈V, a∈T, x∈V*, and any pair (A, a) occurs at most once in production P.

how can i find the s-grammar for this language?

i found that the corresponding CFG for this language is:

S -> aaAbbbb,
A -> aAbb | ϵ
$\endgroup$
1

1 Answer 1

1
+50
$\begingroup$

First, there is the problem of the empty word. For that, just consider:

  • $S\to aaAbbbb\mid aabbbb$
  • $A \to aAbb \mid abb$

There is still the problem of multiple rules from the same variable beginning by the same terminal. For that, you'd need to be able to stop the derivation. For that, replace the rules by:

  • $S\to aaAbbb$
  • $A \to aAbb \mid b$

Then, may seem artificial, but you could just replace each apparition of a terminal in a rule not in the first position by a variable, and add a rule to replace this variable by the corresponding terminal.

For example, replace $S\to aaAbbb$ by $S \to aX_aAX_bX_bX_b$ and add rules:

  • $X_a \to a$,
  • $X_b \to b$.
$\endgroup$
2
  • 1
    $\begingroup$ Ha. I started this remark to complain the $S$-rule is missing a $b$, but I see now how the missing $b$ is used in the end. Nice! $\endgroup$ Commented Nov 24 at 13:40
  • 1
    $\begingroup$ @HendrikJan Hey! Thanks for the bounty! $\endgroup$
    – Nathaniel
    Commented Nov 30 at 12:14

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.