If SetVariable is a set of sets and a union function attribute has been set, then each element of Poss comes annotated with its respective length.
Use domain/3 instead of domain/2 whenever Cardinality variable is available, for efficiency reasons, since in the case of SetVariable being already ground, it is not neccessary to recalculate its length (to retrieve [Setvariable:Cardinality,[]:Cardinality]. This is due to the loss of attributes of variables when these become instantiated.
Cardinality should be input to domain/3. Do not use this predicate to retrieve the cardinality of a set, for it will only work when set is ground.
?- S `::[c]+[a,b]:C, domain(S,C,D). D = [[c]:1, [a,b]:3] ?- S `::[c]+[a,b]:C, S=[a,c], domain(S,C,D). D = [[a,c]:2, []:2] ?- set(S, [],[[a,b],[b,c],[a,c],[b]],[union:[a,b,c],cardinality:C]), domain(S,C,D). D = [[]:0, [[a,b]:2, [a,c]:2, [b]:1, [b,c]:2]:4]