Cut and Fail in Prolog
it fails because fail
must fail.
The cut removes alternatives, then forbids values that otherwise would be 'returned' by means of X
binding. Try
a(X) :- b(X),c(X),fail.
...
you'll get
?- a(X).
X = 4.
example :
a(X):- b(X),!,fail. %is the same as \+ a(X):- b(X).
the merge of "!" and "fail" gives you the negative of a(X).
its called the Negation by Failure.