[ library(fd_global) | Reference Manual | Alphabetic Index ]

alldifferent(+Vars)

All members of Vars are different
Vars
A collection (a la collection_to_list/2) of variables or integers

Description

Constrains all elements of a collection to be pairwise different (and integral). This is an implementation with the same semantics as the standard alldifferent/1 constraint, but with stronger propagation behaviour. It checks for exhaustion of all sub-ranges of possible values.

The algorithm is based roughly on: Jean Francois Puget, A fast algorithm for the bound consistency of the alldiff constraint, AAAI 1998, but makes some additional inferences based on domain size.

Any input variables which do not already have finite bounds will be given default bounds of -10000000 to 10000000.

Examples

    ?- length(Xs,5), Xs::1..4, alldifferent(Xs).
    no (more) solution.


    ?- [X1,X2]::1..2, [X3,X4,X5]::1..5, alldifferent([X1,X2,X3,X4,X5]).

    X1 = X1{[1, 2]}
    X2 = X2{[1, 2]}
    X3 = X3{[3..5]}
    X4 = X4{[3..5]}
    X5 = X5{[3..5]}

    Delayed goals:
        alldifferent([X1{[1, 2]}, X2{[1, 2]}], 1)
        alldifferent([X3{[3..5]}, X4{[3..5]}, X5{[3..5]}], 1)
    

See Also

ic : alldifferent / 1, ic_symbolic : alldifferent / 1, gfd : alldifferent / 1, sd : alldifferent / 1, ic_global : alldifferent / 1, fd : alldifferent / 1, fd_global_gac : alldifferent / 1, ic_global_gac : alldifferent / 1, alldifferent / 2, eclipse_6 : collection_to_list / 2, lists : collection_to_list / 2