Some Notes On Untyped Lambda Calculus
Some Notes On Untyped Lambda Calculus
Untyped Lambda-Calculus
Abstract grammar of lambda calculus:
lambda-term ::= x
x.lambda-term
lambda-term lambda-term
(variable)
(abstraction)
(abstraction)
4.1
Booleans
Boolean true/false:
tru = t.f.t,
fls = t.f.f.
So, tru is a function taking two parameters and returning the first one; fls is a
function taking two parameters and returning the second one. More operators:
not = f.a.b.f b a,
or = f.g.f tru g,
and = f.g.f g fls .
Helper function to implement if t then x else y:
test = t.x.y.t x y.
When t is tru, test returns x; if it is fls, test returns y.
4.2
Natural Numbers
0N = s.z.z,
1N = s.z.s z,
2N = s.z.s s z,
...
Then,
iN + jN = s.z.s(i) s(j) (z) = s.z.s(i+j) (z) = (i + j)N ,
iN jN = s.z.(s(j) )(i) (z) = s.z.s(ij) (z) = (i j)N .