Chomsky and Greibach Normal
Forms
Chomsky and Greibach Normal Forms – p.1/24
Simplifying a CFG
It is often convenient to simplify CFG
Chomsky and Greibach Normal Forms – p.2/24
Simplifying a CFG
It is often convenient to simplify CFG
One of the simplest and most useful simplified forms of
CFG is called the Chomsky normal form
Chomsky and Greibach Normal Forms – p.2/24
Simplifying a CFG
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
Chomsky and Greibach Normal Forms – p.2/24
Simplifying a CFG
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 simplification
Chomsky and Greibach Normal Forms – p.2/24
Note
Normal forms are useful when more advanced topics in
computation theory are approached, as we shall see further
Chomsky and Greibach Normal Forms – p.3/24
Definition
A context-free grammar is in Chomsky normal form if
every rule is of the form:









where

is a terminal, 




are nonterminals, and



may not be the start variable (the axiom)
Chomsky and Greibach Normal Forms – p.4/24
Note
The rule



, where is the start variable, is not ex-
cluded from a CFG in Chomsky normal form.
Chomsky and Greibach Normal Forms – p.5/24
Theorem 2.9
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Chomsky and Greibach Normal Forms – p.6/24
Theorem 2.9
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Chomsky and Greibach Normal Forms – p.6/24
Theorem 2.9
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
Chomsky and Greibach Normal Forms – p.6/24
Theorem 2.9
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
Chomsky and Greibach Normal Forms – p.6/24
Theorem 2.9
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
Chomsky and Greibach Normal Forms – p.6/24
Theorem 2.9
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

defines the same language
Chomsky and Greibach Normal Forms – p.6/24
Proof
Let








be the original CFG.
Chomsky and Greibach Normal Forms – p.7/24
Proof
Let








be the original CFG.
Step 1: add a new start symbol


to

, and the rule




to

Chomsky and Greibach Normal Forms – p.7/24
Proof
Let








be the original CFG.
Step 1: add a new start symbol


to

, and the rule




to

Note: this change guarantees that the start symbol of

does not occur
on the



of any rule
Chomsky and Greibach Normal Forms – p.7/24
Step 2: eliminate -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









;
replace








 by
















	









3. Replace the rule




, (if it is present) by





unless the
rule



has been previously eliminated
until all

rules are eliminated
Chomsky and Greibach Normal Forms – p.8/24
Step 3: remove unit rules
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
Chomsky and Greibach Normal Forms – p.9/24
Convert all remaining rules
Repeat
1. Replace a rule











,



, where each


,

	


	

,
is a variable or a terminal, by:





, 






,



,
where

,


,



,
are new variables
2. If



replace any terminal


with a new variable


and add the
rule






until no rules of the form











with


remain
Chomsky and Greibach Normal Forms – p.10/24
Convert all remaining rules
Repeat
1. Replace a rule











,



, where each


,

	


	

,
is a variable or a terminal, by:





, 






,



,
where

,


,



,
are new variables
2. If



replace any terminal


with a new variable


and add the
rule






until no rules of the form











with


remain
Chomsky and Greibach Normal Forms – p.10/24
Convert all remaining rules
Repeat
1. Replace a rule











,



, where each


,

	


	

,
is a variable or a terminal, by:





, 






,



,
where

,


,



,
are new variables
2. If



replace any terminal


with a new variable


and add the
rule






until no rules of the form











with


remain
Chomsky and Greibach Normal Forms – p.10/24
Example CFG conversion
Consider the grammar

whose rules are:

















Notation: symbols removed are green and those added are red.
After first step of transformation we get:








	












Chomsky and Greibach Normal Forms – p.11/24
Example CFG conversion
Consider the grammar

whose rules are:

















Notation: symbols removed are green and those added are red.
After first step of transformation we get:








	












Chomsky and Greibach Normal Forms – p.11/24
Example CFG conversion
Consider the grammar

whose rules are:

















Notation: symbols removed are green and those added are red.
After first step of transformation we get:








	












Chomsky and Greibach Normal Forms – p.11/24
Removing rules
Removing


:











	





	




	






Removing


:
Chomsky and Greibach Normal Forms – p.12/24
Removing rules
Removing


:











	





	




	






Removing


:
Chomsky and Greibach Normal Forms – p.12/24
Removing rules
Removing


:











	





	




	






Removing


:
Chomsky and Greibach Normal Forms – p.12/24
Removing unit rule
Removing

:











	











	

	



Removing


