Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Xerox never comes up with anything original.


devel / comp.lang.prolog / Re: comparing infinite terms

SubjectAuthor
* comparing infinite termsMostowski Collapse
`* comparing infinite termsMostowski Collapse
 `* comparing infinite termsMostowski Collapse
  `* comparing infinite termsMostowski Collapse
   `* comparing infinite termsMostowski Collapse
    `* comparing infinite termsMostowski Collapse
     +- comparing infinite termsMostowski Collapse
     `* comparing infinite termsMostowski Collapse
      `* comparing infinite termsMostowski Collapse
       `* comparing infinite termsMostowski Collapse
        `* comparing infinite termsMostowski Collapse
         `* comparing infinite termsMostowski Collapse
          `- comparing infinite termsMostowski Collapse

1
Re: comparing infinite terms

<95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1933&group=comp.lang.prolog#1933

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:6214:18ec:b0:5ad:e0b4:9003 with SMTP id ep12-20020a05621418ec00b005ade0b49003mr792935qvb.2.1679500290847;
Wed, 22 Mar 2023 08:51:30 -0700 (PDT)
X-Received: by 2002:a05:6902:168d:b0:aa9:bd2e:3746 with SMTP id
bx13-20020a056902168d00b00aa9bd2e3746mr158236ybb.4.1679500290518; Wed, 22 Mar
2023 08:51:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!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: Wed, 22 Mar 2023 08:51:30 -0700 (PDT)
In-Reply-To: <u8ispas4jsi.fsf@brigitte.csd.uu.se>#1/1>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se>#1/1>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Wed, 22 Mar 2023 15:51:30 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3122
 by: Mostowski Collapse - Wed, 22 Mar 2023 15:51 UTC

This never gets old, especially since even seasoned Prologers
might not be aware of it. But it made it even into Prolog system
documentation, like here:

"Please note : the standard order is only well-defined for finite (acyclic) terms.
There are infinite (cyclic) terms for which no order relation holds."
https://sicstus.sics.se/sicstus/docs/3.12.11/html/sicstus/Term-Compare.html

And here is a funny disagreement between two Prolog systems,
an old lady (SWI-Prolog) and a youngster (Scryer Prolog):

/* SWI-Prolog 9.1.7 */
?- X=f(X,a(X)), Y=f(Y,b(Y)), Z=f(Y,c(Y)),
compare(A,X,Y), compare(B,Y,Z), compare(C,X,Z).
A = B, B = (<),
C = (>).

/* Scryer Prolog 0.9.1-194 */
?- X=f(X,a(X)), Y=f(Y,b(Y)), Z=f(Y,c(Y)),
compare(A,X,Y), compare(B,Y,Z), compare(C,X,Z).
A = (<), B = (<), C = (<).

Mats Carlsson schrieb am Dienstag, 16. Juli 1996 um 09:00:00 UTC+2:
> In the '80s, Alain Comerauer, Joxan Jaffar and others published
> algorithms for unification without occurs check that could work
> with infinite (cyclic) terms with termination guaranteed.
> Until yesterday, I always believed that the standard total order for
> finite Prolog terms readily extended to include infinite terms as
> well. However, the following example shows two terms that can't be
> ordered.
> Consider the terms A and B defined by the equations
> [1] A = s(B,0).
> [2] B = s(A,1).
> Clearly, A and B are not identical, so is A @< B or A @> B?
> Assume A @< B. But then s(A,1) @< s(B,0) i.e. B @< A. Contradiction.
> Assume A @> B. But then s(A,1) @> s(B,0) i.e. B @> A. Contradiction.
> So the standard order of Prolog terms cannot include (some) infinite
> terms. On reflection, the same is true for the integers---infinity
> minus infinity is not defined.
> Perhaps this is all obvious, but I was a bit jarred at first.
> Mats Carlsson, PhD
> Computing Science Department tel: +46 18 187691
> Uppsala University fax: +46 18 511925
> P.O. Box 311 Email: m...@csd.uu.se
> S-751 05 Uppsala, Sweden

Re: comparing infinite terms

<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1938&group=comp.lang.prolog#1938

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:a18:b0:746:7f12:f2f3 with SMTP id i24-20020a05620a0a1800b007467f12f2f3mr2051439qka.13.1679833617957;
Sun, 26 Mar 2023 05:26:57 -0700 (PDT)
X-Received: by 2002:a81:ac67:0:b0:544:9421:45fd with SMTP id
z39-20020a81ac67000000b00544942145fdmr3596392ywj.6.1679833617588; Sun, 26 Mar
2023 05:26:57 -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: Sun, 26 Mar 2023 05:26:57 -0700 (PDT)
In-Reply-To: <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sun, 26 Mar 2023 12:26:57 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4453
 by: Mostowski Collapse - Sun, 26 Mar 2023 12:26 UTC

Hurray, I found a new counter example, derived from
my X,Y,Z tripple. This is a counter example for unstable
keysort, using @ridgeworks new_compare/2.

Lets define unstable_keysort/2 as follows:

unstable_keysort(L, R) :- predsort(new_compare, L, R).

I can now use unstable_keysort/2 and as expected and
useful for setof/3 implementation, it gives me ascending
order of the values for equal keys:

?- unstable_keysort([x-3,x-1,x-2,x-1], L).
L = [x-1, x-2, x-3].

?- predsort(new_compare, [3,1,2,1], L).
L = [1, 2, 3].

Now using the new counter example. The key X is such
that it mimics a pair, confusing acyclic_rep/2 inside
new_compare/2. It breaks the ascending order property:

?- X=(X-b(X)), unstable_keysort([X-b(X), X-a(X)], L).
X = X-b(X),
L = [X-b(X), X-a(X)].

?- X=(X-b(X)), predsort(new_compare, [b(X), a(X)], L).
X = X-b(X),
L = [a(X), b(X)].

Mostowski Collapse schrieb am Mittwoch, 22. März 2023 um 16:51:31 UTC+1:
> This never gets old, especially since even seasoned Prologers
> might not be aware of it. But it made it even into Prolog system
> documentation, like here:
>
> "Please note : the standard order is only well-defined for finite (acyclic) terms.
> There are infinite (cyclic) terms for which no order relation holds."
> https://sicstus.sics.se/sicstus/docs/3.12.11/html/sicstus/Term-Compare.html
>
> And here is a funny disagreement between two Prolog systems,
> an old lady (SWI-Prolog) and a youngster (Scryer Prolog):
>
> /* SWI-Prolog 9.1.7 */
> ?- X=f(X,a(X)), Y=f(Y,b(Y)), Z=f(Y,c(Y)),
> compare(A,X,Y), compare(B,Y,Z), compare(C,X,Z).
> A = B, B = (<),
> C = (>).
>
> /* Scryer Prolog 0.9.1-194 */
> ?- X=f(X,a(X)), Y=f(Y,b(Y)), Z=f(Y,c(Y)),
> compare(A,X,Y), compare(B,Y,Z), compare(C,X,Z).
> A = (<), B = (<), C = (<).
>
> Mats Carlsson schrieb am Dienstag, 16. Juli 1996 um 09:00:00 UTC+2:
> > In the '80s, Alain Comerauer, Joxan Jaffar and others published
> > algorithms for unification without occurs check that could work
> > with infinite (cyclic) terms with termination guaranteed.
> > Until yesterday, I always believed that the standard total order for
> > finite Prolog terms readily extended to include infinite terms as
> > well. However, the following example shows two terms that can't be
> > ordered.
> > Consider the terms A and B defined by the equations
> > [1] A = s(B,0).
> > [2] B = s(A,1).
> > Clearly, A and B are not identical, so is A @< B or A @> B?
> > Assume A @< B. But then s(A,1) @< s(B,0) i.e. B @< A. Contradiction.
> > Assume A @> B. But then s(A,1) @> s(B,0) i.e. B @> A. Contradiction.
> > So the standard order of Prolog terms cannot include (some) infinite
> > terms. On reflection, the same is true for the integers---infinity
> > minus infinity is not defined.
> > Perhaps this is all obvious, but I was a bit jarred at first.
> > Mats Carlsson, PhD
> > Computing Science Department tel: +46 18 187691
> > Uppsala University fax: +46 18 511925
> > P.O. Box 311 Email: m...@csd.uu.se
> > S-751 05 Uppsala, Sweden

Re: comparing infinite terms

<6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1944&group=comp.lang.prolog#1944

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a37:684b:0:b0:74a:505:b64 with SMTP id d72-20020a37684b000000b0074a05050b64mr1310882qkc.12.1680215546144;
Thu, 30 Mar 2023 15:32:26 -0700 (PDT)
X-Received: by 2002:a05:6902:102b:b0:b6c:48c3:3c1c with SMTP id
x11-20020a056902102b00b00b6c48c33c1cmr17063801ybt.13.1680215545885; Thu, 30
Mar 2023 15:32:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!peer01.ams4!peer.am4.highwinds-media.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: Thu, 30 Mar 2023 15:32:25 -0700 (PDT)
In-Reply-To: <45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Thu, 30 Mar 2023 22:32:26 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2105
 by: Mostowski Collapse - Thu, 30 Mar 2023 22:32 UTC

Here is a formal proof of Matt Carlsons counter example.
Wiithout loss of generality its enough to handle the case
Lab, although Matt Carlson mentioned both proofs:

/* Lexical Ordering */
∀x∀y∀z∀t(Ls(x,y)s(z,t) ↔ (Lxz ∨ (x=z ∧ Lyt))),

/* Example A,B satisfies A @< B and ~(B @< A) */
Lab, ¬Lba,

/* Example A,B is A=s(B,c) and B=s(A,d), proof works for any c,d */
a=s(b,c), b=s(a,d)

/* We can derive a Contradiction */
entails p∧¬p.
https://www.umsu.de/trees/#~6x~6y~6z~6t(Ls(x,y)s(z,t)~4Lxz~2(x=z~1Lyt)),Lab,~3Lba,a=s(b,c),b=s(a,d)

The consistency means unless hell freezes over,
we can never find a less than relationship L.

Re: comparing infinite terms

<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1945&group=comp.lang.prolog#1945

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:1a0d:b0:3e3:9041:3f6c with SMTP id f13-20020a05622a1a0d00b003e390413f6cmr9758418qtb.11.1680215606730;
Thu, 30 Mar 2023 15:33:26 -0700 (PDT)
X-Received: by 2002:a05:6902:1545:b0:b75:8ac3:d5dc with SMTP id
r5-20020a056902154500b00b758ac3d5dcmr16368353ybu.2.1680215606442; Thu, 30 Mar
2023 15:33:26 -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: Thu, 30 Mar 2023 15:33:26 -0700 (PDT)
In-Reply-To: <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Thu, 30 Mar 2023 22:33:26 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Mostowski Collapse - Thu, 30 Mar 2023 22:33 UTC

Corr.:

The inconsistency means unless hell freezes over,
we can never find a less than relationship L.

Mostowski Collapse schrieb am Freitag, 31. März 2023 um 00:32:28 UTC+2:
> Here is a formal proof of Matt Carlsons counter example.
> Wiithout loss of generality its enough to handle the case
> Lab, although Matt Carlson mentioned both proofs:
>
> /* Lexical Ordering */
> ∀x∀y∀z∀t(Ls(x,y)s(z,t) ↔ (Lxz ∨ (x=z ∧ Lyt))),
>
> /* Example A,B satisfies A @< B and ~(B @< A) */
> Lab, ¬Lba,
>
> /* Example A,B is A=s(B,c) and B=s(A,d), proof works for any c,d */
> a=s(b,c), b=s(a,d)
>
> /* We can derive a Contradiction */
> entails p∧¬p.
> https://www.umsu.de/trees/#~6x~6y~6z~6t(Ls(x,y)s(z,t)~4Lxz~2(x=z~1Lyt)),Lab,~3Lba,a=s(b,c),b=s(a,d)
>
> The consistency means unless hell freezes over,
> we can never find a less than relationship L.

Re: comparing infinite terms

<d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1946&group=comp.lang.prolog#1946

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a37:6552:0:b0:746:9411:4c18 with SMTP id z79-20020a376552000000b0074694114c18mr6124902qkb.5.1680215842632;
Thu, 30 Mar 2023 15:37:22 -0700 (PDT)
X-Received: by 2002:a05:6902:1181:b0:b6c:2224:8a77 with SMTP id
m1-20020a056902118100b00b6c22248a77mr16704753ybu.1.1680215842290; Thu, 30 Mar
2023 15:37:22 -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: Thu, 30 Mar 2023 15:37:22 -0700 (PDT)
In-Reply-To: <b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Thu, 30 Mar 2023 22:37:22 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Mostowski Collapse - Thu, 30 Mar 2023 22:37 UTC

Link of the proof:
https://www.umsu.de/trees/#~6x~6y~6z~6t(Ls(x,y)s(z,t)~4Lxz~2(x=z~1Lyt)),Lab,~3Lba,a=s(b,c),b=s(a,d)|=p~1~3p

Got somehow cropped, hope this one works now?

Mostowski Collapse schrieb am Freitag, 31. März 2023 um 00:33:27 UTC+2:
> Corr.:
>
> The inconsistency means unless hell freezes over,
> we can never find a less than relationship L.
> Mostowski Collapse schrieb am Freitag, 31. März 2023 um 00:32:28 UTC+2:
> > Here is a formal proof of Matt Carlsons counter example.
> > Wiithout loss of generality its enough to handle the case
> > Lab, although Matt Carlson mentioned both proofs:
> >
> > /* Lexical Ordering */
> > ∀x∀y∀z∀t(Ls(x,y)s(z,t) ↔ (Lxz ∨ (x=z ∧ Lyt))),
> >
> > /* Example A,B satisfies A @< B and ~(B @< A) */
> > Lab, ¬Lba,
> >
> > /* Example A,B is A=s(B,c) and B=s(A,d), proof works for any c,d */
> > a=s(b,c), b=s(a,d)
> >
> > /* We can derive a Contradiction */
> > entails p∧¬p.
> > https://www.umsu.de/trees/#~6x~6y~6z~6t(Ls(x,y)s(z,t)~4Lxz~2(x=z~1Lyt)),Lab,~3Lba,a=s(b,c),b=s(a,d)
> >
> > The consistency means unless hell freezes over,
> > we can never find a less than relationship L.

Re: comparing infinite terms

<d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1947&group=comp.lang.prolog#1947

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:6214:aad:b0:56f:605:dc88 with SMTP id ew13-20020a0562140aad00b0056f0605dc88mr4956376qvb.7.1680296934149;
Fri, 31 Mar 2023 14:08:54 -0700 (PDT)
X-Received: by 2002:a25:d0d0:0:b0:b6e:b924:b96f with SMTP id
h199-20020a25d0d0000000b00b6eb924b96fmr6969990ybg.3.1680296933824; Fri, 31
Mar 2023 14:08: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: Fri, 31 Mar 2023 14:08:53 -0700 (PDT)
In-Reply-To: <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com> <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Fri, 31 Mar 2023 21:08:54 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2325
 by: Mostowski Collapse - Fri, 31 Mar 2023 21:08 UTC

Here is a relatively cheap compare for cyclic terms that satisfies the
laws, except lexical order. It is based on the idea to define:

S @<' T :<=> rep(S) @< rep(T)
The only requirement to the function rep is that it is injective,
then the laws, except for lexical order, are automatically satisfied.
The proof is not so difficult. Here is an example proof, showing

irreflexivity of @<’ based on irreflexivity of @<:

/* I am using r for the function rep,
R for the relation @<' and L for the relation @< */
/* Injectivity */
∀x∀y(r(x)=r(y) → x=y),

/* Bootstrapping */
∀x∀y(Rxy ↔ Lr(x)r(y)),

/* Irreflexivity */
∀x¬Lxx

/* Irreflexivity */
entails ∀x¬Rxx.

https://www.umsu.de/trees/#~6x~6y(r(x)=r(y)~5x=y),~6x~6y(Rxy~4Lr(x)r(y)),~6x(~3Lxx)%7C=~6x(~3Rxx)

Re: comparing infinite terms

<abc09183-f44c-44b2-a191-18582b08e09fn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1948&group=comp.lang.prolog#1948

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:88:b0:3e3:8455:f307 with SMTP id o8-20020a05622a008800b003e38455f307mr10668764qtw.1.1680297014909;
Fri, 31 Mar 2023 14:10:14 -0700 (PDT)
X-Received: by 2002:a05:6902:188f:b0:b78:bced:2e3d with SMTP id
cj15-20020a056902188f00b00b78bced2e3dmr16775540ybb.3.1680297014663; Fri, 31
Mar 2023 14:10:14 -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: Fri, 31 Mar 2023 14:10:14 -0700 (PDT)
In-Reply-To: <d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com> <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
<d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <abc09183-f44c-44b2-a191-18582b08e09fn@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Fri, 31 Mar 2023 21:10:14 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Mostowski Collapse - Fri, 31 Mar 2023 21:10 UTC

Here is a suggestion:

rep(X, Y-Z) :-
term_factorized(X, Y, Z),
numberassoc(Z, 0).

numberassoc([], _).
numberassoc(['$VAR'(N)=_|L], N) :-
M is N+1,
numberassoc(L, M).

And then the comparator:

rep_compare(C, X, Y) :-
rep(X, A), rep(Y, B),
compare(C, A, B).

Any bugs? It requires that term_factorized/3 is stable and it works
only for terms that don’t have already ‘$VAR’/1 in it. Might need to
use something else, but with ‘$VAR’/1 rep/2 can be easily inspected.

Mostowski Collapse schrieb am Freitag, 31. März 2023 um 23:08:55 UTC+2:
> Here is a relatively cheap compare for cyclic terms that satisfies the
> laws, except lexical order. It is based on the idea to define:
>
> S @<' T :<=> rep(S) @< rep(T)
> The only requirement to the function rep is that it is injective,
> then the laws, except for lexical order, are automatically satisfied.
> The proof is not so difficult. Here is an example proof, showing
>
> irreflexivity of @<’ based on irreflexivity of @<:
>
> /* I am using r for the function rep,
> R for the relation @<' and L for the relation @< */
> /* Injectivity */
> ∀x∀y(r(x)=r(y) → x=y),
>
> /* Bootstrapping */
> ∀x∀y(Rxy ↔ Lr(x)r(y)),
>
> /* Irreflexivity */
> ∀x¬Lxx
>
> /* Irreflexivity */
> entails ∀x¬Rxx.
>
> https://www.umsu.de/trees/#~6x~6y(r(x)=r(y)~5x=y),~6x~6y(Rxy~4Lr(x)r(y)),~6x(~3Lxx)%7C=~6x(~3Rxx)

Re: comparing infinite terms

<c4b1f559-aed0-4cd5-a94d-51b2af1ef5f4n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1949&group=comp.lang.prolog#1949

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:7e5:b0:74a:18e:3a6c with SMTP id k5-20020a05620a07e500b0074a018e3a6cmr2413102qkk.0.1680297057569;
Fri, 31 Mar 2023 14:10:57 -0700 (PDT)
X-Received: by 2002:a81:e405:0:b0:544:d5ce:eb33 with SMTP id
r5-20020a81e405000000b00544d5ceeb33mr13518074ywl.8.1680297057286; Fri, 31 Mar
2023 14:10:57 -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: Fri, 31 Mar 2023 14:10:57 -0700 (PDT)
In-Reply-To: <d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com> <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
<d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c4b1f559-aed0-4cd5-a94d-51b2af1ef5f4n@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Fri, 31 Mar 2023 21:10:57 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3156
 by: Mostowski Collapse - Fri, 31 Mar 2023 21:10 UTC

Here is a sort example, the Matt Carlsson pairs can be easily sorted:

?- A=(B,0), B=(A,1), predsort(rep_compare, [A,B], X),
term_factorized(X, P, Q).
P = [_A, _B],
Q = [_B=(_A, 0), _A=(_B, 1)].

?- A=(B,0), B=((B,0),1), predsort(rep_compare, [B,A], X),
term_factorized(X, P, Q).
P = [_A, _B],
Q = [_B=(_A, 0), _A=(_B, 1)].

And the tripple X,Y,Z that has a bug in native compare/3, the bug is gone:

?- X=f(X,a(X)), Y=f(Y,b(Y)), Z=f(Y,c(Y)),
rep_compare(A,X,Y), rep_compare(B,Y,Z), rep_compare(C,X,Z).
A = B, B = C, C = (<)

Mostowski Collapse schrieb am Freitag, 31. März 2023 um 23:08:55 UTC+2:
> Here is a relatively cheap compare for cyclic terms that satisfies the
> laws, except lexical order. It is based on the idea to define:
>
> S @<' T :<=> rep(S) @< rep(T)
> The only requirement to the function rep is that it is injective,
> then the laws, except for lexical order, are automatically satisfied.
> The proof is not so difficult. Here is an example proof, showing
>
> irreflexivity of @<’ based on irreflexivity of @<:
>
> /* I am using r for the function rep,
> R for the relation @<' and L for the relation @< */
> /* Injectivity */
> ∀x∀y(r(x)=r(y) → x=y),
>
> /* Bootstrapping */
> ∀x∀y(Rxy ↔ Lr(x)r(y)),
>
> /* Irreflexivity */
> ∀x¬Lxx
>
> /* Irreflexivity */
> entails ∀x¬Rxx.
>
> https://www.umsu.de/trees/#~6x~6y(r(x)=r(y)~5x=y),~6x~6y(Rxy~4Lr(x)r(y)),~6x(~3Lxx)%7C=~6x(~3Rxx)

Re: comparing infinite terms

<7a30fc47-ae8b-45fe-a6f1-abbe513dd2aen@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1950&group=comp.lang.prolog#1950

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:148f:b0:3e4:e076:c4a9 with SMTP id t15-20020a05622a148f00b003e4e076c4a9mr8798468qtx.10.1680299145741;
Fri, 31 Mar 2023 14:45:45 -0700 (PDT)
X-Received: by 2002:a81:b1c9:0:b0:546:556d:7578 with SMTP id
p192-20020a81b1c9000000b00546556d7578mr1526307ywh.5.1680299145479; Fri, 31
Mar 2023 14:45:45 -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: Fri, 31 Mar 2023 14:45:45 -0700 (PDT)
In-Reply-To: <c4b1f559-aed0-4cd5-a94d-51b2af1ef5f4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com> <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
<d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com> <c4b1f559-aed0-4cd5-a94d-51b2af1ef5f4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7a30fc47-ae8b-45fe-a6f1-abbe513dd2aen@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Fri, 31 Mar 2023 21:45:45 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Mostowski Collapse - Fri, 31 Mar 2023 21:45 UTC

Ok, half of the proofs don't need injectivity. But connectedness
shows me a proof using injectivity in Wolfgang Schwartz tree tool:

/* I am using r for the function rep,
R for the relation @<' and L for the relation @< */
/* Injectivity */
∀x∀y(r(x)=r(y) → x=y),

/* Bootstrapping */
∀x∀y(Rxy ↔ Lr(x)r(y)),

/* Connectedness */
∀x∀y(¬x=y → (Lyx ∨ Lxy))

/* Connectedness */
entails ∀x∀y(¬x=y → Ryx ∨ Rxy)

https://www.umsu.de/trees/#~6x~6y(r(x)=r(y)~5x=y),~6x~6y(Rxy~4Lr(x)r(y)),~6x~6y(~3x=y~5Lyx~2Lxy)%7C=~6x~6y(~3x=y~5Ryx~2Rxy)

Mostowski Collapse schrieb am Freitag, 31. März 2023 um 23:10:58 UTC+2:
> Here is a sort example, the Matt Carlsson pairs can be easily sorted:
>
> ?- A=(B,0), B=(A,1), predsort(rep_compare, [A,B], X),
> term_factorized(X, P, Q).
> P = [_A, _B],
> Q = [_B=(_A, 0), _A=(_B, 1)].
>
> ?- A=(B,0), B=((B,0),1), predsort(rep_compare, [B,A], X),
> term_factorized(X, P, Q).
> P = [_A, _B],
> Q = [_B=(_A, 0), _A=(_B, 1)].
>
> And the tripple X,Y,Z that has a bug in native compare/3, the bug is gone:
>
> ?- X=f(X,a(X)), Y=f(Y,b(Y)), Z=f(Y,c(Y)),
> rep_compare(A,X,Y), rep_compare(B,Y,Z), rep_compare(C,X,Z).
> A = B, B = C, C = (<)
> Mostowski Collapse schrieb am Freitag, 31. März 2023 um 23:08:55 UTC+2:
> > Here is a relatively cheap compare for cyclic terms that satisfies the
> > laws, except lexical order. It is based on the idea to define:
> >
> > S @<' T :<=> rep(S) @< rep(T)
> > The only requirement to the function rep is that it is injective,
> > then the laws, except for lexical order, are automatically satisfied.
> > The proof is not so difficult. Here is an example proof, showing
> >
> > irreflexivity of @<’ based on irreflexivity of @<:
> >
> > /* I am using r for the function rep,
> > R for the relation @<' and L for the relation @< */
> > /* Injectivity */
> > ∀x∀y(r(x)=r(y) → x=y),
> >
> > /* Bootstrapping */
> > ∀x∀y(Rxy ↔ Lr(x)r(y)),
> >
> > /* Irreflexivity */
> > ∀x¬Lxx
> >
> > /* Irreflexivity */
> > entails ∀x¬Rxx.
> >
> > https://www.umsu.de/trees/#~6x~6y(r(x)=r(y)~5x=y),~6x~6y(Rxy~4Lr(x)r(y)),~6x(~3Lxx)%7C=~6x(~3Rxx)

Re: comparing infinite terms

<c357e797-7343-4d4a-bf14-5fbf7311f64cn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1951&group=comp.lang.prolog#1951

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ad4:58eb:0:b0:577:5ef5:4cfb with SMTP id di11-20020ad458eb000000b005775ef54cfbmr6407385qvb.8.1680373385807;
Sat, 01 Apr 2023 11:23:05 -0700 (PDT)
X-Received: by 2002:a81:af08:0:b0:545:64c4:7701 with SMTP id
n8-20020a81af08000000b0054564c47701mr15019018ywh.3.1680373385559; Sat, 01 Apr
2023 11:23:05 -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, 1 Apr 2023 11:23:05 -0700 (PDT)
In-Reply-To: <7a30fc47-ae8b-45fe-a6f1-abbe513dd2aen@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com> <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
<d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com> <c4b1f559-aed0-4cd5-a94d-51b2af1ef5f4n@googlegroups.com>
<7a30fc47-ae8b-45fe-a6f1-abbe513dd2aen@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c357e797-7343-4d4a-bf14-5fbf7311f64cn@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sat, 01 Apr 2023 18:23:05 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Mostowski Collapse - Sat, 1 Apr 2023 18:23 UTC

Instead of using the verification path, and making
mathematical proofs, one can also use the validation path.
What helps is this fuzzer:

% random_cyclic(-Term)
random_cyclic(T) :-
random_cyclic([T], T).

% random_cyclic(+List, -Term)
random_cyclic(L, T) :-
length(L, M),
random(R),
N is truncate(R*(M+3)),
(N = 0 -> T = 0;
N = 1 -> T = 1;
N = 2 -> T = s(P,Q), random_cyclic([P|L], P), random_cyclic([Q|L], Q);
K is N-3, nth0(K, L, S), S=T).

Now I found that term_factorized/3 might run into
a stack overflow. The reason could be the buggy
compare/3, in case it is used in rbtrees:

?- aggregate_all(count, (between(1,1000000,_), random_cyclic(A),
random_cyclic(B), random_cyclic(C), rep_less(A,B),
rep_less(B,C), \+ rep_less(A,C)), F).
ERROR: Stack limit (1.0Gb) exceeded
ERROR: Stack sizes: local: 0.7Gb, global: 0.2Gb, trail: 1Kb
ERROR: Stack depth: 12,882,088, last-call: 50%, Choice points: 6
ERROR: In:
ERROR: [12,882,088] rbtrees:lookup(<compound s/2>,
_64416492, <compound black/4>)
ERROR: [12,882,086] terms:insert_vars(<compound s/2>,
_64416526, <compound t/2>)

Re: comparing infinite terms

<4334a7e2-0d40-4947-931e-71a59f31b2e5n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1955&group=comp.lang.prolog#1955

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:891:b0:749:fd48:68b5 with SMTP id b17-20020a05620a089100b00749fd4868b5mr3116901qka.10.1680523754935;
Mon, 03 Apr 2023 05:09:14 -0700 (PDT)
X-Received: by 2002:a05:6902:1003:b0:b1d:5061:98e3 with SMTP id
w3-20020a056902100300b00b1d506198e3mr23731323ybt.6.1680523754714; Mon, 03 Apr
2023 05:09:14 -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: Mon, 3 Apr 2023 05:09:14 -0700 (PDT)
In-Reply-To: <c357e797-7343-4d4a-bf14-5fbf7311f64cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com> <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
<d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com> <c4b1f559-aed0-4cd5-a94d-51b2af1ef5f4n@googlegroups.com>
<7a30fc47-ae8b-45fe-a6f1-abbe513dd2aen@googlegroups.com> <c357e797-7343-4d4a-bf14-5fbf7311f64cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4334a7e2-0d40-4947-931e-71a59f31b2e5n@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Mon, 03 Apr 2023 12:09:14 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3269
 by: Mostowski Collapse - Mon, 3 Apr 2023 12:09 UTC

There is a new surprise. I get the same stack
overflow when I use a ground term:

/* SWI-Prolog 9.1.7 */
?- T = _S1, % where
_S1 = s(s(_S1, _S2), 0),
_S2 = s(_S2, _S1), term_factorized(T, Y, L).
ERROR: Stack limit (1.0Gb) exceeded

The stack overflow glitch is not only present in non-ground
terms, it sadly happens for ground terms as well.

Mostowski Collapse schrieb am Samstag, 1. April 2023 um 20:23:06 UTC+2:
> Instead of using the verification path, and making
> mathematical proofs, one can also use the validation path.
> What helps is this fuzzer:
>
> % random_cyclic(-Term)
> random_cyclic(T) :-
> random_cyclic([T], T).
>
> % random_cyclic(+List, -Term)
> random_cyclic(L, T) :-
> length(L, M),
> random(R),
> N is truncate(R*(M+3)),
> (N = 0 -> T = 0;
> N = 1 -> T = 1;
> N = 2 -> T = s(P,Q), random_cyclic([P|L], P), random_cyclic([Q|L], Q);
> K is N-3, nth0(K, L, S), S=T).
>
> Now I found that term_factorized/3 might run into
> a stack overflow. The reason could be the buggy
> compare/3, in case it is used in rbtrees:
>
> ?- aggregate_all(count, (between(1,1000000,_), random_cyclic(A),
> random_cyclic(B), random_cyclic(C), rep_less(A,B),
> rep_less(B,C), \+ rep_less(A,C)), F).
> ERROR: Stack limit (1.0Gb) exceeded
> ERROR: Stack sizes: local: 0.7Gb, global: 0.2Gb, trail: 1Kb
> ERROR: Stack depth: 12,882,088, last-call: 50%, Choice points: 6
> ERROR: In:
> ERROR: [12,882,088] rbtrees:lookup(<compound s/2>,
> _64416492, <compound black/4>)
> ERROR: [12,882,086] terms:insert_vars(<compound s/2>,
> _64416526, <compound t/2>)

Re: comparing infinite terms

<a2415ab4-7e6e-4f89-a8ab-89ca124b61d1n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1960&group=comp.lang.prolog#1960

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:7d89:0:b0:3d6:2cd9:74e6 with SMTP id c9-20020ac87d89000000b003d62cd974e6mr1104156qtd.9.1680692208644;
Wed, 05 Apr 2023 03:56:48 -0700 (PDT)
X-Received: by 2002:a25:cc0c:0:b0:b78:3a15:e704 with SMTP id
l12-20020a25cc0c000000b00b783a15e704mr3908523ybf.10.1680692208421; Wed, 05
Apr 2023 03:56:48 -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: Wed, 5 Apr 2023 03:56:48 -0700 (PDT)
In-Reply-To: <4334a7e2-0d40-4947-931e-71a59f31b2e5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com> <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
<d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com> <c4b1f559-aed0-4cd5-a94d-51b2af1ef5f4n@googlegroups.com>
<7a30fc47-ae8b-45fe-a6f1-abbe513dd2aen@googlegroups.com> <c357e797-7343-4d4a-bf14-5fbf7311f64cn@googlegroups.com>
<4334a7e2-0d40-4947-931e-71a59f31b2e5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a2415ab4-7e6e-4f89-a8ab-89ca124b61d1n@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Wed, 05 Apr 2023 10:56:48 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Mostowski Collapse - Wed, 5 Apr 2023 10:56 UTC

I was too optimistic about the native compare/3. It has also the
mirror anomaly. I find very quickly a violation of the mirror law:

/* SWI-Prolog 9.1.7 */
?- repeat, random_cyclic(A), random_cyclic(B),
compare(X,A,B), X = (<), \+ (compare(Y,B,A), Y = (>)).
A = s(A, A),
B = s(_S1, 1), % where
_S1 = s(_S1, s(1, _S1)),
X = (<) .

Mostowski Collapse schrieb am Montag, 3. April 2023 um 14:09:16 UTC+2:
> There is a new surprise. I get the same stack
> overflow when I use a ground term:
>
> /* SWI-Prolog 9.1.7 */
> ?- T = _S1, % where
> _S1 = s(s(_S1, _S2), 0),
> _S2 = s(_S2, _S1), term_factorized(T, Y, L).
> ERROR: Stack limit (1.0Gb) exceeded
> The stack overflow glitch is not only present in non-ground
> terms, it sadly happens for ground terms as well.
> Mostowski Collapse schrieb am Samstag, 1. April 2023 um 20:23:06 UTC+2:
> > Instead of using the verification path, and making
> > mathematical proofs, one can also use the validation path.
> > What helps is this fuzzer:
> >
> > % random_cyclic(-Term)
> > random_cyclic(T) :-
> > random_cyclic([T], T).
> >
> > % random_cyclic(+List, -Term)
> > random_cyclic(L, T) :-
> > length(L, M),
> > random(R),
> > N is truncate(R*(M+3)),
> > (N = 0 -> T = 0;
> > N = 1 -> T = 1;
> > N = 2 -> T = s(P,Q), random_cyclic([P|L], P), random_cyclic([Q|L], Q);
> > K is N-3, nth0(K, L, S), S=T).
> >
> > Now I found that term_factorized/3 might run into
> > a stack overflow. The reason could be the buggy
> > compare/3, in case it is used in rbtrees:
> >
> > ?- aggregate_all(count, (between(1,1000000,_), random_cyclic(A),
> > random_cyclic(B), random_cyclic(C), rep_less(A,B),
> > rep_less(B,C), \+ rep_less(A,C)), F).
> > ERROR: Stack limit (1.0Gb) exceeded
> > ERROR: Stack sizes: local: 0.7Gb, global: 0.2Gb, trail: 1Kb
> > ERROR: Stack depth: 12,882,088, last-call: 50%, Choice points: 6
> > ERROR: In:
> > ERROR: [12,882,088] rbtrees:lookup(<compound s/2>,
> > _64416492, <compound black/4>)
> > ERROR: [12,882,086] terms:insert_vars(<compound s/2>,
> > _64416526, <compound t/2>)

Re: comparing infinite terms

<c7e6037b-42ad-4b8c-80f3-0cf829b8fe2fn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1962&group=comp.lang.prolog#1962

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:22a2:b0:3e6:5ca6:e9ea with SMTP id ay34-20020a05622a22a200b003e65ca6e9eamr1782593qtb.5.1681390482004;
Thu, 13 Apr 2023 05:54:42 -0700 (PDT)
X-Received: by 2002:a25:d8d2:0:b0:b8f:566d:2570 with SMTP id
p201-20020a25d8d2000000b00b8f566d2570mr1271433ybg.11.1681390481706; Thu, 13
Apr 2023 05:54:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!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: Thu, 13 Apr 2023 05:54:41 -0700 (PDT)
In-Reply-To: <a2415ab4-7e6e-4f89-a8ab-89ca124b61d1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <u8ispas4jsi.fsf@brigitte.csd.uu.se> <95b75edd-396f-40b0-bc5e-e1885f686ce2n@googlegroups.com>
<45485fe3-bde0-45b8-b6fe-5f2e9e2bdd6dn@googlegroups.com> <6325c2f6-a3fb-465e-bed8-77f6cea7fdb1n@googlegroups.com>
<b2eb60e2-c64d-4a20-bd7e-e2c54162dd65n@googlegroups.com> <d14b9cbe-a093-4826-baa2-dfc0844c11d8n@googlegroups.com>
<d5bbd90e-7dea-41d2-93e7-3bd75a0e8ec3n@googlegroups.com> <c4b1f559-aed0-4cd5-a94d-51b2af1ef5f4n@googlegroups.com>
<7a30fc47-ae8b-45fe-a6f1-abbe513dd2aen@googlegroups.com> <c357e797-7343-4d4a-bf14-5fbf7311f64cn@googlegroups.com>
<4334a7e2-0d40-4947-931e-71a59f31b2e5n@googlegroups.com> <a2415ab4-7e6e-4f89-a8ab-89ca124b61d1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c7e6037b-42ad-4b8c-80f3-0cf829b8fe2fn@googlegroups.com>
Subject: Re: comparing infinite terms
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Thu, 13 Apr 2023 12:54:41 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2353
 by: Mostowski Collapse - Thu, 13 Apr 2023 12:54 UTC

Can we produce Naish pointers without relying on
term_factorized/3 which unfortunately gives a stack
overflow sometimes? Of course:

% naish(+Term, -Termt)
naish(T, S) :-
naish(T, [], S).

% naish(+Term, +Map, -Term)
naish(T, _, T) :- \+ compound(T), !.
naish(T, C, '\a'(N)) :- nth0(N, C, S), S == T, !.
naish(T, C, S) :-
T =.. [F|L],
naish_list(L, [T|C], R),
S =.. [F|R].

% naish_list(+List, +Map, -List)
naish_list([], _, []).
naish_list([X|L], C, [Y|R]) :-
naish(X, C, Y),
naish_list(L, C, R).

Works fine:

?- A=(B,0), B=(A,1), naish(A, X).
X = (('\a'(1), 1), 0).

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor