src/HOL/Arith.ML
author nipkow
Thu Oct 01 18:29:25 1998 +0200 (1998-10-01)
changeset 5598 6b8dee1a6ebb
parent 5537 c2bd39a2c0ee
child 5604 cd17004d09e1
permissions -rw-r--r--
a few new lemmas.
clasohm@1465
     1
(*  Title:      HOL/Arith.ML
clasohm@923
     2
    ID:         $Id$
clasohm@1465
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@4736
     4
    Copyright   1998  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Proofs about elementary arithmetic: addition, multiplication, etc.
paulson@3234
     7
Some from the Hoare example from Norbert Galm
clasohm@923
     8
*)
clasohm@923
     9
clasohm@923
    10
(*** Basic rewrite rules for the arithmetic operators ***)
clasohm@923
    11
nipkow@3896
    12
clasohm@923
    13
(** Difference **)
clasohm@923
    14
paulson@4732
    15
qed_goal "diff_0_eq_0" thy
clasohm@923
    16
    "0 - n = 0"
paulson@3339
    17
 (fn _ => [induct_tac "n" 1,  ALLGOALS Asm_simp_tac]);
clasohm@923
    18
paulson@5429
    19
(*Must simplify BEFORE the induction!  (Else we get a critical pair)
clasohm@923
    20
  Suc(m) - Suc(n)   rewrites to   pred(Suc(m) - n)  *)
paulson@4732
    21
qed_goal "diff_Suc_Suc" thy
clasohm@923
    22
    "Suc(m) - Suc(n) = m - n"
clasohm@923
    23
 (fn _ =>
paulson@3339
    24
  [Simp_tac 1, induct_tac "n" 1, ALLGOALS Asm_simp_tac]);
clasohm@923
    25
pusch@2682
    26
Addsimps [diff_0_eq_0, diff_Suc_Suc];
clasohm@923
    27
nipkow@4360
    28
(* Could be (and is, below) generalized in various ways;
nipkow@4360
    29
   However, none of the generalizations are currently in the simpset,
nipkow@4360
    30
   and I dread to think what happens if I put them in *)
paulson@5143
    31
Goal "0 < n ==> Suc(n-1) = n";
berghofe@5183
    32
by (asm_simp_tac (simpset() addsplits [nat.split]) 1);
nipkow@4360
    33
qed "Suc_pred";
nipkow@4360
    34
Addsimps [Suc_pred];
nipkow@4360
    35
nipkow@4360
    36
Delsimps [diff_Suc];
nipkow@4360
    37
clasohm@923
    38
clasohm@923
    39
(**** Inductive properties of the operators ****)
clasohm@923
    40
clasohm@923
    41
(*** Addition ***)
clasohm@923
    42
paulson@4732
    43
qed_goal "add_0_right" thy "m + 0 = m"
paulson@3339
    44
 (fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]);
clasohm@923
    45
paulson@4732
    46
qed_goal "add_Suc_right" thy "m + Suc(n) = Suc(m+n)"
paulson@3339
    47
 (fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]);
clasohm@923
    48
clasohm@1264
    49
Addsimps [add_0_right,add_Suc_right];
clasohm@923
    50
clasohm@923
    51
(*Associative law for addition*)
paulson@4732
    52
qed_goal "add_assoc" thy "(m + n) + k = m + ((n + k)::nat)"
paulson@3339
    53
 (fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]);
clasohm@923
    54
clasohm@923
    55
(*Commutative law for addition*)  
paulson@4732
    56
qed_goal "add_commute" thy "m + n = n + (m::nat)"
paulson@3339
    57
 (fn _ =>  [induct_tac "m" 1, ALLGOALS Asm_simp_tac]);
clasohm@923
    58
paulson@4732
    59
qed_goal "add_left_commute" thy "x+(y+z)=y+((x+z)::nat)"
clasohm@923
    60
 (fn _ => [rtac (add_commute RS trans) 1, rtac (add_assoc RS trans) 1,
clasohm@923
    61
           rtac (add_commute RS arg_cong) 1]);
clasohm@923
    62
clasohm@923
    63
(*Addition is an AC-operator*)
clasohm@923
    64
val add_ac = [add_assoc, add_commute, add_left_commute];
clasohm@923
    65
paulson@5429
    66
Goal "(k + m = k + n) = (m=(n::nat))";
paulson@3339
    67
by (induct_tac "k" 1);
clasohm@1264
    68
by (Simp_tac 1);
clasohm@1264
    69
by (Asm_simp_tac 1);
clasohm@923
    70
qed "add_left_cancel";
clasohm@923
    71
paulson@5429
    72
Goal "(m + k = n + k) = (m=(n::nat))";
paulson@3339
    73
by (induct_tac "k" 1);
clasohm@1264
    74
by (Simp_tac 1);
clasohm@1264
    75
by (Asm_simp_tac 1);
clasohm@923
    76
qed "add_right_cancel";
clasohm@923
    77
paulson@5429
    78
Goal "(k + m <= k + n) = (m<=(n::nat))";
paulson@3339
    79
by (induct_tac "k" 1);
clasohm@1264
    80
by (Simp_tac 1);
clasohm@1264
    81
by (Asm_simp_tac 1);
clasohm@923
    82
qed "add_left_cancel_le";
clasohm@923
    83
paulson@5429
    84
Goal "(k + m < k + n) = (m<(n::nat))";
paulson@3339
    85
by (induct_tac "k" 1);
clasohm@1264
    86
by (Simp_tac 1);
clasohm@1264
    87
by (Asm_simp_tac 1);
clasohm@923
    88
qed "add_left_cancel_less";
clasohm@923
    89
nipkow@1327
    90
Addsimps [add_left_cancel, add_right_cancel,
nipkow@1327
    91
          add_left_cancel_le, add_left_cancel_less];
nipkow@1327
    92
paulson@3339
    93
(** Reasoning about m+0=0, etc. **)
paulson@3339
    94
wenzelm@5069
    95
Goal "(m+n = 0) = (m=0 & n=0)";
nipkow@5598
    96
by (exhaust_tac "m" 1);
nipkow@5598
    97
by (Auto_tac);
nipkow@1327
    98
qed "add_is_0";
nipkow@4360
    99
AddIffs [add_is_0];
nipkow@1327
   100
nipkow@5598
   101
