Ambiguity of Context Free Grammar

419 Views Asked by At

There is a theorem related to CFGs that " There exists no algorithm which can decide whether a grammar is ambiguous or not."

I have developed an algorithm which can decide the ambiguity of a cfg.

But the proof of the above theorem is based on Post Correspondence Problem (PCP). Please tell me if I publish the algorithm would that mean that this theorem is not correct.

Note: Please also post some ambiguous cfgs. I want to test my algo.

1

There are 1 best solutions below

0
On

A good heuristic is: "If you think you have disproved previously proved result X, you are more likely wrong."

I am not sure how many people have worked on PCP over the years. It is most likely a lot, and they have most likely been competent computer scientists and mathematicians.

I would tend to trust a group like that to reason mathematically, more than I would trust myself.

Your algorithm is most likely wrong (there is a probability $\varepsilon > 0 $ that it is correct and all these mathematicians are wrong, for an almost arbitrarily small $\varepsilon$).

It is well known that the grammar of the programming language C++ is ambiguous when expressed as a CFG.

Also, try to present a counterexample for your algorithm. You designed it, you should know when it breaks.