Prolog Language Constraint Logic Programming CLP(FD)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

CLP(FD) constraints (Finite Domains) implement arithmetic over integers. They are available in all serious Prolog implementations.

There are two major use cases of CLP(FD) constraints:

  • Declarative integer arithmetic
  • Solving combinatorial problems such as planning, scheduling and allocation tasks.

Examples:

?- X #= 1+2.
X = 3.

?- 3 #= Y+2.
Y = 1.

Note that if is/2 were to be used in the second query, an instantiation error would occur:

?- 3 is Y+2.
ERROR: is/2: Arguments are not sufficiently instantiated


Got any Prolog Language Question?