Explain the Greibach Normal Form (GNF)

Data Structure AlgorithmsComputer ScienceComputers

Let G = (V, T, P, S) be a CFL. If every production in P is of the form as given below

A -> aa

Where A is in V, a is in T, and a is in V*, then G is said to be in Greibach Normal Form (GNF).

Example

S -> aAB | bB A -> aA | a

B -> bB | c

  • Theorem − Let L be a CFL not containing {s}. Then there exists a GNF grammar G such that L = L(G).
  • Lemma 1 − Let L be a CFL. Then there exists a PDA M such that L = LE(M).
  • Proof − Assume without loss of generality that s is not in L. The construction can be modified to includes later.

Let G = (V, T, P, S) be a CFG, and assume without loss of generality that G is in GNF.

Construct M = (Q, E, r, 5, q, z, 0) where −

Q = {q}

E = T

r = V

z = S

5: for all a in E and A in r,

5(q, a, A) contains (q, y) if A -> ay is in P or rather −

5(q, a, A) = {(q, y) | A -> ay is in P and y is in r*}, for all a in E and A in r

For a given string x in E*, M will attempt to simulate a leftmost derivation of x with G.

Example

Consider the following CFG in GNF.

S ^ aS S a

Construct M as follows −

Q = {q}

E = T = {a} r = V = {S}

z = S

5(T a S) = {(T S) (T s)}

5(q, s, S) = 0

raja
Published on 16-Jun-2021 12:51:02
Advertisements