Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Your mode of life will be changed to ASCII.


devel / comp.lang.prolog / Request for comments: Two types of float of integer division

SubjectAuthor
* Request for comments: Two types of float of integer divisionMostowski Collapse
+* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|`* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
| `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|  `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|   `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|    `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|     `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|      `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|       `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|        `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|         `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|          `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|           `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|            `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|             `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|              `* Re: Request for comments: Two types of float of integer divisionMostowski Collapse
|               `- Re: Request for comments: Two types of float of integer divisionMostowski Collapse
`* Re: Request for comments: Two types of float of integer divisionMild Shock
 `* Re: Request for comments: Two types of float of integer divisionMild Shock
  `* Re: Request for comments: Two types of float of integer divisionMild Shock
   `* Re: Request for comments: Two types of float of integer divisionMild Shock
    `* Re: Request for comments: Two types of float of integer divisionMild Shock
     `- Re: Request for comments: Two types of float of integer divisionMild Shock

1
Request for comments: Two types of float of integer division

<616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:252:b0:35d:482f:e105 with SMTP id c18-20020a05622a025200b0035d482fe105mr204532qtx.92.1664406935669;
Wed, 28 Sep 2022 16:15:35 -0700 (PDT)
X-Received: by 2002:a05:6870:ecab:b0:131:8c96:a1e with SMTP id
eo43-20020a056870ecab00b001318c960a1emr178274oab.122.1664406934473; Wed, 28
Sep 2022 16:15:34 -0700 (PDT)
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: Wed, 28 Sep 2022 16:15:34 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
Subject: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Wed, 28 Sep 2022 23:15:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 29
 by: Mostowski Collapse - Wed, 28 Sep 2022 23:15 UTC

I am playing with the idea to introduce two types
of float of integer division:

- a) Fast and less precise: A/B basically computes
float(A)/float(B).

- b) Slow and more precise: float(A rdiv B) is then
the more precise counterpart.

Currently there is no unity among Prolog systems.
When (/)/2 appears, some Prolog systems implement
a) and some implement b). And it appears

implementing b) is hard! I get:

/* SWI-Prolog 8.5.17 */
?- N9 is 370370367037037036703703703670 / 123456789012345678901234567890.
N9 = 3.

?- N9 is 370370367037037036703703703671 / 123456789012345678901234567890.
N9 = 2.9999999999999996.

Python doesn’t have this bug:

/* Python 3.11.0rc1 (main, Aug 8 2022, 11:30:54) */
>>> 370370367037037036703703703670 / 123456789012345678901234567890
3.0

>>> 370370367037037036703703703671 / 123456789012345678901234567890
3.0

Re: Request for comments: Two types of float of integer division

<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:1114:b0:35b:bb43:a88d with SMTP id e20-20020a05622a111400b0035bbb43a88dmr185652qty.139.1664407324755;
Wed, 28 Sep 2022 16:22:04 -0700 (PDT)
X-Received: by 2002:a05:6820:1888:b0:476:1d00:9d8f with SMTP id
bm8-20020a056820188800b004761d009d8fmr158839oob.98.1664407324580; Wed, 28 Sep
2022 16:22:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Wed, 28 Sep 2022 16:22:04 -0700 (PDT)
In-Reply-To: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Wed, 28 Sep 2022 23:22:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3711
 by: Mostowski Collapse - Wed, 28 Sep 2022 23:22 UTC

So what are the next steps. I already made the following
step. I downgraded the (/)/2 in Dogelog Player for Python,
which simply used the Python (/)/2.

Originally I had:

/* Dogelog Player 1.0.1, Python */
?- N9 is 370370367037037036703703703670 / 123456789012345678901234567890.
N9 = 3.0

Now I have downgraded it:

/* Preview, Dogelog Player 1.0.1, Python */
?- N9 is 370370367037037036703703703670 / 123456789012345678901234567890.
N9 = 3.0000000000000004.

It now corresponds to our Java and JavaScript realization,
all are fast and less precise. What are the next steps:

1. Try prototyping precise float(A rdiv B) in formerly Jekejeke
Prolog, in the rational number library. Rational numbers have
the advantage that they already do a reduction, so I find:

?- N9 is 370370367037037036703703703670 rdiv 123456789012345678901234567890..
N9 = 3.

So float/1 doesn't have much to do. On the other hand here,
float/1 has more work to do, to get to the right conclusion:

?- N9 is 370370367037037036703703703671 rdiv 123456789012345678901234567890..
N9 = 370370367037037036703703703671#123456789012345678901234567890.

2. Dogelog player for JavaScript and Python will only eventually
receive the precise and slow float(A rdiv B), namely when
they also receive rational numbers.

Mostowski Collapse schrieb am Donnerstag, 29. September 2022 um 01:15:36 UTC+2:
> I am playing with the idea to introduce two types
> of float of integer division:
>
> - a) Fast and less precise: A/B basically computes
> float(A)/float(B).
>
> - b) Slow and more precise: float(A rdiv B) is then
> the more precise counterpart.
>
> Currently there is no unity among Prolog systems.
> When (/)/2 appears, some Prolog systems implement
> a) and some implement b). And it appears
>
> implementing b) is hard! I get:
>
> /* SWI-Prolog 8.5.17 */
> ?- N9 is 370370367037037036703703703670 / 123456789012345678901234567890.
> N9 = 3.
>
> ?- N9 is 370370367037037036703703703671 / 123456789012345678901234567890.
> N9 = 2.9999999999999996.
>
> Python doesn’t have this bug:
>
> /* Python 3.11.0rc1 (main, Aug 8 2022, 11:30:54) */
> >>> 370370367037037036703703703670 / 123456789012345678901234567890
> 3.0
>
> >>> 370370367037037036703703703671 / 123456789012345678901234567890
> 3.0

Re: Request for comments: Two types of float of integer division

<98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ad4:4eae:0:b0:4af:9a04:ae3d with SMTP id ed14-20020ad44eae000000b004af9a04ae3dmr3105203qvb.49.1664465890832;
Thu, 29 Sep 2022 08:38:10 -0700 (PDT)
X-Received: by 2002:a05:6808:1149:b0:350:edd9:d2e8 with SMTP id
u9-20020a056808114900b00350edd9d2e8mr7326920oiu.282.1664465890573; Thu, 29
Sep 2022 08:38:10 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Thu, 29 Sep 2022 08:38:10 -0700 (PDT)
In-Reply-To: <80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com> <80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Thu, 29 Sep 2022 15:38:10 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2396
 by: Mostowski Collapse - Thu, 29 Sep 2022 15:38 UTC

Under certain circumstances, there is also an ultra fast
rounding for rational numbers, similar like there is for bigint.
Take this bigint approach, assuming msb(X) > 52:

float_half_even(X,Y) :-
M is msb(X),
float_half_even(M, X, Y).

float_half_even(M, X,Y) :-
(getbit(X, M-53) =:= 0;
getbit(X, M-52) =:= 0, M-53 =:= lsb(X)), !, mpz_get_d(X,Y).
float_half_even(_, X,Y) :-
mpz_get_d(X,H),
Y is nexttoward(H, 1E300).

Now we can do the same for rational numbers, namely
we can do the following, now assuming msb(A)-msb(B) > 52,
we convert a rational number A rdiv B to a float as follows:

float_rat_half_even(A,B,Y) :-
divmod(A,B,X,Z),
M is msb(X),
float_rat_half_even(M, X, Z, Y).

float_rat_half_even(M, X, Z, Y) :-
(getbit(X, M-53) =:= 0;
getbit(X, M-52) =:= 0, M-53 =:= lsb(X), Z =:= 0), !, mpz_get_d(X,Y).
float_rat_half_even(_, X, _, Y) :-
mpz_get_d(X,H),
Y is nexttoward(H, 1E300).

Will do some testing. The testing would be easier if SWI-Prolog
(/)/2 were not buggy. So I have to do some testing against
some other Prolog system, which one?, or against Python (/)/2.

Re: Request for comments: Two types of float of integer division

<th4ffa$8ttm$1@solani.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: janburse@fastmail.fm (Mostowski Collapse)
Newsgroups: comp.lang.prolog
Subject: Re: Request for comments: Two types of float of integer division
Date: Thu, 29 Sep 2022 18:00:42 +0200
Message-ID: <th4ffa$8ttm$1@solani.org>
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com>
<98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Sep 2022 16:00:42 -0000 (UTC)
Injection-Info: solani.org;
logging-data="292790"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.14
Cancel-Lock: sha1:ll0twKClSLXsr28Y9QJrvFYTBUg=
In-Reply-To: <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
X-User-ID: eJwFwYEBwCAIA7CXwLVFz0GE/09Ywk+uCogCh1PBnYUsvfF11+byU+yemTTTQWXeI1PExjft3rJ8uM7mww9p3hXu
 by: Mostowski Collapse - Thu, 29 Sep 2022 16:00 UTC

If we have a numerator with a high lsb/1,
i.e. a lot of zeros in it, the algorithm
indeed agrees, namely I find the following result:

/* SWI-Prolog 8.5.17 */
?- B is 333333, between(1,1000000,N), A is N<<80, X is A/B,
float_rat_half_even(A,B,Y), X =\= Y.
false.

Hell breaks loose if the numerator is not that
simple, but there are only a few cases where
things go wrong. Need to cross check with Python:

/* SWI-Prolog 8.5.17 */
?- B is 333333, between(1,1000000,N), A is N<<80+123456789, X is A/B,
float_rat_half_even(A,B,Y), X =\= Y, write(N), nl, fail; true.
13
26
52
8915
458442
791775
true.

Mostowski Collapse wrote:
> Under certain circumstances, there is also an ultra fast
> rounding for rational numbers, similar like there is for bigint.
> Take this bigint approach, assuming msb(X) > 52:
>
> float_half_even(X,Y) :-
> M is msb(X),
> float_half_even(M, X, Y).
>
> float_half_even(M, X,Y) :-
> (getbit(X, M-53) =:= 0;
> getbit(X, M-52) =:= 0, M-53 =:= lsb(X)), !, mpz_get_d(X,Y).
> float_half_even(_, X,Y) :-
> mpz_get_d(X,H),
> Y is nexttoward(H, 1E300).
>
> Now we can do the same for rational numbers, namely
> we can do the following, now assuming msb(A)-msb(B) > 52,
> we convert a rational number A rdiv B to a float as follows:
>
> float_rat_half_even(A,B,Y) :-
> divmod(A,B,X,Z),
> M is msb(X),
> float_rat_half_even(M, X, Z, Y).
>
> float_rat_half_even(M, X, Z, Y) :-
> (getbit(X, M-53) =:= 0;
> getbit(X, M-52) =:= 0, M-53 =:= lsb(X), Z =:= 0), !, mpz_get_d(X,Y).
> float_rat_half_even(_, X, _, Y) :-
> mpz_get_d(X,H),
> Y is nexttoward(H, 1E300).
>
> Will do some testing. The testing would be easier if SWI-Prolog
> (/)/2 were not buggy. So I have to do some testing against
> some other Prolog system, which one?, or against Python (/)/2.
>

Re: Request for comments: Two types of float of integer division

<th4fhr$8ttm$2@solani.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: janburse@fastmail.fm (Mostowski Collapse)
Newsgroups: comp.lang.prolog
Subject: Re: Request for comments: Two types of float of integer division
Date: Thu, 29 Sep 2022 18:02:03 +0200
Message-ID: <th4fhr$8ttm$2@solani.org>
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com>
<98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 29 Sep 2022 16:02:03 -0000 (UTC)
Injection-Info: solani.org;
logging-data="292790"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.14
Cancel-Lock: sha1:kG3b1Mit8LkMX3ibf7oABZxfGPU=
X-User-ID: eJwFwQkBwDAIBDBL/AdyCgz/Epa4BsfAwsP8/HQBpeonS64waDt/ztjMSrHAzMi9cxV6RhnF3bJrRISsHyqlFEE=
In-Reply-To: <th4ffa$8ttm$1@solani.org>
 by: Mostowski Collapse - Thu, 29 Sep 2022 16:02 UTC

Cross checking with Python tells me (/)/2 is wrong
and float_rat_half_even/2 is correct (wao! lucky me),
for example for N=13 I get:

/* Python 3.11.0rc1 */
>>> 15716035654990179394637077 / 333333
4.7148154113124655e+19

/* SWI-Prolog 8.5.7 */
?- X is 15716035654990179394637077 / 333333.
X = 4.714815411312465e+19. /* wrong too small */

?- float_rat_half_even(15716035654990179394637077, 333333, Y).
Y = 4.7148154113124655e+19.

Mostowski Collapse wrote:
>
> If we have a numerator with a high lsb/1,
> i.e. a lot of zeros in it, the algorithm
> indeed agrees, namely I find the following result:
>
> /* SWI-Prolog 8.5.17 */
> ?- B is 333333, between(1,1000000,N), A is N<<80, X is A/B,
> float_rat_half_even(A,B,Y), X =\= Y.
> false.
>
> Hell breaks loose if the numerator is not that
> simple, but there are only a few cases where
> things go wrong. Need to cross check with Python:
>
> /* SWI-Prolog 8.5.17 */
> ?- B is 333333, between(1,1000000,N), A is N<<80+123456789, X is A/B,
> float_rat_half_even(A,B,Y), X =\= Y, write(N), nl, fail; true.
> 13
> 26
> 52
> 8915
> 458442
> 791775
> true.
>
>
> Mostowski Collapse wrote:
>> Under certain circumstances, there is also an ultra fast
>> rounding for rational numbers, similar like there is for bigint.
>> Take this bigint approach, assuming msb(X) > 52:
>>
>> float_half_even(X,Y) :-
>>      M is msb(X),
>>      float_half_even(M, X, Y).
>>
>> float_half_even(M, X,Y) :-
>>       (getbit(X, M-53) =:= 0;
>>        getbit(X, M-52) =:= 0, M-53 =:= lsb(X)), !, mpz_get_d(X,Y).
>> float_half_even(_, X,Y) :-
>>       mpz_get_d(X,H),
>>       Y is nexttoward(H, 1E300).
>>
>> Now we can do the same for rational numbers, namely
>> we can do the following, now assuming msb(A)-msb(B) > 52,
>> we convert a rational number A rdiv B to a float as follows:
>>
>> float_rat_half_even(A,B,Y) :-
>>      divmod(A,B,X,Z),
>>      M is msb(X),
>>      float_rat_half_even(M, X, Z, Y).
>>
>> float_rat_half_even(M, X, Z, Y) :-
>>       (getbit(X, M-53) =:= 0;
>>        getbit(X, M-52) =:= 0, M-53 =:= lsb(X), Z =:= 0), !,
>> mpz_get_d(X,Y).
>> float_rat_half_even(_, X, _, Y) :-
>>       mpz_get_d(X,H),
>>       Y is nexttoward(H, 1E300).
>>
>> Will do some testing. The testing would be easier if SWI-Prolog
>> (/)/2 were not buggy. So I have to do some testing against
>> some other Prolog system, which one?, or against Python (/)/2.
>>
>

Re: Request for comments: Two types of float of integer division

<8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:6214:27e2:b0:4ac:97ba:57b5 with SMTP id jt2-20020a05621427e200b004ac97ba57b5mr3203454qvb.130.1664467750096;
Thu, 29 Sep 2022 09:09:10 -0700 (PDT)
X-Received: by 2002:a05:6808:23d5:b0:350:4f5c:143f with SMTP id
bq21-20020a05680823d500b003504f5c143fmr2030816oib.257.1664467749919; Thu, 29
Sep 2022 09:09:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Thu, 29 Sep 2022 09:09:09 -0700 (PDT)
In-Reply-To: <th4fhr$8ttm$2@solani.org>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Thu, 29 Sep 2022 16:09:10 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4776
 by: Mostowski Collapse - Thu, 29 Sep 2022 16:09 UTC

The bad news is. Cannot implement the same in JavaScript,
the JavaScript bigints do not have (yet) bit operations such as
msb/1, lsb/1 or getbit/1. And if there are no native and

fast implementations of these, the algorithm is pointless.
Maybe just wait some time till they arrive in JavaScript,
for example one finds discussion to include bitLength,

which can be used for msb/1. Didn't check yet Phyton, but
in Python I don't need an algorithm, since (/)/2 can already
do the more exact division. But now when cross checking

with Python, I was blindly trusting Python that the rounding
is also HALF_EVEN in Python! So the cross checking
is a preliminary result.

Mostowski Collapse schrieb am Donnerstag, 29. September 2022 um 18:02:06 UTC+2:
> Cross checking with Python tells me (/)/2 is wrong
> and float_rat_half_even/2 is correct (wao! lucky me),
> for example for N=13 I get:
>
> /* Python 3.11.0rc1 */
> >>> 15716035654990179394637077 / 333333
> 4.7148154113124655e+19
>
> /* SWI-Prolog 8.5.7 */
> ?- X is 15716035654990179394637077 / 333333.
> X = 4.714815411312465e+19. /* wrong too small */
>
> ?- float_rat_half_even(15716035654990179394637077, 333333, Y).
> Y = 4.7148154113124655e+19.
> Mostowski Collapse wrote:
> >
> > If we have a numerator with a high lsb/1,
> > i.e. a lot of zeros in it, the algorithm
> > indeed agrees, namely I find the following result:
> >
> > /* SWI-Prolog 8.5.17 */
> > ?- B is 333333, between(1,1000000,N), A is N<<80, X is A/B,
> > float_rat_half_even(A,B,Y), X =\= Y.
> > false.
> >
> > Hell breaks loose if the numerator is not that
> > simple, but there are only a few cases where
> > things go wrong. Need to cross check with Python:
> >
> > /* SWI-Prolog 8.5.17 */
> > ?- B is 333333, between(1,1000000,N), A is N<<80+123456789, X is A/B,
> > float_rat_half_even(A,B,Y), X =\= Y, write(N), nl, fail; true.
> > 13
> > 26
> > 52
> > 8915
> > 458442
> > 791775
> > true.
> >
> >
> > Mostowski Collapse wrote:
> >> Under certain circumstances, there is also an ultra fast
> >> rounding for rational numbers, similar like there is for bigint.
> >> Take this bigint approach, assuming msb(X) > 52:
> >>
> >> float_half_even(X,Y) :-
> >> M is msb(X),
> >> float_half_even(M, X, Y).
> >>
> >> float_half_even(M, X,Y) :-
> >> (getbit(X, M-53) =:= 0;
> >> getbit(X, M-52) =:= 0, M-53 =:= lsb(X)), !, mpz_get_d(X,Y).
> >> float_half_even(_, X,Y) :-
> >> mpz_get_d(X,H),
> >> Y is nexttoward(H, 1E300).
> >>
> >> Now we can do the same for rational numbers, namely
> >> we can do the following, now assuming msb(A)-msb(B) > 52,
> >> we convert a rational number A rdiv B to a float as follows:
> >>
> >> float_rat_half_even(A,B,Y) :-
> >> divmod(A,B,X,Z),
> >> M is msb(X),
> >> float_rat_half_even(M, X, Z, Y).
> >>
> >> float_rat_half_even(M, X, Z, Y) :-
> >> (getbit(X, M-53) =:= 0;
> >> getbit(X, M-52) =:= 0, M-53 =:= lsb(X), Z =:= 0), !,
> >> mpz_get_d(X,Y).
> >> float_rat_half_even(_, X, _, Y) :-
> >> mpz_get_d(X,H),
> >> Y is nexttoward(H, 1E300).
> >>
> >> Will do some testing. The testing would be easier if SWI-Prolog
> >> (/)/2 were not buggy. So I have to do some testing against
> >> some other Prolog system, which one?, or against Python (/)/2.
> >>
> >

