Chomsky and Greibach Normal
Forms
Chomsky and Greibach Normal Forms – p.1/2
Simplifying a CFG
Chomsky and Greibach Normal Forms – p.2/2
It is often convenient to simplify CFG
Simplifying a CFG
Chomsky and Greibach Normal Forms – p.2/2
It is often convenient to simplify CFG
One of the simplest and most useful simplified forms of
CFG is called the Chomsky normal form
Simplifying a CFG
Chomsky and Greibach Normal Forms – p.2/2
It is often convenient to simplify CFG
One of the simplest and most useful simplified forms of
CFG is called the Chomsky normal form
Another normal form usually used in algebraic
specifications is Greibach normal form
Simplifying a CFG
Chomsky and Greibach Normal Forms – p.2/2
It is often convenient to simplify CFG
One of the simplest and most useful simplified forms of
CFG is called the Chomsky normal form
Another normal form usually used in algebraic
specifications is Greibach normal form
Note the difference between grammar cleaning and simplifi cation
Note
Chomsky and Greibach Normal Forms – p.3/2
Normal forms are useful when more advanced topics in
computation theory are approached, as we shall see further
Definition
Chomsky and Greibach Normal Forms – p.4/2
is in Chomsky normal form ifA context-free grammar
every rule is of the form:
where is a terminal, are nonterminals, and
may not be the start variable (the axiom)
Note
Chomsky and Greibach Normal Forms – p.5/2
The rule , where is the start variable, is not ex-
cluded from a CFG in Chomsky normal form.
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Show that any CFG can be converted into a CFG in
Chomsky normal form
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Show that any CFG can be converted into a CFG in
Chomsky normal form
Conversion procedure has several stages where the rules that
violate Chomsky normal form conditions are replaced with
equivalent rules that satisfy these conditions
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Show that any CFG can be converted into a CFG in
Chomsky normal form
Conversion procedure has several stages where the rules that
violate Chomsky normal form conditions are replaced with
equivalent rules that satisfy these conditions
Order of transformations: (1) add a new start variable, (2)
eliminate all-rules, (3) eliminate unit-rules, (4) convert other rules
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Show that any CFG can be converted into a CFG in
Chomsky normal form
Conversion procedure has several stages where the rules that
violate Chomsky normal form conditions are replaced with
equivalent rules that satisfy these conditions
Order of transformations: (1) add a new start variable, (2)
eliminate all-rules, (3) eliminate unit-rules, (4) convert other rules
Check that the obtained CFG defi nes the same language
Proof
Chomsky and Greibach Normal Forms – p.7/2
Let be the original CFG.
Proof
Chomsky and Greibach Normal Forms – p.7/2
Let be the original CFG.
Step 1: add a new start symbol to , and the rule to
Proof
Chomsky and Greibach Normal Forms – p.7/2
Let be the original CFG.
to
does not occur
Step 1: add a new start symbol to , and the rule
Note: this change guarantees that the startsymbol of
on the of any rule
Step 2: eliminate
Chomsky and Greibach Normal Forms – p.8/2
-rules
Repeat
1. Eliminate the rule from where is not the start symbol
2. For each occurrence of on the of a rule, add a new rule to
with that occurrence of deleted
Example: replace by ;
unless the
replace by
3. Replace the rule , (if it is present) by
rule has been previously eliminated
until all rules are eliminated
Step 3: remove unit rules
Chomsky and Greibach Normal Forms – p.9/2
Repeat
1. Remove a unit rule
2. For each rule , add the rule to , unless
was a unit rule previously removed
until all unit rules are eliminated
Note: is a string of variables and terminals
Convert all remaining rules
Repeat
, , where each , ,1. Replace a rule
is a variable or a terminal, by:
, , ,
are new variables
replace any terminal with a new variable and add the
where , , ,
2. If
rule
withuntil no rules of the form
remain
Chomsky and Greibach Normal Forms – p.10/2
Convert all remaining rules
Repeat
, , where each , ,1. Replace a rule
is a variable or a terminal, by:
, , ,
are new variables
replace any terminal with a new variable and add the
where , , ,
2. If
rule
withuntil no rules of the form
remain
Chomsky and Greibach Normal Forms – p.10/2
Convert all remaining rules
Repeat
, , where each , ,1. Replace a rule
is a variable or a terminal, by:
, , ,
are new variables
replace any terminal with a new variable and add the
where , , ,
2. If
rule
withuntil no rules of the form
remain
Chomsky and Greibach Normal Forms – p.10/2
Example CFG conversion
Chomsky and Greibach Normal Forms – p.11/2
Consider the grammar whose rules are:
Notation: symbols removed are green and those added are red.
After fi rst step of transformation we get:
Example CFG conversion
Chomsky and Greibach Normal Forms – p.11/2
Consider the grammar whose rules are:
Notation: symbols removed are green and those added are red.
After fi rst step of transformation we get:
Example CFG conversion
Chomsky and Greibach Normal Forms – p.11/2
Consider the grammar whose rules are:
Notation: symbols removed are green and those added are red.
After fi rst step of transformation we get:
Removing
Chomsky and Greibach Normal Forms – p.12/2
rules
Removing :
Removing :
Removing
Chomsky and Greibach Normal Forms – p.12/2
rules
Removing :
Removing :
Removing
Chomsky and Greibach Normal Forms – p.12/2
rules
Removing :
Removing :
Removing unit rule
Chomsky and Greibach Normal Forms – p.13/2
Removing :
Removing :
Removing unit rule
Chomsky and Greibach Normal Forms – p.13/2
Removing :
Removing :
Removing unit rule
Chomsky and Greibach Normal Forms – p.13/2
Removing :
Removing :
More unit rules
Chomsky and Greibach Normal Forms – p.14/2
Removing :
Removing :
More unit rules
Chomsky and Greibach Normal Forms – p.14/2
Removing :
Removing :
More unit rules
Chomsky and Greibach Normal Forms – p.14/2
Removing :
Removing :
Converting remaining rules
Chomsky and Greibach Normal Forms – p.15/2
Converting remaining rules
Chomsky and Greibach Normal Forms – p.15/2
Converting remaining rules
Chomsky and Greibach Normal Forms – p.15/2
Note
The conversion procedure produces several
variables along with several rules .
Since all these represent the same rule, we
may simplify the result using a single variable
and a single rule
Chomsky and Greibach Normal Forms – p.16/2
Note
The conversion procedure produces several
variables along with several rules .
Since all these represent the same rule, we
may simplify the result using a single variable
and a single rule
Chomsky and Greibach Normal Forms – p.16/2
Note
The conversion procedure produces several
variables along with several rules .
Since all these represent the same rule, we
may simplify the result using a single variable
and a single rule
Chomsky and Greibach Normal Forms – p.16/2
Greibach Normal Form
is in
has the
and
A context-free grammar
Greibach normal form if each rule
property: , ,
.
Chomsky and Greibach Normal Forms – p.17/2
Note: Greibach normal form provides a justifi ca-
tion of operator prefi x-notation usually employed
in algebra.
Greibach Normal Form
is in
has the
and
A context-free grammar
Greibach normal form if each rule
property: , ,
.
Chomsky and Greibach Normal Forms – p.17/2
Note: Greibach normal form provides a justifi ca-
tion of operator prefi x-notation usually employed
in algebra.
Greibach Normal Form
is in
has the
and
A context-free grammar
Greibach normal form if each rule
property: , ,
.
Chomsky and Greibach Normal Forms – p.17/2
Note: Greibach normal form provides a justifi ca-
tion of operator prefi x-notation usually employed
in algebra.
Greibach Theorem
Every CFL where can be generated by a
CFG in Greibach normal form.
Chomsky and Greibach Normal Forms – p.18/2
be a CFG generating . Assume thatProof idea: Let
is in Chomsky normal form
Let be an ordering of nonterminals.
Construct the Greibach normal form from Chomsky normal form
Greibach Theorem
Every CFL where can be generated by a
CFG in Greibach normal form.
Chomsky and Greibach Normal Forms – p.18/2
be a CFG generating . Assume thatProof idea: Let
is in Chomsky normal form
Let be an ordering of nonterminals.
Construct the Greibach normal form from Chomsky normal form
Greibach Theorem
Every CFL where can be generated by a
CFG in Greibach normal form.
Chomsky and Greibach Normal Forms – p.18/2
be a CFG generating . Assume thatProof idea: Let
is in Chomsky normal form
Let be an ordering of nonterminals.
Construct the Greibach normal form from Chomsky normal form
Construction
Chomsky and Greibach Normal Forms – p.19/2
so that if1. Modify the rules in
2. Starting with and proceeding to
then
this is done as follows:
(a) Assume that productions have been modifi ed so that for
,
(b) If
only if
is a production with , generate a new set of
the rhs of eachproductions substituting for the
production
times we obtain rules of the form(c) Repeating (b) at most
,
(d) Replace rules by removing left-recursive rules
Construction
Chomsky and Greibach Normal Forms – p.19/2
so that if1. Modify the rules in
2. Starting with and proceeding to
then
this is done as follows:
(a) Assume that productions have been modifi ed so that for
,
(b) If
only if
is a production with , generate a new set of
the rhs of eachproductions substituting for the
production
times we obtain rules of the form(c) Repeating (b) at most
,
(d) Replace rules by removing left-recursive rules
Construction
Chomsky and Greibach Normal Forms – p.19/2
so that if1. Modify the rules in
2. Starting with and proceeding to
then
this is done as follows:
(a) Assume that productions have been modifi ed so that for
,
(b) If
only if
is a production with , generate a new set of
the rhs of eachproductions substituting for the
production
times we obtain rules of the form(c) Repeating (b) at most
,
(d) Replace rules by removing left-recursive rules
Removing left-recursion
Chomsky and Greibach Normal Forms – p.20/2
Left-recursion can be eliminated by the following
scheme:
If are all left recursive rules, and
are all remaining -rules then chose a
new
nonterminal, sayAdd the new
Replace the
-rules ,
-rules by ,
This construction preserve the language .
Removing left-recursion
Chomsky and Greibach Normal Forms – p.20/2
Left-recursion can be eliminated by the following
scheme:
If are all left recursive rules, and
are all remaining -rules then chose a
new
nonterminal, sayAdd the new
Replace the
-rules ,
-rules by ,
This construction preserve the language .
Removing left-recursion
Chomsky and Greibach Normal Forms – p.20/2
Left-recursion can be eliminated by the following
scheme:
If are all left recursive rules, and
are all remaining -rules then chose a
new
nonterminal, sayAdd the new
Replace the
-rules ,
-rules by ,
This construction preserve the language .
21-1
More on Greibach NF
Chomsky and Greibach Normal Forms – p.22/2
See Introduction to Automata Theory, Languages,
and Computation, J.E, Hopcroft and J.D Ullman,
Addison-Wesley 1979, p. 94–96
Example
Chomsky and Greibach Normal Forms – p.23/2
Convert the CFG
where
into Greibach normal form.
Example
Chomsky and Greibach Normal Forms – p.23/2
Convert the CFG
where
into Greibach normal form.
Example
Chomsky and Greibach Normal Forms – p.23/2
Convert the CFG
where
into Greibach normal form.
Solution
Chomsky and Greibach Normal Forms – p.24/2
1. Step 1: ordering the rules: (Only rules violate ordering
conditions, hence only rules need to be changed).
Following the procedure we replace rules by:
2. Eliminating left-recursion we get: ,
3. All rules start with a terminal. We use them to replace
. This introduces the rules
4. Use production to make them start with a terminal
Solution
Chomsky and Greibach Normal Forms – p.24/2
1. Step 1: ordering the rules: (Only rules violate ordering
conditions, hence only rules need to be changed).
Following the procedure we replace rules by:
2. Eliminating left-recursion we get: ,
3. All rules start with a terminal. We use them to replace
. This introduces the rules
4. Use production to make them start with a terminal
Solution
Chomsky and Greibach Normal Forms – p.24/2
1. Step 1: ordering the rules: (Only rules violate ordering
conditions, hence only rules need to be changed).
Following the procedure we replace rules by:
2. Eliminating left-recursion we get: ,
3. All rules start with a terminal. We use them to replace
. This introduces the rules
4. Use production to make them start with a terminal

Normal forms cfg

  • 1.
    Chomsky and GreibachNormal Forms Chomsky and Greibach Normal Forms – p.1/2
  • 2.
    Simplifying a CFG Chomskyand Greibach Normal Forms – p.2/2 It is often convenient to simplify CFG
  • 3.
    Simplifying a CFG Chomskyand Greibach Normal Forms – p.2/2 It is often convenient to simplify CFG One of the simplest and most useful simplified forms of CFG is called the Chomsky normal form
  • 4.
    Simplifying a CFG Chomskyand Greibach Normal Forms – p.2/2 It is often convenient to simplify CFG One of the simplest and most useful simplified forms of CFG is called the Chomsky normal form Another normal form usually used in algebraic specifications is Greibach normal form
  • 5.
    Simplifying a CFG Chomskyand Greibach Normal Forms – p.2/2 It is often convenient to simplify CFG One of the simplest and most useful simplified forms of CFG is called the Chomsky normal form Another normal form usually used in algebraic specifications is Greibach normal form Note the difference between grammar cleaning and simplifi cation
  • 6.
    Note Chomsky and GreibachNormal Forms – p.3/2 Normal forms are useful when more advanced topics in computation theory are approached, as we shall see further
  • 7.
    Definition Chomsky and GreibachNormal Forms – p.4/2 is in Chomsky normal form ifA context-free grammar every rule is of the form: where is a terminal, are nonterminals, and may not be the start variable (the axiom)
  • 8.
    Note Chomsky and GreibachNormal Forms – p.5/2 The rule , where is the start variable, is not ex- cluded from a CFG in Chomsky normal form.
  • 9.
    Theorem 2.9 Chomsky andGreibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form.
  • 10.
    Theorem 2.9 Chomsky andGreibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea:
  • 11.
    Theorem 2.9 Chomsky andGreibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Show that any CFG can be converted into a CFG in Chomsky normal form
  • 12.
    Theorem 2.9 Chomsky andGreibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Show that any CFG can be converted into a CFG in Chomsky normal form Conversion procedure has several stages where the rules that violate Chomsky normal form conditions are replaced with equivalent rules that satisfy these conditions
  • 13.
    Theorem 2.9 Chomsky andGreibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Show that any CFG can be converted into a CFG in Chomsky normal form Conversion procedure has several stages where the rules that violate Chomsky normal form conditions are replaced with equivalent rules that satisfy these conditions Order of transformations: (1) add a new start variable, (2) eliminate all-rules, (3) eliminate unit-rules, (4) convert other rules
  • 14.
    Theorem 2.9 Chomsky andGreibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Show that any CFG can be converted into a CFG in Chomsky normal form Conversion procedure has several stages where the rules that violate Chomsky normal form conditions are replaced with equivalent rules that satisfy these conditions Order of transformations: (1) add a new start variable, (2) eliminate all-rules, (3) eliminate unit-rules, (4) convert other rules Check that the obtained CFG defi nes the same language
  • 15.
    Proof Chomsky and GreibachNormal Forms – p.7/2 Let be the original CFG.
  • 16.
    Proof Chomsky and GreibachNormal Forms – p.7/2 Let be the original CFG. Step 1: add a new start symbol to , and the rule to
  • 17.
    Proof Chomsky and GreibachNormal Forms – p.7/2 Let be the original CFG. to does not occur Step 1: add a new start symbol to , and the rule Note: this change guarantees that the startsymbol of on the of any rule
  • 18.
    Step 2: eliminate Chomskyand Greibach Normal Forms – p.8/2 -rules Repeat 1. Eliminate the rule from where is not the start symbol 2. For each occurrence of on the of a rule, add a new rule to with that occurrence of deleted Example: replace by ; unless the replace by 3. Replace the rule , (if it is present) by rule has been previously eliminated until all rules are eliminated
  • 19.
    Step 3: removeunit rules Chomsky and Greibach Normal Forms – p.9/2 Repeat 1. Remove a unit rule 2. For each rule , add the rule to , unless was a unit rule previously removed until all unit rules are eliminated Note: is a string of variables and terminals
  • 20.
    Convert all remainingrules Repeat , , where each , ,1. Replace a rule is a variable or a terminal, by: , , , are new variables replace any terminal with a new variable and add the where , , , 2. If rule withuntil no rules of the form remain Chomsky and Greibach Normal Forms – p.10/2
  • 21.
    Convert all remainingrules Repeat , , where each , ,1. Replace a rule is a variable or a terminal, by: , , , are new variables replace any terminal with a new variable and add the where , , , 2. If rule withuntil no rules of the form remain Chomsky and Greibach Normal Forms – p.10/2
  • 22.
    Convert all remainingrules Repeat , , where each , ,1. Replace a rule is a variable or a terminal, by: , , , are new variables replace any terminal with a new variable and add the where , , , 2. If rule withuntil no rules of the form remain Chomsky and Greibach Normal Forms – p.10/2
  • 23.
    Example CFG conversion Chomskyand Greibach Normal Forms – p.11/2 Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After fi rst step of transformation we get:
  • 24.
    Example CFG conversion Chomskyand Greibach Normal Forms – p.11/2 Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After fi rst step of transformation we get:
  • 25.
    Example CFG conversion Chomskyand Greibach Normal Forms – p.11/2 Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After fi rst step of transformation we get:
  • 26.
    Removing Chomsky and GreibachNormal Forms – p.12/2 rules Removing : Removing :
  • 27.
    Removing Chomsky and GreibachNormal Forms – p.12/2 rules Removing : Removing :
  • 28.
    Removing Chomsky and GreibachNormal Forms – p.12/2 rules Removing : Removing :
  • 29.
    Removing unit rule Chomskyand Greibach Normal Forms – p.13/2 Removing : Removing :
  • 30.
    Removing unit rule Chomskyand Greibach Normal Forms – p.13/2 Removing : Removing :
  • 31.
    Removing unit rule Chomskyand Greibach Normal Forms – p.13/2 Removing : Removing :
  • 32.
    More unit rules Chomskyand Greibach Normal Forms – p.14/2 Removing : Removing :
  • 33.
    More unit rules Chomskyand Greibach Normal Forms – p.14/2 Removing : Removing :
  • 34.
    More unit rules Chomskyand Greibach Normal Forms – p.14/2 Removing : Removing :
  • 35.
    Converting remaining rules Chomskyand Greibach Normal Forms – p.15/2
  • 36.
    Converting remaining rules Chomskyand Greibach Normal Forms – p.15/2
  • 37.
    Converting remaining rules Chomskyand Greibach Normal Forms – p.15/2
  • 38.
    Note The conversion procedureproduces several variables along with several rules . Since all these represent the same rule, we may simplify the result using a single variable and a single rule Chomsky and Greibach Normal Forms – p.16/2
  • 39.
    Note The conversion procedureproduces several variables along with several rules . Since all these represent the same rule, we may simplify the result using a single variable and a single rule Chomsky and Greibach Normal Forms – p.16/2
  • 40.
    Note The conversion procedureproduces several variables along with several rules . Since all these represent the same rule, we may simplify the result using a single variable and a single rule Chomsky and Greibach Normal Forms – p.16/2
  • 41.
    Greibach Normal Form isin has the and A context-free grammar Greibach normal form if each rule property: , , . Chomsky and Greibach Normal Forms – p.17/2 Note: Greibach normal form provides a justifi ca- tion of operator prefi x-notation usually employed in algebra.
  • 42.
    Greibach Normal Form isin has the and A context-free grammar Greibach normal form if each rule property: , , . Chomsky and Greibach Normal Forms – p.17/2 Note: Greibach normal form provides a justifi ca- tion of operator prefi x-notation usually employed in algebra.
  • 43.
    Greibach Normal Form isin has the and A context-free grammar Greibach normal form if each rule property: , , . Chomsky and Greibach Normal Forms – p.17/2 Note: Greibach normal form provides a justifi ca- tion of operator prefi x-notation usually employed in algebra.
  • 44.
    Greibach Theorem Every CFLwhere can be generated by a CFG in Greibach normal form. Chomsky and Greibach Normal Forms – p.18/2 be a CFG generating . Assume thatProof idea: Let is in Chomsky normal form Let be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form
  • 45.
    Greibach Theorem Every CFLwhere can be generated by a CFG in Greibach normal form. Chomsky and Greibach Normal Forms – p.18/2 be a CFG generating . Assume thatProof idea: Let is in Chomsky normal form Let be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form
  • 46.
    Greibach Theorem Every CFLwhere can be generated by a CFG in Greibach normal form. Chomsky and Greibach Normal Forms – p.18/2 be a CFG generating . Assume thatProof idea: Let is in Chomsky normal form Let be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form
  • 47.
    Construction Chomsky and GreibachNormal Forms – p.19/2 so that if1. Modify the rules in 2. Starting with and proceeding to then this is done as follows: (a) Assume that productions have been modifi ed so that for , (b) If only if is a production with , generate a new set of the rhs of eachproductions substituting for the production times we obtain rules of the form(c) Repeating (b) at most , (d) Replace rules by removing left-recursive rules
  • 48.
    Construction Chomsky and GreibachNormal Forms – p.19/2 so that if1. Modify the rules in 2. Starting with and proceeding to then this is done as follows: (a) Assume that productions have been modifi ed so that for , (b) If only if is a production with , generate a new set of the rhs of eachproductions substituting for the production times we obtain rules of the form(c) Repeating (b) at most , (d) Replace rules by removing left-recursive rules
  • 49.
    Construction Chomsky and GreibachNormal Forms – p.19/2 so that if1. Modify the rules in 2. Starting with and proceeding to then this is done as follows: (a) Assume that productions have been modifi ed so that for , (b) If only if is a production with , generate a new set of the rhs of eachproductions substituting for the production times we obtain rules of the form(c) Repeating (b) at most , (d) Replace rules by removing left-recursive rules
  • 50.
    Removing left-recursion Chomsky andGreibach Normal Forms – p.20/2 Left-recursion can be eliminated by the following scheme: If are all left recursive rules, and are all remaining -rules then chose a new nonterminal, sayAdd the new Replace the -rules , -rules by , This construction preserve the language .
  • 51.
    Removing left-recursion Chomsky andGreibach Normal Forms – p.20/2 Left-recursion can be eliminated by the following scheme: If are all left recursive rules, and are all remaining -rules then chose a new nonterminal, sayAdd the new Replace the -rules , -rules by , This construction preserve the language .
  • 52.
    Removing left-recursion Chomsky andGreibach Normal Forms – p.20/2 Left-recursion can be eliminated by the following scheme: If are all left recursive rules, and are all remaining -rules then chose a new nonterminal, sayAdd the new Replace the -rules , -rules by , This construction preserve the language .
  • 53.
  • 54.
    More on GreibachNF Chomsky and Greibach Normal Forms – p.22/2 See Introduction to Automata Theory, Languages, and Computation, J.E, Hopcroft and J.D Ullman, Addison-Wesley 1979, p. 94–96
  • 55.
    Example Chomsky and GreibachNormal Forms – p.23/2 Convert the CFG where into Greibach normal form.
  • 56.
    Example Chomsky and GreibachNormal Forms – p.23/2 Convert the CFG where into Greibach normal form.
  • 57.
    Example Chomsky and GreibachNormal Forms – p.23/2 Convert the CFG where into Greibach normal form.
  • 58.
    Solution Chomsky and GreibachNormal Forms – p.24/2 1. Step 1: ordering the rules: (Only rules violate ordering conditions, hence only rules need to be changed). Following the procedure we replace rules by: 2. Eliminating left-recursion we get: , 3. All rules start with a terminal. We use them to replace . This introduces the rules 4. Use production to make them start with a terminal
  • 59.
    Solution Chomsky and GreibachNormal Forms – p.24/2 1. Step 1: ordering the rules: (Only rules violate ordering conditions, hence only rules need to be changed). Following the procedure we replace rules by: 2. Eliminating left-recursion we get: , 3. All rules start with a terminal. We use them to replace . This introduces the rules 4. Use production to make them start with a terminal
  • 60.
    Solution Chomsky and GreibachNormal Forms – p.24/2 1. Step 1: ordering the rules: (Only rules violate ordering conditions, hence only rules need to be changed). Following the procedure we replace rules by: 2. Eliminating left-recursion we get: , 3. All rules start with a terminal. We use them to replace . This introduces the rules 4. Use production to make them start with a terminal