Skip to main content

Theory of Computation

Regular Properties

GATE asks “which of these languages is regular?” and “which closure property holds?”. Learn the pumping-lemma game, the closure table, and the short list of classic regular and non-regular languages.

~4 hrs ~1–1.5 marks · High 10 samples · 10 practice · 10 cards

GATE CSE properties of regular languages — pumping lemma (and how GATE uses it to prove non-regularity), closure under union, concatenation, star, complement, intersection and homomorphism, Myhill-Nerode idea, and regular vs non-regular language MCQs.

Learning outcomes

  • State the pumping lemma for regular languages and use it as a game to prove a language is NOT regular
  • Recall closure of regular languages under union, concatenation, star, complement, intersection, difference, reversal and homomorphism
  • Use closure properties (for example intersection with a*b*) to prove non-regularity indirectly
  • Classify classic languages as regular or non-regular and recognise decidable questions about regular languages

Closure properties of regular languages

  • Regular languages are closed under union, intersection, complement, difference, concatenation, Kleene star, reversal, homomorphism, inverse homomorphism, prefix/suffix closure and quotient with any language.
  • Union, concatenation and star follow from regular expressions; complement and intersection use a complete DFA (swap final states / product construction); reversal reverses the NFA arrows; homomorphism replaces each symbol by a string in the regex.
  • Closure is under FINITE operations only: an infinite union of regular languages need not be regular, e.g. ∪_{n ≥ 0} {a^n b^n} is the non-regular language {a^n b^n}.
  • An arbitrary subset of a regular language need not be regular: Σ* is regular, but {a^n b^n} ⊂ Σ* is not. Likewise a superset or an arbitrary language L with L ⊆ regular tells nothing.
  • If L1 ∪ L2 is regular, neither L1 nor L2 must be regular (take L1 = {a^n b^n} and L2 = Σ*, whose union is Σ*). Similarly L1 ∩ L2 can be regular even when both L1 and L2 are non-regular (for example disjoint non-regular languages with ∅ as the intersection).
  • Complement of a non-regular language is non-regular (otherwise complementing again would make the original regular). Concatenation or union of two non-regular languages can however be regular.
  • Homomorphism: h(L) is regular for regular L, but h of a non-regular language can be regular (for instance h mapping every symbol to ε).
  • Closure under these operations is the tool for indirect non-regularity proofs: if L were regular then L ∩ a*b* would be regular, which is false for L = {w | #a(w) = #b(w)}.
  • Constructions behind each closure: union/intersection → product DFA (m·n states); complement → complete DFA with F ↔ Q∖F (n states, no blow-up); reversal → reverse arrows of the NFA (DFA may need 2^n states); star/concatenation → ε-moves; difference L1 ∖ L2 = L1 ∩ complement(L2).
  • Quotient: L1 / L2 = {x | ∃y ∈ L2, xy ∈ L1} is regular for regular L1 and ANY L2 (even non-regular). Mark as final every state from which some string of L2 reaches a final state of the DFA for L1. Typical GATE use: init(L) = {x | ∃y xy ∈ L} is regular.
  • Inverse homomorphism h⁻¹(L) = {w | h(w) ∈ L} is regular; compute by running the DFA of L on the image h(a) for every symbol a. Homomorphic image can blow up the regex size but never leaves the regular class.
  • Closed ≠ size-preserving: complement keeps n states, product multiplies (m·n), reversal can blow up exponentially, and star on an NFA only adds one state plus ε-moves.
  • Special operations: min(L) = {w ∈ L | no proper prefix of w is in L} and max(L) are regular; cyclic shift, “half(L) = {x | ∃y, |y| = |x|, xy ∈ L}” are also regular (half is a classic hard example, proved by guessing the midpoint state with an NFA that simulates two copies of the DFA).
OperationRegular languages closed?
Union, intersection, complement, differenceYes
Concatenation, Kleene star, reversalYes
Homomorphism, inverse homomorphismYes
Prefix, suffix, quotientYes
Finite union / intersectionYes
Infinite unionNo
Arbitrary subset of a regular languageNo

Worked example

Problem. Show that L = {w ∈ {a,b}* | #a(w) = #b(w)} is not regular using closure properties.

Solution. If L were regular, then L ∩ L(a*b*) would be regular. But L ∩ a*b* = {a^n b^n | n ≥ 0}, which is non-regular (pumping lemma). Contradiction, so L is not regular.

Green panel of twelve operations under which regular languages are closed and red panel listing infinite union, infinite intersection and arbitrary subsets as not closed
Regular languages are closed under every finite Boolean and regular operation, but not under infinite unions or arbitrary subsets.

Pumping lemma for regular languages

  • Statement: if L is regular there is a pumping length p ≥ 1 such that EVERY string w ∈ L with |w| ≥ p can be written as w = xyz with (1) |y| ≥ 1, (2) |xy| ≤ p and (3) xy^i z ∈ L for all i ≥ 0.
  • Idea: a DFA with p states reading a string of length ≥ p must repeat a state within the first p symbols (pigeonhole). The loop y can be pumped up or down and the string is still accepted.
  • The lemma is a NECESSARY condition for regularity, never sufficient. A non-regular language may still satisfy it, so you can use it only to prove a language is NOT regular.
  • Proof by contradiction as a game: (1) assume L is regular with pumping length p; (2) YOU choose a string w ∈ L with |w| ≥ p (depending on p); (3) the opponent splits w = xyz with |xy| ≤ p, |y| ≥ 1; (4) YOU pick i such that xy^i z ∉ L; contradiction.
  • The choice of w must work for EVERY legal split. Because |xy| ≤ p, the segment y lies entirely inside the first p symbols of w — choose w so that its first p symbols are all the same (for example a^p b^p).
  • Pumping down (i = 0) is often the quickest: for {a^n b^n} with w = a^p b^p, y is all a’s, so xz has fewer a’s than b’s.
  • Standard w choices: {a^n b^n}: a^p b^p; {a^(n²)}: a^(p²); {ww}: 0^p 1 0^p 1; {a^n b^m : n > m}: a^(p+1) b^p with i = 0; {a^p : p prime}: a^q with q a prime ≥ p and i = q + 1.
  • Pumping lemma cannot show a language is regular. To prove regularity, give a DFA, NFA or regular expression.
  • Common mistakes: (a) choosing w that depends on a particular split instead of on p alone; (b) forgetting that |xy| ≤ p restricts WHERE y can lie; (c) assuming y is a single symbol — it can be any nonempty block inside the first p symbols; (d) trying i = 1, which never changes the string.
  • Pumping length is not unique: if p works then any p′ ≥ p works. A finite language has pumping length longer than its longest string (so the condition holds vacuously). A regular language with an n-state minimal DFA has p = n.
  • Quantifier order matters: ∃p ∀w ∃(split) ∀i for the lemma, so for the PROOF of non-regularity you flip to ∀p ∃w ∀(split) ∃i. Mixing the order is the usual source of wrong arguments.

Formulas to remember

  • L regular ⇒ ∃ p ∀ w ∈ L, |w| ≥ p ∃ xyz = w: |y| ≥ 1, |xy| ≤ p, ∀ i ≥ 0 xy^i z ∈ L
LanguageString wPump iWhy it fails
{a^n b^n}a^p b^p0 or 2y ⊆ a’s: a’s ≠ b’s
{a^(n²)}a^(p²)2p² < p² + |y| ≤ p² + p < (p+1)²
{ww}0^p 1 0^p 12y ⊆ first block of 0s: halves differ
{a^p : p prime}a^q, q ≥ p primeq + 1length q(1 + |y|) is composite
{a^n b^m : n > m}a^(p+1) b^p0a’s drop to ≤ b’s

Worked example

Problem. Show L = {a^(n²) | n ≥ 0} is not regular.

Solution. Assume regular with pumping length p. Take w = a^(p²). Then y = a^k with 1 ≤ k ≤ p. Pumping once gives length p² + k with p² < p² + k ≤ p² + p < (p + 1)², so it lies strictly between two consecutive squares and is not a square. Contradiction, so L is not regular.

A string w split into blocks x, y and z with |xy| at most p and |y| at least 1, rows showing xz, xyz and xyyz, and a DFA with a loop on y
Pumping lemma: the loop y sits inside the first p symbols and can be repeated or removed.

Worked example — pumping lemma for palindromes

  • Claim: PAL = {w ∈ {a,b}* | w = w^R} is not regular. Assume it is regular with pumping length p.
  • Choose w = a^p b a^p. It is a palindrome of length 2p + 1 ≥ p, so w ∈ PAL. The special middle b prevents the opponent from finding a symmetric split.
  • Any split w = xyz with |xy| ≤ p puts y strictly inside the first block of a’s, so y = a^k for some k with 1 ≤ k ≤ p.
  • Pump up with i = 2: xy²z = a^(p+k) b a^p. The left block has p + k a’s, the right block has p a’s, and k ≥ 1, so the string is not a palindrome — a contradiction.
  • Why not w = a^p a^p? That string a^(2p) stays a palindrome after pumping (still all a’s), so the proof would fail. A good w must make pumping break a symmetry or a count.
  • The same template proves {ww^R}, {ww} and {w c w} non-regular: choose w with a uniform first block, a unique separator, and a mirrored second half.
  • Odd and even palindromes are both non-regular, but palindromes over a ONE-letter alphabet are just a*, which is regular — alphabet size matters.
StepMoveResult
1Assume regular, pumping length pp ≥ 1 fixed by the opponent
2Pick w = a^p b a^ppalindrome, |w| = 2p + 1
3Any split has y = a^k, 1 ≤ k ≤ py inside the first block
4Pump i = 2a^(p+k) b a^p
5Compare with its reversenot a palindrome ⇒ contradiction

Worked example

Problem. Show that L = {0^n 1 0^n | n ≥ 0} is not regular.

Solution. Assume regular with pumping length p and take w = 0^p 1 0^p ∈ L. Because |xy| ≤ p, y = 0^k with 1 ≤ k ≤ p. Then xz = 0^(p−k) 1 0^p has fewer 0s before the 1 than after it, so xz ∉ L. This contradicts the pumping lemma, so L is not regular.

Worked example — proving non-regularity by closure

  • Goal: show L = {a^n b^m | n ≠ m} is not regular without running the pumping lemma on L itself.
  • Step 1: assume L is regular. Regular languages are closed under complement, so L̄ (over {a, b}) would be regular.
  • Step 2: intersect with the regular language a*b*: L̄ ∩ a*b* would be regular (closure under intersection).
  • Step 3: compute that intersection. A string a^n b^m is in L̄ exactly when NOT (n ≠ m), i.e. n = m. So L̄ ∩ a*b* = {a^n b^n | n ≥ 0}.
  • Step 4: {a^n b^n} is not regular (pumping lemma or Myhill-Nerode), a contradiction. Hence L is not regular.
  • Template: reduce a new language to a known non-regular one using only operations under which regular languages are closed (∩ with a*b*, complement, homomorphism, inverse homomorphism, quotient).
  • Homomorphism variant: to show {0^n 1^n 2^n} is non-regular, take h(0) = a, h(1) = b, h(2) = ε; h(L) = {a^n b^n} which is non-regular, so L cannot be regular (homomorphic images of regular sets are regular).
  • Warning: closure rules go ONE way. “L ∩ R regular” does not imply L regular; the argument only works when the operation preserves regularity.

Formulas to remember

  • L regular ⇒ complement(L) regular ⇒ complement(L) ∩ a*b* regular
  • L = {a^n b^m | n ≠ m}: complement(L) ∩ a*b* = {a^n b^n}
GivenIs the result regular?Why
L1 regular, L2 non-regular: L1 ∪ L2Not necessarilyL1 = Σ*, L2 = {a^n b^n} gives Σ*, but L1 = ∅ gives L2
L1, L2 both non-regular: L1 ∪ L2Can beL and complement(L) union to Σ*
L non-regular: complement(L)Never regularcomplement twice would make L regular
L regular: any subset of LNot necessarily{a^n b^n} ⊂ a*b*
L regular: h(L), h⁻¹(L), L^R, L*Alwaysclosure properties

Worked example

Problem. Is {0^n 1^n 2^n | n ≥ 0} regular? Argue with a homomorphism.

Solution. No. Let h(0) = a, h(1) = b, h(2) = ε. Then h({0^n 1^n 2^n}) = {a^n b^n}, which is not regular. Regular languages are closed under homomorphism, so if {0^n 1^n 2^n} were regular, {a^n b^n} would be too — a contradiction.

Classic regular vs non-regular languages

  • Non-regular (needs unbounded counting or matching): {a^n b^n}, {a^n b^m | n > m}, {a^n b^m | n ≠ m}, {w | #a = #b}, {ww}, {ww^R} (even palindromes), palindromes, {a^(n²)}, {a^(2^n)}, {a^p | p prime}, {a^n b^(n²)}, {a^i b^j | i > j}.
  • Regular (bounded memory suffices): {a^i b^j | i, j ≥ 0} = a*b*, {w | #a(w) mod m = r}, {w | |w| is even}, strings with a fixed substring, ending/starting patterns, and ANY finite language.
  • Surprising regular languages: {xy | x, y ∈ {a,b}*, |x| = |y|} = even-length strings; {w ∈ {0,1}* | #01(w) = #10(w)} = strings that are empty or start and end with the same symbol; {a^n b^n | n ≤ 10^6} is finite hence regular.
  • A language with a bounded (constant) amount of counting is regular: “number of a’s is at most 5” and “#a mod 3 = 0” are regular, but “#a = #b” is not.
  • Every finite language is regular; every subset of a finite language is finite and so regular. Unary context-free languages are regular (Parikh), but this is not needed for most MCQs.
  • {a^n b^m c^(n+m)} and {a^n b^m | n ≠ m} are non-regular. The second follows because its complement intersected with a*b* gives {a^n b^n}.
  • Ask whether the machine must remember an UNBOUNDED quantity (a count, a prefix to compare). If yes, the language is not regular; if only a constant amount (parity, remainder, last k symbols), it is regular.
  • Mixed cases that look hard: {w | #a(w) − #b(w) ≡ 0 (mod 3)} is regular (3 states track the difference mod 3), but {w | #a(w) − #b(w) = 0} is not; {a^n b^m | n + m is even} is regular; {a^n b^m | n·m is even} is regular too (n·m is even exactly when n or m is even, a union of two simple languages).
  • Subset trap: {a^n b^n | n ≥ 0} ⊂ a*b*, and a*b* is regular, yet the subset is not. Similarly L = {a^p | p prime} is a subset of a* (regular) and is not regular.
LanguageRegular?Reason
{a^n b^n | n ≥ 0}Nounbounded counting
{w | #a(w) = #b(w)}Nounbounded counting
{ww}Nomust remember first half
{xy | |x| = |y|}Yeseven length strings
{w | #01 = #10}Yesfirst symbol = last symbol
{a^p | p prime}Nopumping changes primality
{a^n b^n | n ≤ 10^6}Yesfinite language

Worked example

Problem. Is L = {xy | x, y ∈ {a,b}*, |x| = |y|} regular?

Solution. Since x and y can be any strings with the same length, xy can be any even-length string. L = ((a+b)(a+b))*, which is regular, even though it looks like it needs matching.

Nested regions for finite languages inside regular languages inside all languages, listing regular examples inside and non-regular examples outside
Finite ⊂ regular ⊂ all languages: bounded memory stays inside, unbounded counting falls outside.

Myhill-Nerode idea and decision problems

  • Myhill-Nerode: define x ~_L y iff for every z, xz ∈ L ⇔ yz ∈ L. L is regular iff ~_L has finitely many equivalence classes; the number of classes equals the size of the minimal DFA.
  • To show non-regularity with Myhill-Nerode, exhibit infinitely many strings that are pairwise distinguishable. For {a^n b^n}, the strings a^i and a^j (i ≠ j) are distinguished by the suffix b^i, so there are infinitely many classes.
  • To get the minimal DFA size, count the distinct “futures” of prefixes. For “ends with 01” the three futures are those after ε, 0 and 01, giving 3 states.
  • Decision problems for regular languages given as DFA / NFA / regex are all decidable: membership (simulate), emptiness (reachability of a final state), finiteness (a cycle on a path from the start to a final state means infinite), equivalence (minimal DFAs are isomorphic or the symmetric difference is empty), universality, and containment.
  • Finiteness test: L(DFA) is infinite iff there is a string of length n ≤ |w| < 2n accepted by the DFA with n states.
  • Closure tool to test equivalence: L1 = L2 iff (L1 ∖ L2) ∪ (L2 ∖ L1) = ∅, and emptiness is checkable on the product DFA.

Formulas to remember

  • x ~_L y ⇔ ∀z (xz ∈ L ⇔ yz ∈ L)
  • |min DFA| = number of ~_L classes
Problem for a DFA / regexDecidable?Method
Membership (w ∈ L?)YesSimulate the DFA
Emptiness (L = ∅?)YesNo final state reachable
Finiteness (L finite?)YesNo cycle on a start → final path
Equivalence (L1 = L2?)YesSymmetric-difference DFA is empty
Universality (L = Σ*?)YesComplement is empty

Worked example

Problem. Use Myhill-Nerode to show {a^n b^n} is not regular.

Solution. For i ≠ j, the strings a^i and a^j are distinguished by the suffix b^i: a^i b^i ∈ L but a^j b^i ∉ L. So the language has infinitely many Myhill-Nerode classes and cannot be regular.

GATE exam tricks — pumping lemma and closure MCQs

  • GATE uses the pumping lemma only to show NON-regular. A statement “L satisfies the pumping lemma, therefore L is regular” is always false as a reasoning rule.
  • Statement “an infinite union of regular languages is regular” is FALSE; “a finite union of regular languages is regular” is TRUE. Similarly “every subset of a regular language is regular” is FALSE.
  • When asked “which language is regular”, look for bounded memory: parity, modulo, fixed suffix/prefix/substring or finite. Reject equal counts, squares, primes, powers of 2, ww and palindromes.
  • Indirect proof: to show {a^n b^m | n ≠ m} is non-regular, note that if it were regular its complement intersected with a*b* would be regular, but that intersection is {a^n b^n}.
  • Check homomorphism questions by applying h to a typical string: h(0) = aa, h(1) = ε sends (01)* to (aa)*.
  • Emptiness, finiteness, membership and equivalence are all decidable for regular languages given as DFA / NFA / regex. Questions listing these as “undecidable” are distractors; undecidability appears only for CFG equivalence and TM problems.

Worked example

Problem. L1 is regular and L1 ∪ L2 is regular. Must L2 be regular?

Solution. No. Take L1 = Σ* (regular) and L2 = {a^n b^n}. Then L1 ∪ L2 = Σ* is regular but L2 is not.

Exam tips

  • Use the pumping lemma only to disprove regularity; never to prove it.
  • Pick a string whose first p symbols are identical, so that y is forced to be a block of one symbol.
  • Use closure (intersection with a*b*, complement) to reduce unfamiliar languages to {a^n b^n}.
  • Ask “does the machine need unbounded memory?” — if yes, the language is not regular.
  • Finite unions and finite languages stay regular; infinite unions and arbitrary subsets may not.
Exam pattern · 10 questions

GATE sample questions & answers

10 GATE-style MCQs for Regular Properties with full explanations. Attempt each question before revealing the answer.

Q1 Surprising regular language

Which of the following languages over {0, 1} is regular?

  • A) {0^n 1^n | n ≥ 1}
  • B) {ww | w ∈ {0,1}*}
  • C) {0^(n²) | n ≥ 1}
  • D) {w | the number of occurrences of 01 in w equals the number of occurrences of 10}
Show answer & explanation

Answer: D

Occurrences of 01 and 10 alternate along the string, so their counts are equal exactly when the first and last symbol of w coincide (or w is empty). That is a regular condition. A, B and C need unbounded memory.

Q2

Let L be a regular language. Which of the following is NOT necessarily regular?

  • A) L*
  • B) The reversal of L
  • C) An arbitrary subset of L
  • D) The complement of L
