src/HOL/Divides.thy
changeset 48561 12aa0cb2b447
parent 47268 262d96552e50
child 48891 c0eafbd55de3
     1.1 --- a/src/HOL/Divides.thy	Fri Jul 27 17:59:18 2012 +0200
     1.2 +++ b/src/HOL/Divides.thy	Fri Jul 27 19:27:21 2012 +0200
     1.3 @@ -693,8 +693,20 @@
     1.4    val div_name = @{const_name div};
     1.5    val mod_name = @{const_name mod};
     1.6    val mk_binop = HOLogic.mk_binop;
     1.7 -  val mk_sum = Nat_Arith.mk_sum;
     1.8 -  val dest_sum = Nat_Arith.dest_sum;
     1.9 +  val mk_plus = HOLogic.mk_binop @{const_name Groups.plus};
    1.10 +  val dest_plus = HOLogic.dest_bin @{const_name Groups.plus} HOLogic.natT;
    1.11 +  fun mk_sum [] = HOLogic.zero
    1.12 +    | mk_sum [t] = t
    1.13 +    | mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
    1.14 +  fun dest_sum tm =
    1.15 +    if HOLogic.is_zero tm then []
    1.16 +    else
    1.17 +      (case try HOLogic.dest_Suc tm of
    1.18 +        SOME t => HOLogic.Suc_zero :: dest_sum t
    1.19 +      | NONE =>
    1.20 +          (case try dest_plus tm of
    1.21 +            SOME (t, u) => dest_sum t @ dest_sum u
    1.22 +          | NONE => [tm]));
    1.23  
    1.24    val div_mod_eqs = map mk_meta_eq [@{thm div_mod_equality}, @{thm div_mod_equality2}];
    1.25