Re: Request for comments: Two types of float of integer division

<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a37:4646:0:b0:6e4:ed82:a3ac with SMTP id t67-20020a374646000000b006e4ed82a3acmr857706qka.57.1666988216511;
Fri, 28 Oct 2022 13:16:56 -0700 (PDT)
X-Received: by 2002:a05:6870:63aa:b0:13a:fe6c:5ed0 with SMTP id
t42-20020a05687063aa00b0013afe6c5ed0mr537935oap.257.1666988216133; Fri, 28
Oct 2022 13:16:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.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: Fri, 28 Oct 2022 13:16:55 -0700 (PDT)
In-Reply-To: <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Fri, 28 Oct 2022 20:16:56 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2406
 by: Mostowski Collapse - Fri, 28 Oct 2022 20:16 UTC

Ok, this was settled with Python mode in SWI-Prolog,
we can switch on more precise integer division. Another
application of Python mode, since it also applies to (**)/2,

measure failures of the power function:

% swi_sweep
swi_sweep :-
set_prolog_flag(prefer_rationals, true),
set_prolog_flag(max_rational_size, 0),
set_prolog_flag(max_rational_size_action, float),
fail.
swi_sweep :- % like in needle3
L is -(1<<15), H is (1<<15)+1,
M is -(1<<3), J is (1<<3)+1,
aggregate_all(count,
(between(L, H, P), P =\= 0,
between(M, J, Q), P**Q =\= float(P)**float(Q)), C),
write('sweep1, swi: '), write(C), nl, fail.
swi_sweep :- % like in fuzzer6
L is -(1<<12), H is (1<<12)+1,
M is -(1<<6), J is (1<<6)+1,
aggregate_all(count,
(between(L, H, P), P =\= 0,
between(M, J, Q), P**Q =\= float(P)**float(Q)), C),
write('sweep2, swi: '), write(C), nl, fail.
swi_sweep :-
set_prolog_flag(prefer_rationals, false),
fail.
swi_sweep.

Re: Request for comments: Two types of float of integer division

<b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:440e:b0:6f6:2a11:c497 with SMTP id v14-20020a05620a440e00b006f62a11c497mr795626qkp.213.1666988292552;
Fri, 28 Oct 2022 13:18:12 -0700 (PDT)
X-Received: by 2002:a05:6808:308c:b0:354:99ec:bbb7 with SMTP id
bl12-20020a056808308c00b0035499ecbbb7mr664735oib.68.1666988292315; Fri, 28
Oct 2022 13:18:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.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: Fri, 28 Oct 2022 13:18:12 -0700 (PDT)
In-Reply-To: <f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Fri, 28 Oct 2022 20:18:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2900
 by: Mostowski Collapse - Fri, 28 Oct 2022 20:18 UTC

Here are some test results. WASM is again the best, although
not extremly far away from WSL2. Windows is again last:

/* SWI-Prolog 8.5.20 WASM */
sweep1, swi: 2186
sweep2, swi: 1242

/* SWI-Prolog 8.5.20 WSL2 */
sweep1, swi: 3300
sweep2, swi: 1370

/* SWI-Prolog 8.5.20 Windows */
sweep1, swi: 405161
sweep2, swi: 786699

Mostowski Collapse schrieb am Freitag, 28. Oktober 2022 um 22:16:57 UTC+2:
> Ok, this was settled with Python mode in SWI-Prolog,
> we can switch on more precise integer division. Another
> application of Python mode, since it also applies to (**)/2,
>
> measure failures of the power function:
>
> % swi_sweep
> swi_sweep :-
> set_prolog_flag(prefer_rationals, true),
> set_prolog_flag(max_rational_size, 0),
> set_prolog_flag(max_rational_size_action, float),
> fail.
> swi_sweep :- % like in needle3
> L is -(1<<15), H is (1<<15)+1,
> M is -(1<<3), J is (1<<3)+1,
> aggregate_all(count,
> (between(L, H, P), P =\= 0,
> between(M, J, Q), P**Q =\= float(P)**float(Q)), C),
> write('sweep1, swi: '), write(C), nl, fail.
> swi_sweep :- % like in fuzzer6
> L is -(1<<12), H is (1<<12)+1,
> M is -(1<<6), J is (1<<6)+1,
> aggregate_all(count,
> (between(L, H, P), P =\= 0,
> between(M, J, Q), P**Q =\= float(P)**float(Q)), C),
> write('sweep2, swi: '), write(C), nl, fail.
> swi_sweep :-
> set_prolog_flag(prefer_rationals, false),
> fail.
> swi_sweep.

Re: Request for comments: Two types of float of integer division

<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:7f43:0:b0:39c:dd97:ad5b with SMTP id g3-20020ac87f43000000b0039cdd97ad5bmr1216791qtk.415.1666990574907;
Fri, 28 Oct 2022 13:56:14 -0700 (PDT)
X-Received: by 2002:a9d:5a11:0:b0:661:d4b7:cefb with SMTP id
v17-20020a9d5a11000000b00661d4b7cefbmr615760oth.270.1666990574633; Fri, 28
Oct 2022 13:56:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.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: Fri, 28 Oct 2022 13:56:14 -0700 (PDT)
In-Reply-To: <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Fri, 28 Oct 2022 20:56:14 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4225
 by: Mostowski Collapse - Fri, 28 Oct 2022 20:56 UTC

To bring some of my precise float emulations to Dogelog
Playrer I need msb/1. I looking for inspiration.

Scryer Prolog isn't some inspiration:

test(X) :- msb(698072381837257563305573971580726935040345973
88060083583912810633489137842647022803107007382
69827592504647436506289493205329736363655295902
94743735953400982487450103250905033780625181457
49473537073305602444617606242084853904869693687
541, X).

?- time((between(1,1000,_), test(_), fail; true)).
% CPU time: 0.277s
true.

On the other hand Trealla Prolog does a good job:

/* Trealla Prolog */
test(X) :- X is msb(698072381837257563305573971580726935040345973
88060083583912810633489137842647022803107007382
69827592504647436506289493205329736363655295902
94743735953400982487450103250905033780625181457
49473537073305602444617606242084853904869693687
541).

?- time((between(1,1000,_), test(_), fail; true)).
Time elapsed 0.000384s
true.

Holy Cow, thats factor 721x slower. Looks like Scyer Prolog
msb/1 is O(N) where N is the number of bits, and Trealla
Prologs msb/1 is O(1). How comes?

Mostowski Collapse schrieb am Freitag, 28. Oktober 2022 um 22:18:13 UTC+2:
> Here are some test results. WASM is again the best, although
> not extremly far away from WSL2. Windows is again last:
>
> /* SWI-Prolog 8.5.20 WASM */
> sweep1, swi: 2186
> sweep2, swi: 1242
>
> /* SWI-Prolog 8.5.20 WSL2 */
> sweep1, swi: 3300
> sweep2, swi: 1370
>
> /* SWI-Prolog 8.5.20 Windows */
> sweep1, swi: 405161
> sweep2, swi: 786699
> Mostowski Collapse schrieb am Freitag, 28. Oktober 2022 um 22:16:57 UTC+2:
> > Ok, this was settled with Python mode in SWI-Prolog,
> > we can switch on more precise integer division. Another
> > application of Python mode, since it also applies to (**)/2,
> >
> > measure failures of the power function:
> >
> > % swi_sweep
> > swi_sweep :-
> > set_prolog_flag(prefer_rationals, true),
> > set_prolog_flag(max_rational_size, 0),
> > set_prolog_flag(max_rational_size_action, float),
> > fail.
> > swi_sweep :- % like in needle3
> > L is -(1<<15), H is (1<<15)+1,
> > M is -(1<<3), J is (1<<3)+1,
> > aggregate_all(count,
> > (between(L, H, P), P =\= 0,
> > between(M, J, Q), P**Q =\= float(P)**float(Q)), C),
> > write('sweep1, swi: '), write(C), nl, fail.
> > swi_sweep :- % like in fuzzer6
> > L is -(1<<12), H is (1<<12)+1,
> > M is -(1<<6), J is (1<<6)+1,
> > aggregate_all(count,
> > (between(L, H, P), P =\= 0,
> > between(M, J, Q), P**Q =\= float(P)**float(Q)), C),
> > write('sweep2, swi: '), write(C), nl, fail.
> > swi_sweep :-
> > set_prolog_flag(prefer_rationals, false),
> > fail.
> > swi_sweep.

Re: Request for comments: Two types of float of integer division

<cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:5d49:0:b0:3a4:ee8d:db04 with SMTP id g9-20020ac85d49000000b003a4ee8ddb04mr1345540qtx.114.1666991799480;
Fri, 28 Oct 2022 14:16:39 -0700 (PDT)
X-Received: by 2002:a05:6870:f629:b0:136:b5dd:8717 with SMTP id
ek41-20020a056870f62900b00136b5dd8717mr655290oab.33.1666991799076; Fri, 28
Oct 2022 14:16:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.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: Fri, 28 Oct 2022 14:16:38 -0700 (PDT)
In-Reply-To: <f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Fri, 28 Oct 2022 21:16:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 5547
 by: Mostowski Collapse - Fri, 28 Oct 2022 21:16 UTC

