$$S \rightarrow abaABabba$$
$$A \rightarrow aaBBAB \mid bBabaa$$
$$B \rightarrow aBb \mid ab$$
In the above grammar, $S$ is the start symbol, $a$ and $b$ are terminal symbols, and $A$ and $B$ are non-terminal symbols.
Let $L(G)$ be the language generated by the grammar $G$. For a string $s \in L(G)$, let $n_1(s)$ be the number of $a$’s in $s$ and $n_2(s)$ be the number of $b$’s in $s$.
Which of the following statements is/are true?
Productions for B:
By induction, all strings derived from $B$ satisfy $n_1(s) = n_2(s)$. Therefore, $n_1(s) \ge n_2(s)$ and $n_1(s) \le 2n_2(s)$ hold for all strings from $B$.
Productions for A:
Thus, for all strings derived from $A$, $n_1(s) \ge n_2(s)$ and $n_1(s) \le 2n_2(s)$ hold.
Production for S:
Statement 2: For every string $s \in L(G)$, $n_1(s) \ge n_2(s)$
Statement 4: For every string $s \in L(G)$, $n_1(s) \le 2n_2(s)$
Conclusion
Based on the analysis, statements 2 and 4 are true for all strings $s \in L(G)$.
| A | S $\rightarrow$ Ab aS$\rightarrow$ aA A$\rightarrow$ a | B | S $\rightarrow$ Ab A $\rightarrow$ Sa A $\rightarrow$ a |
| C | S $\rightarrow$ AS S $\rightarrow$ aA A$\rightarrow$ a | D | S $\rightarrow$ Ab S $\rightarrow$ aA A$\rightarrow$ a |
| E | S $\rightarrow$ Sb A $\rightarrow$ Aa A $\rightarrow$ $\varepsilon$ |
Which of the following grammars is (are)ambiguous ?
(1) S → SS | aSb | bSa |e
(2) S → aSbS | bSaS |e
(3) S → aAB
A → bBb
B → A Ι e
Consider the grammar,
G = S → abScB | e,
B→ bB | b.
What is the language generated by the given grammar ?
Consider the given grammar
S → Abc | ad
A → eS | Cr| ξ
C → f/p/ξ
Compute FIRST (A)
Select the sentence which is meaningful and grammatically correct.