Language classes and pumping arguments
Use a construction to establish membership in a class, and an impossibility argument to establish nonmembership. Closure statements are universal guarantees, not predictions of the exact class of every result.
6.1 Closure and mixed operations
Past papers · CS 2014–2026 (23 papers): 13 questions, 15 marks
Let REG denote regular languages, CFL context-free languages, DEC decidable languages and RE Turing-recognisable languages. “Yes” means closure for every pair in the class; “No” means there is a counterexample. All unions and concatenations in this table are finite.
| Operation | REG | CFL | DEC | RE |
|---|---|---|---|---|
| Union, intersection | Yes, Yes | Yes, No | Yes, Yes | Yes, Yes |
| Complement, difference | Yes, Yes | No, No | Yes, Yes | No, No |
| Concatenation, star, reversal | Yes | Yes | Yes | Yes |
| Homomorphism, allowing erasure | Yes | Yes | No | Yes |
| Inverse homomorphism | Yes | Yes | Yes | Yes |
For context-free and regular, , , , and are context-free. need not be. For deterministic context-free, , , and are DCFLs. REG and CFL are closed under prefix, suffix and substring. Their quotients by regular languages are also in the same class; for example is CFL.
Even DEC is not closed under erasing homomorphism: a decidable language of finite valid accepting computation histories can erase the history and retain the accepted input, yielding an undecidable RE language. Non-erasing homomorphisms preserve decidability because every preimage candidate has bounded length.
6.2 Pumping lemma for regular languages
Past papers · CS 2014–2026 (23 papers): 1 question, 1 mark
To disprove regularity: let the opponent choose ; choose a word depending on ; handle every legal split; choose an exponent that makes the pumped word leave the language. You do not get to select a convenient split. The lemma is necessary, not sufficient, for regularity.
For unary arithmetic progressions, both the cycle step and the lower cutoff matter. Choose a pump that preserves the residue and remains above the cutoff when deleted.
6.3 Pumping lemma for context-free languages
Past papers · CS 2014–2026 (23 papers): 1 question, 2 marks
The same strategy disproves context-freeness of and ; for the latter choose and pump up when the pumped pieces lie in the first two blocks. If both those counts increase equally, the count becomes too small; if they do not, equality fails. A window reaching cannot also reach , so pumping down or up breaks the constraints there as well.
6.4 Standard classification patterns
Past papers · CS 2014–2026 (23 papers): 10 questions, 19 marks
For this table, are nonnegative integers and range over a binary alphabet unless specified. “Non-CFL” examples here are still decidable: finite input can be checked with enough memory.
| Language or constraint | Smallest class stated | Reason to remember |
|---|---|---|
| Any finite language; | REG | Finite union or independent repetition |
| Fixed modular symbol counts | REG | Finite residue tuple |
| ; for fixed integer | DCFL, nonregular | One stack counter |
| DCFL, nonregular | Push for both first blocks; pop for last | |
| DCFL, nonregular | Nested comparisons | |
| DCFL, nonregular | Finish and reset the counter | |
| Non-CFL | Two crossing comparisons | |
| ; | Non-CFL | Three coupled blocks |
| with | Non-CFL | Filter to ; a short pump cannot preserve multiplication |
| for prime ; ; | Non-CFL | Unary CFLs are regular; lengths are not eventually periodic |
| CFL, not DCFL | Guess the middle, then pop | |
| ; with a separator | Non-CFL | General copying needs more than a stack |
| ; | CFL | Concatenated or nested mirrors |
| Non-CFL | Crossing mirrors; regular filtering exposes crossing block counts |
A unary language is regular exactly when its accepted lengths are eventually periodic: beyond some threshold, membership depends only on the length modulo one fixed positive integer. Every unary CFL is regular (the unary case of the semilinearity theorem). Prime lengths are not eventually periodic: if a prime beyond the threshold belongs to an accepted residue with period , then the composite would also belong. Squares and powers of two have unbounded gaps, which eventual periodicity of an infinite set forbids.
For counts of overlapping patterns, check whether they are really independent. Occurrences of 110 end runs of at least two 1's, and occurrences of 011 begin such runs. Interior runs contribute one of each; only boundary runs change the difference. Hence comparing those two counts needs only finite boundary information. Comparing 000 with 111 has no such cancellation: filtering to , , leaves the unbounded comparison .
6.5 Complement of copying
Past papers · CS 2014–2026 (23 papers): 2 questions, 4 marks
Although is not context-free, its complement is context-free. Odd-length words are automatically outside . For an even-length word, it suffices to guess two different symbols at corresponding positions of its halves.
The even-length unequal-halves language is exactly . This is a useful counterexample to the false rule “if a language is non-CFL, its complement must also be non-CFL”.
6.6 Closure-based impossibility proofs
Start by intersecting a suspected CFL with a regular language that fixes block order. If that produces a known non-CFL, the original language cannot be CFL. Homomorphism and inverse homomorphism can remove irrelevant symbols or encode blocks. Always name the operation and the class whose closure you use.
For and , both are DCFLs, but their intersection is , not CFL. If CFLs were closed under complement, De Morgan's identity and union closure would force intersection closure; therefore they are not closed under complement.
For the nonregular language , its complement is also nonregular, because REG is closed under complement. For , if were regular then would be regular, a contradiction.
Last-minute recall
- REG is closed under all finite Boolean operations.
- CFL is closed under union and intersection with REG, but not general intersection.
- is CFL; need not be.
- In regular pumping, forces the pump near the beginning.
- In CFL pumping, limits the window, not its position.
- One stack handles nesting and signed counts; arbitrary copying is harder.
- A unary CFL is regular.
- Complement can change a non-CFL into a CFL.