equivalent grammars

equivalent grammars

Two

formal grammars

G

1

=

(

Σ

1

,

N

1

,

P

1

,

σ

1

)

and

G

2

=

(

Σ

2

,

N

2

,

P

2

,

σ

2

)

are said to be

equivalent

if they generate the same

formal languages

:

L

⁢

(

G

1

)

=

L

⁢

(

G

2

)

.

When two

grammars

G

1

and

G

2

are equivalent, we write

G

1

≅

G

2

.

For example, the

language

{

a

n

⁢

b

2

⁢

n

∣

n

⁢

is a non-negative integer

}

over

T

=

{

a

,

b

,

c

}

can be generated by a grammar

G

1

with three non-terminals

x

,

y

,

σ

, and the following productions:

P

1

=

{

σ

→

λ

,

σ

→

x

σ

y

,

x

→

a

,

y

→

b

2

}

.

Alternatively, it can be generated by a simpler grammar

G

2

with just the starting symbol:

P

2

=

{

σ

→

λ

,

σ

→

a

σ

b

2

}

.

This shows that

G

1

≅

G

2

.

An alternative way of writing a grammar

G

is

(

T

,

N

,

P

,

σ

)

, where

T

=

Σ

-

N

is the set of terminals of

G

. Suppose

G

1

=

(

T

1

,

N

1

,

P

1

,

σ

1

)

and

G

2

=

(

T

2

,

N

2

,

P

2

,

σ

2

)

are two grammars. Below are some basic

properties

of equivalence of grammars:

1.

Suppose

G

1

≅

G

2

. If

T

1

∩

T

2

=

∅

, then

L

⁢

(

G

1

)

=

∅

.

2.

Let

G

=

(

T

,

N

,

P

,

σ

)

be a grammar. Then the grammar

G

′

=

(

T

,

N

′

,

P

,

σ

)

where

N

⊆

N

′

is equivalent to

G

.

3.

If

(

T

1

,

N

1

,

P

1

,

σ

1

)

≅

(

T

1

,

N

1

,

P

2

,

σ

2

)

, then

(

T

,

N

,

P

1

,

σ

1

)

≅

(

T

,

N

,

P

2

,

σ

2

)

, where

T

=

T

1

∪

T

2

and

N

=

N

1

∪

N

2

.

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.

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.

If

u

∈

L

⁢

(

G

)

, then adding the production

σ

→

u

to

P

produces a grammar equivalent to

G

.

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.

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.

Let

S

⁢

(

P

)

be the set of all symbols that

occur in

the productions in

P

(in either

antecedents

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.

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.

X

→

X

⁢

Y

,

2.

X

⁢

Y

→

Z

⁢

T

,

3.

X

→

λ

,

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

Generated on Sat Feb 10 13:38:58 2018 by

LaTeXML