276 by (dres_inst_tac [("x","0")] spec 1); |
276 by (dres_inst_tac [("x","0")] spec 1); |
277 by (auto_tac(claset(), |
277 by (auto_tac(claset(), |
278 simpset() addsimps [nat_into_Ord RS Ord_0_lt_iff RS iff_sym])); |
278 simpset() addsimps [nat_into_Ord RS Ord_0_lt_iff RS iff_sym])); |
279 qed "not_znegative_imp_zero"; |
279 qed "not_znegative_imp_zero"; |
280 |
280 |
|
281 (**** nat_of: coercion of an integer to a natural number ****) |
|
282 |
|
283 Goalw [nat_of_def] "nat_of(intify(z)) = nat_of(z)"; |
|
284 by Auto_tac; |
|
285 qed "nat_of_intify"; |
|
286 Addsimps [nat_of_intify]; |
|
287 |
|
288 Goalw [nat_of_def, raw_nat_of_def] "nat_of($# n) = natify(n)"; |
|
289 by (auto_tac (claset(), simpset() addsimps [int_of_eq])); |
|
290 qed "nat_of_int_of"; |
|
291 Addsimps [nat_of_int_of]; |
|
292 |
|
293 Goalw [raw_nat_of_def] "raw_nat_of(z) : nat"; |
|
294 by Auto_tac; |
|
295 by (case_tac "EX! m. m: nat & z = int_of(m)" 1); |
|
296 by (asm_simp_tac (simpset() addsimps [the_0]) 2); |
|
297 by (rtac theI2 1); |
|
298 by Auto_tac; |
|
299 qed "raw_nat_of_type"; |
|
300 |
|
301 Goalw [nat_of_def] "nat_of(z) : nat"; |
|
302 by (simp_tac (simpset() addsimps [raw_nat_of_type]) 1); |
|
303 qed "nat_of_type"; |
|
304 AddIffs [nat_of_type]; |
|
305 AddTCs [nat_of_type]; |
|
306 |
281 (**** zmagnitude: magnitide of an integer, as a natural number ****) |
307 (**** zmagnitude: magnitide of an integer, as a natural number ****) |
282 |
308 |
283 Goalw [zmagnitude_def] "zmagnitude($# n) = natify(n)"; |
309 Goalw [zmagnitude_def] "zmagnitude($# n) = natify(n)"; |
284 by (auto_tac (claset(), simpset() addsimps [int_of_eq])); |
310 by (auto_tac (claset(), simpset() addsimps [int_of_eq])); |
285 qed "zmagnitude_int_of"; |
311 qed "zmagnitude_int_of"; |
341 Goal "z : int ==> EX n: nat. z = $# n | z = $- ($# succ(n))"; |
367 Goal "z : int ==> EX n: nat. z = $# n | z = $- ($# succ(n))"; |
342 by (case_tac "znegative(z)" 1); |
368 by (case_tac "znegative(z)" 1); |
343 by (blast_tac (claset() addDs [not_zneg_mag, sym]) 2); |
369 by (blast_tac (claset() addDs [not_zneg_mag, sym]) 2); |
344 by (blast_tac (claset() addDs [zneg_int_of]) 1); |
370 by (blast_tac (claset() addDs [zneg_int_of]) 1); |
345 qed "int_cases"; |
371 qed "int_cases"; |
|
372 |
|
373 Goal "[| ~ znegative(z); z: int |] ==> $# (raw_nat_of(z)) = z"; |
|
374 by (dtac not_zneg_int_of 1); |
|
375 by (auto_tac (claset(), simpset() addsimps [raw_nat_of_type])); |
|
376 by (auto_tac (claset(), simpset() addsimps [raw_nat_of_def])); |
|
377 qed "not_zneg_raw_nat_of"; |
|
378 |
|
379 Goal "~ znegative(intify(z)) ==> $# (nat_of(z)) = intify(z)"; |
|
380 by (asm_simp_tac (simpset() addsimps [nat_of_def, not_zneg_raw_nat_of]) 1); |
|
381 qed "not_zneg_nat_of_intify"; |
|
382 |
|
383 Goal "[| ~ znegative(z); z: int |] ==> $# (nat_of(z)) = z"; |
|
384 by (asm_simp_tac (simpset() addsimps [not_zneg_nat_of_intify]) 1); |
|
385 qed "not_zneg_nat_of"; |
|
386 |
|
387 Goalw [nat_of_def, raw_nat_of_def] "znegative(intify(z)) ==> nat_of(z) = 0"; |
|
388 by Auto_tac; |
|
389 qed "zneg_nat_of"; |
|
390 Addsimps [zneg_nat_of]; |
346 |
391 |
347 |
392 |
348 (**** zadd: addition on int ****) |
393 (**** zadd: addition on int ****) |
349 |
394 |
350 (** Congruence property for addition **) |
395 (** Congruence property for addition **) |
736 by (rename_tac "n" 1); |
781 by (rename_tac "n" 1); |
737 by (cut_inst_tac [("w","w"),("n","n")] zless_succ_zadd 1); |
782 by (cut_inst_tac [("w","w"),("n","n")] zless_succ_zadd 1); |
738 by Auto_tac; |
783 by Auto_tac; |
739 qed "zless_iff_succ_zadd"; |
784 qed "zless_iff_succ_zadd"; |
740 |
785 |
|
786 Goal "[| m: nat; n: nat |] ==> ($#m $< $#n) <-> (m<n)"; |
|
787 by (asm_simp_tac (simpset() addsimps [less_iff_succ_add, zless_iff_succ_zadd, |
|
788 int_of_add RS sym]) 1); |
|
789 by (blast_tac (claset() addIs [sym]) 1); |
|
790 qed "zless_int_of"; |
|
791 Addsimps [zless_int_of]; |
|
792 |
741 Goalw [zless_def, znegative_def, zdiff_def, int_def] |
793 Goalw [zless_def, znegative_def, zdiff_def, int_def] |
742 "[| x $< y; y $< z; x: int; y : int; z: int |] ==> x $< z"; |
794 "[| x $< y; y $< z; x: int; y : int; z: int |] ==> x $< z"; |
743 by (auto_tac (claset(), |
795 by (auto_tac (claset(), simpset() addsimps [zadd, zminus, image_iff])); |
744 simpset() addsimps [zadd, zminus, int_of_def, image_iff])); |
|
745 by (rename_tac "x1 x2 y1 y2" 1); |
796 by (rename_tac "x1 x2 y1 y2" 1); |
746 by (res_inst_tac [("x","x1#+x2")] exI 1); |
797 by (res_inst_tac [("x","x1#+x2")] exI 1); |
747 by (res_inst_tac [("x","y1#+y2")] exI 1); |
798 by (res_inst_tac [("x","y1#+y2")] exI 1); |
748 by (auto_tac (claset(), simpset() addsimps [add_lt_mono])); |
799 by (auto_tac (claset(), simpset() addsimps [add_lt_mono])); |
749 by (rtac sym 1); |
800 by (rtac sym 1); |