 The question has to go. We'll try to record this and see if this works. This is a regular or a cursive regular expression. So we have the regular expression. So we have the regular expression is left parentheses concatenated with, we'll call it harsh, concatenated with right parentheses. Exactly. So is this a regular expression? I think it is, but are you allowed to do a recursive call in a regular expression? No. Okay. So that's why. The idea is you can't... I don't know if it's a factor, so it can be a little confusing because we've used definitions of regular expressions. We said what, a digit, d-i-g-i-a is basically 0 through 9. Num is like a digit, a p-digit. Right? We did this. But the idea here is each of these is a finite regular expression. It's definitions in the mathematical sense where you could just take whatever that regular expression is, put it right in there, and it's exactly the same thing. Same thing with the Hulmespray. When we use previous regular expressions, we're using those exactly. So even though we can say p-digit at start, the problem, and this is exactly the problem with regular expressions is we have no way of how to use this around the stars or something like that. So remember when we defined the language described by a regular expression based on all the different cases. We said the language defined by r star is equal to... I'm testing myself. I think it's a summation of l, i's, of the i's, of r, something like that. So if you did this, you'd end up with infinite definition that's never going to finish. So yeah, it's not a regular expression. Thank you. That's a good question. So essentially, basically, if you think about it, context-free grammars are essentially that. But the interesting part is once you add that one picture, now everything you have something that's fundamentally more complicated and different and can get things that regular questions can, but you have to pay for it with a little bit more non-spacer efficient. So just saying you're saying like the recursive feature is what makes it more powerful. Exactly. Thank you. I was looking at question 2, or you're given the regular expression of r, 0, r, 1, r, 2, and then it's a very last one where you're given the giant p-hack string of numbers like the 9, 0, and 2. My question was when I was reading it, it said that it's something similar, or 0 gets token function. So my question was, is it calling it on every single item one at a time, or is it calling it to where it'll find one of the regular expressions, and then once it fails all of them, it goes on to call it again? So the basic idea is it's following what we did the example that we did in class with the table and everything. So it's trying to get everything. So this is basically what you're doing. So the idea is when you first call get token, it works on the whole string. It tries to go through the string to find out what's the longest token that matches the input string. And this is why we use this to figure that out. Then once we've decided, that's when we get here, we say, okay, decimal of 3 is the longest. We return that, and we say, okay, the first token returned is decimal. And then the next call on get token basically gets rid of everything that we matched and starts right after that as if it's a new string. And does the same thing over and over again. So when I was reading the homework, that's what I was thinking it would do, because that makes the most sense. But just when I was reading the wording of it, I was just like, it would just seem slightly off to me, and maybe it was doing it 11 o'clock at night. That also could be a problem. But yeah, you should check that out. You can see the stuff where I did in class kind of going over it. It's the exact same. Okay, thank you. Well, check my logic. Checking his logic. I'm eavesdropping on this. So I defined a couple things. Our version of p-digit digits in the header. So how I'd understood it, a hex function had to be in the header followed by any other digits except for running zeros. So more than one zero wasn't allowed, essentially. So I was thinking you'd have a header. Had to be compacted with a digit, one through hex characters, and then followed by any number of zero plus those, or it could be one zero followed by the header. What's the valid hex value? Is this a valid hex value? Is this a valid hex value? Is this a valid hex value? I would say so. Is that a valid hex value? I don't think so. Did you define your hexes as being okay with it? Is this a valid hex value? No. Oh, I guess you define it as all lowercase or all uppercase. You can't mix and match, per se. You want to make sure that uppercase to hex doesn't matter. As long as you just define it as one way or the other, uppercase or lowercase. That's actually a really good question. Should we define for both uppercase and lowercase, or is one fine? I would say both. Just do exactly this, put a big bar there, define another set that contains the lowercase stuff, and do literally the exact same thing. One or the other. Is that a valid hex value? I have an idea of how it's done, but I thought you couldn't define syntactically as a lowercase with an uppercase. If all you care about is the character, it doesn't matter. We'll say that's valid for our purposes. You should put that in state of your assumptions. Is there any other cases that I might need to look at here? More than one zero is not valid. That is valid. The same one is valid. What about that matrix question? No, because I'll hit that case. So any more than one zero though? That's valid. Because you can do lowercase and uppercase in your language, you have to define it as a valid and the character has to be either uppercase or lowercase, but it can't be both at the same time. I guess you could do it. You have to think about it from the compiler's perspective. Can I take this hex value and interpret it as a base 16 number so that I can do some computation? If I was looking at it and I just saw that, I wouldn't question it. Your compiler should support that. If I am a compiler, then yes. Technically that's a hex. Would you say that's a valid number? I mean they're both right. The same principle behind this. I thought we said the whole num thing. That would be leading zero. So we're going with no on that one, right? That follows much more closely with what we've been doing in class. Cool beans. Thank you. So we should have leading zeroes. You should follow what we've been doing in class. When we define regular expression and smash a number, we said this is in there. This is not in there, we want to prevent that. So the same thing applies here. Somebody touched it. Sorry. Correct. I have a question. Sure. Sure. I don't know the numbers exactly. Right. And it will fill the language requirement for the expression, but then there is a string left over. So I guess in general, right? So when you're trying to answer this question, right? Like is it an element of or is it not an element of, right? So the idea is, you know, one way to think about it is we defined explicitly how a language defined by r is calculated, right? That set is a bunch of strings. So the question is, is this string in this set of strings here? So let's say it's a, a, b, right? And I have in the language defined by r, I have the string a, a, right? So let's say r here is just the regular expression a.a, right? So the only string in there is a, a. So if you were to say is, if you were to say is a, a, b an element of the language defined by r, I would say, yeah, because a, a, b would return language, I'm sorry, I guess it would be like getToken. Ah, okay, yes. Yeah, you got it. So, yes, it has the potential. So like, how do I match what I've seen so far of this string? Does it match something in the regular expression? So like the entire time as I was going through it it matched Alfa. It belonged to Alfa. Once I got to the end of the last character, I had like 30 more minutes on this full four five to clean up my code. What was your first design? Exactly. So, okay, here's Aston. Great. So technically it would be language development. Ah, okay, yeah, so this is the thing. So when you're answering these type of questions, right, so is it an element of the language defined by r? Right, so the way you've got to think about it is exactly like this. So we have r is a.a. We know the language defined by r is the set containing just the string a.a, right? So right now this is just a set question, right? Like is the string a.a.b in this set? It's definitely not in there, right? Yeah, exactly. Exactly, so yeah, that's what this thing is. Is that string possibly in that set? And that's just, and this is what regular expression matching, like does this match this regular expression exactly, right? When we're doing the table to do long prefix matching, yes, that's where it does get because potential means is it, so this has the a.a.b, right? Actually a.a.b does not have the potential to match the regular expression a.a, right? Because it's got the potential, it's got to match all of it, but probably what is happening, right, is you're thinking about, okay, if I'm just looking at a.a, right, that has the potential to match the language, the regular expression a.a, right? Well that's if we're considering white space as a... There's no white space here, a.a.b. Right, yeah, yeah. So just don't worry about the white space, it doesn't matter in this case. Yeah, so this, yeah, so you just have to so this is why when we do the tables, right, we step through it during the time, and at each point, right, so here we're only looking at the string one. We're just saying, okay, does it have the potential to match any of the tokens? Yeah, we don't look ahead, that's why we do this step by step so that way. Okay, thanks. So in the vein of that question you already had one, is that something else? You already had one too, didn't you? No? No, it was just a question for me something really quick, but for this, like, would this be a proper way to show our work for these questions? Yeah, that's good. Because I know what you're saying, it's like, well, sometimes you would use a like, long street tags, that's nice. And I think that shows what you were talking about, like this entire time, it matched alpha and then you get to the end, it doesn't. So, good, thanks. Questions? Yeah, sure. I have a question on the home, do you mind if I use your, is that dependent? So what is the difference, if you don't mind explaining a little bit, what is the difference between desk parentheses, so full star or bar star, and then everything star versus if you would have had full or bar star. And then what if you have full star or bar star without the star for the parentheses? Like, there's three different parentheses that are kind of confusing, you know? Got it. So you mean, so that? So that is the first one. So then it basically says that you can have... So what does this mean? Let's parse it. And then the third one would be like full star or bar star without a star for the parentheses. I just want to go over those as general ones. Cool. So I think I understand, but I just want to double check with you. So full star or bar star, everything star, means you can have any combination of full is repeated and bar repeated and that combination is repeated. Exactly. So then you would have, you could have full, full, bar, bar, and then that would be repeated. Yep, and then full bar, full, full bar. But it doesn't have to be that exact combination, right? The star just means zero or more of that. So then in that case, in the case of that parentheses, could you have full as a valid? Yeah, so full matches, right? So if you think about it, right, we take this once, full matches this, if this is one, this goes to zero, we don't repeat any more. Exactly, and then full would be a valid one, okay. Exactly. We'll get there, almost. So full... This actually maybe was going to be your homework assignment, but I couldn't figure out how to do that, because I didn't want to get into proofs. So let's think about this one now, right? Full or bar star, right? So it's pretty much you have full, but instead of taking it multiple times, you only take it once. You could potentially have it just once or bar once and then you can repeat it. Exactly, so you take... Could it be like full bar, full? So this is any number of fulls or bars. Zero or more fulls or bars. So then wouldn't it have the potential to just give the same string as... So then in that case if we take his answer and say they're the same we can potentially have for both of them, you can have full, full, bar, bar, right? Like full, full, bar, bar, right? And they're going to be valid for both of them. So is this string in the language defined by this regular expression? Yes. So we have full any number of times, bar any number of times. This goes once, that matches. Here we have for the first character matches the full and then we can have any more full or bars. This matches a full. Any more full or bars, this matches a bar. Any more full or bars, this matches a bar. Can you give an example of a string that wouldn't match the second one or that's different for the first or the second one? I don't think so. So this is the thing. I'm pretty sure they're equivalent but I can't prove it. That was going to be your third homework problem was proof that these are equivalent but to prove that regular expressions are equivalent you have to do set equivalents and subsets and all that stuff. There's a bunch of stuff we don't go into. I thought about it and I was like okay in explanation they're not the same but in practice they're the same. It doesn't sound the same but then if you write them out it actually sounds the same. I'm fairly certain they're the same. They can actually just be the empty string because the top one has the potential to use it. The second one. Right, so if this is zero or more what is this string going to produce? The thing is each of the who bar and star bar who star or bar star. They have the potential to be the empty string so you can get empty string, empty string, bar, empty string using empty string within it. Whereas the bottom one it would have to be a four bar and you couldn't have an empty string mix. Yes but when we define the language of a regular expression it's just strings and we simplify it down to get rid of all absolute space. It was just a semantic. Would it matter if you had empty string, empty string, bar versus empty string doesn't even count right? If you take it in a string. The theory definition is because we define the identity of a string concatenated with epsilon is the same thing as that string itself. Then those would be the same sets. Logically it doesn't change what it is but when you actually, I'm also applying what I've been learning in 355 it does technically change the definition of the string without changing the meaning of it. That's why I don't want to make any claims that it definitely does or definitely does not. So then the third one. Pretty much what the first one means without the repeated part. What does it mean? So it's foo any foo string repeatedly or any bar? Right so is foo foo bar bar in there? But you wouldn't be able to do foo bar foo bar would you? Is this string in here? Well it has to be one of the others so it has to be all foos. Zero more foos or zero more bars wouldn't it be? Because you have to do either a foo or a bar and it has to be zero or as many as you want of a foo or a bar. Yeah let's break it down. Right? We get that transformed into there. So what's the language, what's this look like? What's the language of foo star look like that set? Empty string and then foo from one revolution to a number. Okay and then the language described by bar star? The empty string and then the iteration from one to infinity of bar. Right what happens when you union these sets, what's the language of these two sets union? Empty string and foo from one revolution to infinity of bar. Right what happens when you union these sets what's the language of these two sets union? That would not be concatenating with it. Bar, foo, foo, bar, bar. It doesn't mix in the same way the top one did. What's set union do? It takes all the elements and puts them together. It does not do concatenation exactly. So this is foo, foo, foo. So can you have three foos in one bar or not? No. So is that in that set? You can have two. Foo, foo, bar, bar. So here's the other thing to think about it. Is it in either of these sets? Is foo, foo, bar, bar in the language described by foo star or the language described by bar star? Nope. It takes the sets and makes a big set out of both of them. So it's not doing any concatenations or anything like that. It just says it can be either... It can either be foo, foo, bar, bar. It doesn't allow that to mix. It can either be any number of foos, zero or more foos. Or it can be zero or more bars. It takes one or the other. Yeah, the last one. I recorded it. I'll post it. Cool. Any other quick questions? I gotta go to class. Okay. So these are considered greedy when you're running them, right? Like these regular expressions? Tricky. I'll keep talking and I'll tell you if that's correct or not. There's two quick versions of it. I'll start with R2. If you're given 0, 1, 1, that would all fit into the first part of 0, 1 star. But it would also match if you went 0, 1, 1. So that could be a matching and a potential. Got it. So the idea is... So remember what you're talking about is, well, potential or match. So it could be both how I sort of see it. If you look at it as a greedy or not, correct. So matching, right, just says is it in... So it's exactly what we've been doing here. Is that string exactly in the language defined by that regular expression? So the idea here is for matching, right, so in this language described by this regular expression, there's going to be every possible combination of applying zero or mores and concatenations and ores, all that stuff is going to be in there. So matching just means is there one essential path through that regular expression that matches? Just one path. Exactly. It doesn't really matter how you... Which path? Exactly. As long as there's one. Potential says... There could be more. Yeah, have I matched a prefix? Yeah. Can I still match more characters in there based on what happens? So it is matching and it's a potential. Exactly. So you look to see if it's greedy, see if you can add more to it, but you have to look for a match also at the same time. So in this case, do we have a potential here? On what? On R2? On R2, yeah. Because you can fill up the zero or one infinitely. This is zero or one infinitely. So yeah, so that could still match, right? You don't know what's after that. So we can say, yeah, we're still in here. We're still matching whatever. So yeah, we still have the potential to keep... We can keep going. You keep giving me zero or one. I'll keep having a potential to match. So here, can we have zero, one, one, zero? Does it match R2? If we didn't have this. Just this one. Does it match zero, one, one, zero? It wouldn't be a matching. It would be a potential then. Wait, wait. If you just had, sorry, if you had R2, if you had R2 as zero or one star. Yeah. So we have zero or one. Or is it like you have to have zero, zero, zero, one, one? Or can we have a combination of zero, one, zero and one? Right. So the matching question all comes back to what is the set of the language described by zero or one star? Right. What does that set look like? I'll just call them zero, zero, zero. Zero, well... So then we got to break this one down. So... Oh, that's how you have set up zeros and then set of one and then any combination of those. Concatenated, yeah. So the star operator right means repeated, which means concatenation. And that's where you get the concatenations. So the idea is so this is the same thing as the union, big union of all of the language described, well first it's, actually let's do this. It's epsilon, union with the language described by zero or one union with the language described by zero or one concatenated with the language described by zero or one. Right. So we can just go... union with, yeah, we keep repeating these concatenations together with whatever's inside the star. So then we have the language of zero or one concatenated with the language of zero or one concatenated with the language of zero or one. Okay. So to answer one question Yeah. So what's the set look like? Wait, let's go back to this. What's the set look like then? This resulting set. What are some of the strings in here? So epsilon right? You already said that from here. So what from this one? What's the language described by one or zero? Exactly. And then what about this one? I'll see you later, man. Sounds good. What else? No, no, from this one. What else? From that one? Yeah. Yeah. Right. So it's every possible combinations of ones or zeros concatenated together. So any combinations of zero or ones. So then back to your question here, right? Is this going to be in here? Exactly. Alright, I gotta run guys. Okay. Thank you.