- Documentation
- Reference manual
- The SWI-Prolog library
- library(clpfd): CLP(FD): Constraint Logic Programming over Finite Domains
- CLP(FD) predicate index
- Arithmetic constraints
- Membership constraints
- Enumeration predicates
- Global constraints
- Reification predicates
- Reflection predicates
- FD set predicates
- in_set/2
- fd_set/2
- is_fdset/1
- empty_fdset/1
- fdset_parts/4
- empty_interval/2
- fdset_interval/3
- fdset_singleton/2
- fdset_min/2
- fdset_max/2
- fdset_size/2
- list_to_fdset/2
- fdset_to_list/2
- range_to_fdset/2
- fdset_to_range/2
- fdset_add_element/3
- fdset_del_element/3
- fdset_disjoint/2
- fdset_intersect/2
- fdset_intersection/3
- fdset_member/2
- fdset_eq/2
- fdset_subset/2
- fdset_subtract/3
- fdset_union/3
- fdset_union/2
- fdset_complement/2
- FD miscellaneous predicates
- CLP(FD) predicate index
- library(clpfd): CLP(FD): Constraint Logic Programming over Finite Domains
- The SWI-Prolog library
- Packages
- Reference manual
A.9.17.7 FD set predicates
These predicates allow operating directly on the internal representation of CLP(FD) domains. In this context, such an internal domain representation is called an FD set.
Note that the exact term representation of FD sets is unspecified and will vary across CLP(FD) implementations or even different versions of the same implementation. FD set terms should be manipulated only using the predicates in this section. The behavior of other operations on FD set terms is undefined. In particular, you should not construct or deconstruct FD sets by unification, and you cannot reliably compare FD sets using unification or generic term equality/comparison predicates.
- ?Var in_set +Set
- Var is an element of the FD set Set.
- [det]fd_set(?Var, -Set)
- Set is the FD set representation of the current domain of Var.
- [semidet]is_fdset(@Set)
- Set is currently bound to a valid FD set.
- [det]empty_fdset(-Set)
- Set is the empty FD set.
- [semidet]fdset_parts(?Set, ?Min, ?Max, ?Rest)
- Set is a non-empty FD set representing the domain Min..Max
\/
Rest, where Min..Max is a non-empty interval (see fdset_interval/3) and Rest is another FD set (possibly empty).If Max is sup, then Rest is the empty FD set. Otherwise, if Rest is non-empty, all elements of Rest are greater than Max+1.
This predicate should only be called with either Set or all other arguments being ground.
- [semidet]empty_interval(+Min, +Max)
- Min..Max is an empty interval. Min and Max are integers or one of the atoms inf or sup.
- [semidet]fdset_interval(?Interval, ?Min, ?Max)
- Interval is a non-empty FD set consisting of the single
interval
Min..Max.
Min is an integer or the atom inf to denote negative
infinity.
Max is an integer or the atom sup to denote positive
infinity.
Either Interval or Min and Max must be ground.
- [semidet]fdset_singleton(?Set, ?Elt)
- Set is the FD set containing the single integer Elt.
Either Set or Elt must be ground.
- [semidet]fdset_min(+Set, -Min)
- Min is the lower bound (infimum) of the non-empty FD set Set. Min is an integer or the atom inf if Set has no lower bound.
- [semidet]fdset_max(+Set, -Max)
- Max is the upper bound (supremum) of the non-empty FD set Set. Max is an integer or the atom sup if Set has no upper bound.
- [det]fdset_size(+Set, -Size)
- Size is the number of elements of the FD set Set, or the atom sup if Set is infinite.
- [det]list_to_fdset(+List, -Set)
- Set is an FD set containing all elements of List, which must be a list of integers.
- [det]fdset_to_list(+Set, -List)
- List is a list containing all elements of the finite FD set Set, in ascending order.
- [det]range_to_fdset(+Domain, -Set)
- Set is an FD set equivalent to the domain Domain. Domain uses the same syntax as accepted by (in)/2.
- [det]fdset_to_range(+Set, -Domain)
- Domain is a domain equivalent to the FD set Set. Domain is returned in the same format as by fd_dom/2.
- [det]fdset_add_element(+Set1, +Elt, -Set2)
- Set2 is the same FD set as Set1, but with the integer Elt added. If Elt is already in Set1, the set is returned unchanged.
- [det]fdset_del_element(+Set1, +Elt, -Set2)
- Set2 is the same FD set as Set1, but with the integer Elt removed. If Elt is not in Set1, the set returned unchanged.
- [semidet]fdset_disjoint(+Set1, +Set2)
- The FD sets Set1 and Set2 have no elements in common.
- [semidet]fdset_intersect(+Set1, +Set2)
- The FD sets Set1 and Set2 have at least one element in common.
- [det]fdset_intersection(+Set1, +Set2, -Intersection)
- Intersection is an FD set (possibly empty) of all elements that the FD sets Set1 and Set2 have in common.
- [nondet]fdset_member(?Elt, +Set)
- The integer Elt is a member of the FD set Set. If Elt is unbound, Set must be finite and all elements are enumerated on backtracking.
- [semidet]fdset_eq(+Set1, +Set2)
- True if the FD sets Set1 and Set2 are equal, i. e. contain exactly the same elements. This is not necessarily the same as unification or a term equality check, because some FD sets have multiple possible term representations.
- [semidet]fdset_subset(+Set1, +Set2)
- The FD set Set1 is a (non-strict) subset of Set2, i. e. every element of Set1 is also in Set2.
- [det]fdset_subtract(+Set1, +Set2, -Difference)
- The FD set Difference is Set1 with all elements of Set2 removed, i. e. the set difference of Set1 and Set2.
- [det]fdset_union(+Set1, +Set2, -Union)
- The FD set Union is the union of FD sets Set1 and Set2.
- [det]fdset_union(+Sets, -Union)
- The FD set Union is the n-ary union of all FD sets in the list Sets. If Sets is empty, Union is the empty FD set.
- [det]fdset_complement(+Set, -Complement)
- The FD set Complement is the complement of the FD set Set.
Equivalent to
fdset_subtract(inf..sup, Set, Complement)
.