De Bruijn index
   HOME

TheInfoList



OR:

In
mathematical logic Mathematical logic is the study of formal logic within mathematics. Major subareas include model theory, proof theory, set theory, and recursion theory. Research in mathematical logic commonly addresses the mathematical properties of formal ...
, the De Bruijn index is a tool invented by the
Dutch Dutch commonly refers to: * Something of, from, or related to the Netherlands * Dutch people () * Dutch language () Dutch may also refer to: Places * Dutch, West Virginia, a community in the United States * Pennsylvania Dutch Country People E ...
mathematician A mathematician is someone who uses an extensive knowledge of mathematics in their work, typically to solve mathematical problems. Mathematicians are concerned with numbers, data, quantity, structure, space, models, and change. History On ...
Nicolaas Govert de Bruijn Nicolaas Govert (Dick) de Bruijn (; 9 July 1918 – 17 February 2012) was a Dutch mathematician, noted for his many contributions in the fields of analysis, number theory, combinatorics and logic.
for representing terms of lambda calculus without naming the bound variables. Terms written using these indices are invariant with respect to α-conversion, so the check for α-equivalence is the same as that for syntactic equality. Each De Bruijn index is a
natural number In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called ''cardinal ...
that represents an occurrence of a
variable Variable may refer to: * Variable (computer science), a symbolic name associated with a value and whose associated value may be changed * Variable (mathematics), a symbol that represents a quantity in a mathematical expression, as used in many ...
in a λ-term, and denotes the number of binders that are in
scope Scope or scopes may refer to: People with the surname * Jamie Scope (born 1986), English footballer * John T. Scopes (1900–1970), central figure in the Scopes Trial regarding the teaching of evolution Arts, media, and entertainment * Cinem ...
between that occurrence and its corresponding binder. The following are some examples: * The term λ''x''. λ''y''. ''x'', sometimes called the
K combinator Combinatory logic is a notation to eliminate the need for quantified variables in mathematical logic. It was introduced by Moses Schönfinkel and Haskell Curry, and has more recently been used in computer science as a theoretical model of comput ...
, is written as λ λ 2 with De Bruijn indices. The binder for the occurrence ''x'' is the second λ in scope. * The term λ''x''. λ''y''. λ''z''. ''x'' ''z'' (''y'' ''z'') (the S combinator), with De Bruijn indices, is λ λ λ 3 1 (2 1). * The term λ''z''. (λ''y''. ''y'' (λ''x''. ''x'')) (λ''x''. ''z'' ''x'') is λ (λ 1 (λ 1)) (λ 2 1). See the following illustration, where the binders are coloured and the references are shown with arrows. De Bruijn indices are commonly used in higher-order reasoning systems such as automated theorem provers and
logic programming Logic programming is a programming paradigm which is largely based on formal logic. Any program written in a logic programming language is a set of sentences in logical form, expressing facts and rules about some problem domain. Major logic pro ...
systems.


Formal definition

