Subject: Re: [SWIPL] arithmetic_function

From: Satoshi Ota :- OOta <[email-masked]>
Date: Sun, 15 Jul 2001 16:23:08 -0500

Michael,

Thank you for your detailed reply. It provides me a lot of information on
programming with prolog. However, my intention was a bit different. I'm sorry for
my insufficient explanation.

My question was simpler. It can be paraphrased as follows:

When I used arithmetic_function/1 to make an arithmetic function, I encountered an
error caused by is/2 if one or more than one of arguments of the function are
functors (or atoms). I thought it would be allowed, but in fact not.

So can anybody tell me if is/2 will reject any arithmetic function containing
functors and/or atoms as its arguments?

Michael A. Covington wrote:

> > ?- 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.

Thanks,

---
Satoshi