GATE / CS ARCHIVE

SUBJECT COLLECTION

Theory of Computation · Closure Properties & Language Hierarchy

30 questions, newest first

GATE CSE has asked 30 questions on Closure Properties & Language Hierarchy (Theory of Computation) from 1992 to 2026, in 24 of the 46 papers; the most recent is in GATE CSE 2026 Set 1. In the last five years it carried 0.6 marks per 100-mark paper on average, against 0.6 since 2003. Since 2014 the questions have been 8 MCQ and 5 MSQ. 3 groups of questions here are solved the same way; “One per method” keeps the newest of each.

Browse topics
2 marks · MSQ
Report issue

What a regular intersection does not imply

Closure Properties & Language Hierarchy

Question 51, GATE 2026: Languages L₁ and L₂ share a finite alphabet. Both L₂ and L₁∩L₂ are regular. Which conclusions always hold: A L₁ regular; B L₁∪L₂ regular; C complement of L₂ context-free; D L₁ context-free?
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C

Givens and goal

Languages L₁ and L₂ share a finite alphabet. Both L₂ and L₁∩L₂ are regular. Which conclusions always hold: A L₁ regular; B L₁∪L₂ regular; C complement of L₂ context-free; D L₁ context-free?

Approach

Use closure of regular languages under complement and their inclusion in context-free languages, then choose a regular L₂ that hides all complexity in L₁.

Step-by-step solution

1. Since L₂ is regular, its complement (relative to the shared alphabet’s full set of finite strings) is regular by closure under complement. Every regular language is context-free: for example, a finite automaton can be converted into a right-linear grammar, which is a context-free grammar. Therefore the complement of L₂ is context-free, so C must hold.
2. To test the other claims, let L₂=∅ and L₁={an bn cn:n≥0}. The alphabet {a,b,c} is finite as required.
3. The empty language is regular, and L₁∩L₂=∅ is also regular. Thus this choice satisfies both hypotheses no matter how complicated L₁ is.
4. The equal-three-block language L₁ is not context-free, hence is not regular either. The usual context-free pumping argument takes ap bp cp: a pumpable region of length at most p cannot span all three blocks, so pumping changes at most two counts or destroys the block order while at least one count remains p.
5. Therefore A and D fail. Also L₁∪L₂=L₁, so B fails for the same example.
6. Only C is guaranteed. Regularity of an intersection controls the part of L₁ inside L₂, not the potentially non-context-free part outside L₂.

Original paper, page 39 · Answer key

1 mark · MSQ
Report issue

Closure Properties & Language Hierarchy

Question 30, GATE 2025: Match language families (i) context-free, (ii) recursive/decidable, (iii) regular with properties (a) closed under union, (b) not closed under complementation, (c) closed under intersection. Select every option whose three matches are all valid.
A. i→a, ii→b, iii→c.
B. i→b, ii→a, iii→c.
C. i→b, ii→c, iii→a.
D. i→a, ii→c, iii→b.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C

Context-free languages are closed under union: introduce a new start symbol that chooses either grammar. They are not closed under complementation. One way to understand the latter fact is that closure under both union and complement would, by De Morgan's law, imply closure under intersection, which CFLs do not have.

Decidable languages are closed under union and intersection because both deciders halt: run them and combine their Boolean answers with OR or AND. They are closed under complement by swapping acceptance and rejection. Regular languages have all three closures: product automata handle union/intersection, and swapping accepting states in a complete DFA handles complement.

Now inspect each full option. A incorrectly assigns nonclosure under complement to decidable languages. B correctly assigns CFL nonclosure, decidable union closure, and regular intersection closure. C correctly assigns CFL nonclosure, decidable intersection closure, and regular union closure. D incorrectly denies complement closure to regular languages. Therefore B and C are correct. This is not a one-to-one matching puzzle: a family can possess more than one listed closure property.

Original paper, page 24 · Answer key

1 mark · MSQ
Report issue

Apply regular-language closure carefully

Closure Properties & Language Hierarchy

Question 23, GATE 2024: L1 and L2 are regular languages and L3 is not regular, over a common alphabet. Which statements always hold? A L1=L2 iff L1∩complement(L2)=∅. B L1∪L3 is nonregular. C complement(L3) is nonregular. D complement(L1)∪complement(L2) is regular.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C, D

Approach: Use closure under complement and union to prove universal claims, and a single legal counterexample to reject each false universal claim.
1. A is false. L1∩complement(L2)=∅ means only L1⊆L2. For instance L1=∅ and L2={a} satisfy this condition without being equal. Equality would require both inclusions.
2. B is false. Choose L1=Σ*, which is regular. Its union with any L3 is Σ*, so the union can be regular even though L3 is not.
3. C is true by contradiction. If complement(L3) were regular, complementing it again would make L3 regular, since regular languages are closed under complement. This contradicts the premise.
4. D is true because complement(L1) and complement(L2) are each regular, and their union is regular by union closure.
Answer: C and D. A nonregular input does not automatically make the result of every language operation nonregular.

Original paper, page 16 · Answer key

1 mark · MSQ
Report issue

Closure Properties & Language Hierarchy

Question 24, GATE 2023: Which language classes are closed under intersection with another language in the same class? A regular; B context-free; C recursive (decidable); D recursively enumerable (recognizable). Select all.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, C, D

Regular intersection uses a product automaton. Decidable-language intersection runs both halting deciders and accepts iff both accept. For recursively enumerable languages, dovetail the recognizers and accept once both have accepted, giving a recognizer. CFL intersection is not closed: {aⁿbⁿcᵐ}∩{aᵐbⁿcⁿ}={aⁿbⁿcⁿ}, which is not context-free. Thus A, C, D.

Teaching detail. For regular languages, a product DFA tracks both component states and accepts only when both components accept. For decidable languages, running the two deciders sequentially terminates, whether the answer is yes or no. For recognizers, a rejecting computation might never terminate, so dovetailing makes explicit that an accepting computation in each recognizer will eventually be observed. The CFL counterexample uses one language checking equality of a's and b's and another checking equality of b's and c's; requiring both produces the standard non-CFL of three equal counts.

Original paper, page 22 · Answer key

1 mark · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 1, GATE 2021: L1 is regular and L2 is context-free. Which language need NOT be context-free? A L1∩L2; B L1·L2 (concatenation); C L1−L2; D L1∪L2.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

CFLs are closed under intersection with regular languages, concatenation with regular languages, and union with regular languages. They are not closed under complement, so choosing regular L1=Σ* makes L1−L2 the complement of a CFL, which need not be context-free. For a concrete witness, the complement of the non-context-free copy language {ww} is context-free; using that complement as L2 yields the non-CFL {ww}. Thus C.

A simpler explicit counterexample to closure under difference uses Σ={a,b,c}. Define L2=Σ*\{an bn cn:n≥0}. This is context-free: strings outside a*b*c* form a regular language; inside that regular pattern, unequal a/b counts or unequal b/c counts form a union of CFLs, each checkable by a PDA. With regular L1=Σ*, L1−L2 is the standard non-CFL {an bn cn}. For A, run the DFA alongside the PDA; for B,D, use standard CFL concatenation/union constructions because regular languages are also CFLs.

Original paper, page 12 · Answer key

1 mark · MSQ
Report issue

Closure Properties & Language Hierarchy

Question 12, GATE 2021: L1 is regular and L2 context-free. Which are necessarily context-free? A L1∩¬L2; B ¬(¬L1∪¬L2); C L1∪(L2∪¬L2); D (L1∩L2)∪(¬L1∩L2). Complements are relative to the common alphabet-star.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B; C; D

Visually reading the overbars, B is the complement of (complement L1 union complement L2), hence L1 intersection L2, which is context-free. C contains L2 union complement L2 and equals the whole alphabet-star. D is (L1 intersection L2) union (complement L1 intersection L2), hence L2. A is L1 intersection complement L2; taking L1=Σ* shows that it need not be context-free, since CFLs are not closed under complement. Thus B, C, D.

The relevant closure theorem is intersection of a CFL with a regular language, not intersection of two arbitrary CFLs. A product construction combines the CFL's PDA control with the regular DFA state without adding another stack. C and D simplify by excluded middle, so no unsupported general CFL-complement closure is used.

Original paper, page 61 · Answer key

1 mark · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 8, GATE 2020: Test I: if L1∪L2 is regular, both L1 and L2 must be regular. II: regular languages are closed under infinite union. Options: A I only; B II only; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

Closure under a binary operation gives the forward implication: if both languages are regular then their union is regular. It does not give the converse. For a concrete converse counterexample choose L={an bn:n≥0} over {a,b}, and its complement. L is nonregular; its complement is nonregular because otherwise closure under complement would make L regular. Their union is the regular language {a,b}*. For infinite union, each singleton {an bn} has a finite automaton, but the union over all n is L. Finite union closure cannot be extended to countably many automata by treating an infinite construction as a finite automaton.

Derivation and answer

For I, take a nonregular language L and its complement; their union isΣ*, regular, although neither component is regular. For II, each singleton{an bn} is regular but their union over n≥0 is not. Both assertions are false, D.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Which language operation need not preserve regularity

Closure Properties & Language Hierarchy

Question 7, GATE 2019: Given a regular language L over {a,b}, compare A L·L^R, where L^R is the set of reversed words; B {ww^R : w∈L}; C Prefix(L), all prefixes of words in L; D Suffix(L), all suffixes. The source asks which is “NOT regular”; evaluate this as which operation is not guaranteed to preserve regularity.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Our answer: B under not-necessarily-regular interpretation

Method: use closure constructions for A, C, D, and a counterexample for B.

1. Regular languages are closed under reversal and concatenation. Reversing an automaton's edges and exchanging start/final roles gives an NFA for LR; concatenating automata then recognizes L·LR. Thus A is always regular. Its two factors are chosen independently.
2. For Prefix(L), take a DFA for L and mark as accepting every state from which some original accepting state is reachable. A word reaches such a state exactly when it can be extended to a word of L. Thus C is regular.
3. For Suffix(L), use an NFA whose possible initial states are all states reachable from the original start, while keeping the original accepting states. It recognizes strings that can follow some prefix to complete a word of L. Thus D is regular.
4. B requires the second half to be the reversal of the very same first half. Choose regular L = {a,b}*. B then contains precisely the even-length palindromes. If it had pumping length p, the palindrome ap bb ap would have a nonempty pumped part wholly among its first p a's. Pumping that part down shortens only the left a-run, producing a non-palindrome. This contradicts the pumping lemma.

Result: B identifies the operation that does not preserve regularity. Literally B can be regular for finite or empty L, so the unconditional wording must mean not necessarily regular. The recorded regularity-quantifier discrepancy is retained.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Closure of recognizable languages

Closure Properties & Language Hierarchy

Question 7, GATE 2018: For recursively enumerable languages, choose the true statement: A closed under complement; B closed under intersection; C all are recursive; D there are uncountably many.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Method

A recognizer may run forever when the input is not in its language. For intersection, sequential simulation is sufficient: run the first recognizer and, if it accepts, run the second and accept only if it also accepts. An input in both languages reaches both acceptances; if the first simulation loops, that input is outside the intersection, where looping is permitted. Dovetailing is another valid construction, not a requirement here. Unlike intersection, union requires avoiding a loop in one recognizer that hides acceptance by the other. Finite machine descriptions are countable, and recognizable but undecidable languages refute C.

Solution

To recognize the intersection of two recursively enumerable languages, dovetail their recognizers on the same input and accept when both accept. Hence intersection closure holds. Complement closure would make every recognizable language decidable, which is false; encodings of recognizers are countable. Thus B.

Original paper, page 5 · Answer key

2 marks · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 38, GATE 2017: L1={a^n b^n c^m:m,n≥0}, L2={a^m b^n c^n:m,n≥0}. Which are context-free? I L1∪L2; II L1∩L2. A I only; B II only; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. L1 is context-free: a stack can match a’s with b’s and then ignore a trailing c block. L2 is likewise context-free by ignoring the initial a block and matching b’s with c’s.

2. Context-free languages are closed under union: a new start symbol can choose either constituent grammar. Therefore I holds.

3. Intersection forces #a=#b=#c and preserves block order, giving {an bn cn}. For pumping length p, a pump window of length at most p in ap bp cp touches at most two blocks. Pumping changes some count but leaves a third unchanged, or breaks the block order. Thus it is not context-free; answer A.

Original paper, page 17 · Answer key

1 mark · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 4, GATE 2017: Let L1,L2 be arbitrary context-free languages and R an arbitrary regular language. Which claims always hold? I:L1∪L2 is context-free. II:complement(L1) is context-free. III:L1−R is context-free. IV:L1∩L2 is context-free. A:I,II,IV. B:I,III. C:II,IV. D:I only.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. I holds: take disjoint copies of the two grammars and add a new start production S→S1|S2. The resulting CFG generates their union.

2. III also holds because L1−R=L1∩complement(R). Regular languages are closed under complement, and a PDA for L1 can be combined with a finite automaton for complement(R). Thus the intersection remains context-free.

3. IV fails in general: {an bn cm} and {am bn cn} are CFLs, but their intersection {an bn cn} is not. II cannot hold for all CFLs either, since closure under both complement and union would imply intersection closure by De Morgan's law. Only I and III are guaranteed, B.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 18, GATE 2016: L1 is regular, L2 context-free, L3 recursive and L4 recursively enumerable. Which are always true? I ¬L3∪L4 is RE; II ¬L2∪L3 is recursive; III L1*∩L2 is context-free; IV L1∪¬L2 is context-free. Complements use the common alphabet-star. A I only; B I,III; C I,IV; D I,II,III.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The source complement bars matter. I: complement(L3) is recursive and its union with RE L4 is RE. II: every CFL is recursive, so complement(L2) and its union with recursive L3 are recursive. III: L1* is regular and its intersection with a CFL is CFL. IV is not guaranteed because taking L1 empty leaves complement(L2), and CFLs are not closed under complement. Thus I, II, III, D.