Goal "(0 = m+n) = (m=0 & n=0)";
nipkow@5598
   102
by (exhaust_tac "m" 1);
nipkow@5598
   103
by (Auto_tac);
nipkow@5598
   104
qed "zero_is_add";
nipkow@5598
   105
AddIffs [zero_is_add];
nipkow@5598
   106
nipkow@5598
   107
Goal "(m+n=1) = (m=1 & n=0 | m=0 & n=1)";
nipkow@5598
   108
by(exhaust_tac "m" 1);
nipkow@5598
   109
by(Auto_tac);
nipkow@5598
   110
qed "add_is_1";
nipkow@5598
   111
nipkow@5598
   112
Goal "(1=m+n) = (m=1 & n=0 | m=0 & n=1)";
nipkow@5598
   113
by(exhaust_tac "m" 1);
nipkow@5598
   114
by(Auto_tac);
nipkow@5598
   115
qed "one_is_add";
nipkow@5598
   116
wenzelm@5069
   117
Goal "(0<m+n) = (0<m | 0<n)";
wenzelm@4423
   118
by (simp_tac (simpset() delsimps [neq0_conv] addsimps [neq0_conv RS sym]) 1);
nipkow@4360
   119
qed "add_gr_0";
nipkow@4360
   120
AddIffs [add_gr_0];
nipkow@4360
   121
nipkow@4360
   122
(* FIXME: really needed?? *)
wenzelm@5069
   123
Goal "((m+n)-1 = 0) = (m=0 & n-1 = 0 | m-1 = 0 & n=0)";
nipkow@4360
   124
by (exhaust_tac "m" 1);
wenzelm@4089
   125
by (ALLGOALS (fast_tac (claset() addss (simpset()))));
paulson@3293
   126
qed "pred_add_is_0";
paulson@3293
   127
Addsimps [pred_add_is_0];
paulson@3293
   128
paulson@5429
   129
(* Could be generalized, eg to "k<n ==> m+(n-(Suc k)) = (m+n)-(Suc k)" *)
paulson@5143
   130
Goal "0<n ==> m + (n-1) = (m+n)-1";
nipkow@4360
   131
by (exhaust_tac "m" 1);
nipkow@4360
   132
by (ALLGOALS (asm_simp_tac (simpset() addsimps [diff_Suc]
berghofe@5183
   133
                                      addsplits [nat.split])));
nipkow@1327
   134
qed "add_pred";
nipkow@1327
   135
Addsimps [add_pred];
nipkow@1327
   136
paulson@5429
   137
Goal "m + n = m ==> n = 0";
paulson@5078
   138
by (dtac (add_0_right RS ssubst) 1);
paulson@5078
   139
by (asm_full_simp_tac (simpset() addsimps [add_assoc]
paulson@5078
   140
                                 delsimps [add_0_right]) 1);
paulson@5078
   141
qed "add_eq_self_zero";
paulson@5078
   142
paulson@1626
   143
clasohm@923
   144
(**** Additional theorems about "less than" ****)
clasohm@923
   145
paulson@5078
   146
(*Deleted less_natE; instead use less_eq_Suc_add RS exE*)
paulson@5143
   147
Goal "m<n --> (? k. n=Suc(m+k))";
paulson@3339
   148
by (induct_tac "n" 1);
paulson@5497
   149
by (ALLGOALS (simp_tac (simpset() addsimps [le_eq_less_or_eq])));
wenzelm@4089
   150
by (blast_tac (claset() addSEs [less_SucE] 
paulson@5497
   151
                        addSIs [add_0_right RS sym, add_Suc_right RS sym]) 1);
nipkow@1485
   152
qed_spec_mp "less_eq_Suc_add";
clasohm@923
   153
wenzelm@5069
   154
Goal "n <= ((m + n)::nat)";
paulson@3339
   155
by (induct_tac "m" 1);
clasohm@1264
   156
by (ALLGOALS Simp_tac);
clasohm@923
   157
by (etac le_trans 1);
clasohm@923
   158
by (rtac (lessI RS less_imp_le) 1);
clasohm@923
   159
qed "le_add2";
clasohm@923
   160
wenzelm@5069
   161
Goal "n <= ((n + m)::nat)";
wenzelm@4089
   162
by (simp_tac (simpset() addsimps add_ac) 1);
clasohm@923
   163
by (rtac le_add2 1);
clasohm@923
   164
qed "le_add1";
clasohm@923
   165
clasohm@923
   166
bind_thm ("less_add_Suc1", (lessI RS (le_add1 RS le_less_trans)));
clasohm@923
   167
bind_thm ("less_add_Suc2", (lessI RS (le_add2 RS le_less_trans)));
clasohm@923
   168
paulson@5429
   169
Goal "(m<n) = (? k. n=Suc(m+k))";
paulson@5429
   170
by (blast_tac (claset() addSIs [less_add_Suc1, less_eq_Suc_add]) 1);
paulson@5429
   171
qed "less_iff_Suc_add";
paulson@5429
   172
paulson@5429
   173
clasohm@923
   174
(*"i <= j ==> i <= j+m"*)
clasohm@923
   175
bind_thm ("trans_le_add1", le_add1 RSN (2,le_trans));
clasohm@923
   176
clasohm@923
   177
(*"i <= j ==> i <= m+j"*)
clasohm@923
   178
bind_thm ("trans_le_add2", le_add2 RSN (2,le_trans));
clasohm@923
   179
clasohm@923
   180
(*"i < j ==> i < j+m"*)
clasohm@923
   181
bind_thm ("trans_less_add1", le_add1 RSN (2,less_le_trans));
clasohm@923
   182
clasohm@923
   183
(*"i < j ==> i < m+j"*)
clasohm@923
   184
bind_thm ("trans_less_add2", le_add2 RSN (2,less_le_trans));
clasohm@923
   185
paulson@5143
   186
Goal "i+j < (k::nat) ==> i<k";
paulson@1552
   187
by (etac rev_mp 1);
paulson@3339
   188
by (induct_tac "j" 1);
clasohm@1264
   189
by (ALLGOALS Asm_simp_tac);
wenzelm@4089
   190
by (blast_tac (claset() addDs [Suc_lessD]) 1);
nipkow@1152
   191
qed "add_lessD1";
nipkow@1152
   192
paulson@5429
   193
