Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

A Linux machine! because a 486 is a terrible thing to waste! (By jjs@wintermute.ucr.edu, Joe Sloan)


devel / comp.lang.prolog / Re: Towards Mixing Floats and Rational Numbers

SubjectAuthor
* Towards Mixing Floats and Rational NumbersMostowski Collapse
`* Re: Towards Mixing Floats and Rational NumbersMostowski Collapse
 `* Re: Towards Mixing Floats and Rational NumbersMostowski Collapse
  `* Re: Towards Mixing Floats and Rational NumbersMostowski Collapse
   `- Re: Towards Mixing Floats and Rational NumbersMostowski Collapse

1
Towards Mixing Floats and Rational Numbers

<12c01edf-5faa-4d4c-bbd9-76c3b44f7f5en@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1905&group=comp.lang.prolog#1905

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:51c6:0:b0:3ab:6e87:db38 with SMTP id d6-20020ac851c6000000b003ab6e87db38mr976459qtn.415.1674392439134;
Sun, 22 Jan 2023 05:00:39 -0800 (PST)
X-Received: by 2002:a05:6830:54d:b0:684:a99a:f22b with SMTP id
l13-20020a056830054d00b00684a99af22bmr1252354otb.270.1674392438848; Sun, 22
Jan 2023 05:00:38 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Sun, 22 Jan 2023 05:00:38 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <12c01edf-5faa-4d4c-bbd9-76c3b44f7f5en@googlegroups.com>
Subject: Towards Mixing Floats and Rational Numbers
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sun, 22 Jan 2023 13:00:39 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 25
 by: Mostowski Collapse - Sun, 22 Jan 2023 13:00 UTC

That mixing floats and rational numbers can be a challenge
recently surfaced for SWI-Prolog, where their floats also
have NaN and Infinity. On the other hand I do not have these

two constants, and my own takes in the form of a simple
library(arithmetic/ratio), that does some overloading of the
existing basic arithmetic operators and comparison,

seems not to be fit at all. If I download an old version
interpreter_1.5.1.jar I get these results:

?- 1229999999999999878 rdiv 123 =:= 1.0E16.
fail.
?- X is (1 rdiv 2)+0.0.
Fehler: Argument sollte Ganzzahl sein, gefunden 1.0.
?- X is (1 rdiv 2)*1.0.
Fehler: Argument sollte Ganzzahl sein, gefunden 1.0.

Such cases were deliberatively left open. But I think these
gaps can be closed towards a ISO core standard backward
compatibility. Keeping in mind that integers are also rational

numbers, and therefore all the coercion of integer to float,
that is already found in the ISO core standard should translate
to a coercion of rational number to float.

Re: Towards Mixing Floats and Rational Numbers

<cd9fd2fc-4c5b-44f7-821e-a85efaecde8cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1906&group=comp.lang.prolog#1906

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a0c:f6d0:0:b0:537:4d8a:d9e2 with SMTP id d16-20020a0cf6d0000000b005374d8ad9e2mr300703qvo.49.1674392882306;
Sun, 22 Jan 2023 05:08:02 -0800 (PST)
X-Received: by 2002:a05:6870:cb93:b0:155:ca1b:3eb1 with SMTP id
ov19-20020a056870cb9300b00155ca1b3eb1mr1303460oab.136.1674392881910; Sun, 22
Jan 2023 05:08:01 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Sun, 22 Jan 2023 05:08:01 -0800 (PST)
In-Reply-To: <12c01edf-5faa-4d4c-bbd9-76c3b44f7f5en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <12c01edf-5faa-4d4c-bbd9-76c3b44f7f5en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cd9fd2fc-4c5b-44f7-821e-a85efaecde8cn@googlegroups.com>
Subject: Re: Towards Mixing Floats and Rational Numbers
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sun, 22 Jan 2023 13:08:02 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Mostowski Collapse - Sun, 22 Jan 2023 13:08 UTC

Here is a prototype of such coercion, already
working for the next release of formerly Jekejeke Prolog.
I now have running these examples:

?- 1229999999999999878 rdiv 123 =:= 1.0E16.
true.
?- X is (1 rdiv 2)+0.0.
X = 0.5.
?- X is (1 rdiv 2)*1.0.
X = 0.5.

And a few further examples:

?- X is 1 rdiv 3.
X = 1#3.
?- X is 1 rdiv 3.0.
X = 0.3333333333333333.
?- X is 3^(-1).
X = 1#3.
?- X is 3.0^(-1).
X = 0.3333333333333333.

The value of 3^(-1) and 1 rdiv 3.0 differ from what SWI-Prolog
delivers in its default setting. The above values result from
consulting use_module(library(arithmetic/ratio)) in my system.