Do not confuse “not context-free” with “undecidable.” Every CFL has a terminating membership algorithm, so its complement is decidable even though it may cease to be context-free. For III, run a finite automaton for L1* alongside a pushdown automaton for L2. The finite control adds no second stack, preserving context-freeness.

Original paper, page 30 · Answer key

1 mark · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 28, GATE 2015: L1 is context-free; L2 is recursively enumerable but not recursive. Which must hold? I complement(L1) is recursive; II complement(L2) is recursive; III complement(L1) is context-free; IV complement(L1)∪L2 is recursively enumerable. A I only; B III only; C III and IV; D I and IV.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

A CFL has a terminating membership algorithm, so it and its complement are recursive. If complement(L2) had a decider, exchanging accept/reject would decide L2, a contradiction. CFL closure under complement fails in general, so III is not necessary. For IV, first decide whether the input is outside L1; accept if so, otherwise run the recognizer for L2. That algorithm recognizes the union and may loop only for nonmembers.

Solution: Every CFL is decidable, so complement(L1) is recursive. The complement of nonrecursive L2 cannot be recursive, because recursive languages are closed under complement. CFLs are not closed under complement. Since complement(L1) is recursive and L2 is RE, their union is RE by dovetailing recognizers. Hence I and IV, D.

Original paper, page 11 · Answer key

1 mark · MCQ
Report issue

Recognizable-language closure

Closure Properties & Language Hierarchy

Question 17, GATE 2013: Which statements are false?1 Every nondeterministic TM has an equivalent deterministic TM.2 Recognizable languages are closed under union and complement.3 Decidable languages are closed under intersection and complement.4 Recognizable languages are closed under union and intersection. A1, 4; B1, 3; C2 only; D3 only.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Nondeterministic Turing machines can be simulated deterministically by dovetailing. Recognizable languages are closed under union and intersection by dovetailing recognizers, but not generally under complement. Decidable languages are closed under intersection and complement. Therefore only statement 2 is false, C.

A deterministic simulator explores a nondeterministic computation tree fairly, preventing an infinite branch from starving an accepting finite branch; this establishes 1. To recognize a union, interleave two recognizers and accept if either accepts. For intersection, interleave and accept after both have accepted, establishing 4. A recognizer may run forever on a rejected input, so simply swapping accept/reject does not recognize its complement; statement 2 is false. A decider always halts, so complementing its result and combining two runs both work, establishing 3.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Regular-language complement guarantee

Closure Properties & Language Hierarchy

Question 24, GATE 2011: P is regular and Q is context-free with Q a subset of P. For example, P=p*q* and Q={p^n q^n : n is natural}. Which language is ALWAYS regular, over alphabet Σ?

(A) P intersect Q
(B) P minus Q
(C) Σ* minus P
(D) Σ* minus Q
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Regular languages are closed under complement, so Σ*−P is always regular. P∩Q=Q may be nonregular. If P−Q were always regular, Q=P−(P−Q) would always be regular, a contradiction; likewise regularity of Σ*−Q would imply regularity of Q. Therefore only C is guaranteed.

A counterexample is permitted because the question asks what is guaranteed for all P,Q. Choose P=0*1* and Q={0n1n}. Then P∩Q=Q is nonregular. If P−Q were regular, subtracting it from regular P would recover nonregular Q, contradicting closure of regular languages under difference. If the complement of Q were regular, complementing again would make Q regular. In contrast, a complete DFA for P can always have its accepting and rejecting states swapped to recognize its complement.

Original paper, page 6 · Answer key

1 mark · MCQ
Report issue

Differences of recursive and enumerable languages

Closure Properties & Language Hierarchy

Question 17, GATE 2010: L₁ is recursive. L₂ and L₃ are recursively enumerable but not recursive. Which statement is not necessarily true?
Options: (A) L₂−L₁ is recursively enumerable; (B) L₁−L₃ is recursively enumerable; (C) L₂∩L₃ is recursively enumerable; (D) L₂∪L₃ is recursively enumerable.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

