This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Free variables and bound variables" – news ·newspapers ·books ·scholar ·JSTOR(December 2008) (Learn how and when to remove this message) |
Inmathematics, and in other disciplines involvingformal languages, includingmathematical logic andcomputer science, a variable may be said to be either free or bound. Some older books use the termsreal variable andapparent variable forfree variable andbound variable, respectively. Afree variable is anotation (symbol) that specifies places in anexpression wheresubstitution may take place and is not a parameter of this or any container expression. The idea is related to aplaceholder (asymbol that will later be replaced by some value), or awildcard character that stands for an unspecified symbol.
Incomputer programming, the term free variable refers tovariables used in afunction that are neitherlocal variables norparameters of that function. The termnon-local variable is often a synonym in this context.
An instance of a variable symbol isbound, in contrast, if the value of that variable symbol has been bound to a specific value or range of values in thedomain of discourse oruniverse. This may be achieved through the use of logical quantifiers, variable-binding operators, or an explicit statement of allowed values for the variable (such as, "...where is a positive integer".) A variable symbol overall isbound if at least one occurrence of it is bound.[1] Since the same variable symbol may appear in multiple places in an expression, some occurrences of the variable symbol may be free while others are bound,[1]: 78 hence "free" and "bound" are at first defined for occurrences and then generalized over all occurrences of said variable symbol in the expression. However it is done, the variable ceases to be an independent variable on which the value of the expression depends, whether that value be a truth value or the numerical result of a calculation, or, more generally, an element of animage set of a function.
While the domain of discourse in many contexts is understood, when an explicit range of values for the bound variable has not been given, it may be necessary to specify the domain in order to properly evaluate the expression. For example, consider the following expression in which both variables are bound by logical quantifiers:
This expression evaluates tofalse if thedomain of and is thereal numbers, buttrue if the domain is thecomplex numbers.
The term "dummy variable" is also sometimes used for a bound variable (more commonly in general mathematics than in computer science), but this should not be confused with the identically named but unrelated concept ofdummy variable as used in statistics, most commonly inregression analysis.[2]p.17
Before stating a precise definition of free variable and bound variable, the following are some examples that perhaps make these two concepts clearer than the definition would:
In a broader context, bound variables are fundamental to the structure ofmathematical proofs. For example, the following proof shows that the square of any positive eveninteger is divisible by 4:
Let be an arbitrary positive even integer. By definition, there exists an integer such that. Substituting this into the expression for the square gives. Since is an integer, is also an integer. Therefore, is divisible by 4.
In this proof, both and function as bound variables, but they are bound in different ways.[3]
The variable is introduced as anarbitrary but particular element of a set. The statement "Let be..." implicitly functions as auniversal quantifier, binding for the scope of the proof. The proof establishes a property for this single, arbitrary, which licenses the general conclusion that the property holds for all positive even integers.[4]
The variable, on the other hand, is bound by anexistential quantifier ("there exists an integer"). It is introduced to represent a specific, though unnamed, integer whose existence is guaranteed by the definition of being even. The scope of is limited to the reasoning that follows its introduction.[5]
Thus, neither variable is free; their meaning is entirely determined by their role within the logical structure of the proof.
Inmathematics andlogic, a number of symbols function asvariable-binding operators. These operators take afunction or an open formula as an argument and bind a free variable within that expression to a specificdomain or range of values, creating a new expression whose meaning does not depend on the bound variable.[6]
Common variable-binding operators include:
In each case, the variablex is bound within the expression that follows the operator (e.g., or). Many of these operators act on a function of the bound variable. While standard notation is often sufficient, complex expressions withnested operators can become ambiguous, particularly if the same variable name is reused. This can lead to a problem known asvariable capture, where a variable intended to be free is incorrectly bound by an operator in a different scope.[7]
To avoid such ambiguity, it can be useful to switch to a notation that makes the binding explicit, treating the operators ashigher-order functions. This approach, rooted in the principles oflambda calculus, clearly separates the function being operated on from the operator itself.[8]
For example:
Here, the operator applies to the setS and the functionf.
This notation clarifies that the operator is applied to the entire function, rather than just an expression in which happens to be a variable.

