Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4


devel / comp.lang.prolog / Re: Autumn Challenge 2023: Lion and Unicorn

SubjectAuthor
* Autumn Challenge 2023: Lion and UnicornMild Shock
`* Re: Autumn Challenge 2023: Lion and UnicornMild Shock
 `* Re: Autumn Challenge 2023: Lion and UnicornMild Shock
  `* Re: Autumn Challenge 2023: Lion and UnicornMild Shock
   `* Re: Autumn Challenge 2023: Lion and UnicornMild Shock
    `* Re: Autumn Challenge 2023: Lion and UnicornMild Shock
     `* Re: Autumn Challenge 2023: Lion and UnicornMild Shock
      `* Re: Autumn Challenge 2023: Lion and UnicornMild Shock
       `- Re: Autumn Challenge 2023: Lion and UnicornMild Shock

1
Autumn Challenge 2023: Lion and Unicorn

<uia9su$15qa7$1@solani.org>

  copy mid

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

  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 (Mild Shock)
Newsgroups: comp.lang.prolog
Subject: Autumn Challenge 2023: Lion and Unicorn
Date: Mon, 6 Nov 2023 09:59:12 +0100
Message-ID: <uia9su$15qa7$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 6 Nov 2023 08:59:10 -0000 (UTC)
Injection-Info: solani.org;
logging-data="1239367"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
Cancel-Lock: sha1:CbJTKvPiOfu742fGzg6dvJYbyH0=
X-Mozilla-News-Host: news://news.solani.org:119
X-User-ID: eJwNysEBwCAIA8CVDELAcQBl/xHae59tgu1Ko9rYrKiDwZWQrJhjkV1YgQppEnC2YnfpgxVi/7WGfq5YvtQPQjgVIw==
 by: Mild Shock - Mon, 6 Nov 2023 08:59 UTC

Please solve this with logic:

When Alice entered the forest of forgetfulness, she did not
forget everything, only certain things. She often forgot her
name, and the most likely thing for her to forget was the day
of the week. Now, the lion and the unicorn were frequent
visitors to this forest. These two are strange creatures. The
lion lies on Mondays, Tuesdays, and Wednesdays and tells
the truth on the other days of the week. The unicorn, on the
other hand, lies on Thursdays, Fridays, and Saturdays, but tells
the truth on the other days of the week.

One day Alice met the lion and the unicorn resting under a tree.
They made the following statements:

Lion: Yesterday was one of my lying days.
Unicorn: Yesterday was one of my lying days.

From these statements, Alice, who was a bright girl, was able to
deduce the day of the week. What was it?

Re: Autumn Challenge 2023: Lion and Unicorn

<82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:6214:50f:b0:66a:ca66:85fb with SMTP id px15-20020a056214050f00b0066aca6685fbmr564887qvb.13.1699285391962;
Mon, 06 Nov 2023 07:43:11 -0800 (PST)
X-Received: by 2002:a9d:4795:0:b0:6c8:f9bc:f768 with SMTP id
b21-20020a9d4795000000b006c8f9bcf768mr8639676otf.1.1699285391699; Mon, 06 Nov
2023 07:43:11 -0800 (PST)
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, 6 Nov 2023 07:43:11 -0800 (PST)
In-Reply-To: <uia9su$15qa7$1@solani.org>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
References: <uia9su$15qa7$1@solani.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com>
Subject: Re: Autumn Challenge 2023: Lion and Unicorn
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 06 Nov 2023 15:43:11 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1739
 by: Mild Shock - Mon, 6 Nov 2023 15:43 UTC

I got the puzzle from a discussion here,
which was about Prolog versus Theorem Proving:

The lion and the unicorn met PROLOG
Bruce D. Ramsey, 1986 - Free Access
https://dl.acm.org/doi/10.1145/382278.382395

This gives immediately the following database:

yesterday(monday , sunday ).
yesterday(tuesday , monday ).
yesterday(wednesday, tuesday ).
yesterday(thursday , wednesday).
yesterday(friday , thursday ).
yesterday(saturday , friday ).
yesterday(sunday , saturday ).

lies(lion, monday ).
lies(lion, tuesday ).
lies(lion, wednesday).

lies(unicorn, thursday).
lies(unicorn, friday ).
lies(unicorn, saturday).

Now what?

Re: Autumn Challenge 2023: Lion and Unicorn

<c8641181-bfa5-4aaf-86d9-727b15b859e5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:7ee4:0:b0:419:a33e:e6fa with SMTP id r4-20020ac87ee4000000b00419a33ee6famr259102qtc.5.1699285659616;
Mon, 06 Nov 2023 07:47:39 -0800 (PST)
X-Received: by 2002:a9d:6258:0:b0:6bf:287e:1afd with SMTP id
i24-20020a9d6258000000b006bf287e1afdmr8320662otk.5.1699285659418; Mon, 06 Nov
2023 07:47:39 -0800 (PST)
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, 6 Nov 2023 07:47:39 -0800 (PST)
In-Reply-To: <82e20f93-78c4-4094-9ee8-487e2dca6926n@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: <uia9su$15qa7$1@solani.org> <82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c8641181-bfa5-4aaf-86d9-727b15b859e5n@googlegroups.com>
Subject: Re: Autumn Challenge 2023: Lion and Unicorn
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 06 Nov 2023 15:47:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2947
 by: Mild Shock - Mon, 6 Nov 2023 15:47 UTC

Picking up an idea by @jamesnvc , abstracting a pattern
behind lying_day_lie_or_nonlying_day_truth/3 into something
with more meta calls:

contrary(S, T) :- S, \+ T.
contrary(S, T) :- \+ S, T.

solve(D) :- yesterday(D, Y),
contrary(lies(lion, D), lies(lion, Y)),
contrary(lies(unicorn, D), lies(unicorn, Y)).

Here some benchmark:

/* SWI-Prolog 9.1.17 */
?- time((between(1,1000000,_), solve(_), fail; true)).
% 45,999,999 inferences, 2.719 CPU in 2.712 seconds (100% CPU, 16919540 Lips)
true.

/* Dogelog Player 1.1.3, Java */
?- time((between(1,1000000,_), solve(_), fail; true)).
% Zeit 9282 ms, GC 0 ms, Lips 10019403, Uhr 06.11.2023 16:34
true.

/* GNU Prolog 1.5.0 */
?- between(1,1000000,_), solve(_), fail; true.
(10782 ms) yes

Quite amazing the speed of SWI-Prolog, here I can only beat GNU Prolog
with my new Dogelog Player for Java. Mostlikely an argument in favor of inlining
negation as failure somehow, as SWI-Prolog does. Only lets do it correctly!

Mild Shock schrieb am Montag, 6. November 2023 um 16:43:13 UTC+1:
> I got the puzzle from a discussion here,
> which was about Prolog versus Theorem Proving:
>
> The lion and the unicorn met PROLOG
> Bruce D. Ramsey, 1986 - Free Access
> https://dl.acm.org/doi/10.1145/382278.382395
>
> This gives immediately the following database:
>
> yesterday(monday , sunday ).
> yesterday(tuesday , monday ).
> yesterday(wednesday, tuesday ).
> yesterday(thursday , wednesday).
> yesterday(friday , thursday ).
> yesterday(saturday , friday ).
> yesterday(sunday , saturday ).
>
> lies(lion, monday ).
> lies(lion, tuesday ).
> lies(lion, wednesday).
>
> lies(unicorn, thursday).
> lies(unicorn, friday ).
> lies(unicorn, saturday).
>
> Now what?

Re: Autumn Challenge 2023: Lion and Unicorn

<ebd4ed81-bbd4-4bdf-80e8-a7fb746522b9n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:4110:b0:76f:f5f:f0ba with SMTP id j16-20020a05620a411000b0076f0f5ff0bamr267015qko.5.1699286595178;
Mon, 06 Nov 2023 08:03:15 -0800 (PST)
X-Received: by 2002:a05:6870:794:b0:1e9:b451:bae6 with SMTP id
en20-20020a056870079400b001e9b451bae6mr38965oab.1.1699286594932; Mon, 06 Nov
2023 08:03:14 -0800 (PST)
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, 6 Nov 2023 08:03:14 -0800 (PST)
In-Reply-To: <c8641181-bfa5-4aaf-86d9-727b15b859e5n@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: <uia9su$15qa7$1@solani.org> <82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com>
<c8641181-bfa5-4aaf-86d9-727b15b859e5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ebd4ed81-bbd4-4bdf-80e8-a7fb746522b9n@googlegroups.com>
Subject: Re: Autumn Challenge 2023: Lion and Unicorn
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 06 Nov 2023 16:03:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4367
 by: Mild Shock - Mon, 6 Nov 2023 16:03 UTC

Its also a test case where my sys_trans_allowed/1 is totally useless. But
I guess this is a problem of my sys_trans_allowed/1, maybe we can make an
exception for \+ A where A is a variable and arrive at something useful?

