I have the following grammar,
S -> Sb
S -> aaSb
S -> b
The typical derivations in this grammar are
S => Sb => [aaSb]b => [aa[b]b]b => aabbb
for n = 1
S => Sb => [aaSb]b => [aa[aaSb]b]b => [aa[aabb]b]b => aaaabbbb
for n = 2
Edit:
So I claimed that this grammar generates the language
L = {a^(2n)b^(n+2) : n >= 1}
I am pretty sure that my a
goes a^(2n)
since there's two a
before S
, but what about b
. There is no lambda here so my n
goes from n >= 1
?.
Edit:
b^(n+1)
and b^(2n+1)
are both wrong assumptions because the grammar can derive a string aaaaaabbbbb
if n = 3
.
I modified my b
to be b^(n+2)
.
so that L
becomes L = {a^(2n)b^(n+2) : n >= 1}