Problem

1. Prove that the context-froe grammar below over the terminals $\{x,+, \times\}$ is ambiguous. \[ \begin{array}{l} S \rightarrow S+S \mid T \\ T \rightarrow S \times S|S| x \end{array} \]

Solution

Step 1 :To prove that a context-free grammar is ambiguous, we need to find a string that can be derived in more than one way from the start symbol. This means we need to find a string that has more than one parse tree.

Step 2 :Looking at the given grammar, we can see that the string 'x+x*x' can be derived in two different ways.

Step 3 :One way is to derive it as '(x+x)*x', and the other way is to derive it as 'x+(x*x)'.

Step 4 :So, we can conclude that the given grammar is ambiguous.

Step 5 :\(\boxed{\text{The given context-free grammar is ambiguous because the string 'x+x*x' can be derived in two different ways: '(x+x)*x' and 'x+(x*x)'.}}\)

From Solvely APP
Source: https://solvelyapp.com/problems/16533/

Get free Solvely APP to solve your own problems!

solvely Solvely
Download