Let . For and , let denote the number of occurrences of in .
Which one or more of the following option(s) define(s) regular language(s)?
- (A)
- (B)
- (C)
- (D)
Let . For and , let denote the number of occurrences of in .
Which one or more of the following option(s) define(s) regular language(s)?
ANSWER
The regular languages are (A) and (C).
Official answer: A, CSource: Official answer key, GATE 2025 CS2 (IIT Roorkee)
(A) is exactly the language of the regular expression , so it is regular.
(B) A string in has no , so a string can lie in only when . The intersection is therefore . This language is not regular, by the pumping lemma. So (B) is not regular.
(C) The two conditions count different letters, so they can be tracked independently. A DFA keeps the pair in states. It starts at , reading adds 1 to the first coordinate (mod 7), reading adds 1 to the second coordinate (mod 9), and the only accepting state is . So (C) is regular.
(D) Call the language . Regular languages are closed under intersection, so if were regular then would be regular. A string in needs and , so .
This language is not regular. Suppose it had pumping length . Choose with and let . The pumped part lies inside the first symbols, so with . Then has , so it is not in the language. This contradicts the pumping lemma, so is not regular, and therefore is not regular.
The regular languages are (A) and (C).
KEY IDEA
Check each language by either giving a finite automaton (independent modular counters give a product DFA) or by intersecting with a simple regular set to expose a non-regular core such as .
WATCH OUT FOR
Treating (D) as regular because of the mod 7 condition, or missing that in (B) the intersection with removes every and forces , which leaves .
From the GATE 2025 CS2 paper. Every question of this paper · Download the full paper · All 5 Regular languages questions, with notes