Definition
A free variable in an Expression is a variable that is not bound by any quantifier, lambda abstraction, or other binding construct within that expression.
A variable occurrence is free if it refers to a value from an enclosing context rather than being locally bound within the expression.
Examples
In the expression :
- is bound by the lambda abstraction
- is free (not bound within this expression)
In the expression :
- is bound by the universal quantifier
- is free
In the expression :
- Both and are free (no binding constructs present)
Formal Definition
The set of free variables of an expression can be defined inductively:
- for a variable
Closed Expressions
An expression with no free variables is called closed or a combinator. Closed expressions are self-contained and do not depend on any external context.
Substitution
Free variables are the targets of substitution. When substituting for in expression , written , only the free occurrences of in are replaced.
Care must be taken to avoid variable capture, where substitution would incorrectly bind a free variable.
Related Concepts
- Bound Variable: The dual concept, variables bound by quantifiers or abstractions
- Expression: The context in which variables appear
- Lambda Calculus: A formal system with explicit variable binding
- Substitution: The operation that replaces free variables
- Scope: The region where a variable binding is active