- Unrestricted grammar
In
formal language theory, an "unrestricted grammar" is aformal grammar on which no restrictions are made on the left and right sides of the grammar's productions. This is the most general class of grammars in theChomsky–Schützenberger hierarchy , and can recognize arbitraryrecursively enumerable language s.Formal definition
An unrestricted grammar is a
formal grammar , where is a set of nonterminal symbols, is a set ofterminal symbol s, and are disjoint (actually, this is not strictly necessary, because unrestricted grammars make no real distinction between nonterminal and terminal symbols, the designation exists purely so that one knows when to stop when trying to generatesentential form s of the grammar), is a set of production rules of the form where and are strings of symbols in and is not the empty string, and is a specially designated start symbol. As the name implies, there are no real restrictions on the types of production rules that unrestricted grammars can have.Unrestricted grammars and Turing machines
It may be shown that unrestricted grammars characterize the recursively enumerable languages. This is the same as saying that for every unrestricted grammar there exists some
Turing machine capable of recognizing and vice-versa. Given an unrestricted grammar, such a Turing machine is simple enough to construct, as a two-tapenondeterministic Turing machine . The first tape contains the input word to be tested, and the second tape is used by the machine to generate sentential forms from . The Turing machine then does the following:# Start at the left of the second tape and repeatedly choose to move right or select the current position on the tape.
# Nondeterministically choose a production from the productions in .
# If appears at some position on the second tape, replace by at that point, possibly shifting the symbols on the tape left or right depending on the relative lengths of and (e.g. if is longer than , shift the tape symbols left).
# Compare the resulting sentential form on tape 2 to the word on tape 1. If they match, then the Turing machine accepts the word. If they don't go back to step 1.It is easy to see that this Turing machine will generate all and only the sentential forms of on its second tape after the last step is executed an arbitrary number of times, thus the language must be recursively enumerable.
The reverse construction is also possible. Given some Turing machine, it is possible to create an unrestricted grammar.
Computational properties
As might be expected from the equivalence of unrestricted grammars and Turing machines, the
decision problem of whether a given string belongs to the language of some unrestricted grammar is in generalundecidable .It is perfectly possible to create a universal unrestricted grammar capable of accepting any other unrestricted grammar's language given a description of the language, just as it is possible to create a
universal Turing machine , so it would in theory be possible to build aprogramming language based on unrestricted grammars.References
* (the Cinderella book)
ee also
*
Turing machine
*Lambda calculus
*String rewriting
Wikimedia Foundation. 2010.