This is basically the Scryer Prolog algorithm:

/* msb2/2, very slow */
msb2(X, N) :-
msb2(X, -1, N).

msb2(0, N, M) :- !, M = N.
msb2(X, N, M) :-
Y is X>>1,
K is N+1,
msb2(Y, K, M).

Here is a trick to make it slightly faster:

/* msb3/2, still slow */
msb3(X, N) :-
msb3(X, -1, N).

msb3(0, N, M) :- !, M = N.
msb3(X, N, M) :-
Y is X>>64, Y =\= 0, !,
K is N+64,
msb3(Y, K, M).
msb3(X, N, M) :-
Y is X>>1,
K is N+1,
msb3(Y, K, M).

In Jekejeke Prolog I get:

/* Scryer Algorithm */
?- time((between(1,10000,_), test(_), fail; true)).
% Threads 2,547 ms, GC 25 ms, Up 2,548 ms (Current 10/28/22 23:13:11)
true.

/* Slightly Faster Algorithm */
?- time((between(1,10000,_), test2(_), fail; true)).
% Threads 140 ms, GC 1 ms, Up 141 ms (Current 10/28/22 23:13:13)
true.

/* BigInteger method bitLength() */
?- time((between(1,10000,_), test3(_), fail; true)).
% Threads 0 ms, GC 0 ms, Up 2 ms (Current 10/28/22 23:13:18)
true.

Mostowski Collapse schrieb am Freitag, 28. Oktober 2022 um 22:56:15 UTC+2:
> To bring some of my precise float emulations to Dogelog
> Playrer I need msb/1. I looking for inspiration.
>
> Scryer Prolog isn't some inspiration:
>
> test(X) :- msb(698072381837257563305573971580726935040345973
> 88060083583912810633489137842647022803107007382
> 69827592504647436506289493205329736363655295902
> 94743735953400982487450103250905033780625181457
> 49473537073305602444617606242084853904869693687
> 541, X).
>
> ?- time((between(1,1000,_), test(_), fail; true)).
> % CPU time: 0.277s
> true.
>
> On the other hand Trealla Prolog does a good job:
>
> /* Trealla Prolog */
> test(X) :- X is msb(698072381837257563305573971580726935040345973
> 88060083583912810633489137842647022803107007382
> 69827592504647436506289493205329736363655295902
> 94743735953400982487450103250905033780625181457
> 49473537073305602444617606242084853904869693687
> 541).
>
> ?- time((between(1,1000,_), test(_), fail; true)).
> Time elapsed 0.000384s
> true.
>
> Holy Cow, thats factor 721x slower. Looks like Scyer Prolog
> msb/1 is O(N) where N is the number of bits, and Trealla
> Prologs msb/1 is O(1). How comes?
> Mostowski Collapse schrieb am Freitag, 28. Oktober 2022 um 22:18:13 UTC+2:
> > Here are some test results. WASM is again the best, although
> > not extremly far away from WSL2. Windows is again last:
> >
> > /* SWI-Prolog 8.5.20 WASM */
> > sweep1, swi: 2186
> > sweep2, swi: 1242
> >
> > /* SWI-Prolog 8.5.20 WSL2 */
> > sweep1, swi: 3300
> > sweep2, swi: 1370
> >
> > /* SWI-Prolog 8.5.20 Windows */
> > sweep1, swi: 405161
> > sweep2, swi: 786699
> > Mostowski Collapse schrieb am Freitag, 28. Oktober 2022 um 22:16:57 UTC+2:
> > > Ok, this was settled with Python mode in SWI-Prolog,
> > > we can switch on more precise integer division. Another
> > > application of Python mode, since it also applies to (**)/2,
> > >
> > > measure failures of the power function:
> > >
> > > % swi_sweep
> > > swi_sweep :-
> > > set_prolog_flag(prefer_rationals, true),
> > > set_prolog_flag(max_rational_size, 0),
> > > set_prolog_flag(max_rational_size_action, float),
> > > fail.
> > > swi_sweep :- % like in needle3
> > > L is -(1<<15), H is (1<<15)+1,
> > > M is -(1<<3), J is (1<<3)+1,
> > > aggregate_all(count,
> > > (between(L, H, P), P =\= 0,
> > > between(M, J, Q), P**Q =\= float(P)**float(Q)), C),
> > > write('sweep1, swi: '), write(C), nl, fail.
> > > swi_sweep :- % like in fuzzer6
> > > L is -(1<<12), H is (1<<12)+1,
> > > M is -(1<<6), J is (1<<6)+1,
> > > aggregate_all(count,
> > > (between(L, H, P), P =\= 0,
> > > between(M, J, Q), P**Q =\= float(P)**float(Q)), C),
> > > write('sweep2, swi: '), write(C), nl, fail.
> > > swi_sweep :-
> > > set_prolog_flag(prefer_rationals, false),
> > > fail.
> > > swi_sweep.

Re: Request for comments: Two types of float of integer division

<b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:19a6:b0:6ee:d3d6:6b03 with SMTP id bm38-20020a05620a19a600b006eed3d66b03mr1483748qkb.376.1667002008974;
Fri, 28 Oct 2022 17:06:48 -0700 (PDT)
X-Received: by 2002:a05:6870:63aa:b0:13a:fe6c:5ed0 with SMTP id
t42-20020a05687063aa00b0013afe6c5ed0mr1013413oap.257.1667002008730; Fri, 28
Oct 2022 17:06:48 -0700 (PDT)
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: Fri, 28 Oct 2022 17:06:48 -0700 (PDT)
In-Reply-To: <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com> <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sat, 29 Oct 2022 00:06:48 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 16
 by: Mostowski Collapse - Sat, 29 Oct 2022 00:06 UTC

Could emulate msb/1. So result for (**)(2 for other Prolog systems.
It seems PyPy and SICStus use the same pow() function:

System sweep1 sweep2 Total Variant
jekejeke 1756 666 2422 JDK 19
swi 2186 1242 3428 WASM
scryer 3300 1370 4670 WSL2
dogelog 2930 2174 5104 PyPy
sicstus 2930 2174 5104 Windows
ciao 3300 324342 327642 WSL2
eclipse 345587 482199 827786 Windows

Ciao botched something in sweep2. ECLiPSe botched
both sweep1 and sweep2. Trealla Prolog I couldn’t

test because of some bigint bug. Ciao Playground
couldn’t test because of missing auto yield i.e timeout.

Re: Request for comments: Two types of float of integer division

<4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a0c:8041:0:b0:4af:b13b:2624 with SMTP id 59-20020a0c8041000000b004afb13b2624mr3974014qva.92.1667054266975;
Sat, 29 Oct 2022 07:37:46 -0700 (PDT)
X-Received: by 2002:a05:6870:9a1d:b0:13c:265b:759e with SMTP id
fo29-20020a0568709a1d00b0013c265b759emr11209550oab.282.1667054266681; Sat, 29
Oct 2022 07:37:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Sat, 29 Oct 2022 07:37:46 -0700 (PDT)
In-Reply-To: <b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com> <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
<b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sat, 29 Oct 2022 14:37:46 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2735
 by: Mostowski Collapse - Sat, 29 Oct 2022 14:37 UTC

SICStus Prolog can be also quite annoying.
It has msb/1 but no lsb/1? Holy Cow.

Thank god it can be easily bootstrapped:

lsb(X, N) :- N is msb(X /\ -X).

This might do for smallints. But is surely not
the most efficient for bigints.

Mostowski Collapse schrieb am Samstag, 29. Oktober 2022 um 02:06:49 UTC+2:
> Could emulate msb/1. So result for (**)(2 for other Prolog systems.
> It seems PyPy and SICStus use the same pow() function:
>
> System sweep1 sweep2 Total Variant
> jekejeke 1756 666 2422 JDK 19
> swi 2186 1242 3428 WASM
> scryer 3300 1370 4670 WSL2
> dogelog 2930 2174 5104 PyPy
> sicstus 2930 2174 5104 Windows
> ciao 3300 324342 327642 WSL2
> eclipse 345587 482199 827786 Windows
>
> Ciao botched something in sweep2. ECLiPSe botched
> both sweep1 and sweep2. Trealla Prolog I couldn’t
>
> test because of some bigint bug. Ciao Playground
> couldn’t test because of missing auto yield i.e timeout.

Re: Request for comments: Two types of float of integer division

<f11a74bf-26bb-4e9f-8d87-9a69b71ccce1n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:6214:d65:b0:4bc:8cd:6d6b with SMTP id 5-20020a0562140d6500b004bc08cd6d6bmr18165976qvs.19.1667491458063;
Thu, 03 Nov 2022 09:04:18 -0700 (PDT)
X-Received: by 2002:aca:1a06:0:b0:35a:3960:8de5 with SMTP id
a6-20020aca1a06000000b0035a39608de5mr5848773oia.262.1667491457725; Thu, 03
Nov 2022 09:04:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Thu, 3 Nov 2022 09:04:17 -0700 (PDT)
In-Reply-To: <4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com> <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
<b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com> <4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f11a74bf-26bb-4e9f-8d87-9a69b71ccce1n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Thu, 03 Nov 2022 16:04:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3775
 by: Mostowski Collapse - Thu, 3 Nov 2022 16:04 UTC

Do we really need libraries such as GMP? My
idea, a good Novacore would have fast arithmetic,
so that one can realize many functions in pure

Prolog itself. Like this here:

iroot(X, Y, Z):
The predicate succeeds in Z with the Y-th root of X.

Here are some benchmarking results:

/* SWI-Prolog 8.5.20 */
?- M is (2^32+3), X is M^3+1, time((between(1,100000,_),
iroot(X, 3, Y), fail; true)).
% 4,900,000 inferences, 2.172 CPU in 2.164 seconds (100% CPU, 2256115 Lips)

/* Trealla Prolog 2.5.13 */
?- M is (2^32+3), X is M^3+1, time((between(1,100000,_),
iroot(X, 3, Y), fail; true)).
Time elapsed 1.28s

/* Jekejeke Prolog 1.5.5 JDK 1.8 */
?- M is (2^32+3), X is M^3+1, time((between(1,100000,_),
iroot(X, 3, Y), fail; true)).
% Threads 718 ms, GC 7 ms, Up 738 ms (Current 11/03/22 16:27:11)

Mostowski Collapse schrieb am Samstag, 29. Oktober 2022 um 16:37:47 UTC+2:
> SICStus Prolog can be also quite annoying.
> It has msb/1 but no lsb/1? Holy Cow.
>
> Thank god it can be easily bootstrapped:
>
> lsb(X, N) :- N is msb(X /\ -X).
>
> This might do for smallints. But is surely not
> the most efficient for bigints.
> Mostowski Collapse schrieb am Samstag, 29. Oktober 2022 um 02:06:49 UTC+2:
> > Could emulate msb/1. So result for (**)(2 for other Prolog systems.
> > It seems PyPy and SICStus use the same pow() function:
> >
> > System sweep1 sweep2 Total Variant
> > jekejeke 1756 666 2422 JDK 19
> > swi 2186 1242 3428 WASM
> > scryer 3300 1370 4670 WSL2
> > dogelog 2930 2174 5104 PyPy
> > sicstus 2930 2174 5104 Windows
> > ciao 3300 324342 327642 WSL2
> > eclipse 345587 482199 827786 Windows
> >
> > Ciao botched something in sweep2. ECLiPSe botched
> > both sweep1 and sweep2. Trealla Prolog I couldn’t
> >
> > test because of some bigint bug. Ciao Playground
> > couldn’t test because of missing auto yield i.e timeout.

Re: Request for comments: Two types of float of integer division

<363039a6-8bcd-4db4-95ba-9b490ffb8058n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:5bcf:0:b0:3a4:f2a4:58b8 with SMTP id b15-20020ac85bcf000000b003a4f2a458b8mr25548994qtb.462.1667491498089;
Thu, 03 Nov 2022 09:04:58 -0700 (PDT)
X-Received: by 2002:a05:6808:1922:b0:35a:58aa:91c6 with SMTP id
bf34-20020a056808192200b0035a58aa91c6mr98942oib.161.1667491497827; Thu, 03
Nov 2022 09:04:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Thu, 3 Nov 2022 09:04:57 -0700 (PDT)
In-Reply-To: <f11a74bf-26bb-4e9f-8d87-9a69b71ccce1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com> <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
<b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com> <4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>
<f11a74bf-26bb-4e9f-8d87-9a69b71ccce1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <363039a6-8bcd-4db4-95ba-9b490ffb8058n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Thu, 03 Nov 2022 16:04:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4952
 by: Mostowski Collapse - Thu, 3 Nov 2022 16:04 UTC

So what are the obstacles to such a Novacore?
I guess there are two problems:
a) Seems to be hard to get basic arithmetic fast
b) Seems to be hard to integrate it with logic and
recursion, i.e. the comparisons on bigint, and also
stack management of predicate invocation.
c) Seems to be hard to provide a good set of built-ins,
for example Scryer Prolog has no speedy msb/1, which is
used in the implementation of iroot/3. Other Prolog system
have msb/1 but no lsb/1.

