File: floor-proofs.lisp

package info (click to toggle)
acl2 6.5-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 108,856 kB
  • ctags: 110,136
  • sloc: lisp: 1,492,565; xml: 7,958; perl: 3,682; sh: 2,103; cpp: 1,477; makefile: 1,470; ruby: 453; ansic: 358; csh: 125; java: 24; haskell: 17
file content (282 lines) | stat: -rw-r--r-- 9,105 bytes parent folder | download | duplicates (8)
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
(in-package "ACL2")

(local (include-book "ground-zero"))
(local (include-book "fp2"))
(local (include-book "denominator"))
(local (include-book "numerator"))
(local (include-book "predicate"))
(local (include-book "nniq"))
(local (include-book "product"))
(local (include-book "unary-divide"))
(local (include-book "rationalp"))
(local (include-book "inverted-factor"))
(local (include-book "meta/meta-plus-lessp" :dir :system))
; (thm (rationalp (floor i j)))) goes through



(defthm floor-non-negative-integerp-type-prescription
  (implies (and (<= 0 i)
                (<= 0 j)
                (case-split (not (complex-rationalp j))) ;gen?
                )
           (and (<= 0 (floor i j))
                (integerp (floor i j))))
  :rule-classes (:type-prescription)
  :hints (("Goal" :in-theory (set-difference-theories
                              (enable floor)
                              '()))
          ))

;nope. (floor #C(0 -1)  #C(0 -1)) = 1
;(defthm floor-with-j-non-rational
;  (implies (not (rationalp j))
 ;          (equal (floor i j)
  ;                0))
;  :hints (("Goal" :in-theory (set-difference-theories
 ;                             (enable floor)
  ;                            '(a13 FL-WEAKLY-MONOTONIC)))
   ;       ))


(defthm floor-non-negative
  (implies (and (<= 0 i)
                (<= 0 j)
                (case-split (not (complex-rationalp i)));drop?
                ;(case-split (rationalp j))
                )
           (<= 0 (floor i j)))

  :hints (("Goal" :in-theory (set-difference-theories
                              (enable floor)
                              '()))
          ))


(defthm floor-with-i-not-rational-but-j-rational
  (implies (and (not (rationalp i))
                (rationalp j)
                )
           (equal (floor i j)
                  0))
  :hints (("Goal" :in-theory (enable floor)))
)


(defthm floor-compare-to-zero
  (implies (and (case-split (rationalp i))
                (case-split (rationalp j)))
           (equal (< (floor i j) 0)
                  (or (and (< i 0) (< 0 j))
                      (and (< 0 i) (< j 0))
                      )))
  :hints (("Goal" :in-theory (enable floor)))
  )

(defthm floor-of-non-acl2-number
  (implies (not (acl2-numberp i))
           (and (equal (floor i j)
                       0)
                (equal (floor j i)
                       0)))
  :hints (("Goal" :in-theory (enable floor)))
  )

;linear? how should it be phrased?
;too many hints.  without the frac-coeff rule, things worked out here
(defthm floor-upper-bound
    (implies (and (case-split (rationalp i))
                  (case-split (rationalp j))
                  )
	     (<= (floor i j) (/ i j)))
    :hints (("Goal" :use ( (:instance nonnegative-integer-quotient-lower-bound-rewrite
                                      (i (* -1 (NUMERATOR (* I (/ J)))))
                                      (j (DENOMINATOR (* I (/ J)))))
                           (:instance  nonnegative-integer-quotient-upper-bound-rewrite
                                      (i (* -1 (NUMERATOR (* I (/ J)))))
                                      (j (DENOMINATOR (* I (/ J)))))
                           (:instance  nonnegative-integer-quotient-lower-bound-rewrite
                                      (i (NUMERATOR (* I (/ J))))
                                      (j (DENOMINATOR (* I (/ J)))))
                           (:instance  nonnegative-integer-quotient-upper-bound-rewrite
                                      (i (NUMERATOR (* I (/ J))))
                                      (j (DENOMINATOR (* I (/ J))))))
                           
             :in-theory (set-difference-theories
                         (enable floor)
                         '(  nonnegative-integer-quotient-lower-bound-rewrite
                             nonnegative-integer-quotient-upper-bound-rewrite
                           ))))
    :rule-classes (:rewrite (:linear :trigger-terms ((floor i j))))
  )



(defthm floor-equal-i-over-j-rewrite
  (implies (and (case-split (not (equal j 0)))
                (case-split (rationalp i))
                (case-split (rationalp j))
                )
           (equal (EQUAL (* J (FLOOR I J)) I)
                  (integerp (* i (/ j)))))
  :otf-flg t
  :hints (("Goal" :in-theory (set-difference-theories
                              (enable floor)
                              '( nonnegative-integer-quotient-lower-bound-rewrite
                                 nonnegative-integer-quotient-max-value-rewrite))
           :use(
                (:instance  nonnegative-integer-quotient-max-value-rewrite
                            (i (* -1 (NUMERATOR (* I (/ J)))))
                            (j (DENOMINATOR (* I (/ J)))))
           
                (:instance  nonnegative-integer-quotient-lower-bound-rewrite
                            (i (* -1 (NUMERATOR (* I (/ J)))))
                            (j (DENOMINATOR (* I (/ J))))))
           )  )
  )



(defthm dumb
  (equal (< x x)
         nil))

(defthm floor-with-j-zero
  (equal (floor i 0)
                  0)
  :hints (("Goal" :in-theory (enable floor)))
)


;(defthm floor-greater-than-zero-rewrite
 ; (equal (< 0 (fl i j))
  ;       (

(defthm floor-upper-bound-2
  (implies (and (<= 0 j)
                (case-split (rationalp i))
                (case-split (rationalp j))
                (case-split (not (equal j 0)))
                )
           (<= (* j (floor i j)) i))
  :hints (("Goal" :in-theory (disable  floor-upper-bound)
           :use  floor-upper-bound))
  :rule-classes (:rewrite (:linear :trigger-terms ((floor i j))))

  )


(defthm floor-upper-bound-3
  (implies (and (<= j 0)
                (case-split (rationalp i))
                (case-split (rationalp j))
                (case-split (not (equal j 0)))
                )
           (<= i (* j (floor i j))))
  :hints (("Goal" :in-theory (disable  floor-upper-bound)
           :use  floor-upper-bound))
  :rule-classes (:rewrite (:linear :trigger-terms ((floor i j))))

  )


;BOZO remove the disables (and prove better nniq rules, and disable nniq!)
(defthm floor-lower-bound
  (implies (and (case-split (rationalp i))
                (case-split (rationalp j))
                )
           (< (+ -1 (* i (/ j))) (floor i j)))
  :otf-flg t
  :hints (("Goal"
             
           :in-theory (set-difference-theories
                       (enable floor)
                       '( ;why do these disables help so much?
                         less-than-multiply-through-by-inverted-factor-from-left-hand-side
                         less-than-multiply-through-by-inverted-factor-from-right-hand-side
                         EQUAL-MULTIPLY-THROUGH-BY-INVERTED-FACTOR-FROM-RIGHT-HAND-SIDE
                         )
                       )))
  :rule-classes (:rewrite (:linear :trigger-terms ((floor i j)))))





(defthm floor-when-arg-quotient-isnt-rational
  (IMPLIES (NOT (RATIONALP (* i (/ j))))
           (EQUAL (FLOOR i j) 0))
  :hints (("Goal" :in-theory (enable floor))))

(defthm floor-of-non-rational-by-one
  (implies (not (rationalp i))
           (equal (floor i 1)
                  0))
  :hints (("Goal" :in-theory (enable floor))))

(defthm floor-of-rational-and-complex
  (implies (and (rationalp i)
                (not (rationalp j))
                (case-split (acl2-numberp j)))
           (and (equal (floor i j)
                       0)
                (equal (floor j i)
                       0)))
  :hints (("Goal" :in-theory (enable floor))))

#|
(defthm floor-of-two-complexes
  (implies (and (complex-rationalp i)
                (complex-rationalp j))
           (equal (floor i j)
                  (if (rationalp (/ i j))
                      (floor (/ i j) 1)
                    0)))
  :hints (("Goal" :in-theory (enable floor))))
|#

(defthm floor-with-i-not-rational
  (implies (not (rationalp i))
           (equal (floor i j)
                  (if (and (complex-rationalp i) (complex-rationalp j) (rationalp (/ i j)))
                      (floor (/ i j) 1)
                    0)))
  :hints (("Goal" :in-theory (enable floor))))

(defthm floor-with-j-not-rational
  (implies (not (rationalp j))
           (equal (floor i j)
                  (if (and (complex-rationalp i) (complex-rationalp j) (rationalp (/ i j)))
                      (floor (/ i j) 1)
                    0)))
  :hints (("Goal" :in-theory (enable floor))))




(defthm floor-with-j-not-rational-but-i-rational
  (implies (and (not (rationalp i))
                (rationalp j)
                )
           (equal (floor i j)
                  0)))

#|
(defthm floor-by-one-equal-zero
  (implies (and (rationalp i)
                (rationalp j))
           (equal (EQUAL 0 (FLOOR (* i (/ j)) 1))
                  (integerp (* i (/ j)))))
  :hints (("Goal" :in-theory (enable floor)))
)
|#

(defthm floor-of-zero
  (equal (floor 0 j)
         0))

(defthm floor-of-integer-by-1
  (implies (integerp i)
           (equal (floor i 1)
                  i))
  :hints (("Goal" :in-theory (enable  floor))))