Linear grammar
In computer science, a linear grammar is a context-free grammar that has at most one nonterminal in the right-hand side of each of its productions.[src] A linear language is a language generated by some linear grammar.[src]
In computer science, a linear grammar is a context-free grammar that has at most one nonterminal in the right-hand side of each of its productions.[src] A linear language is a language generated by some linear grammar.[src] ==Example== An example of a linear grammar is G with N = {S}, Σ = {a, b}, P with start symbol S and rules S → aSb S → ε It generates the language \{ a^ib^i \mid i \geq 0\} .[src] ==Relationship with regular grammars== Two special types of linear grammars are the following: the left-linear or left-regular grammars, in which all rules are of the form A → αw where α is either empty or a single nonterminal and w is a string of terminals; the right-linear or right-regular grammars, in which all rules are of the form A → wα where w is a string of terminals and α is either empty or a single nonterminal.[src] Each of these can describe exactly the regular languages.[src] A regular grammar is a grammar that is left-linear or right-linear.[src] Note that having a mix of left-linear and right-linear rules does not impose any reduction in the expressive power of linear grammars.[src] Indeed, by adding new nonterminals as abbreviations, any linear grammar can be turned into an equivalent one where some of the rules are left-linear and some are right-linear.[src] For instance, the rules of the grammar G above generating \{ a^ib^i \mid i \geq 0 \} can be replaced with S → aA A → Sb S → ε which generates the same language.[src] It is the requirement that all rules be left-linear, or all rules be right-linear, that characterizes regular languages and thus leads to a strict decrease in the expressive power of linear grammars.[src] ==Expressive power, nondeterminism, and complexity== All regular languages are linear; conversely, \{ a^ib^i \mid i \geq 0 \} is an example of a non-regular linear language.[src] All linear languages are context-free; conversely, an example of a context-free, non-linear language is the Dyck language of well-balanced bracket pairs.[src] Hence, the regular languages are a proper subset of the linear languages, which in turn are a proper subset of the context-free languages.[src] Just as the regularity problem for context-free languages is undecidable, it cannot be decided whether a given context-free language is a linear context-free language.[src] While regular languages are deterministic, there exist linear languages that are nondeterministic.[src] For example, the language of even-length palindromes on the alphabet of 0 and 1 has the linear grammar S → 0S0 | 1S1 | ε, but cannot be recognized by any deterministic pushdown automaton.[src] In particular, the existence of nondeterministic linear languages can be used to derive Ω(n²/log n) lower bounds for the online recognition problem for linear grammars.[src] ==One-turn pushdown automata and ultralinear grammars== A language is linear iff it can be generated by a one-turn pushdown automaton – a pushdown automaton that, once it starts popping, never pushes again.[src] If one instead places a finite bound on the number of turns then one obtains a more general class of languages known as ultralinear, still strictly contained in the context-free languages, and which have a corresponding grammatical characterization.[src] A grammar is ultralinear if the set of nonterminals can be decomposed as a disjoint union of sets N = N_0 \cup N_1 \cup \dots \cup N_k , such that for each nonterminal X \in N_i , each production rule is of the form X \to \alpha Y \beta or X \to \alpha , where Y \in N_i and \alpha,\beta \in (\Sigma \cup N_0 \cup \dots \cup N_{i-1})^* .[src] (Thus linear grammars correspond to the case k = 0 .) ==Closure properties== Linear languages are not closed under intersection.[src] For example, let L_1 = \{a^nb^nc^m \mid n, m \geq 0\}, L_2 = \{a^nb^mc^m \mid n, m \geq 0\} , then their intersection is not only not linear, but also not context-free.[src] See pumping lemma for context-free languages.[src] As a corollary, linear languages are not closed under complement (as intersection can be constructed by de Morgan's laws out of union and complement).[src] ==References==[src]
27 sentences · 27 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Linear grammar." encyclopegia.org, 2026, https://encyclopegia.org/wiki/linear-grammar. Accessed 01 December 2026.
Chicago
"Linear grammar." encyclopegia.org. Accessed December 1, 2026. https://encyclopegia.org/wiki/linear-grammar.
APA
encyclopegia.org. (2026). Linear grammar. Retrieved December 1, 2026, from https://encyclopegia.org/wiki/linear-grammar
Accessed December 1, 2026 · CC BY-SA 4.0 · citation page · JSON