Question about lambda calculus.

214 Views Asked by At

Hi so im really struggling right now with the lambda calculus. It doesnt make sense to me.

So i know that ($\lambda x \to x)(y)$ means i have a function which takes a number to itself. The confusing part hits in when i see something like

$(\lambda x \to gx)x$

Does this mean i have a function which takes an x and outputs g and i should apply it to x?

or does it mean i have an a function which takes an x and outputs gx ? My book says that {$g,x$} are free variables. What would that mean concretely. Im looking for intuition, nothing is making sense. :C

1

There are 1 best solutions below

9
On BEST ANSWER

No, $(\lambda x\to x)$ is a function that takes a number (or, indeed, anything whether or not it is a number) to itself. When you say $(\lambda x\to x)y$ you're applying that function to $y$ (whatever $y$ is), and the result of that is just $y$.

In $(\lambda x\to gx)$ you have a function that takes something and returns the value of $g$ applied to that something -- as you describe it, a function that takes $x$ and produces $gx$.

However, again, when you write $(\lambda x\to gx)x$ you have taken the function just described and applied it to $x$, which would produce $gx$.

The statement that $g$ and $x$ are free variables means that the expression "$(\lambda x\to gx)x$" doesn't really have a value before you decide what the value of the variables $g$ and $x$ are going to be. It's a recipe for doing something with a thing you call $g$ and a thing you call $x$, but you can't really do it before you have decided what those things are going to be.


Note, by the way, that in $(\lambda x\to gx)x$ you have two different $x$ around. If we write it $(\lambda x_1\to gx_1)x_2$, the two ones shown as $x_1$ is just a dummy variable that tells you what the function does with its argument, whereas the $x_2$ is the free variable whose value you're supposed to decide.