1

Is it possible for an ambiguous context-free grammar(CFG) to convert into Chomsky Normal Form(CNF) and becomes unambiguous?

Michael
  • 439
  • 1
  • 4
  • 15

1 Answers1

2

Sure. All you really need is a single example to show this is possible. Consider the ambiguous grammar

S :- A | B
A :- a
B :- a

This grammar is equivalent to the following grammar in CNF

S :- a

This grammar is not ambiguous.

Patrick87
  • 27,682
  • 3
  • 38
  • 73
  • Is the grammar first ambiguous because "a" has two leftmost derivations (1) A :- a, S :- A and (2) B :- b; S :- B? – sprajagopal Jan 28 '21 at 16:22
  • 1
    Yes, two distinct derivations produce the string a: S -> A -> a and S -> B -> a. The parse trees are different but the string derived is the same. – Patrick87 Jan 28 '21 at 16:30