If A is a variable, and if we would replace it by (A->fail; true) this would
be compiled with call(A), and thus give a correct translation of negation as
failure again. Its a similar special case like call/1 has the special case that

at runtime call(A) with A variable throws an exception to avoid call/1
wrapping at infinitum and that the Prolog interpreter runs into nirvana.
So the revised sys_trans_allowed/1 would read as follows:

/* Version 2.0 */
sys_trans_allowed(V) :- var(V), !.
sys_trans_allowed(A) :- sys_trans_allowed2(A).

sys_trans_allowed2(V) :- var(V), !, fail.
sys_trans_allowed2((A,B)) :- sys_trans_allowed2(A), sys_trans_allowed2(B).
sys_trans_allowed2((A;B)) :- sys_trans_allowed2(A), sys_trans_allowed2(B).
sys_trans_allowed2((A->B)) :- sys_trans_allowed2(A), sys_trans_allowed2(B).
sys_trans_allowed2(A) :- callable(A).

But I guess a little more is needed. Namely make (A->fail; true) cheap.

Mild Shock schrieb am Montag, 6. November 2023 um 16:47:40 UTC+1:
> Picking up an idea by @jamesnvc , abstracting a pattern
> behind lying_day_lie_or_nonlying_day_truth/3 into something
> with more meta calls:
>
> contrary(S, T) :- S, \+ T.
> contrary(S, T) :- \+ S, T.
>
> solve(D) :- yesterday(D, Y),
> contrary(lies(lion, D), lies(lion, Y)),
> contrary(lies(unicorn, D), lies(unicorn, Y)).
>
> Here some benchmark:
>
> /* SWI-Prolog 9.1.17 */
> ?- time((between(1,1000000,_), solve(_), fail; true)).
> % 45,999,999 inferences, 2.719 CPU in 2.712 seconds (100% CPU, 16919540 Lips)
> true.
>
> /* Dogelog Player 1.1.3, Java */
> ?- time((between(1,1000000,_), solve(_), fail; true)).
> % Zeit 9282 ms, GC 0 ms, Lips 10019403, Uhr 06.11.2023 16:34
> true.
>
> /* GNU Prolog 1.5.0 */
> ?- between(1,1000000,_), solve(_), fail; true.
> (10782 ms) yes
>
> Quite amazing the speed of SWI-Prolog, here I can only beat GNU Prolog
> with my new Dogelog Player for Java. Mostlikely an argument in favor of inlining
> negation as failure somehow, as SWI-Prolog does. Only lets do it correctly!
> Mild Shock schrieb am Montag, 6. November 2023 um 16:43:13 UTC+1:
> > I got the puzzle from a discussion here,
> > which was about Prolog versus Theorem Proving:
> >
> > The lion and the unicorn met PROLOG
> > Bruce D. Ramsey, 1986 - Free Access
> > https://dl.acm.org/doi/10.1145/382278.382395
> >
> > This gives immediately the following database:
> >
> > yesterday(monday , sunday ).
> > yesterday(tuesday , monday ).
> > yesterday(wednesday, tuesday ).
> > yesterday(thursday , wednesday).
> > yesterday(friday , thursday ).
> > yesterday(saturday , friday ).
> > yesterday(sunday , saturday ).
> >
> > lies(lion, monday ).
> > lies(lion, tuesday ).
> > lies(lion, wednesday).
> >
> > lies(unicorn, thursday).
> > lies(unicorn, friday ).
> > lies(unicorn, saturday).
> >
> > Now what?

Re: Autumn Challenge 2023: Lion and Unicorn

<144bc354-c65c-48c0-a8ca-dc319a423ccdn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a0c:e6eb:0:b0:670:754b:2e6d with SMTP id m11-20020a0ce6eb000000b00670754b2e6dmr451143qvn.7.1699288949542; Mon, 06 Nov 2023 08:42:29 -0800 (PST)
X-Received: by 2002:a9d:6b1a:0:b0:6bc:fb26:499e with SMTP id g26-20020a9d6b1a000000b006bcfb26499emr8276739otp.2.1699288949305; Mon, 06 Nov 2023 08:42:29 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!69.80.99.11.MISMATCH!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Mon, 6 Nov 2023 08:42:29 -0800 (PST)
In-Reply-To: <ebd4ed81-bbd4-4bdf-80e8-a7fb746522b9n@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: <uia9su$15qa7$1@solani.org> <82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com> <c8641181-bfa5-4aaf-86d9-727b15b859e5n@googlegroups.com> <ebd4ed81-bbd4-4bdf-80e8-a7fb746522b9n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <144bc354-c65c-48c0-a8ca-dc319a423ccdn@googlegroups.com>
Subject: Re: Autumn Challenge 2023: Lion and Unicorn
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 06 Nov 2023 16:42:29 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 95
 by: Mild Shock - Mon, 6 Nov 2023 16:42 UTC

