comp.lang.ada
 help / color / mirror / Atom feed
* What is the history behind Natural'First = 0 ?
@ 2020-05-01  4:51 reinert
  2020-05-01  7:52 ` J-P. Rosen
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: reinert @ 2020-05-01  4:51 UTC (permalink / raw)


I have been wondering about this for years:

Why Natural'First = 0 ?

There is no consensus about including 0 among the natural numbers.
Since there is a Positive (Positive'First = 1), one may expect Natural'First = 0
Except for this, I find little intuition in "Natural'First = 0".


Copy form: https://en.wikipedia.org/wiki/Natural_number#History

Some definitions, including the standard ISO 80000-2,[1][2] begin the natural numbers with 0, corresponding to the non-negative integers 0, 1, 2, 3, …, whereas others start with 1, corresponding to the positive integers 1, 2, 3, …,[3][4] while others acknowledge both definitions.[5] Texts that exclude zero from the natural numbers sometimes refer to the natural numbers together with zero as the whole numbers, but in other writings, that term is used instead for the integers (including negative integers).[6]

Is the key point here: "the standard ISO 80000-2" ?

reinert

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-01  4:51 What is the history behind Natural'First = 0 ? reinert
@ 2020-05-01  7:52 ` J-P. Rosen
  2020-05-01  8:38   ` AdaMagica
  2020-05-01 19:03   ` Keith Thompson
  2020-05-01 10:13 ` Jeffrey R. Carter
  2020-05-01 18:14 ` Optikos
  2 siblings, 2 replies; 12+ messages in thread
From: J-P. Rosen @ 2020-05-01  7:52 UTC (permalink / raw)


Le 01/05/2020 à 06:51, reinert a écrit :
> Why Natural'First = 0 ?
> 
Because that's the way it is  ;-)

Anyway, type Integer is not the mathematical notion of (infinite)
integers, and more generaly computer types are only reduced abstractions
of mathematical notions.

There is a need for a subtype of type Integer with lower bound 0, and
another one for lower bound 1. The names have been chosen by Ichbiah
following usual practice, they could have been anything else.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-01  7:52 ` J-P. Rosen
@ 2020-05-01  8:38   ` AdaMagica
  2020-05-01 10:24     ` J-P. Rosen
  2020-05-01 19:03   ` Keith Thompson
  1 sibling, 1 reply; 12+ messages in thread
From: AdaMagica @ 2020-05-01  8:38 UTC (permalink / raw)


Am Freitag, 1. Mai 2020 09:52:05 UTC+2 schrieb J-P. Rosen:
> Le 01/05/2020 à 06:51, reinert a écrit :
> > Why Natural'First = 0 ?
> > 
> Because that's the way it is  ;-)
> 
> Anyway, type Integer is not the mathematical notion of (infinite)
> integers, and more generaly computer types are only reduced abstractions
> of mathematical notions.

Being a wiseacre, I'd like to point out out RM 3.5.4(8):
The set of values for a signed integer type is the (infinite) set of mathematical integers[, though only values of the base range of the type are fully supported for run-time operations].

> There is a need for a subtype of type Integer with lower bound 0, and
> another one for lower bound 1. The names have been chosen by Ichbiah
> following usual practice, they could have been anything else.

Yes, could have been Natural and Natural_0. I find Ichbiah's choice optimal.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-01  4:51 What is the history behind Natural'First = 0 ? reinert
  2020-05-01  7:52 ` J-P. Rosen
@ 2020-05-01 10:13 ` Jeffrey R. Carter
  2020-05-01 18:14 ` Optikos
  2 siblings, 0 replies; 12+ messages in thread
From: Jeffrey R. Carter @ 2020-05-01 10:13 UTC (permalink / raw)


On 5/1/20 6:51 AM, reinert wrote:
> 
> There is no consensus about including 0 among the natural numbers.

Precisely, so Ichbiah was free to use Natural for whichever definition he 
considered best. There was a need for subtypes with lower bounds of 0 and 1, and 
those subtypes needed names, and Ichbiah chose Natural and Positive for them. 
This seems like a good choice; if Natural is used for the latter, I cannot think 
of a decent name for the former (Non_Negative? Natural_Plus_Zero?). Given the 
obvious alternative name Positive for the subtype beginning with 1, it seems 
pragmatic to use Natural for the subtype beginning with 0.

IIRC, Natural and Positive existed in Ada 80.

> Is the key point here: "the standard ISO 80000-2" ?

I doubt it, since that standard didn't exist in 1980.

-- 
Jeff Carter
"Why, the Mayflower was full of Fireflies, and a few
horseflies, too. The Fireflies were on the upper deck,
and the horseflies were on the Fireflies."
Duck Soup
95

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-01  8:38   ` AdaMagica
@ 2020-05-01 10:24     ` J-P. Rosen
  0 siblings, 0 replies; 12+ messages in thread
From: J-P. Rosen @ 2020-05-01 10:24 UTC (permalink / raw)


Le 01/05/2020 à 10:38, AdaMagica a écrit :
>> Anyway, type Integer is not the mathematical notion of (infinite) 
>> integers, and more generaly computer types are only reduced
>> abstractions of mathematical notions.
> Being a wiseacre, I'd like to point out out RM 3.5.4(8): The set of
> values for a signed integer type is the (infinite) set of
> mathematical integers[, though only values of the base range of the
> type are fully supported for run-time operations].
> 
Yes, but being even more pedantic, let me point out that Integer is not
a type, it is a first named subtype.

The type is purely conceptual in Ada (wasn't like this in Ada83)

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-01  4:51 What is the history behind Natural'First = 0 ? reinert
  2020-05-01  7:52 ` J-P. Rosen
  2020-05-01 10:13 ` Jeffrey R. Carter
@ 2020-05-01 18:14 ` Optikos
  2 siblings, 0 replies; 12+ messages in thread
From: Optikos @ 2020-05-01 18:14 UTC (permalink / raw)