:
Chomsky and Greibach Normal Forms – p.13/24
Removing unit rule
Removing

:











	











	

	



Removing


:
Chomsky and Greibach Normal Forms – p.13/24
Removing unit rule
Removing

:











	











	

	



Removing


:
Chomsky and Greibach Normal Forms – p.13/24
More unit rules
Removing



:








	














	










	



	



Removing


:








	














	

















	






	



Chomsky and Greibach Normal Forms – p.14/24
More unit rules
Removing



:








	














	










	



	



Removing


:








	














	

















	






	



Chomsky and Greibach Normal Forms – p.14/24
More unit rules
Removing



:








	














	










	



	



Removing


:








	














	

















	






	



Chomsky and Greibach Normal Forms – p.14/24
Converting remaining rules






































	

















Chomsky and Greibach Normal Forms – p.15/24
Converting remaining rules






































	

















Chomsky and Greibach Normal Forms – p.15/24
Converting remaining rules






































	

















Chomsky and Greibach Normal Forms – p.15/24
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/24
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/24
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/24
Greibach Normal Form
A context-free grammar






is in
Greibach normal form if each rule


has the
property: 

	




,


	





,

and




.
Note: Greibach normal form provides a justifica-
tion of operator prefix-notation usually employed
in algebra.
Chomsky and Greibach Normal Forms – p.17/24
Greibach Normal Form
A context-free grammar






is in
Greibach normal form if each rule


has the
property: 

	




,


	





,

and




.
Note: Greibach normal form provides a justifica-
tion of operator prefix-notation usually employed
in algebra.
Chomsky and Greibach Normal Forms – p.17/24
Greibach Normal Form
A context-free grammar






is in
Greibach normal form if each rule


has the
property: 

	




,


	





,

and




.
Note: Greibach normal form provides a justifica-
tion of operator prefix-notation usually employed
in algebra.
Chomsky and Greibach Normal Forms – p.17/24
Greibach Theorem
Every CFL where


can be generated by a
CFG in Greibach normal form.
Proof idea: Let 









	
be a CFG generating


. Assume that
is in Chomsky normal form
Let
be an ordering of nonterminals.
Construct the Greibach normal form from Chomsky normal form
Chomsky and Greibach Normal Forms – p.18/24
Greibach Theorem
Every CFL where


can be generated by a
CFG in Greibach normal form.
Proof idea: Let 









	
be a CFG generating


. Assume that
is in Chomsky normal form
Let
be an ordering of nonterminals.
Construct the Greibach normal form from Chomsky normal form
Chomsky and Greibach Normal Forms – p.18/24
Greibach Theorem
Every CFL where


can be generated by a
CFG in Greibach normal form.
Proof idea: Let 









	
be a CFG generating


. Assume that
is in Chomsky normal form
Let

More Related Content

PPTX
Normal forms cfg
PPT
Chomsky by zeeshan khan and Raheel Khan
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
PDF
2024 State of Marketing Report – by Hubspot
PDF
Everything You Need To Know About ChatGPT
Normal forms cfg
Chomsky by zeeshan khan and Raheel Khan
2024 Trend Updates: What Really Works In SEO & Content Marketing
Storytelling For The Web: Integrate Storytelling in your Design Process
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT

Recently uploaded (20)

PPTX
20th Century Theater, Methods, History.pptx
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Virtual and Augmented Reality in Current Scenario
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PPTX
History, Philosophy and sociology of education (1).pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
My India Quiz Book_20210205121199924.pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
HVAC Specification 2024 according to central public works department
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
20th Century Theater, Methods, History.pptx
Environmental Education MCQ BD2EE - Share Source.pdf
Uderstanding digital marketing and marketing stratergie for engaging the digi...
Weekly quiz Compilation Jan -July 25.pdf
Unit 4 Computer Architecture Multicore Processor.pptx
What if we spent less time fighting change, and more time building what’s rig...
Virtual and Augmented Reality in Current Scenario
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
History, Philosophy and sociology of education (1).pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Chinmaya Tiranga quiz Grand Finale.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
My India Quiz Book_20210205121199924.pdf
Paper A Mock Exam 9_ Attempt review.pdf.
Hazard Identification & Risk Assessment .pdf
TNA_Presentation-1-Final(SAVE)) (1).pptx
HVAC Specification 2024 according to central public works department
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Ad
Ad

