-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Odd behavior on backtracking #52
Comments
Reduced it further: :- module(js_toplevel, [js_ask/1]).
:- use_module(library(lists)).
js_ask(Input) :-
read_term_from_chars(Query, [variable_names(Vars)], Input),
query(Query, Status),
write(Vars), nl, write(Status), nl,
call_any_predicate(Status). % deleting this fixes it?
call_any_predicate(_).
query(Query, Status) :-
% weird:
catch(Query, Error, true),
% ok:
% call(Query),
query_status(true, Error, Status).
query_status(_OK, Error, error) :- nonvar(Error), !.
query_status(true, _, success).
query_status(false, _, failure).
person(socrates).
person(plato).
mortal(X) :- person(X). I think optimization is the culprit: $ ./tpl --version
Trealla Prolog (c) Infradig 2020-2022, v2.2.15
# weird
$ ./tpl js_toplevel.pl -g 'js_ask("mortal(X)")' --ns
[X=socrates]
success
true
;
# ok
$ ./tpl js_toplevel.pl -O0 -g 'js_ask("mortal(X)")' --ns
[X=socrates]
success
true
; [X=plato]
success
true
; |
It would seem so.
…On Sat, Oct 1, 2022 at 12:32 AM guregu ***@***.***> wrote:
Reduced it further:
:- module(js_toplevel, [js_ask/1]).
:- use_module(library(lists)).
js_ask(Input) :-
read_term_from_chars(Query, [variable_names(Vars)], Input),
query(Query, Status),
write(Vars), nl, write(Status), nl,
call_any_predicate(Status). % deleting this fixes it?
call_any_predicate(_).
write_result(Status, Solution) :-
write(Status), write(' '), write(Solution), nl.
query(Query, Status) :-
% weird:
catch(Query, Error, true),
% ok:
% call(Query),
query_status(true, Error, Status).
query_status(_OK, Error, error) :- nonvar(Error), !.query_status(true, _, success).query_status(false, _, failure).
person(socrates).person(plato).mortal(X) :- person(X).
I think optimization is the culprit:
$ ./tpl --version
Trealla Prolog (c) Infradig 2020-2022, v2.2.15
# weird
$ ./tpl js_toplevel.pl -g 'js_ask("mortal(X)")' --ns
[X=socrates]
success
true;
# ok
$ ./tpl js_toplevel.pl -O0 -g 'js_ask("mortal(X)")' --ns
[X=socrates]
success
true; [X=plato]
success
true;
—
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNKSESLJQEYI2KQFZKFFILWA32ZHANCNFSM6AAAAAAQZZVIGA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
infradig
added a commit
that referenced
this issue
Oct 1, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Backtracking here seems to use the wrong variable substitutions (as mentioned here: #46 (comment)).
Here's the smallest way to reproduce it I could find.See comment below for smaller version.
Trace shows odd backtracking:
In particular step 51 looks suspect.
The text was updated successfully, but these errors were encountered: