You stop expanding when there is no more non-terminals (when all of the symbols are terminals). At this point, there is no way to expand anymore. Consider "a + (a x a)", 'a' is a terminal symbol and there is no way to convert it to any other symbol, and also ('+', 'x', '(', ')') are all terminals.
"a + (E)" and "a + a" are both described by the grammar, so both are correct. The purpose of a grammar is (usually) not to generate expressions, but to check if they are valid. In this case the question would be "Is 'a + (a * a)' valid within this grammar?", and the answer is "Yes, because we can apply the rules until we arrive at that string of characters."
If you had the expression A = B + C * D, and you did a LMD using an ambiguous grammar, couldn't that potentially add B + C before multiplying by D, and if you did a RMD, couldn't it multiply C * D before adding B? In other words, for an ambiguous CFG, wouldn't the LMD and RMD produce different parse trees, and not be abstracted to the same parse tree?
What I can't seem to figure out is, when doing a left most derivation; does this assume we use the left-most rule in the CFG rules as well? Like what if your grammar is: S->a|B B->Bb|b is the left-most derivation just S=>a? because a is the left-most rule in the definition S->a|B? How do we determine rule to use in these types of situations?
Nope. Left most derivation is the idea of expanding the left-most token in your input. With your example grammar, and the input of "SB": SB => aB => aBb => abb Thus "abb" is valid grammar. If we only chose the left rule, we would arrive at: SB => aB => aBb => aBbb => aBbbb => aBbbbb => ... This tells us that abbbbbbb... is also valid within this grammar. This is however an infinite string, which is rather impractical, so at some point it must NOT follow the left most rule of B -> Bb, but rather the right rule of B -> b. This will give the string a finite length.
Let's all thank God for this human being :-)
@Brentley Jaxtyn wtf
Thanks man! I got an exam in like 2 hours. Just learned it all from scratch.
lol...
was feeling crap about starting the night before, but this gave me hope. lmao
i'm in the exact same spot right now lol
my exam will start in two hours lol
The Same with me Lol
These videos are pure gold, I feel I understand everything with your teaching style. I appreciate how concise and clear these videos are. Thanks!
You're so goals. I'm in love. You turn logic into lovemaking with your beautiful videos. Thank you Harry Porter
Holly Whimsy Thanks for your nice compliment, Holly.
Hmm. You might be getting a little carried away here....
*2018 poor computer science student here and I have no fucking Idea why should I know these things But thank god I found you Thank you*
this comment is me rn lmao
reupload videos with higher resulution please. These are gold.
Thank you so much Professor.
Thank you for explaining things so clearly.
you're a wizard harry!
never heard that joke before
Tomorrow we have an exam ! And this video gave me hope too much...Appreciate thanks thanks muah muah i love yaaaaaaaaaaaaaaaaaa...
Review 12:30 for understanding grammar and language definitions.
Thank you!
How do you know when to stop expanding?
You stop expanding when there is no more non-terminals (when all of the symbols are terminals). At this point, there is no way to expand anymore. Consider "a + (a x a)", 'a' is a terminal symbol and there is no way to convert it to any other symbol, and also ('+', 'x', '(', ')') are all terminals.
Thank you for this sensational video!
What this made earlier? Not quite as clear as the FSM segments, still good though.
Starting from this video this course became really complicated to understand. What happened?
In the first example, after 'a + F', why didn't we made it 'a + a' instead of making it 'a + (E)'??
+Devesh Beri Do you got the answer?
been bothering me too. any answers?
Would a + a be accepted instead of a + (a x a)?
"a + (E)" and "a + a" are both described by the grammar, so both are correct. The purpose of a grammar is (usually) not to generate expressions, but to check if they are valid. In this case the question would be "Is 'a + (a * a)' valid within this grammar?", and the answer is "Yes, because we can apply the rules until we arrive at that string of characters."
@@dr1303 Is 'a' valid within this grammar ?
Thank you! Sir !
UGA 2021 boi!!!!
Definition: 12:33
If you had the expression A = B + C * D, and you did a LMD using an ambiguous grammar, couldn't that potentially add B + C before multiplying by D, and if you did a RMD, couldn't it multiply C * D before adding B? In other words, for an ambiguous CFG, wouldn't the LMD and RMD produce different parse trees, and not be abstracted to the same parse tree?
Thank you for these videos, they are very helpful
What I can't seem to figure out is, when doing a left most derivation; does this assume we use the left-most rule in the CFG rules as well? Like what if your grammar is:
S->a|B
B->Bb|b
is the left-most derivation just S=>a? because a is the left-most rule in the definition S->a|B? How do we determine rule to use in these types of situations?
No and this is because A or B is the same as B or A. So
S -> a|b
is the same as
S -> b|a
You don't apply the left mot derivation when choosing a rule.
Nope. Left most derivation is the idea of expanding the left-most token in your input.
With your example grammar, and the input of "SB":
SB => aB => aBb => abb
Thus "abb" is valid grammar. If we only chose the left rule, we would arrive at:
SB => aB => aBb => aBbb => aBbbb => aBbbbb => ...
This tells us that abbbbbbb... is also valid within this grammar. This is however an infinite string, which is rather impractical, so at some point it must NOT follow the left most rule of B -> Bb, but rather the right rule of B -> b. This will give the string a finite length.
Great stuff..!
Is the following derivation also true : E -> T -> F -> a
yes, it is
thank you
this was uploaded in 2015 why the potato quality?
I can't see the writting clearly.
I don’t get it I absolutely hate this, because I don’t know why I don’t understand any of it.
Thank you!