S → abaABAbba
A → aaBBAb | bBabaa
B → aBb | ab
L(G) is the language generated by the grammar. For a string s ∈ L(G), let n1(s) be the number of a's in s and n2(s) be the number of b's in s. Which of the following is/are correct?
Correct : a,d
The correct answers are A and D.
The key insight is to compute the fixed difference d = n1(s) - n2(s) for all strings in L(G) by analyzing each production rule.
For B → ab: n1 - n2 = 1 - 1 = 0. So dB = 0.
For A → aaBBAb: n1 - n2 = 2 + 2×0 - 1 + 1 = 2. So dA = 2. (Both A-rules give 2 — consistent.)
For S → abaABAbba: n1 - n2 = (4-3) + dA + dB + dA = 1 + 2 + 0 + 2 = 5.
So for every string s ∈ L(G): n1(s) = n2(s) + 5.
• A (n1 ≥ n2): Always true since n1 = n2 + 5 > n2.
• B (n1 ≥ 2n2 for some s): Would need n2 ≤ 5, but the minimum n2 in any generated string is large (many b"s come from A and B productions), so this is false.
• C (n1 < n2): Always false since n1 > n2.
• D (n1 ≤ 2n2): n2+5 ≤ 2n2 ⇒ n2 ≥ 5. Since all strings have n2 well above 5, this always holds.
Similar Questions
Total Unique Visitors