Show answer & explanation

Answer: C

Regular languages are closed under star, reversal and complement, but a subset of a regular language can be non-regular (e.g., {a^n b^n} ⊂ Σ*).

Q3

To prove that {a^n b^n | n ≥ 0} is not regular with the pumping lemma, take w = a^p b^p. For any split w = xyz with |xy| ≤ p and |y| ≥ 1, the substring y consists of:

  • A) only b’s
  • B) a’s and b’s
  • C) only a’s
  • D) is empty
Show answer & explanation

Answer: C

Because |xy| ≤ p, both x and y lie in the initial block a^p, so y = a^k with k ≥ 1. Pumping changes the number of a’s but not the b’s.

Q4

Which of the following languages is NOT regular?

  • A) {a^n | n is even}
  • B) {a^p | p is a prime number}
  • C) {w ∈ {a,b}* | w has an even number of a’s}
  • D) {a^n b^m | n, m ≥ 1}
Show answer & explanation

Answer: B

The set of prime lengths is not periodic. Pumping a^q (q prime) i = q + 1 times gives length q(1 + |y|), which is composite.

Q5

Which technique correctly shows that L = {w ∈ {a,b}* | #a(w) = #b(w)} is not regular?

  • A) L is a subset of (a + b)*
  • B) L ∩ a*b* = {a^n b^n} is not regular but regular languages are closed under intersection
  • C) The complement of L is regular
  • D) L is infinite
