Controlled grammars are a class of grammars that extend, usually, the context-free grammars with additional controls on the derivations of a sentence in the language. A number of different kinds of controlled grammars exist, the four main divisions being Indexed grammars, grammars with prescribed derivation sequences, grammars with contextual conditions on rule application, and grammars with parallelism in rule application. Because indexed grammars are so well established in the field, this article will address only the latter three kinds of controlled grammars.
Control by prescribed sequences Grammars with prescribed sequences are grammars in which the sequence of rule application is constrained in some way. There are four different versions of prescribed sequence grammars: language controlled grammars (often called just controlled grammars), matrix grammars, vector grammars, and programmed grammars. In the standard context-free grammar formalism, a grammar itself is viewed as a 4-tuple, G=(N,T,S,P), where N is a set of non-terminal/phrasal symbols, T is a disjoint set of terminal/word symbols, S is a specially designated start symbol chosen from N, and P is a set of production rules like X→α, where X is some member of N, and α is some member of (N∪T)∗. Productions over such a grammar are sequences of rules in P that, when applied in order of the sequence, lead to a terminal string. That is, one can view the set of imaginable derivations in G as the set {p1p2...pn:n≥0}, and the language of G as being the set of terminal strings L(G)={w∈T∗:S⇒p1...⇒pnw}. Control grammars take seriously this definition of the language generated by a grammar, concretizing the set-of-derivations as an aspect of the grammar. Thus, a prescribed sequence controlled grammar is at least approximately a 5-tuple G=(N,T,S,P,R) where everything except R is the same as in a CFG, and R is an infinite set of valid derivation sequences p1p2...pn. The set R, due to its infinitude, is almost always (though not necessarily) described via some more convenient mechanism, such as a grammar (as in language controlled grammars), or a set of matrices or vectors (as in matrix and vector grammars). The different variations of prescribed sequence grammars thus differ by how the sequence of derivations is defined on top of the context-free base. Because matrix grammars and vector grammars are essentially special cases of language controlled grammars, examples of the former two will not be provided below.
Language controlled grammars Language controlled grammars are grammars in which the production sequences constitute a well-defined language of arbitrary nature, usually though not necessarily regular, over a set of (again usually though not necessarily) context-free production rules. They also often have a sixth set in the grammar tuple, making it G=(N,T,S,P,R,F), where F is a set of productions that are allowed to apply vacuously. This version of language controlled grammars, ones with what is called "appearance checking", is the one henceforth.
Proof-theoretic description We let a regularly controlled context-free grammar with appearance checking be a 6-tuple G=(N,T,S,P,R,F) where N, T, S, and P are defined as in CFGs, R is a subset of P* constituting a regular language over P, and F is some subset of P. We then define the immediately derives relation ⇒pi as follows: Given some strings x and y, both in (N∪T)∗, and some rule p=A→w∈P,
x⇒pacy holds if either
x=x1Ax2 and y=y1wy2, or x=y and p∈F Intuitively, this simply spells out that a rule can apply to a string if the rule's left-hand-side appears in that string, or if the rule is in the set of "vacuously applicable" rules which can "apply" to a string without changing anything. This requirement that the non-vacuously applicable rules must apply is the appearance checking aspect of such a grammar. The language for this kind of grammar is then simply set of terminal strings L(G)={w∈T∗:S⇒p1acw1⇒p2acw2⇒p3ac...⇒pnacw, for some p1p2...pn∈R}.
Example Consider a simple (though not the simplest) context-free grammar that generates the language {an:n≥1}: Let G=({S,A,X},{a},S,{f,g,h,k,l}), where
f:S→AA g:S→X h:A→S k:A→X l:S→a In language controlled form, this grammar is simply G′=({S,A,X},{a},S,{f,g,h,k,l},(f|g|h|k|l)∗,{f,g,h,k,l}) (where (f|g|h|k|l)∗ is a regular expression denoting the set of all sequences of production rules). A simple modification to this grammar, changing is control sequence set R into the set (f∗gh∗k)∗l∗, and changing its vacuous rule set F to {g,k}, yields a grammar which generates the non-CF language {a2n:n≥0}. To see how, consider the general case of some string with n instances of S in it, i.e. Sn (the special case S1 trivially derives the string a which is a20, an uninteresting fact). If we chose some arbitrary production sequence fughvk..., we can consider three possibilities: n=u, n<u, and n>u When n=u we rewrite all n instances of S as AA, by applying rule f to the string u times, and proceed to apply g, which applies vacuously (by virtue of being in F) . When n<u, we rewrite all n instances of S as AA, and then try to perform the n+1 rewrite using rule f, but this fails because there are no more Ss to rewrite, and f is not in F and so cannot apply vacuously, thus when n<u, the derivation fails. Lastly, then n>u, we rewrite u instances of S, leaving at least one instance of S to be rewritten by the subsequent application of g, rewriting S as X. Given that no rule of this grammar ever rewrites X, such a derivation is destined to never produce a terminal string. Thus only derivations with n=u will ever successfully rewrite the string Sn. Similar reasoning holds of the number of As and v. In general, then, we can say that the only valid derivations have the structure Sn⇒f...⇒fA2n⇒gA2n⇒h...⇒hS2n⇒kS2n will produce terminal strings of the grammar. The X rules, combined with the structure of the control, essentially force all Ss to be rewritten as AAs prior to any As being rewritten as Ss, which again is forced to happen prior to all still later iterations over the S-to-AA cycle. Finally, the Ss are rewritten as as. In this way, the number of Ss doubles each for each instantiation of f8gh∗k that appears in a terminal-deriving sequence. Choosing two random non-terminal deriving sequences, and one terminal-deriving one, we can see this in work: Let s1=ffghkll, then we get the failed derivation:
… excerpt ends here. Continue reading the full article.
