Functions and simplification WAS: Fully simplifiying Exp function



I don't think our rules for when to call simplification etc. are
documented anywhere.  Here's a first try.

                -s

1) All routines callable from the Maxima level (namely, all $xxx
functions) should assume that their arguments are simplified but may
return unsimplified results.  MEVAL takes care of simplifying
arguments and simplifying results as necessary.  When constructing
algebraic expressions, they should preferably use add, mul, etc. which
take care of simplification; or they can construct algebraic
expressions *without* simp flags and call simplifya.  They should
*not* create expressions with a SIMP flag explicitly except for
constants (e.g. ((mtimes simp) 2 $%pi)).

2) Within Lisp code, in general functions can assume that their
arguments are simplified and should return simplified results.  That
is the best convention, but some existing packages may have other
conventions.

3) Functions and routines should never explicitly check $SIMP and
DOSIMP -- those flags should be handled only by the top-level
simplifying functions. Functions and routines should not call
resimplify or ssimplifya except in very special circumstances.

4) Simplifying functions (simp-%xxx) work differently from other
routines. They always take three arguments, conventionally called
(form vestigial simp-flag) or the like.  The first argument is the
full form ((%xxx)...) to be simplified.  The second argument is
ignored.  The third argument, if T, means that the *arguments* of form
are already simplified; if NIL, means that cannot be assumed to be
simplified, and (simplifya arg nil) should be called on them.
Arguments to %xxx may also be special forms (CRE etc.).  But you don't
need to know all those details: simply call (simpcheck <arg>
simp-flag) on each argument before doing anything else.

5) In general, Maxima and Lisp code *cannot* be assumed to work
correctly when SIMP = NIL.