Definition
De Bruijn indices provide a notation for the syntax of the -calculus where variable names are replaced by natural numbers. Each index represents the number of binders () between the variable occurrence and its corresponding binder.
Structure
In this formalization, a -term is defined by the following grammar:
where is an index. An index refers to the innermost enclosing , while an index refers to the binder that binds the index in the enclosing scope.
Examples
The following table shows the translation from named terms to De Bruijn terms:
| Named Term | De Bruijn Term |
|---|---|
Properties
- Canonical Representation: Terms that are -equivalent in named notation have identical De Bruijn representations. This eliminates the need for -conversion during computation.
- Substitution: Implementing -reduction requires a shifting operation. When a term is moved under a binder or a binder is removed, free indices within that term must be incremented or decremented to maintain their original references.
- Implementation: They are widely used in proof assistants like Coq or Agda and in compiler backends to simplify scope management and equality checking.
References
- De Bruijn, N. G. (1972). Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Mathematicae.
- Pierce, B. C. (2002). Types and Programming Languages. MIT Press.
Would you like me to provide the Agda implementation for the lifting and substitution operations on these indices?