Grammar to Chomsky Normal Form

In summary, the given grammar has the following production rules: E -> E + T | E - T | TT -> T * F | T - F | FF -> (E) | i | εTo convert this grammar to Chomsky Normal Form, we can follow these steps: 1. Remove ε productions: E -> E + T | E - T | T | +T -> T * F | T - F | F | *F -> (E) | i | ε2. Remove unit productions: E -> E1 | E2 | T | +T -> T1 | T2 | F | *F -> (E) | i | εE1
  • #1
MalickT
4
0
I have grammar:

S -> ASA
S -> aB
A -> B
A -> S
B -> b
B -> epsilon (empty string)

Can someone please help me to convert this grammar to Chomsky Normal From so i can do CKY-algorithm
 
Physics news on Phys.org
  • #2
Hi,

S -> ASA | aB
A -> B | S
B -> b | eps

your CNF grammar should be

S -> AS | SA | CB | a
A-> b | AS | SA | CB | a
B -> b
C -> a
 
  • #3
Saw this online and decided to give another version, because I'm not sure if the answer above is correct. Unless there is a rule that allows ASA -> AS | SA that I don't know about.

(From where you left off...)
S -> ASA | aB
A -> B | S
B -> b | eps

(Step 1: remove eps productions)
S -> ASA | aB | a
A -> B | S
B -> b

(Step 2: remove unit productions)
S -> ASA | aB | a
A -> b | ASA | aB | a
B -> b

(Step 3: remove useless productions)
none, all have terminal variable

(Step 4: put into Chomsky form)
S -> DA | CB | a
A -> b | DA | CB | a
B -> b
C -> a
D -> AS
 
  • #4
Can someone help me convert this Grammar to Chomsky Normal Form?

S--->XYx
X--->xxy
Y--->Xw

Thank you.
Urgent Reply Needed
 
  • #6
help me in this
if we have E →E+T/E-T/T
T→T*F/T-F/F
F→(E)/i/ε
how we will solve using chomsky normal form
 

1. What is Chomsky Normal Form (CNF)?

Chomsky Normal Form is a specific form of context-free grammar (CFG), a formal language used to describe the syntax of a language. It is named after linguist Noam Chomsky and is considered to be one of the simplest forms of CFG, making it easier to analyze and process.

2. What is the purpose of converting a grammar to CNF?

The purpose of converting a grammar to CNF is to simplify the grammar and make it more manageable for computational analysis. It also helps to eliminate ambiguity and allows for more efficient parsing algorithms to be used.

3. What are the rules for converting a grammar to CNF?

The rules for converting a grammar to CNF include: 1) Eliminate all epsilon productions (productions that derive the empty string), 2) Eliminate all unit productions (productions with only one nonterminal symbol on the right-hand side), 3) Eliminate all symbols that cannot be reached from the start symbol, 4) Eliminate all productions with more than two nonterminal symbols on the right-hand side, and 5) Replace all remaining productions with two nonterminal symbols on the right-hand side with two productions with only one nonterminal symbol on the right-hand side.

4. What are the benefits of using CNF?

Using CNF has several benefits, including: 1) It simplifies the grammar and makes it easier to analyze and understand, 2) It eliminates ambiguity in the grammar, making it easier to process, 3) It allows for more efficient parsing algorithms to be used, and 4) It is a standard form used in many natural language processing applications.

5. Can any grammar be converted to CNF?

Yes, any context-free grammar can be converted to CNF. However, some grammars may require a large number of steps to be converted, and some may require more advanced techniques to handle specific cases. In general, converting a grammar to CNF is an important step in the process of analyzing and processing languages.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
3
Views
942
  • Linear and Abstract Algebra
Replies
4
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
2K
  • Linear and Abstract Algebra
Replies
20
Views
992
  • Set Theory, Logic, Probability, Statistics
Replies
26
Views
2K
  • General Discussion
Replies
16
Views
1K
Replies
23
Views
2K
  • Linear and Abstract Algebra
Replies
2
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
11
Views
3K
Back
Top