NON-LINEAR-ARITHMETIC

This documentation topic is divided into two parts. We first
discuss the practical aspect of how to use the non-linear arithmetic
extension to ACL2,
and then the theory behind it. We assume that the reader is
familiar with the material in linear-arithmetic and that on
:linear rules.

We begin our discussion of how to use non-linear arithmetic with
a simple example. Assume that we wish to prove:

Note that (floor x y) <= (/ x y). Note also that if we
divide both sides of x < (* y z) by y, since 0 < y, we
obtain (/ x y) < z. By chaining these two inequalities
together, we get the inequality we desired to prove.

We now proceed with our example session:

(skip-proofs
(progn

; Since the truth of this theorem depends on the linear properties
; of floor, we will need the linear lemma:

; We create five rewrite rules which we will use during non-linear
; arithmetic. The necessity for these is due to one of the differences in
; ACL2's behaviour when non-linear arithmetic is turned on. Although
; the conclusions of linear lemmas have always been rewritten before
; they are used, now, when non-linear arithmetic is turned on, the
; conclusions are rewritten under a different theory than under ``normal''
; rewriting. This theory is also used in other, similar, circumstances
; described below.

The above example illustrates the two practical requirements for using
non-linear arithmetic in ACL2. First, one must set up an
arithmetic-theory. Usually, one would not set up an
arithmetic-theory on one's own but would instead load a library book or books
which do so. Second, one must turn the non-linear arithmetic extension
on. This one must do explicitly -- no book can do this for you.

You can also enable non-linear arithmetic with the hint :nonlinearp t.
See hints. We, in fact, recommend the use of a hint which will enable
nonlinear arithmetic only when the goal has stabilized under rewriting.
Using default-hints can make this easier.

This has proven to be a helpful strategy which allows faster proof
times.

We now proceed to briefly describe the theory behind the non-linear
extension to ACL2. In linear-arithmetic it was stated that,
``[L]inear polynomial inequalities can be combined by
cross-multiplication and addition to permit the deduction of a third
inequality....'' That is, if

0 < poly1,
0 < poly2,

and c and d are rational constants, then

0 < c*poly1 + d*poly2.

Similarly, given the above,

0 < poly1*poly2.

In the linear arithmetic case, we are taking advantage of the facts that
multiplication by a positive rational constant does not change the
sign of a polynomial and that the sum of two positive polynomials is
itself positive. In the non-linear arithmetic case, we are using the
fact that the product of two positive polynomials is itself positive.

and we wish to prove that a < 0. As described elsewhere
(see linear-arithmetic), we proceed by assuming the negation of our goal:

p4: 0 <= a,

and looking for a contradiction.

There are no cancellations which can be performed by linear arithmetic
in the above situation. (Recall that two polynomials are cancelled
against each other only when they have the same largest unknown.)
However, p1 has a product as its largest unknown, and for each of
the factors of that product there is a poly that has that factor as
a largest unknown. When non-linear arithmetic is enabled, ACL2
will therefore multiply p1' and p2' obtaining

p5: 0 < 3 + -2*x + -3*y + 2*x*y.

The addition of this polynomial will allow cancelation to continue
and, in this case, we will prove our goal. Thus, just as ACL2
adds two polynomials together when they have the same largest
unknown of opposite signs in order to create a new ``smaller''
polynomial; so ACL2 multiplies polynomials together when the
product of their largest unknowns is itself the largest unknown
of another polynomial. As the use of :linear lemmas
to further seed the arithmetic data base may allow cancellation to
proceed, so may the use of non-linear arithmetic.

This multiplication of polynomials is the other situation in which
terms are rewritten under the arithemtic-theory rather than the
normal one. Because this may be done so often, and because the
individual factors have presumably already been rewritten, it is
important that this be done in an efficient way. The use of a small,
specialized, theory helps avoid the repeated application of rewrite
rules to already stabilized terms.