equivalent grammars
Two formal grammars and are said to be equivalent if they generate the same formal languages:
When two grammars and are equivalent, we write .
For example, the language over can be generated by a grammar with three non-terminals , and the following productions:
Alternatively, it can be generated by a simpler grammar with just the starting symbol:
This shows that .
An alternative way of writing a grammar is , where is the set of terminals of . Suppose and are two grammars. Below are some basic properties of equivalence of grammars:
- 1.
Suppose . If , then .
- 2.
Let be a grammar. Then the grammar where is equivalent to .
- 3.
If , then , where and .
- 4.
If we fix an alphabet , then is an equivalence relation on grammars over .
So far, the properties have all been focused on the underlying alphabets. More interesting properties on equivalent grammars center on productions. Suppose is a grammar.
- 1.
A production is said to be trivial if it has the form . Then the grammar obtained by adding trivial productions to is equivalent to .
- 2.
If , then adding the production to produces a grammar equivalent to .
- 3.
Call a production a filler if it has the form . Replacing a filler by productions and using all symbols gives us a grammar that is equivalent to .
- 4.
is equivalent to a grammar without any fillers. This can be done by replacing each filler using the productions mentioned in the previous section. Finally, if , we add the production to if it were not already in .
- 5.
Let be the set of all symbols that occur in the productions in (in either antecedents
or conseqents). If , then obtained by replacing every production with production and , with a symbol , is equivalent to . Here, means that we replace each occurrence of in with .
- 6.
is equivalent to a grammar , all of whose productions have antecedents in (non-empty words over ).
Remark. In fact, if we let
- 1.
,
- 2.
,
- 3.
,
- 4.
be four types of productions, then it can be shown that
- •
any formal grammar is equivalent to a grammar all of whose productions are in any of the four forms above
- •
any context-sensitive grammar is equivalent to a grammar all of whose productions are in any of forms 1, 2, or 4, and
- •
and any context-free grammar is equivalent to a grammar all of whose productions are in any of forms 1, 3, or 4.
References
- 1 A. Salomaa Computation and Automata, Encyclopedia of Mathematics and Its Applications, Vol. 25. Cambridge (1985).