author | paulson |
Thu, 04 Dec 2003 10:29:17 +0100 | |
changeset 14272 | 5efbb548107d |
parent 14271 | 8ed6989228bb |
child 14273 | e33ffff0123c |
permissions | -rw-r--r-- |
13577 | 1 |
(* Title: Integ/Int.thy |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1998 University of Cambridge |
|
5 |
*) |
|
6 |
||
14271 | 7 |
header {*Type "int" is an Ordered Ring and Other Lemmas*} |
14264 | 8 |
|
9 |
theory Int = IntDef: |
|
13577 | 10 |
|
11 |
constdefs |
|
14264 | 12 |
nat :: "int => nat" |
13 |
"nat(Z) == if neg Z then 0 else (THE m. Z = int m)" |
|
13577 | 14 |
|
15 |
defs (overloaded) |
|
14264 | 16 |
zabs_def: "abs(i::int) == if i < 0 then -i else i" |
17 |
||
18 |
||
19 |
lemma int_0 [simp]: "int 0 = (0::int)" |
|
20 |
by (simp add: Zero_int_def) |
|
21 |
||
22 |
lemma int_1 [simp]: "int 1 = 1" |
|
23 |
by (simp add: One_int_def) |
|
24 |
||
25 |
lemma int_Suc0_eq_1: "int (Suc 0) = 1" |
|
26 |
by (simp add: One_int_def One_nat_def) |
|
27 |
||
28 |
lemma neg_eq_less_0: "neg x = (x < 0)" |
|
29 |
by (unfold zdiff_def zless_def, auto) |
|
30 |
||
14266 | 31 |
lemma not_neg_eq_ge_0: "(~neg x) = (0 \<le> x)" |
14264 | 32 |
apply (unfold zle_def) |
33 |
apply (simp add: neg_eq_less_0) |
|
34 |
done |
|
35 |
||
36 |
subsection{*To simplify inequalities when Numeral1 can get simplified to 1*} |
|
37 |
||
38 |
lemma not_neg_0: "~ neg 0" |
|
39 |
by (simp add: One_int_def neg_eq_less_0) |
|
40 |
||
41 |
lemma not_neg_1: "~ neg 1" |
|
42 |
by (simp add: One_int_def neg_eq_less_0) |
|
43 |
||
44 |
lemma iszero_0: "iszero 0" |
|
45 |
by (simp add: iszero_def) |
|
46 |
||
47 |
lemma not_iszero_1: "~ iszero 1" |
|
48 |
by (simp only: Zero_int_def One_int_def One_nat_def iszero_def int_int_eq) |
|
49 |
||
50 |
lemma int_0_less_1: "0 < (1::int)" |
|
51 |
by (simp only: Zero_int_def One_int_def One_nat_def zless_int) |
|
52 |
||
53 |
lemma int_0_neq_1 [simp]: "0 \<noteq> (1::int)" |
|
54 |
by (simp only: Zero_int_def One_int_def One_nat_def int_int_eq) |
|
55 |
||
56 |
||
14271 | 57 |
subsection{*Comparison laws*} |
14264 | 58 |
|
14272
5efbb548107d
Tidying of the integer development; towards removing the
paulson
parents:
14271
diff
changeset
|
59 |
(*RING AND FIELD????????????????????????????????????????????????????????????*) |
14264 | 60 |
|
61 |
lemma zminus_zless_zminus [simp]: "(- x < - y) = (y < (x::int))" |
|
62 |
by (simp add: zless_def zdiff_def zadd_ac) |
|
63 |
||
14266 | 64 |
lemma zminus_zle_zminus [simp]: "(- x \<le> - y) = (y \<le> (x::int))" |
14264 | 65 |
by (simp add: zle_def) |
66 |
||
67 |
text{*The next several equations can make the simplifier loop!*} |
|
68 |
||
69 |
lemma zless_zminus: "(x < - y) = (y < - (x::int))" |
|
70 |
by (simp add: zless_def zdiff_def zadd_ac) |
|
71 |
||
72 |
lemma zminus_zless: "(- x < y) = (- y < (x::int))" |
|
73 |
by (simp add: zless_def zdiff_def zadd_ac) |
|
74 |
||
14266 | 75 |
lemma zle_zminus: "(x \<le> - y) = (y \<le> - (x::int))" |
14264 | 76 |
by (simp add: zle_def zminus_zless) |
77 |
||
14266 | 78 |
lemma zminus_zle: "(- x \<le> y) = (- y \<le> (x::int))" |
14264 | 79 |
by (simp add: zle_def zless_zminus) |
80 |
||
81 |
lemma equation_zminus: "(x = - y) = (y = - (x::int))" |
|
82 |
by auto |
|
83 |
||
84 |
lemma zminus_equation: "(- x = y) = (- (y::int) = x)" |
|
85 |
by auto |
|
86 |
||
87 |
||
14271 | 88 |
subsection{*nat: magnitide of an integer, as a natural number*} |
89 |
||
90 |
lemma nat_int [simp]: "nat(int n) = n" |
|
91 |
by (unfold nat_def, auto) |
|
92 |
||
93 |
lemma nat_zminus_int [simp]: "nat(- (int n)) = 0" |
|
94 |
apply (unfold nat_def) |
|
95 |
apply (auto simp add: neg_eq_less_0 zero_reorient zminus_zless) |
|
96 |
done |
|
97 |
||
98 |
lemma nat_zero [simp]: "nat 0 = 0" |
|
99 |
apply (unfold Zero_int_def) |
|
100 |
apply (rule nat_int) |
|
101 |
done |
|
102 |
||
103 |
lemma not_neg_nat: "~ neg z ==> int (nat z) = z" |
|
104 |
apply (drule not_neg_eq_ge_0 [THEN iffD1]) |
|
105 |
apply (drule zle_imp_zless_or_eq) |
|
106 |
apply (auto simp add: zless_iff_Suc_zadd) |
|
107 |
done |
|
108 |
||
109 |
lemma neg_nat: "neg z ==> nat z = 0" |
|
110 |
by (unfold nat_def, auto) |
|
111 |
||
112 |
lemma zless_nat_eq_int_zless: "(m < nat z) = (int m < z)" |
|
113 |
apply (case_tac "neg z") |
|
114 |
apply (erule_tac [2] not_neg_nat [THEN subst]) |
|
115 |
apply (auto simp add: neg_nat) |
|
116 |
apply (auto dest: order_less_trans simp add: neg_eq_less_0) |
|
117 |
done |
|
118 |
||
119 |
lemma nat_0_le [simp]: "0 \<le> z ==> int (nat z) = z" |
|
120 |
by (simp add: neg_eq_less_0 zle_def not_neg_nat) |
|
121 |
||
122 |
lemma nat_le_0 [simp]: "z \<le> 0 ==> nat z = 0" |
|
123 |
by (auto simp add: order_le_less neg_eq_less_0 zle_def neg_nat) |
|
124 |
||
125 |
(*An alternative condition is 0 \<le> w *) |
|
126 |
lemma nat_mono_iff: "0 < z ==> (nat w < nat z) = (w < z)" |
|
127 |
apply (subst zless_int [symmetric]) |
|
128 |
apply (simp (no_asm_simp) add: not_neg_nat not_neg_eq_ge_0 order_le_less) |
|
129 |
apply (case_tac "neg w") |
|
130 |
apply (simp add: neg_eq_less_0 neg_nat) |
|
131 |
apply (blast intro: order_less_trans) |
|
132 |
apply (simp add: not_neg_nat) |
|
133 |
done |
|
134 |
||
135 |
lemma zless_nat_conj: "(nat w < nat z) = (0 < z & w < z)" |
|
136 |
apply (case_tac "0 < z") |
|
137 |
apply (auto simp add: nat_mono_iff linorder_not_less) |
|
138 |
done |
|
139 |
||
140 |
||
141 |
subsection{*Monotonicity results*} |
|
142 |
||
143 |
(*RING AND FIELD?*) |
|
144 |
||
145 |
lemma zadd_right_cancel_zless [simp]: "(v+z < w+z) = (v < (w::int))" |
|
146 |
by (simp add: zless_def zdiff_def zadd_ac) |
|
147 |
||
148 |
lemma zadd_left_cancel_zless [simp]: "(z+v < z+w) = (v < (w::int))" |
|
149 |
by (simp add: zless_def zdiff_def zadd_ac) |
|
150 |
||
151 |
lemma zadd_right_cancel_zle [simp] : "(v+z \<le> w+z) = (v \<le> (w::int))" |
|
152 |
by (simp add: linorder_not_less [symmetric]) |
|
153 |
||
154 |
lemma zadd_left_cancel_zle [simp] : "(z+v \<le> z+w) = (v \<le> (w::int))" |
|
155 |
by (simp add: linorder_not_less [symmetric]) |
|
156 |
||
157 |
(*"v\<le>w ==> v+z \<le> w+z"*) |
|
158 |
lemmas zadd_zless_mono1 = zadd_right_cancel_zless [THEN iffD2, standard] |
|
159 |
||
160 |
(*"v\<le>w ==> z+v \<le> z+w"*) |
|
161 |
lemmas zadd_zless_mono2 = zadd_left_cancel_zless [THEN iffD2, standard] |
|
162 |
||
163 |
(*"v\<le>w ==> v+z \<le> w+z"*) |
|
164 |
lemmas zadd_zle_mono1 = zadd_right_cancel_zle [THEN iffD2, standard] |
|
165 |
||
166 |
(*"v\<le>w ==> z+v \<le> z+w"*) |
|
167 |
lemmas zadd_zle_mono2 = zadd_left_cancel_zle [THEN iffD2, standard] |
|
168 |
||
169 |
lemma zadd_zle_mono: "[| w'\<le>w; z'\<le>z |] ==> w' + z' \<le> w + (z::int)" |
|
170 |
by (erule zadd_zle_mono1 [THEN zle_trans], simp) |
|
171 |
||
172 |
lemma zadd_zless_mono: "[| w'<w; z'\<le>z |] ==> w' + z' < w + (z::int)" |
|
173 |
by (erule zadd_zless_mono1 [THEN order_less_le_trans], simp) |
|
174 |
||
175 |
||
176 |
subsection{*Strict Monotonicity of Multiplication*} |
|
177 |
||
178 |
text{*strict, in 1st argument; proof is by induction on k>0*} |
|
179 |
lemma zmult_zless_mono2_lemma: "i<j ==> 0<k --> int k * i < int k * j" |
|
180 |
apply (induct_tac "k", simp) |
|
181 |
apply (simp add: int_Suc) |
|
182 |
apply (case_tac "n=0") |
|
183 |
apply (simp_all add: zadd_zmult_distrib int_Suc0_eq_1 order_le_less) |
|
184 |
apply (simp_all add: zadd_zmult_distrib zadd_zless_mono int_Suc0_eq_1 order_le_less) |
|
185 |
done |
|
186 |
||
187 |
lemma zmult_zless_mono2: "[| i<j; (0::int) < k |] ==> k*i < k*j" |
|
188 |
apply (rule_tac t = k in not_neg_nat [THEN subst]) |
|
189 |
apply (erule_tac [2] zmult_zless_mono2_lemma [THEN mp]) |
|
190 |
apply (simp add: not_neg_eq_ge_0 order_le_less) |
|
191 |
apply (frule conjI [THEN zless_nat_conj [THEN iffD2]], auto) |
|
192 |
done |
|
193 |
||
194 |
text{*The Integers Form an Ordered Ring*} |
|
195 |
instance int :: ordered_ring |
|
196 |
proof |
|
197 |
fix i j k :: int |
|
198 |
show "(i + j) + k = i + (j + k)" by (simp add: zadd_assoc) |
|
199 |
show "i + j = j + i" by (simp add: zadd_commute) |
|
200 |
show "0 + i = i" by simp |
|
201 |
show "- i + i = 0" by simp |
|
202 |
show "i - j = i + (-j)" by (simp add: zdiff_def) |
|
203 |
show "(i * j) * k = i * (j * k)" by (rule zmult_assoc) |
|
204 |
show "i * j = j * i" by (rule zmult_commute) |
|
205 |
show "1 * i = i" by simp |
|
206 |
show "(i + j) * k = i * k + j * k" by (simp add: int_distrib) |
|
207 |
show "0 \<noteq> (1::int)" by simp |
|
208 |
show "i \<le> j ==> k + i \<le> k + j" by simp |
|
209 |
show "i < j ==> 0 < k ==> k * i < k * j" by (simp add: zmult_zless_mono2) |
|
210 |
show "\<bar>i\<bar> = (if i < 0 then -i else i)" by (simp only: zabs_def) |
|
211 |
qed |
|
212 |
||
213 |
subsection{*Lemmas about the Function @{term int} and Orderings*} |
|
14264 | 214 |
|
215 |
lemma negative_zless_0: "- (int (Suc n)) < 0" |
|
216 |
by (simp add: zless_def) |
|
217 |
||
218 |
lemma negative_zless [iff]: "- (int (Suc n)) < int m" |
|
219 |
by (rule negative_zless_0 [THEN order_less_le_trans], simp) |
|
220 |
||
14266 | 221 |
lemma negative_zle_0: "- int n \<le> 0" |
14264 | 222 |
by (simp add: zminus_zle) |
223 |
||
14266 | 224 |
lemma negative_zle [iff]: "- int n \<le> int m" |
14264 | 225 |
by (simp add: zless_def zle_def zdiff_def zadd_int) |
226 |
||
14266 | 227 |
lemma not_zle_0_negative [simp]: "~(0 \<le> - (int (Suc n)))" |
14264 | 228 |
by (subst zle_zminus, simp) |
229 |
||
14266 | 230 |
lemma int_zle_neg: "(int n \<le> - int m) = (n = 0 & m = 0)" |
14264 | 231 |
apply safe |
232 |
apply (drule_tac [2] zle_zminus [THEN iffD1]) |
|
233 |
apply (auto dest: zle_trans [OF _ negative_zle_0]) |
|
234 |
done |
|
235 |
||
236 |
lemma not_int_zless_negative [simp]: "~(int n < - int m)" |
|
237 |
by (simp add: zle_def [symmetric]) |
|
238 |
||
239 |
lemma negative_eq_positive [simp]: "(- int n = int m) = (n = 0 & m = 0)" |
|
240 |
apply (rule iffI) |
|
241 |
apply (rule int_zle_neg [THEN iffD1]) |
|
242 |
apply (drule sym) |
|
243 |
apply (simp_all (no_asm_simp)) |
|
244 |
done |
|
13577 | 245 |
|
14266 | 246 |
lemma zle_iff_zadd: "(w \<le> z) = (EX n. z = w + int n)" |
14264 | 247 |
by (force intro: exI [of _ "0::nat"] |
248 |
intro!: not_sym [THEN not0_implies_Suc] |
|
249 |
simp add: zless_iff_Suc_zadd int_le_less) |
|
250 |
||
251 |
lemma abs_int_eq [simp]: "abs (int m) = int m" |
|
252 |
by (simp add: zabs_def) |
|
253 |
||
254 |
||
14271 | 255 |
subsection{*Misc Results*} |
14264 | 256 |
|
14271 | 257 |
lemma zless_eq_neg: "(w<z) = neg(w-z)" |
258 |
by (simp add: zless_def) |
|
14264 | 259 |
|
14271 | 260 |
lemma eq_eq_iszero: "(w=z) = iszero(w-z)" |
261 |
by (simp add: iszero_def diff_eq_eq) |
|
14264 | 262 |
|
14271 | 263 |
lemma zle_eq_not_neg: "(w\<le>z) = (~ neg(z-w))" |
264 |
by (simp add: zle_def zless_def) |
|
14264 | 265 |
|
14266 | 266 |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
267 |
subsection{*Monotonicity of Multiplication*} |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
268 |
|
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
269 |
lemma zmult_zle_mono1: "[| i \<le> j; (0::int) \<le> k |] ==> i*k \<le> j*k" |
14271 | 270 |
by (rule Ring_and_Field.mult_right_mono) |
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
271 |
|
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
272 |
lemma zmult_zle_mono1_neg: "[| i \<le> j; k \<le> (0::int) |] ==> j*k \<le> i*k" |
14271 | 273 |
by (rule Ring_and_Field.mult_right_mono_neg) |
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
274 |
|
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
275 |
lemma zmult_zle_mono2: "[| i \<le> j; (0::int) \<le> k |] ==> k*i \<le> k*j" |
14271 | 276 |
by (rule Ring_and_Field.mult_left_mono) |
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
277 |
|
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
278 |
lemma zmult_zle_mono2_neg: "[| i \<le> j; k \<le> (0::int) |] ==> k*j \<le> k*i" |
14271 | 279 |
by (rule Ring_and_Field.mult_left_mono_neg) |
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
280 |
|
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
281 |
(* \<le> monotonicity, BOTH arguments*) |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
282 |
lemma zmult_zle_mono: |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
283 |
"[| i \<le> j; k \<le> l; (0::int) \<le> j; (0::int) \<le> k |] ==> i*k \<le> j*l" |
14271 | 284 |
by (rule Ring_and_Field.mult_mono) |
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
285 |
|
14264 | 286 |
lemma zmult_zless_mono1: "[| i<j; (0::int) < k |] ==> i*k < j*k" |
14266 | 287 |
by (rule Ring_and_Field.mult_strict_right_mono) |
14264 | 288 |
|
289 |
lemma zmult_zless_mono1_neg: "[| i<j; k < (0::int) |] ==> j*k < i*k" |
|
14266 | 290 |
by (rule Ring_and_Field.mult_strict_right_mono_neg) |
14264 | 291 |
|
292 |
lemma zmult_zless_mono2_neg: "[| i<j; k < (0::int) |] ==> k*j < k*i" |
|
14266 | 293 |
by (rule Ring_and_Field.mult_strict_left_mono_neg) |
14264 | 294 |
|
295 |
lemma zmult_eq_0_iff [iff]: "(m*n = (0::int)) = (m = 0 | n = 0)" |
|
14266 | 296 |
by simp |
297 |
||
298 |
lemma zmult_zless_cancel2: "(m*k < n*k) = (((0::int) < k & m<n) | (k<0 & n<m))" |
|
299 |
by (rule Ring_and_Field.mult_less_cancel_right) |
|
300 |
||
301 |
lemma zmult_zless_cancel1: |
|
302 |
"(k*m < k*n) = (((0::int) < k & m<n) | (k < 0 & n<m))" |
|
303 |
by (rule Ring_and_Field.mult_less_cancel_left) |
|
304 |
||
305 |
lemma zmult_zle_cancel2: |
|
306 |
"(m*k \<le> n*k) = (((0::int) < k --> m\<le>n) & (k < 0 --> n\<le>m))" |
|
307 |
by (rule Ring_and_Field.mult_le_cancel_right) |
|
308 |
||
309 |
lemma zmult_zle_cancel1: |
|
310 |
"(k*m \<le> k*n) = (((0::int) < k --> m\<le>n) & (k < 0 --> n\<le>m))" |
|
311 |
by (rule Ring_and_Field.mult_le_cancel_left) |
|
312 |
||
313 |
lemma zmult_cancel2: "(m*k = n*k) = (k = (0::int) | m=n)" |
|
314 |
by (rule Ring_and_Field.mult_cancel_right) |
|
315 |
||
316 |
lemma zmult_cancel1 [simp]: "(k*m = k*n) = (k = (0::int) | m=n)" |
|
317 |
by (rule Ring_and_Field.mult_cancel_left) |
|
318 |
||
14271 | 319 |
|
320 |
subsection{*For the @{text abel_cancel} Simproc (DELETE)*} |
|
321 |
||
322 |
(* Lemmas needed for the simprocs *) |
|
323 |
||
324 |
(** The idea is to cancel like terms on opposite sides by subtraction **) |
|
325 |
||
326 |
lemma zless_eqI: "(x::int) - y = x' - y' ==> (x<y) = (x'<y')" |
|
327 |
by (simp add: zless_def) |
|
328 |
||
329 |
lemma zle_eqI: "(x::int) - y = x' - y' ==> (y<=x) = (y'<=x')" |
|
330 |
apply (drule zless_eqI) |
|
331 |
apply (simp (no_asm_simp) add: zle_def) |
|
332 |
done |
|
333 |
||
334 |
lemma zeq_eqI: "(x::int) - y = x' - y' ==> (x=y) = (x'=y')" |
|
335 |
apply safe |
|
336 |
apply (simp_all add: eq_diff_eq diff_eq_eq) |
|
337 |
done |
|
338 |
||
339 |
(*Deletion of other terms in the formula, seeking the -x at the front of z*) |
|
340 |
lemma zadd_cancel_21: "((x::int) + (y + z) = y + u) = ((x + z) = u)" |
|
341 |
apply (subst zadd_left_commute) |
|
342 |
apply (rule zadd_left_cancel) |
|
343 |
done |
|
344 |
||
345 |
(*A further rule to deal with the case that |
|
346 |
everything gets cancelled on the right.*) |
|
347 |
lemma zadd_cancel_end: "((x::int) + (y + z) = y) = (x = -z)" |
|
348 |
apply (subst zadd_left_commute) |
|
349 |
apply (rule_tac t = y in zadd_0_right [THEN subst], subst zadd_left_cancel) |
|
350 |
apply (simp add: eq_diff_eq [symmetric]) |
|
14264 | 351 |
done |
352 |
||
14271 | 353 |
(*Legacy ML bindings, but no longer the structure Int.*) |
354 |
ML |
|
355 |
{* |
|
356 |
val Int_thy = the_context () |
|
357 |
val zabs_def = thm "zabs_def" |
|
358 |
val nat_def = thm "nat_def" |
|
359 |
||
360 |
val zless_eqI = thm "zless_eqI"; |
|
361 |
val zle_eqI = thm "zle_eqI"; |
|
362 |
val zeq_eqI = thm "zeq_eqI"; |
|
363 |
||
364 |
val int_0 = thm "int_0"; |
|
365 |
val int_1 = thm "int_1"; |
|
366 |
val int_Suc0_eq_1 = thm "int_Suc0_eq_1"; |
|
367 |
val neg_eq_less_0 = thm "neg_eq_less_0"; |
|
368 |
val not_neg_eq_ge_0 = thm "not_neg_eq_ge_0"; |
|
369 |
val not_neg_0 = thm "not_neg_0"; |
|
370 |
val not_neg_1 = thm "not_neg_1"; |
|
371 |
val iszero_0 = thm "iszero_0"; |
|
372 |
val not_iszero_1 = thm "not_iszero_1"; |
|
373 |
val int_0_less_1 = thm "int_0_less_1"; |
|
374 |
val int_0_neq_1 = thm "int_0_neq_1"; |
|
375 |
val zadd_cancel_21 = thm "zadd_cancel_21"; |
|
376 |
val zadd_cancel_end = thm "zadd_cancel_end"; |
|
377 |
||
378 |
structure Int_Cancel_Data = |
|
379 |
struct |
|
380 |
val ss = HOL_ss |
|
381 |
val eq_reflection = eq_reflection |
|
382 |
||
383 |
val sg_ref = Sign.self_ref (Theory.sign_of (the_context())) |
|
384 |
val T = HOLogic.intT |
|
385 |
val zero = Const ("0", HOLogic.intT) |
|
386 |
val restrict_to_left = restrict_to_left |
|
387 |
val add_cancel_21 = zadd_cancel_21 |
|
388 |
val add_cancel_end = zadd_cancel_end |
|
389 |
val add_left_cancel = zadd_left_cancel |
|
390 |
val add_assoc = zadd_assoc |
|
391 |
val add_commute = zadd_commute |
|
392 |
val add_left_commute = zadd_left_commute |
|
393 |
val add_0 = zadd_0 |
|
394 |
val add_0_right = zadd_0_right |
|
395 |
||
396 |
val eq_diff_eq = eq_diff_eq |
|
397 |
val eqI_rules = [zless_eqI, zeq_eqI, zle_eqI] |
|
398 |
fun dest_eqI th = |
|
399 |
#1 (HOLogic.dest_bin "op =" HOLogic.boolT |
|
400 |
(HOLogic.dest_Trueprop (concl_of th))) |
|
401 |
||
402 |
val diff_def = zdiff_def |
|
403 |
val minus_add_distrib = zminus_zadd_distrib |
|
404 |
val minus_minus = zminus_zminus |
|
405 |
val minus_0 = zminus_0 |
|
406 |
val add_inverses = [zadd_zminus_inverse, zadd_zminus_inverse2] |
|
407 |
val cancel_simps = [zadd_zminus_cancel, zminus_zadd_cancel] |
|
408 |
end; |
|
409 |
||
410 |
structure Int_Cancel = Abel_Cancel (Int_Cancel_Data); |
|
411 |
*} |
|
412 |
||
413 |
||
414 |
text{*A case theorem distinguishing non-negative and negative int*} |
|
415 |
||
416 |
lemma negD: "neg x ==> EX n. x = - (int (Suc n))" |
|
417 |
by (auto simp add: neg_eq_less_0 zless_iff_Suc_zadd |
|
418 |
diff_eq_eq [symmetric] zdiff_def) |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
419 |
|
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
420 |
lemma int_cases: |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
421 |
"[|!! n. z = int n ==> P; !! n. z = - (int (Suc n)) ==> P |] ==> P" |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
422 |
apply (case_tac "neg z") |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
423 |
apply (fast dest!: negD) |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
424 |
apply (drule not_neg_nat [symmetric], auto) |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
425 |
done |
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
426 |
|
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
427 |
|
14264 | 428 |
ML |
429 |
{* |
|
430 |
val zless_eq_neg = thm "zless_eq_neg"; |
|
431 |
val eq_eq_iszero = thm "eq_eq_iszero"; |
|
432 |
val zle_eq_not_neg = thm "zle_eq_not_neg"; |
|
433 |
val zadd_right_cancel_zless = thm "zadd_right_cancel_zless"; |
|
434 |
val zadd_left_cancel_zless = thm "zadd_left_cancel_zless"; |
|
435 |
val zadd_right_cancel_zle = thm "zadd_right_cancel_zle"; |
|
436 |
val zadd_left_cancel_zle = thm "zadd_left_cancel_zle"; |
|
437 |
val zadd_zless_mono1 = thm "zadd_zless_mono1"; |
|
438 |
val zadd_zless_mono2 = thm "zadd_zless_mono2"; |
|
439 |
val zadd_zle_mono1 = thm "zadd_zle_mono1"; |
|
440 |
val zadd_zle_mono2 = thm "zadd_zle_mono2"; |
|
441 |
val zadd_zle_mono = thm "zadd_zle_mono"; |
|
442 |
val zadd_zless_mono = thm "zadd_zless_mono"; |
|
443 |
val zminus_zless_zminus = thm "zminus_zless_zminus"; |
|
444 |
val zminus_zle_zminus = thm "zminus_zle_zminus"; |
|
445 |
val zless_zminus = thm "zless_zminus"; |
|
446 |
val zminus_zless = thm "zminus_zless"; |
|
447 |
val zle_zminus = thm "zle_zminus"; |
|
448 |
val zminus_zle = thm "zminus_zle"; |
|
449 |
val equation_zminus = thm "equation_zminus"; |
|
450 |
val zminus_equation = thm "zminus_equation"; |
|
451 |
val negative_zless = thm "negative_zless"; |
|
452 |
val negative_zle = thm "negative_zle"; |
|
453 |
val not_zle_0_negative = thm "not_zle_0_negative"; |
|
454 |
val not_int_zless_negative = thm "not_int_zless_negative"; |
|
455 |
val negative_eq_positive = thm "negative_eq_positive"; |
|
456 |
val zle_iff_zadd = thm "zle_iff_zadd"; |
|
457 |
val abs_int_eq = thm "abs_int_eq"; |
|
458 |
val nat_int = thm "nat_int"; |
|
459 |
val nat_zminus_int = thm "nat_zminus_int"; |
|
460 |
val nat_zero = thm "nat_zero"; |
|
461 |
val not_neg_nat = thm "not_neg_nat"; |
|
462 |
val neg_nat = thm "neg_nat"; |
|
463 |
val zless_nat_eq_int_zless = thm "zless_nat_eq_int_zless"; |
|
464 |
val nat_0_le = thm "nat_0_le"; |
|
465 |
val nat_le_0 = thm "nat_le_0"; |
|
466 |
val zless_nat_conj = thm "zless_nat_conj"; |
|
467 |
val int_cases = thm "int_cases"; |
|
468 |
val zmult_zle_mono1 = thm "zmult_zle_mono1"; |
|
469 |
val zmult_zle_mono1_neg = thm "zmult_zle_mono1_neg"; |
|
470 |
val zmult_zle_mono2 = thm "zmult_zle_mono2"; |
|
471 |
val zmult_zle_mono2_neg = thm "zmult_zle_mono2_neg"; |
|
472 |
val zmult_zle_mono = thm "zmult_zle_mono"; |
|
473 |
val zmult_zless_mono2 = thm "zmult_zless_mono2"; |
|
474 |
val zmult_zless_mono1 = thm "zmult_zless_mono1"; |
|
475 |
val zmult_zless_mono1_neg = thm "zmult_zless_mono1_neg"; |
|
476 |
val zmult_zless_mono2_neg = thm "zmult_zless_mono2_neg"; |
|
477 |
val zmult_eq_0_iff = thm "zmult_eq_0_iff"; |
|
478 |
val zmult_zless_cancel2 = thm "zmult_zless_cancel2"; |
|
479 |
val zmult_zless_cancel1 = thm "zmult_zless_cancel1"; |
|
480 |
val zmult_zle_cancel2 = thm "zmult_zle_cancel2"; |
|
481 |
val zmult_zle_cancel1 = thm "zmult_zle_cancel1"; |
|
482 |
val zmult_cancel2 = thm "zmult_cancel2"; |
|
483 |
val zmult_cancel1 = thm "zmult_cancel1"; |
|
484 |
*} |
|
13577 | 485 |
|
486 |
end |