charfun



On 3/24/07, Barton Willis <willisb at unk.edu> wrote:

> The function charfun (defined in nummod) makes a call to $ev:
>
>   (setq bool (mevalp (mfuncall '$ev e '$nouns))).
>
> I think the intent is to allow (ugly looking) things like
>
>   charfun('"and"(-1 < x, x < 1))

A better solution is to rework the evaluation of Boolean
expressions so that Maxima doesn't barf on stuff like
(- 1 < x and x < 1).

There is already a revision of the Boolean evaluation stuff
in share/contrib/boolsimp/boolsimp.lisp, which allows charfun
to work with compound predicates.

load (boolsimp);
charfun (- 1 < x and x < 1);
  => charfun(- 1 < x and x < 1)
''%, x = 1/2;
  => 1
charfun (y < 0 or y > 1);
  => charfun(y < 0 or y > 1)
''%, y = 1/2;
  => 0

Maybe we can get Stavros and Richard to permit partially-evaluated
Boolean expressions, even though (it appears) they are dead-set
against partially-evaluated conditional expressions.

> (%i1) p : charfun(x > 0, x < 1);  <-- implied "and" (standard in set
> builder notation)

I'm not opposed to allowing multiple arguments to charfun and
interpreting them as a conjunction; Maxima already imposes that
interpretation in assume and probably other stuff. However, if the
primary purpose is to work around Maxima's refusal to handle
partially-evaluated Boolean expressions, we should focus our
attention elsewhere.

With the proposed changes, charfun still can't handle stuff
like (foo or bar), or (not foo). If we revise the evaluation of Boolean
expressions, charfun (and all other functions) can handle
disjunction and negation as well.

> A smarter charfun would know that charfun(x>0,x<0) = 0...

The place to put that would be in the evaluation of Boolean
expressions. Then all functions can benefit from
x < 0 and x > 0 => false.

FWIW
Robert