Language \(L_1\) is defined by the grammar: \(S_1 → aS_1b|ε\) Language \(L_2\)…

2016

Language \(L_1\) is defined by the grammar: \(S_1 → aS_1b|ε\)

Language \(L_2\) is defined by the grammar: \(S_2 → abS_2|ε\)

Consider the following statements:

\(P\)\(L_1\) is regular

\(Q\)\(L_2\) is regular

Which one of the following is TRUE?

  1. A.

    Both \(P\) and \(Q\) are true

  2. B.

    \(P\) is true and \(Q\) is false

  3. C.

    \(P\) is false and \(Q\) is true

  4. D.

    Both \(P\) and \(Q\) are false

Attempted by 127 students.

Show answer & explanation

Correct answer: C

Answer: P is false and Q is true.

Reasoning:

  • L1: The grammar S1 → a S1 b | ε generates L1 = { a^n b^n | n ≥ 0 }. This language is not regular. Sketch using the pumping lemma: assume a pumping length p and take s = a^p b^p. Any decomposition s = xyz with |xy| ≤ p forces y to consist only of a's and y ≠ ε. Pumping y down (taking y^0) gives fewer a's than b's, a string not in L1, contradicting regularity.

  • L2: The grammar S2 → ab S2 | ε generates L2 = { (ab)^n | n ≥ 0 }, which equals the regular expression (ab)*. This is regular — for example, a 2-state DFA can alternate expecting 'a' then 'b' and accept at the start/end.

Therefore P is false (L1 non-regular) and Q is true (L2 regular).

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir