charfun



On 3/24/07, Barton Willis <willisb at unk.edu> wrote:
> The function charfun (defined in nummod) makes a call to $ev:...
> I think the intent is to allow (ugly looking) things like
>   charfun('"and"(-1 < x, x < 1))

I took a look at charfun.  It is ugly.  The fact that it uses mevalp
and $ev internally is a symptom of a fundamentally misguided design
(which has no doubt been around for decades), partly because Maxima's
handling of comparisons and boolean operations was poor.  Fortunately,
Robert's boolsimp fixes a lot of that, and we should be able to do
much better now.

The problem is that charfun re-evaluates its argument as part of
resimplifying.  This breaks the standard Maxima model of evaluation
versus simplification.

Compare for example:

       expr:  x^2  =>  x^2
       x:20$
       ev(expr) => 400                OK
       subst(20,'x,expr) => 400    OK
       expand(expr) => x^20      OK

with

        expr: charfun(x<0)  =>  charfun(x<0)
        x:20$
        ev(expr) => false                 OK
        subst(20,x,expr) => false   OK
        expand(expr) => false        !!!  No! Resimplification must
not reevaluate!

A redesigned and rewritten charfun should not use $ev or mevalp at all
and should take full advantage of boolsimp.

               -s