Dieter Kaiser - 2009-11-14

I think we can not cut out the function MNOT. The current behaviour of the operator "not" is consistent with the other operators "and" and "or":

(%i1) (a:b, b:c, c:d);
(%o1) d
(%i2) (x:y, y:z, z:w);
(%o2) w

The following expressions show one evaluation for every argument:

(%i3) a and x;
(%o3) b and y

(%i4) a or x;
(%o4) b or y

(%i5) not a;
(%o5) not b

This is the putative wrong double evaluation for the logical operators:

(%i6) apply("and", [a,x]);
(%o6) c and z
(%i7) apply("or", [a,x]);
(%o7) c or z
(%i8) apply("not", [a]);
(%o8) not c

This behaviour is due to the specific implementation of the evaluation scheme for the logical operators. This evaluation scheme takes care that predicates are evaluated with mevalp and not meval. But when we use the function apply, first the arguments are evaluated with meval due to a call to mevalargs, then the function MNOT is called which invoke a second evaluation via the function mevalp.

Because mevalp is called in MNOT, we get the following results with the current implementation:

(%i2) not (2>1);
(%o2) false
(%i3) not (1>2);
(%o3) true

When we cut out the function MNOT, we will get:

(%i5) not (2>1);
(%o5) 2 <= 1
(%i6) not (1>2);
(%o6) 1 <= 2

and the predicates are no longer evaluated.

At this point I have no idea what can be done to get both:
1. One evaluation when called with apply.
2. Evaluate predicates with mevalp.

My conclusion is, that the current behaviour is by design. To change it, we have to reimplement the evaluation scheme of all logical operators. This might be a feature request.

Dieter Kaiser