56.3k views
5 votes
Show that the following CFG is ambiguous by finding an example of a string having two different leftmost derivation: S→0OA10∣ B10, B→A0∣B1, A→00∣€.

1 Answer

1 vote

Final answer:

To show that a CFG is ambiguous, we need to find a string with two different leftmost derivations. The given CFG is shown to be ambiguous by finding two different leftmost derivations for the string 010.

Step-by-step explanation:

In order to show that the given context-free grammar (CFG) is ambiguous, we need to find a string that can be derived in two different ways: with two different leftmost derivations. The given CFG is:

S → 0OA10 ∣ B10

B → A0 ∣ B1

A → 00 ∣ ε

Let's consider the string 010. We can derive it using the following two different leftmost derivations:

  1. S → 0OA10 → 01OA10 → 010
  2. S → B10 → A010 → 010

As we can see, the string 010 can be derived in two different ways, thus showing that the given CFG is ambiguous.

User Jataro
by
8.0k points