Some documentation for kindp and featurep



I had a look at $featurep and kindp. There is not a lot of code which uses this
feature of Maxima. Perhaps we can improve this. The following is a documentation
of what we have.

Maxima knows the following properties to declare the type of a symbol:

   integer
   noninteger
   even
   odd
   rational
   irrational
   real
   imaginary
   complex   

results for kindp(symbol,ind):

             IND (1)   (2)   (3)   (4)   (5)   (6)   (7)   (8)   (9)
DECLARATION             
    none         *     *     *     *     *     *     *     *     *    
(1) integer      TRUE  *     *     *     TRUE  *     TRUE  *     TRUE  
(2) noninteger   *     TRUE  *     *     *     *     *     *     *    
(3) even         TRUE  *     TRUE  *     TRUE  *     TRUE  *     TRUE
(4) odd          TRUE  *     *     TRUE  TRUE  *     TRUE  *     TRUE
(5) rational     *     *     *     *     TRUE  *     TRUE  *     TRUE
(6) irrational   *     *     *     *     *     TRUE  TRUE  *     TRUE
(7) real         *     *     *     *     *     *     TRUE  *     TRUE
(8) imaginary    *     *     *     *     *     *     *     TRUE  TRUE
(9) complex      *     *     *     *     *     *     *     *     TRUE

There is one inconsistent result:
A symbol declared to be $noninteger is not $rational, $real and $complex.
That is different to e.g. $irrational. For this case the symbol is
$real and $complex, too.

Results for featurep(symbol,ind):

             IND (1)   (2)   (3)   (4)   (5)   (6)   (7)   (8)   (9)
DECLARATION             
    none         *     *     *     *     *     *     *     *     TRUE
(1) integer      TRUE  *     *     *     TRUE  *     TRUE  *     TRUE  
(2) noninteger   *     TRUE  *     *     *     *     *     *     TRUE    
(3) even         TRUE  *     TRUE  *     TRUE  *     TRUE  *     TRUE
(4) odd          TRUE  *     *     TRUE  TRUE  *     TRUE  *     TRUE
(5) rational     *     *     *     *     TRUE  *     TRUE  *     TRUE
(6) irrational   *     *     *     *     *     TRUE  TRUE  *     TRUE
(7) real         *     *     *     *     *     *     TRUE  *     TRUE
(8) imaginary    *     *     *     *     *     *     *     TRUE  TRUE
(9) complex      *     *     *     *     *     *     *     *     TRUE

There are two differences to kindp: A symbol with no declaration and 
a symbol with the declaration $noninteger returns TRUE, too. The second
difference would vanish when we handle $noninteger more consistent. The
first difference causes that $featurep returns always TRUE if we test
with $complex.

The only test functions which look up the type for symbols are:

In compar.lisp:

maxima-integerp
nonintegerp
mevenp
moddp

The above functions are called by $featurep too. Because $featurep is 
a combination of looking up the type for a symbol and further algorithm to 
determine the type of an expression, we get a lot of inconsistent
results. The Maxima code uses $featurep almost everwhere with $integer
as an argument and in some places with $odd and $even.

In conjugate.lisp:

manfifestly-pure-imaginary-p

Here an imaginary declaration is looked up.

In simp.lisp:

decl-complexp
decl-realp

These two functions work not like their names would suggest:

decl-complexp returns TRUE if the symbol is declared to be $complex or 
$imaginary.

decl-realp returns TRUE, if the symbol is not declared to be $complex or
$imaginary. Therefore any of the following declarations will return TRUE:
  $integer, $noninteger, $even, $odd, $rational, $irrational, $real   

Next:

(1) Make $noninteger consistent with the other declarations.
(2) Improve $featurep to be consistent:
    A major problem is that featurep combines kindp with the test of
    expressions and numbers:
    
    featurep(10,integer)  --> TRUE
    featurep(10,real)     --> TRUE but
    featurep(10,rational) --> FALSE

    That is inconsistent, because with kindp an integer is a rational too:
    
    declare(n,integer)
    featurep(n,integer)  --> TRUE and
    featurep(n,rational) --> TRUE and
    featurep(n,real)     --> TRUE
    
Dieter Kaiser