Ok I was comparing apples with oranges when I looked
at SWI-Prolog and other Prolog systems. Since SWI-Prolog
creates a multi-argument index, which explains the speed:

?- jiti_list(lies).
Predicate Indexed Buckets Speedup Flags
============================================================================
user:lies/2 2 8 6.0
true.

Can I manually switch off this index for a fairer comparison?
Whats even the logic behind choosing this index. Thats
a quite an amazing choice sind the call of lies/2 is ground.

Mild Shock schrieb am Montag, 6. November 2023 um 17:03:16 UTC+1:
> Its also a test case where my sys_trans_allowed/1 is totally useless. But
> I guess this is a problem of my sys_trans_allowed/1, maybe we can make an
> exception for \+ A where A is a variable and arrive at something useful?
>
> If A is a variable, and if we would replace it by (A->fail; true) this would
> be compiled with call(A), and thus give a correct translation of negation as
> failure again. Its a similar special case like call/1 has the special case that
>
> at runtime call(A) with A variable throws an exception to avoid call/1
> wrapping at infinitum and that the Prolog interpreter runs into nirvana.
> So the revised sys_trans_allowed/1 would read as follows:
>
> /* Version 2.0 */
> sys_trans_allowed(V) :- var(V), !.
> sys_trans_allowed(A) :- sys_trans_allowed2(A).
>
> sys_trans_allowed2(V) :- var(V), !, fail.
> sys_trans_allowed2((A,B)) :- sys_trans_allowed2(A), sys_trans_allowed2(B).
> sys_trans_allowed2((A;B)) :- sys_trans_allowed2(A), sys_trans_allowed2(B).
> sys_trans_allowed2((A->B)) :- sys_trans_allowed2(A), sys_trans_allowed2(B).
> sys_trans_allowed2(A) :- callable(A).
>
> But I guess a little more is needed. Namely make (A->fail; true) cheap.
> Mild Shock schrieb am Montag, 6. November 2023 um 16:47:40 UTC+1:
> > Picking up an idea by @jamesnvc , abstracting a pattern
> > behind lying_day_lie_or_nonlying_day_truth/3 into something
> > with more meta calls:
> >
> > contrary(S, T) :- S, \+ T.
> > contrary(S, T) :- \+ S, T.
> >
> > solve(D) :- yesterday(D, Y),
> > contrary(lies(lion, D), lies(lion, Y)),
> > contrary(lies(unicorn, D), lies(unicorn, Y)).
> >
> > Here some benchmark:
> >
> > /* SWI-Prolog 9.1.17 */
> > ?- time((between(1,1000000,_), solve(_), fail; true)).
> > % 45,999,999 inferences, 2.719 CPU in 2.712 seconds (100% CPU, 16919540 Lips)
> > true.
> >
> > /* Dogelog Player 1.1.3, Java */
> > ?- time((between(1,1000000,_), solve(_), fail; true)).
> > % Zeit 9282 ms, GC 0 ms, Lips 10019403, Uhr 06.11.2023 16:34
> > true.
> >
> > /* GNU Prolog 1.5.0 */
> > ?- between(1,1000000,_), solve(_), fail; true.
> > (10782 ms) yes
> >
> > Quite amazing the speed of SWI-Prolog, here I can only beat GNU Prolog
> > with my new Dogelog Player for Java. Mostlikely an argument in favor of inlining
> > negation as failure somehow, as SWI-Prolog does. Only lets do it correctly!
> > Mild Shock schrieb am Montag, 6. November 2023 um 16:43:13 UTC+1:
> > > I got the puzzle from a discussion here,
> > > which was about Prolog versus Theorem Proving:
> > >
> > > The lion and the unicorn met PROLOG
> > > Bruce D. Ramsey, 1986 - Free Access
> > > https://dl.acm.org/doi/10.1145/382278.382395
> > >
> > > This gives immediately the following database:
> > >
> > > yesterday(monday , sunday ).
> > > yesterday(tuesday , monday ).
> > > yesterday(wednesday, tuesday ).
> > > yesterday(thursday , wednesday).
> > > yesterday(friday , thursday ).
> > > yesterday(saturday , friday ).
> > > yesterday(sunday , saturday ).
> > >
> > > lies(lion, monday ).
> > > lies(lion, tuesday ).
> > > lies(lion, wednesday).
> > >
> > > lies(unicorn, thursday).
> > > lies(unicorn, friday ).
> > > lies(unicorn, saturday).
> > >
> > > Now what?