L₂−L₁=L₂∩complement(L₁) is recursively enumerable because L₁ is decidable and its complement is decidable. Recursively enumerable languages are also closed under union and intersection, proving C and D. But take L₁=Σ* and L₃ an undecidable recursively enumerable language: L₁−L₃ is its complement and cannot be recursively enumerable, or L₃ would be decidable by dovetailing both recognizers. Therefore B is not necessarily true.

To recognize an intersection of two recursively enumerable languages, simulate both recognizers in parallel and accept only after both accept; for a union accept after either does. For L₂−L₁, first decide nonmembership in L₁, then run the L₂ recognizer. This construction fails for L₁−L₃ because nonmembership in undecidable L₃ cannot generally be recognized.

Original paper, page 4

2 marks · MCQ
Report issue

Closure with a nonrecursive enumerable language

Closure Properties & Language Hierarchy

Question 33, GATE 2006: L₁ is regular, L₂ is deterministic context-free, and L₃ is recursively enumerable but not recursive. Which universal closure assertion is false?
Options:
(A) L₁∩L₂ is deterministic context-free
(B) L₃∩L₁ is recursive
(C) L₁∪L₂ is context-free
(D) L₁∩L₂∩L₃ is recursively enumerable
Tap to enlarge
Your answer
Answer & solution

Answer: B as a non-guaranteed assertion (no official key was published)

1. Regular∩deterministic-CFL is deterministic context-free; regular∪CFL is context-free. Intersecting the two decidable languages with a recursively enumerable language remains recursively enumerable.

2. But L3∩L1 need not be recursive: take L1=Σ*, giving L3 itself. Thus B is the false universal closure assertion.

3. It can nevertheless be recursive for some choices, such as L1=∅; it is not false for every instance.

4. Teaching check: To refute a universal closure claim, choose an extreme regular language. Taking L₁=Σ* preserves all of L₃ under intersection, so undecidability remains. Taking L₁=∅ illustrates why the false assertion is “always recursive,” not “never recursive.”

Original paper, page 5

2 marks · MCQ
Report issue

Intersection of two context-free languages

Closure Properties & Language Hierarchy

Question 55, GATE 2005: L1={a^n b^n c^m:n, m>0}, L2={a^n b^m c^m:n, m>0}. Identify the false claim among: A their intersection is context-free; B their union is context-free; C both individual languages are context-free; D their intersection is context-sensitive.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

L1={an bn cm:n, m>0} and L2={an bm cm:n, m>0} each need only one stack comparison, hence are CFLs. CFLs are closed under union. Their intersection is {ak bk ck:k>0}, which is not context-free (standard CFL pumping argument) but is context-sensitive by linear-space counting. The false assertion is A.

Each individual language compares only two adjacent block counts and allows the remaining block freely, which a PDA can handle. Closure under union proves the union claim. In the intersection, the first language forces #a=#b and the second forces #b=#c, hence all three counts coincide. The standard pumping argument prevents a single stack from enforcing these three blocks: a short pumped region cannot cover all three, so pumping changes only one or two counts or disrupts the block order. Linear-space checking still recognizes the intersection, establishing context sensitivity.

Original paper, page 7

2 marks · MCQ
Report issue

Complements of recursive and enumerable languages

Closure Properties & Language Hierarchy

Question 56, GATE 2005: L1 is recursive; L2 is recursively enumerable but not recursive. Which is true of their complements? A complement L1 recursive and complement L2 RE; B complement L1 recursive and complement L2 not RE; C both complements RE; D complement L1 RE and complement L2 recursive.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

A recursive language has a halting decider, whose accept/reject outputs can be swapped to decide its complement. If both L2 and its complement were recursively enumerable, dovetailing their recognizers would decide L2, contradicting its nonrecursive premise. Thus complement(L1) is recursive and complement(L2) is not recursively enumerable, B.

A decider always halts, so swapping its accept/reject outcomes gives a complement decider. A recognizer need not halt on nonmembers, so that swap does not work for an arbitrary RE language. If both L2 and its complement had recognizers, run them in alternating steps on any input. Exactly one must eventually accept, deciding which side the input belongs to. That would contradict the given nonrecursive status. Thus B, with the nonhalting possibility explaining the distinction.

Original paper, page 7

2 marks · MCQ
Report issue

Complement closure and overlapping answer choices

Closure Properties & Language Hierarchy

Question 2.14, GATE 2002: Which statement is true?
(A) The complement of a recursive language is recursive.
(B) The complement of a recursively enumerable language is recursively enumerable.
(C) The complement of a recursive language is either recursive or recursively enumerable.
(D) The complement of a context-free language is context-free.
Tap to enlarge
Your answer
Answer & solution

Answer: A; C is also true with inclusive or (no official key was published)

Step 1: Separate mathematical closure from multiple-choice wording.

