src/HOL/Divides.ML
author wenzelm
Thu, 17 Aug 2000 10:33:37 +0200
changeset 9619 6125cc9efc18
parent 9108 9fff97d29837
child 9637 47d39a31eb2f
permissions -rw-r--r--
fixed deps;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Divides.ML
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     2
    ID:         $Id$
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     5
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     6
The division operators div, mod and the divides relation "dvd"
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     7
*)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     8
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
     9
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    10
(** Less-then properties **)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    11
9108
9fff97d29837 bind_thm(s);
wenzelm
parents: 8935
diff changeset
    12
bind_thm ("wf_less_trans", [eq_reflection, wf_pred_nat RS wf_trancl] MRS 
9fff97d29837 bind_thm(s);
wenzelm
parents: 8935
diff changeset
    13
                    def_wfrec RS trans);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    14
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4811
diff changeset
    15
Goal "(%m. m mod n) = wfrec (trancl pred_nat) \
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    16
\                           (%f j. if j<n | n=0 then j else f (j-n))";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    17
by (simp_tac (simpset() addsimps [mod_def]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    18
qed "mod_eq";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    19
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    20
Goal "(%m. m div n) = wfrec (trancl pred_nat) \
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    21
\            (%f j. if j<n | n=0 then 0 else Suc (f (j-n)))";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    22
by (simp_tac (simpset() addsimps [div_def]) 1);
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    23
qed "div_eq";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    24
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    25
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    26
(** Aribtrary definitions for division by zero.  Useful to simplify 
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    27
    certain equations **)
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    28
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
    29
Goal "a div 0 = (0::nat)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    30
by (rtac (div_eq RS wf_less_trans) 1);
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    31
by (Asm_simp_tac 1);
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    32
qed "DIVISION_BY_ZERO_DIV";  (*NOT for adding to default simpset*)
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    33
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
    34
Goal "a mod 0 = (a::nat)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    35
by (rtac (mod_eq RS wf_less_trans) 1);
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    36
by (Asm_simp_tac 1);
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    37
qed "DIVISION_BY_ZERO_MOD";  (*NOT for adding to default simpset*)
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    38
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    39
fun div_undefined_case_tac s i =
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    40
  case_tac s i THEN 
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    41
  Full_simp_tac (i+1) THEN
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    42
  asm_simp_tac (simpset() addsimps [DIVISION_BY_ZERO_DIV, 
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    43
				    DIVISION_BY_ZERO_MOD]) i;
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    44
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    45
(*** Remainder ***)
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    46
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
    47
Goal "m<n ==> m mod n = (m::nat)";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    48
by (rtac (mod_eq RS wf_less_trans) 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    49
by (Asm_simp_tac 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    50
qed "mod_less";
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
    51
Addsimps [mod_less];
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    52
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    53
Goal "~ m < (n::nat) ==> m mod n = (m-n) mod n";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    54
by (div_undefined_case_tac "n=0" 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    55
by (rtac (mod_eq RS wf_less_trans) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    56
by (asm_simp_tac (simpset() addsimps [diff_less, cut_apply, less_eq]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    57
qed "mod_geq";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    58
5415
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
    59
(*Avoids the ugly ~m<n above*)
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    60
Goal "(n::nat) <= m ==> m mod n = (m-n) mod n";
5415
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
    61
by (asm_simp_tac (simpset() addsimps [mod_geq, not_less_iff_le]) 1);
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
    62
qed "le_mod_geq";
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
    63
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    64
Goal "m mod (n::nat) = (if m<n then m else (m-n) mod n)";
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
    65
by (asm_simp_tac (simpset() addsimps [mod_geq]) 1);
4774
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
    66
qed "mod_if";
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
    67
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
    68
Goal "m mod 1 = (0::nat)";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    69
by (induct_tac "m" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
    70
by (ALLGOALS (asm_simp_tac (simpset() addsimps [mod_geq])));
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    71
qed "mod_1";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    72
Addsimps [mod_1];
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    73
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
    74
Goal "n mod n = (0::nat)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    75
by (div_undefined_case_tac "n=0" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
    76
by (asm_simp_tac (simpset() addsimps [mod_geq]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    77
qed "mod_self";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    78
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    79
Goal "(m+n) mod n = m mod (n::nat)";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    80
by (subgoal_tac "(n + m) mod n = (n+m-n) mod n" 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
    81
by (stac (mod_geq RS sym) 2);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    82
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [add_commute])));
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
    83
qed "mod_add_self2";
4810
d55e2fee2084 New laws for mod
paulson
parents: 4774
diff changeset
    84
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    85
Goal "(n+m) mod n = m mod (n::nat)";
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
    86
by (asm_simp_tac (simpset() addsimps [add_commute, mod_add_self2]) 1);
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
    87
qed "mod_add_self1";
4810
d55e2fee2084 New laws for mod
paulson
parents: 4774
diff changeset
    88
8783
9edcc005ebd9 removed obsolete "evenness" proofs
paulson
parents: 8698
diff changeset
    89
Addsimps [mod_add_self1, mod_add_self2];
9edcc005ebd9 removed obsolete "evenness" proofs
paulson
parents: 8698
diff changeset
    90
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    91
Goal "(m + k*n) mod n = m mod (n::nat)";
4810
d55e2fee2084 New laws for mod
paulson
parents: 4774
diff changeset
    92
by (induct_tac "k" 1);
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    93
by (ALLGOALS
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    94
    (asm_simp_tac 
8783
9edcc005ebd9 removed obsolete "evenness" proofs
paulson
parents: 8698
diff changeset
    95
     (simpset() addsimps [read_instantiate [("y","n")] add_left_commute])));
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
    96
qed "mod_mult_self1";
4810
d55e2fee2084 New laws for mod
paulson
parents: 4774
diff changeset
    97
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
    98
Goal "(m + n*k) mod n = m mod (n::nat)";
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
    99
by (asm_simp_tac (simpset() addsimps [mult_commute, mod_mult_self1]) 1);
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   100
qed "mod_mult_self2";
4810
d55e2fee2084 New laws for mod
paulson
parents: 4774
diff changeset
   101
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   102
Addsimps [mod_mult_self1, mod_mult_self2];
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   103
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   104
Goal "(m mod n) * (k::nat) = (m*k) mod (n*k)";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   105
by (div_undefined_case_tac "n=0" 1);
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   106
by (div_undefined_case_tac "k=0" 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   107
by (res_inst_tac [("n","m")] less_induct 1);
4774
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
   108
by (stac mod_if 1);
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
   109
by (Asm_simp_tac 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   110
by (asm_simp_tac (simpset() addsimps [mod_geq, 
4774
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
   111
				      diff_less, diff_mult_distrib]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   112
qed "mod_mult_distrib";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   113
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   114
Goal "(k::nat) * (m mod n) = (k*m) mod (k*n)";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   115
by (asm_simp_tac 
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   116
    (simpset() addsimps [read_instantiate [("m","k")] mult_commute, 
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   117
			 mod_mult_distrib]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   118
qed "mod_mult_distrib2";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   119
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   120
Goal "(m*n) mod n = (0::nat)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   121
by (div_undefined_case_tac "n=0" 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   122
by (induct_tac "m" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   123
by (Asm_simp_tac 1);
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   124
by (rename_tac "k" 1);
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   125
by (cut_inst_tac [("m","k*n"),("n","n")] mod_add_self2 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   126
by (asm_full_simp_tac (simpset() addsimps [add_commute]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   127
qed "mod_mult_self_is_0";
7082
f444e632cdf5 new cancellation laws
paulson
parents: 7059
diff changeset
   128
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   129
Goal "(n*m) mod n = (0::nat)";
7082
f444e632cdf5 new cancellation laws
paulson
parents: 7059
diff changeset
   130
by (simp_tac (simpset() addsimps [mult_commute, mod_mult_self_is_0]) 1);
f444e632cdf5 new cancellation laws
paulson
parents: 7059
diff changeset
   131
qed "mod_mult_self1_is_0";
f444e632cdf5 new cancellation laws
paulson
parents: 7059
diff changeset
   132
Addsimps [mod_mult_self_is_0, mod_mult_self1_is_0];
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   133
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   134
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   135
(*** Quotient ***)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   136
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   137
Goal "m<n ==> m div n = (0::nat)";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   138
by (rtac (div_eq RS wf_less_trans) 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   139
by (Asm_simp_tac 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   140
qed "div_less";
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   141
Addsimps [div_less];
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   142
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   143
Goal "[| 0<n;  ~m<n |] ==> m div n = Suc((m-n) div n)";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   144
by (rtac (div_eq RS wf_less_trans) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   145
by (asm_simp_tac (simpset() addsimps [diff_less, cut_apply, less_eq]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   146
qed "div_geq";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   147
5415
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
   148
(*Avoids the ugly ~m<n above*)
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
   149
Goal "[| 0<n;  n<=m |] ==> m div n = Suc((m-n) div n)";
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
   150
by (asm_simp_tac (simpset() addsimps [div_geq, not_less_iff_le]) 1);
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
   151
qed "le_div_geq";
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
   152
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   153
Goal "0<n ==> m div n = (if m<n then 0 else Suc((m-n) div n))";
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   154
by (asm_simp_tac (simpset() addsimps [div_geq]) 1);
4774
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
   155
qed "div_if";
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
   156
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   157
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   158
(*Main Result about quotient and remainder.*)
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   159
Goal "(m div n)*n + m mod n = (m::nat)";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   160
by (div_undefined_case_tac "n=0" 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   161
by (res_inst_tac [("n","m")] less_induct 1);
4774
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
   162
by (stac mod_if 1);
b4760a833480 Tidied proofs by getting rid of case_tac
paulson
parents: 4686
diff changeset
   163
by (ALLGOALS (asm_simp_tac 
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   164
	      (simpset() addsimps [add_assoc, div_geq,
5537
c2bd39a2c0ee deleted needless parentheses
paulson
parents: 5498
diff changeset
   165
				   add_diff_inverse, diff_less])));
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   166
qed "mod_div_equality";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   167
4358
aa22fcb46a5d Added thm mult_div_cancel
nipkow
parents: 4356
diff changeset
   168
(* a simple rearrangement of mod_div_equality: *)
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   169
Goal "(n::nat) * (m div n) = m - (m mod n)";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   170
by (cut_inst_tac [("m","m"),("n","n")] mod_div_equality 1);
4358
aa22fcb46a5d Added thm mult_div_cancel
nipkow
parents: 4356
diff changeset
   171
by (EVERY1[etac subst, simp_tac (simpset() addsimps mult_ac),
aa22fcb46a5d Added thm mult_div_cancel
nipkow
parents: 4356
diff changeset
   172
           K(IF_UNSOLVED no_tac)]);
aa22fcb46a5d Added thm mult_div_cancel
nipkow
parents: 4356
diff changeset
   173
qed "mult_div_cancel";
aa22fcb46a5d Added thm mult_div_cancel
nipkow
parents: 4356
diff changeset
   174
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4811
diff changeset
   175
Goal "m div 1 = m";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   176
by (induct_tac "m" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   177
by (ALLGOALS (asm_simp_tac (simpset() addsimps [div_geq])));
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   178
qed "div_1";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   179
Addsimps [div_1];
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   180
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   181
Goal "0<n ==> n div n = (1::nat)";
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   182
by (asm_simp_tac (simpset() addsimps [div_geq]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   183
qed "div_self";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   184
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   185
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   186
Goal "0<n ==> (m+n) div n = Suc (m div n)";
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   187
by (subgoal_tac "(n + m) div n = Suc ((n+m-n) div n)" 1);
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   188
by (stac (div_geq RS sym) 2);
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   189
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [add_commute])));
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   190
qed "div_add_self2";
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   191
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   192
Goal "0<n ==> (n+m) div n = Suc (m div n)";
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   193
by (asm_simp_tac (simpset() addsimps [add_commute, div_add_self2]) 1);
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   194
qed "div_add_self1";
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   195
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   196
Goal "!!n::nat. 0<n ==> (m + k*n) div n = k + m div n";
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   197
by (induct_tac "k" 1);
5537
c2bd39a2c0ee deleted needless parentheses
paulson
parents: 5498
diff changeset
   198
by (ALLGOALS (asm_simp_tac (simpset() addsimps add_ac @ [div_add_self1])));
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   199
qed "div_mult_self1";
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   200
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   201
Goal "0<n ==> (m + n*k) div n = k + m div (n::nat)";
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   202
by (asm_simp_tac (simpset() addsimps [mult_commute, div_mult_self1]) 1);
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   203
qed "div_mult_self2";
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   204
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   205
Addsimps [div_mult_self1, div_mult_self2];
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   206
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   207
(** A dividend of zero **)
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   208
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   209
Goal "0 div m = (0::nat)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   210
by (div_undefined_case_tac "m=0" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   211
by (Asm_simp_tac 1);
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   212
qed "div_0"; 
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   213
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   214
Goal "0 mod m = (0::nat)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   215
by (div_undefined_case_tac "m=0" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   216
by (Asm_simp_tac 1);
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   217
qed "mod_0"; 
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   218
Addsimps [div_0, mod_0];
4811
7a98aa1f9a9d Renamed mod_XXX_cancel to mod_XXX_self
paulson
parents: 4810
diff changeset
   219
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   220
(* Monotonicity of div in first argument *)
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   221
Goal "ALL m::nat. m <= n --> (m div k) <= (n div k)";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   222
by (div_undefined_case_tac "k=0" 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   223
by (res_inst_tac [("n","n")] less_induct 1);
3718
d78cf498a88c Minor tidying to use Clarify_tac, etc.
paulson
parents: 3496
diff changeset
   224
by (Clarify_tac 1);
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   225
by (case_tac "n<k" 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   226
(* 1  case n<k *)
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   227
by (Asm_simp_tac 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   228
(* 2  case n >= k *)
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   229
by (case_tac "m<k" 1);
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   230
(* 2.1  case m<k *)
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   231
by (Asm_simp_tac 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   232
(* 2.2  case m>=k *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   233
by (asm_simp_tac (simpset() addsimps [div_geq, diff_less, diff_le_mono]) 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   234
qed_spec_mp "div_le_mono";
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   235
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   236
(* Antimonotonicity of div in second argument *)
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   237
Goal "!!m::nat. [| 0<m; m<=n |] ==> (k div n) <= (k div m)";
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   238
by (subgoal_tac "0<n" 1);
6073
fba734ba6894 Refined arith tactic.
nipkow
parents: 5983
diff changeset
   239
 by (Asm_simp_tac 2);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   240
by (res_inst_tac [("n","k")] less_induct 1);
3496
32e7edc609fd Simplified the new proofs about division
paulson
parents: 3484
diff changeset
   241
by (rename_tac "k" 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   242
by (case_tac "k<n" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   243
 by (Asm_simp_tac 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   244
by (subgoal_tac "~(k<m)" 1);
6073
fba734ba6894 Refined arith tactic.
nipkow
parents: 5983
diff changeset
   245
 by (Asm_simp_tac 2);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   246
by (asm_simp_tac (simpset() addsimps [div_geq]) 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   247
by (subgoal_tac "(k-n) div n <= (k-m) div n" 1);
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   248
 by (REPEAT (ares_tac [div_le_mono,diff_le_mono2] 2));
5318
72bf8039b53f expandshort
paulson
parents: 5316
diff changeset
   249
by (rtac le_trans 1);
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5278
diff changeset
   250
by (Asm_simp_tac 1);
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5278
diff changeset
   251
by (asm_simp_tac (simpset() addsimps [diff_less]) 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   252
qed "div_le_mono2";
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   253
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   254
Goal "m div n <= (m::nat)";
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   255
by (div_undefined_case_tac "n=0" 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   256
by (subgoal_tac "m div n <= m div 1" 1);
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   257
by (Asm_full_simp_tac 1);
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   258
by (rtac div_le_mono2 1);
6073
fba734ba6894 Refined arith tactic.
nipkow
parents: 5983
diff changeset
   259
by (ALLGOALS Asm_simp_tac);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   260
qed "div_le_dividend";
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   261
Addsimps [div_le_dividend];
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   262
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   263
(* Similar for "less than" *)
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   264
Goal "!!n::nat. 1<n ==> (0 < m) --> (m div n < m)";
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   265
by (res_inst_tac [("n","m")] less_induct 1);
3496
32e7edc609fd Simplified the new proofs about division
paulson
parents: 3484
diff changeset
   266
by (rename_tac "m" 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   267
by (case_tac "m<n" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   268
 by (Asm_full_simp_tac 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   269
by (subgoal_tac "0<n" 1);
6073
fba734ba6894 Refined arith tactic.
nipkow
parents: 5983
diff changeset
   270
 by (Asm_simp_tac 2);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   271
by (asm_full_simp_tac (simpset() addsimps [div_geq]) 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   272
by (case_tac "n<m" 1);
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   273
 by (subgoal_tac "(m-n) div n < (m-n)" 1);
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   274
  by (REPEAT (ares_tac [impI,less_trans_Suc] 1));
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   275
  by (asm_full_simp_tac (simpset() addsimps [diff_less]) 1);
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   276
 by (asm_full_simp_tac (simpset() addsimps [diff_less]) 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   277
(* case n=m *)
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   278
by (subgoal_tac "m=n" 1);
6073
fba734ba6894 Refined arith tactic.
nipkow
parents: 5983
diff changeset
   279
 by (Asm_simp_tac 2);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   280
by (Asm_simp_tac 1);
3484
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   281
qed_spec_mp "div_less_dividend";
1e93eb09ebb9 Added the following lemmas tp Divides and a few others to Arith and NatDef:
nipkow
parents: 3457
diff changeset
   282
Addsimps [div_less_dividend];
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   283
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   284
(*** Further facts about mod (mainly for the mutilated chess board ***)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   285
5278
a903b66822e2 even more tidying of Goal commands
paulson
parents: 5183
diff changeset
   286
Goal "0<n ==> Suc(m) mod n = (if Suc(m mod n) = n then 0 else Suc(m mod n))";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   287
by (res_inst_tac [("n","m")] less_induct 1);
8860
paulson
parents: 8783
diff changeset
   288
by (case_tac "Suc(na)<n" 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   289
(* case Suc(na) < n *)
8860
paulson
parents: 8783
diff changeset
   290
by (forward_tac [lessI RS less_trans] 1 
paulson
parents: 8783
diff changeset
   291
    THEN asm_simp_tac (simpset() addsimps [less_not_refl3]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   292
(* case n <= Suc(na) *)
5415
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
   293
by (asm_full_simp_tac (simpset() addsimps [not_less_iff_le, le_Suc_eq, 
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
   294
					   mod_geq]) 1);
8860
paulson
parents: 8783
diff changeset
   295
by (auto_tac (claset(), 
paulson
parents: 8783
diff changeset
   296
	      simpset() addsimps [Suc_diff_le, diff_less, le_mod_geq]));
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   297
qed "mod_Suc";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   298
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   299
Goal "0<n ==> m mod n < (n::nat)";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   300
by (res_inst_tac [("n","m")] less_induct 1);
5498
7b81cae2774f tidying
paulson
parents: 5415
diff changeset
   301
by (case_tac "na<n" 1);
7b81cae2774f tidying
paulson
parents: 5415
diff changeset
   302
(*case n le na*)
7b81cae2774f tidying
paulson
parents: 5415
diff changeset
   303
by (asm_full_simp_tac (simpset() addsimps [mod_geq, diff_less]) 2);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   304
(*case na<n*)
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   305
by (Asm_simp_tac 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   306
qed "mod_less_divisor";
8698
8812dad6ef12 made mod_less_divisor a simplification rule.
nipkow
parents: 8393
diff changeset
   307
Addsimps [mod_less_divisor];
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   308
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   309
(*** More division laws ***)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   310
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   311
Goal "0<n ==> (m*n) div n = (m::nat)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   312
by (cut_inst_tac [("m", "m*n"),("n","n")] mod_div_equality 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   313
by (asm_full_simp_tac (simpset() addsimps [mod_mult_self_is_0]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   314
qed "div_mult_self_is_m";
7082
f444e632cdf5 new cancellation laws
paulson
parents: 7059
diff changeset
   315
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   316
Goal "0<n ==> (n*m) div n = (m::nat)";
7082
f444e632cdf5 new cancellation laws
paulson
parents: 7059
diff changeset
   317
by (asm_simp_tac (simpset() addsimps [mult_commute, div_mult_self_is_m]) 1);
f444e632cdf5 new cancellation laws
paulson
parents: 7059
diff changeset
   318
qed "div_mult_self1_is_m";
f444e632cdf5 new cancellation laws
paulson
parents: 7059
diff changeset
   319
Addsimps [div_mult_self_is_m, div_mult_self1_is_m];
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   320
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   321
(*Cancellation law for division*)
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   322
Goal "0<k ==> (k*m) div (k*n) = m div (n::nat)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   323
by (div_undefined_case_tac "n=0" 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   324
by (res_inst_tac [("n","m")] less_induct 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   325
by (case_tac "na<n" 1);
8393
c7772d3787c3 mod_less, div_less are now default simprules
paulson
parents: 7499
diff changeset
   326
by (asm_simp_tac (simpset() addsimps [zero_less_mult_iff, mult_less_mono2]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   327
by (subgoal_tac "~ k*na < k*n" 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   328
by (asm_simp_tac
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   329
     (simpset() addsimps [zero_less_mult_iff, div_geq,
5415
13a199e94877 tidying; moved diff_less to Arith.ML
paulson
parents: 5355
diff changeset
   330
			  diff_mult_distrib2 RS sym, diff_less]) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   331
by (asm_full_simp_tac (simpset() addsimps [not_less_iff_le, 
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   332
                                          le_refl RS mult_le_mono]) 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   333
qed "div_cancel";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   334
Addsimps [div_cancel];
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   335
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   336
(*mod_mult_distrib2 above is the counterpart for remainder*)
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   337
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   338
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   339
(************************************************)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   340
(** Divides Relation                           **)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   341
(************************************************)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   342
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   343
Goalw [dvd_def] "m dvd (0::nat)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   344
by (blast_tac (claset() addIs [mult_0_right RS sym]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   345
qed "dvd_0_right";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   346
AddIffs [dvd_0_right];
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   347
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   348
Goalw [dvd_def] "0 dvd m ==> m = (0::nat)";
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   349
by Auto_tac;
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   350
qed "dvd_0_left";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   351
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   352
Goalw [dvd_def] "1 dvd (k::nat)";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   353
by (Simp_tac 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   354
qed "dvd_1_left";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   355
AddIffs [dvd_1_left];
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   356
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   357
Goalw [dvd_def] "m dvd (m::nat)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   358
by (blast_tac (claset() addIs [mult_1_right RS sym]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   359
qed "dvd_refl";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   360
Addsimps [dvd_refl];
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   361
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   362
Goalw [dvd_def] "[| m dvd n; n dvd p |] ==> m dvd (p::nat)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   363
by (blast_tac (claset() addIs [mult_assoc] ) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   364
qed "dvd_trans";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   365
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   366
Goalw [dvd_def] "[| m dvd n; n dvd m |] ==> m = (n::nat)";
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   367
by (force_tac (claset() addDs [mult_eq_self_implies_10],
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   368
	       simpset() addsimps [mult_assoc, mult_eq_1_iff]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   369
qed "dvd_anti_sym";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   370
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   371
Goalw [dvd_def] "[| k dvd m; k dvd n |] ==> k dvd (m+n :: nat)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   372
by (blast_tac (claset() addIs [add_mult_distrib2 RS sym]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   373
qed "dvd_add";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   374
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   375
Goalw [dvd_def] "[| k dvd m; k dvd n |] ==> k dvd (m-n :: nat)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   376
by (blast_tac (claset() addIs [diff_mult_distrib2 RS sym]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   377
qed "dvd_diff";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   378
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   379
Goal "[| k dvd (m-n); k dvd n; n<=m |] ==> k dvd (m::nat)";
3457
a8ab7c64817c Ran expandshort
paulson
parents: 3427
diff changeset
   380
by (etac (not_less_iff_le RS iffD2 RS add_diff_inverse RS subst) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   381
by (blast_tac (claset() addIs [dvd_add]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   382
qed "dvd_diffD";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   383
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   384
Goalw [dvd_def] "k dvd n ==> k dvd (m*n :: nat)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   385
by (blast_tac (claset() addIs [mult_left_commute]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   386
qed "dvd_mult";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   387
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   388
Goal "k dvd m ==> k dvd (m*n :: nat)";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   389
by (stac mult_commute 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   390
by (etac dvd_mult 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   391
qed "dvd_mult2";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   392
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   393
(* k dvd (m*k) *)
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   394
AddIffs [dvd_refl RS dvd_mult, dvd_refl RS dvd_mult2];
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   395
7493
e6f74eebfab3 added theorem dvd_reduce
oheimb
parents: 7082
diff changeset
   396
Goal "k dvd (n + k) = k dvd (n::nat)";
7499
23e090051cb8 isatool expandshort;
wenzelm
parents: 7493
diff changeset
   397
by (rtac iffI 1);
23e090051cb8 isatool expandshort;
wenzelm
parents: 7493
diff changeset
   398
by (etac dvd_add 2);
23e090051cb8 isatool expandshort;
wenzelm
parents: 7493
diff changeset
   399
by (rtac dvd_refl 2);
7493
e6f74eebfab3 added theorem dvd_reduce
oheimb
parents: 7082
diff changeset
   400
by (subgoal_tac "n = (n+k)-k" 1);
e6f74eebfab3 added theorem dvd_reduce
oheimb
parents: 7082
diff changeset
   401
by  (Simp_tac 2);
7499
23e090051cb8 isatool expandshort;
wenzelm
parents: 7493
diff changeset
   402
by (etac ssubst 1);
23e090051cb8 isatool expandshort;
wenzelm
parents: 7493
diff changeset
   403
by (etac dvd_diff 1);
23e090051cb8 isatool expandshort;
wenzelm
parents: 7493
diff changeset
   404
by (rtac dvd_refl 1);
7493
e6f74eebfab3 added theorem dvd_reduce
oheimb
parents: 7082
diff changeset
   405
qed "dvd_reduce";
e6f74eebfab3 added theorem dvd_reduce
oheimb
parents: 7082
diff changeset
   406
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   407
Goalw [dvd_def] "!!n::nat. [| f dvd m; f dvd n; 0<n |] ==> f dvd (m mod n)";
3718
d78cf498a88c Minor tidying to use Clarify_tac, etc.
paulson
parents: 3496
diff changeset
   408
by (Clarify_tac 1);
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   409
by (Full_simp_tac 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   410
by (res_inst_tac 
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   411
    [("x", "(((k div ka)*ka + k mod ka) - ((f*k) div (f*ka)) * ka)")] 
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   412
    exI 1);
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   413
by (asm_simp_tac
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   414
    (simpset() addsimps [diff_mult_distrib2, mod_mult_distrib2 RS sym, 
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   415
			 add_mult_distrib2]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   416
qed "dvd_mod";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   417
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   418
Goal "[| (k::nat) dvd (m mod n);  k dvd n |] ==> k dvd m";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   419
by (subgoal_tac "k dvd ((m div n)*n + m mod n)" 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   420
by (asm_simp_tac (simpset() addsimps [dvd_add, dvd_mult]) 2);
4356
0dfd34f0d33d Replaced n ~= 0 by 0 < n
nipkow
parents: 4089
diff changeset
   421
by (asm_full_simp_tac (simpset() addsimps [mod_div_equality]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   422
qed "dvd_mod_imp_dvd";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   423
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   424
Goalw [dvd_def]  "!!k::nat. [| (k*m) dvd (k*n); 0<k |] ==> m dvd n";
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   425
by (etac exE 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   426
by (asm_full_simp_tac (simpset() addsimps mult_ac) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   427
by (Blast_tac 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   428
qed "dvd_mult_cancel";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   429
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   430
Goalw [dvd_def] "[| i dvd m; j dvd n|] ==> (i*j) dvd (m*n :: nat)";
3718
d78cf498a88c Minor tidying to use Clarify_tac, etc.
paulson
parents: 3496
diff changeset
   431
by (Clarify_tac 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   432
by (res_inst_tac [("x","k*ka")] exI 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   433
by (asm_simp_tac (simpset() addsimps mult_ac) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   434
qed "mult_dvd_mono";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   435
6865
5577ffe4c2f1 now div and mod are overloaded; dvd is polymorphic
paulson
parents: 6073
diff changeset
   436
Goalw [dvd_def] "(i*j :: nat) dvd k ==> i dvd k";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   437
by (full_simp_tac (simpset() addsimps [mult_assoc]) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   438
by (Blast_tac 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   439
qed "dvd_mult_left";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   440
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   441
Goalw [dvd_def] "[| k dvd n; 0 < n |] ==> k <= (n::nat)";
3718
d78cf498a88c Minor tidying to use Clarify_tac, etc.
paulson
parents: 3496
diff changeset
   442
by (Clarify_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   443
by (ALLGOALS (full_simp_tac (simpset() addsimps [zero_less_mult_iff])));
3457
a8ab7c64817c Ran expandshort
paulson
parents: 3427
diff changeset
   444
by (etac conjE 1);
a8ab7c64817c Ran expandshort
paulson
parents: 3427
diff changeset
   445
by (rtac le_trans 1);
a8ab7c64817c Ran expandshort
paulson
parents: 3427
diff changeset
   446
by (rtac (le_refl RS mult_le_mono) 2);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   447
by (etac Suc_leI 2);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   448
by (Simp_tac 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   449
qed "dvd_imp_le";
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   450
8935
548901d05a0e added type constraint ::nat because 0 is now overloaded
paulson
parents: 8860
diff changeset
   451
Goalw [dvd_def] "!!k::nat. (k dvd n) = (n mod k = 0)";
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   452
by (div_undefined_case_tac "k=0" 1);
3724
f33e301a89f5 Step_tac -> Safe_tac
paulson
parents: 3718
diff changeset
   453
by Safe_tac;
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   454
by (asm_simp_tac (simpset() addsimps [mult_commute]) 1);
7029
08d4eb8500dd new division laws taking advantage of (m div 0) = 0 and (m mod 0) = m
paulson
parents: 7007
diff changeset
   455
by (res_inst_tac [("t","n"),("n1","k")] (mod_div_equality RS subst) 1);
3366
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   456
by (stac mult_commute 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   457
by (Asm_simp_tac 1);
2402c6ab1561 Moving div and mod from Arith to Divides
paulson
parents:
diff changeset
   458
qed "dvd_eq_mod_eq_0";