[comp.lang.prolog] Relational Arithmetic in Prolog

anv@bnr-di.UUCP (Andre Vellino) (02/02/89)

There is another way of doing arithmetic logically (relationally),
without incurring too great a performance cost.  It is not
clear if it can be *compiled* well, but our interpreter performs
quite well.

The idea is to impose arithmetic constraints on *intervals* which
refer to a point between the upper and lower bounds (floating point
numbers).  As more constraints are placed on intervals, they may
narrow.  

The best way to get the idea across is with an example.  If the
predicate range/2 is used to declare that an arithmetic variable
is an interval, and range(X,_), makes X an interval with bounds
[minfloat,maxfloat], then the question

?- range(X,_), 2 is X * X.

will constrain X to be an interval between [-2.0001,2.0001] (the
bounds are upward rounded to ensure correctness).  Now,

?- range(X,_), 2 is X * X, ( X >= 2 ; X < 0).

will alternately constrain X to [2.0,2.0001] and [-2.0001,-2.0].
This kind of technique will yeild rather quick solutions to
systems of non-linear equations (polynomials, for example).

For further reference, see John Cleary's paper "Logical Arithmetic"
in Future Computing Systems, volume 2, number 2, 1987 pp.125-147.

If anyone is interested in the kinds of things you can do with this
idea, I have a draft of a paper which explains the system.  It differs
quite substantially from Prolog-III and CHIP and CLP(R), but
it is a constraint programming system.

Andre Vellino
Computing Research Lab
Bell-Northern Research
P.O. Box 3511 Station C
Ottawa, Ontario
K1Y 4H7

anv@bnr-di.UUCP (Andre Vellino) (02/03/89)

The example I gave in my last posting has an error.  It should
read:

?- range(X,_), 4 is X * X.

I hope the interest generated by this submission was not due to
the novel discovery that the square root of 2 is 2 :-).