On Thursday, April 30, 2020 at 11:51:09 PM UTC-5, reinert wrote:
> I have been wondering about this for years:
> 
> Why Natural'First = 0 ?
> 
> There is no consensus about including 0 among the natural numbers.
> Since there is a Positive (Positive'First = 1), one may expect Natural'First = 0
> Except for this, I find little intuition in "Natural'First = 0".
> 
> 
> Copy form: https://en.wikipedia.org/wiki/Natural_number#History
> 
> Some definitions, including the standard ISO 80000-2,[1][2] begin the natural numbers with 0, corresponding to the non-negative integers 0, 1, 2, 3, …, whereas others start with 1, corresponding to the positive integers 1, 2, 3, …,[3][4] while others acknowledge both definitions.[5] Texts that exclude zero from the natural numbers sometimes refer to the natural numbers together with zero as the whole numbers, but in other writings, that term is used instead for the integers (including negative integers).[6]
> 
> Is the key point here: "the standard ISO 80000-2" ?
> 
> reinert

The key here is that there has always been a terminology divide between North America and Europe (with UK & Canada sometimes going a 3rd way along British-Empire lines).

Generally, in the USA, the set of natural numbers is the set of positive integers, that is denoted ℕ domestically or ℕ* when interacting with people outside of the USA to show the lack of zero.  Generally, in the USA, the set of whole numbers is the set of positive integers, that is denoted either ℕ₀ or ℤ⁺.

Conversely, generally in UK and Europe, the set of natural numbers is the set of nonnegative integers, which is denoted ℤ-⁺.  (The dispute even goes that far:  having different double-struck/white Z mnemonic notation: ℤ⁺ versus ℤ-⁺.)  Generally in UK and Europe, the set of counting numbers was formerly the set of positive integers, but the further away from the 19th century we get, whole numbers has at times become synonymous with the UK/European definition of natural numbers.

https://mathworld.wolfram.com/NaturalNumber.html

https://mathworld.wolfram.com/NonnegativeInteger.html

https://mathworld.wolfram.com/CountingNumber.html

https://en.wikipedia.org/wiki/Natural_number

Ichbiah showed his European culture by institutionalizing the European definition as the sole normative definition in Ada.  (And don't even get me started on billion, trillion, and milliard.)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-01  7:52 ` J-P. Rosen
  2020-05-01  8:38   ` AdaMagica
@ 2020-05-01 19:03   ` Keith Thompson
  2020-05-01 21:36     ` Robert A Duff
  1 sibling, 1 reply; 12+ messages in thread
From: Keith Thompson @ 2020-05-01 19:03 UTC (permalink / raw)


"J-P. Rosen" <rosen@adalog.fr> writes:
> Le 01/05/2020 à 06:51, reinert a écrit :
>> Why Natural'First = 0 ?
>> 
> Because that's the way it is  ;-)
>
> Anyway, type Integer is not the mathematical notion of (infinite)
> integers, and more generaly computer types are only reduced abstractions
> of mathematical notions.
>
> There is a need for a subtype of type Integer with lower bound 0, and
> another one for lower bound 1. The names have been chosen by Ichbiah
> following usual practice, they could have been anything else.

When I was learning about sets of numbers in elementary school, we
were told that the natural numbers are positive integers and the
whole numbers are non-negative integers (including 0).  Based on
that, if I had been designing the language I probably would have used
the name Natural for 1..Integer'Last and Whole for 0..Integer'Last.

On the other hand, the word "Whole" sounds like "Hole" (at least
in my version of non-accented American English), so I can see that
being awkward in some contexts.

Wikipedia says that some definitions have "natural numbers" starting
with 0, and others have them starting with 1 -- and the term "whole
numbers" is sometimes used to refer to the set of all integers.

It's ultimately arbitrary.  I found the use of Natural in Ada
slightly jarring the first time I encountered it, but I have no
complaints.  And the name Positive seems entirely reasonable.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-01 19:03   ` Keith Thompson
@ 2020-05-01 21:36     ` Robert A Duff
  2020-05-03 20:08       ` Keith Thompson
  0 siblings, 1 reply; 12+ messages in thread
From: Robert A Duff @ 2020-05-01 21:36 UTC (permalink / raw)


Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Wikipedia says that some definitions have "natural numbers" starting
> with 0, and others have them starting with 1 -- and the term "whole
> numbers" is sometimes used to refer to the set of all integers.

"The nice thing about standards is that there are so many to choose from."

I seem to recall an early version of Ada (or Green) that said
"subtype Natural is Integer range 1..Integer'Last;".  I could
be misremembering that, and (if true) I don't remember what the
0..Integer'Last one was called.

Speaking of zero:

Q: What caused the fall of the Roman Empire?
A: They didn't know about zero, so they had no way to terminate
the strings in their C programs.  Har, har.

- Bob

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-01 21:36     ` Robert A Duff
@ 2020-05-03 20:08       ` Keith Thompson
  2020-05-04  3:02         ` Keith Thompson
  0 siblings, 1 reply; 12+ messages in thread
From: Keith Thompson @ 2020-05-03 20:08 UTC (permalink / raw)


Robert A Duff <bobduff@TheWorld.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Wikipedia says that some definitions have "natural numbers" starting
>> with 0, and others have them starting with 1 -- and the term "whole
>> numbers" is sometimes used to refer to the set of all integers.
>
> "The nice thing about standards is that there are so many to choose from."
>
> I seem to recall an early version of Ada (or Green) that said
> "subtype Natural is Integer range 1..Integer'Last;".  I could
> be misremembering that, and (if true) I don't remember what the
> 0..Integer'Last one was called.

Yes, I remember that.  I found a copy of the 1979 Preliminary Ada
Reference Manual from SIGPLAN Notices, June 1979 at

    https://dl.acm.org/doi/pdf/10.1145/956650.956651

The section covering package STANDARD says:

    subtype NATURAL is INTEGER range 1 .. INTEGER'LAST;
    type STRING is array (NATURAL) of CHARACTER;

There was no predefined subtype starting at 0.  I don't know just when
NATURAL was changed to start at 1 and POSITIVE was introduced.

(And I'm glad they decided to stop using ALL_CAPS for identifiers).

> Speaking of zero:
>
> Q: What caused the fall of the Roman Empire?
> A: They didn't know about zero, so they had no way to terminate
> the strings in their C programs.  Har, har.

But it wasn't all that bad, since they only had 100 programs.

A Centurion walks into a bar.  He holds up two fingers.  "Five beers, please."

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-03 20:08       ` Keith Thompson
@ 2020-05-04  3:02         ` Keith Thompson
  2020-05-04  8:50           ` Paul Rubin
  2020-05-04 14:22           ` Dennis Lee Bieber
  0 siblings, 2 replies; 12+ messages in thread
From: Keith Thompson @ 2020-05-04  3:02 UTC (permalink / raw)


Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Robert A Duff <bobduff@TheWorld.com> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Wikipedia says that some definitions have "natural numbers" starting
>>> with 0, and others have them starting with 1 -- and the term "whole
>>> numbers" is sometimes used to refer to the set of all integers.
>>
>> "The nice thing about standards is that there are so many to choose from."
>>
>> I seem to recall an early version of Ada (or Green) that said
>> "subtype Natural is Integer range 1..Integer'Last;".  I could
>> be misremembering that, and (if true) I don't remember what the
>> 0..Integer'Last one was called.
>
> Yes, I remember that.  I found a copy of the 1979 Preliminary Ada
> Reference Manual from SIGPLAN Notices, June 1979 at
>
>     https://dl.acm.org/doi/pdf/10.1145/956650.956651
>
> The section covering package STANDARD says:
>
>     subtype NATURAL is INTEGER range 1 .. INTEGER'LAST;
>     type STRING is array (NATURAL) of CHARACTER;
>
> There was no predefined subtype starting at 0.  I don't know just when
> NATURAL was changed to start at 1 and POSITIVE was introduced.
>
> (And I'm glad they decided to stop using ALL_CAPS for identifiers).

The 1980 edition had the same thing.  I know there was another
preliminary version in 1982 (before the first official standard in
1983), but I don't know what it said.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-04  3:02         ` Keith Thompson
@ 2020-05-04  8:50           ` Paul Rubin
  2020-05-04 14:22           ` Dennis Lee Bieber
  1 sibling, 0 replies; 12+ messages in thread
From: Paul Rubin @ 2020-05-04  8:50 UTC (permalink / raw)


Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> The 1980 edition had the same thing.  I know there was another
> preliminary version in 1982 (before the first official standard in
> 1983), but I don't know what it said.

In math nowadays, "natural numbers" and ordinals are generally
considered to begin with 0 rather than 1.  I think that reflects a
cultural change that might have been taking place around the 1980s.
There is some discussion here:

https://en.wikipedia.org/wiki/Natural_number#Modern_definitions

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: What is the history behind Natural'First = 0 ?
  2020-05-04  3:02         ` Keith Thompson
  2020-05-04  8:50           ` Paul Rubin
@ 2020-05-04 14:22           ` Dennis Lee Bieber
  1 sibling, 0 replies; 12+ messages in thread
From: Dennis Lee Bieber @ 2020-05-04 14:22 UTC (permalink / raw)


On Sun, 03 May 2020 20:02:22 -0700, Keith Thompson
<Keith.S.Thompson+u@gmail.com> declaimed the following:


>The 1980 edition had the same thing.  I know there was another
>preliminary version in 1982 (before the first official standard in
>1983), but I don't know what it said.

	What is your definition of "official standard"? MIL-STD-1815 and 1815A
/are/ official standards -- just not international standards.

	ANSI/MIL-STD-1815A (dated 22 Jan 1983, approved 17 Feb 1983
"superseding MIL-STD-1815 10 Dec 1980") has the 0-based NATURAL and 1-based
POSITIVE.


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-05-04 14:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01  4:51 What is the history behind Natural'First = 0 ? reinert
2020-05-01  7:52 ` J-P. Rosen
2020-05-01  8:38   ` AdaMagica
2020-05-01 10:24     ` J-P. Rosen
2020-05-01 19:03   ` Keith Thompson
2020-05-01 21:36     ` Robert A Duff
2020-05-03 20:08       ` Keith Thompson
2020-05-04  3:02         ` Keith Thompson
2020-05-04  8:50           ` Paul Rubin
2020-05-04 14:22           ` Dennis Lee Bieber
2020-05-01 10:13 ` Jeffrey R. Carter
2020-05-01 18:14 ` Optikos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox