Top Qs
Timeline
Chat
Perspective

Noncontracting grammar

From Wikipedia, the free encyclopedia

Remove ads

In formal language theory, a noncontracting grammar (also called monotonic grammar) is a type of formal grammar whose production rules never decrease the total length of a string during derivation. This means that when applying any rule to transform one string into another, the resulting string must have at least as many symbols as the original.

Noncontracting grammars are significant because they are equivalent in expressive power to context-sensitive grammars and define the same class of languages (the context-sensitive languages) in the Chomsky hierarchy. This equivalence makes them important for understanding the computational limits of natural language processing and compiler design, as they can model complex linguistic phenomena while maintaining certain desirable mathematical properties. Some authors use the term context-sensitive grammar to refer to noncontracting grammars in general, though this usage varies in the literature.[1]

A closely related concept is the essentially noncontracting grammar, which allows one special exception: a rule that produces the empty string from the start symbol, provided that the start symbol never appears elsewhere in the grammar.

Remove ads

Formal definitions

A grammar is noncontracting if for all of its production rules, α  β (where α and β are strings of nonterminal and terminal symbols), it holds that |α| ≤ |β|, that is β has at least as many symbols as α.

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.

A context-sensitive grammar is a noncontracting grammar in which all rules are of the form αAβ  αγβ, where A is a nonterminal, and γ is a nonempty string of nonterminal and/or terminal symbols. However, some authors use the term context-sensitive grammar to refer to noncontracting grammars in general.[1]

A noncontracting grammar in which |α| < |β| for all rules is called a growing context-sensitive grammar.

Remove ads

History

Chomsky (1959) introduced the Chomsky hierarchy, in which context-sensitive grammars occur as "type 1" grammars; general noncontracting grammars do not occur.[2]

Chomsky (1963) calls a noncontracting grammar a "type 1 grammar", and a context-sensitive grammar a "type 2 grammar", and by presenting a conversion from the former into the latter, proves the two weakly equivalent .[3]

Kuroda (1964) introduced Kuroda normal form, into which all noncontracting grammars can be converted.[4]

Remove ads

Example

Sabc
SaSBc
cBBc
bBbb

This grammar, with the start symbol S, generates the language { anbncn : n ≥ 1 },[5] which is not context-free due to the pumping lemma.

A context-sensitive grammar for the same language is shown below.

Expressive power

Summarize
Perspective

Every context-sensitive grammar is a noncontracting grammar.

There are easy procedures for

Hence, these three types of grammar are equal in expressive power, all describing exactly the context-sensitive languages that do not include the empty string; the essentially noncontracting grammars describe exactly the set of context-sensitive languages.

A direct conversion

A direct conversion into context-sensitive grammars, avoiding Kuroda normal form:

For an arbitrary noncontracting grammar (N, Σ, P, S), construct the 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:[note 1]
X1X2...Xm-1 XmZ1X2...Xm-1 Xm
Z1X2...Xm-1 XmZ1Z2...Xm-1 Xm
 :
Z1Z2...Xm-1 XmZ1Z2...Zm-1 Xm
Z1Z2...Zm-1 XmZ1Z2...Zm-1 ZmYm+1...Yn
Z1Z2...Zm-1 ZmYm+1...Yn           Y1Z2...Zm-1 ZmYm+1...Yn
Y1Z2...Zm-1 ZmYm+1...YnY1Y2...Zm-1 ZmYm+1...Yn
 :
Y1Y2...Zm-1 ZmYm+1...YnY1Y2...Ym-1 ZmYm+1...Yn
Y1Y2...Ym-1 ZmYm+1...YnY1Y2...Ym-1 YmYm+1...Yn
where each ZiN’ is a new nonterminal not occurring elsewhere.[7][8]

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:

[a]afrom step 1
[b]bfrom step 1
[c]cfrom step 1
S[a][b][c]from step 2, unchanged
S[a]SB[c]      from step 2, unchanged
[c]BB[c]from step 2, further modified below
[c]BZ1Bmodified from above in step 3
Z1BZ1Z2modified from above in step 3
Z1Z2           BZ2modified from above in step 3
BZ2B[c]modified from above in step 3
[b]B[b][b]from step 2, further modified below
[b]BZ3Bmodified from above in step 3
Z3BZ3Z4modified from above in step 3
Z3Z4[b]Z4modified from above in step 3
[b]Z4[b][b]modified from above in step 3
Remove ads

See also

Notes

  1. For convenience, the non-context part of left and right hand side is shown in boldface.

References

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads