Scope, assumptions, asksign, context. Was Re: Bug in Maxima 5.30.0



I don't think it's hard with fixed variables.  The fun starts when you have
arguments which are expressions which may contain variables.

For example, how would you write a function with_posval(expr,varlist) which
evaluates expr with var assumed positive?  (And of course doesn't let the
assumption leak out of its scope.) Do you have to do the explicit
manipulation of environments that you have to do in say R?  Getting that
sort of thing right is far from trivial.

            -s


On Tue, Sep 3, 2013 at 12:59 PM, Robert Dodier <robert.dodier at gmail.com>wrote:

> On 2013-08-31, John Lapeyre <lapeyre.math122a at gmail.com> wrote:
>
> > On 08/30/2013 08:17 PM, Richard Fateman wrote:
> >
> >>  assume(x>0) block([x],assume(x<0), is (x>0)) returns true.
> >
> > This might be a work around in some cases.
> >
> >   assume(x>0);
> >   assume(y<0);
> >
> >   testassume() := block([x,mycontext,res,oldxfacts ],
> >    oldxfacts : facts(x),
> >    mycontext : gensym(),
> >    msupcontext(mycontext),
> >    forget(oldxfacts),
> >    assume(x<0),
> >    res : is(x<0) and is(y<0),
> >    killcontext(mycontext),
> >    res);
>
> One could separate the scope of symbols from the scope of assumptions --
> with suitable programming one could mix-n-match stuff like:
>
>   with [x, y] lexically (...);
>
> which evaluates (...) in an environment where x and y are distinct from
> any other similarly-named symbols, and
>
>   assuming [<facts>] (...);
>
> which creates a context, asserts <facts>, evaluates (...), and destroys
> the context. (Programming stuff like that is not too difficult; probably
> easier than getting anybody to agree and the syntax.) Then the example
> could be written:
>
>   assume (x > 0, y < 0);
>   with [x, y] lexically
>     (assuming [x < 0] (print (is (x > 0), is (y > 0))));
>
> which should print "false, unknown". Of course one can imagine other
> combinations.
>
> best
>
> Robert Dodier
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>