Finishing converting to Chomsky Normal Form from a CFG?

  • Context:
  • Thread starter Thread starter Lolligirl
  • Start date Start date
  • Tags Tags
    Form Normal
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
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:
Physics 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)