Show answer & explanation

Answer: B

If L were regular then L ∩ a*b* would be regular because regular languages are closed under intersection. But that intersection is {a^n b^n}, which is not regular.

Q6

Let h(0) = aa and h(1) = ε be a homomorphism. If L = (01)*, then h(L) is:

  • A) (aa)*
  • B) a*
  • C) (aaa)*
  • D) not regular
Show answer & explanation

Answer: A

Each 01 maps to aa·ε = aa, so h((01)*) = (aa)*, which is regular.

Q7

The number of Myhill-Nerode equivalence classes of L = {w ∈ {a,b}* | |w| is divisible by 4} is:

  • A) 2
  • B) 4
  • C) 5
  • D) infinite
Show answer & explanation

Answer: B

A prefix is characterised by its length mod 4, giving 4 classes, so the minimal DFA has 4 states.

Q8

L1 ∪ L2 is regular and L1 is regular. Which statement is correct?

  • A) L2 must be regular
  • B) L2 need not be regular
  • C) L2 must be finite
  • D) L2 must be empty
Show answer & explanation

Answer: B

Take L1 = Σ* and L2 = {a^n b^n}: L1 ∪ L2 = Σ* is regular but L2 is not.

Q9

If a language L satisfies the conditions of the pumping lemma for regular languages, then L is:

  • A) always regular
  • B) not necessarily regular
  • C) always non-regular
  • D) always finite