Mostowski Collapse schrieb am Sonntag, 22. Januar 2023 um 14:00:40 UTC+1:
> That mixing floats and rational numbers can be a challenge
> recently surfaced for SWI-Prolog, where their floats also
> have NaN and Infinity. On the other hand I do not have these
>
> two constants, and my own takes in the form of a simple
> library(arithmetic/ratio), that does some overloading of the
> existing basic arithmetic operators and comparison,
>
> seems not to be fit at all. If I download an old version
> interpreter_1.5.1.jar I get these results:
>
> ?- 1229999999999999878 rdiv 123 =:= 1.0E16.
> fail.
> ?- X is (1 rdiv 2)+0.0.
> Fehler: Argument sollte Ganzzahl sein, gefunden 1.0.
> ?- X is (1 rdiv 2)*1.0.
> Fehler: Argument sollte Ganzzahl sein, gefunden 1.0.
>
> Such cases were deliberatively left open. But I think these
> gaps can be closed towards a ISO core standard backward
> compatibility. Keeping in mind that integers are also rational
>
> numbers, and therefore all the coercion of integer to float,
> that is already found in the ISO core standard should translate
> to a coercion of rational number to float.

Re: Towards Mixing Floats and Rational Numbers

<f10e7e3d-9277-4081-af79-9f8fc8a0b224n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1907&group=comp.lang.prolog#1907

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a37:ae03:0:b0:708:f0d3:2372 with SMTP id x3-20020a37ae03000000b00708f0d32372mr671749qke.691.1674393195062;
Sun, 22 Jan 2023 05:13:15 -0800 (PST)
X-Received: by 2002:a05:6808:201f:b0:367:e50c:fc9b with SMTP id
q31-20020a056808201f00b00367e50cfc9bmr1537294oiw.68.1674393194790; Sun, 22
Jan 2023 05:13:14 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Sun, 22 Jan 2023 05:13:14 -0800 (PST)
In-Reply-To: <cd9fd2fc-4c5b-44f7-821e-a85efaecde8cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <12c01edf-5faa-4d4c-bbd9-76c3b44f7f5en@googlegroups.com> <cd9fd2fc-4c5b-44f7-821e-a85efaecde8cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f10e7e3d-9277-4081-af79-9f8fc8a0b224n@googlegroups.com>
Subject: Re: Towards Mixing Floats and Rational Numbers
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sun, 22 Jan 2023 13:13:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4219
 by: Mostowski Collapse - Sun, 22 Jan 2023 13:13 UTC

I think 3^(-1) and 3.0^(-1) is save to have a new value in my system,
since without consulting library(arithmetic/ratio), I get the following
two values:

/* without library(arithmetic/ratio) */
?- X is 3^(-1).
Error: Argument should be positive or 0, found -1.
?- X is 3.0^(-1).
Error: Argument should be positive or 0, found -1.

So only the library(arithmetic/ratio)) opens (^)/2 to negative
exponents. On the other hand without the library(arithmetic/ratio),
the operator (^)/2 already covered floating point numbers:

/* without library(arithmetic/ratio) */
?- X is 3^2.
X = 9.
?- X is 3.0^2.
X = 9.0.

So challenge was to make (^)/2 more exact and at the
same time also support floating point numbers. The
examples 3^(-1) and 1 rdiv 3.0 with the currious results

that differ with SWI-Prolog reflect a different design
decision. Basically we have now this identity in our
system, for both rational number arguments and

floating point value arguments:

X^(-1) =:= 1 rdiv X

Mostowski Collapse schrieb am Sonntag, 22. Januar 2023 um 14:08:03 UTC+1:
> Here is a prototype of such coercion, already
> working for the next release of formerly Jekejeke Prolog.
> I now have running these examples:
> ?- 1229999999999999878 rdiv 123 =:= 1.0E16.
> true.
> ?- X is (1 rdiv 2)+0.0.
> X = 0.5.
> ?- X is (1 rdiv 2)*1.0.
> X = 0.5.
>
> And a few further examples:
>
> ?- X is 1 rdiv 3.
> X = 1#3.
> ?- X is 1 rdiv 3.0.
> X = 0.3333333333333333.
> ?- X is 3^(-1).
> X = 1#3.
> ?- X is 3.0^(-1).
> X = 0.3333333333333333.
>
> The value of 3^(-1) and 1 rdiv 3.0 differ from what SWI-Prolog
> delivers in its default setting. The above values result from
> consulting use_module(library(arithmetic/ratio)) in my system.
> Mostowski Collapse schrieb am Sonntag, 22. Januar 2023 um 14:00:40 UTC+1:
> > That mixing floats and rational numbers can be a challenge
> > recently surfaced for SWI-Prolog, where their floats also
> > have NaN and Infinity. On the other hand I do not have these
> >
> > two constants, and my own takes in the form of a simple
> > library(arithmetic/ratio), that does some overloading of the
> > existing basic arithmetic operators and comparison,
> >
> > seems not to be fit at all. If I download an old version
> > interpreter_1.5.1.jar I get these results:
> >
> > ?- 1229999999999999878 rdiv 123 =:= 1.0E16.
> > fail.
> > ?- X is (1 rdiv 2)+0.0.
> > Fehler: Argument sollte Ganzzahl sein, gefunden 1.0.
> > ?- X is (1 rdiv 2)*1.0.
> > Fehler: Argument sollte Ganzzahl sein, gefunden 1.0.
> >
> > Such cases were deliberatively left open. But I think these
> > gaps can be closed towards a ISO core standard backward
> > compatibility. Keeping in mind that integers are also rational
> >
> > numbers, and therefore all the coercion of integer to float,
> > that is already found in the ISO core standard should translate
> > to a coercion of rational number to float.

