GATE 2026 CS1 Q.51
Let and be two languages over a finite alphabet, such that and are regular languages.
Which of the following statements is/are always true?
- (A)
is regular
- (B)
is regular
- (C)
is context-free
- (D)
is context-free
GATE CS
Closure properties and the pumping lemma
Regular languages are closed under many operations, so you can often prove a language regular or non-regular without building a machine. The decision properties make every basic question about a regular language answerable by an algorithm. The pumping lemma and the Myhill-Nerode theorem are the two standard tools for proving non-regularity, and Myhill-Nerode also counts the states of the minimal DFA.
5 previous-year questions · 5 solved · 6 practice questions
Conventions used here: is the input alphabet, the empty string, the length of , the number of occurrences of the symbol in , and the complement with respect to . A DFA's transition function is total unless stated otherwise. A class is closed under an operation if applying the operation to members of the class always gives a member of the class.
Operation | Regular languages closed? | Why (construction) |
|---|---|---|
Union | Yes | New start state with -moves to both start states, or the product construction |
Intersection | Yes | Product construction, accepting when both components accept |
Finite unions and intersections , | Yes | Apply the two-language case times |
Complement | Yes | Take a total DFA and swap accepting and non-accepting states |
Difference | Yes | |
Concatenation | Yes | -moves from the accepting states of the first NFA to the start of the second; only the second NFA's accepting states accept |
Kleene star | Yes | New start state that is accepting, with an -move to the old start; -moves from the old accepting states back to the old start |
Reversal | Yes | Reverse every arrow, make the old start the only accepting state, add a new start with -moves to the old accepting states |
Homomorphism | Yes | Replace each symbol in a regular expression for by its image |
Substitution of a regular language for each symbol | Yes | Replace each symbol in a regular expression for by a regular expression for its language |
Inverse homomorphism | Yes | A DFA for reads the whole string in one step |
Prefixes ; right quotient , any language | Yes | Keep the DFA; make a state accepting if some (some for the quotient) leads from it to an accepting state. The new accepting set always exists; it can be computed when is regular |
Suffixes | Yes | New start state with -moves to every state reachable from the old start |
Union of infinitely many regular languages | No, in general | is the union of the singletons over , each finite and so regular. Infinite intersections fail too: is the intersection of the regular languages over all |
Taking a subset or a superset | No, in general | Subset: , where is regular and is not. Superset: , where is regular and is not |
COMPLEMENT OF A REGULAR LANGUAGE
Applies to a total DFA only. If some transitions are missing, first add a dead (trap) state and send every missing transition to it. The complement DFA has the same states, so the minimal total DFAs of and have the same number of states. Swapping accepting states in an NFA does not complement it: convert the NFA to a DFA first (the subset construction can need up to states for an -state NFA).
PRODUCT CONSTRUCTION
For total DFAs with and states, the product has states. A pair is accepting when both components accept for intersection, when either accepts for union, and when the first accepts and the second does not for difference.
INVERSE HOMOMORPHISM
Here is the extended transition function on strings, with . The new DFA has the same states, start state and accepting states as the DFA for , and it accepts .
EXAM TIP
Being a subset or superset of a regular language tells you nothing. A non-regular language can sit inside a regular one, and a regular language can sit inside a non-regular one. Only the operations in the closure table let you conclude regularity.
Closure gives two proof patterns. To show a language is regular, build it from known regular languages with closed operations. To show it is non-regular, assume it is regular, apply closed operations to reach a language already known to be non-regular, and conclude by contradiction.
Showing non-regularity by closure
Assume is regular.
Apply closed operations that involve only and regular languages: intersect with a regular language such as , take a complement, or apply a homomorphism or an inverse homomorphism. Combining with a non-regular language proves nothing.
If the result is a known non-regular language such as , then is not regular.
WORKED EXAMPLE
Let . Is regular?
Suppose were regular.
is regular, so would be regular.
A string has equal numbers of and exactly when , so .
That language is not regular, a contradiction.
Answer: is not regular.
EXAM TIP
Do not claim a language is regular just because its strings look simple or because it is a subset of . Comparing two counts with no fixed bound is a warning sign of non-regularity, but it is not a proof. The language looks like such a comparison and is regular (Section 6). Prove each case with closure, the pumping lemma or Myhill-Nerode.
When a regular language is given by a DFA, an NFA or a regular expression (converted to a DFA first if needed), an algorithm decides each question below.
Question | Test |
|---|---|
Emptiness: is ? | Search the transition graph from the start state. is empty exactly when no accepting state is reachable |
Finiteness: is finite? | is infinite exactly when some cycle lies on a path from the start state to an accepting state (only states that are reachable and can reach an accepting state count). Equivalently, for an -state DFA, is infinite exactly when it contains a string with |
Membership: is ? | Run the DFA on for steps |
Universality: is ? | Check that the complement is empty |
Equivalence: is ? | Check that is empty, or minimise both DFAs and compare them up to renaming of states |
Subset: is ? | Check that is empty |
EXAM TIP
All of these are decidable for regular languages. Do not carry the answers over to context-free languages. For CFLs, emptiness, finiteness and membership are decidable, but universality and equivalence are not.
PUMPING LEMMA FOR REGULAR LANGUAGES
The implication runs one way only. A language can satisfy the conditions and still be non-regular, so the lemma can prove non-regularity but never regularity. For example, satisfies the lemma with (pump the first symbol), yet it is not regular: its intersection with is . The pumping length can be taken as the number of states of any DFA for .
Here is why the lemma holds. Take a DFA with states. Reading the first symbols of , it visits states, so some state repeats; this gives . The part read between the two visits is a loop. Repeating the loop any number of times, or deleting it (), leaves the DFA in the same state afterwards, so acceptance does not change.
Proving non-regularity: a game against an adversary
Assume is regular. The adversary then supplies a pumping length ; you do not choose .
You choose a string with , written in terms of (for example ).
The adversary splits with and . Your argument must handle every such split.
You choose (usually or ) with .
This contradicts the lemma, so is not regular.
WORKED EXAMPLE
Show that is not regular.
Assume is regular with pumping length .
Choose ; .
Since and the first symbols are all s, with .
Take : , which has zeros and ones.
Since , this string is not in , a contradiction.
Answer: is not regular.
EXAM TIP
Choose so that forces into one block of symbols. A bad choice lets the adversary find a split you cannot beat. For , the string is a bad choice: with , every is an even-length run of s and stays in the language. The string works. Strings such as and are standard good choices.
EXAM TIP
The lemma only talks about strings at least long. Finite languages are always regular, and they satisfy the lemma vacuously when is larger than their longest string, so the lemma is never applied to them.
Two strings are equivalent with respect to , written , if for every string , exactly when . This is an equivalence relation. A string that puts one of in and the other outside is a distinguishing suffix.
MYHILL-NERODE THEOREM
Unlike the pumping lemma, this is an iff. The number of classes equals the number of states of the minimal total DFA for , counting the dead state if the minimal total DFA has one.
Counting classes or showing non-regularity
To count classes, find a set of strings that are pairwise distinguishable and show that every string is equivalent to one of them. The size of the set is the size of the minimal DFA.
To prove non-regularity, exhibit infinitely many pairwise distinguishable strings. For , the strings work: the suffix separates from when .
The minimal total DFA for is unique up to renaming of states.
Minimising a DFA (table filling)
Make the DFA total and remove the states that cannot be reached from the start state.
Mark every pair where exactly one of is accepting.
Repeat until nothing changes: mark if for some symbol the pair is marked.
Unmarked pairs are equivalent. Merging each group of equivalent states gives the minimal DFA.
WORKED EXAMPLE
Let . How many states does the minimal total DFA for have?
For any suffix with , whether depends only on . For , it depends on and the last symbols of . So the class of is fixed by the last three symbols of .
Treat a string shorter than three symbols as padded with s on the left. A missing position is never a , so a short string behaves exactly like its padded version for every suffix (for example and ). That leaves at most classes, one for each triple of last symbols.
Two different triples differ at some position. Append a suffix of length , or so that this position becomes the third from the right. Then exactly one of the two strings is in , so all 8 triples are pairwise distinguishable.
Each triple is reached by the string made of those three symbols, and every string falls into one of the 8 classes, so there are exactly 8 classes.
Answer: 8
Language | Regular? | Reason |
|---|---|---|
No | Must match two counts with no bound; pumping lemma on , or Myhill-Nerode | |
No | Pump ; lies in the first block of s. (Over a one-letter alphabet it is , which is regular) | |
No | Pump ; lies in the first block of s, and is no longer an even-length palindrome. (Over a one-letter alphabet it is , which is regular) | |
No | Intersection with gives | |
or | No | In an infinite one-letter regular language the lengths are eventually periodic, so the gaps between members are bounded. Here the gaps grow without bound |
Yes | ||
Yes | Three states remember the count modulo 3 | |
No | Its complement intersected with is | |
Yes | The regular expression | |
Yes | Finite (101 strings) | |
Yes | Over the two counts differ by at most 1, and they are equal exactly when or the first and last symbols of are equal | |
Yes | It equals : take to be the first symbol | |
Any finite language | Yes | A finite union of single strings |
EXAM TIP
Matching two quantities against each other with no fixed bound is a warning sign of non-regularity. Counting modulo a constant, or comparing a count with a fixed number, is regular. Always check small cases and look for a simpler description: and the equal--and- language both look non-regular and are regular.
EXAM TIP
Regularity has nothing to do with being infinite or being easy to describe. A language is regular exactly when it has a finite automaton, exactly when it has a regular expression, and exactly when it has finitely many Myhill-Nerode classes.
PREVIOUS-YEAR QUESTIONS
Try each question first, then open the answer. We placed each question under a topic ourselves; the exam paper does not label topics.
See these papers in full: GATE CSE 2026 Set 1 · GATE CSE 2025 Set 1 · GATE CSE 2025 Set 2 · GATE CSE 2024 Set 1 · GATE CSE 2020
Let and be two languages over a finite alphabet, such that and are regular languages.
Which of the following statements is/are always true?
is regular
is regular
is context-free
is context-free
Consider the following two languages over the alphabet :
Which ONE of the following statements is CORRECT?
Both and are regular languages.
is a regular language but is not a regular language.
is not a regular language but is a regular language.
Neither nor is a regular language.
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)?
Let be two regular languages and a language which is not regular. Which of the following statements is/are always TRUE?
if and only if
is not regular
is not regular
is regular
Consider the following statements.
I. If is regular, then both and must be regular.
II. The class of regular languages is closed under infinite union.
Which of the above statements is/are TRUE?
I only
II only
Both I and II
Neither I nor II
PRACTICE
Which one of the following languages over is regular?
Answer: (C)
A is the standard non-regular language: it must match s against s.
B intersected with gives A, so B is not regular.
D has gaps between consecutive members that grow without bound, so it is not regular.
C needs and both even or both odd. The regular expression describes it, so C is regular.
Over the alphabet , which of the following statements are TRUE?
Every subset of a regular language is regular.
If is regular and is a homomorphism, then is regular.
If and are both non-regular, then is non-regular.
The complement of a regular language over is regular.
Answer: (B), (D)
A is false: is a subset of the regular language but is not regular.
B is true: regular languages are closed under homomorphism.
C is false: take and its complement. is non-regular, since otherwise would be regular. The union is , which is regular.
D is true: swap the accepting and non-accepting states of a total DFA.
A total DFA has 5 states and a total DFA has 7 states, both over the same alphabet. The product construction builds a DFA for that keeps every pair of states as a state, reachable or not. How many states does this DFA have?
Answer:
The product DFA has one state for each pair , where is a state of and a state of .
The count is .
Let , and let be its complement with respect to . Which statement is correct?
is regular because and is regular.
is not regular, because if it were, would be a regular language equal to .
is regular because it is an infinite language.
is not regular, because it fails the pumping lemma conditions only when .
Answer: (B)
A is wrong: a subset of a regular language need not be regular.
C is wrong: being infinite says nothing about regularity.
Within , the strings not in are exactly those with , so .
If were regular, its complement and that complement's intersection with would be regular. But is not regular, so is not regular, and B is correct.
D gives a false reason: the pumping lemma is about long strings of itself and says nothing about the strings with , which are not in .
Let and , where is the reverse of . Which statement is correct?
is regular and is not regular.
Both and are regular.
is not regular and is regular.
Neither nor is regular.
Answer: (A)
Every string has length at least 3 and starts and ends with the first symbol of .
Conversely, any string with and is with and .
So , which is regular.
is the set of non-empty even-length palindromes. Pump : with lies in the first block, and is not a palindrome, so is not regular.
Hence A.
Let . How many states does the minimal total DFA for have?
Answer:
Track the pair . There are pairs. A DFA with these pairs as states, start state and the single accepting state , accepts .
Reading adds and reading adds . Reading repeatedly from visits , so all 6 pairs are reachable.
A suffix moves every pair by the same amount, , so two different pairs always end at two different pairs. Pick a suffix that takes the first pair to : it takes the second pair somewhere else. So any two pairs are distinguishable.
No two states can be merged, so the minimal DFA has 6 states.
OFFICIAL GATE 2027 SYLLABUS WORDING
Copied from the GATE 2027 syllabus; see all 2027 syllabi.
GATE CS
Regular … languages, pumping lemma
Preparing in Kolkata? IAE Academy's course for GATE CSE.