Formally, λ-terms (''M'', ''N'', ...) written using De Bruijn indices have the following syntax (parentheses allowed freely): :''M'', ''N'', ... ::= ''n'' , ''M'' ''N'' , λ ''M'' where ''n''—
natural number In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called ''cardinal ...
s greater than 0—are the variables. A variable ''n'' is
bound Bound or bounds may refer to: Mathematics * Bound variable * Upper and lower bounds, observed limits of mathematical functions Physics * Bound state, a particle that has a tendency to remain localized in one or more regions of space Geography *B ...
if it is in the scope of at least ''n'' binders (λ); otherwise it is free. The binding site for a variable ''n'' is the ''n''th binder it is in the
scope Scope or scopes may refer to: People with the surname * Jamie Scope (born 1986), English footballer * John T. Scopes (1900–1970), central figure in the Scopes Trial regarding the teaching of evolution Arts, media, and entertainment * Cinem ...
of, starting from the innermost binder. The most primitive operation on λ-terms is substitution: replacing free variables in a term with other terms. In the
β-reduction Lambda calculus (also written as ''λ''-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation ...
(λ ''M'') ''N'', for example, we must # find the instances of the variables ''n''1, ''n''2, ..., ''n''k in ''M'' that are bound by the λ in λ ''M'', # decrement the free variables of ''M'' to match the removal of the outer λ-binder, and # replace ''n''1, ''n''2, ..., ''n''k with ''N'', suitably incrementing the free variables occurring in ''N'' each time, to match the number of λ-binders, under which the corresponding variable occurs when ''N'' substitutes for one of the ''ni''. To illustrate, consider the application :(λ λ 4 2 (λ 1 3)) (λ 5 1) which might correspond to the following term written in the usual notation :(λ''x''. λ''y''. ''z'' ''x'' (λ''u''. ''u'' ''x'')) (λ''x''. ''w'' ''x''). After step 1, we obtain the term λ 4 □ (λ 1 □), where the variables that are destined for substitution are replaced with boxes. Step 2 decrements the free variables, giving λ 3 □ (λ 1 □). Finally, in step 3, we replace the boxes with the argument, namely λ 5 1; the first box is under one binder, so we replace it with λ 6 1 (which is λ 5 1 with the free variables increased by 1); the second is under two binders, so we replace it with λ 7 1. The final result is λ 3 (λ 6 1) (λ 1 (λ 7 1)). Formally, a substitution is an unbounded list of terms, written ''M''1.''M''2..., where ''M''''i'' is the replacement for the ''i''th free variable. The increasing operation in step 3 is sometimes called ''shift'' and written ↑''k'' where ''k'' is a natural number indicating the amount to increase the variables, and is defined by :\uparrow^k = (k + 1).(k + 2). ... For example, ↑0 is the identity substitution, leaving a term unchanged. A finite list of terms ''M''1.''M''2...''M''n abbreviates the substitution ''M''1.''M''2...''M''n.(n+1).(n+2)... leaving all variables greater than n unchanged. The application of a substitution ''s'' to a term ''M'' is written ''M'' 's'' The composition of two substitutions ''s''''1'' and ''s''2 is written ''s''1 ''s''2 and is defined by :(''M''1.''M''2...) ''s'' = ''M''1 's''''M''2 's''.. satisfying the property :''M'' 's''1 ''s''2= (''M'' 's''1 's''2 and substitution is defined on terms as follows:
\begin n _1\ldots N_n\ldots=& N_n \\ (M_1\;M_2) =& (M_1 (M_2 \\ (\lambda\;M) =& \lambda\;(M .s'\\ & \text s' = s \uparrow^1 \end
The steps outlined for the β-reduction above are thus more concisely expressed as: :(λ ''M'') ''N'' →β ''M'' 'N''


Alternatives to De Bruijn indices

When using the standard "named" representation of λ-terms, where variables are treated as labels or strings, one must explicitly handle α-conversion when defining any operation on the terms. In practice this is cumbersome, inefficient, and often error-prone. It has therefore led to the search for different representations of such terms. On the other hand, the named representation of λ-terms is more pervasive and can be more immediately understandable by others because the variables can be given descriptive names. Thus, even if a system uses De Bruijn indices internally, it will present a user interface with names. An alternative way to view De Bruijn indices is as De Bruijn levels, which indexes variables from the bottom of the stack rather than from the top. This eliminates the need to reindex free variables, for example when weakening the context, whereas De Bruijn indices eliminate the need to reindex bound variables, for example when substituting a closed expression in another context. De Bruijn indices are not the only representation of λ-terms that obviates the problem of α-conversion. Among named representations, the nominal techniques of Pitts and Gabbay is one approach, where the representation of a λ-term is treated as an equivalence class of all terms rewritable to it using variable permutations. This approach is taken by the Nominal Datatype Package of
Isabelle/HOL The Isabelle automated theorem prover is a higher-order logic (HOL) theorem prover, written in Standard ML and Scala. As an LCF-style theorem prover, it is based on a small logical core (kernel) to increase the trustworthiness of proofs with ...
. Another common alternative is an appeal to higher-order representations where the λ-binder is treated as a true function. In such representations, the issues of α-equivalence, substitution, etc. are identified with the same operations in a
meta-logic Metalogic is the study of the metatheory of logic. Whereas ''logic'' studies how logical systems can be used to construct valid and sound arguments, metalogic studies the properties of logical systems.Harry GenslerIntroduction to Logic Routledge, ...
. When reasoning about the meta-theoretic properties of a deductive system in a
proof assistant In computer science and mathematical logic, a proof assistant or interactive theorem prover is a software tool to assist with the development of formal proofs by human-machine collaboration. This involves some sort of interactive proof editor ...
, it is sometimes desirable to limit oneself to first-order representations and to have the ability to name or rename assumptions. The ''locally nameless approach'' uses a mixed representation of variables—De Bruijn indices for bound variables and names for free variables—that is able to benefit from the α-canonical form of De Bruijn indexed terms when appropriate.


Barendregt's variable convention

Barendregt's variable convention is a convention commonly used in proofs and definitions where it is assumed that: * bound variables are distinct from free variables, and * all binders bind variables not already in scope. In the general context of an inductive definition, it is not possible to apply α-conversion as needed to convert an inductive definition using the convention to one where the convention is not used, because a variable may appear in both a binding position and a non-binding position in the rule. The induction principle holds if every rule satisfies the following two conditions: * the rule is
equivariant In mathematics, equivariance is a form of symmetry for functions from one space with symmetry to another (such as symmetric spaces). A function is said to be an equivariant map when its domain and codomain are acted on by the same symmetry grou ...
in the sense of nominal logic, that is to say that its validity is unchanged by renaming variables * assuming the premises of the rule, the variables in binding positions in the rule are distinct and are free in the conclusion


See also

* The
De Bruijn notation In mathematical logic, the De Bruijn notation is a syntax for terms in the λ calculus invented by the Dutch mathematician Nicolaas Govert de Bruijn. It can be seen as a reversal of the usual syntax for the λ calculus where the argument in an ap ...
for λ-terms. * Combinatory logic, a more essential way to eliminate variable names.


References

{{reflist Lambda calculus