Logically incompatible features



I've just pushed partial fix for bug #2528. The problem there was that
if you write:

  declare(rrcc,real)$ declare(rrcc,complex)$

then Maxima "considers rrcc to be complex". In particular, things like
imagpart(rrcc) failed to give zero. The root cause of this weirdness was
that risplit (responsible for splitting an expression into real and
imaginary parts) was treating the symbol "rrcc" as a complex number.

The patch I pushed makes risplit check that rrcc isn't also declared as
real - a bit hacky, but definitely an improvement. However, Stavros also wrote:

> What is less clear is whether featurep(rrcc,complex) should be true
> (which it curently is).

In my opinion, the answer is that it probably shouldn't be true, but
putting logic about real and complex numbers into the feature system is
probably Doing It Wrong.

My proposal is that we allow features to be declared to be
incompatible. The way real and complex are used at the moment (I think)
is that

  featurep (x, real)    = true   => x is real
  featurep (x, complex) = true   => x might not be real
  Both false                     => x is real

As such, declaring x complex after declaring it real (or vice versa)
should clear the previous flag.

Maybe the interface could be something like

  declare ([real, complex], incompatible);

(to go with the "declare (foo, feature)" syntax).

One advantage of this proposal is that it won't slow Maxima down when
checking for features. Indeed, I can remove the extra property check
that I just added in risplit! The only time when "extra thought" would
be required is when making declarations, but that shouldn't be on any
fast path...

A disadvantage is that:

  (%i1) declare (rrcc, real)$
  (%i2) declare (rrcc, complex)$
  (%i3) featurep (rrcc, real);
  (%o3)                                true

would change. I guess this alters the behaviour of the program (cue
incompatibilities...), but I can't believe anyone relies on this rather
odd behaviour in real life...

Does anyone have any comments? 

Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20130206/8685c068/attachment.pgp>;