Transform Grammer to Chomsky Normal Form

In summary, the conversation discusses the process of transforming a grammar into Chomsky Normal Form. The steps involved include splitting up rules and removing epsilon-rules, as well as replacing rules with more than 2 symbols by adding variables. The conversation also mentions the importance of having an algorithm for this process, which can be found in textbooks such as "Introduction to the Theory of Computation" by Michael Sipser.
  • #1
jferg449
1
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
  • #2
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.
 

1. What is the purpose of transforming a grammar to Chomsky Normal Form?

The purpose of transforming a grammar to Chomsky Normal Form is to make it easier to analyze and generate the language it describes. This form has specific rules and restrictions that allow for more efficient parsing algorithms to be used, making the grammar more manageable for computers to process.

2. What are the steps involved in transforming a grammar to Chomsky Normal Form?

The steps involved in transforming a grammar to Chomsky Normal Form include removing all ε-productions, removing all unit productions, converting all productions to either A → BC or A → a form, and finally, introducing new non-terminals for each terminal in the grammar. This process may also require the addition of new start and end symbols.

3. Can any grammar be transformed to Chomsky Normal Form?

Yes, any context-free grammar can be transformed to Chomsky Normal Form. However, some grammars may require more complex transformations or the addition of new symbols to meet the necessary rules and restrictions.

4. How does transforming a grammar to Chomsky Normal Form affect the language it describes?

The language described by a grammar is not affected by transforming it to Chomsky Normal Form. The transformation only changes the structure of the grammar and makes it easier to analyze and process.

5. Are there any disadvantages to transforming a grammar to Chomsky Normal Form?

One potential disadvantage of transforming a grammar to Chomsky Normal Form is that it may result in a larger grammar, as new non-terminals and productions may need to be added. This could make the grammar more complex and difficult for humans to understand. Additionally, the transformation process itself can be time-consuming and may require manual adjustments in some cases.

Similar threads

  • Linear and Abstract Algebra
Replies
1
Views
430
  • Linear and Abstract Algebra
Replies
20
Views
992
  • Linear and Abstract Algebra
Replies
20
Views
2K
  • Linear and Abstract Algebra
Replies
4
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
925
  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
941
Back
Top