1

CLP(FD) is a great Prolog tool. It extends the big nums of Prolog to constraints and labeling. But is it versatile? Can we for example figure out this integer value:

 truncate(7^sqrt(8)-8^sqrt(7)) = ?

What would a Prolog CLP(FD) solution look like? Or are there other recommended ways to determine an answer like CLP(?) or something else?

  • 1
    I haven't tried this, but worth a look. [PRESS: PRolog Equation Solving System](https://github.com/maths/PRESS) – Guy Coder Feb 13 '20 at 15:36

1 Answers1

0

Using float arithmetic, we might not be 100% sure what the truncate result will be. Via floats we get an approximation x~ which might be off from the true x:

SWI-Prolog (threaded, 64 bits, version 8.1.21)

?- X is 7, Y is 8, Z is X**sqrt(Y)-Y^sqrt(X).
X = 7,
Y = 8,
Z = 0.5348772168447056.

By using interval arithmetic we can get more confidence. If an interval arithmetic result points to an interval [x1,x2] then we know for sure that the true x is inside this interval:

ECLiPSe Version 7.0 #52 (x86_64_nt)

?- X is breal(7), Y is breal(8), Z is X^sqrt(Y)-Y^sqrt(X).
X = 7.0__7.0
Y = 8.0__8.0
Z = 0.534877216844194__0.53487721684518874

Since the interval is completely inside [0,1) truncate will be zero.