ArticleslgStudy

science

Controlled grammar

Controlled grammar is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Controlled grammar rather than just read about it. In short: 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 appl…

Controlled grammar — main illustration
Controlled grammar — illustration

Key takeaways

  • Controlled grammar belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Controlled grammar to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Controlled grammar from memory before moving on to harder problems.

Reference excerpt

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.

Worked examples

Example 1 — a first encounter with Controlled grammar

Start with the simplest possible case. Write down what Controlled grammar claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Controlled grammar before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Controlled grammar ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Controlled grammar

In research
Controlled grammar appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Controlled grammar in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Controlled grammar is common in secondary-school and first-year university syllabi. It links to neighbouring topics Formal languages, Grammar frameworks, so understanding it makes those chapters shorter.
In everyday life
Look for Controlled grammar outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Controlled grammar” →

How to study Controlled grammar in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Controlled grammar means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Controlled grammar out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Controlled grammar in simple terms?

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 d…

Why does Controlled grammar matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Controlled grammar?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Controlled grammar.

Tags

  • Formal languages
  • Grammar frameworks

Keep exploring