One way to explain what natural numbers are is to do define
I want to implement them using Haskell Lists like this:
1 2 3 4 5 |
|
To do so, I write the following program:
1 2 |
|
What can I do to fix this program?
Inspired by Peano Axioms
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The problem with this function is that there is no way to properly type it. Let me explain what I mean by that with some smaller values.
Suppose the function
peano
works only upto 1, in which case, it could be defined like this:But then again,
peano 2
is[[], [[]]]
is not really of type[[t]]
. It contains elements of type[[t]]
. This means, it must be of the type[[[t]]]
. In which case, we could definepeano
this way:But there is no way can define this to be infinitely nested, which is why we can never specify a function that works for all natural numbers.