Re: Autumn Challenge 2023: Lion and Unicorn

<528f1010-ff9d-4040-a9cb-133c0b2287b6n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ae9:e204:0:b0:77b:c536:371b with SMTP id c4-20020ae9e204000000b0077bc536371bmr63082qkc.9.1699731773891;
Sat, 11 Nov 2023 11:42:53 -0800 (PST)
X-Received: by 2002:a17:902:e5d2:b0:1cc:cc77:94ed with SMTP id
u18-20020a170902e5d200b001cccc7794edmr872999plf.10.1699731773587; Sat, 11 Nov
2023 11:42:53 -0800 (PST)
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, 11 Nov 2023 11:42:53 -0800 (PST)
In-Reply-To: <205a49e9-02bb-4771-8066-7e898d0e6cebn@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: <uia9su$15qa7$1@solani.org> <82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com>
<c8641181-bfa5-4aaf-86d9-727b15b859e5n@googlegroups.com> <ebd4ed81-bbd4-4bdf-80e8-a7fb746522b9n@googlegroups.com>
<144bc354-c65c-48c0-a8ca-dc319a423ccdn@googlegroups.com> <83240f6d-0a01-48f8-a9ad-9496f4d26381n@googlegroups.com>
<205a49e9-02bb-4771-8066-7e898d0e6cebn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <528f1010-ff9d-4040-a9cb-133c0b2287b6n@googlegroups.com>
Subject: Re: Autumn Challenge 2023: Lion and Unicorn
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Sat, 11 Nov 2023 19:42:53 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3372
 by: Mild Shock - Sat, 11 Nov 2023 19:42 UTC

What the heck, one can even write ultrafast
parsers with SAT (some bit encoding)?

> Long live SMT. Long live meta-programming
This article describes why and how I wrote absolut; a Rust
crate for automating a common pattern of constructing
SIMD byte-wise lookup tables. I learned about this technique
while studying the Parsing Gigabytes of JSON per Second
paper by Geoff Langdale & Daniel Lemire.
https://fuzzypixelz.com/blog/absolut/

Mild Shock schrieb am Samstag, 11. November 2023 um 19:40:21 UTC+1:
> Could ChatGPT, the automatic programming Robot,
> help develop a solution with a SAT solver for XOR in mind?
>
> My idea currently, use 3 variables X,Y,Z for weekday:
>
> X,Y,Z weekday
> 0,0,0 monday
> 0,0,1 tuesday
> 0,1,0 wednesday
> 0,1,1 thursday
> 1,0,0 friday
> 1,0,1 saturday
> 1,1,0 sunday
>
> Or maybe somebody, a human, did it already this way.
> Mild Shock schrieb am Samstag, 11. November 2023 um 18:33:50 UTC+1:
> > Just for the fun of it, also benchmarking,
> > was expecting same behaviour as contrary2:
> >
> > contrary5(S, T) :- \+ (forall(S,T), forall(T,S)).¨
> >
> > Not so good because forall/2 isn’t handled as a “control construct”,
> > whereas (\+)/1 is handled as a “control construct” and inlined.
> > Maybe this is the reason:
> >
> > /* contrary5 */
> > ?- time((between(1,1000000,_), solve(_), fail; true)).
> > % 65,999,999 inferences, 2.812 CPU in 2.813 seconds (100% CPU, 23466666 Lips)
> > true.
> >
> > So contrary is the XOR, i.e. ~(A ↔ B) == ~((A → B) & (B → A)).
> > What can a constraint programming system do to the Lion and Unicorn
> > example. Are there not special SAT solvers who are good in XOR?

Re: Autumn Challenge 2023: Lion and Unicorn

