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
These videos are pure gold, I feel I understand everything with your teaching style. I appreciate how concise and clear these videos are. Thanks!
First explanation I completely understand! Thank you!
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
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....
Thank you so much Professor.
Thank you for explaining things so clearly.
reupload videos with higher resulution please. These are gold.
Review 12:30 for understanding grammar and language definitions.
Definition: 12:33
you're a wizard harry!
never heard that joke before
What this made earlier? Not quite as clear as the FSM segments, still good though.
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.
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 ?
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?
*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
Tomorrow we have an exam ! And this video gave me hope too much...Appreciate thanks thanks muah muah i love yaaaaaaaaaaaaaaaaaa...
Thank you for this sensational video!
Starting from this video this course became really complicated to understand. What happened?
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.
Thank you! Sir !
at 240p i am doing set theory on pixels they practically speak to me and i have learned their language atm i can fully say it`s context free
Thank you for these videos, they are very helpful
Is the following derivation also true : E -> T -> F -> a
yes, it is
Thank you!
Great stuff..!
UGA 2021 boi!!!!
thank you
this was uploaded in 2015 why the potato quality?
I don’t get it I absolutely hate this, because I don’t know why I don’t understand any of it.
I can't see the writting clearly.
Thank you!