6

Consider an ambiguous context-free grammar $G$. Define $A(G)$ the set of ambiguous words, meaning: $$A(G) = \{u\in L(G) \mid u \text{ has at least two derivation trees for }G\}$$ Can we say something about $A(G)$ in the general case? In particular, is $A(G)$ a context-free language?

Nathaniel
  • 18,309
  • 2
  • 30
  • 58

1 Answers1

8

The standard example that context-free languages are not closed under intersection can also be used as a counter-example for the language of ambiguous words.

Construct unambiguous grammars for $\{ a^n b^n c^m \mid m,n\ge 1\}$ and $\{ a^m b^n c^n \mid m,n\ge 1\}$. Take the union of these grammars in the common way. The union language is of course context-free, but the ambiguous strings are in the intersection, which is not context-free.

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109