Sometimes we would like a way of stopping Prolog looking for other solutions. That is we want some predicate to have only one solution (if it has one at all). This is the requirement that the predicate be determinate.
Naturally predicates which do not have this property are indeterminate. This is a desirable property sometimes --- e.g. the generate --- test schema makes use of the generator being indeterminate. On the other hand it can cause major problems when a program has many predicates which are unintentionally indeterminate. Our aim is to make sure that those predicates which should be determinate actually are determinate.
We have already met an example of a predicate ( memberchk/2) that might have been written with this situation in mind. We recall that member/2 used with mode member(- +) behaves as a generator. Perhaps it is worth pointing out that member/2 with mode member(+ +) is also under certain circumstances resatisfiable ---precisely when there are repetitions of the sought element in the list which constitutes the second argument.
Of course if we are dealing with lists--as--sets we should have arranged it so that the second argument does not have repeated elements. Anyway it is very desirable to have a determinate version of member/2 available.
memberchk(X [XNote this isn't quite what we had before. Previously we arranged for memberchk/2 to be determinate with the help ofY]):-
make_determinate.
memberchk(X [Y
Z]):-
memberchk(X Z).
\+/1.
Stating our requirement as above
we seem to be going outside of logic in order
to tell the Prolog interpreter that
once we have found
the element sought
we never want to consider this predicate
as resatisfiable.