src/HOL/Integ/Bin.ML
changeset 6997 1833bdd83ebf
parent 6989 dd3e8bd86cc6
child 7008 6def5ce146e2
equal deleted inserted replaced
6996:1a28d968c5aa 6997:1833bdd83ebf
   276 qed "zless_add1_eq";
   276 qed "zless_add1_eq";
   277 
   277 
   278 Goal "(w + (#1::int) <= z) = (w<z)";
   278 Goal "(w + (#1::int) <= z) = (w<z)";
   279 by (simp_tac (simpset() addsimps [add_int_Suc_zle_eq]) 1);
   279 by (simp_tac (simpset() addsimps [add_int_Suc_zle_eq]) 1);
   280 qed "add1_zle_eq";
   280 qed "add1_zle_eq";
   281 Addsimps [add1_zle_eq];
   281 
       
   282 Goal "((#1::int) + w <= z) = (w<z)";
       
   283 by (stac zadd_commute 1);
       
   284 by (rtac add1_zle_eq 1);
       
   285 qed "add1_left_zle_eq";
   282 
   286 
   283 Goal "neg x = (x < #0)";
   287 Goal "neg x = (x < #0)";
   284 by (simp_tac (simpset() addsimps [neg_eq_less_int0]) 1); 
   288 by (simp_tac (simpset() addsimps [neg_eq_less_int0]) 1); 
   285 qed "neg_eq_less_0"; 
   289 qed "neg_eq_less_0"; 
   286 
   290 
   319 (** Simplification rules for comparison of binary numbers (Norbert Voelker) **)
   323 (** Simplification rules for comparison of binary numbers (Norbert Voelker) **)
   320 
   324 
   321 (** Equals (=) **)
   325 (** Equals (=) **)
   322 
   326 
   323 Goalw [iszero_def]
   327 Goalw [iszero_def]
   324   "((number_of x::int) = number_of y) = iszero(number_of (bin_add x (bin_minus y)))"; 
   328   "((number_of x::int) = number_of y) = \
       
   329 \  iszero (number_of (bin_add x (bin_minus y)))"; 
   325 by (simp_tac (simpset() addsimps
   330 by (simp_tac (simpset() addsimps
   326               (zcompare_rls @ [number_of_add, number_of_minus])) 1); 
   331               (zcompare_rls @ [number_of_add, number_of_minus])) 1); 
   327 qed "eq_number_of_eq"; 
   332 qed "eq_number_of_eq"; 
   328 
   333 
   329 Goalw [iszero_def] "iszero ((number_of Pls)::int)"; 
   334 Goalw [iszero_def] "iszero ((number_of Pls)::int)"; 
   425      le_number_of_eq_not_less];
   430      le_number_of_eq_not_less];
   426 
   431 
   427 Addsimps bin_arith_extra_simps;
   432 Addsimps bin_arith_extra_simps;
   428 Addsimps bin_rel_simps;
   433 Addsimps bin_rel_simps;
   429 
   434 
       
   435 
       
   436 (** Constant folding inside parentheses **)
       
   437 
       
   438 Goal "number_of v + (number_of w + c) = number_of(bin_add v w) + (c::int)";
       
   439 by (stac (zadd_assoc RS sym) 1);
       
   440 by (stac number_of_add 1);
       
   441 by Auto_tac;
       
   442 qed "nested_number_of_add";
       
   443 
       
   444 Goalw [zdiff_def]
       
   445     "number_of v + (number_of w - c) = number_of(bin_add v w) - (c::int)";
       
   446 by (rtac nested_number_of_add 1);
       
   447 qed "nested_diff1_number_of_add";
       
   448 
       
   449 Goal "number_of v + (c - number_of w) = \
       
   450 \    number_of (bin_add v (bin_minus w)) + (c::int)";
       
   451 by (stac (diff_number_of_eq RS sym) 1);
       
   452 by Auto_tac;
       
   453 qed "nested_diff2_number_of_add";
       
   454 
       
   455 Goal "number_of v * (number_of w * c) = number_of(bin_mult v w) * (c::int)";
       
   456 by (stac (zmult_assoc RS sym) 1);
       
   457 by (stac number_of_mult 1);
       
   458 by Auto_tac;
       
   459 qed "nested_number_of_mult";
       
   460 Addsimps [nested_number_of_add, nested_diff1_number_of_add,
       
   461 	  nested_diff2_number_of_add, nested_number_of_mult]; 
       
   462 
       
   463 
       
   464 
   430 (*---------------------------------------------------------------------------*)
   465 (*---------------------------------------------------------------------------*)
   431 (* Linear arithmetic                                                         *)
   466 (* Linear arithmetic                                                         *)
   432 (*---------------------------------------------------------------------------*)
   467 (*---------------------------------------------------------------------------*)
   433 
   468 
   434 (*
   469 (*