Goal "~ (i+j < (i::nat))";
paulson@3457
   194
by (rtac notI 1);
paulson@3457
   195
by (etac (add_lessD1 RS less_irrefl) 1);
paulson@3234
   196
qed "not_add_less1";
paulson@3234
   197
paulson@5429
   198
Goal "~ (j+i < (i::nat))";
wenzelm@4089
   199
by (simp_tac (simpset() addsimps [add_commute, not_add_less1]) 1);
paulson@3234
   200
qed "not_add_less2";
paulson@3234
   201
AddIffs [not_add_less1, not_add_less2];
paulson@3234
   202
wenzelm@5069
   203
Goal "m+k<=n --> m<=(n::nat)";
paulson@3339
   204
by (induct_tac "k" 1);
paulson@5497
   205
by (ALLGOALS (asm_simp_tac (simpset() addsimps le_simps)));
nipkow@1485
   206
qed_spec_mp "add_leD1";
clasohm@923
   207
paulson@5429
   208
Goal "m+k<=n ==> k<=(n::nat)";
wenzelm@4089
   209
by (full_simp_tac (simpset() addsimps [add_commute]) 1);
paulson@2498
   210
by (etac add_leD1 1);
paulson@2498
   211
qed_spec_mp "add_leD2";
paulson@2498
   212
paulson@5429
   213
Goal "m+k<=n ==> m<=n & k<=(n::nat)";
wenzelm@4089
   214
by (blast_tac (claset() addDs [add_leD1, add_leD2]) 1);
paulson@2498
   215
bind_thm ("add_leE", result() RS conjE);
paulson@2498
   216
paulson@5429
   217
(*needs !!k for add_ac to work*)
paulson@5429
   218
Goal "!!k:: nat. [| k<l;  m+l = k+n |] ==> m<n";
paulson@5497
   219
by (auto_tac (claset(),
paulson@5497
   220
	      simpset() delsimps [add_Suc_right]
paulson@5537
   221
	                addsimps [less_iff_Suc_add,
paulson@5537
   222
				  add_Suc_right RS sym] @ add_ac));
clasohm@923
   223
qed "less_add_eq_less";
clasohm@923
   224
clasohm@923
   225
paulson@1713
   226
(*** Monotonicity of Addition ***)
clasohm@923
   227
clasohm@923
   228
(*strict, in 1st argument*)
paulson@5429
   229
Goal "i < j ==> i + k < j + (k::nat)";
paulson@3339
   230
by (induct_tac "k" 1);
clasohm@1264
   231
by (ALLGOALS Asm_simp_tac);
clasohm@923
   232
qed "add_less_mono1";
clasohm@923
   233
clasohm@923
   234
(*strict, in both arguments*)
paulson@5429
   235
Goal "[|i < j; k < l|] ==> i + k < j + (l::nat)";
clasohm@923
   236
by (rtac (add_less_mono1 RS less_trans) 1);
lcp@1198
   237
by (REPEAT (assume_tac 1));
paulson@3339
   238
by (induct_tac "j" 1);
clasohm@1264
   239
by (ALLGOALS Asm_simp_tac);
clasohm@923
   240
qed "add_less_mono";
clasohm@923
   241
clasohm@923
   242
(*A [clumsy] way of lifting < monotonicity to <= monotonicity *)
paulson@5316
   243
val [lt_mono,le] = Goal
clasohm@1465
   244
     "[| !!i j::nat. i<j ==> f(i) < f(j);       \
clasohm@1465
   245
\        i <= j                                 \
clasohm@923
   246
\     |] ==> f(i) <= (f(j)::nat)";
clasohm@923
   247
by (cut_facts_tac [le] 1);
wenzelm@4089
   248
by (asm_full_simp_tac (simpset() addsimps [le_eq_less_or_eq]) 1);
wenzelm@4089
   249
by (blast_tac (claset() addSIs [lt_mono]) 1);
clasohm@923
   250
qed "less_mono_imp_le_mono";
clasohm@923
   251
clasohm@923
   252
(*non-strict, in 1st argument*)
paulson@5429
   253
Goal "i<=j ==> i + k <= j + (k::nat)";
wenzelm@3842
   254
by (res_inst_tac [("f", "%j. j+k")] less_mono_imp_le_mono 1);
paulson@1552
   255
by (etac add_less_mono1 1);
clasohm@923
   256
by (assume_tac 1);
clasohm@923
   257
qed "add_le_mono1";
clasohm@923
   258
clasohm@923
   259
(*non-strict, in both arguments*)
paulson@5429
   260
Goal "[|i<=j;  k<=l |] ==> i + k <= j + (l::nat)";
clasohm@923
   261
by (etac (add_le_mono1 RS le_trans) 1);
wenzelm@4089
   262
by (simp_tac (simpset() addsimps [add_commute]) 1);
clasohm@923
   263
qed "add_le_mono";
paulson@1713
   264
paulson@3234
   265
paulson@3234
   266
(*** Multiplication ***)
paulson@3234
   267
paulson@3234
   268
(*right annihilation in product*)
paulson@4732
   269
qed_goal "mult_0_right" thy "m * 0 = 0"
paulson@3339
   270
 (fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]);
paulson@3234
   271
paulson@3293
   272
(*right successor law for multiplication*)
paulson@4732
   273
qed_goal "mult_Suc_right" thy  "m * Suc(n) = m + (m * n)"
paulson@3339
   274
 (fn _ => [induct_tac "m" 1,
wenzelm@4089
   275
           ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))]);
paulson@3234
   276
paulson@3293
   277
Addsimps [mult_0_right, mult_Suc_right];
paulson@3234
   278
wenzelm@5069
   279
Goal "1 * n = n";
paulson@3234
   280
by (Asm_simp_tac 1);
paulson@3234
   281
qed "mult_1";
paulson@3234
   282
wenzelm@5069
   283
Goal "n * 1 = n";
paulson@3234
   284
by (Asm_simp_tac 1);
paulson@3234
   285
qed "mult_1_right";
paulson@3234
   286
paulson@3234
   287
(*Commutative law for multiplication*)
paulson@4732
   288
qed_goal "mult_commute" thy "m * n = n * (m::nat)"
paulson@3339
   289
 (fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]);
paulson@3234
   290
paulson@3234
   291
