File: nsa.lisp

package info (click to toggle)
acl2 8.6%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 1,111,420 kB
  • sloc: lisp: 17,818,294; java: 125,359; python: 28,122; javascript: 23,458; cpp: 18,851; ansic: 11,569; perl: 7,678; xml: 5,591; sh: 3,976; makefile: 3,833; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (208 lines) | stat: -rw-r--r-- 6,354 bytes parent folder | download | duplicates (5)
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
; Copyright (C) 2007 by Shant Harutunian
; License: A 3-clause BSD license.  See the LICENSE file distributed with ACL2.

(in-package "ACL2")

(include-book "arith-nsa4")
(include-book "abs")

(deflabel nsa-theory-start)

(defthm standard-part-abs-0-thm
  (iff (= (standard-part (abs x)) 0)
       (= (standard-part x) 0)))

(defthm standard-numberp-times-type-thm
  (implies
   (and
    (standard-numberp x)
    (standard-numberp y))
   (standard-numberp (* x y)))
  :rule-classes ((:type-prescription)))

(defthm standard-numberp-plus-type-thm
  (implies
   (and
    (standard-numberp x)
    (standard-numberp y))
   (standard-numberp (+ x y)))
  :rule-classes ((:type-prescription)))

(encapsulate
  ()

  (local (defthm arith-4
           (implies
            (and
             (realp x)
             (realp y)
             (not (equal x 0))
             (not (equal y 0))
             (<= (abs x)
                 (abs y)))
            (<= (abs (/ y))
                (abs (/ x))))
           :rule-classes nil))

  (defthm standard-bound-x-implies-limited-x-thm
    (implies
     (and
      (standard-numberp y)
      (realp y)
      (realp x)
      (not (equal y 0))
      (<= (abs x)
          (abs y)))
     (i-limited x))
    :rule-classes nil
    :hints (("Goal" :cases ((equal y 0) (not (equal y 0)))
             :in-theory (disable abs))
            ("Goal'" :use ((:instance arith-4)
                           (:instance standard-part-<= (x (abs (/ y)))
                                      (y (abs (/ x))))))))

  (defthm limited-bound-x-implies-limited-x-thm
    (implies
     (and
      (i-limited y)
      (realp y)
      (realp x)
      (not (equal y 0))
      (<= (abs x)
          (abs y)))
     (i-limited x))
    :rule-classes nil
    :hints (("Goal" :cases ((i-small y) (not (i-small y)))
             :in-theory (disable abs))
            ("Subgoal 2" :use ((:instance arith-4)
                               (:instance standard-part-<= (x (abs (/ y)))
                                          (y (abs (/ x))))))
            ("Subgoal 1" :use ((:instance arith-4)
                               (:instance standard-part-<= (x (abs (/ y)))
                                          (y (abs (/ x)))))))))

(defthm plus-limited
  (implies
   (and
    (realp x)
    (realp y)
    (i-limited x)
    (i-limited y))
   (i-limited (+ x y)))
  :rule-classes :rewrite
  :hints (("Goal" :use ((:instance standard+small->i-limited
                                   (x (standard-part (+ x y)))
                                   (eps (- (+ x y) (standard-part (+ x y)))))))))

(defthm times-limited
  (implies
   (and
    (realp x)
    (realp y)
    (i-limited x)
    (i-limited y))
   (i-limited (* x y)))
  :rule-classes :rewrite
  :hints (("Goal"  :use ((:instance standard+small->i-limited
                                    (x (standard-part (* x y)))
                                    (eps (- (* x y) (standard-part (* x
                                                                      y)))))))))

(defthm divide-limited
  (implies
   (and
    (realp x)
    (realp y)
    (i-limited x)
    (i-limited y)
    (not (i-small y)))
   (i-limited (/ x y)))
  :rule-classes :rewrite
  :hints (("Goal"  :use ((:instance standard+small->i-limited
                                    (x (standard-part (/ x y)))
                                    (eps (- (/ x y) (standard-part (/ x
                                                                      y)))))))))

(defthm btwn-0-and-1-limited-thm
  (implies
   (and
    (realp a)
    (< 0 a)
    (< a 1))
   (i-limited a))
  :rule-classes nil
  :hints (("Goal"  :cases ((i-small a) (not (i-small a))))
          ("Subgoal 1" :use ((:instance (:theorem (implies
                                                   (and
                                                    (realp x)
                                                    (realp y)
                                                    (not (equal x 0))
                                                    (not (equal y 0))
                                                    (< 0 x)
                                                    (< x 1))
                                                   (< 1 (/ x)))))
                             (:instance standard-part-<= (x 1)
                                        (y (/ a)))))))

(defthm sandwich-limited-thm-hint-1
  (implies
   (and
    (realp u)
    (realp v)
    (realp a)
    (< 0 a)
    (< a 1)
    (i-limited u)
    (i-limited v))
   (i-limited (+ v (* a (- u v)))))
  :rule-classes nil
  :hints (("Goal" :use ((:instance btwn-0-and-1-limited-thm)))))

(defthm sandwich-limited-thm
  (implies
   (and
    (realp u)
    (realp v)
    (realp x)
    (< u x)
    (< x v)
    (i-limited u)
    (i-limited v))
   (i-limited x))
  :rule-classes nil
  :hints (("Goal" :in-theory (disable i-large
                                      DISTRIBUTIVITY
                                      distributivity-left)
           :use ((:instance  sandwich-limited-thm-hint-1
                             (a (/ (- x v) (- u v))))))))

(defthm /-large-integer-is-ismall-thm
  (i-small (/ (i-large-integer)))
  :hints (("Goal" :in-theory (disable i-large-integer-is-large)
           :use ((:instance i-large-integer-is-large)))))

(deftheory nsa-theory
  (set-difference-theories
   (universal-theory :here)
   (universal-theory 'nsa-theory-start)))

(defthm standard-part-limited-thm
  (implies
   (and
    (realp x)
    (i-limited x))
   (i-limited (standard-part x)))
  :hints (("Goal" :use ((:instance standards-are-limited
                                   (x (standard-part x)))))))

(defthm /-large-integer-standard-part-thm
  (equal (STANDARD-PART (/ (I-LARGE-INTEGER)))
         0)
  :hints (("Goal" :in-theory (disable /-LARGE-INTEGER-IS-ISMALL-THM)
           :use ((:instance /-LARGE-INTEGER-IS-ISMALL-THM)))))

(defthm /-large-integer-limited-thm
  (i-limited (/ (I-LARGE-INTEGER)))
  :rule-classes ((:type-prescription) (:rewrite))
  :hints (("Goal" :in-theory (disable /-LARGE-INTEGER-IS-ISMALL-THM)
           :use ((:instance /-LARGE-INTEGER-IS-ISMALL-THM)))))