3
(local (include-book "integerp"))
4
(local (include-book "predicate"))
5
(local (include-book "fp2"))
9
;perhaps should export disabled
10
;make a forward-chaining rule?
11
(defthmd even-int-implies-int
12
(implies (and (integerp (* 1/2 x))
16
:rule-classes ((:rewrite :backchain-limit-lst (1 nil)))
17
:hints (("Goal" :in-theory (disable integerp-prod)
18
:use (:instance integerp-prod (x (* 1/2 x)) (y 2)))))
20
;this book is currently a mess.
22
;normal forms: leave evenp and oddp enabled
34
(implies (and (integerp x) (>= x 0))
35
(or (integerp (/ x 2)) (integerp (/ (1+ x) 2))))
37
:hints (("Goal" :induct (induct-nat x)))))
39
;is this sort of thing elsewhere? integerp.lisp?
41
(implies (and (integerp x)
47
(or (integerp (/ x 2)) (integerp (/ (1+ x) 2))))
49
:hints (("Goal" :in-theory (disable integerp-+)
50
:use ((:instance integerp-+ (x (+ 1/2 (* -1/2 X))) (y x))
51
(:instance x-or-x/2-4)
52
(:instance x-or-x/2-4 (x (- x)))))))
60
(local (defthm hack-int
61
(implies (and (integerp x)
65
(defthm integerp-sum-of-odds-over-2
66
(implies (and (rationalp x)
68
(integerp (* 2 x)) ;these two hyps say x is of the form (odd)/2
71
(equal (integerp (+ x y))
72
(and (integerp (* 2 y))
73
(not (integerp y)) ; (oddp (* 2 y)) ;rephrase the oddp hyps?
75
:hints (("Goal" :in-theory (disable even-int-implies-int)
76
:use ( (:instance even-int-implies-int (x (+ (* 2 x) (* 2 y))))
77
(:instance hack-int (x (+ 1/2 X)) (y (+ 1/2 y)))
78
(:instance x-or-x/2 (x (* 2 x)))
79
(:instance x-or-x/2 (x (* 2 y)))))))
82
;derive the results below from the above (or eliminate them)
84
(in-theory (disable integerp-sum-of-odds-over-2))
88
(defthm integerp-sum-of-odds-over-2-leading-constant
89
(implies (and (syntaxp (and (quotep x)
90
(integerp (* 2 x)) ;;these two hyps say x is of the form (odd)/2
95
(integerp (* 2 x)) ;;these two hyps say x is of the form (odd)/2
98
(not (integerp y)) ; (oddp (* 2 y)) ;rephrase the oddp hyps?
101
:hints (("Goal" :use integerp-sum-of-odds-over-2)))
103
;do we need all this stuff?
106
; (implies (integerp x)
107
; (or (evenp x) (oddp x)))
110
;should be a rewrite? - general rewrites for evenp/oddp of sum/diff?
112
; (implies (and (integerp x)
115
;:hints (("Goal" :use (:instance x-or-x/2 ))))
117
;(defthm odd/2-plus-1/2
118
; (implies (and (integerp x)
120
; (integerp (+ 1/2 (/ x 2))))
121
;:hints (("Goal" :use (:instance odd-+-1))))
123
;hack, don't leave enabled ;rewrite?
124
;(defthm integerp-next
125
; (implies (and (rationalp x)
126
; (integerp (+ x 1)))
129
;(defthm odd/2-minus-1/2
130
; (implies (and (integerp x)
132
; (integerp (+ -1/2 (/ x 2))))
133
;:hints (("Goal" :use (:instance odd/2-plus-1/2))))
135
;(in-theory (disable integerp-next))
137
;(defthm odd/2-minus-1/2-alt
138
; (implies (and (integerp x)
140
; (integerp (+ -1/2 (* 1/2 x))))
141
; :hints (("Goal" :in-theory (disable odd/2-minus-1/2)
142
; :use (:instance odd/2-minus-1/2))))
144
;floor of odd/2 is odd/2 -1/2
147
;; :hints (("Goal" :use ( (:instance fl-unique
149
; (n (- (* 1/2 x) 1/2)))))))
154
(defthm even-and-odd-alternate-eric
155
(implies (and (rationalp x)
157
(equal (integerp (+ 1/2 x))
158
(not (integerp x)))))
161
;should this go in type.lisp?
162
;needed? ;lets change any leading constant of -1/2 to 1/2 and elim this rule
163
(defthm even-and-odd-alternate-3
164
(implies (and (integerp x))
165
(equal (integerp (+ -1/2 (* -1/2 x)))
166
(not (integerp (* 1/2 x)))))
167
:hints (("Goal" :in-theory (disable integerp-minus)
168
:use (:instance integerp-minus (x (+ -1/2 (* -1/2 x)))))))
170
#| never finished this
171
(defthm integerp-+-odd-over-2-reduce
172
(implies (and (rationalp x)
173
(integerp (* 2 x)) ;these two hyps say x is of the form (odd)/2
176
(implies (integerp (+ x y))
177
(and (integerp (* 2 y)) ;these two hyps say x is of the form (odd)/2
178
(not (integerp y))))) ;
180
:hints (("Goal" :use integerp-sum-of-odds-over-2)))
186
(defthm even-and-odd-alternate-eric-2-bk
187
(implies (rationalp x)
188
(implies (and (integerp (* 2 x))
190
(integerp (+ 1/2 x)))))
192
;if s is even, then s-1 is odd
194
(implies (and (rationalp x)
195
(integerp (* 1/2 x)))
196
(and (integerp (- x 1))
197
(not (integerp (* 1/2 (- x 1))))))
198
:hints (("Goal" :in-theory (enable even-int-implies-int)))
202
(defthm even-and-odd-alternate-eric-2-fw
203
(implies (rationalp x)
204
(implies (integerp (+ 1/2 x))
205
(and (integerp (* 2 x))
206
(not (integerp x)))))
208
:in-theory (disable even-odd-5)
209
:use (:instance even-odd-5 (x (+ 1 (* 2 x)))))))
212
;replace the 1/2 rules above and similarly generalize the rules at the top to be equal rules
213
(defthm even-and-odd-alternate-eric-2
214
(implies (rationalp x)
215
(equal (integerp (+ 1/2 x))
216
(and (integerp (* 2 x))
217
(not (integerp x))))))
219
(in-theory (disable even-and-odd-alternate-eric-2-fw even-and-odd-alternate-eric-2-bk))