[ library(cardinal) | Third Party Libraries | Reference Manual | Alphabetic Index ]
# set(?SetVariable, ++Glb, ++Poss, +Functions)

Set variable declaration with optional functions
*SetVariable*
- A variable.
*Glb*
- A ground set.
*Poss*
- A ground set.
*Functions*
- A list.

## Description

Declare or constrain a set domain variable to have Glb as assured
elements and Poss as the possible additional elements.
Functions is a list of functions over SetVariable in the form
FunctionName:FunctionValue, where FunctionName can be 'cardinality',
'minimum', 'maximum' or 'union':

cardinality: FunctionValue can be an integer, an FD variable or an integer domain (list or range)
union: (SetVariable must be a set of sets.) FunctionValue can be a set, a set variable
or a set domain in the form GlbUnion+PossUnion, representing the glb and poss of
the union of SetVariable
minimum and maximum: (SetVariable must be a nonempty set of integers.)
FunctionValue can be an integer, an FD variable or an integer domain

Cardinal inferences over SetVariable and its union, minimum and maximum
functions will be performed only if these functions are explicitly
declared, whereas the cardinality function and respective inferences
will always be present even if this (cardinality) function is not
explicitly declared. Note that a simple function declaration such as
minimum:_ is sufficient to make it 'active'.
### Fail Conditions

Fails if SetVariable can not be constrained accordingly.
### Resatisfiable

No.
## Examples

?- set(S,[],[a,b],[]).
?- set(S,[],[a,b],[cardinality:1]).
?- set(S,[],[a,b],[cardinality:C]).
?- set(S,[],[a,b],[cardinality:[0,2]]).
?- set(S,[c],[a,b,d,e,f,g,h,i,j,k],[cardinality:[2,4..7]]).
?- set(S,[],[1,3,4,5,7],[minimum:Min,maximum:Max]), fd:(Max #> Min+2).
?- set(S, [], [[1,2,5],[2,4],[3,5],[1,3,4]],
[cardinality:2, union:[1,2,3,4,5]]). %set-covering
?- set(S, [], [[1,2,5],[2,4],[3,5],[1,3,4]], [union:[1]+[2,4,5]]).

## See Also

sets / 4, `:: / 2, cardinality / 2, union_var / 2, minimum / 2, maximum / 2, set_labeling / 1