[not loaded]PublicShow sourcesscasp.pl -- s(CASP) from Prolog

Load this, write the program as ordinary Prolog clauses, and ask:

:- use_module(library(sscasp)).

bird(tweety).
bird(polly).
penguin(polly).
flies(X) :- bird(X), not penguin(X).

?- ? flies(X).
Model:
    bird(tweety)
    flies(tweety)
    not penguin(tweety)
X = tweety.

scasp/2 is the predicate; the ?-prefixed operators are the same thing with the printing chosen for you, for use at a toplevel. scasp/2 collects the clauses the query reaches — see sscasp/dyncall.pl for what that means and for how a program says the things Prolog has no syntax for.

The shortcuts

Each asks for what its name says — the + and - are the model and the justification, in that order — and the toplevel shows it, as part of the answer:

`?-- Q`bindings only
`?+- Q`, `? Q`and the model
`?-+ Q`and the justification
`?++ Q`, `?? Q`both
`??+- Q`, `??-+ Q`, `??++ Q`the same, said in words

They are ordinary nondeterministic goals: ; at the toplevel asks for the next answer, and shows it the same way.

They show nothing outside a toplevel. The model reaches the terminal through residual_goals//0, which is the toplevel's hook for adding to an answer, and that is deliberate: the model then comes after the bindings, and the toplevel names the variables of the answer and of the model together — `¬ ab(_A) and _A` being anything but john or sam are one variable, and a model printed on its own could not say so. To print from a program, use scasp_human/1,2, or scasp/2 with portray_model/2 and portray_justification/2.

Source user:term_expansion(+Term, -Expanded) is semidet[multifile]
A global constraint is a rule with no head. :- Body. in a Prolog file is a directive to run at load time, and false/0 is a built-in that cannot be given clauses, so false :- Body. becomes a clause of 'scasp$constraint'/1 in the same module instead — see sscasp/dyncall.pl:constraint_clauses/2.

In user because that is where SWI looks: an expansion exported from a library is not consulted for the module that imported it. The old implementation puts its own there for the same reason (scasp/dyncall.pl, which maps false :- Body onto a clause of -/0).

Source scasp_human(:Query) is nondet
Source scasp_human(:Query, +Options) is nondet
The same, said in words: each literal by its :- describe template where the program wrote one, and by sscasp/lang.pl's vocabulary where it did not. This is the old implementation's `--human`, and it goes through the same HTML description — see sscasp/html.pl.

Unlike the ?-shortcuts this prints, so it is the one to use from a program. Options are scasp/2's, plus show_model(Boolean) and show_justification(Boolean), both true here.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 scasp(Arg1)
 scasp(Arg1, Arg2)
 scasp_query_clauses(Arg1, Arg2)
 scasp_query_clauses(Arg1, Arg2, Arg3)
 scasp_directive(Arg1)
 scasp_show(Arg1, Arg2)
 scasp_json(Arg1, Arg2)
 scasp_json(Arg1, Arg2, Arg3)
Source scasp_human(Arg1, Arg2)
 scasp_dynamic(Arg1)
 scasp_assert(Arg1)
 scasp_assert(Arg1, Arg2)
 scasp_retract(Arg1)
 scasp_retractall(Arg1)
 scasp_abolish(Arg1)
 sld(Arg1)
 describe(Arg1)
 pred(Arg1)
 domain(Arg1)
 #=(Arg1, Arg2)
 #<>(Arg1, Arg2)
 #<(Arg1, Arg2)
 #>(Arg1, Arg2)
 #=<(Arg1, Arg2)
 #>=(Arg1, Arg2)
Source ?(Arg1)
Source ??(Arg1)
Source ?--(Arg1)
Source ?+-(Arg1)
Source ?-+(Arg1)
Source ?++(Arg1)
Source ??+-(Arg1)
Source ??-+(Arg1)
Source ??++(Arg1)
 scasp_readable(Arg1, Arg2)
 scasp_readable(Arg1, Arg2, Arg3)
 portray_model(Arg1)
 portray_model(Arg1, Arg2)
 portray_justification(Arg1)
 portray_justification(Arg1, Arg2)
 html_model(Arg1, Arg2, Arg3, Arg4)
 html_justification(Arg1, Arg2, Arg3, Arg4)
 html_query(Arg1, Arg2, Arg3, Arg4)
 html_atom(Arg1, Arg2, Arg3, Arg4)
 scasp(Arg1)
 scasp(Arg1, Arg2)
 scasp_query_clauses(Arg1, Arg2)
 scasp_query_clauses(Arg1, Arg2, Arg3)
 scasp_directive(Arg1)
 scasp_show(Arg1, Arg2)
 scasp_json(Arg1, Arg2)
 scasp_json(Arg1, Arg2, Arg3)
 scasp_dynamic(Arg1)
 scasp_assert(Arg1)
 scasp_assert(Arg1, Arg2)
 scasp_retract(Arg1)
 scasp_retractall(Arg1)
 scasp_abolish(Arg1)
 sld(Arg1)
 describe(Arg1)
 pred(Arg1)
 domain(Arg1)
 #=(Arg1, Arg2)
 #<>(Arg1, Arg2)
 #<(Arg1, Arg2)
 #>(Arg1, Arg2)
 #=<(Arg1, Arg2)
 #>=(Arg1, Arg2)
 html_model(Arg1, Arg2, Arg3, Arg4)
 html_justification(Arg1, Arg2, Arg3, Arg4)
 html_query(Arg1, Arg2, Arg3, Arg4)
 html_atom(Arg1, Arg2, Arg3, Arg4)
 scasp_readable(Arg1, Arg2)
 scasp_readable(Arg1, Arg2, Arg3)
 portray_model(Arg1)
 portray_model(Arg1, Arg2)
 portray_justification(Arg1)
 portray_justification(Arg1, Arg2)