Past exam of the mathematics course of the University of Cambridge 2017 ii Paper 2 4H a ii Solution Created 2026-09-24 Updated 2026-10-05
Use . A halting algorithm checks that a word consists of three consecutive blocks in the correct order and compares their lengths, so is a decidable language. If it were a context-free language, apply the pumping lemma for context-free languages to . The segment containing both pumped pieces has length at most , so it cannot meet both the and blocks. Pumping down therefore changes at least one block count but leaves another equal to , or destroys the required block order. Either way the resulting word is not in , a contradiction. Thus is a decidable language but not a context-free language.
Past exam of the mathematics course of the University of Cambridge 2017 ii Paper 3 4H b Solution Created 2026-09-24 Updated 2026-10-05
Their intersection is . Suppose satisfied the pumping lemma for context-free languages with length . In a decomposition with and , the window cannot meet both the and blocks. Pumping down changes at least one count and leaves at least one count unchanged. Thus the three counts are unequal, or the word order is invalid, contrary to the pumping lemma for context-free languages. Hence CFLs are not closed under intersection.
Past exam of the mathematics course of the University of Cambridge 2018 ii Paper 1 4G a Solution Created 2026-09-24 Updated 2026-10-03
The pumping lemma for context-free languages states that every context-free language has a pumping length such that every with can be writtenwith , , and for every integer .
Past exam of the mathematics course of the University of Cambridge 2018 ii Paper 1 4G b iii Solution Created 2026-09-24 Updated 2026-10-03
This language is not context-free. Let be a proposed pumping length and choose with . In any pumping decomposition of the unary word , pumping once more increases its length by an integer with . Butso the pumped length is not a power of three, contrary to the pumping lemma for context-free languages. This is also an instance of the fact that a unary context-free language is regular, whereas the powers of three are not ultimately periodic.
Past exam of the mathematics course of the University of Cambridge 2018 ii Paper 1 4G b i Solution Created 2026-09-24 Updated 2026-10-03
This language is not context-free. Suppose it were, and define the homomorphismThen closure under inverse homomorphism and intersection of a context-free language with a regular language would makecontext-free. The equality holds because the midpoint of a square with four nonempty alternating runs must lie between its second and third runs.
Apply the pumping lemma for context-free languages to . A pumpable window of length at most meets at most two adjacent blocks. Pumping changes at least one block but cannot reach its equal-count partner two blocks away, so either the counts or the counts cease to agree. This contradiction proves the claim.
Past exam of the mathematics course of the University of Cambridge 2019 ii Paper 1 4H a Solution Created 2026-09-24 Updated 2026-09-29
The pumping lemma for context-free languages states that for every context-free language there is a pumping length such that every with can be writtenwith
Past exam of the mathematics course of the University of Cambridge 2020 ii Paper 3 4F ii Solution Created 2026-09-24 Updated 2026-09-29
The language is not context-free. Suppose it had pumping length in the pumping lemma for context-free languages, and apply the lemma to . Write with , , and for every .
Let and be the respective numbers of s and s in . If , pumping with or destroys equality of the two block lengths. Hence a valid decomposition would require . Pumping with would then produce , where . Butso is not a square number. This contradiction proves the square-count language is not context-free.
Past exam of the mathematics course of the University of Cambridge 2021 ii Paper 3 12F i Solution Created 2026-09-24 Updated 2026-09-25
A parse tree has the start variable at its root; the ordered children of a variable spell the right side of the production used at that occurrence, and its leaves, read left to right, spell the derived word.
For a grammar in Chomsky normal form with variables, take pumping length . A parse tree for a word of length at least has a root-to-leaf path containing one variable twice. The yield can therefore be writtenwhere , , and replacing the subtree between the repeated variables zero, one, or several times provesThis is the pumping lemma for context-free languages. Without Chomsky normal form but with no epsilon or unit productions, use the maximum production length to choose a larger exponential ; bounded branching and the same repeated-variable argument apply.
Past exam of the mathematics course of the University of Cambridge 2022 ii Paper 3 4I i Solution Created 2026-09-24 Updated 2026-09-25
A context-free grammar is a quadruple consisting of finite nonterminal and terminal alphabets, a set of productions with one nonterminal on the left, and a start symbol . A context-free language is a language generated by such a grammar.
The pumping lemma for context-free languages says that there is a pumping length such that every in the language with can be writtenwith , , and in the language for every integer .
The language in (i) is not context-free. If it were, pumpThe substring , having length at most , cannot meet both the - and -blocks. If pumping changes the number of 's or 's, those two counts cease to agree. If it changes neither, it changes the number of 's while the outer counts remain , so the middle count ceases to be . Every permitted decomposition therefore fails, contradicting the pumping lemma.
Past exam of the mathematics course of the University of Cambridge 2024 ii Paper 1 4J c Solution Created 2026-09-24 Updated 2026-09-25
Assume that is context-free and let be its pumping length. Apply the pumping lemma for context-free languages toWrite , with and . The substring meets at most two of the three constant-letter blocks.
If and affect only the first block, only the middle block, or only the last block, pumping down immediately makes the final block length differ from the minimum of the first two lengths. If they meet the first and second blocks, pumping down decreases at least one of those block lengths while leaving the final length , again violating the defining minimum.
Past exam of the mathematics course of the University of Cambridge 2026 ii Paper 1 12I b Solution Created 2026-09-24 Updated 2026-09-25
A type-2 rule is with one nonterminal on the left; a type-2 grammar and its language are context-free languages. The required repetition criterion is the pumping lemma for context-free languages.
Past exam of the mathematics course of the University of Cambridge 2026 ii Paper 1 12I c ii Solution Created 2026-09-24 Updated 2026-09-25
It is not context-free. Intersecting it with the regular language would give , which violates the pumping lemma for context-free languages. Context-free languages are closed under intersection with regular languages.