<s>
In	O
mathematical	O
logic	O
,	O
the	O
De	B-Application
Bruijn	I-Application
index	I-Application
is	O
a	O
tool	O
invented	O
by	O
the	O
Dutch	O
mathematician	O
Nicolaas	O
Govert	O
de	O
Bruijn	O
for	O
representing	O
terms	O
of	O
lambda	B-Language
calculus	I-Language
without	O
naming	O
the	O
bound	O
variables	O
.	O
</s>
<s>
Each	O
De	B-Application
Bruijn	I-Application
index	I-Application
is	O
a	O
natural	O
number	O
that	O
represents	O
an	O
occurrence	O
of	O
a	O
variable	O
in	O
a	O
λ-term	O
,	O
and	O
denotes	O
the	O
number	O
of	O
binders	O
that	O
are	O
in	O
scope	B-Language
between	O
that	O
occurrence	O
and	O
its	O
corresponding	O
binder	O
.	O
</s>
<s>
The	O
term	O
λx	B-Language
.	O
</s>
<s>
λy	B-Language
.	O
</s>
<s>
x	O
,	O
sometimes	O
called	O
the	O
K	O
combinator	B-Application
,	O
is	O
written	O
as	O
λ	O
λ	O
2	O
with	O
De	B-Application
Bruijn	I-Application
indices	I-Application
.	O
</s>
<s>
The	O
binder	O
for	O
the	O
occurrence	O
x	O
is	O
the	O
second	O
λ	O
in	O
scope	B-Language
.	O
</s>
<s>
The	O
term	O
λx	B-Language
.	O
</s>
<s>
λy	B-Language
.	O
</s>
<s>
λz	B-Language
.	O
</s>
<s>
x	O
z	O
(	O
y	O
z	O
)	O
(	O
the	O
S	O
combinator	B-Application
)	O
,	O
with	O
De	B-Application
Bruijn	I-Application
indices	I-Application
,	O
is	O
λ	O
λ	O
λ	O
3	O
1	O
(	O
2	O
1	O
)	O
.	O
</s>
<s>
The	O
term	O
λz	B-Language
.	O
</s>
<s>
( λy	O
.	O
</s>
<s>
y	O
( λx	O
.	O
</s>
<s>
x	O
)	O
)	O
( λx	O
.	O
</s>
<s>
De	B-Application
Bruijn	I-Application
indices	I-Application
are	O
commonly	O
used	O
in	O
higher-order	B-Algorithm
reasoning	O
systems	O
such	O
as	O
automated	B-Application
theorem	I-Application
provers	I-Application
and	O
logic	B-Language
programming	I-Language
systems	O
.	O
</s>
<s>
Formally	O
,	O
λ-terms	B-Language
(	O
M	O
,	O
N	O
,	O
...	O
)	O
written	O
using	O
De	B-Application
Bruijn	I-Application
indices	I-Application
have	O
the	O
following	O
syntax	O
(	O
parentheses	O
allowed	O
freely	O
)	O
:	O
</s>
<s>
A	O
variable	O
n	O
is	O
bound	O
if	O
it	O
is	O
in	O
the	O
scope	B-Language
of	O
at	O
least	O
n	O
binders	O
( λ	O
)	O
;	O
otherwise	O
it	O
is	O
free	O
.	O
</s>
<s>
The	O
binding	O
site	O
for	O
a	O
variable	O
n	O
is	O
the	O
nth	O
binder	O
it	O
is	O
in	O
the	O
scope	B-Language
of	O
,	O
starting	O
from	O
the	O
innermost	O
binder	O
.	O
</s>
<s>
The	O
most	O
primitive	O
operation	O
on	O
λ-terms	B-Language
is	O
substitution	O
:	O
replacing	O
free	O
variables	O
in	O
a	O
term	O
with	O
other	O
terms	O
.	O
</s>
<s>
( λx	O
.	O
</s>
<s>
λy	B-Language
.	O
</s>
<s>
u	O
x	O
)	O
)	O
( λx	O
.	O
</s>
<s>
When	O
using	O
the	O
standard	O
"	O
named	O
"	O
representation	O
of	O
λ-terms	B-Language
,	O
where	O
variables	O
are	O
treated	O
as	O
labels	O
or	O
strings	O
,	O
one	O
must	O
explicitly	O
handle	O
α-conversion	O
when	O
defining	O
any	O
operation	O
on	O
the	O
terms	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
the	O
named	O
representation	O
of	O
λ-terms	B-Language
is	O
more	O
pervasive	O
and	O
can	O
be	O
more	O
immediately	O
understandable	O
by	O
others	O
because	O
the	O
variables	O
can	O
be	O
given	O
descriptive	O
names	O
.	O
</s>
<s>
Thus	O
,	O
even	O
if	O
a	O
system	O
uses	O
De	B-Application
Bruijn	I-Application
indices	I-Application
internally	O
,	O
it	O
will	O
present	O
a	O
user	O
interface	O
with	O
names	O
.	O
</s>
<s>
An	O
alternative	O
way	O
to	O
view	O
De	B-Application
Bruijn	I-Application
indices	I-Application
is	O
as	O
De	O
Bruijn	O
levels	O
,	O
which	O
indexes	O
variables	O
from	O
the	O
bottom	O
of	O
the	O
stack	O
rather	O
than	O
from	O
the	O
top	O
.	O
</s>
<s>
De	B-Application
Bruijn	I-Application
indices	I-Application
are	O
not	O
the	O
only	O
representation	O
of	O
λ-terms	B-Language
that	O
obviates	O
the	O
problem	O
of	O
α-conversion	O
.	O
</s>
<s>
This	O
approach	O
is	O
taken	O
by	O
the	O
Nominal	O
Datatype	O
Package	O
of	O
Isabelle/HOL	B-Application
.	O
</s>
<s>
Another	O
common	O
alternative	O
is	O
an	O
appeal	O
to	O
higher-order	B-Algorithm
representations	O
where	O
the	O
λ-binder	O
is	O
treated	O
as	O
a	O
true	O
function	O
.	O
</s>
<s>
all	O
binders	O
bind	O
variables	O
not	O
already	O
in	O
scope	B-Language
.	O
</s>
