This is a topic to discuss the wiki
Welcome to SWI-Prolog (32 bits, version 8.5.13-33-g3ad3dafc6). ... SWI-Prolog WebAssembly ready! ?- assertz(parent(tom,ann)). true. ?- assertz(parent(mary,ann)). true. ?- parent(P,ann). ERROR: char_code/2: Type error: `character_code' expected, found `-1' (an integer) P = tom
The problem is reproduceable for nondeterministic queries, e.g.
?- between(1,5,N). ERROR: char_code/2: Type error: `character_code' expected, found `-1' (an integer) N = 1
Running Google Chrome on Windows 10 if that helps.
Yes, as the wiki says, execution of the query should not try to read. A nondet toplevel queries tries to read the action from the user. This can surely be solved, but I don’t know how (yet).
In right panel created parent/2 facts.
Then below that clicked
(Re)consult which ran
In left panel ran
parent(P,ann) which prints first result and prompts for next action:
May I ask a rather fundamental question: Is it a good idea at all to run applications in a browser? Nowadays browsers are already way too complex, with a correspondingly large surface for attackers.
also the next paragraph on Security
(Nothing of Importance here)
Excellent work @jan and it is really supporting our goal to enable client side reasoning to reach World wide welding machine transforming data into proofs
It was pretty straightforward to do N3 proof generation in Eyebrow but I’m not sure why the page not always starts with
Welcome to SWI-Prolog (32 bits, version 8.5.15-33-g3ad3dafc6) SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software. Please run ?- license. for legal details. For online help and background, visit https://www.swi-prolog.org For built-in help, use ?- help(Topic). or ?- apropos(Word). SWI-Prolog WebAssembly ready!
and why a
reload is needed.
Most probably it is because eyebrow/socrates.html at c070571d980406db5c05d6b166dfe7aa470eb5f2 · josd/eyebrow · GitHub needs a PR
(Nothing of Importance here)
I don’t know. So far it seems to start properly each time. Now that you are some versions behind. Current development is on the
yield-wasm branch. Testing and feedback welcome. Be aware that there are still a large number of issues and interfaces change quite often. The first challenge is to get the basic toplevel interaction working.
It is clarified and with the help of Jesse Wright fix: remove loading race conditions by jeswr · Pull Request #1 · josd/eyebrow · GitHub
Nice and so far so good with the latest
yield-wasm branch when applied to https://josd.github.io/eyebrow/socrates.html and https://josd.github.io/eyebrow/gps.html although I am not sure why the latter retursn
undefined instead of
The foreign yield has a bug that causes the block of “well known terms”, among which the well formed semantics (WFS) delay list to be garbage collected That is my TODO for this morning … Thanks for reporting.
I have pushed a new version to the normal
master branch and updated SWI-Prolog WebAssembly build test to address this issue. The shell is now a bit more friendly, including the possibility to abort long running queries, handle multiple files and make the programs and command history persistent using the browser’s localStorage.
Async behavior now uses auto yielding and restarts using
setTimeout() That seems to slow down a lot. Hopefully async functions can make this better.
We are getting to a state where some basic evaluation is feasible
[2022-08-08] Fixed yield. Add auto yielding such that the browser remains responsive and queries can be aborted. Allow creating multiple files, Added persistent (using the browser
localStorage) command line history and files.
For those use to using the up arrow to go back in the command history.
To use the up arrow to go back in the command history the input box has to be active for it to work.
Say for example you run a query and click on the Next button, then the input box is no longer active so you have to click on the input box then the up arrow will work.
The middle icon seems to be a trash can.
How it works for me. (Don’t know if this is how it is suppose to work or if it has a bug).
- If the file was updated since being new or clicking re(consult), if you click the trash can the input since the last re(consult) for the file is deleted.
- If the file was not updated since being new or clicking re(consult), If you click the trash can the file is left alone and
program.plbecomes the current file.
If you run a long running query, e.g.
you will now get an abort button while it is running.
Now that we have persistent Prolog files need way to remove or delete the files since they are stored in the browsers cache.
Tried this for Chorme but it does not work.
Press F12 to open developer tools.
Go back to Chrome, right click reload button, select
hard reset and clear cache
Seems that file names with
_ in them are not valid.
The hello world example from SWISH behaves badly.
hello_world :- writeln('Hello World!'), sleep(1), hello_world.
Yes, works now (and beats Ciao Playground, since it has abort):
?- time(fib(25,X)). ERROR: Execution Aborted % 94,176 inferences, 1.608 CPU in 1.608 seconds (100% CPU, 58567 Lips) ?- time(fib(25,X)). % 489,517 inferences, 11.648 CPU in 11.648 seconds (100% CPU, 42026 Lips) X = 121393.
Cool! Do you see some overhead by auto-yielding?
Whats the auto-yielding rate? (in Dogelog I try to reach 60Hz)
In normal SWI-Prolog its much much faster:
?- time(fib(25,X)). % 485,570 inferences, 0.031 CPU in 0.036 seconds (87% CPU, 15538240 Lips) X = 121393.
Maybe you do over auto-yielding? Or whats the issue? Or maybe
memory shortage in WASM? 42026 LIPS is very poor, could be
result of an expensive auto-yielding or some other issue.
For reproduction of the result, I used this code:
fib(0,1) :- !. fib(1,1) :- !. fib(N,X) :- N>1, M is N-1, fib(M,Y), L is M-1, fib(L,Z), X is Y+Z.
Ciao Prolog on WASM does fib(25,X) with that code in 20-30ms.
Where does the time out comes from?
Note also that the timeout in Ciao is a completely arbitrary number (mostly for students). It is configurable from the .html code but the next version will allow changing it from the Prolog side too.
(Nothing of Importance here)
I really do not understand “(and beats Ciao Playground, since it has abort)”. Ciao Prolog WASM does fib(25,X) in 20-30ms. in my machine and x5 slower in SWI Prolog WASM. It is possible that Ciao WASM is faster than SWI native in those artificial benchmarks (which of course, means absolutely nothing since real applications are much more complex than fib/2…).
@jan It may be good to design a shared set of benchmarks to measure different aspects and features of our engines.