The language {aⁿbⁿ | n ∈ ℕ} #
For letters a and b, Language.anbn a b is the language of the words consisting of n copies
of a followed by n copies of b. It is language (10i) of [Cho57] (§3.2), the first of
three languages there that are not finite state, and it is the standard witness that the
context-free languages properly contain the regular ones
(Language.setOf_isRegular_ssubset_setOf_isContextFree).
For distinct letters the language is not regular: the words aⁿ have pairwise distinct left
quotients, since bⁿ completes aᵐ exactly when m = n. It is generated by the grammar
S → a S b | ε, whose sentential forms are exactly aⁿ S bⁿ and aⁿ bⁿ.
Main definitions #
Language.anbn a b: the language{aⁿbⁿ | n ∈ ℕ}.ContextFreeGrammar.anbn a b: the grammarS → a S b | ε.
Main results #
Language.replicate_append_replicate_mem_anbn_iff: fora ≠ b,aᵐbⁿis in the language exactly whenm = n.Language.not_isRegular_anbn: fora ≠ b, the language is not regular.ContextFreeGrammar.language_anbn: the grammar generates the language, soLanguage.isContextFree_anbn.Language.setOf_isRegular_ssubset_setOf_isContextFree: over a finite alphabet with two letters, the regular languages are a proper subclass of the context-free languages.
References #
The language {aⁿbⁿ | n ∈ ℕ} of the words consisting of n copies of the letter a followed
by n copies of the letter b.
Equations
- Language.anbn a b = {w : List α | ∃ (n : ℕ), List.replicate n a ++ List.replicate n b = w}
Instances For
For distinct letters, {aⁿbⁿ} is not regular: the left quotients by the words aⁿ are
pairwise distinct, since bⁿ is in the one by aᵐ exactly when m = n.
The grammar S → a S b | ε, with a single nonterminal.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The sentential forms of anbn are aⁿ S bⁿ and aⁿbⁿ.
Over a finite alphabet with two distinct letters a and b, the regular languages are a
proper subclass of the context-free languages, as {aⁿbⁿ} witnesses.