author | paulson |
Wed, 25 Nov 1998 15:54:41 +0100 | |
changeset 5971 | c5a7a7685826 |
parent 5779 | 5c74f003a68e |
child 6036 | 1512f4b7d2e8 |
permissions | -rw-r--r-- |
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
1 |
(* Title: HOL/Integ/Bin.ML |
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
2 |
Authors: Lawrence C Paulson, Cambridge University Computer Laboratory |
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
3 |
David Spelt, University of Twente |
1632 | 4 |
Copyright 1994 University of Cambridge |
5 |
Copyright 1996 University of Twente |
|
6 |
||
7 |
Arithmetic on binary integers. |
|
8 |
*) |
|
9 |
||
10 |
(** extra rules for bin_succ, bin_pred, bin_add, bin_mult **) |
|
11 |
||
5512 | 12 |
qed_goal "NCons_Pls_0" Bin.thy |
13 |
"NCons Pls False = Pls" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
14 |
(fn _ => [(Simp_tac 1)]); |
1632 | 15 |
|
5512 | 16 |
qed_goal "NCons_Pls_1" Bin.thy |
17 |
"NCons Pls True = Pls BIT True" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
18 |
(fn _ => [(Simp_tac 1)]); |
1632 | 19 |
|
5512 | 20 |
qed_goal "NCons_Min_0" Bin.thy |
21 |
"NCons Min False = Min BIT False" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
22 |
(fn _ => [(Simp_tac 1)]); |
1632 | 23 |
|
5512 | 24 |
qed_goal "NCons_Min_1" Bin.thy |
25 |
"NCons Min True = Min" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
26 |
(fn _ => [(Simp_tac 1)]); |
1632 | 27 |
|
5512 | 28 |
qed_goal "bin_succ_1" Bin.thy |
29 |
"bin_succ(w BIT True) = (bin_succ w) BIT False" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
30 |
(fn _ => [(Simp_tac 1)]); |
1632 | 31 |
|
5512 | 32 |
qed_goal "bin_succ_0" Bin.thy |
33 |
"bin_succ(w BIT False) = NCons w True" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
34 |
(fn _ => [(Simp_tac 1)]); |
1632 | 35 |
|
5512 | 36 |
qed_goal "bin_pred_1" Bin.thy |
37 |
"bin_pred(w BIT True) = NCons w False" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
38 |
(fn _ => [(Simp_tac 1)]); |
1632 | 39 |
|
5512 | 40 |
qed_goal "bin_pred_0" Bin.thy |
41 |
"bin_pred(w BIT False) = (bin_pred w) BIT True" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
42 |
(fn _ => [(Simp_tac 1)]); |
1632 | 43 |
|
5512 | 44 |
qed_goal "bin_minus_1" Bin.thy |
45 |
"bin_minus(w BIT True) = bin_pred (NCons (bin_minus w) False)" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
46 |
(fn _ => [(Simp_tac 1)]); |
1632 | 47 |
|
5512 | 48 |
qed_goal "bin_minus_0" Bin.thy |
49 |
"bin_minus(w BIT False) = (bin_minus w) BIT False" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
50 |
(fn _ => [(Simp_tac 1)]); |
1632 | 51 |
|
5491 | 52 |
|
1632 | 53 |
(*** bin_add: binary addition ***) |
54 |
||
5512 | 55 |
qed_goal "bin_add_BIT_11" Bin.thy |
56 |
"bin_add (v BIT True) (w BIT True) = \ |
|
57 |
\ NCons (bin_add v (bin_succ w)) False" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
58 |
(fn _ => [(Simp_tac 1)]); |
1632 | 59 |
|
5512 | 60 |
qed_goal "bin_add_BIT_10" Bin.thy |
61 |
"bin_add (v BIT True) (w BIT False) = NCons (bin_add v w) True" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
62 |
(fn _ => [(Simp_tac 1)]); |
1632 | 63 |
|
5512 | 64 |
qed_goal "bin_add_BIT_0" Bin.thy |
65 |
"bin_add (v BIT False) (w BIT y) = NCons (bin_add v w) y" |
|
5491 | 66 |
(fn _ => [Auto_tac]); |
1632 | 67 |
|
5551 | 68 |
Goal "bin_add w Pls = w"; |
69 |
by (induct_tac "w" 1); |
|
70 |
by Auto_tac; |
|
71 |
qed "bin_add_Pls_right"; |
|
1632 | 72 |
|
5512 | 73 |
qed_goal "bin_add_BIT_Min" Bin.thy |
74 |
"bin_add (v BIT x) Min = bin_pred (v BIT x)" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
75 |
(fn _ => [(Simp_tac 1)]); |
1632 | 76 |
|
5512 | 77 |
qed_goal "bin_add_BIT_BIT" Bin.thy |
78 |
"bin_add (v BIT x) (w BIT y) = \ |
|
79 |
\ NCons(bin_add v (if x & y then (bin_succ w) else w)) (x~= y)" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
80 |
(fn _ => [(Simp_tac 1)]); |
1632 | 81 |
|
82 |
||
83 |
(*** bin_add: binary multiplication ***) |
|
84 |
||
5512 | 85 |
qed_goal "bin_mult_1" Bin.thy |
86 |
"bin_mult (v BIT True) w = bin_add (NCons (bin_mult v w) False) w" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
87 |
(fn _ => [(Simp_tac 1)]); |
1632 | 88 |
|
5512 | 89 |
qed_goal "bin_mult_0" Bin.thy |
90 |
"bin_mult (v BIT False) w = NCons (bin_mult v w) False" |
|
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
91 |
(fn _ => [(Simp_tac 1)]); |
1632 | 92 |
|
93 |
||
94 |
(**** The carry/borrow functions, bin_succ and bin_pred ****) |
|
95 |
||
96 |
||
5491 | 97 |
(**** integ_of ****) |
1632 | 98 |
|
5512 | 99 |
qed_goal "integ_of_NCons" Bin.thy |
100 |
"integ_of(NCons w b) = integ_of(w BIT b)" |
|
5184 | 101 |
(fn _ =>[(induct_tac "w" 1), |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
102 |
(ALLGOALS Asm_simp_tac) ]); |
1632 | 103 |
|
5512 | 104 |
Addsimps [integ_of_NCons]; |
1632 | 105 |
|
5491 | 106 |
qed_goal "integ_of_succ" Bin.thy |
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
107 |
"integ_of(bin_succ w) = int 1 + integ_of w" |
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
108 |
(fn _ =>[(rtac bin.induct 1), |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
109 |
(ALLGOALS(asm_simp_tac (simpset() addsimps zadd_ac))) ]); |
5491 | 110 |
|
111 |
qed_goal "integ_of_pred" Bin.thy |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
112 |
"integ_of(bin_pred w) = - (int 1) + integ_of w" |
5491 | 113 |
(fn _ =>[(rtac bin.induct 1), |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
114 |
(ALLGOALS(asm_simp_tac (simpset() addsimps zadd_ac))) ]); |
1632 | 115 |
|
5491 | 116 |
Goal "integ_of(bin_minus w) = - (integ_of w)"; |
117 |
by (rtac bin.induct 1); |
|
118 |
by (Simp_tac 1); |
|
119 |
by (Simp_tac 1); |
|
120 |
by (asm_simp_tac (simpset() |
|
5551 | 121 |
delsimps [bin_pred_Pls, bin_pred_Min, bin_pred_BIT] |
5491 | 122 |
addsimps [integ_of_succ,integ_of_pred, |
123 |
zadd_assoc]) 1); |
|
124 |
qed "integ_of_minus"; |
|
1632 | 125 |
|
126 |
||
5512 | 127 |
val bin_add_simps = [bin_add_BIT_BIT, |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
128 |
integ_of_succ, integ_of_pred]; |
1632 | 129 |
|
5491 | 130 |
Goal "! w. integ_of(bin_add v w) = integ_of v + integ_of w"; |
5184 | 131 |
by (induct_tac "v" 1); |
4686 | 132 |
by (simp_tac (simpset() addsimps bin_add_simps) 1); |
133 |
by (simp_tac (simpset() addsimps bin_add_simps) 1); |
|
1632 | 134 |
by (rtac allI 1); |
5184 | 135 |
by (induct_tac "w" 1); |
5540 | 136 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps bin_add_simps @ zadd_ac))); |
5491 | 137 |
qed_spec_mp "integ_of_add"; |
1632 | 138 |
|
5779
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
139 |
|
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
140 |
(*Subtraction*) |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
141 |
Goalw [zdiff_def] |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
142 |
"integ_of v - integ_of w = integ_of(bin_add v (bin_minus w))"; |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
143 |
by (simp_tac (simpset() addsimps [integ_of_add, integ_of_minus]) 1); |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
144 |
qed "diff_integ_of_eq"; |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
145 |
|
5512 | 146 |
val bin_mult_simps = [zmult_zminus, integ_of_minus, integ_of_add]; |
1632 | 147 |
|
5491 | 148 |
Goal "integ_of(bin_mult v w) = integ_of v * integ_of w"; |
5184 | 149 |
by (induct_tac "v" 1); |
4686 | 150 |
by (simp_tac (simpset() addsimps bin_mult_simps) 1); |
151 |
by (simp_tac (simpset() addsimps bin_mult_simps) 1); |
|
5491 | 152 |
by (asm_simp_tac |
5540 | 153 |
(simpset() addsimps bin_mult_simps @ [zadd_zmult_distrib] @ zadd_ac) 1); |
5491 | 154 |
qed "integ_of_mult"; |
155 |
||
1632 | 156 |
|
5491 | 157 |
(** Simplification rules with integer constants **) |
158 |
||
159 |
Goal "#0 + z = z"; |
|
160 |
by (Simp_tac 1); |
|
161 |
qed "zadd_0"; |
|
162 |
||
163 |
Goal "z + #0 = z"; |
|
164 |
by (Simp_tac 1); |
|
165 |
qed "zadd_0_right"; |
|
166 |
||
5592 | 167 |
Addsimps [zadd_0, zadd_0_right]; |
168 |
||
169 |
||
170 |
(** Converting simple cases of (int n) to numerals **) |
|
5491 | 171 |
|
5592 | 172 |
(*int 0 = #0 *) |
173 |
bind_thm ("int_0", integ_of_Pls RS sym); |
|
5491 | 174 |
|
5592 | 175 |
Goal "int (Suc n) = #1 + int n"; |
176 |
by (simp_tac (simpset() addsimps [zadd_int]) 1); |
|
177 |
qed "int_Suc"; |
|
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
178 |
|
5592 | 179 |
val int_simps = [int_0, int_Suc]; |
5491 | 180 |
|
181 |
Goal "- (#0) = #0"; |
|
182 |
by (Simp_tac 1); |
|
183 |
qed "zminus_0"; |
|
184 |
||
185 |
Addsimps [zminus_0]; |
|
186 |
||
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
187 |
|
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
188 |
Goal "#0 - x = -x"; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
189 |
by (simp_tac (simpset() addsimps [zdiff_def]) 1); |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
190 |
qed "zdiff0"; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
191 |
|
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
192 |
Goal "x - #0 = x"; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
193 |
by (simp_tac (simpset() addsimps [zdiff_def]) 1); |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
194 |
qed "zdiff0_right"; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
195 |
|
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
196 |
Goal "x - x = #0"; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
197 |
by (simp_tac (simpset() addsimps [zdiff_def]) 1); |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
198 |
qed "zdiff_self"; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
199 |
|
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
200 |
Addsimps [zdiff0, zdiff0_right, zdiff_self]; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
201 |
|
5491 | 202 |
Goal "#0 * z = #0"; |
203 |
by (Simp_tac 1); |
|
204 |
qed "zmult_0"; |
|
205 |
||
206 |
Goal "#1 * z = z"; |
|
207 |
by (Simp_tac 1); |
|
208 |
qed "zmult_1"; |
|
209 |
||
210 |
Goal "#2 * z = z+z"; |
|
211 |
by (simp_tac (simpset() addsimps [zadd_zmult_distrib]) 1); |
|
212 |
qed "zmult_2"; |
|
213 |
||
214 |
Goal "z * #0 = #0"; |
|
215 |
by (Simp_tac 1); |
|
216 |
qed "zmult_0_right"; |
|
217 |
||
218 |
Goal "z * #1 = z"; |
|
219 |
by (Simp_tac 1); |
|
220 |
qed "zmult_1_right"; |
|
221 |
||
222 |
Goal "z * #2 = z+z"; |
|
223 |
by (simp_tac (simpset() addsimps [zadd_zmult_distrib2]) 1); |
|
224 |
qed "zmult_2_right"; |
|
225 |
||
226 |
Addsimps [zmult_0, zmult_0_right, |
|
227 |
zmult_1, zmult_1_right, |
|
228 |
zmult_2, zmult_2_right]; |
|
229 |
||
230 |
Goal "(w < z + #1) = (w<z | w=z)"; |
|
5592 | 231 |
by (simp_tac (simpset() addsimps [zless_add_int_Suc_eq]) 1); |
5491 | 232 |
qed "zless_add1_eq"; |
233 |
||
234 |
Goal "(w + #1 <= z) = (w<z)"; |
|
5592 | 235 |
by (simp_tac (simpset() addsimps [add_int_Suc_zle_eq]) 1); |
5491 | 236 |
qed "add1_zle_eq"; |
237 |
Addsimps [add1_zle_eq]; |
|
238 |
||
5540 | 239 |
Goal "neg x = (x < #0)"; |
240 |
by (simp_tac (simpset() addsimps [neg_eq_less_nat0]) 1); |
|
241 |
qed "neg_eq_less_0"; |
|
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
242 |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
243 |
Goal "(~neg x) = (int 0 <= x)"; |
5540 | 244 |
by (simp_tac (simpset() addsimps [not_neg_eq_ge_nat0]) 1); |
245 |
qed "not_neg_eq_ge_0"; |
|
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
246 |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
247 |
Goal "#0 <= int m"; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
248 |
by (Simp_tac 1); |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
249 |
qed "zero_zle_int"; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
250 |
AddIffs [zero_zle_int]; |
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
251 |
|
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
252 |
|
5747 | 253 |
(** Needed because (int 0) rewrites to #0. |
254 |
Can these be generalized without evaluating large numbers?**) |
|
255 |
||
256 |
Goal "~ (int k < #0)"; |
|
257 |
by (Simp_tac 1); |
|
258 |
qed "int_less_0_conv"; |
|
259 |
||
260 |
Goal "(int k <= #0) = (k=0)"; |
|
261 |
by (Simp_tac 1); |
|
262 |
qed "int_le_0_conv"; |
|
263 |
||
264 |
Goal "(int k = #0) = (k=0)"; |
|
265 |
by (Simp_tac 1); |
|
266 |
qed "int_eq_0_conv"; |
|
267 |
||
268 |
Goal "(#0 = int k) = (k=0)"; |
|
269 |
by Auto_tac; |
|
270 |
qed "int_eq_0_conv'"; |
|
271 |
||
272 |
Addsimps [int_less_0_conv, int_le_0_conv, int_eq_0_conv, int_eq_0_conv']; |
|
273 |
||
274 |
||
5491 | 275 |
(** Simplification rules for comparison of binary numbers (Norbert Voelker) **) |
276 |
||
277 |
(** Equals (=) **) |
|
1632 | 278 |
|
5491 | 279 |
Goalw [iszero_def] |
5779
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
280 |
"(integ_of x = integ_of y) = iszero(integ_of (bin_add x (bin_minus y)))"; |
5491 | 281 |
by (simp_tac (simpset() addsimps |
282 |
(zcompare_rls @ [integ_of_add, integ_of_minus])) 1); |
|
283 |
qed "eq_integ_of_eq"; |
|
284 |
||
5512 | 285 |
Goalw [iszero_def] "iszero (integ_of Pls)"; |
5491 | 286 |
by (Simp_tac 1); |
5512 | 287 |
qed "iszero_integ_of_Pls"; |
5491 | 288 |
|
5512 | 289 |
Goalw [iszero_def] "~ iszero(integ_of Min)"; |
5491 | 290 |
by (Simp_tac 1); |
5512 | 291 |
qed "nonzero_integ_of_Min"; |
5491 | 292 |
|
293 |
Goalw [iszero_def] |
|
5512 | 294 |
"iszero (integ_of (w BIT x)) = (~x & iszero (integ_of w))"; |
5491 | 295 |
by (Simp_tac 1); |
296 |
by (int_case_tac "integ_of w" 1); |
|
297 |
by (ALLGOALS (asm_simp_tac |
|
5540 | 298 |
(simpset() addsimps zcompare_rls @ |
299 |
[zminus_zadd_distrib RS sym, |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
300 |
zadd_int]))); |
5512 | 301 |
qed "iszero_integ_of_BIT"; |
5491 | 302 |
|
5779
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
303 |
Goal "iszero (integ_of (w BIT False)) = iszero (integ_of w)"; |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
304 |
by (simp_tac (HOL_ss addsimps [iszero_integ_of_BIT]) 1); |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
305 |
qed "iszero_integ_of_0"; |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
306 |
|
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
307 |
Goal "~ iszero (integ_of (w BIT True))"; |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
308 |
by (simp_tac (HOL_ss addsimps [iszero_integ_of_BIT]) 1); |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
309 |
qed "iszero_integ_of_1"; |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
310 |
|
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
311 |
|
5491 | 312 |
|
313 |
(** Less-than (<) **) |
|
314 |
||
315 |
Goalw [zless_def,zdiff_def] |
|
316 |
"integ_of x < integ_of y \ |
|
5540 | 317 |
\ = neg (integ_of (bin_add x (bin_minus y)))"; |
5491 | 318 |
by (simp_tac (simpset() addsimps bin_mult_simps) 1); |
5540 | 319 |
qed "less_integ_of_eq_neg"; |
5491 | 320 |
|
5540 | 321 |
Goal "~ neg (integ_of Pls)"; |
5491 | 322 |
by (Simp_tac 1); |
5512 | 323 |
qed "not_neg_integ_of_Pls"; |
5491 | 324 |
|
5540 | 325 |
Goal "neg (integ_of Min)"; |
5491 | 326 |
by (Simp_tac 1); |
5512 | 327 |
qed "neg_integ_of_Min"; |
5491 | 328 |
|
5540 | 329 |
Goal "neg (integ_of (w BIT x)) = neg (integ_of w)"; |
5491 | 330 |
by (Asm_simp_tac 1); |
331 |
by (int_case_tac "integ_of w" 1); |
|
332 |
by (ALLGOALS (asm_simp_tac |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
333 |
(simpset() addsimps [zadd_int, neg_eq_less_nat0, |
5540 | 334 |
symmetric zdiff_def] @ zcompare_rls))); |
5512 | 335 |
qed "neg_integ_of_BIT"; |
5491 | 336 |
|
337 |
||
338 |
(** Less-than-or-equals (<=) **) |
|
339 |
||
340 |
Goal "(integ_of x <= integ_of y) = (~ integ_of y < integ_of x)"; |
|
341 |
by (simp_tac (simpset() addsimps [zle_def]) 1); |
|
342 |
qed "le_integ_of_eq_not_less"; |
|
343 |
||
5540 | 344 |
(*Delete the original rewrites, with their clumsy conditional expressions*) |
5551 | 345 |
Delsimps [bin_succ_BIT, bin_pred_BIT, bin_minus_BIT, |
346 |
NCons_Pls, NCons_Min, bin_add_BIT, bin_mult_BIT]; |
|
5491 | 347 |
|
348 |
(*Hide the binary representation of integer constants*) |
|
5540 | 349 |
Delsimps [integ_of_Pls, integ_of_Min, integ_of_BIT]; |
5491 | 350 |
|
5779
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
351 |
(*simplification of arithmetic operations on integer constants*) |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
352 |
val bin_arith_extra_simps = |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
353 |
[integ_of_add RS sym, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
354 |
integ_of_minus RS sym, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
355 |
integ_of_mult RS sym, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
356 |
bin_succ_1, bin_succ_0, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
357 |
bin_pred_1, bin_pred_0, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
358 |
bin_minus_1, bin_minus_0, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
359 |
bin_add_Pls_right, bin_add_BIT_Min, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
360 |
bin_add_BIT_0, bin_add_BIT_10, bin_add_BIT_11, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
361 |
diff_integ_of_eq, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
362 |
bin_mult_1, bin_mult_0, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
363 |
NCons_Pls_0, NCons_Pls_1, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
364 |
NCons_Min_0, NCons_Min_1, NCons_BIT]; |
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
365 |
|
5779
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
366 |
(*For making a minimal simpset, one must include these default simprules |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
367 |
of Bin.thy. Also include simp_thms, or at least (~False)=True*) |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
368 |
val bin_arith_simps = |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
369 |
[bin_pred_Pls, bin_pred_Min, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
370 |
bin_succ_Pls, bin_succ_Min, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
371 |
bin_add_Pls, bin_add_Min, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
372 |
bin_minus_Pls, bin_minus_Min, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
373 |
bin_mult_Pls, bin_mult_Min] @ bin_arith_extra_simps; |
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
374 |
|
5779
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
375 |
(*Simplification of relational operations*) |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
376 |
val bin_rel_simps = |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
377 |
[eq_integ_of_eq, iszero_integ_of_Pls, nonzero_integ_of_Min, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
378 |
iszero_integ_of_0, iszero_integ_of_1, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
379 |
less_integ_of_eq_neg, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
380 |
not_neg_integ_of_Pls, neg_integ_of_Min, neg_integ_of_BIT, |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
381 |
le_integ_of_eq_not_less]; |
2224
4fc4b465be5b
New material from Norbert Voelker for efficient binary comparisons
paulson
parents:
1894
diff
changeset
|
382 |
|
5779
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
383 |
Addsimps bin_arith_extra_simps; |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
384 |
Addsimps bin_rel_simps; |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
385 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
386 |
|
5592 | 387 |
(** Simplification of arithmetic when nested to the right **) |
388 |
||
389 |
Goal "integ_of v + (integ_of w + z) = integ_of(bin_add v w) + z"; |
|
390 |
by (simp_tac (simpset() addsimps [zadd_assoc RS sym]) 1); |
|
391 |
qed "add_integ_of_left"; |
|
392 |
||
393 |
Goal "integ_of v * (integ_of w * z) = integ_of(bin_mult v w) * z"; |
|
394 |
by (simp_tac (simpset() addsimps [zmult_assoc RS sym]) 1); |
|
395 |
qed "mult_integ_of_left"; |
|
396 |
||
397 |
Addsimps [add_integ_of_left, mult_integ_of_left]; |
|
398 |
||
399 |
||
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
400 |
(** Simplification of inequalities involving numerical constants **) |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
401 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
402 |
Goal "(w <= z + #1) = (w<=z | w = z + #1)"; |
5540 | 403 |
by (simp_tac (simpset() addsimps [integ_le_less, zless_add1_eq]) 1); |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
404 |
qed "zle_add1_eq"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
405 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
406 |
Goal "(w <= z - #1) = (w<z)"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
407 |
by (simp_tac (simpset() addsimps zcompare_rls) 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
408 |
qed "zle_diff1_eq"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
409 |
Addsimps [zle_diff1_eq]; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
410 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
411 |
(*2nd premise can be proved automatically if v is a literal*) |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
412 |
Goal "[| w <= z; #0 <= v |] ==> w <= z + v"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
413 |
by (dtac zadd_zle_mono 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
414 |
by (assume_tac 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
415 |
by (Full_simp_tac 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
416 |
qed "zle_imp_zle_zadd"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
417 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
418 |
Goal "w <= z ==> w <= z + #1"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
419 |
by (asm_simp_tac (simpset() addsimps [zle_imp_zle_zadd]) 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
420 |
qed "zle_imp_zle_zadd1"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
421 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
422 |
(*2nd premise can be proved automatically if v is a literal*) |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
423 |
Goal "[| w < z; #0 <= v |] ==> w < z + v"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
424 |
by (dtac zadd_zless_mono 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
425 |
by (assume_tac 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
426 |
by (Full_simp_tac 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
427 |
qed "zless_imp_zless_zadd"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
428 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
429 |
Goal "w < z ==> w < z + #1"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
430 |
by (asm_simp_tac (simpset() addsimps [zless_imp_zless_zadd]) 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
431 |
qed "zless_imp_zless_zadd1"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
432 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
433 |
Goal "(w < z + #1) = (w<=z)"; |
5540 | 434 |
by (simp_tac (simpset() addsimps [zless_add1_eq, integ_le_less]) 1); |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
435 |
qed "zle_add1_eq_le"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
436 |
Addsimps [zle_add1_eq_le]; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
437 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
438 |
Goal "(z = z + w) = (w = #0)"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
439 |
by (rtac trans 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
440 |
by (rtac zadd_left_cancel 2); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
441 |
by (simp_tac (simpset() addsimps [eq_sym_conv]) 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
442 |
qed "zadd_left_cancel0"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
443 |
Addsimps [zadd_left_cancel0]; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
444 |
|
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
445 |
(*LOOPS as a simprule!*) |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
446 |
Goal "[| w + v < z; #0 <= v |] ==> w < z"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
447 |
by (dtac zadd_zless_mono 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
448 |
by (assume_tac 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
449 |
by (full_simp_tac (simpset() addsimps zadd_ac) 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
450 |
qed "zless_zadd_imp_zless"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
451 |
|
5540 | 452 |
(*LOOPS as a simprule! Analogous to Suc_lessD*) |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
453 |
Goal "w + #1 < z ==> w < z"; |
5540 | 454 |
by (dtac zless_zadd_imp_zless 1); |
455 |
by (assume_tac 2); |
|
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
456 |
by (Simp_tac 1); |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
457 |
qed "zless_zadd1_imp_zless"; |
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
458 |
|
5551 | 459 |
Goal "w + #-1 = w - #1"; |
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
460 |
by (Simp_tac 1); |
5551 | 461 |
qed "zplus_minus1_conv"; |
5510
ad120f7c52ad
improved (but still flawed) treatment of binary arithmetic
paulson
parents:
5491
diff
changeset
|
462 |
|
5551 | 463 |
|
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
464 |
(*** nat ***) |
5551 | 465 |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
466 |
Goal "#0 <= z ==> int (nat z) = z"; |
5551 | 467 |
by (asm_full_simp_tac |
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
468 |
(simpset() addsimps [neg_eq_less_0, zle_def, not_neg_nat]) 1); |
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
469 |
qed "nat_0_le"; |
5551 | 470 |
|
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
471 |
Goal "z < #0 ==> nat z = 0"; |
5551 | 472 |
by (asm_full_simp_tac |
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
473 |
(simpset() addsimps [neg_eq_less_0, zle_def, neg_nat]) 1); |
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
474 |
qed "nat_less_0"; |
5551 | 475 |
|
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
476 |
Addsimps [nat_0_le, nat_less_0]; |
5551 | 477 |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
478 |
Goal "#0 <= w ==> (nat w = m) = (w = int m)"; |
5551 | 479 |
by Auto_tac; |
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
480 |
qed "nat_eq_iff"; |
5551 | 481 |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
482 |
Goal "#0 <= w ==> (nat w < m) = (w < int m)"; |
5551 | 483 |
by (rtac iffI 1); |
484 |
by (asm_full_simp_tac |
|
5582
a356fb49e69e
many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents:
5562
diff
changeset
|
485 |
(simpset() delsimps [zless_int] addsimps [zless_int RS sym]) 2); |
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
486 |
by (etac (nat_0_le RS subst) 1); |
5551 | 487 |
by (Simp_tac 1); |
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
488 |
qed "nat_less_iff"; |
5551 | 489 |
|
5747 | 490 |
|
5779
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
491 |
(*Users don't want to see (int 0) or w + - z*) |
5c74f003a68e
Explicit (and improved) simprules for binary arithmetic.
paulson
parents:
5747
diff
changeset
|
492 |
Addsimps [int_0, symmetric zdiff_def]; |
5747 | 493 |
|
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
494 |
Goal "#0 <= w ==> (nat w < nat z) = (w<z)"; |
5551 | 495 |
by (case_tac "neg z" 1); |
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
496 |
by (auto_tac (claset(), simpset() addsimps [nat_less_iff])); |
5551 | 497 |
by (auto_tac (claset() addIs [zless_trans], |
5747 | 498 |
simpset() addsimps [neg_eq_less_0, zle_def])); |
5562
02261e6880d1
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5551
diff
changeset
|
499 |
qed "nat_less_eq_zless"; |
5747 | 500 |