Re: Can't parse "a # not b", but parses "a # (not b)" and prints it as "a # not b"

Stavros Macrakis <[email protected]> Wed, 10 Jun 2026 12:27:36 -0400
Newsgroups gmane.comp.mathematics.maxima.general
Message-ID <CACLVabWqPLtjRCG9mRJwvftpnnquhqY7xcgUK7BkbwAuLbbj_g@mail.gmail.com>
Thanks for working on this.

This is fine for logical expressions, and *a>b* can be considered a logical
expression, so logically, interpreting *a>b = c>d* as *(a>b) = (c>d) *is
not unnatural.

However, I think most *mathematical* users (not system programmers) will
expect *a=b=c *to mean *(a=b) and (b=c)*, and not *(a=b)=c*. Similarly,
they "natural" mathematical meaning of *a>b=c* is either "don't do that"
(which is what I think my math teachers would say) or maybe *(a>b) and
(b=c)*. I think it will be a bad surprise for any user that it is
interpreted as *(a>b)=c*, especially because:


is((2=2)=true) => false
is(equal(2>1,true)) => false

assume(a>b)$
is((a>b)=true) => false

assume(equal(q,r))$
is(equal(q,r)=true) => false

Although it's true that legacy systems implementation languages follow the
*(a<b)<c* interpretation, other symbolic math systems (Mathematica, Maple,
SAGE) -- as well as Python -- follow the mathematical convention, and
*a<b<c* means *(a<b)<c*.

            -s

On Wed, Jun 10, 2026 at 1:54 AM David Scherfgen via Maxima-discuss <
[email protected]> wrote:

> Dear all,
>
> as Stavros noted in this bug report
> <https://sourceforge.net/p/maxima/bugs/4390/>, Maxima fails to parse this:
>
> a # not b
> Error: "Found LOGICAL expression where ALGEBRAIC expression expected"
>
> However, a # (not b) with parentheses parses perfectly, but is printed *without
> parentheses*. This means that Maxima cannot parse its own output. (The
> same for =.)
>
> *Proposed fix:*
> In nparse.lisp, change lpos and rpos for the = and # operators from $expr
> to $any. Also, increase the binding powers of  <, <=, >= and > from 80 to
> 85. Note that this is in accordance with most programming languages, where
> <, <=, >= and > have a higher binding power than == and !=, for the exact
> same reason of being able to compare logical expressions. Maxima currently
> has them all the same.
>
> If we make this change, the following expressions will parse directly
> without requiring parentheses, building the exact same trees they already
> do:
>
> a # not b
> a = not b
> a = b = c (parses as (a = b) = c)
> a > b = c (parses as (a > b) = c)
> c = a > b (parses as c = (a > b), wouldn't parse with the original
> binding powers)
>
> Would this have any unintended side-effects?
>
> Best regards
> David Scherfgen
> _______________________________________________
> Maxima-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>

_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss