mydefint2



-----maxima-bounces at math.utexas.edu wrote: -----

>In particular, there are two problems with this definition:
>
>a) It is actually eval_assuming, not simp_assuming (remember that ::=
>defines a macro).
>
> b) It does not?necessarily return you to the original state:
>
>assume(x>0)$
> 
>facts() => [x>0]
>block( assume(x>0), forget(x>0) )
>facts() => [] ? <<< oops, deleted existing fact
> 
>
>A better definition would use the 'context' mechanism to do this cleanly.

I have no experience using contexts. Maybe somebody would like to
comment on my first waffle: (the first waffle is never quite right)

(%i1) larry(e,[fcts]) ::= block([cntx],
  newcontext(cntx),
  for f in fcts do assume(f),
  unwind_protect(expand(e,0,0), killcontext(cntx)))$

(%i2) george(e,[fcts]) ::= block([cntx],
  supcontext(cntx),
  for f in fcts do assume(f),
  unwind_protect(expand(e,0,0), killcontext(cntx)))$

(%i3) load(unwind_protect)$

(%i4) assume(x > 10)$

(%i5) larry(max(x,x^2), 0 < x, x < 1);
(%o5) x

(%i6) george(max(x,x^2), 0 < x, x < 1);
(%o6) x^2

(%i7) facts();
(%o7) [x>10]

(%i8) contexts;
(%o8) [initial,global]

(%i9) max(x,x^2);
(%o9) x^2


--bw