Let allDifferent(A, B, C, D, E, F) be true if and only if ∀i, j in {1, 2, 3, 4, 5, 6}, the i-th and j-th arguments unify if and only if i = j.
Thus allDifferent(3, 1, 4, 1, 5, 9) is false, but allDifferent(3, 1, 4, 2, 5, 9) is true.
How does one implement allDifferent/6 in Prolog?
In particular, is there a way to express it that does not require listing the 6-choose-2 = 15 non-equalities A ≠ B, A ≠ C, ..., E ≠ F (or, rather, their Prolog rendition)?
If you accept that
allDifferentreceive a list of values (instead of six values) I can propose the following solution-- EDIT --
As suggested by False, you can use
dif/2instead of\=(if your Prolog provide it) so the mainisDifferent/2can beAnyway... hoping this is obvious... but if you really want a
allDifferent/6instead aallDifferent/1that receive a list, you can define yourallDifferent/6as follows