File: expt-helper.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 (108 lines) | stat: -rw-r--r-- 2,561 bytes parent folder | download | duplicates (6)
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
; See the top-level arithmetic-3 LICENSE file for authorship,
; copyright, and license information.

;;
;; expt-helper.lisp
;;

(in-package "ACL2")


(local (include-book "basic-arithmetic"))

(local (include-book "inequalities"))

(local (include-book "prefer-times"))

(defmacro fc (x)
  x)

(defthm expt-crock
    (equal (expt x 1)
           (fix x))
  :hints (("Goal" :expand (expt x 1))))

(encapsulate
 ()

 (local
  (defun
    Math-induction-start-at-k (k n)
    (declare (xargs :measure (if (and (integerp k)
                                      (integerp n)
                                      (< k n))
                                 (- n k)
                               0)))
    (if (and (integerp k)
             (integerp n)
             (< k n))
        (Math-induction-start-at-k k (+ -1 n))
      t)))

 (local
  (defthm justify-induction
    (implies (and (integerp i)
		  (< 1 r)
		  (rationalp r))
	     (< (expt r i) (expt r (+ 1 i))))
    :hints (("Goal" :in-theory (enable prefer-*-to-/)))))

 (defthm expt-is-increasing-for-base>1
   (implies (and (< 1 r)
                 (< i j)
                 (rationalp r)
                 (integerp i)
                 (integerp j))
            (< (expt r i)
               (expt r j)))
   :rule-classes (:rewrite :linear)
   :hints (("Goal"
	    :do-not '(generalize)
            :induct (Math-induction-start-at-k i j)
	    :in-theory (enable prefer-*-to-/))
	   ("Subgoal *1/1" :use (:instance justify-induction
					   (i (+ -1 J))))))
)

;; The following four theorems need to be proved in the order
;; given.  However, I want them to be in a different order so
;; I prove them here, and then include them in expt.lisp in the
;; right order.

(defthm exponents-add-for-nonpos-exponents
  (implies (and (<= i 0)
		(<= j 0)
		(fc (integerp i))
		(fc (integerp j)))
	   (equal (expt r (+ i j))
		  (* (expt r i)
		     (expt r j)))))

(defthm exponents-add-for-nonneg-exponents
  (implies (and (<= 0 i)
		(<= 0 j)
		(fc (integerp i))
		(fc (integerp j)))
	   (equal (expt r (+ i j))
		  (* (expt r i)
		     (expt r j)))))

(defthm exponents-add-2
  (implies (and (not (equal 0 r))
		(fc (acl2-numberp r))
		(fc (integerp i))
		(fc (integerp j)))
	   (equal (expt r (+ i j))
		  (* (expt r i)
		     (expt r j))))
  :hints (("Goal" :expand (expt r (+ i j)))))

(defthm exponents-add-1
  (implies (and (fc (integerp i))
		(fc (integerp j)))
	   (equal (expt r (+ i j))
		  (if (equal (+ i j) 0)
		      1
		      (* (expt r i)
			 (expt r j)))))
  :hints (("Goal" :do-not '(generalize))))