Alright, so Boolean values in LC are encoded as true =: λx.λy.x
and false =: λx.λy.y
. The conditional is ifthenelse =: λp.λa.λb.p a b
.
This means that ifthenelse true foo bar = foo
and iftehelse false foo bar = bar
.
Then we want iszero
, which tests whether a Church numeral is 0. It's iszero =: λn.n (λx.false) true
. If you give it 0, then the function (λx.false)
is iterated 0 times on true
, and the result is true
. If you give it a positive n
, then the function is iterated at least once, and the result is false
.
(Remember that a Church numeral is just function iteration).
Finally, we need the n-1
function, which we call pred
(for predecessor).