assume:problems with fractions or multiples of %pi and %e
Subject: assume:problems with fractions or multiples of %pi and %e
From: Dieter Kaiser
Date: Sat, 03 Oct 2009 16:31:59 +0200
I think I have found a solution for the problem that the extra facts are
visible to the user.
We write the additional facts from learn-numer and learn-abs in a new
context which I have called '$learndata. We can activate this context.
All facts are present, but not seen by the user with the command
facts();.
This is an example how it works:
(%i2) assume(x<%pi/2);
(%o2) [%pi/2 > x]
The user only sees the fact from the assume statement:
(%i3) facts();
(%o3) [%pi/2 > x]
But the following works now too, because Maxima has put an additional
fact into the database:
(%i4) is(x<%pi);
(%o4) true
These are the contexts. The facts from learn-numer are put into the
context learndata:
(%i5) contexts;
(%o5) [learndata,initial,global]
(%i6) activecontexts;
(%o6) [learndata]
When we use kill(all) the additional facts in learndata will vanish too:
(%i7) kill(all);
(%o0) done
(%i1) contexts;
(%o1) [initial,global]
(%i2) activecontexts;
(%o2) []
Maxima no longer knows that x < %pi:
(%i3) is(x<%pi);
(%o3) unknown
It is possible to have a look at the additional facts. We have to change
the context:
(%i4) assume(x<%pi/2);
(%o4) [%pi/2 > x]
(%i5) context:learndata;
(%o5) learndata
(%i6) facts();
(%o6) [1.570796326794897 > x]
The command forget will work as expected. A fact is removed from both
contexts:
(%i1) assume(x<%pi/2);
(%o1) [%pi/2 > x]
(%i2) forget(x<%pi/2);
(%o2) [%pi/2 > x]
(%i3) facts();
(%o3) []
(%i4) context:learndata;
(%o4) learndata
(%i5) facts();
(%o5) []
First I had to correct a small bug in the routine killcontext. When a
context is killed it is not removed from the list of active contexts.
This causes problems.
This is the code which collects the additional information in the
context learndata:
(when (not (alike (cdr pat) (cdr patnew)))
(let ((oldcontext $context))
;; Switch to the context '$learndata
;; If '$learndata does not exist, it is created.
(asscontext nil '$learndata)
;; Put the numerically evaluated fact into the database
(learn patnew flag)
;; Switch back to the context on entry
(asscontext nil oldcontext)
;; Make sure that the context '$learndata is active
($activate '$learndata)))
There is one open problem. One example of the testsuite in rtestint.mac
fails. I have to understand why this happens.
Dieter Kaiser