🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #56

Shumway Prolog is the real monster [WASM Runtime] (Was: Making Prolog more useful [Zen Practice with Cosmology])

#56
From: Mild Shock
Date: Thu, 19 Nov 2026 14:10
174 lines
5773 bytes
Hi,

Holy cow! Look at this:

/* Shumway Prolog, WASM */
?- time((between(1,7,_), sieve(3,7920,[2],_), fail; true)).
% 0.811 seconds, 69,472 heap cells
true.

/* Trealla Prolog 3.14.17, Windows */
?- time((between(1,7,_), sieve(3,7920,[2],_), fail; true)).
% CPU elapsed 1.312s, 52_754_138 inferences, 40.194 MLips
    true.

So Trealla has become amazing.
But Shumway is kind of super amazing!

Bye

P.S.: Test case used:

% sieve(+Integer, +Integer, +List, -List)
sieve(N, M, L, L) :- N > M, !.
sieve(N, M, L, R) :-
    member(X, L),
    N mod X =:= 0, !,
    J is N+1,
    sieve(J, M, L, R).
sieve(N, M, L, R) :-
    J is N+1,
    sieve(J, M, [N|L], R).

https://gusbro.github.io/Shumway/

Mild Shock schrieb:
> Hi,
> 
> Ok, I am following Haskell advice, a more
> useful language has more effects.
> 
>  > Useless vs Useful Languages - Simon Jones
>  > https://www.youtube.com/watch?v=xcB_LF3cdqw
> 
> So how do you add more effects to Prolog?
> Well you start with *pure effects*, like
> adding a new tree_remove:
> 
> /**
>   * tree_remove(T, K, R):
>   * The predicate succeeds. It unifies R with the red black
>   * tree T removed by the entry with key K, or identical if
>   * no such entry exists.
>   */
> 
> And then you add *impure effects*, like:
> 
> /**
>   * tree_remove(T, K):
>   * The predicate succeeds. As a side effect the red black
>   * tree T removed by the entry with key K, or identical if
>   * no such entry exists.
>   */
> 
> Bye
> 
> P.S.: Both predicates follow a new Zen
> Mantra of Red Black trees, which can be
> cast as follows:
> 
>  > The bottom-up adjustment after a new
>  > sub node has been created, follows the
>  > simple balancing as found in Chris Okasaki,
>  > 1993. The predicates tree_remove/3 and
>  > tree_remove/2 only implement a pivoting
>  > strategy. Since the pivoting retains the
>  > coloring invariant, we can do without any
>  > balancing after a sub node has been deleted.
> 
> It was deduced by doing some Cern Cosmology
> experiments on the trees, by bombarding
> them with fuzzy testing particles.
> 
> P.P.S.: Why does SWI have no non-backtracking
> tree remove:
> 
> https://www.swi-prolog.org/pldoc/doc/_SWI_/library/nb_rbtrees.pl
> 
> Mild Shock schrieb:
>> Hi,
>>
>> Amazing how Trealla has gained speed!
>>
>> /* SWI-Prolog 10.1.18 */
>> ?- between(1,3,_), time(test), fail; true.
>> % 9,368,753 inferences, 0.266 CPU in 0.291 seconds
>> % 9,368,775 inferences, 0.266 CPU in 0.275 seconds
>> % 9,369,755 inferences, 0.281 CPU in 0.279 seconds
>> true.
>>
>> /* Trealla Prolog 3.14.17 */
>> ?- between(1,3,_), time(test), fail; true.
>> % CPU elapsed 0.203s, 4_052_402 inferences, 19.950 MLips
>> % CPU elapsed 0.188s, 4_052_402 inferences, 21.613 MLips
>> % CPU elapsed 0.188s, 4_052_402 inferences, 21.613 MLips
>>     true.
>>
>> Is it different library(rbtrees) ?
>>
>> Bye
>>
>> /***************************************************************/
>> /* Backtracking Test                                           */
>> /***************************************************************/
>>
>> % test
>> test :-
>>     between(1, 300, _),
>>     rb_empty(T),
>>     run_set(300, T, T2),
>>     run_remove(600, T2, T3),
>>     rb_size(T3, _),
>>     fail.
>> test.
>>
>> % run_set(+Integer, +Tree, -Tree)
>> run_set(0, T, T) :- !.
>> run_set(N, T, T3) :-
>>     random(W),
>>     K is floor(W*900),
>>     rb_insert(T, K, true, T2),
>>     M is N-1,
>>     run_set(M, T2, T3).
>>
>> % run_remove(+Integer, +Tree, -Tree)
>> run_remove(0, T, T) :- !.
>> run_remove(N, T, T3) :-
>>     random(W),
>>     K is floor(W*900),
>>     (rb_delete(T, K, T2) -> true; T2 = T),
>>     M is N-1,
>>     run_remove(M, T2, T3).
>>
>> Mild Shock schrieb:
>>> Hi,
>>>
>>> Now that even the last village idiot
>>> has groked what Unified Memory is
>>> and maybe also what a GPU is.
>>>
>>> Here a little challenge for the
>>> Prolog community, which probably
>>> still thinks the AI boom is for
>>>
>>> probabilistic parots:
>>>
>>> Winter Challenge 2026:
>>> Linked Data on GPU
>>>
>>> Have Fun!
>>>
>>> Bye
>>>
>>> P.S.: Do we need SLG tabling for that?
>>> If yes how bring it on GPU? If no
>>> what offers the GPU?
>>>
>>> P.P.S.: What about nevertheless
>>> adopting a little probabilistic parots
>>> idea? Like heuristic top N
>>>
>>> linked data queries?
>>
> 
Technical Details
Message-ID: <11dn00l$4ds5$1@solani.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
References: <11dhk07$l2e$1@solani.org> <11djob1$24c4$1@solani.org> <11djvgt$29r6$2@solani.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: Mild Shock <janburse@fastmail.fm>
Newsgroups: comp.lang.prolog
Subject: Shumway Prolog is the real monster [WASM Runtime] (Was: Making Prolog
 more useful [Zen Practice with Cosmology])
Date: Thu, 19 Nov 2026 15:10:29 +0100
Message-ID: <11dn00l$4ds5$1@solani.org>
References: <11dhk07$l2e$1@solani.org> <11djob1$24c4$1@solani.org>
 <11djvgt$29r6$2@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 19 Nov 2026 14:10:29 -0000 (UTC)
Injection-Info: solani.org;
	logging-data="145285"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:esZPgusUAJhxkW8IL6xTj9J8bHU=
X-User-ID: eJwFwYkBwEAEBMCWvItyjtB/CZlxBWPC4DA/v2YzxIGXx3OrEiI9hM+4MqaLnto2kU69PhUNCyMSxZLkDzSYFDw=
In-Reply-To: <11djvgt$29r6$2@solani.org>