Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Church Numerals: how to encode zero in lambda calculus?

I am learning lambda calculus but I cant seem to understand the encoding for the number 0.

how is "function that takes in a function and a second value and applies the function zero times on the argument" a zero? Is there any other way to encode zero? Could anyone here help me encode 0?

like image 269
unj2 Avatar asked Sep 26 '09 19:09

unj2


2 Answers

A "function that takes in a function and a second value and applies the function zero times on the argument" is, of course, not zero. It's an encoding of zero. When you deal with plain lambda calculus, you have to encode numbers (as well as other primitive types) in some way, and there are a few requirements dictated for each of these types. For example, one requirement for natural numbers is to be able to add 1 to a given number, and another is to be able to distinguish zero from bigger numbers (if you want to know more, look for "Peano Arithmetic"). The popular encoding that Dario quoted gives you these two things, and it is also representing an integer N by a function that does something (encoded as the f argument) N times -- which is a kind of a natural way to use naturals.

There are other encodings that are possible -- for example, once you can represent lists, you can represent N as a list of N items. These encodings have their pros and cons, but the one above is by far the most popular one.

like image 79
Eli Barzilay Avatar answered Sep 21 '22 09:09

Eli Barzilay


See wikipedia:

0 ≡ λf.λx. x
1 ≡ λf.λx. f x
2 ≡ λf.λx. f (f x)
3 ≡ λf.λx. f (f (f x))
...
n ≡ λf.λx. fn x
like image 27
Dario Avatar answered Sep 24 '22 09:09

Dario