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

card_labeling(?SetVars)

Label cardinality of set variables
SetVars
A list of set variables.

Description

Instantiate all cardinalities of variables in SetVars from first to last, using indomain/1 predicate of fd library.

card_labeling/1 is defined as:

  card_labeling([]).
  card_labeling([H|T]):-
	cardinality(H, C),
	indomain(C),
	card_labeling(T).

Fail Conditions

Fails if cardinalities of SetVars can not be labeled (because constraint propagation leads to a failure).

Resatisfiable

Yes.

Examples

?- S `:: [a]+[b,c]:CS, T `:: [1] + [2], card_labeling([S, T]).
CS = 1, S = [a], T = [1] ;
CS = 1, S = [a], T = [1, 2] ;
CS = 2, T = [1] ;
CS = 2, T = [1, 2] ;
CS = 3, S = [a,b,c], T = [1] ;
CS = 3, S = [a,b,c], T = [1, 2] ;
no

?- S `:: [a] + [b,c,d,e,f]:[2,3,6,9], card_labeling([S]), cardinality(S,C).
C = 2 ;
C = 3 ;
C = 6, S = [a,b,c,d,e,f] ;
no

See Also

set_labeling / 2, refine / 2, cardinality / 2