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)?