What is the language of the following CFG?

43 Views Asked by At

The CFG has the following productions where S is the start symbol, S and Y are non-terminals and a and b are terminals.

S → bb ∣ SY
Y → bYa | ba

1

There are 1 best solutions below

0
On

This is a very simple language: you can actually identify all of the possible derivations. If a derivation starts by applying $S\to bb$, you get the word $bb$. Otherwise, you get a derivation

$$S\Rightarrow SY\Rightarrow^n Sb^nYa^n\Rightarrow bbb^nYa^n\Rightarrow bbb^nbaa^n=bbb^{n+1}a^{n+1}$$

for some $n\ge 0$ (or a reordering of some of the steps that produces the same result). You can combine the two possibilities: the language is

$$\left\{bbb^na^n:n\ge 0\right\}=\left\{b^{n+2}a^n:n\ge 0\right\}\;.$$

This is the kind of analysis that you should try, at least as a first step, whenever the grammar is fairly simple.