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). max_pressups(eddie,12).
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.