**[alekk--obywatel--pl]**

# Natural numbers

### [1/7] from: alekk::obywatel::pl at: 4-Jul-2001 21:42

----- Original Message -----
From: "Joel Neely" <

**[joel--neely--fedex--com]**> To: <**[rebol-list--rebol--com]**> Sent: Wednesday, July 04, 2001 11:51 AM Subject: [REBOL] Re: Natural numbers> Hi, Alek,
> Alekk wrote:

<<quoted lines omitted: 17>>

> Peano (1858-1932), the brilliant Italian mathematician and
> logician (...)
I think You have gone to far. ;)
It is not my opinion - natural numbers are with us from very past (fact is
that there was not number 1 in those numbers in greek mathematic). When You
say that natural numbers starts with 0 because one man (i agree - great) in
XX century made axioms about it - it sounds like "there was no world before
1796".
When is 0 or not in natural numbers, is matter of context.
regards
Aleksander K.

### [2/7] from: larry:ecotope at: 4-Jul-2001 13:34

Hi Joel,

> Recognizing 0 as the origin of the natural numbers is both
> explicit in Peano's Axioms, and too fundamentally useful to
> give up. We learned long ago (from negative experience with
> FORTRAN, actually ;-) that requiring a minimum loop count of
> one instead of zero is often entirely too awkward.

Just a few quick comments about indexing of arrays (or REBOL blocks).
1) Some of the recent posts seem to imply there is some intrinsic
mathematical reason which justifies zero-based indexing. These posts seem to
ignore the fact that in the areas of mathematics where arrays, vectors,
matrices, tensors, etc. are widely used, it is almost universal to use
one-based offsets (check any book on linear algebra). So that, e.g., a[1]
is notation for the first element of a vector, a[1,1] is the first element
in the first row of a matrix, etc. So for the purpose of indexing arrays,
mathematicians have always used one-based indexing.
2) In my own view, the whole issue of index base is fairly minor, you can do
it either way. However as a person who has implemented many array-based
mathematics packages in C, I have found the zero-based indexing of C to be
more often a hindrance than a help. There are, however, good reasons for
zero-base offsets when doing system programming that involves things like
pointer arithmetic. After all, C was designed for low-level systems
programming, not for doing mathematics. FORTRAN, on the other hand, was
designed to do scientific numerical computing on arrays and vectors, so the
choice of one-based array indexing was the natural one.
3) There is a thoughtful discussion of the subject in "Numerical Recipes in
C" by Press, et al. Second Edition 1992. It is in Chapter 1 Section 2 under
the heading Vectors and One-Dimensional Arrays p. 18. I would recommend a
careful reading this topic. In all of their C code for matrix/vector
operations they use one-based indexing (having shown a clever way to achieve
this in C). Here are a few quotes from their discussion (forgive my typos):
It is sometimes convenient to use zero-offset vectors, and sometimes
convenient to use unit-offset vectors. ... a vector of data points calls for
a unit-offset.
But suppose that your vector of length 7, now call it a, is perversely a
native C, zero-offset array (has range a[0..6]). Perhaps, this is the case
because you disagree with our aesthetic prejudices, Heaven help you!
We want to free you from the zero-offset thinking that C encourages but (as
we see) does not require.
Cheers
-Larry

### [3/7] from: joel:neely:fedex at: 4-Jul-2001 7:00

Hi again, Alek,
Alekk wrote:

> I think You have gone to far. ;)
> It is not my opinion - natural numbers are with us from very
> past (fact is that there was not number 1 in those numbers
> in greek mathematic). When You say that natural numbers
> starts with 0 because one man (i agree - great) in XX century
>

XIX, actually. (The axioms date from 1891. ;-)

> made axioms about it - it sounds like "there was no world
> before 1796".
> When is 0 or not in natural numbers, is matter of context.
>

As you correctly point out, the ancient Greeks didn't even
consider 1 as a "number". Many of them also believed that
the world was flat, that the sun rode on a chariot, and that
air, earth, fire, and water were the basic physical elements.
It hardly seems fair to restrict our science or mathematics
to what they understood... :-}
Perhaps I didn't express my point sufficiently clearly (if
so I apologize):
"natural number" is a mathematical concept, and the
standard model in mathematics is Peano's axioms.
In the same sense as the statement:
"quark" is a physical concept, and the standard model in
physics (quantumelectrodynamics IIRC) uses that concept.
In neither case do we limit ourselves to the boundaries of
knowledge of the past.
-jn-
------------------------------------------------------------
Programming languages: compact, powerful, simple ...
Pick any two!
joel'dot'neely'at'fedex'dot'com

### [4/7] from: johan:forsberg:6117:student:uu:se at: 5-Jul-2001 3:32

On 04-Jul-01, Joel Neely wrote:

> "quark" is a physical concept, and the standard model in
> physics (quantumelectrodynamics IIRC) uses that concept.

A *completely* off-topic note: I think it's quantum cromodynamics
(QCD) you're after :)
--
Johan Forsberg

### [5/7] from: joel:neely:fedex at: 4-Jul-2001 13:42

Hi, Larry,
I guess the short version is this: if we're allowed to use
zero, we don't have to; if we're forbidden to use zero, then
we can't. The first sounds more permissive an option to me.
Larry Palmiter wrote:

> Hi Joel,
> > Recognizing 0 as the origin of the natural numbers is both

<<quoted lines omitted: 7>>

> intrinsic mathematical reason which justifies zero-based
> indexing.
There are intrinsic mathematical and performance reasons
which justify zero-based indexing for many non-numerical
(e.g. combinatorial and statistical) applications.

> These posts seem to ignore the fact that in the
> areas of mathematics where arrays, vectors, matrices,
> tensors, etc. are widely used...
>

I don't ignore those; it's simply that if one has zero-based
indexing, one always has the option of ignoring position
0 and treating the remainder as 1-origin if the logic of the
algorithm inherently calls for a 1-based view.
In contrast, if one only has 1-origin indexing, there is no
way to achieve a similar conversion to 0-based design. One
is forced to do surplus index manipulation.

> 2) In my own view, the whole issue of index base is fairly
> minor, you can do it either way.
>

Provided one's language ALLOWS one to do it either way...

> ... There are, however, good reasons for zero-base offsets
> when doing system programming that involves things like
> pointer arithmetic.
>

As stated above, and illustrated (at least I intended so)
by many examples I've used previously in this thread, there
are also good reasons for 0-based indexing when doing other
kinds of algorithms as well. This is not merely a "systems"
programming vs. "applications" programming issue.

> "It is sometimes convenient to use zero-offset vectors, and
> sometimes convenient to use unit-offset vectors. ... a vector
> of data points calls for a unit-offset."
>

They are entitled to their own views. However, as someone
who has implemented lots of different classes of applications
(including language translation/interpretation, payroll, data
conversion, mailing list management, inventory management,
barcode decoding and printing, sales and commissions accounting,
artificial intelligence, neural networks, numerical analysis,
systems utilities, device drivers, text processing for pre-press
formatting, web application development, statistical processing
and reporting, education management, grades processing and
reporting, student records, manufacturing accounting and
production planning, and document management) in lots of different
languages (including Algol, FORTRAN, COBOL, RPG,
several dialects of Basic, various assemblers, NewtonScript,
LISP, TLWMNBN, Perl, SNOBOL, xBase, Java, a few incarnations
of FORTH, and last -- but certainly not least -- REBOL), I can
only say that I've experienced far fewer difficulties caused by
0-based indexing than by 1-based indexing.

> "We want to free you from the zero-offset thinking that C
> encourages but (as we see) does not require."
>

I wish I could free us from the 1-origin thinking that REBOL
both encourages and requires.
(However, I see another windmill that needs tilting... ;-)
-jn-
------------------------------------------------------------
Programming languages: compact, powerful, simple ...
Pick any two!
joel'dot'neely'at'fedex'dot'com

### [6/7] from: alekk:obywatel:pl at: 4-Jul-2001 15:26

[...]

> the series of natural numbers
>
> 0 1 2 3 4 5 ....... infinity
>
> which is the first number? 0 or 1 ?

[...]
But there are two shools -
first - as You said
second - that natural numbers starts from 1...
THEN ANSWER IS:
0 AND 1 are good (from that point of view)
greets
Aleksander K.

**[alekk--obywatel--pl]**### [7/7] from: joel:neely:fedex at: 4-Jul-2001 4:51

Hi, Alek,
Alekk wrote:

> [...]
> > the series of natural numbers

<<quoted lines omitted: 6>>

> first - as You said
> second - that natural numbers starts from 1...
I'm sorry, but this is neither a matter of opinion nor of
popular vote. The standard model in Mathematics is known
as "Peano's Postulates" or "Peano's Axioms", after Giuseppe
Peano (1858-1932), the brilliant Italian mathematician and
logician. The full set of axioms states:
- 0 is a natural number.
- The (unique) successor of any natural number is
a natural number.
- No two numbers have the same successor.
- 0 is not the successor of any number.
- If P is a property over the natural numbers
such that
- P(0) is true, and
- P(n+1) is true whenever P(n) is true
then P is true for all natural numbers.
The last of these, of course, is the principle of mathematical
induction, which has direct application to programming.
Suppose I have some expressions in the following schema
; point 0
while [loop-cond] [
; point n
loop-action
; point n+1
]
; point z
Now, suppose there is some property (of my computation) that
holds at "point 0", and is preserved by LOOP-ACTION -- i.e.,
if it is true at "point n" then it will still be true at
point n+1
. Then, by mathematical induction, I can conclude
that at "point z" I will know that the property still holds
true, and that LOOP-COND is false. The induction, of course,
is over the number of times LOOP-ACTION has been evaluated,
and that count is 0 prior to any evaluations of the loop.
(Corresponding reasoning holds for schemata using other loop
control functions as well.)
Recognizing 0 as the origin of the natural numbers is both
explicit in Peano's Axioms, and too fundamentally useful to
give up. We learned long ago (from negative experience with
FORTRAN, actually ;-) that requiring a minimum loop count of
one instead of zero is often entirely too awkward.
...feeling too loopy to continue ... ;-)
-jn-
------------------------------------------------------------
Programming languages: compact, powerful, simple ...
Pick any two!
joel'dot'neely'at'fedex'dot'com

Notes

- Quoted lines have been omitted from some messages.

View the message alone to see the lines that have been omitted