Consider the following context-free grammar 𝐺. π‘†β†’π‘Žπ‘π‘Žπ΄π΅π΄π‘π‘π‘Žβ€¦

2026

Consider the following context-free grammar 𝐺.

π‘†β†’π‘Žπ‘π‘Žπ΄π΅π΄π‘π‘π‘Ž

π΄β†’π‘Žπ‘Žπ΅π΅π΄π‘ | π‘π΅π‘Žπ‘π‘Žπ‘Ž

π΅β†’π‘Žπ΅π‘ | π‘Žπ‘

In the above grammar, 𝑆 is the start symbol, π‘Ž and 𝑏 are terminal symbols, and 𝐴 and B are non-terminal symbols.

Let 𝐿(𝐺) be the language generated by the grammar 𝐺. For a string π‘ βˆˆπΏ(𝐺), let n1(𝑠) be the number of π‘Žβ€™s in 𝑠 and 𝑛2(𝑠) be the number of 𝑏’s in 𝑠.

Which of the following statements is/are true?

Answer: B. For every string π‘ βˆˆπΏ(𝐺), 𝑛1(𝑠)β‰₯𝑛2(𝑠); D. For every string π‘ βˆˆπΏ(𝐺), 𝑛1(𝑠)≀2𝑛2(𝑠) β€” To determine the true statements, we analyze the balance of terminal symbols 'a' and 'b' in each production rule. First, consider non-terminal B. The…

  1. A.

    There is a string π‘ βˆˆπΏ(𝐺) such that 𝑛1(𝑠)<𝑛2(𝑠)

  2. B.

    For every string π‘ βˆˆπΏ(𝐺), 𝑛1(𝑠)β‰₯𝑛2(𝑠)

  3. C.

    There is a string π‘ βˆˆπΏ(𝐺) such that 𝑛1(𝑠)>2𝑛2(𝑠)

  4. D.

    For every string π‘ βˆˆπΏ(𝐺), 𝑛1(𝑠)≀2𝑛2(𝑠)

Attempted by 24 students.

Show answer & explanation

Correct answer: B, D

To determine the true statements, we analyze the balance of terminal symbols 'a' and 'b' in each production rule.

First, consider non-terminal B. The productions are B β†’ aBb | ab. In both cases, the number of 'a's equals the number of 'b's generated directly or recursively. Thus, for any string derived from B, n1 = n2.

Next, analyze non-terminal A. Production 1 (aaBBAb) adds more 'a's than 'b's and includes A recursively. Production 2 (bBabaa) adds more 'a's than 'b's and includes B. Derivation shows that for any string from A, n1 > n2.

Finally, analyze the start symbol S (ab a A B A b b a). It adds more 'a's than 'b's directly and includes two instances of A (where n1 > n2) and one B (n1 = n2). The total count confirms that for any string s in L(G), the number of 'a's is strictly greater than the number of 'b's.

Based on this analysis, the statements corresponding to options 1 and 3 are true.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…