src/HOL/Divides.thy
changeset 48561 12aa0cb2b447
parent 47268 262d96552e50
child 48891 c0eafbd55de3
equal deleted inserted replaced
48560:e0875d956a6b 48561:12aa0cb2b447
   691 structure Cancel_Div_Mod_Nat = Cancel_Div_Mod
   691 structure Cancel_Div_Mod_Nat = Cancel_Div_Mod
   692 (
   692 (
   693   val div_name = @{const_name div};
   693   val div_name = @{const_name div};
   694   val mod_name = @{const_name mod};
   694   val mod_name = @{const_name mod};
   695   val mk_binop = HOLogic.mk_binop;
   695   val mk_binop = HOLogic.mk_binop;
   696   val mk_sum = Nat_Arith.mk_sum;
   696   val mk_plus = HOLogic.mk_binop @{const_name Groups.plus};
   697   val dest_sum = Nat_Arith.dest_sum;
   697   val dest_plus = HOLogic.dest_bin @{const_name Groups.plus} HOLogic.natT;
       
   698   fun mk_sum [] = HOLogic.zero
       
   699     | mk_sum [t] = t
       
   700     | mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
       
   701   fun dest_sum tm =
       
   702     if HOLogic.is_zero tm then []
       
   703     else
       
   704       (case try HOLogic.dest_Suc tm of
       
   705         SOME t => HOLogic.Suc_zero :: dest_sum t
       
   706       | NONE =>
       
   707           (case try dest_plus tm of
       
   708             SOME (t, u) => dest_sum t @ dest_sum u
       
   709           | NONE => [tm]));
   698 
   710 
   699   val div_mod_eqs = map mk_meta_eq [@{thm div_mod_equality}, @{thm div_mod_equality2}];
   711   val div_mod_eqs = map mk_meta_eq [@{thm div_mod_equality}, @{thm div_mod_equality2}];
   700 
   712 
   701   val prove_eq_sums = Arith_Data.prove_conv2 all_tac (Arith_Data.simp_all_tac
   713   val prove_eq_sums = Arith_Data.prove_conv2 all_tac (Arith_Data.simp_all_tac
   702     (@{thm add_0_left} :: @{thm add_0_right} :: @{thms add_ac}))
   714     (@{thm add_0_left} :: @{thm add_0_right} :: @{thms add_ac}))