 Morning everyone. Let's get started Monday morning. I am Monday. Monday. Monday. I actually never heard of that. I don't know if that's actually true. Is it true? It's Monday. Monday. Sunday. Monday. I've never heard of that. It's one of those things you tell yourself at the crime scene. Oh, I see. You're conceiving yourself. Yes. Monday. Monday. Let's get ready to roll. Brief over here the week. Today we're going to go over Lambda calculus. Wednesday. And after class today I'm going to release the practice, the midterm three practice, the practice midterm three exam. Then on Wednesday we'll go over that practice exam in class and we'll have the midterm on Friday. Cool. And the homework is due Wednesday. It's tomorrow. Tomorrow. Okay. Great. So we've been talking about Lambda calculus and we've been trying to think, we've actually been trying to establish, so what do we mean when we write the Lambda calculus expression? So we're kind of trying to treat this as we're learning a new programming language that we don't know. So we're trying to come in with open minds. We don't want to take any preconceived notions. Okay. So what's the syntax? What are the syntax rules for a Lambda calculus expression? An expression goes to two expressions. Two expressions, so expression space expression. That's one. Expression goes to ID. Expression goes to an ID. Expression, dot expression. Not quite it. Lambda expression, dot expression. ID. Yeah. So that's an important thing. This can't be an arbitrary expression. It can only be an ID. And we have expression space expression. And what's the last one? In parentheses. In parentheses. Good. All right. Look at that. See, look. Not scary. Not scary at all. Okay. So we looked through some examples. So we talked about the disambiguation rules. Okay. So we looked at, we saw that whenever we see e space e, we're going to assume that this is left associative. So this means that in the case of x, y, z, we're going to group x and y together first. In the case of w, x, y, z, we first group w, x together, the leftmost, and then we group w, x and y together. And for here, we're going to try to extend the dot all the way as far to the right as possible. So that lambda ID.expression here is going to be parsed as if the whole expression inside lambda x.expression is x space y. Similarly here, we're going to have this dot go all the way there. Okay. Some other examples. So is this the case that, so is this the same as lambda x dot yx? No. Why not? Because you would arrive there via, you would arrive there via a different tree, right? But so what does the disambiguation rules tell us about this expression on the right? Yx is one expression, but lambda x is another. So this, yeah, so here, even though we have the dot, right? So it should be kind of clear, even though, yes, we have the dot and we said we tried to extend it as far right as possible. Well, clearly it can't extend farther than this parentheses, right? We're parsing this thing, right? This is saying, okay, the very first thing is expression, space expression, right? Expression here, expression here, because of the parentheses. Those are forcing us to parse it in that way. Lambda x dot parentheses xy? Yeah, that's the same. So is this the same as what? The second one. The second one here? This one? Yes. No, because it's not y. It has some, yes, details. Right, but we can see that this, the body in here, right, is lambda x, and the body is both x and y of this lambda x, right? So the dot extends all the way to there. What about this? You had to insert all the parentheses possible to make this unambiguous. Could you do it? How many would you insert? Three cents. Okay, cents, yes. Three cents. Inserting parentheses should always be even, right? Unless you're talking about cents. I agree, right? So you have AB inside here, you're going to fully disambiguate this, right? I mean, you have another parentheses around here, you have parentheses here, parentheses here, right? Four cents. Four cents. Four. Okay, so does everybody feel any questions on the syntax part of lambda calculus? This is something that is very important because when you write a lambda expression, right, and if you write it assuming different disambiguation rules, and according to what we've talked about in class, it's actually parts of the different way it's going to be wrong, right? You didn't write the correct expression, yeah. So if you write an expression that's invalid under lambda calculus, what exactly is that called? Just invalid or is it a type of error? It would be a syntax error just like any other programming language, right? So we have our specific grammar and if you don't write it according to the grammar, it's going to be a syntax error, just something that doesn't belong in the language of lambda calculus expressions, yeah. Why do we do it left-associative instead of right-associative? Do you want me to make up a reason? It's a convention, I would say. Actually, I think it's probably, well, you just need a way to do it. It gets into more of a semantics, it's function application, and it's a little bit, I think, would be clearer, more natural this way, the way you think about functions. But honestly, it's just a convention, right? You could do it completely with right-associative and it would be fine. Assuming it would be used in homework or tests, do you want us to do left-associative? Yes, got to use these rules, right? So this is what we're going with. So in this way, if we write a lambda expression that is not fully, has all the parentheses that it needs, we can know exactly what we need. So this way, there is no ambiguous lambda expressions. And we're all assuming these rules. Okay, syntax questions. All right, cool. Now let's go to the cool part. So what do these lambda expressions actually mean? This is kind of the interesting part. I could talk about syntax all day, but really that just means, how does it look like? So semantics is about what does it mean to be a lambda expression? Okay, so every ID that we see is a variable. That's what we're going to think of it as. Every instance of an ID is a variable. And here, we're kind of defining some terms that we're going to use that are going to help us when we talk about what do these things mean. So we say, okay, any variable we see or any ID that we see, we're going to call it a variable. When we see this rule, so lambda ID dot E, dot expression, we're going to call this an abstraction. And a lot of this is from historical context, too. So we're kind of learning this kind of in the original manner that it was presented. Okay, here the ID that's here next to the lambda is the variable of the abstraction. It's also called the meta variable, but I don't think we'll use this. So this is the variable of this abstraction. So it's some abstraction over this expression E that has the variable ID. And E is called the body of the abstraction. So another way to think about this is functions. So here I'm defining a function that takes in some parameter, some variable ID, and it has some body, which is the expression. Like we said, lambda calculus, the basic parameters are defining an anonymous function and applying a function. So the ID is the parameter? Yes. No, there's actually no names. So all functions are anonymous. So like this function here has no name. It is a function that takes in a parameter called ID and it has some body, which is the expression. Then now here's where, okay, so we have defining functions. Here we have applying functions. So this what we're using is, so E space E, we're going to call it an application, right? Which is exactly what we call applying functions, right? When we talk about function semantics. So this is going to be how we apply functions. Any questions on this? Just a little terminology? Okay. So as we said, lambda ID dot E defines a new anonymous function. Basically. And so this is why. So anonymous functions. So in Java 8, anonymous functions are called lambda expressions. It directly comes from lambda calculus. Also in Python, we define what we call a lambda function, right? Anonymous function with no name. Use the keyword lambda. It actually comes directly from lambda calculus. ID is what we're going to think of as the formal parameter of the function, right? So this is the parameter of the function and the body is the body of the function. And the idea is function application, right? We're going to think of it similarly to calling function E1 and setting its formal parameter to be E2. So kind of this would be in our more classical, in more of our classical way we think about it is function name, parentheses, parameter, right? That's how we invoke a function. Here we invoke a function with the function that we actually want to call, right? We don't have names. We can't really refer to them as names. But the function that we want to call is space the parameter that we want to pass it. So one is the function and two is the parameter? Yes. Definitely very similar to how, just without the parentheses, right? Where do you have parentheses? And that's all right. Maybe you do Ruby programming. Some people, like one. Yeah, you can actually, in Ruby, the parentheses when calling functions are optional. So you can call a function without using parentheses and it actually looks exactly like this. In some cases it can be a little bit more clean looking, but in other cases it can be really confusing. Okay. Okay, so this is just simply an example. Okay, so we're going to get an example. We want to build up some intuition for what lambda calculus does, right? So what we're going to do is we're going to first assume that we actually have a function plus defined. Okay, we have not defined a function plus. There is no function plus in base lambda calculus. And we have some constant one. So we also, there are no, we didn't talk about numbers. We didn't talk about addition, numerals. What did we talk about? What did we define? What does our language basically have? The three rules. The three rules. What are some things that our language has? Variables. Variables? Abstractions. Abstractions and applications. Yeah, exactly, right? Variables, function definitions, and calling functions. There are no numbers in there. There's no operators. There's no nothing, right? This is incredibly simple language. But to understand how these function applications work, let's first for a moment, just assume that we have a plus operator and assume that we have a constant one. So if we had a plus operator, how many parameters would that take in? Two, taking two, return one, right? Well, kind of, all right, let's see. Okay, so we wanted to find a function, a lambda expression that is an anonymous function that takes in one parameter and returns one plus that parameter. What would that look like? One plus parameter? One plus ID? So we have, what we're saying, lambda, whatever you did. Lambda, ID. You want to give it an ID? You want to call it X? X, okay, lambda X. Dot, and then one plus X. One plus X. Okay, cool. What do you think? Space X. It'd probably be one space X if it's defined as the plus. One space X? Yes. Okay, yeah, we'll say that's a space. Okay. Oh, you mean like if there's a one plus operator? Yeah. Yeah, let's say we have two different concepts. Yeah, let's say we have a plus operator and a one constant. Okay. What does everybody else think? You could flip the X and the plus. You could flip it? Or the one and the plus. The one and the plus? Well, what, so what makes more sense? Let's think about this from what we just learned. Yeah, it should be that one. It should be this way, why? Because the parameters come after. Because the parameters come after, yeah, right? We saw that we defined basically function application. So A, where are my parentheses going to go on this expression? Yeah, so first around here, right? And then around here. The same with here. So if I'm thinking function application, so what does this mean here? Yeah, or like apply exactly. So, or which is the function and which is the parameter here? One is the function. One is the function and plus is the parameter. Does that make sense? Does this make a little bit more sense? That actually, did I just lie? How many parameters did I say that one, that the plus operator took in? Two. Two. But can we actually write a function in Landbekeg, that takes in two parameters? You could put the parentheses around it. The parentheses around what? The one in the X. No. So maybe you like this. That's a pretty good idea. Well, but what would this mean? That they're applying one to function X. Yeah, applying one as a function with X as the parameter. So this is actually a good way. Yeah, we'll kind of actually leave that hanging right now about how do you deal with multiple parameters. It actually turns out that you can translate any function that takes in n number of parameters to a function that takes in one parameter and returns a function that takes in n minus one parameter. So that's how we kind of get away with that right now. So does everybody kind of agree Landbekeg X dot plus one X will define a function that takes in one parameter and returns one plus that parameter? For any given set X, Y, you're applying parameter X to function Y? Like this? Yeah, just... Put the space there. Here your X is a function and Y is going to be the parameter. We're going to actually step through and see exactly what this means, how we actually do function application. But this is what we mean. If we were thinking about a programming language, it would be similar to doing this, which is kind of why it makes sense to be here. Maybe that does go to the left. We'll hold that question. So just like this, this is the function, this is the parameter. Exactly the same idea. This represents an anonymous function. This function has no name. It's some function that adds one to its argument. And we actually flipped our X. Does it matter? So let's think about some things that matter. Does it matter that X was here and one was here? No, assuming we have a plus operator that takes in two and returns one, the order that you add things in don't matter. What about the fact, why would we call this X? Why do we call this X? We wrote this function. So we've been trained to use this as a variable. So let's think about it a different way. If you change that X to be something else, could you define a function that adds one to its parameter? Yep. So if we change both X to W's, it would be the same. If we change both X's to foos, they'd be the same. So let's look at applications. So what happens if we... So is this function application? Yeah, if you were trying to apply what to what? So let's think about this. Are these parentheses here necessary? What if I didn't have these parentheses? Then it would extend all the way. Yeah, so the body of this abstraction would be plus X12. So intuitively, what would this mean? What happens here? Two plus one, so you get three. But how do you know two plus one? What are you actually doing to get that? You apply the two to the function on the left and replace the X's with the two. That's replacing the X's with the two. That's your weight. Do you think about that? So here we have our lambda X plus one X. And so if we want to apply this function to two, I'm going to replace every X in the body of this abstraction with two. And so by applying this... So this is called a reduction in lambda calculus terms. So I'm basically applying this function. So you can think about I'm producing this. I have two expressions here. Whenever it turns, it's just going to be the body with X substitute with two. So I'm going to get plus one. Was that plus one dot two? No, it was only the body in here, right? The plus one, two. I substituted the two in here to suggest the body. And we're going to go into exactly what these things mean. So these are... I'm trying to... You want to develop some intuition for what do these things actually mean. So that way, when you look at something, you can compare how you actually mechanically do it versus how it actually looks or how you think it should be. And so, yeah. So then we would then reduce plus two one to three, right? We didn't do that, but by just applying this function, reducing this function, we'll get plus two one. And then if we reduce that, then hopefully we would get eventually three. So now how can we define a plus function if abstractions only accept one parameter? How can we do this? We have a language, right, that only supports one parameter. Man, that really sucks. That's really limiting. How many functions do you write that take in only one parameter? Percentage-wise, of all functions you write, how many functions just take in one parameter? Not enough to be memorable. All right, let's think about this. Yeah, it's probably, I don't know, I'd say maybe five percent. Maybe a good, like, lower bound. I mean, it really depends, right? So, okay. But the idea is, let's think about this. So let's say we want to create a function that sums up, I don't know, let's do three. Let's go with three parameters, right? So ideally, if I was writing a function, I would do some kind of fun foo, and I've had A, B, and C, and I would say this is equal to A plus B plus C, right? I'm defining a function, I'm defining a function that takes in three parameters. I'm actually even using a plus function that takes in two parameters. So the question is, so I made the claim at the beginning of the section that lambda calculus, right, can is turn complete and can represent all types of computations. Well, if lambda calculus, the basis of the computation is functions, well then how could you write what would be a trivial function in normal language in lambda calculus? So here's the idea. Let's think for a second, right? Let's talk about functions. The fact that I called these A, B, and C, does that matter at all? No. No, right? So let's make a new function. We'll do lambda A dot lambda B dot lambda C, and we will do plus A, B, make more room here, plus A, B plus, so how many abstractions do I have in this expression? Three. Three. So we're going to do something else. I said you can't name things. I'm going to give this a name. I'm going to say, I'm going to use mathematical naming. So I'm going to say that this thing is foo, right? So anywhere I write foo, I can just expand it out to this expression. Right? It's not really a, I'm not defining it, I can't call foo within foo, right? The language has no name for it, but I can just replace it here. So if I call in our language up here, if I call foo one, two, and three, right? You would know exactly what to do if I call this function. Actually here I think we do get it to a left associated, so here it makes more sense. So if I'm looking at this, from my disambiguation rules, what happens first or what, where do the innermost parentheses, sorry, in here, right? Because here I'm just defining a function, right? There's actually no, well, defining a function. You would group foo and one and that and two, and then that and three. Cool. Okay, so let's look at this. So if I call this foo with one, right? So I have foo one, and I know foo is lambda a dot lambda b dot lambda c dot plus plus a b c, right? All of this applied to with one. So now what do I do? How do I apply this to one? All the a's with one inside layer in all of the parentheses, the body of the outermost abstraction, right? Because I'm calling. So think about it like this. So if you think about function definition, it's here I've defined a function that takes in a, and what does this actually return when I reduce this and apply this? A plus b plus c. Lambda b. Lambda body, right? Yeah, so it returns a function that takes in one parameter b, which returns a function that takes in a parameter c, right? But we've replaced it in here a with one, right? So let's reduce this by one step. So here we have lambda b dot lambda c dot plus, plus, now what do I put in here for a? One. One. b c. Have to put plus and a in a parentheses. You do, but I'm ignoring that for now. We're assuming we have a magical plus operator that will do it like this. We can see, if we can show this concept, it should be pretty clear about how plus would work. And I actually don't need to put parentheses there because that's not ambiguous, right? So if I do plus a b, we know exactly that plus a happens first and then that b is applied to that result. So I've reduced this, right? So this is this expression here. This is super ugly, why? That's this expression here, right? And now I apply what? Two. You apply the result of the top. The two? The two. Yeah, so what do I do then here? Replace b with two. Replace b with two inside this body here? Yep. So I'm going to have lambda c dot plus, let's go plus one, two, c. Shouldn't you c? My parentheses sometimes look like c's. So let's think about this. First, so here I had a function, right? I want to write a function that took in three parameters and returns some result. So instead I wrote a function, I wrote, okay, so I took, instead I wrote a function that takes in one parameter that returns a function that takes in one parameter, that returns a function that takes in one parameter, right, but that was three and then that actually does something. I'm confused. Is there an extra set of parentheses in the last one? Well, I think it's going to be another one when I throw a parentheses. Yeah, we'll just go add the three. You just hadn't put the parentheses on the left side yet. So let's think it. Now, do I know what this result is? Can I reduce this result? Plus one, two. Yeah. So we're going to say lambda c dot plus, say this returns three, c, right? And then I want to apply this whole thing to what? Three. Three, right? And then I reduce this. What do I get? Plus three, three. And I reduce this. Three, six. So essentially, this is how we do multiple parameters. Yeah, I see that. Let's see. Apply. This one? Yes. We need to define a magic free. Actually, so we will define a plus operator. We will also define actually the numbers are going to be functions instead of actual numbers. So we can think about them. But they will still work and then act like we would want numbers to work. Yeah. Can we do it next time with letters? With letters? I'll make it more confusing. Probably, if something like this we need some kind of, we want it to compute something. So we're actually going to show how we can do this. We're going to find true and false in terms of functions. And we're going to find numerals also in terms of function. But this is kind of assuming that we've done that and kind of not worrying about those steps. Like if I gave you a lambda calculus with a plus operator and with numbers, the key part here is in, so this is essentially called, this is called currying. So I need to translate the evaluation of a function that takes in multiple arguments, into a sequence of functions that each take a single argument. So this hopefully shows that you can actually, so actually it's kind of interesting to think about. So the ability to take in multiple parameters into a function doesn't give you any more expressive power than just taking one parameter in a function. So you can translate it, exactly. You can translate it backwards and forward. So here we can define a plus operator, kind of like this, and we can apply it, and this is kind of the same example, so I'm not going to step through this. So we talked a little bit about variables, we talked a little bit about function application, we're trying to build up some intuition for what function application means. Now we need to talk about the different types of variables because we wanted to find, so we're trying to build up a formalism here, so we needed to find very precisely what are the semantics of all these operators that we just kind of walked through. Like when we said, oh, replace A with whatever, replace A with whatever's on the right, what does that actually mean, and how can we actually do that in a way that's formal and also safe? Okay, so free variables. So we talked about variables, right? Is it any ID? So a free variable is, right, so in my lambda expression, so let's think about it like this. If I have an expression, x, y, and I have an expression and I look at lambda x. Let's say lambda x dot x, right? So here, what does this x define? What does this x, we kind of already saw that in function application, right? What does this x mean? That's the parameter. Yeah, this is the parameter, right? This is the parameter of this abstraction. It's the meta variable of this abstraction, right? What does this x mean? Right, this x and this y and this z. Yeah, we don't know, right? They could be anything. We can kind of think of them, in this case, you think about looking at them here, right? We don't know what they mean. They can refer to kind of, well, anything, right? We don't have actually enough context to understand what they really mean. So we're going to find these, we'll call these, these are going to be called free variables. So the idea is, right, so you think about it, so in this expression, lambda x dot x, right, is x a free variable? No. But if we look just at this expression, like in a lambda expression of this, is x a free variable here? So if we looked at, like, lambda y dot lambda x dot x y. So is this x a free variable? No. No, it's bound here. Is this y a free variable? No. No, because it's bound to this abstraction here. Is this x a free variable? No. I think it's bound to that other thing. Is that? No. It's not bound. What's the body of this abstraction? x y. x y. Yeah, right? From the disambiguation rules. Okay, it's not bound then. Exactly. This x is outside, right? It's free. So even though it appears, x appears in the same expression, right? This x is a free x, free variable. There's all three variables like that. We will see. We actually will leave them as is, essentially. On that last one, since you had the big parentheses and the dot, everything... Sorry, say that again? Here? So you have the dot, you have lambda y at the beginning dot. Okay, now that whole chunk after that is bound to lambda y. It's inside the body of this abstraction, yes. So the net x is bound to lambda y, right? This x... The last x, the big x in the end. Ah, no, no. It's not bound, right? It's inside the body, but they have different names. This is y and this is x. This y here is bound to this y because they have the same name. This y references the parameter y, whereas this x... So that last thing was a, not x. Yeah, it would also be free. It's a free a. Anything like an a in here, a w in here, right? Anything that does not have an enclosing abstraction that has the same name. What if you turn that y into an a? Is it still bound now? No, because it does not have the same name. Okay, so it's bound by name. Yes, yes. Alright, I get it now. Okay, so we have to define things formally, right? So we'll say x, so any variable x, right? It doesn't matter that it's actually x. It's free in an expression if, right? So what were our four cases? What do expressions look like? IDs. Lambda ID dot expression. Yeah, an abstraction, right? So lambda ID dot expression. Application. Application. Forensics, right? So just like those are our four base cases, in here we have to do the same thing. We have to define precisely what we need a free variable is in all of those base cases. So x is free of e if the expression is equal to e, or x, sorry, the expression is x, right? So x is an ID. This means that x is free, right? Just as we saw, look at that. x by itself is free. Okay, we have one case where the expression is lambda y dot body, right? E1, where y is not equal to x, right? So y and x are different. And x is free in E1, right? So this is, what kind of definition is this? How do you know if x is free in E1? Yeah, you apply these rules, right? So it's a recursive definition, right? And in function applications, we'll say for the left, so e is going to be free where if x is free in E1, that is not complete. Is that missing? Where x is free in E2? These are examples on the next slide. Okay, it's in function application. Why would x be not free there? Okay, let's think about what case is not handled here. This is actually really easy, I don't know why. I mean, the rules are kind of simple. So what case is not handled here? And rule number two here. Let's go on this specific thing here. If y does equal x. Yeah, if y does equal x, right? And y, not y, but variable, but y. Why is that case not in here? It should be as just free in E2. So if I'm wrong, I will fix that. I've just put a note to go check. It should be recursive, it should be fine. So it's free on the left, then it's free, or if it's free on the right, then it's free, right? That's what this should be. It doesn't have to be free in both, right? E1 and E2, right? This is saying that it has to be free in either E1 or it has to be free in E2, right? That means x is free in that whole expression. So basically we're defining the one case where x is not free is if the expression is lambda x dot E1, right? Then we know that x is not free there. Okay, that's a good example. So is x free in x lambda x dot x? Yes, why? Because it's free on the left on E1. Right, because it's free on the left, right? So this would be... I'm not understanding this, I don't know why. So the first thing you have to do is how to parse this. So let's, right, x lambda x dot x, right? The first question is how do we parse this? X, so if we were to draw a parse tree, right, it would be application, so we'd have x and then we'd have lambda x dot and then we'd have the body, which is just x, right? So it would be application, but yeah, this is a space, right? So x lambda x dot x, so we can think of it like this, right? Let's think of it like this, right? Our rule says, okay, well, x would be free in this expression if it's free in either the left or the right. So first, is x free in the right? Because that rule stops us from going in because it says, hey, lambda x, well, x is the same as that name that I'm looking for, so I'd say it's not free in here. But I also have to check the left expression, right? Is it free in here? Yes. Yes, right? Because this x is not bound. Exactly. So this is free. If lambda x dot x, and that x was an a, then that a was free. If this was an a? Yeah. Yeah, free. Yeah, exactly, they're both free. Okay, let's go lambda dot x, y. So it's x free in here. So is this x free? No. Is this x free? Yes. Yes. Okay, good. What about the y? It's free. It's free. Also free. Exactly. Because it doesn't match lambda x dot x. Right. Okay. Is x free in here? No. No. No. Right? Because this is under this body, right? So you can think of this abstraction kind of protects, right? This x refers to this x. The y is still right. Right? The y is free. Exactly. Oh, I get it now. Yeah. Yes, we're just going to ask the question. And that's the body that you just asked. Yes, the body. So we're saying does the body, are there any, like, what variables don't refer to the parameter? What are essentially global variables? You can declare a new variable in the body. Yeah, I know. Okay. Okay, so we're going to look at a couple things. So we're going to look at combinators. So these are ways of thinking about different types of functions. So an expression is a combinator if it does not have any free variables. So you can think of these as kind of self-contained functions. Right? We can look at them. We can use them. And they're not going to change based on context. Like a function with a free variable could change depending on whatever that free variable is. Right? So is lambda x dot lambda y dot x y x a combinator? x before the y? Which x, what does this refer to? This x? Yes. And this y refers to? The y. The y, and this x? Same x. Refers to the same x? So are there any free variables in this expression? No, this doesn't appear so. No, unless you kind of wanted to say combinator, question mark would be a free variable. But actually, that would be a really good answer. Yes, I probably accepted. Lambda x dot x? Yes. Yes. Lambda z dot lambda x dot x y z? No. No, why not? It has a y. In fact, it has a y? It has a y that doesn't have a binding. Yeah, because it's a y that doesn't have a binding. Yeah, cool. Okay, so this is another thing we're defining. So we're building up some definitions of things. We're going to see actually combinators play a very important factor. Okay, so bound variables. So this is what we're going to call variables that are not free. We've actually, I think, been kind of using that term. So if a variable is not free, it's bound. So if we went back to here. So here we said this x is free, this y is free. But in this lambda x dot x y x. So this x is bound. The question we really want to ask is what abstraction binds this variable? So essentially we're also asking which x is this bound to? The lambda x dot x. Yeah, this lambda x. What if I did something like this? That second dot last lambda x is bound to that second lambda x. So, wait, wait, let's think about this. That guy's bound to the one next to it. This one? It's bound to where? To the one next to it. This one? Yeah. And what about this? It's bound to the other one. It's bound to the other one? But this is a parameter name. How can a parameter name be bound to another? Because it's based on this function. So its parameter is the previous parameter? Think of it like functions, right? So you're defining a function, that has some parameter x. Then inside there we're defining a new function, which takes in a parameter into x. So we're trying to do it like this. Return a function that takes in that and returns x. In normal programming, what does x do to this x? What happens? What is this y reference here? It is referencing that parameter that's coming in. This parameter? Yes. What does this y to reference? The previous y. What? Whatever gets passed into it. Whatever gets passed into the function. When you program, you can have a function, have a parameter that has the same name as a global parameter. Your global variable. Well, your code's right. But it shadows this y. You can't actually even refer in the body of y. It actually goes back to scoping rules. This is essentially we're trying to define the scoping rules of lambda calculus. Keeping that in mind, does this x refer to this outer x? No. Does it refer to the inner x? Yes. Does it even really make sense to talk about if this is bound or not bound or free? This is the parameter name. It's just a new name. It's neither free nor bound. It's a meta variable. I think we'll use the term meta variable. It's not a variable we care about whether it's free or bound. It actually does the binding. We want to know. When we talk about bound variables, we want to know that this x is bound to this lambda x and not the outer lambda x. If you added parentheses on here to fully disambiguate it, what does that look like? What's the body of this lambda x, this outer abstraction? Everything after the dot. Everything after the dot. Just like you have a function body. Everything that's defined with references that same name finds that parameter. Any other questions on this? All right.