-2

What language generated by the following context-free grammar 1) S------> SaS | b i already know the answer to question one but to prove it would is be something like this: S -----> SaaS -----> baab which can also be express as the language b(ab)* or (ba)*b

Another question is what does | b mean does it mean substitute into S afterwards?

2) S ----> AA

A----> aA | Aa | b

So for this question how can i start this? Would it be like S----> AA ----> aAaA ----> aAaAaA -----> abababa ? SO the language would be (ab)*?

Darkflame
  • 57
  • 1
  • 8

1 Answers1

1

The vertical bar indicates an alternative: $S\to SaS \mid b$ means there are two production rules in the grammar, $S\to SaS$ and $S\to b$. Since $b$ contains no variables it is like a final rule applied to a particular branch of the derivation-tree. But that does not mean the rule $S\to b$ has to be the postponed and applied to all occurrences of $S$ in the end.

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109