Finding query for which a prolog program gives incorrect result
问题 This Prolog program defines the third argument to be the maximum value of the first two numeric arguments: max(X, Y, X) :- X >= Y, !. max(X, Y, Y). I think that this program works just fine. But I am told that it can give incorrect result. Can you tell when and why? 回答1: This is a textbook example. ?- max(5,1,1). true. Homework: Why is the program wrong? How do we make the program correct? EDIT max(X, Y, X) :- X >= Y, !. max(X, Y, Y). Our intention is to say: If X is greater than Y, then Max