Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a "free variable"?

Tags:

(I'm sure this must have been answered on this site already, but search gets inundated with the concept of calling free() on a variable in C.)

I came across the term "eta reduction," which was defined something like f x = M x ==> M if x is "not free in M". I mean, I think I understand the gist of what it's trying to say, it seems like what you do when you convert a function to point-free style, but I don't know what the qualifier about x not being free means.

like image 996
J Cooper Avatar asked Jan 13 '12 20:01

J Cooper


People also ask

What is meant by free variable?

In computer programming, the term free variable refers to variables used in a function that are neither local variables nor parameters of that function. The term non-local variable is often a synonym in this context.

What is a free variable example?

When you first started learning about variables, most of them are free variables. For example, the x in this function is a free variable: f(x) = 3x - 1.

What is basic variable and free variable?

basic variable: any variable that corresponds to a pivot column in the augmented matrix of a system. ● free variable: all nonbasic variables. EXAMPLE: 160 300.


1 Answers

Here's an example:

\f -> f x

In this lambda, x is a free variable. Basically a free variable is a variable used in a lambda that is not one of the lambda's arguments (or a let variable). It comes from outside the context of the lambda.

Eta reduction means we can change:

(\x -> g x) to (g)

But only if x is not free (i.e. it is not used or is an argument) in g. Otherwise we'd be creating an expression which refers to a unknown variable:

(\x -> (x+) x) to (x+) ???
like image 200
porges Avatar answered Oct 14 '22 08:10

porges