equality test for lists, matrices, etc.



> I am trying to understand how equality tests for lists, 
> matrices, & other composite objects works in Maxima, and also 
> how it should work.

How it should work: correctly.
  Lists, sets, and matrices should test equal iff they are equal.
How it currently works: buggy (baggy?).
  "Is" doesn't understand bags at all.

I have reported this as bug 884947 and supplied a fix.  Copy of bug
report below.

          -s

-----------------------------

Currently, IS doesn't understand semantic-equality of 
bags (lists, matrices, sets) at all:

is(equal([1],[1])) => true OK
is(equal([0],[1])) => Unknown NO

The first case only works because the two expressions 
are syntactically equal (is/= or ?like).

The problem is that meqp uses compare, which 
compares x and y by comparing x-y to (scalar) 0, 
obviously irrelevant here. The solution is to explicitly 
add bags to meqp and mnqp. See code attached. With 
this code, we have:

is(equal([1],[1])) => true
is(equal([0],[1])) => false
is(equal([a,0],[a,1])) => false
is(equal([a,b],[a,c])) => unknown

HOWEVER: a) this code ignores doscmxplus, so lists are 
never considered equal to matrices; b) the assume 
database is not consulted in cases like equal(x,[a,b]), 
because compar thinks this is the same as equal([x-a,x-
b],0).

I considered also adding ordering inequalities (< etc.), 
but I don't think it's worth it right now given the limited 
capabilities of compar. Also, it's not clear whether 
lexicographic ([a,b]<[c,d] iff (a dominating order (a more useful.

This was originally reported by Robert Dodier in email.