- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Eliminate epsilon, unit and useless symbols and rewrite into CNF

## Problem

Eliminate epsilon, unit and the useless symbols for the given grammar and rewrite it into CNF.

S->0E0|1FF| ε

E->G

F->S|E

G->S| ε

## Solution

In the given grammar, we will first remove the null production. There are two null productions in the grammar, as given below −

S ==> ε

G ==> ε

So, remove null production and rewrite all the other rules containing G by epsilon there, along with old productions. We do not remove S ==> epsilon as it is the start symbol.

Remove G ==> epsilon, we get the following −

S ==> 0E0 | 1FF | ε

E ==> G | ε

F ==> S | E

G ==> S

Now remove E ==> epsilon, we get the following −

S ==> 0E0 | 1FF | 00 | ε

E ==> G

F ==> S | E | ε

G ==> S

Now remove F ==> epsilon, we get the following −

S ==> 0E0 | 1FF | 00 | 1S | 1E | 1 | ε

E ==> G

F ==> S | E

G ==> S

Now, we have to remove unit production, there is only one unit production E ==> G and G ==> S,

By removing G ==> S, we get the following −

S ==> 0E0 | 1FF | 00 | 1S | 1E | 1 | ε

E ==> S

F ==> S | E

Remove E ==> S, we get the following −

S ==> 0S0 | 1FF | 00 | 1S | 1 | ε

F ==> S

Removing F ==> S, we get the following −

S ==> 0S0 | 1SS | 00 | 1S | 1 | ε

Now we have to convert it to Chomsky normal form (CNF). So, we do the following −

Add production A ==> 0, B==>1, C ==> AS and D ==> BS,

We get final grammar as follows −

S ==> CA | DS | BB | AS | 1 | ε

A ==> 0

B ==> 1

C ==> AS

D ==> BS

- Related Articles
- Explain the removal of useless symbols
- Are new HTML5 elements like and useless?
- How to convert NFA with epsilon to without epsilon?
- Electrical Components and Their Symbols
- What are Elements, Compounds and Symbols?
- How to convert a higher unit into a lower unit?
- How to convert a lower unit into a higher unit?
- Z-Transform of Unit Impulse, Unit Step, and Unit Ramp Functions
- Control unit and CPU
- Difference between Hardwired Control Unit and Microprogrammed Control Unit
- Explain NFA with epsilon transition.
- Laplace Transform of Unit Impulse Function and Unit Step Function
- Mention the symbol, unit and base unit of magnetic field
- Explain how to convert CFG to CNF
- How to convert a variable into zero mean and unit variance in an R data frame?