should all floats be nonintegers?



The floor function doesn't call nonintegerp (either directly or indirectly), so it's safe for nonintegerp to call floor.
Leveraging floor in nonintegerp and assuming  floats are noninteger, my code has the inconsistency:

  (%i3) declare(k,integer)$

  (%i4) featurep(k+3.0,noninteger);
  (%o4) false

  (%i5) featurep(3.0,noninteger);
  (%o5) true

This happens because floor(k+3.0) is not less than k+3

  (%i6) floor(k+3.0);
  (%o6) k+3

Uncommenting the call to $rationalize leads to askinteger weirdness:

  (%i2) assume(equal(x,3.0))$
  
 (%i3) askinteger(x);
 rat: replaced 3.0 by 3/1 = 3.0
 "Is "x" an "integer"?"no;
 (%o3) no

askinteger appends to the fact database

  (%i4) facts();
  (%o4) [equal(x,3.0),kind(x,noninteger)]

 (%i5) featurep(x,integer);
 (%o5) false

Although equal(x,3.0), Maxima reports that x is a noninteger and 3.0 isn't a noninteger

 (%i6) featurep(x,noninteger);
 (%o6) true

 (%i7) featurep(3.0,noninteger);
 (%o7) false

Or if the user says that x isn't an integer:

(%i3) askinteger(x);
rat: replaced 3.0 by 3/1 = 3.0
"Is "x" an "integer"?"yes;
(%o3) yes

(%i4) facts();
(%o4) [equal(x,3.0),kind(x,integer)]

(%i5) featurep(x,integer);
(%o5) true

(%i9) featurep(3.0,integer);
(%o9) false

Proposed code (without $rationalize, runs the test suites OK; with $rationalize, triggers one askinteger call)

(defvar *calls-to-nonintegerp* 0)

;; not done: (1) rational x irrational is noninteger (2) nonzero even / nonzero odd is noninteger ...
(defun nonintegerp (e)
  (incf *calls-to-nonintegerp*)
  (cond ((and (symbolp e) (or (kindp e '$noninteger) (check-noninteger-facts e)))) ;declared noninteger
	((and (symbolp e) (kindp e '$irrational))) ; irrationals are nonintegers
	((mnump e)
	 ;(setq e ($rationalize e))
	 (if (integerp e) nil t)) ;all floats are noninteger and integers are not nonintegers
	(($ratp e) 
	 (nonintegerp ($ratdisrep e)))
	(t
	 (setq e (equal-facts-simp e))
	 (eq t (unwind-protect (mgrp e (take '($floor) e)) (clearsign)))))) ; e > floor(e), so e is noninteger.
 

--Barton