You are on page 1of 22

Taibah University

College of Computer Science & Engineering


Course Title: Theory of Computation
Course Code: CS 301

Chapter 6
Chomsky Normal Forms and Greibach Normal
Form

Text Book: Peter Linz, Introduction to Formal Languages and automata 6th edition, 2017.
This presentation is for academic use only in Taibah University, KSA
Removing Productions
Removing Productions
Step 01: To remove A→ B, add production A→x to grammar rule whenever B→x
occurs in the grammar where [x belong to terminal, x can also be Null]

Step 2: Delete A→B from the grammar.

Step 3: Repeat from step 1 until all unit productions are removed.

Example:
S 0A|1B|C
A  0S|00
B  1|A CFG becomes:
C  01 S  0A|1B|01
A  0S|00
Step 1 B  1|0S|00
S  C is unit production but while removing S  C, C  01
we have to consider what C gives so we can add a rule to S.
   S  0A|1B|01
Step 2
B  A is also unit production
B  1|0S|00
Chomsky Normal Form

𝜆
Example 1
Chomsky Normal Form
:Conversion of CFG to CNF steps

𝜆 𝜆 𝜆
Example 2
Example 3

𝜆
𝜆
𝜆
𝜆 𝜆

𝜆
Example 4

:Example Convert the following CFG to CNF


Original CFG Equivalent CNF
S S0 |Y1U3| U0U3 | Y2U1|U0U1|Y3U3|U2U3
A1
A2 A1
B
C A2 Y3U3|U2U3

C
Greibach Normal Form
Greibach Normal Form
Example 1
Example 2
Exercises:

Section 6.2: 2, 3, 4, 5

You might also like