Previous Up Next

10.3  Set Variables

Set variables are variables which can eventually take a ground integer set as their value. They are characterized by a lower bound (the set of elements that are definitely in the set) and an upper bound (the set of elements that may be in the set). A set variable can be declared as follows:

SetVar :: []..[1,2,3,4,5,6,7]

If the lower bound is the empty set and the upper bound is a set of consecutive integers, one can also declare it like

intset(SetVar, 1, 7)

which is equivalent to the above.

?Set :: ++Lwb..++Upb
Set is an integer set within the given bounds
intset(?Set, +Min, +Max)
Set is a set containing numbers between Min and Max
intsets(?Sets, ?N, +Min, +Max)
Sets is a list of N sets containing numbers between Min and Max
Figure 10.1: Declaring Set Variables

The system prints set variables in a particular way, for instance:

?- lib(ic_sets).
?- X :: [2,3]..[1,2,3,4].
X = X{[2, 3] \/ ([] .. [1, 4]) : _308{[2 .. 4]}}

The curly brackets contain the description of the current domain of the set variable in the form of

  1. the lower bound of the set (values which definitely are in the set)
  2. the union symbol \/
  3. the set of optional values (which may or may not be in the set)
  4. a colon
  5. a finite domain variable indicating the admissible cardinality for the set

Previous Up Next