We have the bug report ID: 856209 - "inconsistency between facts() and
facts(v)".
We can improve this, when we add a separate routine for looking up facts
for symbols or expressions. This might be the code:
In the routine $facts we call a special routine facts2. The routine
facts1 is only called for a context.
(defmfun $facts (&optional (ctxt $context))
(if (member ctxt (cdr $contexts))
(facts1 ctxt)
(facts2 ctxt)))
The routine facts2 gets the facts from the database and looks for
symbols and expressions which match the request from the user input.
(defun facts2 (con)
(do ((facts (cdr ($facts $context)) (cdr facts))
(ans))
((null facts) (return (cons '(mlist) ans)))
(when (among1 con (cdar facts))
(push (car facts) ans))))
This is a simple extension of the routine among to have a look for
expressions too. (I have not found an equivalent or better routine.
Perhaps we already have it. Each proposal is welcomed.)
(defun among1 (x l)
(cond ((null l) nil)
((atom l) (eq x l))
((alike1 x (car l)) t)
(t (or (among1 x (car l)) (among1 x (cdr l))))))
This is what we will get:
(%i1) assume(a+b>0);
(%o1) [b+a > 0]
We get an answer for a, b and a+b:
(%i2) facts(a);
(%o2) [b+a > 0]
(%i3) facts(b);
(%o3) [b+a > 0]
(%i4) facts(a+b);
(%o4) [b+a > 0]
(%i5) assume(2*a+b>0);
(%o5) [b+2*a > 0]
In this example we get an answer for a, b, 2*a and 2*a+b:
(%i6) facts(a);
(%o6) [b+2*a > 0,b+a > 0]
(%i7) facts(b);
(%o7) [b+2*a > 0,b+a > 0]
(%i8) facts(2*a);
(%o8) [b+2*a > 0]
(%i9) facts(2*a+b);
(%o9) [b+2*a > 0]
Of course the extension is not perfect. It works well for symbols, but
not in general for expressions. The reason is that the test to detect an
expression is to simple.
Dieter Kaiser