Transform Grammer to Chomsky Normal Form

  • Context: Undergrad 
  • Thread starter Thread starter jferg449
  • Start date Start date
  • Tags Tags
    Form Normal Transform
Click For Summary
SUMMARY

This discussion focuses on transforming a given grammar into Chomsky Normal Form (CNF). The original grammar consists of the productions S → abAB, A → bAB | λ, and B → BAa | A | λ. The transformation process involves splitting rules, eliminating epsilon-productions, and ensuring that all productions conform to CNF by having either two non-terminal symbols or a single terminal symbol. The final CNF includes productions such as S → A'S1, S1 → B'S2, and A' → a, among others.

PREREQUISITES
  • Understanding of context-free grammars
  • Familiarity with Chomsky Normal Form (CNF)
  • Knowledge of epsilon-productions and their elimination
  • Ability to manipulate grammar rules and symbols
NEXT STEPS
  • Study the algorithm for converting grammars to Chomsky Normal Form as outlined in "Introduction to the Theory of Computation" by Michael Sipser
  • Practice transforming various context-free grammars into CNF
  • Learn about the implications of CNF in parsing algorithms
  • Explore the relationship between CNF and pushdown automata
USEFUL FOR

This discussion is beneficial for computer science students, linguists, and anyone involved in formal language theory or compiler design, particularly those working with context-free grammars and their transformations.

jferg449
Messages
1
Reaction score
0
Can anyone help me transform the following G to Chomsky Normal Form?

S --> abAB

A --> bAB | λ

B --> BAa | A | λ


Thanks for your help!
 
Physics news on Phys.org
Don't your textbook have some kind of algorithm for doing this? I know that my copy of "Introduction to the Theory of Computation" by Michael Sipser has one right after the definition of Chomsky normal form.

We first we split up rules to get (no need to introduce new start rule as S doesn't reference itself):

S -> abAB
A -> bAB
A -> λ
B -> BAa
B -> A
B -> λ

Then we remove B->A by adding B->u for every A->u where u is an arbitrary expression (no epsilon-rules to get rid of):

S -> abAB
A -> bAB
A -> λ
B -> BAa
B -> λ
B -> bAB
B -> λ

Now we replace rules with more than 2 symbols by simply splitting them up like a(b(c(de))) and we also add variables to represent the terminals.

S -> A'S1
S1 -> B'S2
S2 -> AB
A -> B'A1
A1 -> AB
A -> λ
B -> BB1
B1 -> AA'
B -> B'B2
B2 -> AB
B -> λ
A' -> a
B' -> b
λ' -> λ

Your book really should have an algorithm for doing this.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K