Previous Up
10.3 Real and Herbrand domains combinations

10.3.1 Unification

The unification of a CLP(R) variable either to another CLP(R) variable or to a floating point number is interpreted as an equality constraint. For example :
| ?- {X=2*Y+3*Z}, Z=Y, X=5.0.

X = 5.0
Y = 1.0
Z = 1.0

yes
is equivalent to
| ?- {X=2*Y+3*Z, Z=Y, X=5}.

X = 5.0
Y = 1.0
Z = 1.0

yes
Note that CLP(R) variables cannot be bound to integer numbers. This is because, in standard Prolog, unification between float and integer fails. Inside {} the integer values are automatically converted into floats.

10.3.2 Implicit equalities

The solver tries to detected equalities implied by the store of constraints and unifies CLP(R) variables in consequence. Currently equalities implied by inequations are not detected. For example in the following goal, the two first constraints imply A=2.0 and B=C and the two last imply X=1.0, but only the first equalities are detected.
| ?- {A+B-C=2, A-B+C=2}, {1>=X, 1=<X}.

{ X =< 1.0 }
{ -1.0 * X =< -1.0 }
A = 2.0
C = B

yes
10.3.3 Nonlinear constraints

The solver presented here can only solve linear constraints, however it freezes all nonlinear constraints in the hope that they would become linear. A nonlinear constraint may be reduce to a linear one by unification, example :

| ?- {X + 2 * X * Y + Y**2 = 10}.

{ Y ** 2 + X * Y * 2.0 + X = 10.0 }

yes
| ?- {X + 2 * X * Y + Y**2 = 10}, Y=1.0.

X = 3.0
Y = 1.0

yes




Copyright (C) 1999-2002 Daniel Diaz.

Chapters 9 and 10 : Copyright (C) 2002-2003 INRIA, Rémy Haemmerlé.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

More about the copyright
Previous Up