Show answer & explanation

Answer: B

The pumping lemma is only a necessary condition. For example {a^i b^j c^k | i = 1 ⇒ j = k} is non-regular yet satisfies the pumping property.

Q10

Which of the following languages is regular?

  • A) {ww | w ∈ {a,b}*}
  • B) {xy | x, y ∈ {a,b}*, |x| = |y|}
  • C) {a^n b^n | n ≥ 0}
  • D) {a^(2^n) | n ≥ 0}
Show answer & explanation

Answer: B

Since x and y are arbitrary, xy ranges over all even-length strings, i.e. ((a+b)(a+b))*, which is regular. A, C and D are not regular.

Topic drill · 10 questions

10 practice questions — Regular Properties

Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.

P1

A complete minimal DFA for L has n states. The minimal DFA for the complement of L has:

  • A) n − 1 states
  • B) n states
  • C) 2n states
  • D) 2^n states
Show answer & explanation

Answer: B) n states

Swapping final and non-final states of a complete DFA keeps it minimal with the same number of states.

P2

Which of the following languages over {0, 1} is regular?

  • A) {0^n 1^n | n ≥ 0}
  • B) {0^n 1^m | n + m is even}
  • C) {0^n 1^(2n) | n ≥ 0}
  • D) {0^(n²) | n ≥ 0}
