forall...



> forall(A,a->bool(e o a = a))
> (which essentially applies the given function to all elements
> of A and then takes the conjunction).
> Could something like that be done easily in maxima.

Yes, certainly.  Here is the simplest way:

  forall(func,list) := apply("and",map(func,list))$

Then

  forall(evenp,[2,4,6,100]) => true
  forall(evenp,[2,4,8,3]) => false

This function also be written as a recursion or an iteration.  However,
Maxima does not recognize tail-recursions, so it quickly runs out of
stack space.  And the iterative version is 200 times slower than the
'map' version (even when translated automatically into Lisp -- of
course, a manual translation would be faster).

This forall requires explicitly listing the elements of A.  Versions
using generators (in the programming language sense) or other
characterizations of the elements of A are also possible.

In your case, how big is A typically?  There are many tricks possible
for making all this much more efficient for large A.  If A is of size
10^5, then forall(evenp,A) takes about 1 sec on my 1 Ghz machine with no
optimizations at all.

       -s