
sscasp.pl -- s(CASP) from PrologLoad 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.
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.
user:term_expansion(+Term, -Expanded) is semidet[multifile]:- 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).
scasp_human(:Query) is nondet
scasp_human(:Query, +Options) is nondet:- 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.
The following predicates are exported, but not or incorrectly documented.
scasp_human(Arg1, Arg2)
?(Arg1)
??(Arg1)
?--(Arg1)
?+-(Arg1)
?-+(Arg1)
?++(Arg1)
??+-(Arg1)
??-+(Arg1)
??++(Arg1)