Show answer & explanation

Answer: B) {0^n 1^m | n + m is even}

n + m is even iff n and m have the same parity: (00)*(11)* + 0(00)*1(11)*. Only parities must be remembered, so it is regular.

P3

If L = a(a + b)*, the reversal L^R is:

  • A) a(a + b)*
  • B) (a + b)*a
  • C) (a + b)*
  • D) a*b*
Show answer & explanation

Answer: B) (a + b)*a

Reversing every string that starts with a gives strings that end with a: (a + b)*a.

P4

Is the union of an infinite family of regular languages always regular?

  • A) Yes, always
  • B) No, not necessarily
  • C) Yes, but only if each language is finite
  • D) Only if they are pairwise disjoint
Show answer & explanation

Answer: B) No, not necessarily

{a^n b^n | n ≥ 0} is the union over n of the single-string languages {a^n b^n}, yet it is non-regular. Closure holds only for finite unions.

P5

A finite language has a longest string of length 6. A valid pumping length p for this language is:

  • A) 5
  • B) 6
  • C) 7
  • D) 0
Show answer & explanation

Answer: C) 7

With p = 7 no string has length ≥ p, so the pumping condition is vacuously true. p must exceed the longest string length.

P6

The minimum number of states in a DFA for {a^n | n is a multiple of 3 or a multiple of 5} is:

  • A) 8
  • B) 15
  • C) 5
  • D) 3
