# [Maxima] Is %i an integer?

Dieter Kaiser drdieterkaiser at web.de
Fri Oct 2 10:38:37 CDT 2009

```Am Donnerstag, den 01.10.2009, 14:32 -0600 schrieb Robert Dodier:

> > 2.
> > Cut out the inferences between the different declarations. Then a symbol
> > can declared to be a real and a noninteger at the same time.
>
> I'm in favor of this. I don't remember if cutting out the
> inference stuff in featurep breaks anything. I hope not.
>
> I believe it is useful to have featurep only for properties
> attached to symbols, and a separate system to do
> set membership inference or perhaps other kinds of inferences.
> At present featurep mixes up both (and it does a poor job
> on the inferences). So at this point let's restrict featurep to
> only symbol properties, and keep talking about a set membership
> inference system.

These are the necessary changes to cut out the inferences and to
introduce facts like %i is a noninteger:

1. Cutting out inferences in compar.lisp:

; Cut out inferences between the declarations
;	  (kind \$integer \$rational)
;	  (par (\$rational \$irrational) \$real)
;	  (par (\$real \$imaginary) \$complex)

2. Define properties for constants in compar.lisp:

;; Properties of constants
(kind \$%i     \$noninteger)
(kind \$%i     \$imaginary)
(kind \$%pi    \$noninteger)
(kind \$%pi    \$real)
(kind \$%gamma \$noninteger)
(kind \$%gamma \$real)
... more is possible

3. A small change to the function featurep:
Symbols are no longer by default complex.

(defmfun \$featurep (e ind)
(setq e (\$ratdisrep e))
(cond ((not (symbolp ind))
(merror (intl:gettext "featurep: second argument must be a
symbol; found ~M") ind))
((eq ind '\$integer) (maxima-integerp e))
((eq ind '\$noninteger) (nonintegerp e))
((eq ind '\$even) (mevenp e))
((eq ind '\$odd) (moddp e))
((eq ind '\$real)
(if (atom e)
(or (numberp e) (kindp e '\$real) (numberp (numer e)))
(free (\$rectform e) '\$%i)))
; Symbols and expressions are no longer by default complex
;	((eq ind '\$complex) t)
((symbolp e) (kindp e ind))))

4. Change the definition of decl-complexp and decl-realp
to match the new behavior of kindp:

;; TRUE, if the symbol e is declared to be \$complex or \$imaginary.
(defmfun decl-complexp (e)
(and (symbolp e)
(or (kindp e '\$complex)
(kindp e '\$imaginary))))

;; TRUE, if the symbol e is declared to be
;; \$integer, \$rational, \$real
(defmfun decl-realp (e)
(and (symbolp e)
(or (kindp e '\$real)
(kindp e '\$rational)
(kindp e '\$integer))))

With these changes we have no problems with the testsuite. All examples
work as before. No changes are necessary.

The integral integrate(exp(-x^%i),x,0,1) no longer asks a question.

Remarks:
1. Featurep works for numbers and expressions too. Perhaps this can be
cut out in a next step.
2. The function decl-realp is not completely equivalent to the old
definition. To be complete the declarations \$odd, \$even,
\$noninteger, \$irrational have to be included. Because we have no
problems with the testsuite I think we should not extend the
definition of decl-realp further.