|Did you know ...||Search Documentation:|
|Enabling monotonic CLP(FD)|
In the default execution mode, CLP(FD) constraints still exhibit some non-relational properties. For example, adding constraints can yield new solutions:
?- X #= 2, X = 1+1. false. ?- X = 1+1, X #= 2, X = 1+1. X = 1+1.
This behaviour is highly problematic from a logical point of view, and it may render declarative debugging techniques inapplicable.
Set the Prolog flag
to make CLP(FD)
monotonic: This means that adding new constraints cannot
yield new solutions. When this flag is
true, we must wrap
variables that occur in arithmetic expressions with the functor
(#)/1. For example:
?- set_prolog_flag(clpfd_monotonic, true). true. ?- #(X) #= #(Y) + #(Z). #(Y)+ #(Z)#= #(X). ?- X #= 2, X = 1+1. ERROR: Arguments are not sufficiently instantiated
The wrapper can be omitted for variables that are already constrained to integers.