Step 2: A recursive decider halts on every input; reversing its output gives another total decider. A recognizer for an arbitrary RE language need not halt on nonmembers, so merely reversing its states is not a complement recognizer. Option C nevertheless remains true as a weak inclusive disjunction because its first alternative already holds; it is not made false simply by being less informative than A.

Conclusion: A decider always halts, so swapping its accept and reject answers decides the complement. Thus A is true. Recursive languages are also recursively enumerable, making C’s printed claim that the complement is either recursive or recursively enumerable true as an inclusive disjunction as well. If C intends recursive or merely-RE-but-not-recursive, its imprecise wording is hiding that distinction. General RE languages are not closed under complement (otherwise dovetailing both recognizers decides every RE language), and CFLs are not closed under complement. A is the strongest precise statement, but the literal single-choice options overlap.

Original paper, page 5

1 mark · MCQ
Report issue

Closure properties of context-free languages

Closure Properties & Language Hierarchy

Question 1.5, GATE 2001: Which statement about context-free languages is true: every CFL has a deterministic PDA; CFLs are closed under union; CFLs are closed under intersection; or CFLs are closed under complement?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Given grammars with disjoint renamed nonterminals and start symbols S1,S2, introduce a fresh start S→S1|S2. This grammar generates their union, proving B.

Step 2: The CFLs {an bn cm} and {am bn cn} have intersection{an bn cn}, which is not context-free. Thus C is false. If CFLs were closed under complement, their union closure and De Morgan would imply intersection closure, so D also fails.

Finally deterministic PDA languages form a strict subclass of CFLs; an arbitrary CFL need not have a deterministic PDA. Hence A is false.

Original paper, page 1

1 mark · MCQ
Report issue

Context-free closure properties

Closure Properties & Language Hierarchy

Question 1.5, GATE 1999: Which pair of operations preserves context-free languages: intersection/complement, union/Kleene star, or the other listed pairs?
Question 1.5, GATE 1999: Which pair of operations preserves context-free languages: intersection/complement, union/Kleene star, or the other listed pairs?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

For union, introduce a fresh start symbol with alternatives leading to the two original start symbols. For Kleene star, introduce S→S_old S|ε, producing any finite concatenation of words from the original language. Thus union and star preserve context-freeness. Intersection does not: {ai bi cj} intersected with {ai bj cj} gives {an bn cn}. Closure under complement together with union would imply intersection closure by De Morgan, so complement closure also fails. Hence B.

Original paper, page 1

2 marks · MSQ
Report issue

False context-free closure claims

Closure Properties & Language Hierarchy

Question 2.4, GATE 1999: L1 is context-free and L2 regular. Which claims are false in general: A L1−L2 is not context-free; B L1∩L2 is context-free; C complement L1 is context-free; D complement L2 is regular?
Tap to enlarge
Select all that apply
Answer & solution

Answer: A,C (no official key was published)

Regular languages are closed under complement, and intersecting a CFL with a regular language preserves context-freeness using a PDA–DFA product. Thus L1−L2=L1∩complement(L2) is context-free, so A is false; B and D are true. CFLs are not closed under complement: otherwise their union closure plus De Morgan would imply intersection closure, contradicted by the standard an bn cn construction. Hence C is also false as a universal assertion. Some particular L1 do have context-free complements, so the conclusion is about closure, not every instance.

Original paper, page 3

2 marks · Descriptive
Report issue

Regular union does not determine a summand

Closure Properties & Language Hierarchy

Question 6(a), GATE 1999: Given that language A is regular and A∪B is regular, must B be regular? Justify.
Question 6(a), GATE 1999: Given that language A is regular and A∪B is regular, must B be regular? Justify.
Tap to enlarge
Shared context

Given that language A is regular and A∪B is regular, must B be regular? Justify.

Answer & solution

Answer: No: take A={0,1}* and B={0ⁿ1ⁿ:n≥0}. (no official key was published)

Let the alphabet be {0,1}. Choose A={0,1}*, a regular language, and B={0ⁿ1ⁿ:n≥0}, which is not regular. Because B⊆A, the union A∪B equals A and is regular.

For completeness, B is nonregular by the pumping lemma: for pumping length p, any allowed pumped substring in 0ᵖ1ᵖ lies among the initial p zeros, and pumping it down changes the number of zeros without changing the p ones. The resulting word is not in B.

Closure under difference only proves (A∪B)\A=B\A is regular. It gives no control over the possibly nonregular part B∩A. This is precisely why reversing union closure fails.

Original paper, page 6

5 marks · Descriptive
Report issue

Closure under prefixes and reversal

