Strange result in 'every'



-----maxima-admin@math.utexas.edu wrote: -----

>I built cvs Maxima last week and I get this:
>
>(%i1) every([false,false]);
>(%o1)                                true
>
>everything else seems to be ok.
>
>I get 'false' with Maxima 5.9.1 + clisp
>
>Can anyone replicate this behaviour or is it a
>local problem?

Maxima 5.9.1cvs uses the nset 'every' function.
The first argument to 'every' should be a predicate
(a boolean-valued function). To do what you wanted, use

(%i1) every('identity,[false,false]);
(%o1) false
(%i2) every('identity,[false,true]);
(%o2) false
(%i3) every('identity,[true,true]);
(%o3) true
(%i4) every('identity,[]);
(%o4) true

The 'every' function should be changed to signal an error
when it doesn't receive two or more arguments. Sigh...

Here is the nset documentation for 'every'

Function: every (f, set(a1,...,an) | [a11,...,a1n],[a21,...],...)

    The first argument f should be a predicate (a function that evaluates
    to true, false, or unknown).

    Given one set as the second argument, every(f, set(a1,...,an)) returns
    true if any f(ai) evaluates to true. Since sets are unordered, 'every'
    is free to evaluate f(ai) in any order. 'Every' may or may not evaluate
    all the f(ai)'s. Because the order of evaluation isn't specified, the
    predicate f should not have side-effects or signal errors for any
    input. To use 'every' on multiple set arguments, they should first be
    converted to an ordered sequence so that their relative alignment
    becomes well-defined.

    Given one or more lists as arguments,
    every(f,[a11,...,a1n],[a21,...],...) evaluates to true if any
    f(ai1,ai2,...) evaluates to true. 'Every' may or may not evaluate all
    the f(ai1,ai2,...)'s. Since lists are ordered, 'every' evaluates in the
    order of increasing 'i'. If the global flag maperror is true (the
    default), all lists [a11,..a1n], [a21,..], ... must have equal lengths
    -- otherwise, 'every' signals an error. When the Maxima flag $maperror
    is false, the list arguments are effectively truncated each to the
    length of the shortest list.

    The Maxima function 'is' automatically applied after evaluating the
    predicate f; thus the following work correctly

(C1) every("=",[a,b],[a,b]);
(D1)                         TRUE
(C2) every("#",[a,b],[a,b]);
(D2)                         FALSE

Barton