sCASP: from top level

The following works:

$ ./scasp ./test/birds.pl
% QUERY:?- flies(X).

	ANSWER:	1 (in 60 ms)

MODEL:
{ flies(tweety),  bird(tweety),  not ab(tweety),  not penguin(tweety),  not wounded_bird(tweety),  not -ab(sam),  ab(sam),  penguin(sam),  not -ab(john),  ab(john),  wounded_bird(john),  -ab(Var1 | {Var1 \= john,Var1 \= sam}),  not ab(Var1 | {Var1 \= john,Var1 \= sam}),  not penguin(Var1 | {Var1 \= john,Var1 \= sam}),  not wounded_bird(Var1 | {Var1 \= john,Var1 \= sam}),  not -penguin(sam),  -penguin(Var2 | {Var2 \= sam}),  not penguin(Var2 | {Var2 \= sam}),  not -wounded_bird(john),  -wounded_bird(Var3 | {Var3 \= john}),  not wounded_bird(Var3 | {Var3 \= john}),  not -bird(tweety),  not -bird(john),  bird(john),  -bird(Var4 | {Var4 \= john,Var4 \= tweety}),  not bird(Var4 | {Var4 \= john,Var4 \= tweety}),  not wounded_bird(Var4 | {Var4 \= john,Var4 \= tweety}),  not -flies(tweety),  -flies(sam),  not flies(sam),  not bird(sam),  not wounded_bird(sam),  -flies(john),  not flies(john),  -flies(Var5 | {Var5 \= john,Var5 \= sam,Var5 \= tweety}),  -bird(Var5 | {Var5 \= john,Var5 \= sam,Var5 \= tweety}),  not bird(Var5 | {Var5 \= john,Var5 \= sam,Var5 \= tweety}),  not wounded_bird(Var5 | {Var5 \= john,Var5 \= sam,Var5 \= tweety}),  not flies(Var5 | {Var5 \= john,Var5 \= sam,Var5 \= tweety}) }

BINDINGS: 
X = tweety ? 

But this doesn’t:

$ swipl  -l src/scasp.pl
1 ?- main([ 'test/birds.pl']).
true.

Is there something I am doing wrongly?

No. I did something wrong :slight_smile: Pushed a fix. Note that the code is under very heavy development, so it is likely to break from time to time … Please report problems. If you are playing with it and you happen to create things that may be added to the tests, please share!

Thanks

sure, if I write something that I think may be useful as a test I’ll be happy to share it.

Is there a predicate callable from the swipl toplevel to:

  1. solve an scasp goal and get the results
  2. consult an scasp file? (I’ve been using main/1 but probably there is something better).

No. As is, sCASP is designed to act as a stand alone executable. Part of the proposed changes will turn it the primary setup to be a Prolog embedded language. This means you will be able to write ASP code inside your Prolog file and query it from Prolog. The result must be module and thread aware. It will also imply that you can manage an ASP program as a set of Prolog terms. For applications, think about ILP or dynamically constructing ASP programs from the current program context to do a little sCASP reasoning on it. It will take some time …

Of course, the stand alone program will remain an option.

1 Like

This sounds great. From the little I have learned I think sCASP (and ASP in general I guess) solves the thorny negation problem by providing both default and classical negation, with nice declarative programming. What seems missing is more complete constraints (such as all_different, and those types of global constraints).

The above combination of embedding sCASP code in Prolog I think is a perfect combination. #1 above is solved since eventually you can query it from Prolog, and #2 is also solved since you can consult the Prolog file that embeds the sCASP code.

With sCASP, threads, tabling (esp. monotonic) and the many libraries that SWI-Prolog has, I think all the other prolog implementations will have a very hard time catching up to SWI-Prolog.