49
53
(equal (equal (* x y) y)
50
54
(and (acl2-numberp y)
51
55
(or (equal y 0) (equal x 1)))))
52
:hints (("Goal" :in-theory (enable equal-*-x-y-x)))
53
:doc ":doc-section math-lemmas
54
Rewrite: x + y = x EQUAL y = 0;
55
x * y = x EQUAL x = 0 or y = 1;
56
also commutative forms.
56
:enable equal-*-x-y-x)
59
(defthm normalize-equal-0
58
(defrule normalize-equal-0
59
:short "Rewrite @('(equal (- x) 0)'), @('(equal (+ x y) 0)'), and
60
@('(equal (* x y) 0)')."
60
61
(and (equal (equal (- x) 0) (equal (fix x) 0))
61
62
(equal (equal (+ x y) 0) (equal (fix x) (- y)))
62
(equal (equal (* x y) 0) (or (equal (fix x) 0) (equal (fix y) 0))))
63
:doc ":doc-section math-lemmas
64
Rewrite: -x = 0 EQUAL x = 0;
65
x + y = 0 EQUAL x = -y;
66
x * y = 0 EQUAL x = 0 or y = 0.
69
(deftheory acl2-numberp-algebra
72
'(EQUAL EQL = /= IFF FORCE BINARY-+ BINARY-* UNARY-- UNARY-/
74
;; 1+ 1- ; removed in 1.8
77
commutativity-of-+ COMMUTATIVITY-OF-* inverse-of-+
78
associativity-of-+ associativity-of-* commutativity-2-of-+
79
commutativity-2-of-* unicity-of-0 functional-self-inversion-of-minus
80
unicity-of-1 default-*-1 default-*-2
81
default-<-1 default-<-2 default-+-1 default-+-2
82
inverse-of-* functional-self-inversion-of-/ minus-cancellation-on-right
83
minus-cancellation-on-left /-cancellation-on-left
84
/-cancellation-on-right
85
equal-*-x-y-y cancel-equal-+-* normalize-equal-0
86
left-cancellation-for-* left-cancellation-for-+
87
equal-minus-0 zero-is-only-zero-divisor
88
equal-minus-minus equal-/-/ default-unary-minus equal-/ equal-*-/-2
89
functional-commutativity-of-minus-*-left
90
functional-commutativity-of-minus-*-right
91
reciprocal-minus equal-minus-minus distributivity-of-/-over-*
93
distributivity-of-minus-over-+))
94
:doc ":doc-section math-lemmas
95
A basic theory of algebra for all ACL2-NUMBERPs.
98
This theory includes the following lemmas:
101
The ACL2-NUMBERP-ALGEBRA theory is designed to be a simple, compact basis
63
(equal (equal (* x y) 0) (or (equal (fix x) 0) (equal (fix y) 0)))))
65
(defsection acl2-numberp-algebra
66
:short "A basic theory of algebra for all @(see acl2-numberp)s."
68
:long "<p>The ACL2-NUMBERP-ALGEBRA theory is designed to be a simple, compact basis
102
69
for building other theories. This theory contains a minimal set of rules
103
70
for basic algebraic manipulation including associativity and commutativity,
104
71
simplification, cancellation, and normalization. It is extended by the
105
72
theories RATIONALP-ALGEBRA and INTEGERP-ALGEBRA to include selected linear
106
73
rules and rules for integers respectively. This theory also contains the
107
74
DEFUN-THEORY (which see) of all built-in function symbols that would
108
normally occur during reasoning about the ACL2-NUMBERPs.
110
We used keep this theory (and book) separate but roughly equal to the books
111
maintained by Matt K. in order to have a solid, simple, and predictable
112
foundation on which to build the rest of the books in the IHS
113
hierarchy. However it was decided that this was too much trouble
114
and we just select the rules of Matt K. that we want.~/
116
:cite cancel-equal-+-*")
118
(defthm rewrite-linear-equalities-to-iff
119
(equal (equal (< w x) (< y z))
120
(iff (< w x) (< y z)))
121
:doc ":doc-section math-lemmas
122
Rewrite: (EQUAL (< w x) (< y z)) = (IFF (< w x) (< y z)).
125
Some proofs of linear equalities don't work when presented as equalities
126
because they need to be proved by linear arithmetic, but linear arithmetic
127
only works at the literal level. This lemma allows you to state the
128
equality as an equality rewrite rule, but breaks the equality into
129
literals for the proof.")
131
(defthm normalize-<-minus-/
75
normally occur during reasoning about the ACL2-NUMBERPs.</p>
77
<p>We used keep this theory (and book) separate but roughly equal to the
78
books maintained by Matt K. in order to have a solid, simple, and predictable
79
foundation on which to build the rest of the books in the IHS hierarchy.
80
However it was decided that this was too much trouble and we just select the
81
rules of Matt K. that we want.</p>"
83
(deftheory acl2-numberp-algebra
86
'(EQUAL EQL = /= IFF FORCE BINARY-+ BINARY-* UNARY-- UNARY-/
88
;; 1+ 1- ; removed in 1.8
91
commutativity-of-+ COMMUTATIVITY-OF-* inverse-of-+
92
associativity-of-+ associativity-of-* commutativity-2-of-+
93
commutativity-2-of-* unicity-of-0 functional-self-inversion-of-minus
94
unicity-of-1 default-*-1 default-*-2
95
default-<-1 default-<-2 default-+-1 default-+-2
96
inverse-of-* functional-self-inversion-of-/ minus-cancellation-on-right
97
minus-cancellation-on-left /-cancellation-on-left
98
/-cancellation-on-right
99
equal-*-x-y-y cancel-equal-+-* normalize-equal-0
100
left-cancellation-for-* left-cancellation-for-+
101
equal-minus-0 zero-is-only-zero-divisor
102
equal-minus-minus equal-/-/ default-unary-minus equal-/ equal-*-/-2
103
functional-commutativity-of-minus-*-left
104
functional-commutativity-of-minus-*-right
105
reciprocal-minus equal-minus-minus distributivity-of-/-over-*
107
distributivity-of-minus-over-+))))
109
(defrule rewrite-linear-equalities-to-iff
110
:short "Rewrite: @('(EQUAL (< w x) (< y z))') → @('(IFF (< w x) (< y z))')."
111
:long "<p>Some proofs of linear equalities don't work when presented as
112
equalities because they need to be proved by linear arithmetic, but linear
113
arithmetic only works at the literal level. This lemma allows you to state
114
the equality as an equality rewrite rule, but breaks the equality into
115
literals for the proof.</p>"
116
(equal (equal (< w x) (< y z))
117
(iff (< w x) (< y z))))
119
(defrule normalize-<-minus-/
120
:short "Rewrite inequalities between 0 and negated or reciprocal terms, and
121
@('(< (- x) (- y))')."
132
122
(and (equal (< (- x) 0) (< 0 x))
133
123
(equal (< 0 (- x)) (< x 0))
137
127
(implies (real/rationalp x)
138
128
(and (equal (< 0 (/ x)) (< 0 x))
139
(equal (< (/ x) 0) (< x 0)))))
140
:doc ":doc-section math-lemmas
141
Rewrite: -x < 0 EQUAL 0 < x;
147
(deftheory rationalp-algebra
149
(theory 'ACL2-NUMBERP-ALGEBRA)
151
(defun-theory '(NUMERATOR DENOMINATOR < ABS PLUSP MINUSP MIN MAX SIGNUM
153
'(equal-*-/-1 *-r-denominator-r
154
default-denominator numerator-minus
155
equal-denominator-1 numerator-when-integerp
156
<-y-*-y-x <-*-y-x-y <-*-/-right <-*-/-right-commuted
157
<-*-/-left <-*-/-left-commuted
158
<-*-left-cancel <-0-minus /-preserves-positive /-preserves-negative
159
rewrite-linear-equalities-to-iff
161
<-unary-/-negative-left <-unary-/-negative-right
162
<-unary-/-positive-left <-unary-/-positive-right)))
163
:doc ":doc-section math-lemmas
164
A basic theory of algebra for all RATIONALPs.
167
This theory includes the ACL2-NUMBERP-ALGEBRA theory, along with the
168
following lemmas about the rationals:
171
This theory extends ACL2-NUMBERP-ALGEBRA to include theorems about
172
NUMERATOR and DENOMINATOR, and simple cancellationn and normalization
173
theorems and other simple theorems for inequalities.")
175
(defthm normalize-<-/-to-*
129
(equal (< (/ x) 0) (< x 0))))))
131
(defsection rationalp-algebra
132
:short "A basic theory of algebra for all @(see rationalp)s."
133
:long "<p>This theory includes the @(see acl2-numberp-algebra) theory along
134
with additional lemmas about the rationals.</p>
136
<p>This theory extends ACL2-NUMBERP-ALGEBRA to include theorems about NUMERATOR
137
and DENOMINATOR, and simple cancellation and normalization theorems and other
138
simple theorems for inequalities.</p>"
140
(deftheory rationalp-algebra
142
(theory 'ACL2-NUMBERP-ALGEBRA)
144
(defun-theory '(NUMERATOR DENOMINATOR < ABS PLUSP MINUSP MIN MAX SIGNUM
146
'(equal-*-/-1 *-r-denominator-r
147
default-denominator numerator-minus
148
equal-denominator-1 numerator-when-integerp
149
<-y-*-y-x <-*-y-x-y <-*-/-right <-*-/-right-commuted
150
<-*-/-left <-*-/-left-commuted
151
<-*-left-cancel <-0-minus /-preserves-positive /-preserves-negative
152
rewrite-linear-equalities-to-iff
154
<-unary-/-negative-left <-unary-/-negative-right
155
<-unary-/-positive-left <-unary-/-positive-right)))))
157
(defrule normalize-<-/-to-*
158
:parents (math-lemmas prefer-*-to-/)
159
:short "Rewrite: Replace @('x < 1/y') with @('x*y < 1') or @('x*y > 1'),
160
based on the sign of y."
176
161
(implies (and (real/rationalp x)
177
162
(real/rationalp y)
178
163
(not (equal y 0)))
179
164
(and (equal (< x (/ y)) (if (< y 0) (< 1 (* x y)) (< (* x y) 1)))
180
(equal (< (/ y) x) (if (< y 0) (< (* x y) 1) (< 1 (* x y))))))
181
:doc ":doc-section math-lemmas
182
Rewrite: Replace x < 1/y with x*y < 1 or x*y > 1, based on the sign of y.
165
(equal (< (/ y) x) (if (< y 0) (< (* x y) 1) (< 1 (* x y)))))))
185
(defthm normalize-<-/-to-*-3
167
(defrule normalize-<-/-to-*-3
168
:parents (math-lemmas prefer-*-to-/)
169
:short "Rewrite: Replace @('x < y/z') and @('x > y/z') with @('x*z < y') or
170
@('x*z > y'), depending on the sign of z."
186
171
(implies (and (real/rationalp x)
187
172
(real/rationalp y)
188
173
(real/rationalp z)
215
196
(equal (* x z) (fix y))))
216
197
(equal (equal x (* (/ z) y))
217
198
(and (acl2-numberp x)
218
(equal (* x z) (fix y))))))
219
:doc ":doc-section math-lemmas
220
Rewrite: Replace x = y/z with x*z = y.
223
(deftheory prefer-*-to-/
224
'(normalize-<-/-to-* normalize-<-/-to-*-3 normalize-equal-/-to-*)
225
:doc ":doc-section math-lemmas
226
A small theory of lemmas that eliminate / in favor of *.
229
This is a small theory of rules that eliminate / from equalites and
230
inequalities in favor of *, e.g., x < y/z is rewritten to x*y < z for
231
positive z. This theory is comaptible with the ALGEBRA theories, i.e., it
232
should not cause looping. The following lemmas are included:
235
These rules are not included in RATIONALP-ALGEBRA bacause it is not clear
236
that we should prefer x*y < z to x < y/z, or x*y = z to x = y/z. In the
237
case of the lemma NORMALIZE-EQUAL-/-TO-*, there is no reason to suspect
238
that `y' is a better term than `x'; in fact, the whole point of the proofs
239
using these libraries may have to do with a representation involving /.
240
So, unless someone provides a convincing reason to the contrary, these
241
rules will remain separate from the RATIONALP-ALGEBRA theory.
243
Note, however, that in certain cases this theory is just the thing that
244
needs to be ENABLEd to make the proofs work. Keep it in mind.~/
246
:cite normalize-<-/-to-*
247
:cite normalize-<-/-to-*-3
248
:cite normalize-equal-/-to-*
199
(equal (* x z) (fix y)))))))
201
(defsection prefer-*-to-/
202
:short "A small theory of lemmas that eliminate / in favor of *."
204
:long "<p>This is a small theory of rules that eliminate / from equalites and
205
inequalities in favor of *, e.g., @('x < y/z') is rewritten to @('x*y < z')
206
for positive z. This theory is compatible with the ALGEBRA theories, i.e.,
207
it should not cause looping.</p>
209
<p>These rules are not included in @(see rationalp-algebra) because it is not
210
clear that we should prefer @('x*y < z') to @('x < y/z'), or @('x*y = z') to
211
@('x = y/z'). In the case of the lemma @(see normalize-equal-/-to-*), there
212
is no reason to suspect that `y' is a better term than `x'; in fact, the
213
whole point of the proofs using these libraries may have to do with a
214
representation involving /. So, unless someone provides a convincing reason
215
to the contrary, these rules will remain separate from the @(see
216
rationalp-algebra) theory.</p>
218
<p>Note, however, that in certain cases this theory is just the thing that
219
needs to be ENABLEd to make the proofs work. Keep it in mind.</p>"
221
(deftheory prefer-*-to-/
224
normalize-equal-/-to-*)))
251
226
(in-theory (disable prefer-*-to-/))
253
(defthm integerp-+-minus-*
265
(integerp (* i j)))))
266
:doc ":doc-section math-lemmas
267
Rewrite: -i, i + j, i - j, and i * j are integers, when i and j are
271
The system has powerful enough type reasoning to `get' these facts
228
(defrule integerp-+-minus-*
229
:short "Rewrite: -i, i + j, i - j, and i * j are integers, when i and j are
231
:long "<p>The system has powerful enough type reasoning to `get' these facts
272
232
automatically most of the time. There are cases, however, where we need to
273
bring the full power of the rewriter to bear on the problem. In general
274
one would like to keep lemmas like this to a minimum so as to avoid
275
swamping the rewriter.~/")
277
(deftheory integerp-algebra
279
(theory 'RATIONALP-ALGEBRA)
281
(defun-theory '(INTEGERP INTEGER-ABS))
282
'(integerp-+-minus-* integerp==>denominator=1 <-minus-zero natp-rw posp-rw)))
283
:doc ":doc-section math-lemmas
284
A basic theory of algebra for all INTEGERPs.
287
This theory consists of the ACL2-NUMBERP-ALGEBRA and RATIONALP-ALGEBRA
288
theories, aloing with the follwing lemmas about the integers.
291
This theory extends ACL2-RATIONALP-ALGEBRA to include theorems about
292
NUMERATOR and DENOMINATOR for integers, and other special theorems about
295
(deftheory expt-algebra
296
'((expt) (:type-prescription expt)
297
expt-type-prescription-nonzero
298
expt-type-prescription-positive
299
expt-type-prescription-integerp
300
right-unicity-of-1-for-expt functional-commutativity-of-expt-/-base
301
expt-minus exponents-add exponents-multiply
303
expt-is-increasing-for-base>1 expt-is-decreasing-for-pos-base<1
304
expt-is-weakly-increasing-for-base>1
305
expt-is-weakly-decreasing-for-pos-base<1)
306
:doc ":doc-section math-lemmas
307
A theory of EXPT which is compatible with the ALGEBRA theories.~/
309
This theory contains the following documeted lemmas:
312
This theory contains :TYPE-PRESCRIPTIONS, simpification, normalization and
313
selected :LINEAR rules for EXPT. This theory will not be useful unless the
314
INTEGERP-ALGEBRA theory, or something similar is ENABLEd.")
317
(union-theories (theory 'integerp-algebra)
318
(theory 'expt-algebra))
319
:doc ":doc-section math-lemmas
320
The default theory of +, -, *, /, and EXPT for the IHS library.
323
This theory simply consists of the theories INTEGERP-ALGEBRA and
327
This theory is the default theory exported by this book. This theory will
328
normally be ENABLEd by every book in the IHS library.~/
330
:cite integerp-algebra
233
bring the full power of the rewriter to bear on the problem. In general one
234
would like to keep lemmas like this to a minimum so as to avoid swamping the
236
(and (implies (integerp i)
238
(implies (and (integerp i)
240
(and (integerp (+ i j))
242
(integerp (* i j))))))
244
(defsection integerp-algebra
245
:parents (math-lemmas ihs-math)
246
:short "A basic theory of algebra for all INTEGERPs."
247
:long "<p>this theory consists of the @(see acl2-numberp-algebra) and @(see
248
rationalp-algebra) theories, along with additional lemmas about the
251
(deftheory integerp-algebra
253
(theory 'RATIONALP-ALGEBRA)
255
(defun-theory '(INTEGERP INTEGER-ABS))
256
'(integerp-+-minus-* integerp==>denominator=1 <-minus-zero natp-rw posp-rw)))))
259
(defsection expt-algebra
260
:parents (math-lemmas ihs-math)
261
:short "A theory of EXPT which is compatible with the ALGEBRA theories."
262
:long "<p>This theory contains :TYPE-PRESCRIPTIONS, simpification,
263
normalization and selected :LINEAR rules for @(see EXPT.) This theory will
264
not be useful unless the @(see integerp-algebra) theory, or something similar
267
(deftheory expt-algebra
268
'((expt) (:type-prescription expt)
269
expt-type-prescription-nonzero
270
expt-type-prescription-positive
271
expt-type-prescription-integerp
272
right-unicity-of-1-for-expt functional-commutativity-of-expt-/-base
273
expt-minus exponents-add exponents-multiply
275
expt-is-increasing-for-base>1 expt-is-decreasing-for-pos-base<1
276
expt-is-weakly-increasing-for-base>1
277
expt-is-weakly-decreasing-for-pos-base<1)))
280
:short "The default theory of +, -, *, /, and EXPT for the IHS library."
281
:long "<p>This theory simply consists of the theories @(see INTEGERP-ALGEBRA)
282
and @(see EXPT-ALGEBRA).</p>
284
<p>This theory is the default theory exported by the @('ihs/math-lemmas') book.
285
This theory will normally be ENABLEd by every book in the IHS library.</p>"
288
(union-theories (theory 'integerp-algebra)
289
(theory 'expt-algebra))))