[ library(cardinal) | Third Party Libraries | Reference Manual | Alphabetic Index ]

# all_disjoint(+SetVars)

All sets disjointness global constraint

SetVars
  A list of set variables.

## Description

Constrain all pairs of sets in SetVars to be disjoint. I.e. No two sets can have a common element (empty pairwise intersection).

This version of all_disjoint/1 is a weak global constraint, but stronger than the simple posting of all pairwise disjoint/2 constraints, since it posts the additional constraint that the sum of the cardinalities of SetVars must be less than or equal to the cardinality of the union of all the initial LUBs.

### Fail Conditions

Fails if SetVars can not be all disjoint.

### Resatisfiable

No.

## Examples

    ?- all_disjoint([[7],[8],[i,k]]).
    yes

    ?- all_disjoint([[7,8],[i],[8]]).
    no

    ?- sets([X,Y,Z], [],[1,2,7,8,9], [cardinality:2]), all_disjoint([X,Y,Z]).
    no

    ?- sets([X,Y,Z], [],[1,2,7,8,9], [cardinality:2]), all_disjoint([X,Y,Z]), 2 `@ X, lub(Y,LubY), lub(Z,LubZ)
    LubY = [1,7,8,9], LubZ = [1,7,8,9]

## See Also

`$ / 2, `<> / 2, complement / 2, complement / 3, `/= / 2, all_union / 2