MHB Finishing converting to Chomsky Normal Form from a CFG?

  • Thread starter Thread starter Lolligirl
  • Start date Start date
  • Tags Tags
    Form Normal
AI Thread Summary
The discussion revolves around converting a context-free grammar into Chomsky Normal Form (CNF). The initial grammar includes rules for generating strings with specific symbols and productions. The participants focus on eliminating lambda productions and unit/chain rules, leading to a series of transformations. Key points include the removal of lambda, resulting in a new set of productions, and the challenge of maintaining the original language's integrity while restructuring the grammar. There is concern about losing essential rules, particularly the production S → s, which is crucial for generating valid strings. Suggestions are made to retain the original meaning of S while introducing new variables to facilitate the conversion to CNF. The conversation highlights the importance of careful rule management to ensure all original language constructs are preserved during the transformation process.
Lolligirl
Messages
22
Reaction score
0
Hello everyone! Here is a question I am working on:

Consider the context-free grammar G = ( { S, B, E }, { 0, 1, i, e, s }, R, S ), where R is:

S --> iBSE | s
B --> 0 | 1
E --> lambda | eS

Convert this to Chomsky Normal Form, showing all steps.

Alrighty, so I removed the lambda and got:

S0 --> S
S --> iBS | iBSE | s
B --> 0 | 1
E --> eS

And now I'm trying to remove the unit/chain rules and the rest, and this is what I have so far:

S0 --> X
X --> YS
S --> BS
S --> BSE
S --> s
B --> 0
B --> 1
E --> ZS
Y --> i
Z --> e

But I know S0 --> X and S --> BSE are not valid. From here I am a bit unsure: How can I fix this? Can I do this?

S0 --> YS
S --> BS
S --> BT
S --> s
B --> 0
B --> 1
E --> ZS
T --> SE
Y --> i
Z --> e

Thank you for any help! :)
 
Last edited:
Technology news on Phys.org
Hi Lolligirl!

Are you still busy with this problem? (Wondering)

Lolligirl said:
S --> iBSE | s
B --> 0 | 1
E --> lambda | eS

Convert this to Chomsky Normal Form, showing all steps.

Alrighty, so I removed the lambda and got:
S0 --> S
S --> iBS | iBSE | s
B --> 0 | 1
E --> eS

And now I'm trying to remove the unit/chain rules and the rest, and this is what I have so far:
S0 --> X
X --> YS
S --> BS
S --> BSE
S --> s

Hmm... it looks like you have recycled S to mean something else now... (Worried)
But hold on!
The language in the previous step contained $S_0 \to S \to s$.
But your new language only contains the equivalent $S_0 \to X \to YS \to is$.
You have lost a word from your language! :eek:
 
Oh! Could I fix it by doing this?

S0 --> YS | s
S --> BS | BT
B --> 0 | 1
T --> SE
E --> ZS
Y --> i
Z --> eOr maybe I'm nuts. :o
 
Lolligirl said:
Oh! Could I fix it by doing this?

S0 --> YS | s
S --> BS | BT
B --> 0 | 1
T --> SE
E --> ZS
Y --> i
Z --> eOr maybe I'm nuts. :o

That would take care of the missing word 's'... but I do not think the reduction of the rules is right.

You started from:
S0 --> S
S --> iBS | iBSE | s

With your reduction, you no longer have the rule S-->s that could be applied recursively. Now it can only be applied once a the beginning. :eek:I think this will go better if you keep the meaning of S the same as it was.
Your might do for instance:
S0 --> S
S --> YU | YV | s
U --> BS
V --> BT
Y --> i
(Wasntme)
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top