Cfg3

  • 1. Chomsky and Greibach Normal Forms Chomsky and Greibach Normal Forms – p.1/24
  • 2. Simplifying a CFG It is often convenient to simplify CFG Chomsky and Greibach Normal Forms – p.2/24
  • 3. Simplifying a CFG It is often convenient to simplify CFG One of the simplest and most useful simplified forms of CFG is called the Chomsky normal form Chomsky and Greibach Normal Forms – p.2/24
  • 4. Simplifying a CFG 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 Chomsky and Greibach Normal Forms – p.2/24
  • 5. Simplifying a CFG 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 simplification Chomsky and Greibach Normal Forms – p.2/24
  • 6. Note Normal forms are useful when more advanced topics in computation theory are approached, as we shall see further Chomsky and Greibach Normal Forms – p.3/24
  • 7. Definition A context-free grammar is in Chomsky normal form if every rule is of the form: where is a terminal, are nonterminals, and may not be the start variable (the axiom) Chomsky and Greibach Normal Forms – p.4/24
  • 8. Note The rule , where is the start variable, is not ex- cluded from a CFG in Chomsky normal form. Chomsky and Greibach Normal Forms – p.5/24
  • 9. Theorem 2.9 Any context-free language is generated by a context-free grammar in Chomsky normal form. Chomsky and Greibach Normal Forms – p.6/24
  • 10. Theorem 2.9 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Chomsky and Greibach Normal Forms – p.6/24
  • 11. Theorem 2.9 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 Chomsky and Greibach Normal Forms – p.6/24
  • 12. Theorem 2.9 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 Chomsky and Greibach Normal Forms – p.6/24
  • 13. Theorem 2.9 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 Chomsky and Greibach Normal Forms – p.6/24
  • 14. Theorem 2.9 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 defines the same language Chomsky and Greibach Normal Forms – p.6/24
  • 15. Proof Let be the original CFG. Chomsky and Greibach Normal Forms – p.7/24
  • 16. Proof Let be the original CFG. Step 1: add a new start symbol to , and the rule to Chomsky and Greibach Normal Forms – p.7/24
  • 17. Proof Let be the original CFG. Step 1: add a new start symbol to , and the rule to Note: this change guarantees that the start symbol of does not occur on the of any rule Chomsky and Greibach Normal Forms – p.7/24
  • 18. Step 2: eliminate -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 ; replace by 3. Replace the rule , (if it is present) by unless the rule has been previously eliminated until all rules are eliminated Chomsky and Greibach Normal Forms – p.8/24
  • 19. Step 3: remove unit rules 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 Chomsky and Greibach Normal Forms – p.9/24
  • 20. Convert all remaining rules Repeat 1. Replace a rule , , where each , , is a variable or a terminal, by: , , ,
  • 22. are new variables 2. If replace any terminal with a new variable and add the rule until no rules of the form with remain Chomsky and Greibach Normal Forms – p.10/24
  • 23. Convert all remaining rules Repeat 1. Replace a rule , , where each , , is a variable or a terminal, by: , , ,
  • 25. are new variables 2. If replace any terminal with a new variable and add the rule until no rules of the form with remain Chomsky and Greibach Normal Forms – p.10/24
  • 26. Convert all remaining rules Repeat 1. Replace a rule , , where each , , is a variable or a terminal, by: , , ,
  • 28. are new variables 2. If replace any terminal with a new variable and add the rule until no rules of the form with remain Chomsky and Greibach Normal Forms – p.10/24
  • 29. Example CFG conversion Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After first step of transformation we get: Chomsky and Greibach Normal Forms – p.11/24
  • 30. Example CFG conversion Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After first step of transformation we get: Chomsky and Greibach Normal Forms – p.11/24
  • 31. Example CFG conversion Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After first step of transformation we get: Chomsky and Greibach Normal Forms – p.11/24
  • 33. Chomsky and Greibach Normal Forms – p.12/24
  • 35. Chomsky and Greibach Normal Forms – p.12/24
  • 37. Chomsky and Greibach Normal Forms – p.12/24
  • 39. Chomsky and Greibach Normal Forms – p.13/24
  • 41. Chomsky and Greibach Normal Forms – p.13/24
  • 43. Chomsky and Greibach Normal Forms – p.13/24
  • 44. More unit rules Removing : Removing : Chomsky and Greibach Normal Forms – p.14/24
  • 45. More unit rules Removing : Removing : Chomsky and Greibach Normal Forms – p.14/24
  • 46. More unit rules Removing : Removing : Chomsky and Greibach Normal Forms – p.14/24
  • 47. Converting remaining rules Chomsky and Greibach Normal Forms – p.15/24
  • 48. Converting remaining rules Chomsky and Greibach Normal Forms – p.15/24
  • 49. Converting remaining rules Chomsky and Greibach Normal Forms – p.15/24
  • 50. 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/24
  • 51. 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/24
  • 52. 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/24
  • 53. Greibach Normal Form A context-free grammar is in Greibach normal form if each rule has the property: , , and . Note: Greibach normal form provides a justifica- tion of operator prefix-notation usually employed in algebra. Chomsky and Greibach Normal Forms – p.17/24
  • 54. Greibach Normal Form A context-free grammar is in Greibach normal form if each rule has the property: , , and . Note: Greibach normal form provides a justifica- tion of operator prefix-notation usually employed in algebra. Chomsky and Greibach Normal Forms – p.17/24
  • 55. Greibach Normal Form A context-free grammar is in Greibach normal form if each rule has the property: , , and . Note: Greibach normal form provides a justifica- tion of operator prefix-notation usually employed in algebra. Chomsky and Greibach Normal Forms – p.17/24
  • 56. Greibach Theorem Every CFL where can be generated by a CFG in Greibach normal form. Proof idea: Let be a CFG generating . Assume that is in Chomsky normal form Let
  • 57. be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form Chomsky and Greibach Normal Forms – p.18/24
  • 58. Greibach Theorem Every CFL where can be generated by a CFG in Greibach normal form. Proof idea: Let be a CFG generating . Assume that is in Chomsky normal form Let
  • 59. be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form Chomsky and Greibach Normal Forms – p.18/24
  • 60. Greibach Theorem Every CFL where can be generated by a CFG in Greibach normal form. Proof idea: Let be a CFG generating . Assume that is in Chomsky normal form Let
  • 61. be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form Chomsky and Greibach Normal Forms – p.18/24
  • 62. Construction 1. Modify the rules in so that if then 2. Starting with and proceeding to
  • 63. this is done as follows: (a) Assume that productions have been modified so that for , only if (b) If is a production with , generate a new set of productions substituting for the the rhs of each production (c) Repeating (b) at most times we obtain rules of the form , (d) Replace rules by removing left-recursive rules Chomsky and Greibach Normal Forms – p.19/24
  • 64. Construction 1. Modify the rules in so that if then 2. Starting with and proceeding to
  • 65. this is done as follows: (a) Assume that productions have been modified so that for , only if (b) If is a production with , generate a new set of productions substituting for the the rhs of each production (c) Repeating (b) at most times we obtain rules of the form , (d) Replace rules by removing left-recursive rules Chomsky and Greibach Normal Forms – p.19/24
  • 66. Construction 1. Modify the rules in so that if then 2. Starting with and proceeding to
  • 67. this is done as follows: (a) Assume that productions have been modified so that for , only if (b) If is a production with , generate a new set of productions substituting for the the rhs of each production (c) Repeating (b) at most times we obtain rules of the form , (d) Replace rules by removing left-recursive rules Chomsky and Greibach Normal Forms – p.19/24
  • 68. Removing left-recursion 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, say Add the new -rules , Replace the -rules by , This construction preserve the language . Chomsky and Greibach Normal Forms – p.20/24
  • 69. Removing left-recursion 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, say Add the new -rules , Replace the -rules by , This construction preserve the language . Chomsky and Greibach Normal Forms – p.20/24
  • 70. Removing left-recursion 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, say Add the new -rules , Replace the -rules by , This construction preserve the language . Chomsky and Greibach Normal Forms – p.20/24
  • 71. 21-1
  • 72. More on Greibach NF See Introduction to Automata Theory, Languages, and Computation, J.E, Hopcroft and J.D Ullman, Addison-Wesley 1979, p. 94–96 Chomsky and Greibach Normal Forms – p.22/24
  • 73. Example Convert the CFG where into Greibach normal form. Chomsky and Greibach Normal Forms – p.23/24
  • 74. Example Convert the CFG where into Greibach normal form. Chomsky and Greibach Normal Forms – p.23/24
  • 75. Example Convert the CFG where into Greibach normal form. Chomsky and Greibach Normal Forms – p.23/24
  • 76. Solution 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 Chomsky and Greibach Normal Forms – p.24/24
  • 77. Solution 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 Chomsky and Greibach Normal Forms – p.24/24
  • 78. Solution 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 Chomsky and Greibach Normal Forms – p.24/24