Formal grammar Created 2026-09-24 Updated 2026-11-05
A formal grammar specifies how to generate a formal language by repeated applications of production rules. Write , where is a finite set of nonterminal symbols, is a disjoint finite alphabet of terminal symbols, is the start symbol, and is a finite set of production rules . In an unrestricted formal grammar, the word must contain at least one nonterminal symbol; may be any word over .
A grammar derivation replaces an occurrence of inside a word by . The generated formal language isIntermediate words may still contain nonterminal symbols; these are sentential forms. For example, the production rules and give and generate exactly . Restricting each left side to one nonterminal symbol gives a context-free grammar.[ref]
Introduction to the Theory of Computation by Jean Gallier (2017). Sections6.1–6.2, printed pp.127–129, context-free grammar and derivation definitions
Nonproductive nonterminal Created 2026-09-24 Updated 2026-11-05
A nonterminal symbol of a formal grammar is productive if for some word consisting only of terminal symbols; otherwise it is nonproductive. In a context-free grammar, a sentential form containing a nonproductive nonterminal symbol cannot derive a terminal word: the descendants of that occurrence would have to provide a terminal derivation from the nonterminal symbol. Consequently productions involving nonproductive nonterminal symbols can be discarded when simplifying a context-free grammar.
The context-free hypothesis matters. A general variable-based grammar can have a production rule while neither nor alone derives a terminal word. A terminal derivation from a larger context therefore need not demonstrate productivity of each individual nonterminal symbol.