Let Ξ£ = {π, π, π}. For π₯ β Ξ£β , and πΌ β Ξ£, let #πΌ(π₯) denote the numberβ¦
2025
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.
{ππππ | π, π β₯ 0}
- B.
{π, π}β β© {ππππ ππβπ | π β₯ π β₯ 0}
- C.
{π€ | π€ β {π, π}β , #π (π€) β‘ 2 (mod 7), and #π (π€) β‘ 3 (mod 9)}
- D.
{π€ | π€ β {π, π}β , #π (π€) β‘ 2 (mod 7), and #π (π€) = #π(π€)}
Attempted by 82 students.
Show answer & explanation
Correct answer: A, C
Answer: The regular languages among the choices are {a^m b^n | m, n β₯ 0} and { w β {a,b}* | #a(w) β‘ 2 (mod 7) and #b(w) β‘ 3 (mod 9) }.
{a^m b^n | m, n β₯ 0} is regular because it equals the regular expression a*b*. A DFA can be built with a start/accepting state that loops on a, transitions on the first b to a second accepting state that loops on b; any string of a's followed by b's is accepted.
The set of strings where #a β‘ 2 (mod 7) and #b β‘ 3 (mod 9) is regular because only residues modulo fixed integers are constrained. A finite automaton can track (#a mod 7, #b mod 9) with at most 7Γ9 = 63 states and accept precisely the states with residues (2,3).
Intersecting {a,b}* with {a^m b^n c^{mβn} | m β₯ n β₯ 0} removes any strings containing c, forcing mβn = 0 and yielding {a^m b^m | m β₯ 0}. This language is a classic non-regular language (can be shown by the pumping lemma), so the intersection is not regular.
The language requiring #a β‘ 2 (mod 7) together with #a = #b remains non-regular because equality of the number of a's and b's is a non-regular property. Adding a modular constraint on #a does not remove the need for unbounded counting, so the language is non-regular (again, the pumping lemma can be used to prove this).
A video solution is available for this question β log in and enroll to watch it.