Closure Properties & Language Hierarchy

Question 21, GATE 1997: A language L is accepted by a finite-state machine. Prove that finite-state machines also accept L′={s: ss′∈L for some string s′} and Lᴿ={s: s is the reversal of some string in L}.
Tap to enlarge
Answer & solution

Answer: For prefixes, accept all states that can reach an old final state. For reversal, reverse edges and exchange starts/finals using an ε-NFA. (no official key was published)

Begin with a DFA M=(Q,Σ,δ,q0,F) for L. This loses no generality because any finite-state recognizer can be determinized. The two constructions solve different problems: L′ consists of prefixes that can still be completed to an accepted word; Lᴿ reverses complete accepted words.

Prefix construction: compute C={q∈Q: δ*(q,t)∈F for some t∈Σ*}. These are exactly the states from which some accepting state is reachable, found by a reverse graph search starting at F. Keep Q,Σ,δ,q0 unchanged and replace the accepting set F by C. The new machine accepts s precisely when δ*(q0,s) belongs to C, which is equivalent to the existence of t with δ*(q0,st)∈F. That is exactly s∈L′. No new states are needed. If L is nonempty, q0∈C and ε is a prefix; if L is empty, C is empty and no word is accepted.

Reversal construction: retain all old states and reverse every labeled transition. For each δ(p,a)=q, add an a-transition q→p. Introduce a fresh start state r with ε-transitions to every f∈F, and make q0 the sole final state. The result is generally nondeterministic because reversing edges can create several transitions with the same label. A path q0 --a1...an--> f in the old machine becomes f --an...a1--> q0 in the new one, and the converse follows by reversing the path again. Thus exactly the reversed words are accepted. If a DFA is required, apply ε-closure and subset construction. Simply exchanging start/final states without reversing edges, or reversing edges while insisting on a single old final as start, would not establish closure for arbitrary L.

Original paper, page 9

2 marks · MCQ
Report issue

Closure properties of context-free languages

Closure Properties & Language Hierarchy

Question 2.8, GATE 1996: For CFLs L1,L2 and regular R, which need not be context-free: concatenation, L1∩L2, L1∩R, or union?
Tap to enlarge
Your answer
Answer & solution

Answer: B, C (no official key was published)

Context-free languages are closed under union and concatenation by introducing an appropriate new grammar start rule. They are also closed under intersection with a regular language, using a product of a PDA and a finite automaton. But take L1={an bn cm} and L2={am bn cn}, with nonnegative exponents. Each is context-free, while their intersection is {an bn cn}, which is not. Hence intersection of two arbitrary CFLs is the exceptional operation. The paper instead repeats L1∩L2 in choice C, making both B and C valid answers to its literal options; this source discrepancy is retained.

Original paper, page 4

Descriptive
Report issue

Iterate a concatenated language

Closure Properties & Language Hierarchy

Question 12(b), GATE 1996: M1 has states A(start,final),B(nonfinal), with A→B and B→A on either 0 or 1. M2 has C(start,final),D(final),E(nonfinal): C loops on a, C→D on b, D loops on b, D→E on a, and E loops on a,b. Starting with the concatenation machine (start A, finals C,D, added ε-edge A→C), recognize (L1L2)* without new states.
Question 12(b), GATE 1996: M1 has states A(start,final),B(nonfinal), with A→B and B→A on either 0 or 1. M2 has C(start,final),D(final),E(nonfinal): C loops on a, C→D on b, D loops on b, D→E on a, and E loops on a,b. Starting with the concatenation machine (start A, finals C,D, added ε-edge A→C), recognize (L1L2)* without new states.
Question 12(b), GATE 1996: M1 has states A(start,final),B(nonfinal), with A→B and B→A on either 0 or 1. M2 has C(start,final),D(final),E(nonfinal): C loops on a, C→D on b, D loops on b, D→E on a, and E loops on a,b. Starting with the concatenation machine (start A, finals C,D, added ε-edge A→C), recognize (L1L2)* without new states.
Question 12(b), GATE 1996: M1 has states A(start,final),B(nonfinal), with A→B and B→A on either 0 or 1. M2 has C(start,final),D(final),E(nonfinal): C loops on a, C→D on b, D loops on b, D→E on a, and E loops on a,b. Starting with the concatenation machine (start A, finals C,D, added ε-edge A→C), recognize (L1L2)* without new states.
Tap to enlarge
Answer & solution

Answer: Add C→A and D→A on ε; keep start A and final states C,D. (no official key was published)

