The cut

next up previous contents
Next: Advantages of Prolog
Up: Introduction to Prolog for Mathematicians
Previous: The effect of clause ordering

The cut

To avoid writing the negation of a condition, Prolog uses the cut, written as !:

has_fitness(Skier, poor) :-
    max_pressups(Skier, P),
    P < 15,

has_fitness(Skier, good).


The ! in the first clause means ``if you get this far, then discard (cut out) any alternative solutions''.

Cut is very frequently used. But it destroys the logical reading of clauses which contain it. Logically, the clauses above mean

Skier has fitness poor if
    he can do less than 15 press-ups.

Skier has fitness good.
The second sentence contradicts the first.

Jocelyn Ireson-Ireson-Paine
Mon Jul 17 22:27:41 BST 1995