A constraint network is defined by a triplet
Constraint programming is a form of declarative programming. Constraints specify the desired properties of a solution, not a sequence of steps to execute.
A constraint satisfaction problem (CSP) is defined by a triplet <X,C,D>
, where X
is a set of variables, C
is a set of constraints, and D
a domain for X
(i.e. a mapping from variables to sets of values).
A CSP is called consistent if it has a solution.
Constraint programming blends in naturally with logic programming, since logic programming can in fact be regarded as a special form of constraint programming, where the domain is the set of Herbrand terms. When constraint programming is hosted by a logic programming language, it is called constraint logic programming and abbreviated as CLP.
The notion CLP(X) is used to refer to constraint logic programming over the domain X. The following instances are of particular relevance:
- CLP(FD): reasoning over integers (see clpfd)
- CLP(B): reasoning over Boolean variables (see clpb)
- CLP(Q): reasoning over rational numbers (see clpq)
- CLP(R): reasoning over real numbers or an approximation (see clpq).
All widely used Prolog systems (see prolog) ship with several constraint solvers, which are available either as built-in predicates or provided by libraries.
More information: