Recall warm-up
- Why does |xy| ≤ p matter when proving aⁿbⁿ non-regular?
Stuck? Peek at 2.4.3 Pumping lemma for regular languages
- L regular ⇒ ∃p ∀w ∈ L, |w| ≥ p, ∃ xyz: |xy| ≤ p, |y| ≥ 1, ∀i ≥ 0: xyⁱz ∈ L. p = #states.
- Game: they pick p and split; you pick w and i. Beat every split.
- Standard picks: aᵖbᵖ; a^{p²}; aᵖbaᵖb (ww); prime q ≥ p+2 with i = q+1.
- Necessary, not sufficient. Finite languages pass vacuously.
- Is a regular language closed under reversal?
Stuck? Peek at 2.4.1 Closure properties of regular languages
- Closed: ∪ ∩ − complement, concat, *, ⁺, reversal, homomorphism, inverse homomorphism, quotient (by any language), prefix, suffix, substring, substitution, finite ∪/∩.
- Not guaranteed: infinite ∪/∩, subset, superset.
- Prove non-regular: L ∩ R non-regular (R regular) ⇒ L non-regular.
- Minimal DFA states for binary numbers divisible by 6?
Stuck? Peek at 1.1.3 DFA design patterns
Language (|w| = k pattern) Minimal states starts with w k + 2 contains w / ends with w k + 1 |x| ≡ r mod n n |x| = k, |x| ≤ k k + 2 |x| ≥ k k + 1 #a mod m and/or #b mod n m·n (typical) binary value ≡ 0 mod k, k odd k binary ÷ 2ʲ j + 1 k-th symbol from start fixed k + 2 Divisibility update: r ← (base·r + digit) mod k.
The Hook
In the exam you don’t write pumping proofs. You see a list of 4 languages and must tick the regular ones in about a minute. The skill is intuition about memory: can a machine with a fixed number of states keep track of what is needed? This lesson gives you rules of thumb, then the traps where intuition lies.
Predict First
Regular or not: L = { w x wᴿ | w, x ∈ {a,b}⁺ }? (wᴿ is w reversed.)
Core Concept
Prediction check
Regular! Choose w to be just the first symbol: if a string starts and ends with the same symbol and has length ≥ 3, take w = that symbol and x = the middle. Conversely any such string starts and ends with the same symbol. So L = a(a+b)⁺a + b(a+b)⁺b. The famous trap: “wᴿ” looks like it needs memory, but x can absorb everything.
Rule 1 — bounded facts are regular
Counts modulo a constant, the last k symbols, whether a pattern has appeared, a count capped at a constant (“at least 3 a’s”, “at most 5”): all regular.
Rule 2 — unbounded comparison is not regular
Comparing two counts (#a = #b, n ≥ m, n = 2m), matching a string with its copy or reverse (ww, wwᴿ with |w| unrestricted), squares, primes, powers of 2: not regular.
Rule 3 — watch for bounds and finite sets
- { aⁿbⁿ : n ≤ 100 } is finite ⇒ regular.
- { aⁿbᵐ : n, m ≥ 0 } — no relation ⇒ a*b*, regular.
- { aⁿbᵐ : n + m is even } — only parity ⇒ regular.
- { aⁿbᵐ : n ≡ m (mod 3) } ⇒ regular (track (n − m) mod 3).
| language | verdict | why |
|---|---|---|
| aⁿbⁿ, n ≤ 1000 | regular | finite |
| aⁿbᵐ | regular | no relation: a*b* |
| aⁿbᵐ, n + m even | regular | parity only |
| aⁿbᵐ, n ≡ m (mod 3) | regular | (n − m) mod 3 |
Rule 4 — unary languages
Over a one-letter alphabet, L is regular iff the set of lengths is eventually periodic (from some point on, repeats with a fixed period). a^{2n}, a^{3n+1}, lengths ≥ 7: regular. Squares, primes, powers of 2, Fibonacci lengths: not regular.
Rule 5 — the x-absorbs-it trap
- { wxwᴿ : w, x ∈ Σ⁺ } regular (first = last symbol, length ≥ 3).
- { wxw : w, x ∈ Σ⁺ } regular by the same idea (first symbol reappears at the end).
- { wwᴿx : … } and { xwwᴿ } with w ∈ Σ⁺: careful — these require an even palindrome somewhere and are NOT regular in general unless x can absorb; {wwᴿ : w ∈ Σ*} itself is not regular.
- { ww : w ∈ {a}* } = (aa)* — regular (unary!).
| language | verdict |
|---|---|
| { wxwᴿ : w, x ∈ Σ⁺ } | regular |
| { wxw : w, x ∈ Σ⁺ } | regular |
| { wwᴿ : w ∈ Σ* } | not regular |
| { ww : w ∈ {a}* } | regular = (aa)* |
Rule 6 — the comparison that a DFA can still do
“#ab = #ba as substrings” is regular: in any binary string, the number of “ab” and “ba” occurrences differ by at most 1, and they are equal exactly when the first and last symbols are the same (or the string is short). Intuition can fail; when a weird comparison appears, look for such hidden structure.
Putting it together
- Ask what fact must be carried: bounded → regular; an exact comparison of unbounded counts → not regular.
- Finite languages and eventually periodic unary sets are regular.
- A free middle x often absorbs the hard part (wxwᴿ, wxw).
Visual
REGULAR NOT REGULAR
a*b* aⁿbⁿ
aⁿbᵐ, n+m even aⁿbᵐ, n ≥ m
#a ≡ #b (mod 3) #a = #b
aⁿbⁿ, n ≤ 1000 (finite) aⁿbⁿcⁿ
w x wᴿ (w,x ∈ Σ⁺) w wᴿ
ww over {a} = (aa)* ww over {a,b}
a^{2n+1} a^{n²}, a^{2ⁿ}, a^{prime}
#ab = #ba aⁿ bᵐ cⁿ⁺ᵐWorked Examples
Regular? L = { aⁿbᵐ : n ≥ 3, m ≤ 2 }.
Show the full solution
Yes: aaaa*(ε + b + bb). Bounds are constants.
Regular? L = { aⁿbᵐ : n ≠ m }.
Show the full solution
No. If it were, its complement intersected with a*b* would be regular: complement ∩ a*b* = { aⁿbⁿ } — not regular. Contradiction ⇒ L not regular.
Which are regular? (i) { aᵐbⁿ : m, n ≥ 1, m·n is even } (ii) { aⁿbⁿ⁺¹ } ∪ { aⁿbⁿ } (iii) { w ∈ {a,b}* : every prefix has at most 2 more a’s than b’s and at most 2 more b’s than a’s } (iv) { 0ⁿ : n is a multiple of 3 or of 5 }
Show the full solution
(i) m·n even ⇔ m even or n even: parity only ⇒ regular. (ii) still ties counts (m = n or n + 1) ⇒ not regular. (iii) the difference #a − #b stays in {−2,…,2} ⇒ bounded ⇒ regular (5 states + dead). (iv) eventually periodic (period 15) ⇒ regular. Answer: (i), (iii), (iv).
GATE Traps
- wxwᴿ with x ∈ Σ⁺ is regular; wwᴿ is not.
- Bounded differences (|#a − #b| ≤ k on all prefixes) are regular.
- { ww : w ∈ a* } = (aa)* is regular — unary changes everything.
- A finite language is always regular, however “complicated” its definition.
- Comparisons modulo a constant are regular; exact comparisons are not.
Memory Hook
Ask one question: “Could a goldfish with a fixed-size notebook do it?” Remainders, flags, last few symbols — yes. A running tally that can grow forever — no.
Connect the Dots
Phase 2 complete: regular languages have five equivalent descriptions, strong closure, algorithms for every question, and a clear boundary. Beyond that boundary are aⁿbⁿ, balanced brackets, palindromes. Phase 3 gives the machine its first unbounded memory — a stack — and meets the grammars that describe these languages.
Self-Test
- MSQ
Which are regular?
- { aⁿbᵐ : n, m ≥ 0 }
- { aⁿbⁿ : n ≥ 0 }
- { aⁿbᵐ : n ≡ m (mod 2) }
- { aⁿbⁿ : 0 ≤ n ≤ 10 }
- MCQ
{ w x wᴿ : w, x ∈ {0,1}⁺ } is:
- not regular
- regular
- finite
- empty
- MSQ
Over {a}, which are regular?
- { a^{n²} }
- { a^{3n+2} }
- { aⁿ : n ≥ 100 }
- { a^{2ⁿ} }
- MCQ
{ w ∈ {a,b}* : |w|ₐ = 2|w|_b } is:
- regular
- not regular
- finite
- equal to Σ*
- MCQ
{ w ∈ {a,b}* : #(ab) = #(ba) } (occurrences as substrings) is:
- regular
- not regular
- finite
- empty
Rule Card
- Bounded fact (mod, flag, last k, capped count, bounded difference) ⇒ regular.
- Exact comparison of two unbounded counts, ww, wwᴿ, squares, primes, 2ⁿ ⇒ not regular.
- Finite ⇒ regular. Unary: regular ⇔ lengths eventually periodic.
- wxwᴿ, wxw (x ∈ Σ⁺) regular. #ab = #ba regular. ww over one letter regular.
Concept Ledger
- regular-or-not intuition
- eventually periodic (unary)
- bounded difference
- absorbing middle (wxwᴿ)
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- It forces y to consist only of a’s.
- Yes.
- 4.
Self-test answers
- ACD — No relation, parity relation, finite.
- B: Unbounded comparison.
- B — First symbol = last symbol, length ≥ 3.
- A: x absorbs everything.
- C: Infinite.
- D: Non-empty.
- BC — Eventually periodic length sets.
- A: Gaps grow.
- D: Gaps grow.
- B — Intersect with a*b*: { a²ⁿbⁿ } — not regular.
- A: Exact comparison.
- C: Infinite.
- D: ab not in it.
- A — Equivalent to: |w| ≤ 1 or first symbol = last symbol.
- B: Looks like a comparison, but the counts differ by at most 1.
- C: Infinite.
- D: ε is in it.
Flashcards
- Is { w x wᴿ : w, x ∈ Σ⁺ } regular?
Reveal answer
Yes — same first and last symbol, length ≥ 3. - Is { aⁿbᵐ : n ≡ m mod 3 } regular?
Reveal answer
Yes. - When is a unary language regular?
Reveal answer
When its set of lengths is eventually periodic. - Is { w : #ab = #ba } regular?
Reveal answer
Yes. - Is { aⁿbᵐ : n ≠ m } regular?
Reveal answer
No (complement ∩ a*b* = aⁿbⁿ).
Exam shortcuts
- Regular-or-not in 10 seconds: (1) finite? → regular. (2) only remainders/flags/last-k/caps? → regular. (3) two unbounded quantities compared exactly? → not regular. (4) a free middle x? → it probably absorbs the hard part → regular.