The numbers in ACL2 can be partitioned into the following subtypes:
Rationals Integers Positive integers
-3Non-Integral Rationals Positive Non-Integral Rationals
19/3Negative Non-Integral Rationals
-22/7Complex Rational Numbers
#c(3 5/2) ; = 3+(5/2)i
Signed integer constants are usually written (as illustrated above)
as sequences of decimal digits, possibly preceded by
Decimal points are not allowed. Integers may be written in binary,
#b1011 (= 23) and
#b-111 (= -7). Octal may also be
#o-777 = -511. Non-integral rationals are written as a
signed decimal integer and an unsigned decimal integer, separated by
a slash. Complex rationals are written as #c(rpart ipart) where
rpart and ipart are rationals.
Of course, 4/2 = 2/1 = 2 (i.e., not every rational written with a slash is a non-integer). Similarly, #c(4/2 0) = #c(2 0) = 2.
The common arithmetic functions and relations are denoted by
>=. However there
are many others, e.g.,
suggest you see programming where we list all of the primitive
ACL2 functions. Alternatively, see any Common Lisp language
The primitive predicates for recognizing numbers are illustrated below. The following ACL2 function will classify an object, x, according to its numeric subtype, or else return 'NaN (not a number). We show it this way just to illustrate programming in ACL2.
(defun classify-number (x) (cond ((rationalp x) (cond ((integerp x) (cond ((< 0 x) 'positive-integer) ((= 0 x) 'zero) (t 'negative-integer))) ((< 0 x) 'positive-non-integral-rational) (t 'negative-non-integral-rational))) ((complex-rationalp x) 'complex-rational) (t 'NaN)))