<55e4d77a-744c-4bcf-b642-4b9bb1b38d91n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a37:e113:0:b0:776:f5ad:a7de with SMTP id c19-20020a37e113000000b00776f5ada7demr14103qkm.1.1699917095690;
Mon, 13 Nov 2023 15:11:35 -0800 (PST)
X-Received: by 2002:a05:6a00:81ca:b0:690:3793:17f9 with SMTP id
ft10-20020a056a0081ca00b00690379317f9mr2015509pfb.6.1699917095373; Mon, 13
Nov 2023 15:11:35 -0800 (PST)
Path: i2pn2.org!i2pn.org!news.swapon.de!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, 13 Nov 2023 15:11:34 -0800 (PST)
In-Reply-To: <528f1010-ff9d-4040-a9cb-133c0b2287b6n@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: <uia9su$15qa7$1@solani.org> <82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com>
<c8641181-bfa5-4aaf-86d9-727b15b859e5n@googlegroups.com> <ebd4ed81-bbd4-4bdf-80e8-a7fb746522b9n@googlegroups.com>
<144bc354-c65c-48c0-a8ca-dc319a423ccdn@googlegroups.com> <83240f6d-0a01-48f8-a9ad-9496f4d26381n@googlegroups.com>
<205a49e9-02bb-4771-8066-7e898d0e6cebn@googlegroups.com> <528f1010-ff9d-4040-a9cb-133c0b2287b6n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <55e4d77a-744c-4bcf-b642-4b9bb1b38d91n@googlegroups.com>
Subject: Re: Autumn Challenge 2023: Lion and Unicorn
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 13 Nov 2023 23:11:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2404
 by: Mild Shock - Mon, 13 Nov 2023 23:11 UTC

Ok, I was using a SAT solver in a little unorthodox way.
Used it as a compiler for a formula, so that I got:

yesterday(0,0,0,1,1,0).
yesterday(0,0,1,0,0,0).
yesterday(0,1,0,0,0,1).
yesterday(0,1,1,0,1,0).
yesterday(1,0,0,0,1,1).
yesterday(1,0,1,1,0,0).
yesterday(1,1,0,1,0,1).

two_liars(T1,T2,T3,Y1,Y2,Y3) :-
T1=\=Y1,
T1=:=(T1/\Y2) xor (T1/\Y3) xor (Y2/\Y3),
Y1=:=(T2/\T3) xor (T2/\Y1) xor (T3/\Y1),
T1=\=(T1/\T2) xor (T1/\T3) xor T2 xor (T2/\T3) xor T3,
Y1=\=(Y1/\Y2) xor (Y1/\Y3) xor Y2 xor (Y2/\Y3) xor Y3.

solve_for(T1,T2,T3) :-
yesterday(T1,T2,T3,Y1,Y2,Y3),
two_liars(T1,T2,T3,Y1,Y2,Y3).

Works fine:

/* SWI-Prolog 9.1.17, optimise=false */
?- time(solve_for(T1,T2,T3)).
% 16 inferences, 0.000 CPU in 0.000 seconds (0% CPU, Infinite Lips)
T1 = 1,
T2 = T3, T3 = 0 ;
% 10 inferences, 0.000 CPU in 0.000 seconds (0% CPU, Infinite Lips)
false.

Re: Autumn Challenge 2023: Lion and Unicorn

<e1ea35e0-84fe-45d5-b062-3f0fe55caa3bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:622a:15c9:b0:41b:8268:d2c3 with SMTP id d9-20020a05622a15c900b0041b8268d2c3mr14582qty.10.1699917135118;
Mon, 13 Nov 2023 15:12:15 -0800 (PST)
X-Received: by 2002:a63:534c:0:b0:5bd:9b7f:b08d with SMTP id
t12-20020a63534c000000b005bd9b7fb08dmr136757pgl.0.1699917134892; Mon, 13 Nov
2023 15:12:14 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Mon, 13 Nov 2023 15:12:14 -0800 (PST)
In-Reply-To: <55e4d77a-744c-4bcf-b642-4b9bb1b38d91n@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: <uia9su$15qa7$1@solani.org> <82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com>
<c8641181-bfa5-4aaf-86d9-727b15b859e5n@googlegroups.com> <ebd4ed81-bbd4-4bdf-80e8-a7fb746522b9n@googlegroups.com>
<144bc354-c65c-48c0-a8ca-dc319a423ccdn@googlegroups.com> <83240f6d-0a01-48f8-a9ad-9496f4d26381n@googlegroups.com>
<205a49e9-02bb-4771-8066-7e898d0e6cebn@googlegroups.com> <528f1010-ff9d-4040-a9cb-133c0b2287b6n@googlegroups.com>
<55e4d77a-744c-4bcf-b642-4b9bb1b38d91n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e1ea35e0-84fe-45d5-b062-3f0fe55caa3bn@googlegroups.com>
Subject: Re: Autumn Challenge 2023: Lion and Unicorn
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 13 Nov 2023 23:12:15 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 51
X-Received-Bytes: 3491
 by: Mild Shock - Mon, 13 Nov 2023 23:12 UTC