What are the chances of such a Novacore?
I guess there are these chances:
a) Could implement the whole rational arithmethic like that
b) Could implement rational to float conversion like that
c) Extremly high portability, need only find some bigints
on each platform, and everything concerning rational
numbers etc.. will be automatically there.

Mostowski Collapse schrieb am Donnerstag, 3. November 2022 um 17:04:19 UTC+1:
> Do we really need libraries such as GMP? My
> idea, a good Novacore would have fast arithmetic,
> so that one can realize many functions in pure
>
> Prolog itself. Like this here:
>
> iroot(X, Y, Z):
> The predicate succeeds in Z with the Y-th root of X.
>
> Here are some benchmarking results:
>
> /* SWI-Prolog 8.5.20 */
> ?- M is (2^32+3), X is M^3+1, time((between(1,100000,_),
> iroot(X, 3, Y), fail; true)).
> % 4,900,000 inferences, 2.172 CPU in 2.164 seconds (100% CPU, 2256115 Lips)
>
> /* Trealla Prolog 2.5.13 */
> ?- M is (2^32+3), X is M^3+1, time((between(1,100000,_),
> iroot(X, 3, Y), fail; true)).
> Time elapsed 1.28s
>
> /* Jekejeke Prolog 1.5.5 JDK 1.8 */
> ?- M is (2^32+3), X is M^3+1, time((between(1,100000,_),
> iroot(X, 3, Y), fail; true)).
> % Threads 718 ms, GC 7 ms, Up 738 ms (Current 11/03/22 16:27:11)
> Mostowski Collapse schrieb am Samstag, 29. Oktober 2022 um 16:37:47 UTC+2:
> > SICStus Prolog can be also quite annoying.
> > It has msb/1 but no lsb/1? Holy Cow.
> >
> > Thank god it can be easily bootstrapped:
> >
> > lsb(X, N) :- N is msb(X /\ -X).
> >
> > This might do for smallints. But is surely not
> > the most efficient for bigints.
> > Mostowski Collapse schrieb am Samstag, 29. Oktober 2022 um 02:06:49 UTC+2:
> > > Could emulate msb/1. So result for (**)(2 for other Prolog systems.
> > > It seems PyPy and SICStus use the same pow() function:
> > >
> > > System sweep1 sweep2 Total Variant
> > > jekejeke 1756 666 2422 JDK 19
> > > swi 2186 1242 3428 WASM
> > > scryer 3300 1370 4670 WSL2
> > > dogelog 2930 2174 5104 PyPy
> > > sicstus 2930 2174 5104 Windows
> > > ciao 3300 324342 327642 WSL2
> > > eclipse 345587 482199 827786 Windows
> > >
> > > Ciao botched something in sweep2. ECLiPSe botched
> > > both sweep1 and sweep2. Trealla Prolog I couldn’t
> > >
> > > test because of some bigint bug. Ciao Playground
> > > couldn’t test because of missing auto yield i.e timeout.

Re: Request for comments: Two types of float of integer division

<7c36004a-c28e-4db6-a25f-01101d10ab02n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:5712:0:b0:3a5:636d:6d67 with SMTP id 18-20020ac85712000000b003a5636d6d67mr12188510qtw.674.1667784368829;
Sun, 06 Nov 2022 17:26:08 -0800 (PST)
X-Received: by 2002:a05:6830:6083:b0:660:d54e:583 with SMTP id
by3-20020a056830608300b00660d54e0583mr23413412otb.282.1667784368549; Sun, 06
Nov 2022 17:26:08 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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, 6 Nov 2022 17:26:08 -0800 (PST)
In-Reply-To: <363039a6-8bcd-4db4-95ba-9b490ffb8058n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com> <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
<b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com> <4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>
<f11a74bf-26bb-4e9f-8d87-9a69b71ccce1n@googlegroups.com> <363039a6-8bcd-4db4-95ba-9b490ffb8058n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7c36004a-c28e-4db6-a25f-01101d10ab02n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Mon, 07 Nov 2022 01:26:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2323
 by: Mostowski Collapse - Mon, 7 Nov 2022 01:26 UTC

Now I have added a new decimal128 datatype to my formerly
Jekejeke Prolog system. Syntactically it starts with the prefix
0m, inspired by a the money datatype in some database systems.

I almost created a separate division operator ('/128')/2 but now
the ordinary division operator (/)/2 switches to decimal128, as
soon as one of its argumemts is decimal128:

?- X is 1/3.
X = 0.3333333333333333.
?- X is 0m1/3.
X = 0m0.3333333333333333333333333333333333.

Re: Request for comments: Two types of float of integer division

<4e5b6771-ac47-49be-8762-9b7497834b43n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ae9:ed06:0:b0:6f9:efd2:9b96 with SMTP id c6-20020ae9ed06000000b006f9efd29b96mr35217662qkg.651.1667784457218;
Sun, 06 Nov 2022 17:27:37 -0800 (PST)
X-Received: by 2002:a4a:58c7:0:b0:49e:9fd1:2610 with SMTP id
f190-20020a4a58c7000000b0049e9fd12610mr7734439oob.89.1667784456960; Sun, 06
Nov 2022 17:27:36 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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, 6 Nov 2022 17:27:36 -0800 (PST)
In-Reply-To: <7c36004a-c28e-4db6-a25f-01101d10ab02n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com> <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
<b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com> <4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>
<f11a74bf-26bb-4e9f-8d87-9a69b71ccce1n@googlegroups.com> <363039a6-8bcd-4db4-95ba-9b490ffb8058n@googlegroups.com>
<7c36004a-c28e-4db6-a25f-01101d10ab02n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4e5b6771-ac47-49be-8762-9b7497834b43n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Mon, 07 Nov 2022 01:27:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3161
 by: Mostowski Collapse - Mon, 7 Nov 2022 01:27 UTC

Using a little Taylor expansion of arctan can now compute π:

?- X is pi.
X = 3.141592653589793.
?- X is pi128.
X = 0m3.141592653589793238462643383279503.

By implementing more trigonometric functions, can not only
provide them to the end-user. They also can serve as a test
case generator for ordinary float routines. I already

found an interesting test case:

/* SWI-Prolog 8.5.20 Windows */
?- X is atan(897/2048).
X = 0.4128202041682507.

/* SWI-Prolog 8.5.20 WSL2 */
?- X is atan(897/2048).
X = 0.41282020416825077.

The second result is more accurate, right?

Mostowski Collapse schrieb am Montag, 7. November 2022 um 02:26:09 UTC+1:
> Now I have added a new decimal128 datatype to my formerly
> Jekejeke Prolog system. Syntactically it starts with the prefix
> 0m, inspired by a the money datatype in some database systems.
>
> I almost created a separate division operator ('/128')/2 but now
> the ordinary division operator (/)/2 switches to decimal128, as
> soon as one of its argumemts is decimal128:
>
> ?- X is 1/3.
> X = 0.3333333333333333.
> ?- X is 0m1/3.
> X = 0m0.3333333333333333333333333333333333.

Re: Request for comments: Two types of float of integer division

<5050681e-a1a2-4de4-b177-34f7b8d2f9bbn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:692:0:b0:3a5:9196:ed40 with SMTP id f18-20020ac80692000000b003a59196ed40mr6430168qth.676.1667905761054;
Tue, 08 Nov 2022 03:09:21 -0800 (PST)
X-Received: by 2002:a05:6870:63aa:b0:13a:fe6c:5ed0 with SMTP id
t42-20020a05687063aa00b0013afe6c5ed0mr33178226oap.257.1667905760777; Tue, 08
Nov 2022 03:09:20 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Tue, 8 Nov 2022 03:09:20 -0800 (PST)
In-Reply-To: <4e5b6771-ac47-49be-8762-9b7497834b43n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com> <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
<b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com> <4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>
<f11a74bf-26bb-4e9f-8d87-9a69b71ccce1n@googlegroups.com> <363039a6-8bcd-4db4-95ba-9b490ffb8058n@googlegroups.com>
<7c36004a-c28e-4db6-a25f-01101d10ab02n@googlegroups.com> <4e5b6771-ac47-49be-8762-9b7497834b43n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5050681e-a1a2-4de4-b177-34f7b8d2f9bbn@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Tue, 08 Nov 2022 11:09:21 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3976
 by: Mostowski Collapse - Tue, 8 Nov 2022 11:09 UTC

I am currently implementing unums in pure Prolog. There is
already some progress, basic operations with HALF_EVEN
and then an atan function realization. It can be used to compute

pi, it has pre-defined the Euler formula 20*atan(1/7)+8*atan(3/79):

/* Compute pi with 53 Bit Precision*/
?- mp_pi(53, (M,E)), P is M*(2**E).
P = 3.141592653589793.

I have no clue how accurate the atan is. Unlike libBF it
doesn’t use Ziv iteration, but a dynamically estimated
fixed number of members of the Taylor expansion in a

Horner schema implementation.

Mostowski Collapse schrieb am Montag, 7. November 2022 um 02:27:38 UTC+1:
> Using a little Taylor expansion of arctan can now compute π:
>
> ?- X is pi.
> X = 3.141592653589793.
> ?- X is pi128.
> X = 0m3.141592653589793238462643383279503.
>
> By implementing more trigonometric functions, can not only
> provide them to the end-user. They also can serve as a test
> case generator for ordinary float routines. I already
>
> found an interesting test case:
> /* SWI-Prolog 8.5.20 Windows */
> ?- X is atan(897/2048).
> X = 0.4128202041682507.
> /* SWI-Prolog 8.5.20 WSL2 */
> ?- X is atan(897/2048).
> X = 0.41282020416825077.
>
> The second result is more accurate, right?
> Mostowski Collapse schrieb am Montag, 7. November 2022 um 02:26:09 UTC+1:
> > Now I have added a new decimal128 datatype to my formerly
> > Jekejeke Prolog system. Syntactically it starts with the prefix
> > 0m, inspired by a the money datatype in some database systems.
> >
> > I almost created a separate division operator ('/128')/2 but now
> > the ordinary division operator (/)/2 switches to decimal128, as
> > soon as one of its argumemts is decimal128:
> >
> > ?- X is 1/3.
> > X = 0.3333333333333333.
> > ?- X is 0m1/3.
> > X = 0m0.3333333333333333333333333333333333.

Re: Request for comments: Two types of float of integer division

<bedca824-67c5-4b04-84d2-1855f1c868cbn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:440e:b0:6f6:2a11:c497 with SMTP id v14-20020a05620a440e00b006f62a11c497mr36955293qkp.213.1667905841122;
Tue, 08 Nov 2022 03:10:41 -0800 (PST)
X-Received: by 2002:aca:ef86:0:b0:35a:33d8:84e4 with SMTP id
n128-20020acaef86000000b0035a33d884e4mr19482965oih.196.1667905840889; Tue, 08
Nov 2022 03:10:40 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Tue, 8 Nov 2022 03:10:40 -0800 (PST)
In-Reply-To: <5050681e-a1a2-4de4-b177-34f7b8d2f9bbn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.218.40.218; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 80.218.40.218
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<80a94d97-44ee-4a34-baff-64c6bf7cc272n@googlegroups.com> <98657e23-84b3-4f84-9a9c-32bf6263e8e5n@googlegroups.com>
<th4ffa$8ttm$1@solani.org> <th4fhr$8ttm$2@solani.org> <8fba7cd2-edd2-4f1d-9c19-7950726eb6c4n@googlegroups.com>
<f12fbd00-2824-4c1f-b8ca-9e6146e8ea1en@googlegroups.com> <b95f9f3f-189c-4972-bb9d-43bfa648a4aan@googlegroups.com>
<f5ce2f9a-79f7-4152-bbf1-55b4b3981644n@googlegroups.com> <cc500ca0-ba21-4917-97f8-305128a9c319n@googlegroups.com>
<b06ff665-4eb6-4a72-bad4-b71be2d420b9n@googlegroups.com> <4f2814c1-9bb2-45a8-94c9-96815fe00878n@googlegroups.com>
<f11a74bf-26bb-4e9f-8d87-9a69b71ccce1n@googlegroups.com> <363039a6-8bcd-4db4-95ba-9b490ffb8058n@googlegroups.com>
<7c36004a-c28e-4db6-a25f-01101d10ab02n@googlegroups.com> <4e5b6771-ac47-49be-8762-9b7497834b43n@googlegroups.com>
<5050681e-a1a2-4de4-b177-34f7b8d2f9bbn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bedca824-67c5-4b04-84d2-1855f1c868cbn@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Tue, 08 Nov 2022 11:10:41 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4809
 by: Mostowski Collapse - Tue, 8 Nov 2022 11:10 UTC

Here are some timings I get for SWI-Prolog and my Prolog
system using the pure Prolog arbitrary floats code:

/* Jekejeke Prolog 1.5.5 Windows JDK 1.8 */
?- time((between(1,1000,_), mp_pi(53, _), fail; true)).
% Threads 375 ms, GC 2 ms, Up 401 ms (Current 11/08/22 11:48:47)
true.

/* SWI-Prolog 8.5.20 Windows */
?- time((between(1,1000,_), mp_pi(53, _), fail; true)).
% 3,358,000 inferences, 0.391 CPU in 0.391 seconds (100% CPU, 8596480 Lips)
true.

More or less same speed. But still much slower
then any Math.atan().

Mostowski Collapse schrieb am Dienstag, 8. November 2022 um 12:09:21 UTC+1:
> I am currently implementing unums in pure Prolog. There is
> already some progress, basic operations with HALF_EVEN
> and then an atan function realization. It can be used to compute
>
> pi, it has pre-defined the Euler formula 20*atan(1/7)+8*atan(3/79):
>
> /* Compute pi with 53 Bit Precision*/
> ?- mp_pi(53, (M,E)), P is M*(2**E).
> P = 3.141592653589793.
>
> I have no clue how accurate the atan is. Unlike libBF it
> doesn’t use Ziv iteration, but a dynamically estimated
> fixed number of members of the Taylor expansion in a
>
> Horner schema implementation.
> Mostowski Collapse schrieb am Montag, 7. November 2022 um 02:27:38 UTC+1:
> > Using a little Taylor expansion of arctan can now compute π:
> >
> > ?- X is pi.
> > X = 3.141592653589793.
> > ?- X is pi128.
> > X = 0m3.141592653589793238462643383279503.
> >
> > By implementing more trigonometric functions, can not only
> > provide them to the end-user. They also can serve as a test
> > case generator for ordinary float routines. I already
> >
> > found an interesting test case:
> > /* SWI-Prolog 8.5.20 Windows */
> > ?- X is atan(897/2048).
> > X = 0.4128202041682507.
> > /* SWI-Prolog 8.5.20 WSL2 */
> > ?- X is atan(897/2048).
> > X = 0.41282020416825077.
> >
> > The second result is more accurate, right?
> > Mostowski Collapse schrieb am Montag, 7. November 2022 um 02:26:09 UTC+1:
> > > Now I have added a new decimal128 datatype to my formerly
> > > Jekejeke Prolog system. Syntactically it starts with the prefix
> > > 0m, inspired by a the money datatype in some database systems.
> > >
> > > I almost created a separate division operator ('/128')/2 but now
> > > the ordinary division operator (/)/2 switches to decimal128, as
> > > soon as one of its argumemts is decimal128:
> > >
> > > ?- X is 1/3.
> > > X = 0.3333333333333333.
> > > ?- X is 0m1/3.
> > > X = 0m0.3333333333333333333333333333333333.

Re: Request for comments: Two types of float of integer division

<b4fe1397-91ae-472c-9365-dbd8e0937f27n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:1056:b0:412:26ce:857f with SMTP id f22-20020a05622a105600b0041226ce857fmr137418qte.12.1694282986487;
Sat, 09 Sep 2023 11:09:46 -0700 (PDT)
X-Received: by 2002:a05:6a00:2d23:b0:68c:33a9:e564 with SMTP id
fa35-20020a056a002d2300b0068c33a9e564mr2165560pfb.5.1694282985851; Sat, 09
Sep 2023 11:09:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.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: Sat, 9 Sep 2023 11:09:45 -0700 (PDT)
In-Reply-To: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b4fe1397-91ae-472c-9365-dbd8e0937f27n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Sat, 09 Sep 2023 18:09:46 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2083
 by: Mild Shock - Sat, 9 Sep 2023 18:09 UTC

I am still fiddling around with (is)/2 implementation.
Formerly Jekejeke Prolog had traditionally automatic
bridging and tunneling. This is all going down the drain,

we want to become more GNU Prolog compatible. Novacore
should be as puritanical as possible, namely a Prolog core that
has an upbringing that disapproves the suggar laced world of

formerly Jekejeke Prolog! Funny discovery, not all Prolog
systems throw the same evaluable errors. Here a little
discrepancy between GNU Prolog and SWI-Prolog:

/* GNU Prolog */
?- X is append(1,2).
uncaught exception: error(type_error(evaluable,append/2),(is)/2)
?- X is append([1,2],[3]).
uncaught exception: error(type_error(evaluable,append/2),(is)/2)

/* SWI-Prolog */
?- X is append(1,2).
ERROR: Arithmetic: `append/2' is not a function
?- X is append([1,2],[3]).
ERROR: Type error: `[]' expected, found `[1,2]' (a list)
("x" must hold one character)

Re: Request for comments: Two types of float of integer division

<a6ed877b-5d7d-4404-b41c-ee58c12ba6a0n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:63c1:b0:76f:1531:aa32 with SMTP id pw1-20020a05620a63c100b0076f1531aa32mr173080qkn.7.1694283180820;
Sat, 09 Sep 2023 11:13:00 -0700 (PDT)
X-Received: by 2002:a17:902:f38a:b0:1b7:c944:edd4 with SMTP id
f10-20020a170902f38a00b001b7c944edd4mr1844942ple.2.1694283180582; Sat, 09 Sep
2023 11:13:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.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: Sat, 9 Sep 2023 11:13:00 -0700 (PDT)
In-Reply-To: <b4fe1397-91ae-472c-9365-dbd8e0937f27n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com> <b4fe1397-91ae-472c-9365-dbd8e0937f27n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a6ed877b-5d7d-4404-b41c-ee58c12ba6a0n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Sat, 09 Sep 2023 18:13:00 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3096
 by: Mild Shock - Sat, 9 Sep 2023 18:13 UTC

My newest take in formerly Jekejeke Prolog and Dogelog
Player, now behaving the same for this test case. This
is a preview, these versions have not yet been officially released:

/* Jekejeke Prolog, 1.6.3 */
?- X is append(1,2).
Error: Argument should have evaluable functor, found append/2.
?- X is append([1,2],[3]).
Error: Argument should have evaluable functor, found append/2.

/* Dogelog Player, 1.1.1, nodeJS */
?- X is append(1,2).
Error: Argument should have evaluable functor, found append/2.
?- X is append([1,2],[3]).
Error: Argument should have evaluable functor, found append/2.

/* Dogelog Player, 1.1.1, PyPy */
?- X is append(1,2).
Error: Argument should have evaluable functor, found append/2.
?- X is append([1,2],[3]).
Error: Argument should have evaluable functor, found append/2.

Mild Shock schrieb am Samstag, 9. September 2023 um 20:09:47 UTC+2:
> I am still fiddling around with (is)/2 implementation.
> Formerly Jekejeke Prolog had traditionally automatic
> bridging and tunneling. This is all going down the drain,
>
> we want to become more GNU Prolog compatible. Novacore
> should be as puritanical as possible, namely a Prolog core that
> has an upbringing that disapproves the suggar laced world of
>
> formerly Jekejeke Prolog! Funny discovery, not all Prolog
> systems throw the same evaluable errors. Here a little
> discrepancy between GNU Prolog and SWI-Prolog:
>
> /* GNU Prolog */
> ?- X is append(1,2).
> uncaught exception: error(type_error(evaluable,append/2),(is)/2)
> ?- X is append([1,2],[3]).
> uncaught exception: error(type_error(evaluable,append/2),(is)/2)
>
> /* SWI-Prolog */
> ?- X is append(1,2).
> ERROR: Arithmetic: `append/2' is not a function
> ?- X is append([1,2],[3]).
> ERROR: Type error: `[]' expected, found `[1,2]' (a list)
> ("x" must hold one character)

Re: Request for comments: Two types of float of integer division

<5848823c-8c71-4d67-8dc0-42a72aaa95acn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:5bc6:0:b0:410:a249:bee5 with SMTP id b6-20020ac85bc6000000b00410a249bee5mr120408qtb.9.1694290632334;
Sat, 09 Sep 2023 13:17:12 -0700 (PDT)
X-Received: by 2002:a63:7311:0:b0:564:c506:bcf1 with SMTP id
o17-20020a637311000000b00564c506bcf1mr1201337pgc.4.1694290631532; Sat, 09 Sep
2023 13:17:11 -0700 (PDT)
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: Sat, 9 Sep 2023 13:17:11 -0700 (PDT)
In-Reply-To: <a6ed877b-5d7d-4404-b41c-ee58c12ba6a0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<b4fe1397-91ae-472c-9365-dbd8e0937f27n@googlegroups.com> <a6ed877b-5d7d-4404-b41c-ee58c12ba6a0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5848823c-8c71-4d67-8dc0-42a72aaa95acn@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Sat, 09 Sep 2023 20:17:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Mild Shock - Sat, 9 Sep 2023 20:17 UTC

I started using this test case:

test :-
between(0,1000000,N),
_ is exp(1+N/1000000),
fail.
test.

To test a new Java foreign function interface. I then
observed that SWI-Prolog stack engine causes
a little overhead:

/* SWI-Prolog, 9.1.14, optimise=false */
?- time(test).
% 2,000,001 inferences, 0.313 CPU in 0.315 seconds
(99% CPU, 6400003 Lips)
true.

/* SWI-Prolog, 9.1.14, optimise=true */
?- time(test).
% 1,000,002 inferences, 0.172 CPU in 0.176 seconds
(98% CPU, 5818193 Lips)
true.

Intrestingly GNU Prolog doesn’t use a stack engine,
just relies on the native stack. Its quite speedy without
any optimisation:

/* GNU Prolog 1.5.0 (64 bits) */
?- test.
(125 ms) yes

Re: Request for comments: Two types of float of integer division

<f3083699-800d-45c6-b622-cea67bac91fbn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:6214:18f0:b0:63d:a43:7b06 with SMTP id ep16-20020a05621418f000b0063d0a437b06mr122081qvb.9.1694290700088;
Sat, 09 Sep 2023 13:18:20 -0700 (PDT)
X-Received: by 2002:a63:9313:0:b0:569:450d:cf3d with SMTP id
b19-20020a639313000000b00569450dcf3dmr1187877pge.6.1694290699603; Sat, 09 Sep
2023 13:18:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.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: Sat, 9 Sep 2023 13:18:19 -0700 (PDT)
In-Reply-To: <5848823c-8c71-4d67-8dc0-42a72aaa95acn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<b4fe1397-91ae-472c-9365-dbd8e0937f27n@googlegroups.com> <a6ed877b-5d7d-4404-b41c-ee58c12ba6a0n@googlegroups.com>
<5848823c-8c71-4d67-8dc0-42a72aaa95acn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f3083699-800d-45c6-b622-cea67bac91fbn@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Sat, 09 Sep 2023 20:18:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3320
 by: Mild Shock - Sat, 9 Sep 2023 20:18 UTC

The internal call is tail recursive I guess, since the functor is
already checked, and a looked up handle, a function pointer,
causes the evaluation. Recently GNU Prolog has moved to GitHub,

so I can find the source code of GNU Prolog stuff more easily, things
like Load_Math_Expression. But I think the GNU Prolog approach is
only feasible, if you dare to rely on the native stack.

Concerning the new Java foreign function interface. I switched
from handles obtained by method reflection to handles that were
populated via functional interfaces. Its an itch faster, and close

to SWI-Prolog optimised, but only for JDK 8:

/* Jekejeke Prolog, 1.6.3, JDK 8, Functional Interface */
?- time(test).
% Time 171 ms, GC 2 ms, Wall 09/09/2023 22:04
true.

The above uses the native stack like GNU Prolog and no
cycle testing nothing. But I guess it burns CPU since it uses
two pointers to represent a term. I hope I can soon get rid of that.

Another brake could be the varargs array allocation.

Mild Shock schrieb am Samstag, 9. September 2023 um 22:17:13 UTC+2:
> I started using this test case:
>
> test :-
> between(0,1000000,N),
> _ is exp(1+N/1000000),
> fail.
> test.
>
> To test a new Java foreign function interface. I then
> observed that SWI-Prolog stack engine causes
> a little overhead:
>
> /* SWI-Prolog, 9.1.14, optimise=false */
> ?- time(test).
> % 2,000,001 inferences, 0.313 CPU in 0.315 seconds
> (99% CPU, 6400003 Lips)
> true.
>
> /* SWI-Prolog, 9.1.14, optimise=true */
> ?- time(test).
> % 1,000,002 inferences, 0.172 CPU in 0.176 seconds
> (98% CPU, 5818193 Lips)
> true.
>
> Intrestingly GNU Prolog doesn’t use a stack engine,
> just relies on the native stack. Its quite speedy without
> any optimisation:
>
> /* GNU Prolog 1.5.0 (64 bits) */
> ?- test.
> (125 ms) yes

Re: Request for comments: Two types of float of integer division

<02c12d31-31dd-436d-b3ac-26379ccc6522n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:5ed6:0:b0:412:7ea:37c9 with SMTP id s22-20020ac85ed6000000b0041207ea37c9mr287934qtx.5.1694382353958;
Sun, 10 Sep 2023 14:45:53 -0700 (PDT)
X-Received: by 2002:a63:921e:0:b0:566:1c6:139b with SMTP id
o30-20020a63921e000000b0056601c6139bmr1726254pgd.8.1694382353486; Sun, 10 Sep
2023 14:45:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.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, 10 Sep 2023 14:45:52 -0700 (PDT)
In-Reply-To: <f3083699-800d-45c6-b622-cea67bac91fbn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<b4fe1397-91ae-472c-9365-dbd8e0937f27n@googlegroups.com> <a6ed877b-5d7d-4404-b41c-ee58c12ba6a0n@googlegroups.com>
<5848823c-8c71-4d67-8dc0-42a72aaa95acn@googlegroups.com> <f3083699-800d-45c6-b622-cea67bac91fbn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <02c12d31-31dd-436d-b3ac-26379ccc6522n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Sun, 10 Sep 2023 21:45:53 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4340
 by: Mild Shock - Sun, 10 Sep 2023 21:45 UTC

Ok there is a big confusion in SWI-Prolog discourse, I was
mentioning native stack, and people think I was talking
about native code. Holy cow! Do I speak chinese, or what?

Just look for yourself. Step 1: Go to GNU Prolog GitHub,
Step 2: Lookup the C function Load_Math_Expression
Interesting find, for Dogelog Player on CPython so far:

/* Dogelog Player 1.1.1, CPython */
?- X=1+X, Y is X.
Unknown exception: 'maximum recursion depth exceeded'

What does PyPy do? What does JavaScript do? How do we
handle this exception. Are there more candidates than only (is)/2,
like for example copy_term/2, etc.. This would cover Dogelog

Player. What about formerly Jekejeke Prolog, respectively Java?

Mild Shock schrieb am Samstag, 9. September 2023 um 22:18:21 UTC+2:
> The internal call is tail recursive I guess, since the functor is
> already checked, and a looked up handle, a function pointer,
> causes the evaluation. Recently GNU Prolog has moved to GitHub,
>
> so I can find the source code of GNU Prolog stuff more easily, things
> like Load_Math_Expression. But I think the GNU Prolog approach is
> only feasible, if you dare to rely on the native stack.
>
> Concerning the new Java foreign function interface. I switched
> from handles obtained by method reflection to handles that were
> populated via functional interfaces. Its an itch faster, and close
>
> to SWI-Prolog optimised, but only for JDK 8:
>
> /* Jekejeke Prolog, 1.6.3, JDK 8, Functional Interface */
> ?- time(test).
> % Time 171 ms, GC 2 ms, Wall 09/09/2023 22:04
> true.
>
> The above uses the native stack like GNU Prolog and no
> cycle testing nothing. But I guess it burns CPU since it uses
> two pointers to represent a term. I hope I can soon get rid of that.
>
> Another brake could be the varargs array allocation.
> Mild Shock schrieb am Samstag, 9. September 2023 um 22:17:13 UTC+2:
> > I started using this test case:
> >
> > test :-
> > between(0,1000000,N),
> > _ is exp(1+N/1000000),
> > fail.
> > test.
> >
> > To test a new Java foreign function interface. I then
> > observed that SWI-Prolog stack engine causes
> > a little overhead:
> >
> > /* SWI-Prolog, 9.1.14, optimise=false */
> > ?- time(test).
> > % 2,000,001 inferences, 0.313 CPU in 0.315 seconds
> > (99% CPU, 6400003 Lips)
> > true.
> >
> > /* SWI-Prolog, 9.1.14, optimise=true */
> > ?- time(test).
> > % 1,000,002 inferences, 0.172 CPU in 0.176 seconds
> > (98% CPU, 5818193 Lips)
> > true.
> >
> > Intrestingly GNU Prolog doesn’t use a stack engine,
> > just relies on the native stack. Its quite speedy without
> > any optimisation:
> >
> > /* GNU Prolog 1.5.0 (64 bits) */
> > ?- test.
> > (125 ms) yes

Re: Request for comments: Two types of float of integer division

<9adc813b-8b5b-4e4e-a823-f7d6af5c6e57n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:6214:1914:b0:655:afc1:e9b1 with SMTP id er20-20020a056214191400b00655afc1e9b1mr233104qvb.1.1694467907791;
Mon, 11 Sep 2023 14:31:47 -0700 (PDT)
X-Received: by 2002:a17:902:db05:b0:1c2:c60:839d with SMTP id
m5-20020a170902db0500b001c20c60839dmr4661580plx.8.1694467907498; Mon, 11 Sep
2023 14:31:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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, 11 Sep 2023 14:31:47 -0700 (PDT)
In-Reply-To: <02c12d31-31dd-436d-b3ac-26379ccc6522n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
References: <616590d2-4927-4f60-ba91-acef849695a3n@googlegroups.com>
<b4fe1397-91ae-472c-9365-dbd8e0937f27n@googlegroups.com> <a6ed877b-5d7d-4404-b41c-ee58c12ba6a0n@googlegroups.com>
<5848823c-8c71-4d67-8dc0-42a72aaa95acn@googlegroups.com> <f3083699-800d-45c6-b622-cea67bac91fbn@googlegroups.com>
<02c12d31-31dd-436d-b3ac-26379ccc6522n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9adc813b-8b5b-4e4e-a823-f7d6af5c6e57n@googlegroups.com>
Subject: Re: Request for comments: Two types of float of integer division
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 11 Sep 2023 21:31:47 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5581
 by: Mild Shock - Mon, 11 Sep 2023 21:31 UTC

Is there any use case for the cycle check? It gives an error more earlier.
If one has a resource quota, one would also get an error only a little bit
later, when the stack is to large and some memory is exhausted.

Here is a sketch of a post mortem analysis, even written in 100%
pure Prolog, which gives an error analysis service:

X is Y :-
catch(eval(Y,X), error(foo,_),
(acyclic_term(Y) -> throw(error(bar,_)); throw(error(baz,_)))).

The single error “foo” produced by the internal eval/2 predicate
is changed into either an error “bar” or an error “baz”, to provide the
end-user some more information. Can be also implemented

natively by the builtin is/2, making a cycle test during eval/2
unnecessary, since acyclic_term/1 exists. Or is there a danger
that acyclic_term/1 crashes? It probably uses less stack than eval/2.

Mild Shock schrieb am Sonntag, 10. September 2023 um 23:45:55 UTC+2:
> Ok there is a big confusion in SWI-Prolog discourse, I was
> mentioning native stack, and people think I was talking
> about native code. Holy cow! Do I speak chinese, or what?
>
> Just look for yourself. Step 1: Go to GNU Prolog GitHub,
> Step 2: Lookup the C function Load_Math_Expression
> Interesting find, for Dogelog Player on CPython so far:
>
> /* Dogelog Player 1.1.1, CPython */
> ?- X=1+X, Y is X.
> Unknown exception: 'maximum recursion depth exceeded'
>
> What does PyPy do? What does JavaScript do? How do we
> handle this exception. Are there more candidates than only (is)/2,
> like for example copy_term/2, etc.. This would cover Dogelog
>
> Player. What about formerly Jekejeke Prolog, respectively Java?
> Mild Shock schrieb am Samstag, 9. September 2023 um 22:18:21 UTC+2:
> > The internal call is tail recursive I guess, since the functor is
> > already checked, and a looked up handle, a function pointer,
> > causes the evaluation. Recently GNU Prolog has moved to GitHub,
> >
> > so I can find the source code of GNU Prolog stuff more easily, things
> > like Load_Math_Expression. But I think the GNU Prolog approach is
> > only feasible, if you dare to rely on the native stack.
> >
> > Concerning the new Java foreign function interface. I switched
> > from handles obtained by method reflection to handles that were
> > populated via functional interfaces. Its an itch faster, and close
> >
> > to SWI-Prolog optimised, but only for JDK 8:
> >
> > /* Jekejeke Prolog, 1.6.3, JDK 8, Functional Interface */
> > ?- time(test).
> > % Time 171 ms, GC 2 ms, Wall 09/09/2023 22:04
> > true.
> >
> > The above uses the native stack like GNU Prolog and no
> > cycle testing nothing. But I guess it burns CPU since it uses
> > two pointers to represent a term. I hope I can soon get rid of that.
> >
> > Another brake could be the varargs array allocation.
> > Mild Shock schrieb am Samstag, 9. September 2023 um 22:17:13 UTC+2:
> > > I started using this test case:
> > >
> > > test :-
> > > between(0,1000000,N),
> > > _ is exp(1+N/1000000),
> > > fail.
> > > test.
> > >
> > > To test a new Java foreign function interface. I then
> > > observed that SWI-Prolog stack engine causes
> > > a little overhead:
> > >
> > > /* SWI-Prolog, 9.1.14, optimise=false */
> > > ?- time(test).
> > > % 2,000,001 inferences, 0.313 CPU in 0.315 seconds
> > > (99% CPU, 6400003 Lips)
> > > true.
> > >
> > > /* SWI-Prolog, 9.1.14, optimise=true */
> > > ?- time(test).
> > > % 1,000,002 inferences, 0.172 CPU in 0.176 seconds
> > > (98% CPU, 5818193 Lips)
> > > true.
> > >
> > > Intrestingly GNU Prolog doesn’t use a stack engine,
> > > just relies on the native stack. Its quite speedy without
> > > any optimisation:
> > >
> > > /* GNU Prolog 1.5.0 (64 bits) */
> > > ?- test.
> > > (125 ms) yes

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor