How does one know which string to choose when nothing is given in the question?
2026-03-26 07:46:30.1774511190
On
Show that the CFG with productions S→ a | Sa | bSS | SSb | SbS is ambiguous?
4.2k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
0
On
I generally start by looking for a single production with repeated nonterminals that easily generate the same sequence twice. In your case I 'hit jackpot' with the last: S -> SbS. This generates the sequence SbSbS two ways: (SbS)bS and Sb(SbS). I don't think the same thing happens with S->bSS or S->SSb.
Failing that, I would try to combine two or more productions to achieve the same effect. This works with the productions S->bSS and S->SSb, which combine to produce the string bSSSb two ways: (bSS)Sb or bS(SSb).
Failing that, look for ways to produce the same terminal(s) at different heights of the parse tree. That leads to the approach implied by @Brian M. Scott.
HINT: You can use $abaa$. Try it yourself; if you get stuck, I’ve left two leftmost derivations in the spoiler-protected block below.