simp_assuming (was Re: mydefint2)



I'd like some discussion on whether with_assumptions should resimplify the
result or not.

Arguments against resimplification:

* It's orthogonal to the main meaning of with_assumptions, which is to *
evaluate* an expression in a given context.
* Resimplifying the result is unnecessary overhead when the functionality
isn't needed.
* Including resimplification is more likely to DWIM (Do What I Mean), just
like 'ev'; this makes it less predictable sometimes.
* It is surely what the user intends if he/she writes
with_assumptions(integrate(...), x>0).
* Users shouldn't be writing with_assumptions when all they really want is
resimplification with assumptions.

Arguments for resimplification:

* The distinction between evaluating in a context and resimplifying in a
context is subtle, and new users will have trouble with it.
* It almost never hurts to resimplify.
* Including resimplification is more likely to DWIM (Do What I Mean), just
like 'ev'. This dispenses with semantic subtleties and just gives the user
what he/she wants.
* It is surely what the user intends if he/she writes
with_assumptions(%o23,x>0), and the user is not going to bother with
resimplify(%o23,x>0).
* It would be a good idea to add assumptions to 'ev' and with_assumptions
is the* ? la carte *version of this -- e.g.
         (%i23) abs(x),x<0;    => -x
         (%i45) q:abs(x)$
         (%i46) q,x<0;     => -x

As a general rule, I prefer clean and simple to DWIM and messy.  We all
know what a mess ev's semantics are, and how they can confuse users.  But
we also know how convenient the syntax is, and how easily new users get
lost in subtle distinctions, notably evaluation vs. simplification.

With some misgivings, I think I'll recommend that with_assumptions *do
include* the resimplify step.

On a separate topic, what do people think of adding the resimplify function
(including optional relations) I suggested? Should it also include
value-setting, * ? la *ev?  So resimplify(abs(x),x=3) => 3.  Again, this
makes it more DWIMy and inconsistent -- note for example that
resimplify(abs(x),equal(-3,x)) would return -x rather than 3 (a limitation
of the current simplifier), while resimplify(abs(x),x=-3) would return 3.

I would like to put this in share/simplification, not share/contrib -- so
let's get it right.

Discussion?

            -s


/* evaluate with assumptions -- without resimplification */
with_assumptions(e,[fcts]) ::=
   buildq([e,fcts],
     with_assumption_list(e,fcts))$

/* evaluate with assumptions -- with resimplification */
with_assumptions(e,[fcts]) ::=
   buildq([e,fcts],
     with_assumption_list(expand(e,0,0),fcts))$