(/=We use the intended meaning of numerical constants in defining the numerical functions and relations in this chapter. In effect, we require that these functions and relations behave correctly on all numbers represented in this way. Note that this does mean that it is incorrect to apply these functions and relations to terms other than numbers. For example, a nonnumerical term mayt1t2)

`*`-- If, ...,**t1**denote numbers, then the term**tn**`(*`denotes the product of those numbers.**t1**...**tn**)`+`-- If, ...,**t1**are numerical constants, then the term**tn**`(+`denotes the sum**t1**...**tn**)of the numbers corresponding to those constants.**t**`-`-- Ifand**t**, ...,**t1**denote numbers, then the term**tn**`(-`denotes the difference between the number denoted by**t****t1**...**tn**)and the numbers denoted by**t**through**t1**. An exception occurs when**tn****n=0**, in which case the term denotes the negation of the number denoted by.**t**`/`-- If, ...,**t1**are numbers, then the term**tn**`(/`denotes the result**t1**...**tn**)obtained by dividing the number denoted by**t**by the numbers denoted by**t1**through**t2**. An exception occurs when**tn****n=1**, in which case the term denotes the reciprocalof the number denoted by**t**.**t1**`1+`-- The term`(1+`denotes the sum of the object denoted by)**t**and**t**.**1**(deffunction 1+ (?x) := (+ ?x 1)) `1-`-- The term`(1-`denotes the difference of the object denoted by)**t**and**t**.**1**(deffunction 1- (?x) := (- ?x 1)) `abs`-- The term`(abs`denotes the absolute value of the object denoted by)**t**.**t**(deffunction abs (?x) := (if (>= ?x 0) ?x (- ?x))) `acos`-- Ifdenotes a number, then the term**t**`(acos`denotes the arc cosine of that number (in radians).**t**)`acosh`-- The term`(acosh`denotes the arc cosine of the object denoted by**t**)(in radians).**t**`ash`-- The term`(ash`denotes the result of arithmetically shifting the object denoted by**t1**)**t2**by the number of bits denoted by**t1**(left or right shifting depending on the sign of**t2**).**t2**`asin`-- The term`(asin`denotes the arc sine of the object denoted by)**t**(in radians).**t**`asinh`-- The term`(asinh`denotes the hyperbolic arc sine of the object denoted by)**t**(in radians).**t**`atan`-- The term`(atan`denotes the arc tangent of the object denoted by)**t**(in radians).**t**`atanh`-- The term`(atanh`denotes the hyperbolic arc tangent of the object denoted by)**t**(in radians).**t**`boole`-- The term`(boole`denotes the result of applying the operation denoted by**t****t1**)**t2**to the objects denoted by**t**and**t1**.**t2**`ceiling`-- Ifdenotes a real number, then the term**t**`(ceiling`denotes the smallest integer greater than or equal to the number denoted by)**t**.**t**`cis`-- The term`(cis`denotes the complex number)**t****cos(t) + i sin(t)**. The argument is any non-complex number of radians.`conjugate`-- Ifdenotes a complex number, then the term**t**`(conjugate`denotes the complex conjugate of the number denoted by)**t**.**t**(deffunction conjugate (?c) := (complex (realpart ?c) (- (imagpart ?c)))) `cos`-- The term`(cos`denotes the cosine of the object denoted by)**t**(in radians).**t**`cosh`-- The term`(cosh`denotes the hyperbolic cosine of the object denoted by)**t**(in radians).**t**`decode-float`-- The term`(decode-float`denotes the mantissa of the object denoted by)**t**.**t**`denominator`-- The term`(denominator`denotes the denominator of the canonical reduced form of the object denoted by)**t**.**t**`exp`-- The term`(exp`denotes)**t****e**raised to the power the object denoted by.**t**(deffunction exp (?x) := (expt e ?x)) `expt`-- The term`(expt`denotes the object denoted by**t1**)**t2**raised to the power the object denoted by**t1**.**t2**`fceiling`-- The term`(fceiling`denotes the smallest integer (as a floating point number) greater than the object denoted by)**t**.**t**`ffloor`-- The term`(ffloor`denotes the largest integer (as a floating point number) less than the object denoted by)**t**.**t**`float`-- The term`(float`denotes the floating point number equal to the object denoted by)**t**.**t**`float-digits`-- The term`(float-digits`denotes the number of digits used in the representation of a floating point number denoted by)**t**.**t**`float-precision`-- The term`(float-precision`denotes the number of significant digits in the floating point number denoted by)**t**.**t**`float-radix`-- The term`(float-radix`denotes the radix of the floating point number denoted by)**t**. The most common values are**t****2**and**16**.`float-sign`-- The term`(float-sign`denotes a floating-point number with the same sign as the object denoted by**t1**)**t2**and the same absolute value as the object denoted by**t1**.**t2**`floor`-- The term`(floor`denotes the largest integer less than the object denoted by)**t**.**t**`fround`-- The term`(fround`is equivalent to)**t**`(ffloor (+ 0.5`.))**t**`ftruncate`-- The term`(ftruncate`denotes the largest integer (as a floating point number) less than the object denoted by)**t**.**t**`gcd`-- The term`(gcd`denotes the greatest common divisor of the objects denoted by**t1**...**tn**)through**t1**.**tn**`imagpart`-- The term`(imagpart`denotes the imaginary part of the object denoted by)**t**.**t**`integer-decode-float`-- The term`(integer-decode-float`denotes the significand of the object denoted by)**t**.**t**`integer-length`-- The term`(integer-length`denotes the number of bits required to store the absolute magnitude of the object denoted by)**t**.**t**`isqrt`-- The term`(isqrt`denotes the integer square root of the object denoted by)**t**.**t**`lcm`-- The term`(lcm`denotes the least common multiple of the objects denoted by**t1**...**tn**)**t1**,...,**tn**.`log`-- The term`(log`denotes the logarithm of the object denoted by**t1**)**t2**in the base denoted by**t1**.**t2**`logand`-- The term`(logand`denotes the bit-wise logical and of the objects denoted by**t1**...**tn**)through**t1**.**tn**`logandc1`-- The term`(logandc1`is equivalent to**t1**)**t2**`(logand (lognot`.)**t1**)**t2**`logandc2`-- The term`(logandc2`is equivalent to**t1**)**t2**`(logand`.(lognot**t1**))**t2**`logcount`-- The term`(logcount`denotes the number of)**t****it on bits in the object denoted by**. If the denotation of**t**is positive, then the one bits are counted; otherwise, the zero bits in the twos-complement representation are counted.**t**`logeqv`-- The term`(logeqv`denotes the logical-exclusive-or of the objects denoted by**t1**...**tn**)**t1**,...,**tn**.`logior`-- The term`(logior`denotes the bit-wise logical inclusive or of the objects denoted by**t1**...**tn**)through**t1**. It denotes 0 if there are no arguments.**tn**`lognand`-- The term`(lognand`is equivalent to**t1**)**t2**`(lognot (logand`.**t1**))**t2**`lognor`-- The term`(lognor`is equivalent to**t1**)**t2**`(not (logior`.**t1**))**t2**`lognot`-- The term`(lognot`denotes the bit-wise logical not of the object denoted by)**t**.**t**`logorc1`-- The term`(logorc1`is equivalent to**t1**)**t2**`(logior (lognot`.)**t1**)**t2**`logorc2`-- The term`(logorc2`is equivalent to**t1**)**t2**`(logior`.(lognot**t1**))**t2**`logxor`-- The term`(logxor`denotes the bit-wise logical exclusive or of the objects denoted by**t1**...**tn**)through**t1**. It denotes 0 if there are no arguments.**tn**`max`-- The term`(max`denotes the largest object denoted by**t1**...**tk**)through**t1**.**tn**`min`-- The term`(min`denotes the smallest object denoted by**t1**...**tk**)through**t1**.**tn**`mod`-- The term`(mod`denotes the root of the object denoted by**t1**)**t2**modulo the object denoted by**t1**. The result will have the same sign as denoted by**t2**.**t1**`numerator`-- The term`(numerator`denotes the numerator of the canonical reduced form of the object denoted by)**t**.**t**`phase`-- The term`(phase`denotes the angle part of the polar representation of the object denoted by)**t**(in radians).**t**`rationalize`-- The term`(rationalize`denotes the rational representation of the object denoted by)**t**.**t**`realpart`-- The term`(realpart`denotes the real part of the object denoted by)**t**.**t**`rem`-- The term`(rem`denotes the remainder of the object denoted by**t1****t2**)divided by the object denoted by**t1**. The result has the same sign as the object denoted by**t2**.**t2**`round`-- The term`(round`denotes the integer nearest to the object denoted by)**t**. If the object denoted by**t**is halfway between two integers (for example 3.5), it denotes the nearest integer divisible by**t****2**.`scale-float`-- The term`(scale-float`denotes a floating-point number that is the representational radix of the object denoted by**t1**)**t2**raised to the integer denoted by**t1**.**t2**`signum`-- The term`(signum`denotes the sign of the object denoted by)**t**. This is one of -1, 1, or 0 for rational numbers, and one of -1.0, 1.0, or 0.0 for floating point numbers.**t**`sin`-- The term`(sin`denotes the sine of the object denoted by)**t**(in radians).**t**`sinh`-- The term`(sinh`denotes the hyperbolic sine of the object denoted by)**t**(in radians).**t**`sqrt`-- The term`(sqrt`denotes the principal square root of the object denoted by)**t**.**t**`tan`-- The term`(tan`denotes the tangent of the object denoted by)**t**(in radians).**t**`tanh`-- The term`(tanh`denotes the hyperbolic tangent of the object denoted by)**t**(in radians).**t**`truncate`-- The term`(truncate`denotes the largest integer less than the object denoted by)**t**.**t**### Relations on Numbers

