!/0¶
!* is iso
Read as "cut". Cuts any choices taken in the current procedure. When first found "cut" succeeds as a goal, but if backtracking should later return to it, the parent goal (the one which matches the head of the clause containing the "cut", causing the clause activation) will fail. This is an extra-logical predicate and cannot be explained in terms of the declarative semantics of Prolog.
example:
member(X,[X|_]).
member(X,[_|L]) :- member(X,L).
With the above definition
?- member(X,[1,2,3]).
will return each element of the list by backtracking. With the following definition:
member(X,[X|_]) :- !.
member(X,[_|L]) :- member(X,L).
the same query would return only the first element of the list, since backtracking could not "pass through" the cut.