assume database



On Mon, Sep 28, 2009 at 5:36 PM, Robert Dodier <robert.dodier at gmail.com> wrote:
> On 9/28/09, Andrej Vodopivec <andrej.vodopivec at gmail.com> wrote:
>
>> My analysis was not correct, the function isp is not used to query the
>> assume database. Actually it is only used at the end of mevalp2 (in
>> compar.lisp) and I cant find any input for which it would return
>> something other than unknown or a lisp error. I don't really
>> understand what it is supposed to do, but whatever it does it should
>> check to see if the input is something that it can handle.
>
> Well, the presence of 'kind in truep and falsep (called from isp)
> suggests that it was intended to look at declared properties.
> (I wasn't able to find an example which returns other than
> unknown, however.)
>
> I agree isp shouldn't cause an error, but I think enumerating
> the operators for which it won't cause an error is mistaken;
> it's likely that some inputs for which it should return t or nil
> (if only we understood the db code) are therefore excluded.
> It is better to put a test at the point at which the error is
> now generated. (Actually it would be OK to wrap the body
> of isp in some error-catching construct; that also allows for
> correct inputs, if ever we figure out what they are.)

isp calls truep and falsep. The only other place where these two
functions are called is when you define some function to be positive
(declare(f, posfun)). I changed isp so that it always returns unknown
and the testsuite and share testsuite show no changes. I guess isp
works correctly only in some obscure cases, most likely never.

Anyway, if nobody objects, I will commit the patch below.

Andrej

Index: db.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/db.lisp,v
retrieving revision 1.22
diff -u -r1.22 db.lisp
--- db.lisp	4 Aug 2009 03:06:52 -0000	1.22
+++ db.lisp	29 Sep 2009 07:03:22 -0000
@@ -389,9 +389,13 @@
 	 (propg))))

 (defmfun isp (pat)
-  (cond ((truep pat))
-	((falsep pat) nil)
-	(t 'unknown)))
+  (let ((isp 'unknown))
+    (ignore-errors
+      (setq isp
+	    (cond ((truep pat))
+		  ((falsep pat) nil)
+		  (t 'unknown))))
+    isp))

 (defmfun kindp (x y)
   (unless (symbolp x)