(*addition distributes over multiplication*)
paulson@4732
   292
qed_goal "add_mult_distrib" thy "(m + n)*k = (m*k) + ((n*k)::nat)"
paulson@3339
   293
 (fn _ => [induct_tac "m" 1,
wenzelm@4089
   294
           ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))]);
paulson@3234
   295
paulson@4732
   296
qed_goal "add_mult_distrib2" thy "k*(m + n) = (k*m) + ((k*n)::nat)"
paulson@3339
   297
 (fn _ => [induct_tac "m" 1,
wenzelm@4089
   298
           ALLGOALS(asm_simp_tac (simpset() addsimps add_ac))]);
paulson@3234
   299
paulson@3234
   300
(*Associative law for multiplication*)
paulson@4732
   301
qed_goal "mult_assoc" thy "(m * n) * k = m * ((n * k)::nat)"
paulson@3339
   302
  (fn _ => [induct_tac "m" 1, 
wenzelm@4089
   303
            ALLGOALS (asm_simp_tac (simpset() addsimps [add_mult_distrib]))]);
paulson@3234
   304
paulson@4732
   305
qed_goal "mult_left_commute" thy "x*(y*z) = y*((x*z)::nat)"
paulson@3234
   306
 (fn _ => [rtac trans 1, rtac mult_commute 1, rtac trans 1,
paulson@3234
   307
           rtac mult_assoc 1, rtac (mult_commute RS arg_cong) 1]);
paulson@3234
   308
paulson@3234
   309
val mult_ac = [mult_assoc,mult_commute,mult_left_commute];
paulson@3234
   310
wenzelm@5069
   311
Goal "(m*n = 0) = (m=0 | n=0)";
paulson@3339
   312
by (induct_tac "m" 1);
paulson@3339
   313
by (induct_tac "n" 2);
paulson@3293
   314
by (ALLGOALS Asm_simp_tac);
paulson@3293
   315
qed "mult_is_0";
paulson@3293
   316
Addsimps [mult_is_0];
paulson@3293
   317
paulson@5429
   318
Goal "m <= m*(m::nat)";
paulson@4158
   319
by (induct_tac "m" 1);
paulson@4158
   320
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_assoc RS sym])));
paulson@4158
   321
by (etac (le_add2 RSN (2,le_trans)) 1);
paulson@4158
   322
qed "le_square";
paulson@4158
   323
paulson@3234
   324
paulson@3234
   325
(*** Difference ***)
paulson@3234
   326
paulson@3234
   327
paulson@4732
   328
qed_goal "diff_self_eq_0" thy "m - m = 0"
paulson@3339
   329
 (fn _ => [induct_tac "m" 1, ALLGOALS Asm_simp_tac]);
paulson@3234
   330
Addsimps [diff_self_eq_0];
paulson@3234
   331
paulson@3234
   332
(*Addition is the inverse of subtraction: if n<=m then n+(m-n) = m. *)
wenzelm@5069
   333
Goal "~ m<n --> n+(m-n) = (m::nat)";
paulson@3234
   334
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@3352
   335
by (ALLGOALS Asm_simp_tac);
paulson@3381
   336
qed_spec_mp "add_diff_inverse";
paulson@3381
   337
paulson@5143
   338
Goal "n<=m ==> n+(m-n) = (m::nat)";
wenzelm@4089
   339
by (asm_simp_tac (simpset() addsimps [add_diff_inverse, not_less_iff_le]) 1);
paulson@3381
   340
qed "le_add_diff_inverse";
paulson@3234
   341
paulson@5143
   342
Goal "n<=m ==> (m-n)+n = (m::nat)";
wenzelm@4089
   343
by (asm_simp_tac (simpset() addsimps [le_add_diff_inverse, add_commute]) 1);
paulson@3381
   344
qed "le_add_diff_inverse2";
paulson@3381
   345
paulson@3381
   346
Addsimps  [le_add_diff_inverse, le_add_diff_inverse2];
paulson@3234
   347
paulson@3234
   348
paulson@3234
   349
(*** More results about difference ***)
paulson@3234
   350
paulson@5414
   351
Goal "n <= m ==> Suc(m)-n = Suc(m-n)";
paulson@5316
   352
by (etac rev_mp 1);
paulson@3352
   353
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@3352
   354
by (ALLGOALS Asm_simp_tac);
paulson@5414
   355
qed "Suc_diff_le";
paulson@3352
   356
paulson@5429
   357
Goal "n<=(l::nat) --> Suc l - n + m = Suc (l - n + m)";
paulson@5429
   358
by (res_inst_tac [("m","n"),("n","l")] diff_induct 1);
paulson@5429
   359
by (ALLGOALS Asm_simp_tac);
paulson@5429
   360
qed_spec_mp "Suc_diff_add_le";
paulson@5429
   361
wenzelm@5069
   362
Goal "m - n < Suc(m)";
paulson@3234
   363
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@3234
   364
by (etac less_SucE 3);
wenzelm@4089
   365
by (ALLGOALS (asm_simp_tac (simpset() addsimps [less_Suc_eq])));
paulson@3234
   366
qed "diff_less_Suc";
paulson@3234
   367
paulson@5429
   368
Goal "m - n <= (m::nat)";
paulson@3234
   369
by (res_inst_tac [("m","m"), ("n","n")] diff_induct 1);
paulson@3234
   370
by (ALLGOALS Asm_simp_tac);
paulson@3234
   371
qed "diff_le_self";
paulson@3903
   372
Addsimps [diff_le_self];
paulson@3234
   373
paulson@4732
   374
(* j<k ==> j-n < k *)
paulson@4732
   375
bind_thm ("less_imp_diff_less", diff_le_self RS le_less_trans);
paulson@4732
   376
wenzelm@5069
   377
Goal "!!i::nat. i-j-k = i - (j+k)";
paulson@3352
   378
by (res_inst_tac [("m","i"),("n","j")] diff_induct 1);
paulson@3352
   379
by (ALLGOALS Asm_simp_tac);
paulson@3352
   380
qed "diff_diff_left";
paulson@3352
   381
wenzelm@5069
   382
Goal "(Suc m - n) - Suc k = m - n - k";
wenzelm@4423
   383
by (simp_tac (simpset() addsimps [diff_diff_left]) 1);
paulson@4736
   384
qed "Suc_diff_diff";
paulson@4736
   385
Addsimps [Suc_diff_diff];
nipkow@4360
   386
paulson@5143
   387
Goal "0<n ==> n - Suc i < n";
berghofe@5183
   388
by (exhaust_tac "n" 1);
paulson@4732
   389
by Safe_tac;
paulson@5497
   390
by (asm_simp_tac (simpset() addsimps le_simps) 1);
paulson@4732
   391
qed "diff_Suc_less";
paulson@4732
   392
Addsimps [diff_Suc_less];
paulson@4732
   393
paulson@5329
   394
Goal "i<n ==> n - Suc i < n - i";
paulson@5329
   395
by (exhaust_tac "n" 1);
paulson@5497
   396
by (auto_tac (claset(),
paulson@5537
   397
	      simpset() addsimps [Suc_diff_le]@le_simps));
paulson@5329
   398
qed "diff_Suc_less_diff";
paulson@5329
   399
paulson@5333
   400
Goal "m - n <= Suc m - n";
paulson@4732
   401
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@4732
   402
by (ALLGOALS Asm_simp_tac);
paulson@4732
   403
qed "diff_le_Suc_diff";
paulson@4732
   404
wenzelm@3396
   405
(*This and the next few suggested by Florian Kammueller*)
wenzelm@5069
   406
Goal "!!i::nat. i-j-k = i-k-j";
wenzelm@4089
   407
by (simp_tac (simpset() addsimps [diff_diff_left, add_commute]) 1);
paulson@3352
   408
qed "diff_commute";
paulson@3352
   409
paulson@5429
   410
Goal "k<=j --> j<=i --> i - (j - k) = i - j + (k::nat)";
paulson@3352
   411
by (res_inst_tac [("m","i"),("n","j")] diff_induct 1);
paulson@3352
   412
by (ALLGOALS Asm_simp_tac);
paulson@5414
   413
by (asm_simp_tac (simpset() addsimps [Suc_diff_le, le_Suc_eq]) 1);
paulson@3352
   414
qed_spec_mp "diff_diff_right";
paulson@3352
   415
paulson@5429
   416
Goal "k <= (j::nat) --> (i + j) - k = i + (j - k)";
paulson@3352
   417
by (res_inst_tac [("m","j"),("n","k")] diff_induct 1);
paulson@3352
   418
by (ALLGOALS Asm_simp_tac);
paulson@3352
   419
qed_spec_mp "diff_add_assoc";
paulson@3352
   420
paulson@5429
   421
Goal "k <= (j::nat) --> (j + i) - k = i + (j - k)";
paulson@4732
   422
by (asm_simp_tac (simpset() addsimps [add_commute, diff_add_assoc]) 1);
paulson@4732
   423
qed_spec_mp "diff_add_assoc2";
paulson@4732
   424
paulson@5429
   425
Goal "(n+m) - n = (m::nat)";
paulson@3339
   426
by (induct_tac "n" 1);
paulson@3234
   427
by (ALLGOALS Asm_simp_tac);
paulson@3234
   428
qed "diff_add_inverse";
paulson@3234
   429
Addsimps [diff_add_inverse];
paulson@3234
   430
paulson@5429
   431
Goal "(m+n) - n = (m::nat)";
wenzelm@4089
   432
by (simp_tac (simpset() addsimps [diff_add_assoc]) 1);
paulson@3234
   433
qed "diff_add_inverse2";
paulson@3234
   434
Addsimps [diff_add_inverse2];
paulson@3234
   435
paulson@5429
   436
Goal "i <= (j::nat) ==> (j-i=k) = (j=k+i)";
paulson@3724
   437
by Safe_tac;
paulson@3381
   438
by (ALLGOALS Asm_simp_tac);
paulson@3366
   439
qed "le_imp_diff_is_add";
paulson@3366
   440
paulson@5356
   441
Goal "(m-n = 0) = (m <= n)";
paulson@3234
   442
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@5497
   443
by (ALLGOALS Asm_simp_tac);
paulson@5356
   444
qed "diff_is_0_eq";
paulson@5356
   445
Addsimps [diff_is_0_eq RS iffD2];
paulson@3234
   446
paulson@5316
   447
Goal "m-n = 0  -->  n-m = 0  -->  m=n";
paulson@3234
   448
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@3234
   449
by (REPEAT(Simp_tac 1 THEN TRY(atac 1)));
paulson@3234
   450
qed_spec_mp "diffs0_imp_equal";
paulson@3234
   451
paulson@5333
   452
Goal "(0<n-m) = (m<n)";
paulson@3234
   453
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@3352
   454
by (ALLGOALS Asm_simp_tac);
paulson@5333
   455
qed "zero_less_diff";
paulson@5333
   456
Addsimps [zero_less_diff];
paulson@3234
   457
paulson@5333
   458
Goal "i < j  ==> ? k. 0<k & i+k = j";
paulson@5078
   459
by (res_inst_tac [("x","j - i")] exI 1);
paulson@5333
   460
by (asm_simp_tac (simpset() addsimps [add_diff_inverse, less_not_sym]) 1);
paulson@5078
   461
qed "less_imp_add_positive";
paulson@5078
   462
wenzelm@5069
   463
Goal "Suc(m)-n = (if m<n then 0 else Suc(m-n))";
paulson@5414
   464
by (simp_tac (simpset() addsimps [leI, Suc_le_eq, Suc_diff_le]) 1);
paulson@5414
   465
qed "if_Suc_diff_le";
paulson@3234
   466
wenzelm@5069
   467
Goal "Suc(m)-n <= Suc(m-n)";
paulson@5414
   468
by (simp_tac (simpset() addsimps [if_Suc_diff_le]) 1);
paulson@4672
   469
qed "diff_Suc_le_Suc_diff";
paulson@4672
   470
wenzelm@5069
   471
Goal "P(k) --> (!n. P(Suc(n))--> P(n)) --> P(k-i)";
paulson@3234
   472
by (res_inst_tac [("m","k"),("n","i")] diff_induct 1);
paulson@3718
   473
by (ALLGOALS (Clarify_tac THEN' Simp_tac THEN' TRY o Blast_tac));
paulson@3234
   474
qed "zero_induct_lemma";
paulson@3234
   475
paulson@5316
   476
