Context-sensitive grammar 2026-11-05
A context-sensitive grammar has productions of the form , where is a nonterminal symbol and is a nonempty word. The surrounding words specify the context in which replacement is permitted. Every such step is length-nondecreasing.
An equivalent language-class description uses arbitrary noncontracting production rules with and a nonterminal in . If the empty word is included, the customary exception is with start symbol absent from every right side. Individual noncontracting rules need not have the displayed context-preserving form, although the generated language classes agree.
For example, replaces only when its immediate context is on the left and on the right. The language is context-sensitive and is not a context-free language. The associated computational model is a linear bounded automaton, whose usable tape is bounded by a constant times input length.
Linear bounded automaton 2026-11-05
A linear bounded automaton is a Turing machine whose usable tape on an input of length is bounded by cells for a fixed constant . A common equivalent model places end markers around the input and permits rewriting only between them. The standard language-class characterization uses a nondeterministic machine: these machines recognize exactly the nonempty-word languages generated by context-sensitive grammars, with an explicit convention needed for the empty word.[ref]
For , repeatedly mark one unmarked , one and one , rejecting if the order is wrong or a matching symbol is absent. Accept when no symbols remain unmarked. This uses the original input cells and repeated sweeps, showing how bounded space can check three linked counts. “Linear bounded” limits space, not running time.