Embedded scasp not loading

Embedded scasp seems not to be working:

:- use_module(library(scasp)).

:- begin_scasp(qp,[p/1,q/1]).

p(X) :- not q(X).
q(X) :- not p(X).

?- p(X).

:- end_scasp.


$ swipl -f none -q /tmp/t.pl
ERROR: /tmp/t.pl:10:
ERROR:    scasp_input:sasp_statement/5: Deterministic procedure scasp_input:sasp_statement/5 failed
?- p(X).
Correct to: "'_scasp_qp':p(X)"? yes
false.

I guess we should just do:

:- use_module(library(scasp)).

p(X) :- not q(X).
q(X) :- not p(X).

run(M,J) :-
   scasp(p(X),[model(M),tree(J)]).

I guess the embed way is useful in case of operator clash? (like (not)/1)?

The :- begin_scasp ... :- end_scasp was my first attempt. I think it was wrong. Pushed a fix for this simple one. One of the more complicated examples however still fails.

Writing scasp as normal Prolog seems much more natural and ensures all usual Prolog tools keep working. The only price is that the collection and compilation of the code happens at runtime. At this moment the overhead is still neglectable for anything realistic. Should we ever find a way to efficiently deal with the “forall” construct, that may change :slight_smile:

Jan, you mentioned pushing a fix. I installed (12 December 2022) scasp with package_install(scasp). from swipl version 9.02.

The problem seems to still be there, and the solution (above) of run(M,J) seems to be the only thing that works. I tried both the use_module(library(scasp)) and the use_module(library(scasp/embed)) varieties.

Is there anything else that I need to do to make the embed approach work?

It works fine for me:

:- use_module(library(scasp)).

:- begin_scasp(qp,[p/1,q/1]).

p(X) :- not q(X).
q(X) :- not p(X).

:- end_scasp.

And then

swipl s.pl
?- p(X), scasp_model(M).
M = [p(X), not q(X)].

But, I still won’t use it. The begin_scasp/end_scasp is old school. Surely no active support will happen and it is not unlikely it will be removed at some point.

How very strange. I retyped the example exactly as you wrote it and still got the error:

:- use_module(library(scasp)).

:- begin_scasp(qp,[p/1,q/1]).

p(X) :- not q(X).
q(X) :- not p(X).

:- end_scasp.
$  swipl s.pl
ERROR: /g/Prolog/src/scasp/s.pl:8:
ERROR:    scasp_input:sasp_statement/5: Deterministic procedure scasp_input:sasp_statement/5 failed
Welcome to SWI-Prolog (threaded, 64 bits, version 9.0.2)
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).

?-

However, I’m not going to worry about it, because as you say, it’s not the preferred approach anyway.

cheers,

RdR