val prems = Goal "[| P(k);  !!n. P(Suc(n)) ==> P(n) |] ==> P(0)";
paulson@3234
   477
by (rtac (diff_self_eq_0 RS subst) 1);
paulson@3234
   478
by (rtac (zero_induct_lemma RS mp RS mp) 1);
paulson@3234
   479
by (REPEAT (ares_tac ([impI,allI]@prems) 1));
paulson@3234
   480
qed "zero_induct";
paulson@3234
   481
paulson@5429
   482
Goal "(k+m) - (k+n) = m - (n::nat)";
paulson@3339
   483
by (induct_tac "k" 1);
paulson@3234
   484
by (ALLGOALS Asm_simp_tac);
paulson@3234
   485
qed "diff_cancel";
paulson@3234
   486
Addsimps [diff_cancel];
paulson@3234
   487
paulson@5429
   488
Goal "(m+k) - (n+k) = m - (n::nat)";
paulson@3234
   489
val add_commute_k = read_instantiate [("n","k")] add_commute;
paulson@5537
   490
by (asm_simp_tac (simpset() addsimps [add_commute_k]) 1);
paulson@3234
   491
qed "diff_cancel2";
paulson@3234
   492
Addsimps [diff_cancel2];
paulson@3234
   493
paulson@5414
   494
(*From Clemens Ballarin, proof by lcp*)
paulson@5429
   495
Goal "[| k<=n; n<=m |] ==> (m-k) - (n-k) = m-(n::nat)";
paulson@5414
   496
by (REPEAT (etac rev_mp 1));
paulson@5414
   497
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@5414
   498
by (ALLGOALS Asm_simp_tac);
paulson@5414
   499
(*a confluence problem*)
paulson@5414
   500
by (asm_simp_tac (simpset() addsimps [Suc_diff_le, le_Suc_eq]) 1);
paulson@3234
   501
qed "diff_right_cancel";
paulson@3234
   502
paulson@5429
   503
Goal "n - (n+m) = 0";
paulson@3339
   504
by (induct_tac "n" 1);
paulson@3234
   505
by (ALLGOALS Asm_simp_tac);
paulson@3234
   506
qed "diff_add_0";
paulson@3234
   507
Addsimps [diff_add_0];
paulson@3234
   508
paulson@5409
   509
paulson@3234
   510
(** Difference distributes over multiplication **)
paulson@3234
   511
wenzelm@5069
   512
Goal "!!m::nat. (m - n) * k = (m * k) - (n * k)";
paulson@3234
   513
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@3234
   514
by (ALLGOALS Asm_simp_tac);
paulson@3234
   515
qed "diff_mult_distrib" ;
paulson@3234
   516
wenzelm@5069
   517
Goal "!!m::nat. k * (m - n) = (k * m) - (k * n)";
paulson@3234
   518
val mult_commute_k = read_instantiate [("m","k")] mult_commute;
wenzelm@4089
   519
by (simp_tac (simpset() addsimps [diff_mult_distrib, mult_commute_k]) 1);
paulson@3234
   520
qed "diff_mult_distrib2" ;
paulson@3234
   521
(*NOT added as rewrites, since sometimes they are used from right-to-left*)
paulson@3234
   522
paulson@3234
   523
paulson@1713
   524
(*** Monotonicity of Multiplication ***)
paulson@1713
   525
paulson@5429
   526
Goal "i <= (j::nat) ==> i*k<=j*k";
paulson@3339
   527
by (induct_tac "k" 1);
wenzelm@4089
   528
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_le_mono])));
paulson@1713
   529
qed "mult_le_mono1";
paulson@1713
   530
paulson@1713
   531
(*<=monotonicity, BOTH arguments*)
paulson@5429
   532
Goal "[| i <= (j::nat); k <= l |] ==> i*k <= j*l";
paulson@2007
   533
by (etac (mult_le_mono1 RS le_trans) 1);
paulson@1713
   534
by (rtac le_trans 1);
paulson@2007
   535
by (stac mult_commute 2);
paulson@2007
   536
by (etac mult_le_mono1 2);
wenzelm@4089
   537
by (simp_tac (simpset() addsimps [mult_commute]) 1);
paulson@1713
   538
qed "mult_le_mono";
paulson@1713
   539
paulson@1713
   540
(*strict, in 1st argument; proof is by induction on k>0*)
paulson@5429
   541
Goal "[| i<j; 0<k |] ==> k*i < k*j";
paulson@5078
   542
by (eres_inst_tac [("m1","0")] (less_eq_Suc_add RS exE) 1);
paulson@1713
   543
by (Asm_simp_tac 1);
paulson@3339
   544
by (induct_tac "x" 1);
wenzelm@4089
   545
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_less_mono])));
paulson@1713
   546
qed "mult_less_mono2";
paulson@1713
   547
paulson@5429
   548
Goal "[| i<j; 0<k |] ==> i*k < j*k";
paulson@3457
   549
by (dtac mult_less_mono2 1);
wenzelm@4089
   550
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [mult_commute])));
paulson@3234
   551
qed "mult_less_mono1";
paulson@3234
   552
wenzelm@5069
   553
Goal "(0 < m*n) = (0<m & 0<n)";
paulson@3339
   554
by (induct_tac "m" 1);
paulson@3339
   555
by (induct_tac "n" 2);
paulson@1713
   556
by (ALLGOALS Asm_simp_tac);
paulson@1713
   557
qed "zero_less_mult_iff";
nipkow@4356
   558
Addsimps [zero_less_mult_iff];
paulson@1713
   559
wenzelm@5069
   560
Goal "(m*n = 1) = (m=1 & n=1)";
paulson@3339
   561
by (induct_tac "m" 1);
paulson@1795
   562
by (Simp_tac 1);
paulson@3339
   563
by (induct_tac "n" 1);
paulson@1795
   564
by (Simp_tac 1);
wenzelm@4089
   565
by (fast_tac (claset() addss simpset()) 1);
paulson@1795
   566
qed "mult_eq_1_iff";
nipkow@4356
   567
Addsimps [mult_eq_1_iff];
paulson@1795
   568
paulson@5143
   569
Goal "0<k ==> (m*k < n*k) = (m<n)";
wenzelm@4089
   570
by (safe_tac (claset() addSIs [mult_less_mono1]));
paulson@3234
   571
by (cut_facts_tac [less_linear] 1);
paulson@4389
   572
by (blast_tac (claset() addIs [mult_less_mono1] addEs [less_asym]) 1);
paulson@3234
   573
qed "mult_less_cancel2";
paulson@3234
   574
paulson@5143
   575
Goal "0<k ==> (k*m < k*n) = (m<n)";
paulson@3457
   576
by (dtac mult_less_cancel2 1);
wenzelm@4089
   577
by (asm_full_simp_tac (simpset() addsimps [mult_commute]) 1);
paulson@3234
   578
qed "mult_less_cancel1";
paulson@3234
   579
Addsimps [mult_less_cancel1, mult_less_cancel2];
paulson@3234
   580
wenzelm@5069
   581
Goal "(Suc k * m < Suc k * n) = (m < n)";
wenzelm@4423
   582
by (rtac mult_less_cancel1 1);
wenzelm@4297
   583
by (Simp_tac 1);
wenzelm@4297
   584
qed "Suc_mult_less_cancel1";
wenzelm@4297
   585
wenzelm@5069
   586
Goalw [le_def] "(Suc k * m <= Suc k * n) = (m <= n)";
wenzelm@4297
   587
by (simp_tac (simpset_of HOL.thy) 1);
wenzelm@4423
   588
by (rtac Suc_mult_less_cancel1 1);
wenzelm@4297
   589
qed "Suc_mult_le_cancel1";
wenzelm@4297
   590
paulson@5143
   591
Goal "0<k ==> (m*k = n*k) = (m=n)";
paulson@3234
   592
by (cut_facts_tac [less_linear] 1);
paulson@3724
   593
by Safe_tac;
paulson@3457
   594
by (assume_tac 2);
paulson@3234
   595
