Menu

#4283 equality on make_arrays is wrong

None
open
nobody
5
2024-04-14
2024-04-08
No
qq: make_array('any,4) => {Lisp Array: #(NIL NIL NIL NIL)}
rr: make_array('any,4) => {Lisp Array: #(NIL NIL NIL NIL)}
ss: make_array('any,4) => {Lisp Array: #(NIL NIL NIL NIL)}
qq[2]:3$
rr[1]:5$
ss[2]:3$
qq  =>  {Lisp Array: #(NIL NIL 3 NIL)}
rr  =>  {Lisp Array: #(NIL 5 NIL NIL)}
ss  =>  {Lisp Array: #(NIL NIL 3 NIL)}
is(equal(qq,ss)) => true
is(equal(qq,rr)) => unknown  << should be false

alike1 correctly returns T and NIL in these cases, but array-meqp messes up.

Discussion

  • Robert Dodier

    Robert Dodier - 2024-04-09

    ARRAY-MEQP calls MEQP, and MEQP is the one saying it doesn't know if NIL is equal to 5.

    (%i16) is(equal(false,5));
      0: (MAXIMA::MEQP NIL 5)
      0: MEQP returned (($EQUAL) NIL 5)
    (%o16)                                 unknown
    (%i17) is(equal(a,b));
      0: (MAXIMA::MEQP #(NIL NIL 3 NIL) #(NIL 5 NIL NIL))
        1: (MAXIMA::ARRAY-MEQP #(NIL NIL 3 NIL) #(NIL 5 NIL NIL))
          2: (MAXIMA::MEQP NIL NIL)
          2: MEQP returned T
          2: (MAXIMA::MEQP NIL 5)
          2: MEQP returned (($EQUAL) NIL 5)
        1: ARRAY-MEQP returned (($EQUAL) #(NIL NIL 3 NIL) #(NIL 5 NIL NIL))
      0: MEQP returned (($EQUAL) #(NIL NIL 3 NIL) #(NIL 5 NIL NIL))
    (%o17)                                 unknown
    

    So from what I can tell the bug is in MEQP.

    I'm kind of confused by the comments. The problem isn't in ALIKE1, right? ALIKE1 correctly returns true or false. "Evidence that the array comparison in alike1 isn't used anywhere" ... what?? I don't get it. If it's incorrect we should fix it. But anyway ALIKE1 is correct in this case.

     
  • Stavros Macrakis

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -12,5 +12,3 @@
     is(equal(qq,rr)) =&gt; unknown  &lt;&lt; should be false
     ~~~~
     ``alike1`` correctly returns T and NIL in these cases, but ``array-meqp`` messes up.
    -
    -This seems like good evidence that the array comparison in alike1 is not used anywhere!
    
     
  • Stavros Macrakis

    You're right. I've removed the incorrect comment.

     
  • Robert Dodier

    Robert Dodier - 2024-04-14

    I think I can fix this if we figure out what's the correct result for comparisons to true and false.

    Considering is(equal(x, b)) where b is a Boolean value (true or false) and x is anything other than a Boolean value, I guess we want that to be true if and only if x is known to be equal to b (via assume(equal(x, true)) or assume(equal(x, false)), unless I've overlooked another way to declare a value), false if and only if x is known to be not equal to b (either by its assume value or because x is known to be a non-Boolean value), and undetermined otherwise. Does that sound right?

     

Log in to post a comment.