`integer`-- The sentence`(integer`means that the object denoted by)**t**is an integer.**t**`real`-- The sentence`(real`means that the object denoted by)**t**is a real number.**t**`complex`-- The sentence`(complex`means that the object denoted by)**t**is a complex number.**t**(defrelation number (?x) := (or (real ?x) (complex ?x))) (defrelation natural (?x) := (and (integer ?x) (>= ?x 0))) (defrelation rational (?x) := (exists (?y) (and (integer ?y) (integer (* ?x ?y))))) `<`-- The sentence`(<`is true if and only if the number denoted by**t1**)**t2**is less than the number denoted by**t1**.**t2**(defrelation > (?x ?y) := (< ?y ?x)) (defrelation =< (?x ?y) := (or (= ?x ?y) (< ?x ?y))) (defrelation >= (?x ?y) := (or (> ?x ?y) (= ?x ?y))) (defrelation positive (?x) := (> ?x 0)) (defrelation negative (?x) := (< ?x 0)) (defrelation zero (?x) := (= ?x 0)) (defrelation odd (?x) := (integer (/ (+ ?x 1) 2)) (defrelation even (?x) := (integer (/ ?x 2)) `logbit`-- The sentence`(logbit`is true if bit**t1**)**t2**of**t2**is**t1****1**.`logtest`-- The sentence`(logtest`is true if the logical**t1**)**t2***and*of the two's-complement representation of the integersand**t1**is not zero.**t2**

Michael R. Genesereth