Definitions

# 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 application is placed next to its corresponding binder in the function instead of after the latter's body.

## Formal definition

Terms ($M, N, ldots$) in the de Bruijn notation are either variables ($v$), or have one of two wagon prefixes. The abstractor wagon, written $\left[v\right]$, corresponds to the usual λ-binder of the λ calculus, and the applicator wagon, written $\left(M\right)$, corresponds to the argument in an application in the λ calculus.

$M,N,... ::= v | \left[v\right];M | \left(M\right);N$

Terms in the traditional syntax can be converted to the de Bruijn notation by defining an inductive function $mathcal\left\{I\right\}$ for which:

begin\left\{align\right\} mathcal\left\{I\right\}\left(v\right) &= v mathcal\left\{I\right\}\left(lambda v. M\right) &= \left[v\right];mathcal\left\{I\right\}\left(M\right) mathcal\left\{I\right\}\left(M;N\right) &= \left(mathcal\left\{I\right\}\left(N\right)\right)mathcal\left\{I\right\}\left(M\right) end\left\{align\right\}

All operations on λ-terms commute with respect to the $mathcal\left\{I\right\}$ translation. For example, the usual β-reduction,

$\left(lambda v. M\right);N longrightarrow_beta M\left[v := N\right]$
in the de Bruijn notation is, predictably,
$\left(N\right);\left[v\right];M longrightarrow_beta M\left[v := N\right]$.

A feature of this notation is that abstractor and applicator wagons of β-redexes are paired like parentheses. For example, consider the stages in the β-reduction of the term $\left(M\right);\left(N\right);\left[u\right];\left(P\right);\left[v\right];\left[w\right];\left(Q\right);z$, where the redexes are underlined:

begin\left\{align\right\} \left(M\right);underline\left\{\left(N\right);\left[u\right]\right\};\left(P\right);\left[v\right];\left[w\right];\left(Q\right);z &\left\{ longrightarrow_beta \right\} \left(M\right);underline\left\{\left(P\left[u:=N\right]\right);\left[v\right]\right\};\left[w\right];\left(Q\left[u:=N\right]\right);z &\left\{ longrightarrow_beta \right\} underline\left\{\left(M\right);\left[w\right]\right\};\left(Q\left[u:=N,v:=P\left[u:=N\right]\right]\right);z &\left\{ longrightarrow_beta \right\}
` (Q[u:=N,v:=P[u:=N],w:=M]);z`
end{align}

Thus, if one views the applicator as an open paren ('`(`') and the abstractor as a close paren ('`)`'), then the pattern in the above term is '`(()())`'. De Bruijn called an applicator and its corresponding abstractor in this interpretation partners, and wagons without partners bachelors. A sequence of wagons, which he called a segment, is well balanced if all its wagons are partnered.

## Advantages of the de Bruijn notation

In a well balanced segment, the partnered wagons may be moved around arbitrarily and, as long as parity is not destroyed, the meaning of the term stays the same. For example, in the above example, the applicator $\left(M\right)$ can be brought to its abstractor $\left[w\right]$, or the abstractor to the applicator. In fact, all commutatives and permutative conversions on lambda terms may be described simply in terms of parity-preserving reorderings of partnered wagons. One thus obtains a generalised conversion primitive for λ-terms in the de Bruijn notation.

Several properties of λ-terms that are difficult to state and prove using the traditional notation are easily expressed in the de Bruijn notation. For example, in a type-theoretic setting, one can easily compute the canonical class of types for a term in a typing context, and restate the type checking problem to one of verifying that the checked type is a member of this class. De Bruijn notation has also been shown to be useful in calculi for explicit substitution in pure type systems.

## References

Search another word or see de bruijn notationon Dictionary | Thesaurus |Spanish