In the concatenation machine, reaching either C or D after consuming input means one complete L1L2 factor has been recognized. To permit another factor, add ε-edges from both accepting states back to the start A. Retain A→C and all original symbol edges. The complete added-edge set relative to the original two diagrams is A→C, C→A and D→A, all labelled ε.

An accepting run can now consist of any finite number of concatenation runs separated by the new return edges. Each segment consumes a word of L1L2; conversely a concatenation of such words is realized by joining their accepting runs through these ε-edges. Since L1 and L2 already contain ε, the start A can reach accepting C without consuming input, so the zero-factor case is accepted without adding a new accepting start state.

Keep C,D as final states. Making A final as well would also be harmless here because A already has an ε-path to a final state, but it is unnecessary. Adding only D→A would be insufficient as a general concatenation construction because C is also a valid final state, for example after a factor ending with only a's. ε-cycles cause no language-theoretic problem; an implementation computes finite ε-closures rather than following such cycles forever.

Original paper, page 8

Report issue

Closure of context-free languages

Closure Properties & Language Hierarchy

Question 2(xix), GATE 1992: Which closures hold for CFLs: union, complement, intersection, Kleene star?
Question 2(xix), GATE 1992: Which closures hold for CFLs: union, complement, intersection, Kleene star?
Tap to enlarge
Select all that apply
Answer & solution

Answer: A, D (no official key was published)

For union, introduce a new start symbol choosing either original grammar. For star, use a new start that produces ε or concatenates one original-language word with another repetition. Hence both operations preserve context-freeness. Intersection does not: {an bn cm} intersected with {am bn cn} gives the non-CFL equal-three-block language. If CFLs were also closed under complement, De Morgan together with union closure would imply intersection closure, contradicting that example. Thus complement and arbitrary intersection fail.

Original paper, page 4

Descriptive
Report issue

Union of two recursive languages

Closure Properties & Language Hierarchy

Question 16(i), GATE 1992: True or false? The union of two recursive languages is recursive. Prove your answer.
Question 16(i), GATE 1992: True or false? The union of two recursive languages is recursive. Prove your answer.
Tap to enlarge
Answer & solution

Answer: True; run the two total deciders and accept iff either accepts. (no official key was published)

True. A recursive language has a decider: a machine that halts on every input and answers membership correctly. Let M1 decide L1 and M2 decide L2, taking a common ambient alphabet (the union of their alphabets if necessary). A machine for L1∪L2 operates as follows:

On input w:
  run M1(w) to completion;
  if M1 accepts, accept;
  run M2(w) to completion;
  if M2 accepts, accept;
  otherwise reject.

If w belongs to the union, at least one decider accepts. Acceptance by M1 immediately suffices; otherwise M2 accepts. If w is outside the union, both deciders reject, and the constructed machine rejects. It always halts because M1 always halts and, when run, M2 always halts. Correctness together with total termination proves recursiveness.

Sequential simulation is adequate here. For merely recursively enumerable languages the first recognizer might loop forever on a nonmember, so a union recognizer generally needs dovetailing instead. The stronger halting promise for recursive languages is the precise reason the simpler proof works. This establishes closure under finite union by induction; it does not establish closure under arbitrary infinite union.

Original paper, page 9

Report issue

Failure of closure under infinite union

Closure Properties & Language Hierarchy

Question 16(iii), GATE 1992: True or false? Regular languages are closed under infinite union. Prove your answer.
Question 16(iii), GATE 1992: True or false? Regular languages are closed under infinite union. Prove your answer.
Tap to enlarge
Answer & solution

Answer: False; ⋃_{n≥0}{0ⁿ1ⁿ} is nonregular although each singleton is regular. (no official key was published)

False. For every n≥0 define Ln={0n1n}. Each Ln contains one fixed finite word and is regular: a finite chain of states accepts exactly that word, or the word itself is a regular expression. However, the infinite union ⋃_{n≥0}Ln={0n1n:n≥0} is not regular.

For completeness, suppose this union has pumping length p. The word w=0p1p belongs to it. Every legal decomposition w=xyz with |xy|≤p and |y|≥1 puts y entirely in the first block of zeros, say y=0d with d≥1. Pump down to i=0. The resulting xz=0p−d1p has unequal numbers of zeros and ones and is not in the union, contradicting the pumping lemma.

This is a countably infinite family of regular languages with a nonregular union, enough to disprove arbitrary infinite-union closure. Closure under two-way union, and hence any finite union, is not in conflict: the usual product/NFA constructions use finitely many component automata, whereas this family requires unboundedly many distinct word lengths. Some infinite unions do happen to be regular, for example ⋃_{n≥0}{0n}=0*. The statement fails because not every infinite union is regular.

Original paper, page 9