Determining Ambiguity in Context Free Grammars What are some common ways to determine if a grammar is ambiguous or not? What are some common attributes that ambiguous grammars have?
For example, consider the following Grammar G:
$S \rightarrow S(E)|E$
$E \rightarrow (S)E|0|1|\epsilon$
My guess is that this grammar is not ambiguous, because of the parentheses I could not make an equivalent strings with distinct parse trees. I could have easily made a mistake since I am new to this. What are some common enumeration techniques for attempting to construct the same string with different parse trees?


*

*How can I know that I am right or wrong?

*What are common attributes of ambiguous grammars?

*How could I prove this to myself intuitively?

*How could I prove this with formal mathematics?


If CFG may produce more than one parse tree for the same input string then the grammar is said to be ambiguous. Very easily we can able to identify that.  (i.e)  when the same non-terminal  appears twice on a right hand side of the production then it has the ambiguity problem.
The general form of the ambiguous grammar is:
 S ->  α S β S γ | α1| α2 | α3 | …. |αn          this production has an ambiguity problem because S are present twice on the right hand side of the production. Where α,β and γ are some string.
Example E -> E + E | E * E | (E) | id   
