File: top.lisp

package info (click to toggle)
acl2 8.5dfsg-5
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 991,452 kB
  • sloc: lisp: 15,567,759; javascript: 22,820; cpp: 13,929; ansic: 12,092; perl: 7,150; java: 4,405; xml: 3,884; makefile: 3,507; sh: 3,187; ruby: 2,633; ml: 763; python: 746; yacc: 723; awk: 295; csh: 186; php: 171; lex: 154; tcl: 49; asm: 23; haskell: 17
file content (422 lines) | stat: -rw-r--r-- 14,663 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
; Arithmetic-5 Library
; Written by Robert Krug
; Copyright/License:
; See the LICENSE file at the top level of the arithmetic-5 library.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; top.lisp
;;;
;;;
;;; This book collects all the other books together in one place,
;;; establishes a couple of useful theory collections, and sets up
;;; a default starting point.
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(in-package "ACL2")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Notes: 1 |(integerp (* c x))| in integerp.lisp should not be
;;; nneded after my type-set patch gets in ACL2.  Fix comment about
;;; version number.  Otherwise, prove some guards for it and uncomment
;;; it.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(deftheory base
  (current-theory :here))

;;; marker for determining whether this library is active

(include-book "we-are-here")

;;; We want these to be the last rules seen:
;;; See comments in basic.lisp.

(include-book "distributivity")

;;(include-book "elim-hint")

(include-book "default-hint")

(include-book "building-blocks")

(include-book "common")

(include-book "normalize")

(include-book "simplify")

(deftheory minimal-start-a
  (current-theory :here))

; (depends-on "build/ground-zero-theory.certdep" :dir :system)
(deftheory-static arithmetic-5-minimal-start-a
  (current-theory :here))

(include-book "mini-theories")

(include-book "numerator-and-denominator")

(deftheory natp-posp-start
  (current-theory :here))

(include-book "natp-posp")

(deftheory natp-posp-end
  (current-theory :here))

(include-book "integerp-meta")

(include-book "integerp")

(include-book "basic")

(include-book "expt")

(deftheory minimal-end-a
  (current-theory :here))

(deftheory-static arithmetic-5-minimal-end-a
  (current-theory :here))

(include-book "collect")

(include-book "remove-weak-inequalities")

(include-book "arithmetic-theory")

(include-book "types")

(deftheory minimal-start-b
  (current-theory :here))

(deftheory-static arithmetic-5-minimal-start-b
  (current-theory :here))

(include-book "simple-equalities-and-inequalities")

;;; We want these to be the first rules seen:

(include-book "if-normalization")

(include-book "forcing-types")

(deftheory minimal-end-b
  (current-theory :here))

(deftheory-static arithmetic-5-minimal-end-b
  (current-theory :here))

(deftheory full
  (current-theory :here))

