Computer science Automata and formal languages Example
Dyck language
Builds on Dyck wordContext-free grammarRegular languagePumping lemma for regular languagesDeterministic context-free languageDyck words are counted by Catalan numbers
Example
Let . The Dyck language is the set of balanced strings of brackets. In such a string , every prefix has at least as many as . The string itself has as many as . Its elements are the Dyck words, for example , , and . More generally, is the language of balanced strings over kinds of bracket pairs. In , each closing bracket must match the kind of the last unmatched opening bracket.
is a context-free language: it is generated by the context-free grammar with rules , and . To check this, note that each rule keeps the strings balanced. Conversely, a nonempty balanced string either splits into two shorter nonempty balanced strings or has the form with balanced.
is not a regular language. Let be the pumping length of the pumping lemma for regular languages. The word can only be pumped inside its first block, which unbalances it.
Remarks
is even a deterministic context-free language: a pushdown automaton pushes on , pops on , and never needs to guess. The number of Dyck words of length is the Catalan number , see Dyck words are counted by Catalan numbers. The languages play a central role in the Chomsky–Schützenberger representation theorem.
Reading path
To understand this page from the ground up, read these 11 pages in order. The foundations come first.
Show the path as a graph
- no evidence level
- Catalan numbers definition
- Context-free grammar concept
- Deterministic context-free language concept
- Deterministic finite automaton concept
- Dyck word definition
- Dyck word concept
- Regular language concept
- String concept
- Dyck words are counted by Catalan numbers statement
- Pumping lemma for regular languages statement
- Dyck language example
Where this leads
1 page builds on this one.
Further reading
About this page
| Tag | B80FATJ43P |
|---|---|
| URI | m2://B80FATJ43P |
| Kind | example |
| Writing | W0 stub |
| MSC | 68Q45, 68R15, 05A15 |
| Instance of | Context-free language |
| Uses | Dyck word, Context-free grammar, Regular language, Pumping lemma for regular languages, Deterministic context-free language, Dyck words are counted by Catalan numbers |
| Same as | |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- an inventory row: the row of the inventory that the node accounts for (0 of 1)
- a source with a locator (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.