Supriya Ghosh (Editor)

Noncontracting grammar

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In formal language theory, a grammar is noncontracting (or monotonic) 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.

Contents

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 (1963) 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 (context-free grammars were designated "type 4" in this work). 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 [generative] and strong [structural] equivalence; in his 1959 work he had used "type 1 grammar" to denote a context-sensitive grammar and "type 2" for context-free.

Example

This grammar, with the start symbol S, generates the language { anbncn : n ≥ 1 }, 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 (N, Σ, P, S) can be transformed into a context-sensitive grammar (N’, Σ, P’, S) as follows:

  1. For every terminal symbol a ∈ Σ, introduce a new nonterminal symbol [a] ∈ N’, and a new rule ([a] → a) ∈ P’.
  2. In the rules of P, replace every terminal symbol a by its corresponding nonterminal symbol [a]. As a result, all these rules are of the form X1...XmY1...Yn for nonterminals Xi, Yj and mn.
  3. Replace each rule X1...XmY1...Yn with m>1 by 2m rules:

For example, the above noncontracting grammar for { anbncn | n ≥ 1 } leads to the following context-sensitive grammar (with start symbol S) 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.

References

Noncontracting grammar Wikipedia