Show answer & explanation

Answer: B) 15

The language is periodic with minimal period 15, so the minimal DFA is a cycle of 15 states.

P7

To prove that {ww | w ∈ {0,1}*} is not regular via the pumping lemma, a suitable string is:

  • A) 0^p 0^p
  • B) 0^p 1 0^p 1
  • C) (01)^p
  • D) 1^p 0^p
Show answer & explanation

Answer: B) 0^p 1 0^p 1

Since |xy| ≤ p, y lies in the first block 0^p; pumping changes the length of the first half only, so the two halves differ. The string 0^p 0^p fails as a choice because the opponent can pick y = 00 and every pumped string 0^(2p+2i−2) is still of the form ww.

P8

If L is non-regular and h is a homomorphism, then h(L) is:

  • A) always non-regular
  • B) always regular
  • C) not necessarily non-regular
  • D) always finite
Show answer & explanation

Answer: C) not necessarily non-regular

If h maps every symbol to ε, then h(L) ⊆ {ε} is regular for every L.

P9

If L1 and L2 are both non-regular, then L1 ∩ L2:

  • A) is always non-regular
  • B) is always regular
  • C) can be regular
  • D) is always empty
Show answer & explanation

Answer: C) can be regular

For instance L1 = {a^n b^n} and L2 = {a^n b^(n+1)} are disjoint non-regular languages, so L1 ∩ L2 = ∅ is regular.

