Subject: Re: [SWIPL] arithmetic_function

From: "Michael A. Covington" <[email-masked]>
Date: Sat, 14 Jul 2001 21:48:29 -0400

> ?- A is sum(0, 4, k).
> It does not work because:
> ERROR: Arithmetic: `k/0' is not a function
> Does anybody know why it did not work?

It does not work because the letter k is not the sum of two numbers.

Did you mean to write the variable K?  In that case, the reason it
doesn't work is that Prolog does not include an all-purpose equation
solver.  (Indeed, neither does all of mathematics as we know it.)
Prolog does not have a mechanism to search for numbers that solve
equations.  (How many numbers should it try?  There are infinitely
many.)

There are numerous algorithms that solve large classes of equations
numerically, though success with arbitrary functions is not guaranteed.
One of them is in the book Prolog Programming in Depth, by Covington,
Nute, and Vellino, Prentice-Hall edition, pp. 198-203.  The code,
solver.pl, is online at ftp.ai.uga.edu (somewhere), but you need the
book to explain how it works.

You can find such algorithms in numerical methods textbooks.  They are
basically search algorithms, but over an infinite search space.