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

complement(?SetVar, ++Universe, ?Complement)

Set complement constraint
SetVar
A variable.
Universe
A ground set.
Complement
A variable

Description

Constrain sets so that Complement is the complement set of SetVar, with respect to the given Universe. I.e. Complement is Universe \ SetVar.

If a variable (SetVar or Complement) is not yet a set domain variable, it is declared as such, limited by the Universe.

This constraint is usually more efficient (stronger) than posting an equivalent set difference constraint, due to specific inferences.

Fail Conditions

Fails if Complement can not be the set complement of SetVar in set universe Universe.

Resatisfiable

No.

Examples

?- complement([7,8], [1,7,8,9], N).
N = [1,9]

?- complement(N, [1,7,8,9], [7,8]).
N = [1,9]

?- X `:: [a]+[b,c,d], Y `:: []+[a,b,c,d,e,f], complement(X, [a,b,c,d,e,f,g], Y).
no

?- X `:: [a]+[b,c,d], Y `:: []+[a,b,c,d,e,f], complement(X,[a,b,f],Y), domain(X,DX),domain(Y,DY).
DX = [[a]:1,[b]:2], DY = [[f]:1,[b]:2]

?- X `:: [a]+[b,c,d], Y `:: []+[a,b,c,d,e,f], complement(X, [a,b,c,d,e,f], Y), domain(Y,DY).
DY = [[e,f]:2,[b,c,d]:5]

See Also

complement / 2, `$ / 2, `= / 2