Derivation Problem
Consider the following CFG:
SB(S)|B|BC
BaB|bbB|b
CcCc|c|[B]
Which of the following strings can be derived from the start symbol S? Click on the arrow for the answer.
 
  1. bbb
    1. Yes. Replace S with B and follow your nose.
  2. bb
    1. No. Starting from B, if you introduce b, you must stop. So you introduce bb, but you cannot stop there, so there is no way to produce two bs. You can only make odd numbers of bs.
  3. ba
    1. No. There is no way to introduce an a at the end of the string.
  4. abbb(bccc)
    1. Yes. Use SB(S), then use SBC on the second S.
  5. bbb[ab]
    1. Yes. Start with SBC, and use C[B], then you can derive each part from B.
  6. cabc
    1. No. To generate a c, you must introduce a C. From S, you can't use SB(S) since you don't want the parens. You can't use SB since you can never introduce a C. So you must start with SBC. But anything that comes from B must start with a or b. So nothing can generate cabc.
  7. bbab(bc[b]c)
    1. Yes. Start with SB(S)B(BC)B(BcCc)B(Bc[B]c). Proceed from there.
  8. bbbccc
    1. Yes. Start with SBC.