nouns, verbs, why?



Hi!

After thinking about this topic a bit further I want to throw the 
following points in the discussion:

In maxima we currently have two separate but relatated issues:
nouns vs. verbs
simplification vs. evaluation

and the relationships are something like
* there is always simplification unless globally turned off
* nouns are never evaluated unless manually(!) converted to verbs
* verbs are sometimes evaluated
* verbs might evaluate to nouns automatically
* verbs might be subject to simplification too

I think the above lines already show that the status quo is pretty
much pointless in most cases. For example consider:

diff(x^2, x) -> 2*x

It's equally valid to view this as the programm diff calculating
the derivative of x^2 to be 2*x or as transforming the expression
diff(x^2, x) into the equivalent experssion 2*x.

Being somebody doing some calculations I don't care. Somebody designing
a CAS probably wouldn't care either. But after using maxima for
several years I care a lot...

OTOH the distinction between simplification and evaluation is somewhat
justified by the following practical (but not binding at all) rules:
a) evaluation might be computationally expensive
b) evaluation might require user interaction
c) simplification should be efficient 
d) simplification should be entirely automatic

I claim that the noun/verb concept currently suffers from being
abused to implement a-d. If we give up on the practical distinction
between evaluation and simplification (that is: reevaluate verbs in
functional position on simplification) then a much improved noun/verb
solution is quite obvious:

* verbs can operate on anything (i.e. nouns and verbs) below in the
  expression tree

* nouns are objects that are only operated on by verbs above
  in the expression tree

* nouns don't protect verbs below in the expresion tree from
  taking effect: 'asin(sin(0)) -> 'asin(0)

* whether some operation is implemented via evaluation or simplification
  is a detail that shouldn't affect the semantics of maxima

Well, there are some corner cases:
'sin('asin(x)) -> 'sin('asin(x))
sin(asin(x)) -> x
'sin(asin(x)) -> 'sin(asin(x))
sin('asin(x)) -> ??? - I think it should be x, but somebody might argue
			against that.

Of course we need some replacement solution for a-d above:
For the user interaction problem it might help to have an asksign database
per expression tree, for the time expensive computations problem I
don't see a way out (other then the user nounifying expressions himself).


So what would be needed to get a system like described above:
Of course it would be a massive code change to convert everything now 
done by nouns into a verb based system. Compared to that the changes
to the infrastructure would be quite small I guess. Perhaps we would also
need some new syntax to return an unevaluated verb in functional
position. Right now we can to something like:
k(x) := if integerp(x) then factor(x) else subst(k, "[", [x]); 
but that's rather clumsy so most people prefer:
k(x) := if integerp(x) then factor(x) else 'k(x);


The content of this mail was inspired partially by preparing a talk
about CAS for students completely new to this topic a few weeks ago
and partially by Richard's draft. I hope somebody had an interessting
read...

Harald