equivalent grammars


Two formal grammars G1=(Σ1,N1,P1,σ1) and G2=(Σ2,N2,P2,σ2) are said to be equivalentMathworldPlanetmathPlanetmathPlanetmathPlanetmath if they generate the same formal languages:

L⁢(G1)=L⁢(G2).

When two grammars G1 and G2 are equivalent, we write G1≅G2.

For example, the languagePlanetmathPlanetmath {an⁢b2⁢n∣n⁢ is a non-negative integer} over T={a,b,c} can be generated by a grammar G1 with three non-terminals x,y,σ, and the following productions:

P1={σ→λ,σ→xσy,x→a,y→b2}.

Alternatively, it can be generated by a simpler grammar G2 with just the starting symbol:

P2={σ→λ,σ→aσb2}.

This shows that G1≅G2.

An alternative way of writing a grammar G is (T,N,P,σ), where T=Σ-N is the set of terminals of G. Suppose G1=(T1,N1,P1,σ1) and G2=(T2,N2,P2,σ2) are two grammars. Below are some basic properties of equivalence of grammars:

  1. 1.

    Suppose G1≅G2. If T1∩T2=∅, then L⁢(G1)=∅.

  2. 2.

    Let G=(T,N,P,σ) be a grammar. Then the grammar G′=(T,N′,P,σ) where N⊆N′ is equivalent to G.

  3. 3.

    If (T1,N1,P1,σ1)≅(T1,N1,P2,σ2), then (T,N,P1,σ1)≅(T,N,P2,σ2), where T=T1∪T2 and N=N1∪N2.

  4. 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 G=(Σ,N,P,σ) is a grammar.

  1. 1.

    A production is said to be trivial if it has the form v→v. Then the grammar G′ obtained by adding trivial productions to P is equivalent to G.

  2. 2.

    If u∈L⁢(G), then adding the production σ→u to P produces a grammar equivalent to G.

  3. 3.

    Call a production a filler if it has the form λ→v. Replacing a filler λ→v by productions a→v⁢a and a→a⁢v using all symbols a∈Σ gives us a grammar that is equivalent to G.

  4. 4.

    G is equivalent to a grammar G′ without any fillers. This can be done by replacing each filler using the productions mentioned in the previous section. Finally, if λ∈L⁢(G), we add the production σ→λ to P if it were not already in P.

  5. 5.

    Let S⁢(P) be the set of all symbols that occur in the productions in P (in either antecedentsPlanetmathPlanetmathPlanetmath or conseqents). If a∈S⁢(P), then G′ obtained by replacing every production u→v∈P with production u⁢[a/b]→v⁢[a/b] and b→a, with a symbol X∉Σ, is equivalent to G. Here, u⁢[a/b] means that we replace each occurrence of a in u with X.

  6. 6.

    G is equivalent to a grammar G′, all of whose productions have antecedents in N+ (non-empty words over N).

Remark. In fact, if we let

  1. 1.

    X→X⁢Y,

  2. 2.

    X⁢Y→Z⁢T,

  3. 3.

    X→λ,

  4. 4.

    X→a

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).
Title equivalent grammars
Canonical name EquivalentGrammars
Date of creation 2013-03-22 17:37:17
Last modified on 2013-03-22 17:37:17
Owner CWoo (3771)
Last modified by CWoo (3771)
Numerical id 6
Author CWoo (3771)
Entry type Definition
Classification msc 91F20
Classification msc 68Q42
Classification msc 68Q45
Classification msc 03D05