Noncontracting grammar


In formal language theory, a grammar is noncontracting if all of its production rules are of the form
α → β where α and β are strings of nonterminal and terminal symbols, and
the length of α is less than or equal to that of β, |α| ≤ |β|, that is β is not shorter than α.
A grammar is essentially noncontracting if there may be one exception, namely, a rule
S → ε
where S is the start symbol and ε the empty string, and furthermore, S never occurs in the right-hand side of any rule.
None of the rules of a noncontracting grammar decreases the length of the string that is being rewritten. If each rule even properly increases the length, the grammar is called a growing context-sensitive grammar.

History

Chomsky called a noncontracting grammar a type 1 grammar; in the same work, he called a context-sensitive grammar a "type 2 grammar", and he proved that these two are weakly equivalent. The type numbering scheme in this 1963 work of Chomsky does not coincide with the earlier one known today as the Chomsky hierarchy because he was trying to emphasize the distinction between weak and strong equivalence; in his 1959 work he had used "type 1 grammar" to denote a context-sensitive grammar and "type 2" for context-free.Chomsky, N. 1959a. On certain formal properties of grammars. Information and Control 2: 137–67.

Example

This grammar, with the start symbol S, generates the language
which is not context-free due to the pumping lemma.
A context-sensitive grammar for the same language is shown [|below].

Transforming into context-sensitive grammar

Every noncontracting grammar can be transformed into a context-sensitive grammar as follows:
  1. For every terminal symbol a ∈ Σ, introduce a new nonterminal symbolN’, and a new rule ∈ P’.
  2. In the rules of P, replace every terminal symbol a by its corresponding nonterminal symbol . As a result, all these rules are of the form → for nonterminals Xi, Yj and mn.
  3. Replace each rule → with m>1 by 2m rules:
For example, the [|above] noncontracting grammar for leads to the following context-sensitive grammar for the same language:

Expressive power

Similarly, there is an easy procedure for bringing any noncontracting grammar into Kuroda normal form.
Vice versa, every context-sensitive grammar and every Kuroda normal form grammar is trivially also a noncontracting grammar.
Therefore, noncontracting grammars, grammars in Kuroda normal form, and context-sensitive grammars have the same expressive power.
To be precise, the noncontracting grammars describe exactly the context-sensitive languages that do not include the empty string, while the essentially noncontracting grammars describe exactly the set of context-sensitive languages.