Variable-binding mechanisms occur in different contexts in mathematics, logic and computer science. In all cases, however, they are purelysyntactic properties of expressions and variables in them. For this section we can summarize syntax by identifying an expression with atree whose leaf nodes are variables, constants, function constants or predicate constants and whose non-leaf nodes are logical operators. This expression can then be determined by doing anin-order traversal of the tree. Variable-binding operators arelogical operators that occur in almost every formal language. A binding operator takes two arguments: a variable and an expression, and when applied to its arguments produces a new expression. The meaning of binding operators is supplied by thesemantics of the language and does not concern us here.
Variable binding relates three things: a variable, a location for that variable in an expression and a non-leaf node of the form. It worth noting that we define a location in an expression as a leaf node in the syntax tree. Variable binding occurs when that location is below the node.
In thelambda calculus,x is a bound variable in the termM = λx. T and a free variable in the termT. We sayx is bound inM and free inT. IfT contains a subtermλx. U thenx is rebound in this term. This nested, inner binding ofx is said to "shadow" the outer binding. Occurrences ofx inU are free occurrences of the newx.[9]
Variables bound at the top level of a program are technically free variables within the terms to which they are bound but are often treated specially because they can be compiled as fixed addresses. Similarly, an identifier bound to arecursive function is also technically a free variable within its own body but is treated specially.
Aclosed term is one containing no free variables.
A clear example of a variable-binding operator from mathematics isfunction definition. An expression that defines a function, such as the right-hand side of:
binds the variables. The expression, which forms the body of the function, may contain some, all, or none of the variables, which are its formal parameters. Any occurrence of these variables within is bound by the function definition. The body may also contain other variables, which would be considered free variables whose values must be determined from a wider context.[6]
The expression is directly analogous to lambda expressions inlambda calculus, where the symbol is the fundamental variable-binding operator. For instance, the function definition is equivalent to the lambda abstraction.[8]
The same definition, binding the function being defined to the name, is more commonly written in mathematical texts in the form
Other mathematical operators can be understood ashigher-order functions that bind variables. For example, thesummation operator,, can be analyzed as an operator that takes a function and a set to evaluate that function over. The expression:
binds the variablex within the term. The scope of the binding is the term that follows the summation symbol. This expression can be treated as a more compact notation for:
Here, is an operator with two parameters: a one-parameter function (in this case,) and a set to evaluate that function over.
Other operators can be expressed in a similar manner. Theuniversal quantifier can be understood as an operator that evaluates to thelogical conjunction of theBoolean-valued function applied to each element in the (possibly infinite) set. Likewise, theproduct operator (), thelimit operator (), and theintegral operator () all function as variable binders, binding the variables and respectively over a specified domain.[10]
When analyzed through the lens offormal semantics,natural languages exhibit a system of variable binding that is analogous to what is found informal logic andcomputer science.[11] This system governs how referring expressions, particularlypronouns, are interpreted within a sentence or discourse.[12]
In English,personal pronouns such ashe,she,they, and their variants (e.g.,her,him) can function asfree variables.[13] A free variable is a term whosereferent is not determined within the immediate syntactic structure of the sentence and must be identified by the broader context, which can be either linguistic or situational (pragmatic).[14]
Consider the following sentence:
Lisa found her book.
Thepossessive pronounher is a free variable. Its interpretation is flexible; it can refer toLisa, an entity within the sentence, or to some other female individual salient in the context of the utterance.[12] This ambiguity leads to two primary interpretations, which can be formally represented using co-indexing subscripts.[15] An identical subscript indicatescoreference, while different subscripts signal that the expressions refer to different entities.
This distinction is not merely a theoretical exercise. Some languages have distinct pronominal forms to differentiate between these two readings. For example,Norwegian andSwedish use the reflexive possessivesin for the coreferential reading (heri) and a non-reflexive form likehennes (in Swedish) for the non-coreferential reading (herj).[16]
While English does not have this explicit distinction in its standard pronouns, it can force a coreferential reading by using the emphatic possessiveown.[17]
In contrast to personal pronouns,reflexive pronouns (e.g.,himself,herself,themselves) andreciprocal pronouns (e.g.,each other) act asbound variables, also known in linguistics asanaphors.[15] A bound variable is an expression that must be co-indexed with, andc-commanded by, an antecedent within a specific syntactic domain.[15]
Consider the sentence:
Jane hurt herself.
The reflexive pronounherself must refer to the subject of the clause,Jane. It cannot refer to any other individual.[12] This obligatory coreference is a hallmark of a bound variable.
This binding relationship can be formally captured using a lambda expression, a tool fromlambda calculus used in formal semantics to model function abstraction and application.[18] The sentence can be represented as:
(λx.x hurt x)(Jane)In this notation:
λx is the lambda operator that binds the variablex.x hurt x is thepredicate, a function that takes an argument and states that this argument hurt itself.(Jane) is the argument applied to the function.The expression evaluates to "Jane hurt Jane," correctly capturing the fact that the subject and object of the verb are the same entity.[18]
The distinct behavior of pronouns and anaphors is systematically explained by thebinding theory, a central component of Noam Chomsky'sGovernment and Binding Theory.[15] This theory proposes three principles that govern the interpretation of different types ofnoun phrases:
The concept of variable binding is essential for understandingquantificationalnoun phrases (QNPs), such asevery student,some politician, orno one.[18] Unlike proper names, these phrases do not refer to a specific entity. Instead, they express a quantity over a set of individuals.[18] A QNP can bind a pronoun that falls within itsscope, making the pronoun a bound variable.
Every studenti thinks hei is smart.
In this sentence, the pronounhe is most naturally interpreted as a bound variable.[21] Its reference co-varies with the individuals in the set denoted by "every student". The sentence does not mean that every student thinks a specific person (e.g., Peter) is smart; rather, it means that for each individual student, thinks that is smart. In syntactic theories, this is often analyzed via a process ofquantifier raising (QR), where the QNP moves at the abstract syntactic level oflogical form to a position where it c-commands and binds the pronoun.[21]
Variable binding is also central to the analysis ofwh-movement, which occurs in the formation of questions andrelative clauses.[22]Wh-words likewho,what, andwhich function as operators that bind a variable in the main clause.[23]
In these structures, thewh-word is said to move from an underlying position, leaving behind a "trace", which is treated as a bound variable.[15] The meaning of the question can be paraphrased as "For which person, does John like?".[18] Similarly, the relative clause denotes a set of individuals such that "Mary saw".[18]
The distinction between free and bound variables provides a powerful explanation for certain ambiguities that arise underVP-ellipsis.[24][25] Consider the following sentence:
John loves his mother, and Bill does too.
This sentence has two distinct interpretations:
This ambiguity can be explained by the status of the pronounhis in the first clause.[19]
λx.x loves x's mother. When this property is applied to Bill, the result is thesloppy reading.[19]The existence of the sloppy identity reading is considered strong evidence for the psychological reality of bound variable interpretations in thegrammar ofnatural languages.[26]
Thus, the distribution and interpretation of pronouns and other referring expressions in natural languages are not random but are governed by a sophisticated syntactic and semantic system.[12]
The distinction between free and bound variables is a cornerstone of modern linguistic theory, providing the analytical tools necessary to account for coreference, quantification, question formation, and ellipsis.
{{cite journal}}: CS1 maint: DOI inactive as of August 2025 (link)