But I guess I always miss launching SWI-Prolog with optimise=true,
and the version I am using has default optimise=false.
Because I get these varying results:

/* SWI-Prolog 9.1.17, optimise=false */
?- time((between(1, 1000000, _), solve_for(T1,T2,T3), fail; true)).
% 22,999,999 inferences, 2.016 CPU in 2.016 seconds
(100% CPU, 11410852 Lips)

/* SWI-Prolog 9.1.17, optimise=true */
?- time((between(1, 1000000, _), solve_for(T1,T2,T3), fail; true)).
% 9,999,999 inferences, 1.203 CPU in 1.199 seconds
(100% CPU, 8311687 Lips)
Whereas in Dogelog Player I have now practically always
optimise=true, which then gives me the following:

/* Dogelog Player 1.1.4, JDK 8 */
?- time((between(1, 1000000, _), solve_for(T1,T2,T3), fail; true)).
% Zeit 1892 ms, GC 0 ms, Lips 13213582, Uhr 13.11.2023 23:54

Mild Shock schrieb am Dienstag, 14. November 2023 um 00:11:37 UTC+1:
> Ok, I was using a SAT solver in a little unorthodox way.
> Used it as a compiler for a formula, so that I got:
>
> yesterday(0,0,0,1,1,0).
> yesterday(0,0,1,0,0,0).
> yesterday(0,1,0,0,0,1).
> yesterday(0,1,1,0,1,0).
> yesterday(1,0,0,0,1,1).
> yesterday(1,0,1,1,0,0).
> yesterday(1,1,0,1,0,1).
>
> two_liars(T1,T2,T3,Y1,Y2,Y3) :-
> T1=\=Y1,
> T1=:=(T1/\Y2) xor (T1/\Y3) xor (Y2/\Y3),
> Y1=:=(T2/\T3) xor (T2/\Y1) xor (T3/\Y1),
> T1=\=(T1/\T2) xor (T1/\T3) xor T2 xor (T2/\T3) xor T3,
> Y1=\=(Y1/\Y2) xor (Y1/\Y3) xor Y2 xor (Y2/\Y3) xor Y3.
>
> solve_for(T1,T2,T3) :-
> yesterday(T1,T2,T3,Y1,Y2,Y3),
> two_liars(T1,T2,T3,Y1,Y2,Y3).
>
> Works fine:
>
> /* SWI-Prolog 9.1.17, optimise=false */
> ?- time(solve_for(T1,T2,T3)).
> % 16 inferences, 0.000 CPU in 0.000 seconds (0% CPU, Infinite Lips)
> T1 = 1,
> T2 = T3, T3 = 0 ;
> % 10 inferences, 0.000 CPU in 0.000 seconds (0% CPU, Infinite Lips)
> false.

Re: Autumn Challenge 2023: Lion and Unicorn

<cfdd39d2-9964-44cb-bcdb-620dfffa2702n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:620a:8404:b0:77b:c82c:92ea with SMTP id pc4-20020a05620a840400b0077bc82c92eamr13478qkn.15.1699917210390;
Mon, 13 Nov 2023 15:13:30 -0800 (PST)
X-Received: by 2002:a05:6902:43:b0:dae:49a3:ae23 with SMTP id
m3-20020a056902004300b00dae49a3ae23mr190892ybh.7.1699917210133; Mon, 13 Nov
2023 15:13:30 -0800 (PST)
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, 13 Nov 2023 15:13:29 -0800 (PST)
In-Reply-To: <e1ea35e0-84fe-45d5-b062-3f0fe55caa3bn@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: <uia9su$15qa7$1@solani.org> <82e20f93-78c4-4094-9ee8-487e2dca6926n@googlegroups.com>
<c8641181-bfa5-4aaf-86d9-727b15b859e5n@googlegroups.com> <ebd4ed81-bbd4-4bdf-80e8-a7fb746522b9n@googlegroups.com>
<144bc354-c65c-48c0-a8ca-dc319a423ccdn@googlegroups.com> <83240f6d-0a01-48f8-a9ad-9496f4d26381n@googlegroups.com>
<205a49e9-02bb-4771-8066-7e898d0e6cebn@googlegroups.com> <528f1010-ff9d-4040-a9cb-133c0b2287b6n@googlegroups.com>
<55e4d77a-744c-4bcf-b642-4b9bb1b38d91n@googlegroups.com> <e1ea35e0-84fe-45d5-b062-3f0fe55caa3bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cfdd39d2-9964-44cb-bcdb-620dfffa2702n@googlegroups.com>
Subject: Re: Autumn Challenge 2023: Lion and Unicorn
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 13 Nov 2023 23:13:30 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4491
 by: Mild Shock - Mon, 13 Nov 2023 23:13 UTC

