-1

I just took my midterm but couldn't answer this question.

How we can show the following language is ambiguous ?

L={a n bm c p : n≠m} U {a n bm c p : m≠p}

I think this is very hard, Who can Help me with automated tools or ... how we can prove it ?

icktoofay
  • 126,289
  • 21
  • 250
  • 231

1 Answers1

1

Consider one possible grammar for the language {anbmcp : n≠m}:

S → A X C | X B C
X → ε | a X b
A → a | a A
B → b | B b
C → ε | C c

In this grammar, the left-most derivation of any word will not expand and C until all the other non-terminals have been expanded. A very similar grammar for the other half of the union (anbmcp : m≠p} will similarly expand all the As before any other non-terminal is expanded. Any word in the intersection of the two subsets will therefore have (at least) two distinct derivations.

Proving that the language is inherently ambiguous requires proving that the above is true for any grammar for the language. Such a proof is effectively based on Ogden's lemma, which is a generalization of the pumping lemma for context free languages; the proof consists of demonstrating that some word can be "pumped" in two different ways.

It is relatively easy to find the proof that the similar language {anbmcp : n=m} ∪ {anbmcp : m=p} is inherently ambiguous: it's often used as an example in textbooks on formal language theory. I think the proof for your language is "more difficult" in that it probably requires consideration of more cases, but it should be fairly similar.

An alternative approach is the analytic method of Flajolet.

rici
  • 234,347
  • 28
  • 237
  • 341