[ Reference Manual | Alphabetic Index ]


Simple solver for constraints over unordered symbolic domains   [more]


?Vars &:: +Domain
All elements of Vars have a value in the domain Domain
?X &= ?Y
X is the same atomic value as Y
&=(?X, ?Y, ?Bool)
Reified version of X &= Y
?X &\= ?Y
X is different from Y
&\=(?X, ?Y, ?Bool)
Reified version of X &\= Y
All elements of List are different
deleteff(-Min, +List, -Rest)
Pick minimum domain size element from a list (first fail principle)
get_domain_as_list(?Term, -List)
Retrieves the domain of a variable (or value) as a list of values
get_domain_size(?Term, -Size)
Gives the size of the domain of a variable (or value)
Nondeterministically instantiate to domain values
The argument is a domain variable
The argument is a domain variable or atomic constant
The argument is a domain variable
Instantiate all domain variables in a list to domain values
msg(?X, ?Y, -MSG)
MSG is the most specific generalisation of X and Y representable with domain variables from this library


struct sd(dom, any)
No description available

Other Exports

export op(700, xfx, [&::, &=, &\=])



This is a simple library implementing variables and constraints over atomic values. Its main purpose is for first experiments with constraint solving. Moreover, those interested in writing their own constraint solvers can use the source code of this library as a starting point.


Domains are declared by giving a list of possible values for a variable, e.g.
    	?- X &:: [red, green, blue].
	X = X{[blue, green, red]}
	Yes (0.00s cpu)
A variable that has been given a domain can only be instantiated to values from this domain. Any attempt to instantiate the variable to a non-domain value will cause failure:
    	?- X &:: [red, green, blue], X = red.
	X = red
	Yes (0.00s cpu)
    	?- X &:: [red, green, blue], X = yellow.
	No (0.00s cpu)

Basic Constraints

There are only two basic constraints, equality and disequality:
X &= Y
X is the same as Y
X &\= Y
X is different from Y
Both constraints exist in a reified form:
Bool is the truth value (0/1) of X &= Y
Bool is the truth value (0/1) of X &\= Y

Global Constraints

One derived, global constraint is implemented:
All list elements are different


Domain variables can be instantiated to their domain values using
enumerate values of X
enumerate values of all elements of list Xs


Generated from sd.eci on 2022-04-24 18:55