Recall warm-up
- Which grammar shapes generate exactly the regular languages?
Stuck? Peek at 2.3.2 Right-linear and left-linear grammars
- Right-linear: A → wB | w. Left-linear: A → Bw | w. Regular grammar = one of the two (not mixed).
- DFA → grammar: δ(A,a)=B ⇒ A → aB; A accepting ⇒ A → ε.
- Grammar → NFA: A → aB is an arrow; A → a goes to a new accepting state.
- Mixed linear can give aⁿbⁿ. Non-regular grammar does not imply non-regular language.
- Product construction: accepting set for L₁ − L₂?
Stuck? Peek at 1.1.4 Product construction and complement
- Product: states Q₁×Q₂, δ((p,q),a) = (δ₁(p,a), δ₂(q,a)), start (s₁,s₂).
- ∩: F₁×F₂. ∪: F₁×Q₂ ∪ Q₁×F₂. −: F₁×(Q₂−F₂). ≤ |Q₁|·|Q₂| states.
- Complement: complete the DFA (add dead state), swap F ↔ Q−F; same state count.
- Regular languages closed under ∪, ∩, −, complement.
- Thompson: how is r* built?
Stuck? Peek at 2.2.1 Regex → ε-NFA (Thompson construction)
- Invariant: one start (no in-moves), one accept (no out-moves).
- ∅, ε, a: 2 states. r+s: +2 states, 4 ε. rs: ε from accept(r) to start(s). r*: +2 states, 4 ε (enter, skip, loop back, exit).
- States ≤ 2 × (symbols + operators). Regex → ε-NFA → DFA proves regex ⇒ regular.
The Hook
You know L₁ is regular and L₂ is regular. Is “strings in L₁ that are not in L₂, reversed” regular? Instead of designing a DFA each time, mathematicians proved once and for all which operations keep a language regular. In GATE, closure questions are free marks — if you know the table and the classic traps.
Predict First
Each of L₁ = {aⁿbⁿ} and its complement are not regular. Can the union of two non-regular languages be regular?
Core Concept
Prediction check
Yes. {aⁿbⁿ} ∪ complement({aⁿbⁿ}) = Σ*, which is regular. Closure only promises: regular in ⇒ regular out. It says nothing when inputs are non-regular.
Closed: the full list
| Operation | Why it stays regular |
|---|---|
| Union, intersection, difference | product construction (1.1.4) |
| Complement | swap F in a complete DFA |
| Concatenation, Kleene star, plus | regex operations / Thompson |
| Reversal Lᴿ | reverse every arrow, new start with ε to old accepting states, old start becomes accepting |
| Homomorphism h(L) | substitute h(a) for a in the regex |
| Inverse homomorphism h⁻¹(L) | DFA reads a, simulates the original DFA on the string h(a) |
| Quotient L/M (L regular, M any language) | same DFA, new accepting set: states from which some string of M reaches F |
| Prefix(L), Suffix(L), Substring(L) | prefix: make accepting every state that can reach F |
| Substitution by regular languages, finite union/intersection | regex substitution / repeated product |
Homomorphism
Example: h(a) = 01, h(b) = ε. h(a*b) = (01)*. For L = (01)*, h⁻¹(L) = {w : h(w) ∈ (01)*} = all strings over {a, b} (every h(w) is (01)ᵏ).
| w | h(w) |
|---|---|
| a | 01 |
| b | ε |
| ab | 01 |
| aab | 0101 |
Quotient and prefix
Example: L₁ = a*b, L₂ = b ⇒ L₁/L₂ = a*. If L₁ is regular, L₁/L₂ is regular for any L₂, even a non-regular one.
NOT guaranteed (classic traps)
- Infinite union: each {aⁿbⁿ} for a single n is finite (regular), but their union over all n is not regular.
- Subset: {aⁿbⁿ} ⊆ Σ*, yet Σ* is regular and the subset is not. A subset of a regular language need not be regular.
- Superset: similarly no guarantee.
- Infinite intersection: no guarantee.
Using closure to prove NON-regularity
If L were regular, then L ∩ R (R regular) would be regular. So if L ∩ R is known non-regular, L is non-regular. Example: L = { w : |w|ₐ = |w|_b }. L ∩ a*b* = { aⁿbⁿ } — not regular — so L is not regular.
Putting it together
- Regular languages are closed under every finite operation in the syllabus, including reversal, (inverse) homomorphism and quotient.
- No guarantee for infinite unions or subsets.
- Intersect with a regular “shape” to expose a non-regular core.
Visual
reversal of a DFA for "starts with ab" original: →q0 —a→ q1 —b→ (q2) ⟲a,b reversed: new start s —ε→ q2 ⟲a,b —b→ q1 —a→ (q0) language: ends with ba ✓ closure cheat-grid for regular languages ∪ ∩ − ¬ · * ⁺ ᴿ h h⁻¹ / prefix suffix substitution ✔ all closed infinite ∪, infinite ∩, ⊆ (subset), ⊇ (superset) ✘ no guarantee
Worked Examples
L = (a + b)*abb. Describe Lᴿ.
Show the full solution
Lᴿ = bba(a + b)*: strings starting with bba. Reverse the regex (and the order inside concatenations).
h(0) = aa, h(1) = b. L = { w ∈ {a,b}* : w has an even number of a’s }. What is h⁻¹(L)?
Show the full solution
For any w ∈ {0,1}*, h(w) has 2·|w|₀ a’s — always even. So h⁻¹(L) = {0,1}*.
L₁ regular, L₂ not regular. Which must be regular? (i) L₁ ∪ L₂ (ii) L₁ / L₂ (iii) L₁ ∩ L₂ (iv) Prefix(L₁)
Show the full solution
(ii) quotient by any language is regular ✓; (iv) ✓. (i) and (iii) are not guaranteed: L₁ = ∅ gives L₂ (non-regular); L₁ = Σ* gives L₁ ∪ L₂ = Σ* (regular). Answer: (ii) and (iv).
GATE Traps
- Closure is one-way: it says nothing when an input is non-regular.
- A subset of a regular language need not be regular ({aⁿbⁿ} ⊆ Σ*).
- Finite unions keep regularity; infinite unions don’t.
- L₁/L₂ is regular whenever L₁ is regular — L₂ can be anything.
Memory Hook
The regular club has a strict door policy for members (any combination of members stays in the club) but no policy at all for outsiders.
Connect the Dots
Closure tells us when new languages stay regular. Next: what we can compute about a regular language given its DFA — is it empty? finite? equal to another one? Every one of these questions has an algorithm.
Self-Test
- MSQ
Regular languages are closed under:
- reversal
- inverse homomorphism
- infinite union
- quotient with an arbitrary language
- MCQ
L ∩ a*b* = {aⁿbⁿ}. What follows?
- L is regular
- L is not regular
- a*b* is not regular
- nothing
- MCQ
h(a) = 0, h(b) = 0. h({ aⁿbⁿ : n ≥ 0 }) is:
- {0ⁿ1ⁿ}
- (00)*
- 0*
- not regular
- NAT
L = a*b. How many strings of length 3 are in Prefix(L)?
Write your answer before opening the key.
- MCQ
Which is NOT guaranteed to be regular when L is regular?
- Lᴿ
- L*
- a subset of L
- Σ* − L
Rule Card
- 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.
Concept Ledger
- homomorphism h(L)
- inverse homomorphism h⁻¹(L)
- right quotient L₁/L₂
- Prefix(L), Suffix(L)
- substitution
- closure-based non-regularity argument
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- Right-linear or left-linear (not mixed).
- F₁ × (Q₂ − F₂).
- New start and accept, ε into r, skip ε, loop ε from r’s accept to r’s start, exit ε.
Self-test answers
- ABD — Standard closure list.
- C: Union of the finite sets {aⁿbⁿ} is not regular.
- B — If L were regular, the intersection with a regular language would be regular.
- A: Contradiction.
- C: a*b* is regular.
- D: Closure gives a conclusion.
- B — Each string maps to 0²ⁿ.
- A: b maps to 0, not 1.
- C: Odd lengths missing.
- D: Homomorphic images of non-regular languages can be regular.
- 2 — Prefixes of a*b of length 3: aaa (prefix of aaab) and aab.
- C — Subsets can be anything.
- A: Closed.
- B: Closed.
- D: Closed.
Flashcards
- Is a subset of a regular language regular?
Reveal answer
Not necessarily ({aⁿbⁿ} ⊆ Σ*). - Regular L₁, arbitrary L₂: is L₁/L₂ regular?
Reveal answer
Yes, always. - Closed under infinite union?
Reveal answer
No. - How do you reverse a DFA?
Reveal answer
Reverse arrows, new start with ε to old accepting states, old start becomes accepting.
Exam shortcuts
- To show L non-regular fast: intersect with a regular “shape” like a*b* to expose aⁿbⁿ.