Next: Det Options, Previous: Checker Output, Up: The Determinacy Checker [Contents][Index]
Here is an example file:
:- load_files(library(detcheck), [when(compile_time), if(changed)]). parent(abe, rob). parent(abe, sam). parent(betty, rob). parent(betty, sam). is_parent(Parent) :- parent(Parent, _).
The determinacy checker notices that the first arguments of clauses 1 and 2 have the same principal functor, and similarly for clauses 3 and 4. It reports:
* Non-determinate: user:parent/2 (clause 1) * Indexing cannot distinguish this from clause 2. * Non-determinate: user:parent/2 (clause 3) * Indexing cannot distinguish this from clause 4.
In fact, parent/2
should be nondeterminate, so we should
add the declaration
:- parent/2 is nondet.
before the clauses for parent/2
. If run again after modifying file, then
the determinacy checker prints:
* Non-determinate: user:is_parent/1 (clause 1) * This clause calls user:parent/2, which may be nondeterminate.
It no longer complains about parent/2
being nondeterminate,
since this is declared. But now it notices that because parent/2
is nondeterminate, then so is is_parent/1
.