Baker
On 06/05/2014 04:37 PM, Frédéric Goualard wrote: Dear all,
Some time ago I voiced my opposition to having the functions
divRev1(), divRev2()---and, I guess, recipRev() too---included in
the standard (see Table 10.1 in D9.2). I would like to clarify here
what are my concerns about these functions:
As Michel Hack pointed out, divRev1() and divRev2() are useful to
narrow the domains of X and Y in the relation:
X/Y=Z
Dmitri Nadezhin added that the relations X/Y=Z and X=ZY are not
equivalent since the tuple (X=0, Y=0, Z=1) belongs to the second
one but not to the first.
Obviously, they are both right. And yet, in the context of
constraint programming---the precise setting for the benefit of
which these operators are introduced---I believe the relations
X/Y=Z and X=ZY SHOULD be equivalent to prevent most users from
nasty bitings when modeling their problem.
Consider the following Prolog IV program:
ohmslaw(E,R,I):- E = R .*. I.
which enforces the relation E=RI (Ohm's law). With E\in[0,10],
R=0, and I\in[1,2], we may narrow the domains as such:
E=cc(0,10), R=0, I=cc(1,2), ohmslaw(E,R,I).
The answer will be:
U = 0, R = 0, I ~ [1,2].
If the resistance between two nodes is null, the potential
difference is also null. All fine and dandy.
Now, the user could have written Ohm's law as:
ohmslaw(E,R,I):- I = E ./. R.
For most users, the two models should behave equivalently (that is
what is written in most EE textbooks anyway).
And yet, the above request will now yield a different outcome:
E=cc(0,10), R=0, I=cc(1,2), ohmslaw(E,R,I).
false.
Since the denominator shall not be equal to 0 as per P1788's
definition of the interval division, there is now no solution.
Evidently, all these results are correct if we consider the
definitions given in the standard, and the difference between the
two request should be expected. Nevertheless, this would be not at
all obvious to most users.
Cleary's paper (Logical Arithmetic. John G. Cleary. Future
Computing Systems 2(2), pp. 125--149, 1987), which introduces the
use of interval arithmetic in Prolog to obtain a more logical
arithmetic and to solve constraints, never considers the division
relation per se, and it seems clear from the text that such a
relation should be stated through multiplication (hence, X/Y=Z is
equivalent to X=YZ).
We can forgo the X/Y=Z relation (and then divRev1(), divRev2() and
recipRev()), and use the X=ZY relation in its place. In theory,
the price to pay would be less narrowing of the variable domains
for some applications; on the other hand, allowing the X/Y=Z
relation means a loss of solutions whenever it is misused, and it
is very easy to misuse.
I have yet to see models that would benefit from the X/Y=Z
relation. Some systems have offered it in the past (most
prominently Prolog IV) but I believe it was more for symmetry and
completeness than for anything else.
If anyone knows a problem model that positively requires the X/Y=Z
relation, please share it with us now. Otherwise, let us not
clutter the standard with unused functions. There are already so
many to implement.
FG.