🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3257

Re: integers and reals

#3257
From: Richard A. O'Keefe
Date: Wed, 20 Apr 1988 01:32
56 lines
3206 bytes
In article <1152@robin.cs.nott.ac.uk>, abc@cs.nott.ac.uk (Andy Cheese) writes:
> My own intuition, having a maths degree, is that integers are real numbers,
> it's just that you can represent integers in a machine in general. But on
> the otherhand i would like to see built-in predicates keep their "usual"
> (QP, SICStus, etc) meanings.

Reminds me of "Dr Science", a radio character who announces
	"I have a PhD in .......... SCIENCE!"

Yes, integers are (isomorphic to a subring of the field of) real numbers.
The trouble is that FLOATING-POINT numbers AREN'T.  If floating-point
numbers behaved like a subfield (or even a subring) of the reals, there
would be no objection to identifying integers and floats.  But when
something as basic as trichotomy fails (that is, there are IEEE values
X, Y such that none of X < Y, X = Y, X > Y is true), the mathmetical
intuition which tells us that integers are like reals tells us that
integers cannot therefore be like things which are NOT like reals!

Issue No 8 of the Logic Programming Newsletter is out, and it contains a
copy of the Formal specification of Prolog, by P. Deransart, and G. Richard,
of INRIA.  This is the BSI/ISO thingy.  Interestingly enough, they rule that

	1.14) is-a-L-constant ( X ) <= L-atom ( X )
	      is-a-L-constant ( X ) <= |N-integer ( X )
	      is-a-L-constant ( X ) <= |R-real ( X )

That is, _every_ integer is to be a valid Prolog constant,
     and _every_ real is to be a valid Prolog constant.

However, section 7 (type testing) says that "there is a _denumerable_
infinity of clauses
	|N-integer ( X )		for all integers X
	|R-real ( X )			for all reals X
" and section 9 (arithmetic operations) rules in 9.1 that the ONLY valid
expressions are ones built out of constants, _+_, _-_, _*_, _/_,
_ mod _, and length(AList).  That's right: there is no unary minus, and
there is no integer division operator, and 'length' can appear in
arithmetic expressions.  Any rate, with this repertoire of arithmetic
operations, there is no way of constructing an irrational number, so
|R-real(X) presumably is intended to read "X is a RATIONAL number"
(which would make sense of the claim that there are denumerably many of
them).  The specification uses an integer->real conversion, but to get
it yourself you have to write e.g. X*1.0, and there is no real->integer
conversion at all.

Myself, I don't see that allowing you to write
	X is length(L)
instead of the shorter version
	length(L, X)
and requiring you to write
	Q is X - (X mod Y)*Y
instead of the shorter version
	Q is X // Y
is any real improvement, but that's a standard for you.  (To be honest,
I have always detested the spelling '//' and would prefer the older
DEC-10 library spelling 'div', but current practice is current practice.)
Technical Details
Message-ID: <886@cresswell.quintus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!lll-winken!lll-tis!mordor!sri-spam!sri-unix!quintus!ok
References: <1152@robin.cs.nott.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!lll-winken!lll-tis!mordor!sri-spam!sri-unix!quintus!ok
From: ok@quintus.UUCP (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: Re: integers and reals
Message-ID: <886@cresswell.quintus.UUCP>
Date: 20 Apr 88 01:32:36 GMT
References: <1152@robin.cs.nott.ac.uk>
Organization: Quintus Computer Systems, Mountain View, CA
Lines: 55