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.
parent/2 should be nondeterminate, so we should add the
:- nondet parent/2.
before the clauses for
parent/2. If run again after modifying file,
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
nondeterminate, then so is