src/HOL/Arith.ML
author clasohm
Wed, 21 Jun 1995 15:47:10 +0200
changeset 1151 c820b3cc3df0
parent 972 e61b058d58d2
child 1152 b6e1e74695f6
permissions -rw-r--r--
removed \...\ inside strings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/Arith.ML
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
Proofs about elementary arithmetic: addition, multiplication, etc.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
Tests definitions and simplifier.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
open Arith;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
(*** Basic rewrite rules for the arithmetic operators ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
val [pred_0, pred_Suc] = nat_recs pred_def;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
val [add_0,add_Suc] = nat_recs add_def; 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
val [mult_0,mult_Suc] = nat_recs mult_def; 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
(** Difference **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
val diff_0 = diff_def RS def_nat_rec_0;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
qed_goalw "diff_0_eq_0" Arith.thy [diff_def, pred_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
    "0 - n = 0"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
 (fn _ => [nat_ind_tac "n" 1,  ALLGOALS(asm_simp_tac nat_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
(*Must simplify BEFORE the induction!!  (Else we get a critical pair)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
  Suc(m) - Suc(n)   rewrites to   pred(Suc(m) - n)  *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
qed_goalw "diff_Suc_Suc" Arith.thy [diff_def, pred_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
    "Suc(m) - Suc(n) = m - n"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
 (fn _ =>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
  [simp_tac nat_ss 1, nat_ind_tac "n" 1, ALLGOALS(asm_simp_tac nat_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
(*** Simplification over add, mult, diff ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
val arith_simps =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
 [pred_0, pred_Suc, add_0, add_Suc, mult_0, mult_Suc,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
  diff_0, diff_0_eq_0, diff_Suc_Suc];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
val arith_ss = nat_ss addsimps arith_simps;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
(**** Inductive properties of the operators ****)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
(*** Addition ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
qed_goal "add_0_right" Arith.thy "m + 0 = m"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
 (fn _ => [nat_ind_tac "m" 1, ALLGOALS(asm_simp_tac arith_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
qed_goal "add_Suc_right" Arith.thy "m + Suc(n) = Suc(m+n)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
 (fn _ => [nat_ind_tac "m" 1, ALLGOALS(asm_simp_tac arith_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
val arith_ss = arith_ss addsimps [add_0_right,add_Suc_right];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
(*Associative law for addition*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
qed_goal "add_assoc" Arith.thy "(m + n) + k = m + ((n + k)::nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
 (fn _ => [nat_ind_tac "m" 1, ALLGOALS(asm_simp_tac arith_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
(*Commutative law for addition*)  
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
qed_goal "add_commute" Arith.thy "m + n = n + (m::nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
 (fn _ =>  [nat_ind_tac "m" 1, ALLGOALS(asm_simp_tac arith_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
qed_goal "add_left_commute" Arith.thy "x+(y+z)=y+((x+z)::nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
 (fn _ => [rtac (add_commute RS trans) 1, rtac (add_assoc RS trans) 1,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
           rtac (add_commute RS arg_cong) 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
(*Addition is an AC-operator*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
val add_ac = [add_assoc, add_commute, add_left_commute];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
goal Arith.thy "!!k::nat. (k + m = k + n) = (m=n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
by (nat_ind_tac "k" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
by (simp_tac arith_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
by (asm_simp_tac arith_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
qed "add_left_cancel";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
goal Arith.thy "!!k::nat. (m + k = n + k) = (m=n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
by (nat_ind_tac "k" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
by (simp_tac arith_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
by (asm_simp_tac arith_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
qed "add_right_cancel";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
goal Arith.thy "!!k::nat. (k + m <= k + n) = (m<=n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
by (nat_ind_tac "k" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
by (simp_tac arith_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
by (asm_simp_tac (arith_ss addsimps [Suc_le_mono]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
qed "add_left_cancel_le";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
goal Arith.thy "!!k::nat. (k + m < k + n) = (m<n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
by (nat_ind_tac "k" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
by (simp_tac arith_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
by (asm_simp_tac arith_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
qed "add_left_cancel_less";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
(*** Multiplication ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
(*right annihilation in product*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
qed_goal "mult_0_right" Arith.thy "m * 0 = 0"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
 (fn _ => [nat_ind_tac "m" 1, ALLGOALS(asm_simp_tac arith_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
(*right Sucessor law for multiplication*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
qed_goal "mult_Suc_right" Arith.thy  "m * Suc(n) = m + (m * n)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
 (fn _ => [nat_ind_tac "m" 1,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
           ALLGOALS(asm_simp_tac (arith_ss addsimps add_ac))]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
val arith_ss = arith_ss addsimps [mult_0_right,mult_Suc_right];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
(*Commutative law for multiplication*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
qed_goal "mult_commute" Arith.thy "m * n = n * (m::nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
 (fn _ => [nat_ind_tac "m" 1, ALLGOALS (asm_simp_tac arith_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
(*addition distributes over multiplication*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
qed_goal "add_mult_distrib" Arith.thy "(m + n)*k = (m*k) + ((n*k)::nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
 (fn _ => [nat_ind_tac "m" 1,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
           ALLGOALS(asm_simp_tac (arith_ss addsimps add_ac))]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
qed_goal "add_mult_distrib2" Arith.thy "k*(m + n) = (k*m) + ((k*n)::nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
 (fn _ => [nat_ind_tac "m" 1,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   116
           ALLGOALS(asm_simp_tac (arith_ss addsimps add_ac))]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
val arith_ss = arith_ss addsimps [add_mult_distrib,add_mult_distrib2];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
(*Associative law for multiplication*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
qed_goal "mult_assoc" Arith.thy "(m * n) * k = m * ((n * k)::nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
  (fn _ => [nat_ind_tac "m" 1, ALLGOALS(asm_simp_tac arith_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   123
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   124
qed_goal "mult_left_commute" Arith.thy "x*(y*z) = y*((x*z)::nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
 (fn _ => [rtac trans 1, rtac mult_commute 1, rtac trans 1,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
           rtac mult_assoc 1, rtac (mult_commute RS arg_cong) 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   127
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
val mult_ac = [mult_assoc,mult_commute,mult_left_commute];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
(*** Difference ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
qed_goal "diff_self_eq_0" Arith.thy "m - m = 0"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
 (fn _ => [nat_ind_tac "m" 1, ALLGOALS(asm_simp_tac arith_ss)]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
(*Addition is the inverse of subtraction: if n<=m then n+(m-n) = m. *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
val [prem] = goal Arith.thy "[| ~ m<n |] ==> n+(m-n) = (m::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
by (rtac (prem RS rev_mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
by (ALLGOALS(asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
qed "add_diff_inverse";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   141
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   143
(*** Remainder ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
goal Arith.thy "m - n < Suc(m)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   147
by (etac less_SucE 3);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
by (ALLGOALS(asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   149
qed "diff_less_Suc";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
goal Arith.thy "!!m::nat. m - n <= m";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
by (res_inst_tac [("m","m"), ("n","n")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
by (ALLGOALS (asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
by (etac le_trans 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   155
by (simp_tac (HOL_ss addsimps [le_eq_less_or_eq, lessI]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   156
qed "diff_le_self";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   157
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   158
goal Arith.thy "!!n::nat. (n+m) - n = m";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   159
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   160
by (ALLGOALS (asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   161
qed "diff_add_inverse";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   162
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   163
goal Arith.thy "!!n::nat. n - (n+m) = 0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   164
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   165
by (ALLGOALS (asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   166
qed "diff_add_0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   167
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   168
(*In ordinary notation: if 0<n and n<=m then m-n < m *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   169
goal Arith.thy "!!m. [| 0<n; ~ m<n |] ==> m - n < m";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   170
by (subgoal_tac "0<n --> ~ m<n --> m - n < m" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   171
by (fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   172
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   173
by (ALLGOALS(asm_simp_tac(arith_ss addsimps [diff_less_Suc])));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   174
qed "div_termination";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   175
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   176
val wf_less_trans = wf_pred_nat RS wf_trancl RSN (2, def_wfrec RS trans);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   177
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 965
diff changeset
   178
goalw Nat.thy [less_def] "(m,n) : pred_nat^+ = (m<n)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   179
by (rtac refl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   180
qed "less_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
goal Arith.thy "!!m. m<n ==> m mod n = m";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
by (rtac (mod_def RS wf_less_trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
by(asm_simp_tac HOL_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   185
qed "mod_less";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   186
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   187
goal Arith.thy "!!m. [| 0<n;  ~m<n |] ==> m mod n = (m-n) mod n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
by (rtac (mod_def RS wf_less_trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
by(asm_simp_tac (nat_ss addsimps [div_termination, cut_apply, less_eq]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   190
qed "mod_geq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   191
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   192
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   193
(*** Quotient ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   194
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   195
goal Arith.thy "!!m. m<n ==> m div n = 0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   196
by (rtac (div_def RS wf_less_trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   197
by(asm_simp_tac nat_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   198
qed "div_less";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   199
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   200
goal Arith.thy "!!M. [| 0<n;  ~m<n |] ==> m div n = Suc((m-n) div n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   201
by (rtac (div_def RS wf_less_trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   202
by(asm_simp_tac (nat_ss addsimps [div_termination, cut_apply, less_eq]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   203
qed "div_geq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   204
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   205
(*Main Result about quotient and remainder.*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   206
goal Arith.thy "!!m. 0<n ==> (m div n)*n + m mod n = m";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   207
by (res_inst_tac [("n","m")] less_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   208
by (rename_tac "k" 1);    (*Variable name used in line below*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   209
by (case_tac "k<n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   210
by (ALLGOALS (asm_simp_tac(arith_ss addsimps (add_ac @
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   211
                       [mod_less, mod_geq, div_less, div_geq,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   212
	                add_diff_inverse, div_termination]))));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   213
qed "mod_div_equality";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   214
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   215
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   216
(*** More results about difference ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   217
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   218
val [prem] = goal Arith.thy "m < Suc(n) ==> m-n = 0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   219
by (rtac (prem RS rev_mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   220
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   221
by (ALLGOALS (asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   222
qed "less_imp_diff_is_0";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   223
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   224
val prems = goal Arith.thy "m-n = 0  -->  n-m = 0  -->  m=n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   225
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   226
by (REPEAT(simp_tac arith_ss 1 THEN TRY(atac 1)));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   227
qed "diffs0_imp_equal_lemma";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   228
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   229
(*  [| m-n = 0;  n-m = 0 |] ==> m=n  *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   230
bind_thm ("diffs0_imp_equal", (diffs0_imp_equal_lemma RS mp RS mp));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   231
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   232
val [prem] = goal Arith.thy "m<n ==> 0<n-m";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   233
by (rtac (prem RS rev_mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   234
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   235
by (ALLGOALS(asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   236
qed "less_imp_diff_positive";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   237
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   238
val [prem] = goal Arith.thy "n < Suc(m) ==> Suc(m)-n = Suc(m-n)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   239
by (rtac (prem RS rev_mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   240
by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   241
by (ALLGOALS(asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   242
qed "Suc_diff_n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   243
965
24eef3860714 changed syntax of "if"
clasohm
parents: 923
diff changeset
   244
goal Arith.thy "Suc(m)-n = (if m<n then 0 else Suc m-n)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   245
by(simp_tac (nat_ss addsimps [less_imp_diff_is_0, not_less_eq, Suc_diff_n]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   246
                    setloop (split_tac [expand_if])) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   247
qed "if_Suc_diff_n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   248
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   249
goal Arith.thy "P(k) --> (!n. P(Suc(n))--> P(n)) --> P(k-i)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   250
by (res_inst_tac [("m","k"),("n","i")] diff_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   251
by (ALLGOALS (strip_tac THEN' simp_tac arith_ss THEN' TRY o fast_tac HOL_cs));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   252
qed "zero_induct_lemma";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   253
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   254
val prems = goal Arith.thy "[| P(k);  !!n. P(Suc(n)) ==> P(n) |] ==> P(0)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   255
by (rtac (diff_self_eq_0 RS subst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   256
by (rtac (zero_induct_lemma RS mp RS mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   257
by (REPEAT (ares_tac ([impI,allI]@prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   258
qed "zero_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   259
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   260
(*13 July 1992: loaded in 105.7s*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   261
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   262
(**** Additional theorems about "less than" ****)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   263
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   264
goal Arith.thy "!!m. m<n --> (? k. n=Suc(m+k))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   265
by (nat_ind_tac "n" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   266
by (ALLGOALS(simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   267
by (REPEAT_FIRST (ares_tac [conjI, impI]));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   268
by (res_inst_tac [("x","0")] exI 2);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   269
by (simp_tac arith_ss 2);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   270
by (safe_tac HOL_cs);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   271
by (res_inst_tac [("x","Suc(k)")] exI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   272
by (simp_tac arith_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   273
val less_eq_Suc_add_lemma = result();
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   274
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   275
(*"m<n ==> ? k. n = Suc(m+k)"*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   276
bind_thm ("less_eq_Suc_add", less_eq_Suc_add_lemma RS mp);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   277
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   278
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   279
goal Arith.thy "n <= ((m + n)::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   280
by (nat_ind_tac "m" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   281
by (ALLGOALS(simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   282
by (etac le_trans 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   283
by (rtac (lessI RS less_imp_le) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   284
qed "le_add2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   285
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   286
goal Arith.thy "n <= ((n + m)::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   287
by (simp_tac (arith_ss addsimps add_ac) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   288
by (rtac le_add2 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   289
qed "le_add1";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   290
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   291
bind_thm ("less_add_Suc1", (lessI RS (le_add1 RS le_less_trans)));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   292
bind_thm ("less_add_Suc2", (lessI RS (le_add2 RS le_less_trans)));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   293
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   294
(*"i <= j ==> i <= j+m"*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   295
bind_thm ("trans_le_add1", le_add1 RSN (2,le_trans));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   296
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   297
(*"i <= j ==> i <= m+j"*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   298
bind_thm ("trans_le_add2", le_add2 RSN (2,le_trans));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   299
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   300
(*"i < j ==> i < j+m"*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   301
bind_thm ("trans_less_add1", le_add1 RSN (2,less_le_trans));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   302
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   303
(*"i < j ==> i < m+j"*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   304
bind_thm ("trans_less_add2", le_add2 RSN (2,less_le_trans));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   305
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   306
goal Arith.thy "!!k::nat. m <= n ==> m <= n+k";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   307
by (eresolve_tac [le_trans] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   308
by (resolve_tac [le_add1] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   309
qed "le_imp_add_le";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   310
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   311
goal Arith.thy "!!k::nat. m < n ==> m < n+k";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   312
by (eresolve_tac [less_le_trans] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   313
by (resolve_tac [le_add1] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   314
qed "less_imp_add_less";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   315
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   316
goal Arith.thy "m+k<=n --> m<=(n::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   317
by (nat_ind_tac "k" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   318
by (ALLGOALS (asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   319
by (fast_tac (HOL_cs addDs [Suc_leD]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   320
val add_leD1_lemma = result();
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   321
bind_thm ("add_leD1", add_leD1_lemma RS mp);;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   322
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   323
goal Arith.thy "!!k l::nat. [| k<l; m+l = k+n |] ==> m<n";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   324
by (safe_tac (HOL_cs addSDs [less_eq_Suc_add]));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   325
by (asm_full_simp_tac
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   326
    (HOL_ss addsimps ([add_Suc_right RS sym, add_left_cancel] @add_ac)) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   327
by (eresolve_tac [subst] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   328
by (simp_tac (arith_ss addsimps [less_add_Suc1]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   329
qed "less_add_eq_less";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   330
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   331
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   332
(** Monotonicity of addition (from ZF/Arith) **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   333
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   334
(** Monotonicity results **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   335
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   336
(*strict, in 1st argument*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   337
goal Arith.thy "!!i j k::nat. i < j ==> i + k < j + k";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   338
by (nat_ind_tac "k" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   339
by (ALLGOALS (asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   340
qed "add_less_mono1";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   341
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   342
(*strict, in both arguments*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   343
goal Arith.thy "!!i j k::nat. [|i < j; k < l|] ==> i + k < j + l";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   344
by (rtac (add_less_mono1 RS less_trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   345
by (REPEAT (etac asm_rl 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   346
by (nat_ind_tac "j" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   347
by (ALLGOALS(asm_simp_tac arith_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   348
qed "add_less_mono";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   349
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   350
(*A [clumsy] way of lifting < monotonicity to <= monotonicity *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   351
val [lt_mono,le] = goal Arith.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   352
     "[| !!i j::nat. i<j ==> f(i) < f(j);	\
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   353
\        i <= j					\
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   354
\     |] ==> f(i) <= (f(j)::nat)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   355
by (cut_facts_tac [le] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   356
by (asm_full_simp_tac (HOL_ss addsimps [le_eq_less_or_eq]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   357
by (fast_tac (HOL_cs addSIs [lt_mono]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   358
qed "less_mono_imp_le_mono";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   359
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   360
(*non-strict, in 1st argument*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   361
goal Arith.thy "!!i j k::nat. i<=j ==> i + k <= j + k";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   362
by (res_inst_tac [("f", "%j.j+k")] less_mono_imp_le_mono 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   363
by (eresolve_tac [add_less_mono1] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   364
by (assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   365
qed "add_le_mono1";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   366
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   367
(*non-strict, in both arguments*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   368
goal Arith.thy "!!k l::nat. [|i<=j;  k<=l |] ==> i + k <= j + l";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   369
by (etac (add_le_mono1 RS le_trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   370
by (simp_tac (HOL_ss addsimps [add_commute]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   371
(*j moves to the end because it is free while k, l are bound*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   372
by (eresolve_tac [add_le_mono1] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   373
qed "add_le_mono";