The solution is quite easy:
compare3(X, Y, Z):-
X>Y,
Y>Z.
?- compare3(5,4,3).
true.
Keep in mind that you cannot define predicates with an arbitrary number of input parameters (so obviously compare/3
could be called only with 3 input). To make it more flexible you can insert the element in a list and rewrite it like this
myCompare([]).
myCompare([_]):- !.
myCompare([A,B|T]):-
A>B,
myCompare([B|T]).
?- myCompare([5,4,3]).
true.
Now myCompare/1
accepts a list and return true if the list is sorted, false otherwise.