by (ALLGOALS (dtac mult_less_mono1 THEN' assume_tac));
paulson@3234
   596
by (ALLGOALS Asm_full_simp_tac);
paulson@3234
   597
qed "mult_cancel2";
paulson@3234
   598
paulson@5143
   599
Goal "0<k ==> (k*m = k*n) = (m=n)";
paulson@3457
   600
by (dtac mult_cancel2 1);
wenzelm@4089
   601
by (asm_full_simp_tac (simpset() addsimps [mult_commute]) 1);
paulson@3234
   602
qed "mult_cancel1";
paulson@3234
   603
Addsimps [mult_cancel1, mult_cancel2];
paulson@3234
   604
wenzelm@5069
   605
Goal "(Suc k * m = Suc k * n) = (m = n)";
wenzelm@4423
   606
by (rtac mult_cancel1 1);
wenzelm@4297
   607
by (Simp_tac 1);
wenzelm@4297
   608
qed "Suc_mult_cancel1";
wenzelm@4297
   609
paulson@3234
   610
paulson@1795
   611
(** Lemma for gcd **)
paulson@1795
   612
paulson@5143
   613
Goal "m = m*n ==> n=1 | m=0";
paulson@1795
   614
by (dtac sym 1);
paulson@1795
   615
by (rtac disjCI 1);
paulson@1795
   616
by (rtac nat_less_cases 1 THEN assume_tac 2);
wenzelm@4089
   617
by (fast_tac (claset() addSEs [less_SucE] addss simpset()) 1);
nipkow@4356
   618
by (best_tac (claset() addDs [mult_less_mono2] addss simpset()) 1);
paulson@1795
   619
qed "mult_eq_self_implies_10";
paulson@1795
   620
paulson@1795
   621
paulson@4736
   622
(*** Subtraction laws -- mostly from Clemens Ballarin ***)
paulson@3234
   623
paulson@5429
   624
Goal "[| a < (b::nat); c <= a |] ==> a-c < b-c";
paulson@3234
   625
by (subgoal_tac "c+(a-c) < c+(b-c)" 1);
paulson@3381
   626
by (Full_simp_tac 1);
paulson@3234
   627
by (subgoal_tac "c <= b" 1);
wenzelm@4089
   628
by (blast_tac (claset() addIs [less_imp_le, le_trans]) 2);
paulson@3381
   629
by (Asm_simp_tac 1);
paulson@3234
   630
qed "diff_less_mono";
paulson@3234
   631
paulson@5429
   632
Goal "a+b < (c::nat) ==> a < c-b";
paulson@3457
   633
by (dtac diff_less_mono 1);
paulson@3457
   634
by (rtac le_add2 1);
paulson@3234
   635
by (Asm_full_simp_tac 1);
paulson@3234
   636
qed "add_less_imp_less_diff";
paulson@3234
   637
nipkow@5427
   638
Goal "(i < j-k) = (i+k < (j::nat))";
paulson@5497
   639
by (rtac iffI 1);
paulson@5497
   640
 by (case_tac "k <= j" 1);
paulson@5497
   641
  by (dtac le_add_diff_inverse2 1);
paulson@5497
   642
  by (dres_inst_tac [("k","k")] add_less_mono1 1);
paulson@5497
   643
  by (Asm_full_simp_tac 1);
paulson@5497
   644
 by (rotate_tac 1 1);
paulson@5497
   645
 by (asm_full_simp_tac (simpset() addSolver cut_trans_tac) 1);
paulson@5497
   646
by (etac add_less_imp_less_diff 1);
nipkow@5427
   647
qed "less_diff_conv";
nipkow@5427
   648
paulson@5497
   649
Goal "(j-k <= (i::nat)) = (j <= i+k)";
paulson@5497
   650
by (simp_tac (simpset() addsimps [less_diff_conv, le_def]) 1);
paulson@5485
   651
qed "le_diff_conv";
paulson@5485
   652
paulson@5497
   653
Goal "k <= j ==> (i <= j-k) = (i+k <= (j::nat))";
paulson@5497
   654
by (asm_full_simp_tac
paulson@5497
   655
    (simpset() delsimps [less_Suc_eq_le]
paulson@5497
   656
               addsimps [less_Suc_eq_le RS sym, less_diff_conv,
paulson@5497
   657
			 Suc_diff_le RS sym]) 1);
paulson@5497
   658
qed "le_diff_conv2";
paulson@5497
   659
paulson@5143
   660
Goal "Suc i <= n ==> Suc (n - Suc i) = n - i";
paulson@5497
   661
by (asm_full_simp_tac (simpset() addsimps [Suc_diff_le RS sym]) 1);
paulson@3234
   662
qed "Suc_diff_Suc";
paulson@3234
   663
paulson@5429
   664
Goal "i <= (n::nat) ==> n - (n - i) = i";
paulson@3903
   665
by (etac rev_mp 1);
paulson@3903
   666
by (res_inst_tac [("m","n"),("n","i")] diff_induct 1);
wenzelm@4089
   667
by (ALLGOALS (asm_simp_tac  (simpset() addsimps [Suc_diff_le])));
paulson@3234
   668
qed "diff_diff_cancel";
paulson@3381
   669
Addsimps [diff_diff_cancel];
paulson@3234
   670
paulson@5429
   671
Goal "k <= (n::nat) ==> m <= n + m - k";
paulson@3457
   672
by (etac rev_mp 1);
paulson@3234
   673
by (res_inst_tac [("m", "k"), ("n", "n")] diff_induct 1);
paulson@3234
   674
by (Simp_tac 1);
paulson@5497
   675
by (simp_tac (simpset() addsimps [le_add2, less_imp_le]) 1);
paulson@3234
   676
by (Simp_tac 1);
paulson@3234
   677
qed "le_add_diff";
paulson@3234
   678
paulson@5429
   679
Goal "0<k ==> j<i --> j+k-i < k";
paulson@4736
   680
by (res_inst_tac [("m","j"),("n","i")] diff_induct 1);
paulson@4736
   681
by (ALLGOALS Asm_simp_tac);
paulson@4736
   682
qed_spec_mp "add_diff_less";
paulson@4736
   683
paulson@3234
   684
paulson@5356
   685
Goal "m-1 < n ==> m <= n";
paulson@5356
   686
by (exhaust_tac "m" 1);
paulson@5356
   687
by (auto_tac (claset(), simpset() addsimps [Suc_le_eq]));
paulson@5356
   688
qed "pred_less_imp_le";
paulson@5356
   689
paulson@5356
   690
Goal "j<=i ==> i - j < Suc i - j";
paulson@5356
   691
by (REPEAT (etac rev_mp 1));
paulson@5356
   692
by (res_inst_tac [("m","i"),("n","j")] diff_induct 1);
paulson@5356
   693
by Auto_tac;
paulson@5356
   694
qed "diff_less_Suc_diff";
paulson@5356
   695
paulson@5356
   696
Goal "i - j <= Suc i - j";
paulson@5356
   697
by (res_inst_tac [("m","i"),("n","j")] diff_induct 1);
paulson@5356
   698
by Auto_tac;
paulson@5356
   699
qed "diff_le_Suc_diff";
paulson@5356
   700
AddIffs [diff_le_Suc_diff];
paulson@5356
   701
paulson@5356
   702
Goal "n - Suc i <= n - i";
paulson@5356
   703
by (case_tac "i<n" 1);
paulson@5497
   704
by (dtac diff_Suc_less_diff 1);
paulson@5497
   705
by (auto_tac (claset(), simpset() addsimps [leI]));
paulson@5356
   706
qed "diff_Suc_le_diff";
paulson@5356
   707
AddIffs [diff_Suc_le_diff];
paulson@5356
   708
paulson@5409
   709
Goal "0 < n ==> (m <= n-1) = (m<n)";
paulson@5409
   710
by (exhaust_tac "n" 1);
paulson@5497
   711
by (auto_tac (claset(), simpset() addsimps le_simps));
paulson@5409
   712
qed "le_pred_eq";
paulson@5409
   713
paulson@5409
   714
Goal "0 < n ==> (m-1 < n) = (m<=n)";
paulson@5409
   715
by (exhaust_tac "m" 1);
paulson@5409
   716
by (auto_tac (claset(), simpset() addsimps [Suc_le_eq]));
paulson@5409
   717
qed "less_pred_eq";
paulson@5409
   718
paulson@5414
   719
(*In ordinary notation: if 0<n and n<=m then m-n < m *)
paulson@5414
   720
Goal "[| 0<n; ~ m<n |] ==> m - n < m";
paulson@5414
   721
by (subgoal_tac "0<n --> ~ m<n --> m - n < m" 1);
paulson@5414
   722
by (Blast_tac 1);
paulson@5414
   723
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
paulson@5414
   724
by (ALLGOALS(asm_simp_tac(simpset() addsimps [diff_less_Suc])));
paulson@5414
   725
qed "diff_less";
paulson@5414
   726
paulson@5414
   727
Goal "[| 0<n; n<=m |] ==> m - n < m";
paulson@5414
   728
by (asm_simp_tac (simpset() addsimps [diff_less, not_less_iff_le]) 1);
paulson@5414
   729
qed "le_diff_less";
paulson@5414
   730
paulson@5356
   731
paulson@4732
   732
nipkow@3484
   733
(** (Anti)Monotonicity of subtraction -- by Stefan Merz **)
nipkow@3484
   734
nipkow@3484
   735
(* Monotonicity of subtraction in first argument *)
paulson@5429
   736
Goal "m <= (n::nat) --> (m-l) <= (n-l)";
nipkow@3484
   737
by (induct_tac "n" 1);
nipkow@3484
   738
by (Simp_tac 1);
wenzelm@4089
   739
by (simp_tac (simpset() addsimps [le_Suc_eq]) 1);
paulson@4732
   740
by (blast_tac (claset() addIs [diff_le_Suc_diff, le_trans]) 1);
nipkow@3484
   741
qed_spec_mp "diff_le_mono";
nipkow@3484
   742
paulson@5429
   743
Goal "m <= (n::nat) ==> (l-n) <= (l-m)";
nipkow@3484
   744
by (induct_tac "l" 1);
nipkow@3484
   745
by (Simp_tac 1);
berghofe@5183
   746
by (case_tac "n <= na" 1);
berghofe@5183
   747
by (subgoal_tac "m <= na" 1);
wenzelm@4089
   748
by (asm_simp_tac (simpset() addsimps [Suc_diff_le]) 1);
wenzelm@4089
   749
by (fast_tac (claset() addEs [le_trans]) 1);
nipkow@3484
   750
by (dtac not_leE 1);
paulson@5414
   751
by (asm_simp_tac (simpset() addsimps [if_Suc_diff_le]) 1);
nipkow@3484
   752
qed_spec_mp "diff_le_mono2";