Uderstanding the output of Cut in Prolog

I have been learning to use cut in Prolog. I am a little confused about the output of the following program:

min1(X,Y,X):- X=<Y.
min1(X,Y,Y):- Y<X.

min2(X,Y,X):- X=<Y,!.
min2(X,Y,Y):- Y<X,!.

min3(X,Y,X):- X=<Y,!.
min3(X,Y,Y).

min4(X,Y,Z):- X=<Y,!,Z=X.
min4(X,Y,Y).

min5(X,Y,X):-  X=<Y,!.
min5(X,Y,Y):- Y<X.

Why is it so that when I try min3(2,6,6) or min5(2,6,6) they gives me a yes as answer while other mins behave normally?



Read more here: https://stackoverflow.com/questions/66326039/uderstanding-the-output-of-cut-in-prolog

Content Attribution

This content was originally published by yamini goel at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: