 Okay, so we're talking about first sets, we have a question about first sets, so why don't you describe to me the grammar that you want to give me? Yeah, so the context for your grammar is going to be S goes to, these are all non-terminals, or yeah, non-terminals, A, B, C, D. The next rule is A goes to C, D, or little A, big A. The next rule is B goes to little B. The next rule is C goes to little C, big C, or epsilon, and then the final rule is D goes to little D, big D, or epsilon. Cool, so this is the first thing we do. The first thing we're going to do is initialize every first to the empty set, right, so we take the non-terminals in the grammar. Alright, so our goal, right, we always want to think whenever we're going to do something what's our goal, what do we want, right, so here depending on what the question asks you, we want the first of S, the first of A, the first of B, first of C, first of B, first of S, first of A, first of B, first of C, first of D, and as you said we initialize all of these to the empty set. Right, okay, now what? Indeed, so we start with first of S, right, like we try to compute that. We can start anywhere we want, let's say, so we want to apply all our rules to calculate the new value for first of S. Okay, so which rules do we look at? The first rule? The first rule, why? Because we're looking at the first of S. Yes, so we only look at rules where S is on the left-hand side. Okay, now we are going to step through the rule, right, so we need to look at first of A. Okay, look at the first of A, so what do we do with the first of A? We check, yeah, see this is where it starts to come to pieces of me. So I'm not sure what we do here, we check what first of A has, right, and then we add that back to S minus epsilon. Before we do that, what does rule three say? Rules one and two are just about non-terminals and epsilon, right? We're trying to calculate first of S, so right now that doesn't come into play. Right, right. So what does rule three basically say? If A is, if the rule A... We have some rule in the form A goes to... A non-terminal and then alpha. Call it B alpha. Yeah, if it's a production rule then you add the first of B minus epsilon to A. So rule three, so is this rule in this form? If we have non-terminal goes to a symbol, I guess it's kind of confusing that this is B. Right, right. No, it just represents a non-terminal, right? The leftmost symbol. Okay. And alpha represents a terminal, right? Say that again. Alpha represents a terminal. Alpha represents a sequence of terminals or non-terminals. So any number, zero or more. Okay. So yeah, it is in that form then because we have S and then A followed by BCD in this case would be alpha. Cool. So BCD is alpha, A corresponds to B here. So then what do we add to the first of S? We're going to add whatever A contains. The first of A, the difference is epsilon, right? Which is nothing, right? Right. So drag epsilon, just still empty set. Okay. And then we add that to S. Okay. Cool. Then what does rule four say? Rule four. You're not going to do the exact definition. Okay. Yeah. No, that's, this is why I'm confused though. Okay. So, okay. So if epsilon is in the first of B. That's off of here. If epsilon is in the first of B, then what? Then we're going to check for, shoot, I wish I understood this better. Sorry. Oh, this is why you're here. Yeah. This is where it sort of falls apart for me. But intuitively, I understand how to find all of these. Like I can look at it and say, okay, here's this, here's that. It's the algorithm that I'm getting confused on. So why don't you, if you can, I'll try and write the rule for memory, but I'm probably going to mess it up. So check it. All right. So we have, so if we have a rule of the form A goes to B zero dot, dot, dot, B I, B I plus one. And I guess actually here, we'll also do alpha. Let's just represent everything after B I plus one. Okay. It could be zero or more, just like here. Right. So if our rule is of this form, and so if this is true and epsilon exists in the first B zero. Yeah. And epsilon exists in the first of B one and dot, dot, dot, and all the way epsilon exists in the first. Right. So if this, then this, then what, what do we do? Then you're going to add first of B I plus one minus epsilon. Yeah. So what is this saying? I think what it's saying is that you're finding the first character or the first non-terminal in that string of B's that is not epsilon. Right. Or that's not. That's necessarily the first. That's the tricky part. So the question is, does this apply here when I in this case is zero? So I plus one is here. Okay. So is there an epsilon in the first of B zero? In this case A. No. I mean it's empty. No. So this thing is no. This is false. Okay. Therefore this does not apply. Okay. So you're going to use rule four? Right now we don't. We're just in the very first step. All right. All right. So rule four doesn't apply. So then we check rule five then? Check rule five. Okay. So it's in a very similar form. Right. So it says if we have a rule A goes to B zero all the way up to BK. Right. So every single symbol in the right hand side of the rule terminal and non-terminal. If the rule is in this form. So is this rule in that form? Yeah. Yeah. That makes sense. And epsilon exists in the first B zero and all the way up to epsilon exists in the first BK. Then we're going to add epsilon to first of A. Right. We just push the epsilon up to the. So this makes sense. Right. Because if every single symbol in the right hand side can go to epsilon then there must exist some combination of rules where A also goes to epsilon. Correct. Yes. That was five. You say K is the end of the string. That's the key. The end of the symbols. Alpha here means that we have other stuff after it that we don't care what it looks like or if it even exists. That's the key difference. But the other thing is they both can apply. Yeah. They still to me seem like they can apply. Well, four. The only reason we couldn't apply four is that there wasn't an absolute opinion. In B zero. Yes. Well, okay. So there's no epsilon B zero. Which means it doesn't make sense to check if there's any epsilon to B one or B two or B three. Right. This is always going to be no matter what we put our I to. Right. So, if there's no epsilon in this case in A, we don't care four or five. We just move on to the next. Exactly. Because five has that same condition. If epsilon exists in first of B zero. Well, if there's no epsilon here. It fails here. It fails here. I see. Okay. Okay. So we got no information except for the knowledge that we're gaining from doing this. Okay. Cool. Now I go to A. So we have two rules, right? We have to remember to look at each rule in isolation. So we first look at A goes to C D. Apply all these rules. And then we're going to look at A goes to a little A, big A, and then apply those rules. Okay. Why did we go to A? I thought we were working on A saying. Oh, sorry. Sorry. So we've worked on S, right? Okay. We applied rule three, rule four, and then we applied rule three, rule four, and then we applied rule three, rule four, and rule five. Okay. So nothing more than no other rules. So every time you call first of something, you're looking at these rules and you're going to apply them iteratively one through five. Yes. For every one of these steps, S, A, B, C, D, you're going to look like algorithmically. You look up all the rules that have S on the left-hand side. Okay. And then you apply rules three, four, and five to get new elements in the S's first set. Okay. And when you've applied that for every rule where this is on the left-hand side, you're done. Okay. In our programming, in our programming assignment, those are going to be divided right at the oars. Yes. These will be literally different rules. And so the important thing here, this is just syntactic sugar. This is just short-hand. Right. When you see this, this means there is an additional rule that says A goes to little A big A. There's absolutely no difference between this and me writing it without this and saying A goes to little A big A. It's just more condensed. Okay. And so it's just something to be aware of. I think on the exams, we never use the bar because I want it to be very explicit. But when we write it like this for homework, it's a lot easier to think about it like this. Because the bar has very similar things with regular expression bar. Okay. So let's look at this rule. A goes to C, D. So which rule do I apply first? It's going to be three, right? Well, three. So what do I do then? You're going to add first of, in this case, first of C. First of C, which is what? The empty set. The empty set, cool. Minus Epsilon. Minus Epsilon to the first of A. To the first of A, cool. Which is nothing until we change. Right. Now does four apply? No, four and five shouldn't apply because there's no Epsilon in C. Okay. We're done there. But we can't finish. We have to go to the second rule. So then which, so which rule do I apply first? In this case, you're going to apply rule one, right? Because you have, so now A. Well, we first, we first want to apply rule three. Oh, okay. No, no, no. We're going to apply rule three. We're going to calculate first of A. Right. So first of A. Three says take the first symbol on the left-hand side, right? Okay. The first symbol on the left-hand side is a terminal. We know that. Exactly. We're going to say what's the first of little A? Little A. The second containing A. We subtract Epsilon from that. It's still the second containing A. Then we add that to the first of big N. Got it. This is great because you don't have to special case the terminals versus non-terminals when you're calculating rules three, four, and five when you're calculating first sets. So you're saying that this isn't, so rule three technically isn't a non-term which is the first symbol. Yes. Okay. Simple. Okay. So, okay, great. So now we're doing. So we've added A to here. Yeah. Now we also have to ask, does rule four apply? I don't see an Epsilon in the second containing little A, right? Right, exactly. Okay. Yeah, so you'd say is there an Epsilon in this first symbol here? No. Okay. Right, so rule four can't apply and rule five can't apply. Got it. We're done here. We've done all the rules with A. Okay. Now this is our current first set of A. And we're programming this. We would probably make a note that, hey, we changed the first set of A, which means when we get through, we got to do it again. Okay. Right, that's another thing you need to think about. How do I tell when I'm done? So you iterate, okay, so you go first of S, first of A, first of B, first of C, first of D, and if any changes were made, you run through that again. Okay. And then if you run through it, you make no changes, you're done. Those are your first sets. Got it, got it. Okay. Cool. All right, first of B. Okay. Which rule do we apply? First of B is going to be rule three. Yeah, rule three. First of little b minus epsilon is the second take. Little b. Right. Add that to first of B. Okay. Now we get to C. Okay. So C, we take this rule first. Yep. So we do the same thing we did up here. Apply rule three. Rule three. Little c minus epsilon to the first of C. Little c. So we get little c. And then we say, does rule four or five apply? No. Nope, can't move on. Great. Then we look at this rule. Okay. Right, rule three still applies. Right? We have a symbol here. Right. So we take the first of that symbol, which is the second in epsilon, by rule two. And then we subtract epsilon from that, which gives us the empty set. Right. So we add the empty set. To C. To C, which doesn't change it. Okay. Now we're looking at four. Now we say, does rule four apply? Okay. So yes, it does because there's epsilon in rule four. All right. I'm sorry. Rule three goes to epsilon. In this case, epsilon is B zero. We'll get this one. Epsilon is B zero. Okay. So epsilon is contained within first of zero. Hang on. Yeah. Because rule two says that first of epsilon is the set containing epsilon. Right. We'll get there and say yes. Okay. I'm going to say so. In this case, why wouldn't it be rule five or rule four? They all apply. Okay. They all apply. We have to check each of them in turn. Okay. So there's no over, they're all going to apply. And that's why we do the ad here because they're all constantly applying things. Okay. You started with rule three and not one. Because we are talking about here, we're trying to calculate the first set of non-terminals. So it doesn't make sense to check rules one and two because one and two just say, what's the first set of a terminal and rule two says what's the first set of epsilon. Right. So we don't care about these when we're doing that here. Right. We're going to start with three, but that leads us to using rules one and two. Okay. Let's think about this. So we have our b zero. Right. So i is zero in this case. Right. So is there an epsilon in the first of b zero? Yes. Yes. Then what does this rule say that we should do? Then we add the first of b i plus one, which is the empty set. Right. What's i plus one here? There is no i plus one. Exactly. Right. So can this rule apply if there's no i plus one? No, I guess not. Right. So the rule... So part of... It's another thing that's implicit in this rule that we have all the way up to i and i plus one. Gotcha. So we're saying if it's in this form, right, here we're saying b i is zero. Okay. I think there has to be a b one. I see. This can be zero or more. So this is protecting the insta case such that you have like epsilon and then a terminal like later on and that. Exactly. Wow. So we'll see where this applies. Okay. And that's... I totally understand it. Don't be upset that you're confused because I understand it's not an explicit condition in here. All right. And so I get it. And I've struggled with do I change the way I present these rules to be a little bit more straightforward or do I keep them more towards their like mathematical formalism roots? And so I kind of like that you have to learn this and that you're translating this into code basically for project three. I like it. It's good. So it's nice and concise but there are implicit things in here. So okay. Rule four doesn't apply. Then we ask... Rule five is going to apply because the last set in that series of... Yeah. So what's the k here? The k is going to be epsilon. What number is k? Zero. Zero. Yeah. Zero symbols here. Yeah. One symbol in here, right? So k is going to be zero. So a goes to b zero, right? Consistent here. And does epsilon exist in first to b zero? Yes. Yes. So then what do we do? Okay. Which is first of c and this out there and this down. Wow. Okay. And so this is the cool thing is just like in this case, right? We didn't have to special case... Oh, if b goes to a terminal on this side, then you do this. This falls out exactly the same way we did the other ones by just applying rule three. And as long as we know the first set of a terminal is the second taming that terminal, we get this, right? Just applying this rule, this happens. The same as with this epsilon. As long as we know that the first set of epsilon is the second taming epsilon, then when we apply rule five, it happens. Even though here we're subtracting out epsilon by applying rule three. So what we're doing is we're trying to get all non-terminals that are not epsilon into the first of b, right? Like, like rule three, it says like, okay... Get the first one. Yeah, get the first one. You always get the first one, no matter what. That's why there's no qualifiers, right? You always get the first one minus epsilon. Okay. The fourth one says, can I move on to the next one? Right. Right? I've done i. In this case, I've done the first one. Can I move on and add the next one? Okay. And then if so, you check, okay, I've done the second one. Can I add the third one? Because this rule keeps applying. Right. That's the key. We don't have any condition on the i plus one. We choose... Right. We choose i and we want to choose every single i. Okay. We want to start with i zero to add i to b one. We want to then check i one to add b two. Okay. And then check b two to add i three. And then this says if we went all the way through and there's epsilons in all those first sets, then we add epsilons. Yeah, add epsilons. Okay. It's going to be a rule three. Right. Three? Yeah. Which is going to add what? The first of little d minus epsilon. First of little d minus epsilon, which is little d. Little d. Then does rule four apply? No. Cool. All right. Then here we do the same thing we did before. Add three minus epsilon is nothing. Right. Check rule four. Doesn't apply. Then add rule five to add epsilon. Okay. Now it's important to think like this. I totally understand if when you're doing this you simplify this and just say epsilon goes into the first of d because of this rule. Right. But the important thing is understanding the mechanical calculations that fall out from these rules because that is how you code it. Right. Okay. And then we say, did we change? So we've gone through all the non-terminals. Did we change it? Yeah, we did. Yeah. So we've got to do it again. Okay. Cool. Okay. So then we start here with s. So we apply rule three. So what do we do here? So it's going to be add first of b, which is first of a. Right. At first of a. Which is a. Which is just a. Which is a second containing a. The difference. Minus epsilon. Minus epsilon. So the second containing a goes there. Okay. So the rule four apply. Yeah. And so rule five doesn't apply. Okay. I see. And then we can just move them all as they go up. Right. And then. And then now we do, let's do a again. And then I think I probably need to balance. Okay. Yeah. So a. So let's do a. So we'll do this. Let's go with this rule first. Okay. Right. So a will three applies. It's going to be first of c minus epsilon. So we're going to put c in there. Right. So we add c. And so you can do it two ways. Okay. This a came from here. So you can look in the future a little bit and say, when I do apply rule three here, I'll get this a again. Okay. So you can either start fresh every time you do it. Okay. Or you can copy over what you had before. Okay. What would you recommend for the project? Start fresh. No, I would copy. I'd copy new ones in. I think the way I did it was like. First initialize all the sets. And then. I think I made before I calculated, I made new copies of each of these sets for all my non terminals. Added to these and then compared them at the end to see if any of them were different. But you could do it differently. You could set a flag if you change something or. Okay. No, it's all depends on how you want to do it. Okay. Okay. Okay. So we added that. And then we say, does rule four apply? First seed. No. Yes. Yes, it does because first of seed does contain Epsilon. Right. So I in this case is zero. Okay. So we say, does Epsilon exist in the first of seed? Yes. Yes. Then what do we do? Add first to B plus one minus Epsilon. So B by plus one is D. Yeah. So add. D. Okay. D minus Epsilon. So. Exactly. So we got to make sure we just add D. Right. Right. And then we say. Wait, why didn't we add C already? Okay. I think I got off on the tangent. Then we say, does rule four apply again? Yeah, it does because the set, the first of B now with I being D. Right. So I is then would be one in this case. We have B zero, B one. So what do I add to the first of A? Because you're subtracting Epsilon from that. Right. So D. Yeah, first of D. So first. I already added the first of D. Right. So I applied this once when I was zero. Okay. So I think this kind of means for all from I zero to the end of the string. Okay. In some sense. Right. So this one said when I was zero, we added B I plus one. Okay. Which was one. Okay. We added first of D minus Epsilon, which is how we got this B. Okay. Cool. So I checked this one. Rule three says I always do this. Rule four says I can move on to the next one if there's a first and an Epsilon in this first set. Okay. You got it. Cool. So now the question is does rule four apply again? Yes. So what do I add? What's my D of I plus one? Empty. Right. It doesn't exist. It doesn't exist. Yeah. Because the I plus one is there's nothing there. There's nothing after D. There's nothing that falls. Right. So four doesn't apply. Okay. So four doesn't. Okay. Yeah. Cool. So four does not apply. Right. We can't. Because the problem is it's not in this form. Right. We don't have A goes to B zero, B one. Sorry. B one, B two. Right. It is not in this form because we already checked the first here. So we went here. But the problem is it's not in this form. There's nothing after to happen. Right. So that does not apply. But now the question is does rule five apply? Rule five does apply. My question though is B zero still C? Are we looking at B zero? Yes. Okay. So we start with C. Okay. So we know that first of C does contain Epsilon. And first of B of, or BK is going to be D. Like the last non-terminal in that sequence also does contain Epsilon. Therefore we add Epsilon to the first of I. Yep. Okay. I need to walk through this. Do it for D, C and B. Or B, C and D. That's a weird type of thing. B, C and D. And we change it. So we have to do it again. And you can already see that because we added the Epsilon to A. Yeah. It's going to change how we do S now. Right. And so we have to keep that into consideration when we do this. But I think now I will stop. No, that was awesome. Thank you so much for the help. I really appreciate it. Have a cool. You're totally not a plant. People watching online.