2

I am having trouble understanding the concept of free variables in lambda calculus.

How and when should we use them?

I read all Church encoding and there is no use of free variables. Natural numbers, arithmetic, pairs... everything is defined without free variables.

It is also unclear how to translate the lambda term with free variables into programming languages. For example $x.yx$. What is $y$? For $yx.yx$ everything is clear. It is just $f(x)$. Meaning the lambda term takes 2 parameters and applies the first one to the second one. What is the meaning of $x.yx$?

In computer programming, the term free variable refers to variables used in a function that are neither local variables nor parameters of that function. wiki

What does it mean? Is it a global function?

Oleg Dats
  • 425

2 Answers2

4

The term $\lambda x. yx$ is equivalent to just $y$. In mathematical notation it is the function $x\mapsto y(x)$, which is just... the function $y$. To the question "what is $y$", there is no better answer than... it is $y$. Whatever $y$ is. It's some $\lambda$-term represented by a variable, which in this case is $y$.

On the other hand note that contrary to what you say, $\lambda yx. yx$ does not represent $y(x)$ (or $f(x)$ as you write it, but it seems a bad idea to use another letter randomly), but rather the function $(y,x)\mapsto y(x)$. To represent $y(x)$ as a $\lambda$-term, you just write $yx$.

Captain Lama
  • 25,743
  • So $y$ is like a name for another term. In Haskell it will be: let y = \x->x+1, (\x->y x) 2 = 3? It implies that it is impossible to convert . to SKI combinators because we do not know $y$? – Oleg Dats Jul 19 '22 at 08:38
  • @OlegDats: The word "combinator," in the context of the lambda calculus, literally means "a lambda expression that does not have any free variables." – Kevin Jul 19 '22 at 15:45
  • "In the above example, the expression [x].xy is not itself a CL-term, but is merely a short-hand to denote the CL-term SI(Ky)." I know that Combinators is a subset of CL-terms. It was helpful for me know how free variables are represented in CL. – Oleg Dats Jul 21 '22 at 16:27
0

Free variables can always be regarded as being bound in a larger context containing the one you're looking at. So $y(λx·xy)$ could just as well be considered as being inside the context $C = λy·y(λx·xy)$, and the term, itself, can be considered as a template $$y(λx·xy) = (λy·y(λx·xy))y = Cy,$$ where the "$y$" in "$Cy$" can stand for anything and $C$ has no free variables.

If you don't have free variables, then you're seriously hampering your ability to talk about sub-contexts of contexts, and sub-terms of terms, without treating contexts and terms as black boxes.

It's a case of the general situation where discussion of $A$ is much easier and more natural when done as discussion of $A$ and $B$ together, rather than of $A$ alone, even where $B$ may not have the same kind of meaningfulness as $A$. That situation happens all the time in mathematical analysis, and that's what invariably drives discussion toward abstractions like $B$ from things more concrete like $A$. The situation, itself, is telling you that you need to talk about $B$, too, and to not limit attention to just $A$ on "pragmatism" grounds. It's the kind of case where pragmatism is impractical.

NinjaDarth
  • 540
  • 2
  • 4