Re: Towards Mixing Floats and Rational Numbers

<4e21a310-9877-471c-9ed9-a81636ede21fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1911&group=comp.lang.prolog#1911

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:2b42:b0:706:5745:924f with SMTP id dp2-20020a05620a2b4200b007065745924fmr857417qkb.214.1674523837932;
Mon, 23 Jan 2023 17:30:37 -0800 (PST)
X-Received: by 2002:a4a:bd84:0:b0:4f9:412c:4fbb with SMTP id
k4-20020a4abd84000000b004f9412c4fbbmr1083265oop.98.1674523837651; Mon, 23 Jan
2023 17:30:37 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Mon, 23 Jan 2023 17:30:37 -0800 (PST)
In-Reply-To: <f10e7e3d-9277-4081-af79-9f8fc8a0b224n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <12c01edf-5faa-4d4c-bbd9-76c3b44f7f5en@googlegroups.com>
<cd9fd2fc-4c5b-44f7-821e-a85efaecde8cn@googlegroups.com> <f10e7e3d-9277-4081-af79-9f8fc8a0b224n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4e21a310-9877-471c-9ed9-a81636ede21fn@googlegroups.com>
Subject: Re: Towards Mixing Floats and Rational Numbers
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Tue, 24 Jan 2023 01:30:37 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1732
 by: Mostowski Collapse - Tue, 24 Jan 2023 01:30 UTC

Somehow I regret my fingerpointing to 0/0 as nan.
Now there are some new problems, in SWI-Prolog:

?- X is max(nan, 1.0).
X = 1.0.

In JavaScript:

console.log(Math.max(0/0, 1.0));
> NaN

In Python:

>>> max(float('nan'),1.0)
nan

I guess the later two languages adhere to some approaches
of mathematical logic to partial functions, i.e. the rule that

functions that have at least one NaN argument, should
return NaN. But this is my personal speculation.

Re: Towards Mixing Floats and Rational Numbers

<78fff600-7b7c-4a70-810d-df6215061971n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1912&group=comp.lang.prolog#1912

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:15eb:b0:6fb:7c45:bd5 with SMTP id p11-20020a05620a15eb00b006fb7c450bd5mr1740265qkm.304.1674646476098;
Wed, 25 Jan 2023 03:34:36 -0800 (PST)
X-Received: by 2002:a05:6870:40ca:b0:163:18ae:d596 with SMTP id
l10-20020a05687040ca00b0016318aed596mr460411oal.4.1674646475748; Wed, 25 Jan
2023 03:34:35 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Wed, 25 Jan 2023 03:34:35 -0800 (PST)
In-Reply-To: <4e21a310-9877-471c-9ed9-a81636ede21fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <12c01edf-5faa-4d4c-bbd9-76c3b44f7f5en@googlegroups.com>
<cd9fd2fc-4c5b-44f7-821e-a85efaecde8cn@googlegroups.com> <f10e7e3d-9277-4081-af79-9f8fc8a0b224n@googlegroups.com>
<4e21a310-9877-471c-9ed9-a81636ede21fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <78fff600-7b7c-4a70-810d-df6215061971n@googlegroups.com>
Subject: Re: Towards Mixing Floats and Rational Numbers
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Wed, 25 Jan 2023 11:34:36 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 36
 by: Mostowski Collapse - Wed, 25 Jan 2023 11:34 UTC

There is a strange effect, that NaN make the less than
or equal not anymore being a total order, i.e. it is
not anymore assured that X =< Y or Y =< X:

/* SWI-Prolog 9.1.2 */
?- nan =< 1.0.
false.

?- 1.0 =< nan.
false.

Did ROK ever write about that? Exact comparison would
gain transitivity. But continuation values, especially the value
NaN, destroys totality.

Mostowski Collapse schrieb am Dienstag, 24. Januar 2023 um 02:30:38 UTC+1:
> Somehow I regret my fingerpointing to 0/0 as nan.
> Now there are some new problems, in SWI-Prolog:
>
> ?- X is max(nan, 1.0).
> X = 1.0.
>
> In JavaScript:
>
> console.log(Math.max(0/0, 1.0));
> > NaN
>
> In Python:
>
> >>> max(float('nan'),1.0)
> nan
>
> I guess the later two languages adhere to some approaches
> of mathematical logic to partial functions, i.e. the rule that
>
> functions that have at least one NaN argument, should
> return NaN. But this is my personal speculation.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor