 We're talking about question sets based on this table. Yes. OK, cool. So we have the five rules. I guess I'll just look at this here, because I don't have all of these. OK, so we want to calculate the first of s. We look at the first thing, and instead of s, that's a. Right. OK. So we applied rule 3, right? So the first thing we do, right, when we want to calculate the first of s, we only look at the production rule that has s on the left-hand side. So that's the first thing we do. We pre-filter out all those other production rules, because we only look at rules where s is on the left-hand side. OK. Because there can be multiple. So then you look at the first element in s, and that happens to be a. Right? Exactly. We look at the left-most symbol here. So then what happens next right then? Like, what do you think? So we apply this rule, right? OK. So I'm applying this rule. Here is first of a, and here's first of s. So I'm adding the first of a minus epsilon to the first of s. So then I ask myself, what's the first of a? OK. And it could be either c or a little a, bixie or a little a. Nope. No. So this is one of the nice things. So you're trying to look ahead and pre-compute it in your head. Don't want to do that at all, because you're making it too complicated. All you want to do is look at this table and say what's the first of a, the last value for first of a that I have? Empty set. Empty set. So that's what I do. I take the empty set, I subtract epsilon from it, which is still the empty set. Can I add that to the first of s? What is the empty set? So why do we put the extra space there? The formatting thing. Let's just show you. No, no, it's just a problem. Oh, OK. It's not anything. Does it mean anything? No, no. OK. OK. So we always just look at that column every time. So when do we look at these over here, then? So now when we calculate the first of a, which of these rules on the left-hand side do we look at? First of a, well, then we look at a, and then see that c, big c. Which of these rules? Oh, a goes to cd. Just this rule, right? Maybe I'll do that next time. It's like we could block out all these other rules. And we only look focused on those rules. And actually, there's two rules here. The or means that there's two rules. So we have to choose. We look at them one at a time, but apply all the rules to each. It doesn't matter which order we do them in. But we have to do all of them. OK. So we first take a goes to big a, big d, right? So I want to apply rule 3, right? So which is the leftmost symbol of this rule? Big c. Big c, exactly. So I take first set of big c minus epsilon. What's the first set of big c? Empty set. Empty set. OK. Empty set to a, did that. I ask myself, do any of the other rules apply? Do I go on to add the first of d to the first of a? Well, it was empty, so it could still be rule. Which one's rule 4 again? Yeah, let's check real quick. So if epsilon is the first of b, 0, epsilon. So it could still be rule 4. So rule 4, potentially. Potentially. It could be, right? But when do we know that rule 4 applies? It was first b, and first b, guys. So there's some non-empty set that after. Not non-empty, was it, say, explicitly? So basically, does it contain epsilon, right? Is epsilon in the first of a symbol, the leftmost symbol? OK. So is epsilon in the first of big c? Yes. Is it? What's in that set? How many elements are there in that set? OK, it's not epsilon. It's empty. It's an empty set. So epsilon isn't empty? What's epsilon representing then? Epsilon represents an empty string. Empty string. A string of length 0. But epsilon is a thing, right? So if you have a set with nothing in it, right? So empty set versus empty string. Exactly. So if I ask you what's the cardinality of this set, the empty set, how many elements are there in this? Zero. Right. If I put epsilon in there, and I say what's the cardinality of this set containing epsilon? 1. 1. OK. Exactly. Gotcha. So that's why I don't apply rule 4 now. Because it doesn't contain epsilon. Exactly, yes. And I look at the first of c here. I say it's empty set, epsilon's not in there. Bang, I'm done. I know rule 4 and rule 5 don't apply because there has to be epsilon in the first set of those symbols to apply these rules. OK. Then I go to the next rule. Big A goes to little a, big a. OK. So in that same square, you're now looking at big c and little a. But I just did c and d. Yeah, so now that you've looked at that, now you're going to look over the other side of it. Exactly. OK. So I look at the other side, and I say, OK. Let's apply rule 3. What's the leftmost symbol? A, little a. Right. So what's the first set of little a? It's not on my table, so where do I look? So I have to look at one of the rules. That's rule 1. Oh, yeah, rule 1, right? So I take that, I say, OK. This returns the second containing a, and then I subtract epsilon from it. So what's the second containing a minus the second containing epsilon? A. Hey, the second containing a, right? Exactly. So I add that into the first of a. OK. And then I ask again. I can ask again, right? Rule 4, does rule 4 apply? There's no epsilon. Exactly. There's no epsilon in the first set of little a. So I don't go on. And so I'm done. So now I say, hey, the first of a is little a. Gotcha. OK. Makes sense. So then what's the first to be here? Yeah. No, I don't know. I don't know what you want. Yeah, I'm going to, as long as you're willing, first containing a, first containing a, first containing a, first containing a. Ah, OK. Perfect. Yeah, we'll step through that because that's actually pretty complicated. OK. So here we have, so first of b, right? Just goes to b. Just goes to b. This first little b, right? So we apply rule 3, and then rule 1. Perfect. So now we want to do first of c. And this is where it kind of gets tricky. So we take this rule, little c big c, right? We apply rule 3. So we say, hey, what's the first set of little c? We apply rule 1. We say it's clearly the second containing little c. So we subtract epsilon from it, then we add it. So we know the first of c contains little c. Yes. Then we look at the other rule. So the other rule says, OK, c goes to epsilon. So I apply rule 3. Epsilon minus epsilon. Epsilon minus epsilon is what? Nothing. Empty set. Empty set, yes. Exactly, it's the empty set. So we add the empty set to the first of c, right? Which doesn't change anything. So c is still the second containing c at this point. But then we ask, OK, does rule 4 apply? What was our condition for rule 4? The first element had to be epsilon. Right, there has to be an epsilon in the first of the first symbol. But that rule says, if there is, then you can add the next symbol to the first of a, to the first of a, in this case c. But is there a symbol after this epsilon? No. No, so we can't apply rule 4, right? There's nothing afterwards. So therefore, you just take that epsilon that was the first one. Then I apply, ask if rule 5 applies. Right, I still haven't checked that. So does rule 5 apply? So how do I check rule 5? It has to all be epsilon. All be epsilon. So are all the symbols in this rule on the right-hand side of this rule, are all the symbols? Is there epsilon in the first set of all these symbols? Yes. Yes. Then I add epsilon into this. So rule 5 is the one that's being applied. Exactly, yes. And that's an incredibly pedantic point, because when you look at this, you can easily do, yeah, c and, little c and epsilon, right? So if you're programming it, you have to have the rules to do it. Exactly, yes. So that's how you know your rules are working correctly, because you don't have to special, there's nothing special about epsilon in there. It just applies all of these rules. Does that make sense? Yeah, so I think the way to maybe do it, I don't get a good, I don't know if there's going to copy-paste in here. A little bit, yeah, right? Fuzzy. Crazy fuzzy. Because I want to have these, maybe I can do something like... Screenshot? I'll do side-by-side or something like that. What do you mean you won't go smaller? What are you... Programs are stupid. Okay. So we have the rule, right? We have, I'd say just the stupidest simple case, right? S goes to epsilon. Just the empty string. Like, what's the first of S? Right, this is what we want to calculate. First of S, right? So first, wait, for first, right, I know S is a non-terminal, right? So I have to first apply rule three. Right, so rule three says, hey... I didn't know it was a non-terminal if it's going epsilon. Because non-terminals are only on the left and it's uppercase. Exactly, yeah. So all of the non-terminals will be here. So you always have to apply rule three even if it goes to something that's a terminal, essentially. Yes, yes. Exactly, that's the thing is... That didn't make sense to me because I saw it going to term life. I figured you just applied... Yes, you can do that because you're a human and you can take shortcuts. Okay. But the computer, right? Just algorithmically... Has to apply... Apply the rules, yeah. That way it doesn't matter if it's whatever, whatever, whatever, you can just calculate it. So we say, okay, first of S, right? So I say, okay, take... Rule three says take the leftmost symbol, add the first of B minus epsilon to the first of A, right? So if I kind of draw this out... So applying rule three means that I'm going to say first of S is equal to... I'm going to shorten this to just F. First of S union with first of epsilon, right? Minus the set containing epsilon. So this is just straight application of this, just substituting in... Here I have S is A, right, in this example, and here I have this B is epsilon, right? So it's just straight substitution, right? So then I can say, okay, how do I know the first set of S? First set of S? Yeah, so this is the first set of S, right? So I say it's adding it, right? So what did I calculate as the first set of S? Epsilon? What do we do first? What's the very first thing we do in that table? We look at the empty string, or empty set. Empty set, exactly, yes, right? So I look and see, okay, the previous value of S is the empty set. The empty set. So I put empty set here, exactly. Then I say, how do I calculate the first set of epsilon? Rule two. Rule two, right? Rule two applies. Yeah, then I do this, right? So I take this here. You're going to be deleted. I don't know how to delete you, but... Okay, so what's a second containing epsilon minus the second containing epsilon? Empty set. Empty set. And the union of two empty sets? Empty set. Empty set, right? I just applied rule three, right, to this, and didn't change anything. Rule three did not change anything. So then I say, okay, I did that. Can I apply a rule four to this? Yes, because that's that containing the empty set, right? So rule four says, hey, if I have a B zero, right, the leftmost symbol, if there's a first, if there's an epsilon in its first set, then add the symbol after it to the first of S. There isn't any symbol after it. There's nothing here. It's empty. The rule applies, but it doesn't apply. The rule applies, but it's nothing, right? Nothing here. You can't add anything after it if there's not anything there, right? Isn't it rule five? No, no, rule four. Rule four. I was just talking about rule four. And rule five also applies because you went through all your sets and the last set contains the first set. So we check rule four first, and then we check rule five. We say, does rule five apply? So how many, what's the K here? If we were to like simplify this down to where we're at now. What's this K here? Zero, zero. Zero, right? So we say, okay, that's zero. So is the first of B, is epsilon in, that should be epsilon in first of B zero, interesting. Never noticed that. Okay, is epsilon in the first of B zero? Yes. No. Yeah, so that checks. Is it through all the BKs? So BK is zero, right? So we just check that. So then we add epsilon to the first of A, but what's A in this case? S. S, right? So by applying rule five, right? Rule five says, hey, if, if we just look at that, right? It says if epsilon exists in the first of epsilon, right? Then, I'm gonna do this as a then. Then first of S is equal to the first of S union, the second containing epsilon, right? Okay. So then I, I've already calculated this, right? This is the second containing epsilon, right? So is epsilon exists? Is it a member of the second containing epsilon? Yeah. Boom. Checks passed. So this means I do this. So what's the first set of S? Empty set. Empty set, yeah. All right. So I do empty set union with epsilon. So I say, okay, in this step, I calculated the first set of S is the second containing epsilon. And it's a rule four failed because there wasn't a second character that wasn't a non-excellent value. Exactly. Yes. Would it, would it better, or not a better way, a different way of saying rule five is just if you've made it, if you've made it through all of your rules and your last first set still contains an epsilon, then you just add that epsilon back in. Yes. Okay. That's the way I think about it. It's a simple, simpler way of saying it. Because seeing that rule looks confusing for, for lack of a better term. Yeah. So then after one application of this step, right? So when you actually, you know, program this, and I mentioned this in class, you don't actually program it recursively, would you like see all your rules, set aside sets for them to create, initialize them to the empty set, and then just do passes on them. Yep. Similar to how we did it in class. Yeah. Okay. It's exactly how you do it. And all you got to do is write, so you got to write sets somehow. You have to have some way to determine to create a set. You need these operations here. You need union, and you need subtraction. Would you be able to do this recursively? Or would you have to like come up with a six rule to handle? A six rule to handle. The case if you, but I honestly, I don't think so. You'd have to manually detect when you're in a cycle, right? Because if you have A goes to A, yeah, well that's easy to check because you're doing A, but you could have A goes to B, B goes to C, C goes to D, D goes to A. We could just keep track of what rules you're, you're applying on. You could be detecting a cycle. Yeah. On the program side, we have to define all these rules one day. Just pass them through. Yes. Can you maybe post some examples, like supplemental examples that we can verify and go over ourselves on our own time? Yeah, there's other examples in the slides. Is there? This is the homework. And the homework is more examples. Gotcha. I have other examples I can give out, but they're, you know. There's more in the slides. Yeah. Go through those, too. Mm-hmm. Yep. I'm going to have to go over your video. Okay. All right. Well, that's why we have the videos. Good. Yeah, and you can, I'm recording this, too, so this should be helpful. Yeah, it is very helpful. I think. Yeah, actually, that's what I'm going to ask you. I try. Okay. No questions, sir? Yes. So for the definition of first set, I'm still kind of hung up on it. Sure. Like, the first rule, it kind of bothers me just because it's like derived from X. But we don't derive anything from the terminals. Or it's like a parse tree different from like the actual deriving. Because when I was doing the deriving here for the homework, it's like, I see how like from here to here when you're driving. I mean, this is the first symbol when it's derived from A in a way. I guess I mean deriving more in the tree sense. Like, I think of it as like. But nothing comes out of the tree. Right. So I think about if you start at a root, right? Yeah. So the idea is, if I start with a terminal A, right, or some non-terminal. Yes. I know that by applying all possible of these rules, I'm going to create a crazy tree. Yes. Like, of all possible things that I can create. Like, if I wrote out all the strings there that they could create, what's that first character that's in all of these are the first terminal? Yes. So the same logic to me applies here is, okay, I could write out all possible. But nothing comes out of the non-terminal. What's the string here? Like, that's the thing is like, what are all possible strings that are derived from A? There are plenty of things that are derived from the non-terminal A, but. So what are all the strings that are derived from this? Nothing. Like, nothing comes from it. That's like my intuition that nothing comes from it. Isn't that, isn't this equivalent to this string? But that's already the string. It's just looking at trees, I think, right? So like, if you had, I don't know, S and you have A and you have B. You have A and you have B like this, right? So if I look at any of these in isolation, right? Like, if I, I understand what you're saying. So if I look at A, right? And I just have the rule like, let's say we have the rule like A, B, right? A goes to little A, B goes to B, right? Yes. So if I have big A, right? So I say, okay, all possible strings that, trees that start with A as a root. Yes. Right? So what are they? So just little A. Just A, right? This is the only possible string, right? By the same logic, if I just look here and I say, okay, if I use this as the root, right? Okay, it's a root. It's also a leaf. It has no children. But it still represents the string A, exactly. So that's what I think of as derived from, like all possible things. But like, the derived just implies that like something is coming from it and I know like nothing comes from the leaf. Yes. It's just difficult terminology to wrap around. Yes. Derived, I guess, is I can understand it's confusing because we use it in different places. Yeah, okay. Okay, I gotta. Thank you. Relief.