
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).
claimed(?Term, ?Module, -Expanded) is nondet[private]| `:- pred Spec` | a signature here, a description in the old tree, whose expansion raises on this spelling rather than declining it |
| `:- scasp_dynamic Spec` | declares p/N and -/1; the old tree declares the interned '-p'/N, which this one never puts a clause in |
| `#pred Spec` | the spelling s(CASP) programs are written in — 84 in `test/le_programs/` alone |
| `#abducible Spec`, `:- abducible Spec` | an abducible; the old tree calls its own abducible/1 |
| `#show Spec`, `:- show Spec` | what the model shows |
| `#sld Spec`, `#domain Spec`, `#describe Spec` | the file spelling of :- sld, :- domain, :- describe, so a program reads the same in a module and in a file |
false :- Body | a global constraint; the old tree makes it a clause of -/0 |
Qualified with sscasp_dyncall because what the guard establishes is
that the file imported scasp/2, not that it imported these:
use_module(library(sscasp), [scasp/2]) is a file we claim and in
which a bare pred/1 would not resolve.
template(@Spec, ?Module, -Goal) is det[private]p(X) :: 'text'` is a description and `#pred p(dom)` a
signature. The description goes to describe/1 rather than
pred/1, so it does not warn:
source.pl:partition_terms/7 makes the same choice, because the
warning is for `:- pred X :: "..."` written where :- describe was
available and `#pred` is what the generator emits.
ours(+Module) is semidet[private]user is consulted for every file in the
process, so it has to ask which library the file it is firing on
imported — prolog_load_context(module, M) for the file, and then
this. scasp/dyncall.pl:ours/0 asks the mirror-image question, so
the two never both fire and load order decides nothing.
scasp/2 is the marker rather than the directive being claimed,
because it is what a file imports the library for: a file that has
pred/1 has it by way of scasp/2, and a file that has neither is
not speaking to either library. The property survives the re-export
through library(sscasp), which is why it can be asked of the
importing module rather than of the library.
negated_clause(@Term) is semidet[private]
local_negation(@Head, @Body, -Literal, -Local) is nondet[private]
scasp_residuals// is det[private]scasp/embed.pl) and why the variables
come out named: the toplevel names the whole answer — bindings,
model and the constraints still on the answer's variables — in one
go, so a variable two of them share is one name.
Nothing is emitted unless the query asked, which is what separates
`? Q from scasp(Q)`.
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.
solve_and_show(:Query, +Options) is nondet[private]The following predicates are exported, but not or incorrectly documented.
scasp_human(Arg1, Arg2)
?(Arg1)
??(Arg1)
?--(Arg1)
?+-(Arg1)
?-+(Arg1)
?++(Arg1)
??+-(Arg1)
??-+(Arg1)
??++(Arg1)