In the previous chapter we ran into an important problem that arises during substitution. Here we look more closely at how to solve it.
α-conversion
The name of a bound variable is no more than a label: and are one and the same function.
The especially gifted folks skip the renaming hassle altogether and use de Bruijn indices: the lambdas themselves stay but become nameless, while every occurrence of a variable is written as a number — how many lambdas you must go up from it to reach its binder (counting from zero, being the nearest enclosing lambda). Then α-equivalent terms get one and the same representation, and α-conversion disappears as a concept.
- → (the only variable points to its own lambda);
- → ( became , and became ).
η-conversion
This is really a small thing, but still worth a brief mention. η-conversion says that the “wrapper” is no different from itself.
η-reduction collapses such a wrapper to the left, while η-expansion unfolds it to the right.
In Haskell this is the familiar point-free style:
sum xs = foldr (+) 0 xs
-- becomes
sum = foldr (+) 0