So how to use a SAT solver as a compiler. First model the problem
with library(clpb) as Boolean formulas.

lying_day(A, B, C, D, M) :- M = (
~A* ~B* ~C*D+
~A* ~B*C* ~D+
~A* ~B*C*D+
A*B* ~C* ~D+
A*B* ~C*D+
A*B*C* ~D).

two_liars(T1, T2, T3, Y1, Y2, Y3, ((M1#M2)*(M3#M4))) :-
lying_day(0, T1, T2, T3, M1),
lying_day(0, Y1, Y2, Y3, M2),
lying_day(1, T1, T2, T3, M3),
lying_day(1, Y1, Y2, Y3, M4).

Then look at the normalform:

?- two_liars(T1,T2,T3,_,_,_,M), sat(M).
sat(1#T2*T3#T2*_A#T3*_A#_A),
sat(T1=:=T1*_B#T1*_C#_B*_C),
sat(T1=\=_A),
sat(T1=\=T1*T2#T1*T3#T2#T2*T3#T3),
sat(_A=\=_A*_B#_A*_C#_B#_B*_C#_C).

Take the normalform, reorder the equations a little bit, fewer
variables first, and rewrite them into ISO core standard bitwise
operations, and then take profit.

Mild Shock schrieb am Dienstag, 14. November 2023 um 00:12:16 UTC+1:
> But I guess I always miss launching SWI-Prolog with optimise=true,
> and the version I am using has default optimise=false.
> Because I get these varying results:
> /* SWI-Prolog 9.1.17, optimise=false */
> ?- time((between(1, 1000000, _), solve_for(T1,T2,T3), fail; true)).
> % 22,999,999 inferences, 2.016 CPU in 2.016 seconds
> (100% CPU, 11410852 Lips)
>
> /* SWI-Prolog 9.1.17, optimise=true */
> ?- time((between(1, 1000000, _), solve_for(T1,T2,T3), fail; true)).
> % 9,999,999 inferences, 1.203 CPU in 1.199 seconds
> (100% CPU, 8311687 Lips)
> Whereas in Dogelog Player I have now practically always
> optimise=true, which then gives me the following:
>
> /* Dogelog Player 1.1.4, JDK 8 */
> ?- time((between(1, 1000000, _), solve_for(T1,T2,T3), fail; true)).
> % Zeit 1892 ms, GC 0 ms, Lips 13213582, Uhr 13.11.2023 23:54
> Mild Shock schrieb am Dienstag, 14. November 2023 um 00:11:37 UTC+1:
> > Ok, I was using a SAT solver in a little unorthodox way.
> > Used it as a compiler for a formula, so that I got:
> >
> > yesterday(0,0,0,1,1,0).
> > yesterday(0,0,1,0,0,0).
> > yesterday(0,1,0,0,0,1).
> > yesterday(0,1,1,0,1,0).
> > yesterday(1,0,0,0,1,1).
> > yesterday(1,0,1,1,0,0).
> > yesterday(1,1,0,1,0,1).
> >
> > two_liars(T1,T2,T3,Y1,Y2,Y3) :-
> > T1=\=Y1,
> > T1=:=(T1/\Y2) xor (T1/\Y3) xor (Y2/\Y3),
> > Y1=:=(T2/\T3) xor (T2/\Y1) xor (T3/\Y1),
> > T1=\=(T1/\T2) xor (T1/\T3) xor T2 xor (T2/\T3) xor T3,
> > Y1=\=(Y1/\Y2) xor (Y1/\Y3) xor Y2 xor (Y2/\Y3) xor Y3.
> >
> > solve_for(T1,T2,T3) :-
> > yesterday(T1,T2,T3,Y1,Y2,Y3),
> > two_liars(T1,T2,T3,Y1,Y2,Y3).
> >
> > Works fine:
> >
> > /* SWI-Prolog 9.1.17, optimise=false */
> > ?- time(solve_for(T1,T2,T3)).
> > % 16 inferences, 0.000 CPU in 0.000 seconds (0% CPU, Infinite Lips)
> > T1 = 1,
> > T2 = T3, T3 = 0 ;
> > % 10 inferences, 0.000 CPU in 0.000 seconds (0% CPU, Infinite Lips)
> > false.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor