All Manuals > KnowledgeWorks and Prolog User Guide > 7 Reference Guide

cut Backward Chaining Goal

Summary

The standard prolog predicate that stops backtracking.

Package

kw

Signature

cut

Description

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.

Examples
(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.

See also

fail


KnowledgeWorks and Prolog User Guide (Unix version) - 01 Dec 2021 19:35:49