P10

For L = {a^n b^n | n ≥ 0}, the number of Myhill-Nerode equivalence classes is:

  • A) 2
  • B) n
  • C) finite but large
  • D) infinite
Show answer & explanation

Answer: D) infinite

The prefixes a^i (i ≥ 0) are pairwise distinguishable using suffix b^i, giving infinitely many classes, so L is not regular.

Topic FAQs

Can the pumping lemma prove that a language is regular?

No. It is a necessary condition for regularity. A non-regular language can satisfy the pumping property, so you only use it to prove non-regularity by contradiction.

Why must the pumped substring lie within the first p symbols?

The lemma guarantees |xy| ≤ p, so y is inside the first p symbols. Choosing w with a uniform first block (such as a^p) forces y to consist of that symbol alone.

Are regular languages closed under infinite union?

No. {a^n b^n} is the union over n of the finite (hence regular) languages {a^n b^n}, but it is not regular.

Is the complement of a non-regular language regular?

No. If the complement were regular, then complementing it again would make the original language regular, a contradiction.

Quick revision · 10 cards

10 flashcards — Regular Properties

Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.

Q1 What does the pumping lemma for regular languages state?
Q2 Can the pumping lemma be used to prove that a language is regular?
Q3 Why is the pumping lemma true for a DFA with p states?
Q4 Under which operations are regular languages closed?
Q5 Is a subset of a regular language always regular?
Q6 How can you prove that {w | #a(w) = #b(w)} is not regular without the pumping lemma?
Q7 What does the Myhill-Nerode theorem say about regular languages?
Q8 Which questions about a regular language given as a DFA are decidable?
Q9 Is every finite language regular?
Q10 What is the quickest test for whether a language is likely to be regular?