(deftheory minimal-arithmetic-theory
   (union-theories
    (theory 'base)
    (union-theories (set-difference-theories (theory 'minimal-end-a)
					     (theory 'minimal-start-a))
		    (set-difference-theories (theory 'minimal-end-b)
					     (theory 'minimal-start-b)))))

(deftheory natp-posp-theory
  (set-difference-theories (theory 'natp-posp-end)
			   (theory 'natp-posp-start)))

(defmacro enable-natp-pposp-theory ()
  '(progn
     (in-theory (enable natp-posp-theory))
     (in-theory (disable natp posp))))

(defmacro disable-natp-posp-theory ()
  '(progn
     (in-theory (disable natp-posp-theory))
     (in-theory (enable natp posp))))

(disable-natp-posp-theory)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; There are two basic ways of normalizing terms such as
;;; (expt x (+ m n)) and (* (expt x m) (expt x n)).  One can choose the
;;; first of these as the normal form and gather-exponents, or one can
;;; choose the second as the normal form and scatter-exponents.
;;; We here define some macros to make things easier, and recommend
;;; that they be used.

(deftheory gather-exponents-theory
    '(normalize-factors-gather-exponents
      simplify-products-gather-exponents-equal
      simplify-products-gather-exponents-<))

;;; Keep this in sync with arithmetic-default-hint
;;; in default-hint.lisp.

(deftheory scatter-exponents-theory
    '(|(expt x (+ m n))|
      |(expt x (+ m n)) non-zero (+ m n)|
      |(expt x (+ m n)) non-zero x|
      ;;|(expt x (+ m n)) non-pos m and n|
      ;;|(expt x (+ m n))) non-neg m and n|
      normalize-factors-scatter-exponents
      simplify-products-scatter-exponents-equal
      simplify-products-scatter-exponents-<))

(deftheory prefer-positive-addends-theory
    '(prefer-positive-addends-equal
      prefer-positive-addends-<
      |(equal (+ (- c) x) y)|
      |(< (+ (- c) x) y)|
      |(< y (+ (- c) x))|))

;;; Keep this in sync with arithmetic-default-hint
;;; in default-hint.lisp.

(deftheory prefer-positive-exponents-scatter-exponents-theory
    '(prefer-positive-exponents-scatter-exponents-equal
      prefer-positive-exponents-scatter-exponents-<
      PREFER-POSITIVE-EXPONENTS-SCATTER-EXPONENTS-<-2))

(defmacro gather-exponents ()
  '(progn
    (in-theory (disable scatter-exponents-theory))
    (in-theory (disable prefer-positive-exponents-scatter-exponents-theory))
    (in-theory (enable gather-exponents-theory))))

(defmacro scatter-exponents ()
  '(progn
    (in-theory (disable gather-exponents-theory))
    (in-theory (enable scatter-exponents-theory))))

(defmacro prefer-positive-exponents ()
  '(progn
    (in-theory (disable gather-exponents-theory))
    (in-theory (enable prefer-positive-exponents-scatter-exponents-theory))
    (in-theory (enable scatter-exponents-theory))))

(defmacro do-not-prefer-positive-exponents ()
  '(in-theory (disable prefer-positive-exponents-scatter-exponents-theory)))

(defmacro prefer-positive-addends ()
  '(in-theory (enable prefer-positive-addends-theory)))

(defmacro do-not-prefer-positive-addends ()
  '(in-theory (disable prefer-positive-addends-theory)))

(gather-exponents)

(prefer-positive-addends)

(theory-invariant
 (if (active-runep '(:definition arith-5-active-flag))
     (not (and (active-runep '(:rewrite |(expt x (+ m n))|))
               (active-runep '(:rewrite normalize-factors-gather-exponents))))
   t)
 :error nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(in-theory (disable expt))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; We wish to set up the theory that will be used when ACL2 is rewriting
;;; an inequality, prepatory to doing linear and non-linear arithmetic.
;;; The user should not have to change any of this.

(in-theory (disable |arith (expt x c)|
                    |arith (- (- x))| |arith (- (+ x y))|
                    |arith (* y x)| |arith (* y (* x z))|
                    |arith (* (* x y) z)| |arith (* 1 x)|
                    |arith (* x 1)| |arith (* 0 x)|
                    |arith (* x 0)| |arith (* -1 x)|
                    |arith (/ (/ x))| |arith (/ (* x y))|
                    |arith (* x (+ y z))| |arith (* (+ x y) z)|
                    |arith (* x (- y))| |arith (* (- x) y)|
                    |arith (- (* c x))| |arith (/ (- x))|
                    |arith (expt (+ x y) 2)| |arith (expt (+ x y) 3)|
                    |arith (expt x 0)|
                    |arith (expt 0 n)| |arith (expt x 1)|
                    |arith (expt 1 n)| |arith (expt x -1)|
                    ;|arith (expt (/ x) n)| |arith (expt x (- n))|
                    ;|arith (expt (/ x) (- c))|
                    ;|arith (expt 1/c n)|
		    |arith (expt (/ x) n)|
		    |arith (/ (expt x n))|
		    |arith (expt 1/c n)|
                    |arith (expt 4 n)| |arith (expt 8 n)|
                    |arith (expt 16 n)|
                    |arith (expt (* x y) n)|
                    |arith (expt (expt x m) n)| |arith (expt x (+ m n))|
                    ;;|arith (expt x (+ m n)) non-pos m and n|
                    ;;|arith (expt x (+ m n))) non-neg m and n|
                    |arith (expt x (+ m n)) non-zero x|
                    |arith (fix x)| |arith (* (expt x n) (expt y n))|
                    |arith (* x x)| |arith (* x (/ x))|
                    |arith (* x (expt x n))| |arith (* x (expt (- x) n))|
		    |arith (* x (expt x (- n)))|
                    |arith (* x (/ (expt x n)))|
                    |arith (* (numerator x) (/ (denominator x)))|
                    |arith (* c (* d x))|
		    |arith (* x (expt (- x) (- n)))|
		    |arith (* x (/ (expt (- x) n)))|
                    |arith (* (/ x) (expt x n))| |arith (* (/ x) (expt (- x) n))|
                    |arith (* (expt x m) (expt x n))|
                    |arith (* (expt (- x) m) (expt x n))|
                    |arith (* (expt x m) (expt (- x) n))|
		    |arith (* (expt x (- m)) (expt x n))|
                    |arith (* (/ (expt x m)) (expt x n))|
		    |arith (* (expt x m) (expt x (- n)))|
		    |arith (* (expt (- x) (- m)) (expt x n))|
                    |arith (* (/ (expt (- x) m)) (expt x n))|
		    |arith (* (expt x (- m)) (expt (- x) n))|
                    |arith (* (/ (expt x m)) (expt (- x) n))|
                    |arith (* (expt x m) (/ (expt x n)))|
                    |arith (* (expt (- x) m) (/ (expt x n)))|
		    |arith (* (expt (- x) m) (expt x (- n)))|
		    |arith (* (expt x m) (expt (- x) (- n)))|
                    |arith (* (expt x m) (/ (expt (- x) n)))|
                    |arith (* (expt c n) (expt d n))|
                    |arith (+ c (+ d x))|
                    |arith (+ x x)| |arith (+ x (- x))|
                    |arith (+ x (* c x))| |arith (+ (- x) (* c x))|
                    |arith (+ (* c x) (* d x))|
                    arith-collect-+ arith-collect-+-problem-finder
                    arith-collect-* arith-collect-*-problem-finder
                    arith-bubble-down
                    arith-bubble-down-+-problem-finder
                    arith-bubble-down-+-bubble-down
                    arith-bubble-down-+-match-1
                    arith-bubble-down-+-match-2
                    arith-bubble-down-+-match-3
                    arith-bubble-down-*-problem-finder
                    arith-bubble-down-*-bubble-down
                    arith-bubble-down-*-match-1
                    arith-bubble-down-*-match-2
                    arith-bubble-down-*-match-3
                    |(arith-collect-* y x)| |(arith-collect-+ y x)|
                    arith-find-matching-factor-scatter-exponents
                    arith-normalize-factors-scatter-exponents
                    arith-normalize-addends
		    arith-find-matching-addend))

(in-arithmetic-theory '(|arith (expt x c)|
			|arith (- (- x))| |arith (- (+ x y))|
			|arith (* y x)| |arith (* y (* x z))|
			|arith (* (* x y) z)| |arith (* 1 x)|
			|arith (* x 1)| |arith (* 0 x)|
			|arith (* x 0)| |arith (* -1 x)|
			|arith (/ (/ x))| |arith (/ (* x y))|
			|arith (* x (+ y z))| |arith (* (+ x y) z)|
			|arith (* x (- y))| |arith (* (- x) y)|
			|arith (- (* c x))| |arith (/ (- x))|
			|arith (expt (+ x y) 2)| |arith (expt (+ x y) 3)|
			|arith (expt x 0)|
			|arith (expt 0 n)| |arith (expt x 1)|
			|arith (expt 1 n)| |arith (expt x -1)|
					;|arith (expt (/ x) n)| |arith (expt x (- n))|
					;|arith (expt (/ x) (- c))|
					;|arith (expt 1/c n)|
			|arith (expt (/ x) n)|
			|arith (/ (expt x n))|
			|arith (expt 1/c n)|
			|arith (expt 4 n)| |arith (expt 8 n)|
			|arith (expt 16 n)|
			|arith (expt (* x y) n)|
			|arith (expt (expt x m) n)| |arith (expt x (+ m n))|
			;;|arith (expt x (+ m n)) non-pos m and n|
			;;|arith (expt x (+ m n))) non-neg m and n|
			|arith (expt x (+ m n)) non-zero x|
			|arith (fix x)| |arith (* (expt x n) (expt y n))|
			|arith (* x x)| |arith (* x (/ x))|
			|arith (* x (expt x n))| |arith (* x (expt (- x) n))|
			|arith (* x (expt x (- n)))|
			|arith (* x (/ (expt x n)))|
			|arith (* (numerator x) (/ (denominator x)))|
			|arith (* c (* d x))|
			|arith (* x (expt (- x) (- n)))|
			|arith (* x (/ (expt (- x) n)))|
			|arith (* (/ x) (expt x n))| |arith (* (/ x) (expt (- x) n))|
			|arith (* (expt x m) (expt x n))|
			|arith (* (expt (- x) m) (expt x n))|
			|arith (* (expt x m) (expt (- x) n))|
			|arith (* (expt x (- m)) (expt x n))|
			|arith (* (/ (expt x m)) (expt x n))|
			|arith (* (expt x m) (expt x (- n)))|
			|arith (* (expt (- x) (- m)) (expt x n))|
			|arith (* (/ (expt (- x) m)) (expt x n))|
			|arith (* (expt x (- m)) (expt (- x) n))|
			|arith (* (/ (expt x m)) (expt (- x) n))|
			|arith (* (expt x m) (/ (expt x n)))|
			|arith (* (expt (- x) m) (/ (expt x n)))|
			|arith (* (expt (- x) m) (expt x (- n)))|
			|arith (* (expt x m) (expt (- x) (- n)))|
			|arith (* (expt x m) (/ (expt (- x) n)))|
			|arith (* (expt c n) (expt d n))|
			|arith (+ c (+ d x))|
			|arith (+ x x)| |arith (+ x (- x))|
			|arith (+ x (* c x))| |arith (+ (- x) (* c x))|
			|arith (+ (* c x) (* d x))|
			;arith-collect-+
			arith-collect-+-problem-finder
			;arith-collect-*
			arith-collect-*-problem-finder
			;arith-bubble-down
			arith-bubble-down-+-problem-finder
			arith-bubble-down-+-bubble-down
			arith-bubble-down-+-match-1
			arith-bubble-down-+-match-2
			arith-bubble-down-+-match-3
			arith-bubble-down-*-problem-finder
			arith-bubble-down-*-bubble-down
			arith-bubble-down-*-match-1
			arith-bubble-down-*-match-2
			arith-bubble-down-*-match-3
			|(arith-collect-* y x)| |(arith-collect-+ y x)|
			;arith-find-matching-factor-scatter-exponents
			arith-normalize-factors-scatter-exponents
			arith-normalize-addends
			;arith-find-matching-addend
			))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; These next rules have caused problems at one point or another, or
;;; are superseded by rules in this library. I might want to
;;; reconsider what to do later.

(in-theory (disable Associativity-of-+ Commutativity-of-+
		    Unicity-of-0 Inverse-of-+ Rationalp-+
		    Rationalp-unary-- Unicity-of-1
		    Associativity-of-* Commutativity-of-*
		    Inverse-of-* Rationalp-*
		    Rationalp-unary-/
		    Distributivity
		    Nonnegative-product
		    Rationalp-implies-acl2-numberp
		    Expt-type-prescription-non-zero-base
		    default-+-1 default-+-2
		    default-*-1 default-*-2
		    default-unary-minus default-unary-/
		    default-<-1 default-<-2
		    default-denominator default-numerator))

(deftheory default-arithmetic-theory
  (current-theory :here))

(defmacro set-default-arithmetic-theory ()
  `(in-theory (union-theories (set-difference-theories (current-theory :here)
                                                       (theory 'full))
                              (theory 'default-arithmetic-theory))))

(defmacro set-minimal-arithmetic-theory ()
  `(in-theory (union-theories (set-difference-theories (current-theory :here)
                                                       (theory 'full))
                              (theory 'minimal-arithmetic-theory))))

(include-book "banner"
; Avoid printing banner twice:
              :load-compiled-file nil)