The standard prolog predicate that stops backtracking.
kw
cut
The backward chaining goal cut
is a standard prolog predicate. When first called it succeeds and freezes certain choices made by the backward chainer up to this point. It may no longer attempt to resatisfy any of the goals between the start of clause and the cut
, and it may not attempt to use any other clauses to satisfy the same goal.
(defrule nice :backward ((nice ?x) <-- (rottweiler ?x) (cut) (fail)) ((nice ?x) <--))
implements "everything is nice unless it is a rottweiler". First the backward chainer will attempt to prove (nice fido)
with the first clause. If fido
is a rottweiler the cut
then prevents the backward chainer from using the second clause which says "everything is nice". The fail ensures that (nice fido)
fails.
KnowledgeWorks and Prolog User Guide (Unix version) - 01 Dec 2021 19:35:49