src/HOL/Arith.ML
 author clasohm Wed Oct 04 13:10:03 1995 +0100 (1995-10-04) changeset 1264 3eb91524b938 parent 1198 23be92d5bf4d child 1301 42782316d510 permissions -rw-r--r--
added local simpsets; removed IOA from 'make test'
 clasohm@923 ` 1` ```(* Title: HOL/Arith.ML ``` clasohm@923 ` 2` ``` ID: \$Id\$ ``` clasohm@923 ` 3` ``` Author: Lawrence C Paulson, Cambridge University Computer Laboratory ``` clasohm@923 ` 4` ``` Copyright 1993 University of Cambridge ``` clasohm@923 ` 5` clasohm@923 ` 6` ```Proofs about elementary arithmetic: addition, multiplication, etc. ``` clasohm@923 ` 7` ```Tests definitions and simplifier. ``` clasohm@923 ` 8` ```*) ``` clasohm@923 ` 9` clasohm@923 ` 10` ```open Arith; ``` clasohm@923 ` 11` clasohm@923 ` 12` ```(*** Basic rewrite rules for the arithmetic operators ***) ``` clasohm@923 ` 13` clasohm@923 ` 14` ```val [pred_0, pred_Suc] = nat_recs pred_def; ``` clasohm@923 ` 15` ```val [add_0,add_Suc] = nat_recs add_def; ``` clasohm@923 ` 16` ```val [mult_0,mult_Suc] = nat_recs mult_def; ``` clasohm@923 ` 17` clasohm@923 ` 18` ```(** Difference **) ``` clasohm@923 ` 19` clasohm@923 ` 20` ```val diff_0 = diff_def RS def_nat_rec_0; ``` clasohm@923 ` 21` clasohm@923 ` 22` ```qed_goalw "diff_0_eq_0" Arith.thy [diff_def, pred_def] ``` clasohm@923 ` 23` ``` "0 - n = 0" ``` clasohm@1264 ` 24` ``` (fn _ => [nat_ind_tac "n" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 25` clasohm@923 ` 26` ```(*Must simplify BEFORE the induction!! (Else we get a critical pair) ``` clasohm@923 ` 27` ``` Suc(m) - Suc(n) rewrites to pred(Suc(m) - n) *) ``` clasohm@923 ` 28` ```qed_goalw "diff_Suc_Suc" Arith.thy [diff_def, pred_def] ``` clasohm@923 ` 29` ``` "Suc(m) - Suc(n) = m - n" ``` clasohm@923 ` 30` ``` (fn _ => ``` clasohm@1264 ` 31` ``` [Simp_tac 1, nat_ind_tac "n" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 32` clasohm@923 ` 33` ```(*** Simplification over add, mult, diff ***) ``` clasohm@923 ` 34` clasohm@1264 ` 35` ```Addsimps [pred_0, pred_Suc, add_0, add_Suc, mult_0, mult_Suc, diff_0, ``` clasohm@1264 ` 36` ``` diff_0_eq_0, diff_Suc_Suc]; ``` clasohm@923 ` 37` clasohm@923 ` 38` clasohm@923 ` 39` ```(**** Inductive properties of the operators ****) ``` clasohm@923 ` 40` clasohm@923 ` 41` ```(*** Addition ***) ``` clasohm@923 ` 42` clasohm@923 ` 43` ```qed_goal "add_0_right" Arith.thy "m + 0 = m" ``` clasohm@1264 ` 44` ``` (fn _ => [nat_ind_tac "m" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 45` clasohm@923 ` 46` ```qed_goal "add_Suc_right" Arith.thy "m + Suc(n) = Suc(m+n)" ``` clasohm@1264 ` 47` ``` (fn _ => [nat_ind_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*) ``` clasohm@923 ` 52` ```qed_goal "add_assoc" Arith.thy "(m + n) + k = m + ((n + k)::nat)" ``` clasohm@1264 ` 53` ``` (fn _ => [nat_ind_tac "m" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 54` clasohm@923 ` 55` ```(*Commutative law for addition*) ``` clasohm@923 ` 56` ```qed_goal "add_commute" Arith.thy "m + n = n + (m::nat)" ``` clasohm@1264 ` 57` ``` (fn _ => [nat_ind_tac "m" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 58` clasohm@923 ` 59` ```qed_goal "add_left_commute" Arith.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` clasohm@923 ` 66` ```goal Arith.thy "!!k::nat. (k + m = k + n) = (m=n)"; ``` clasohm@923 ` 67` ```by (nat_ind_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` clasohm@923 ` 72` ```goal Arith.thy "!!k::nat. (m + k = n + k) = (m=n)"; ``` clasohm@923 ` 73` ```by (nat_ind_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` clasohm@923 ` 78` ```goal Arith.thy "!!k::nat. (k + m <= k + n) = (m<=n)"; ``` clasohm@923 ` 79` ```by (nat_ind_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` clasohm@923 ` 84` ```goal Arith.thy "!!k::nat. (k + m < k + n) = (m [nat_ind_tac "m" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 95` clasohm@923 ` 96` ```(*right Sucessor law for multiplication*) ``` clasohm@923 ` 97` ```qed_goal "mult_Suc_right" Arith.thy "m * Suc(n) = m + (m * n)" ``` clasohm@923 ` 98` ``` (fn _ => [nat_ind_tac "m" 1, ``` clasohm@1264 ` 99` ``` ALLGOALS(asm_simp_tac (!simpset addsimps add_ac))]); ``` clasohm@923 ` 100` clasohm@1264 ` 101` ```Addsimps [mult_0_right,mult_Suc_right]; ``` clasohm@923 ` 102` clasohm@923 ` 103` ```(*Commutative law for multiplication*) ``` clasohm@923 ` 104` ```qed_goal "mult_commute" Arith.thy "m * n = n * (m::nat)" ``` clasohm@1264 ` 105` ``` (fn _ => [nat_ind_tac "m" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 106` clasohm@923 ` 107` ```(*addition distributes over multiplication*) ``` clasohm@923 ` 108` ```qed_goal "add_mult_distrib" Arith.thy "(m + n)*k = (m*k) + ((n*k)::nat)" ``` clasohm@923 ` 109` ``` (fn _ => [nat_ind_tac "m" 1, ``` clasohm@1264 ` 110` ``` ALLGOALS(asm_simp_tac (!simpset addsimps add_ac))]); ``` clasohm@923 ` 111` clasohm@923 ` 112` ```qed_goal "add_mult_distrib2" Arith.thy "k*(m + n) = (k*m) + ((k*n)::nat)" ``` clasohm@923 ` 113` ``` (fn _ => [nat_ind_tac "m" 1, ``` clasohm@1264 ` 114` ``` ALLGOALS(asm_simp_tac (!simpset addsimps add_ac))]); ``` clasohm@923 ` 115` clasohm@1264 ` 116` ```Addsimps [add_mult_distrib,add_mult_distrib2]; ``` clasohm@923 ` 117` clasohm@923 ` 118` ```(*Associative law for multiplication*) ``` clasohm@923 ` 119` ```qed_goal "mult_assoc" Arith.thy "(m * n) * k = m * ((n * k)::nat)" ``` clasohm@1264 ` 120` ``` (fn _ => [nat_ind_tac "m" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 121` clasohm@923 ` 122` ```qed_goal "mult_left_commute" Arith.thy "x*(y*z) = y*((x*z)::nat)" ``` clasohm@923 ` 123` ``` (fn _ => [rtac trans 1, rtac mult_commute 1, rtac trans 1, ``` clasohm@923 ` 124` ``` rtac mult_assoc 1, rtac (mult_commute RS arg_cong) 1]); ``` clasohm@923 ` 125` clasohm@923 ` 126` ```val mult_ac = [mult_assoc,mult_commute,mult_left_commute]; ``` clasohm@923 ` 127` clasohm@923 ` 128` ```(*** Difference ***) ``` clasohm@923 ` 129` clasohm@923 ` 130` ```qed_goal "diff_self_eq_0" Arith.thy "m - m = 0" ``` clasohm@1264 ` 131` ``` (fn _ => [nat_ind_tac "m" 1, ALLGOALS Asm_simp_tac]); ``` clasohm@923 ` 132` clasohm@923 ` 133` ```(*Addition is the inverse of subtraction: if n<=m then n+(m-n) = m. *) ``` clasohm@923 ` 134` ```val [prem] = goal Arith.thy "[| ~ m n+(m-n) = (m::nat)"; ``` clasohm@923 ` 135` ```by (rtac (prem RS rev_mp) 1); ``` clasohm@923 ` 136` ```by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); ``` clasohm@1264 ` 137` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 138` ```qed "add_diff_inverse"; ``` clasohm@923 ` 139` clasohm@923 ` 140` clasohm@923 ` 141` ```(*** Remainder ***) ``` clasohm@923 ` 142` clasohm@923 ` 143` ```goal Arith.thy "m - n < Suc(m)"; ``` clasohm@923 ` 144` ```by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); ``` clasohm@923 ` 145` ```by (etac less_SucE 3); ``` clasohm@1264 ` 146` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 147` ```qed "diff_less_Suc"; ``` clasohm@923 ` 148` clasohm@923 ` 149` ```goal Arith.thy "!!m::nat. m - n <= m"; ``` clasohm@923 ` 150` ```by (res_inst_tac [("m","m"), ("n","n")] diff_induct 1); ``` clasohm@1264 ` 151` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 152` ```by (etac le_trans 1); ``` clasohm@1264 ` 153` ```by (simp_tac (!simpset addsimps [le_eq_less_or_eq]) 1); ``` clasohm@923 ` 154` ```qed "diff_le_self"; ``` clasohm@923 ` 155` clasohm@923 ` 156` ```goal Arith.thy "!!n::nat. (n+m) - n = m"; ``` clasohm@923 ` 157` ```by (nat_ind_tac "n" 1); ``` clasohm@1264 ` 158` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 159` ```qed "diff_add_inverse"; ``` clasohm@923 ` 160` clasohm@923 ` 161` ```goal Arith.thy "!!n::nat. n - (n+m) = 0"; ``` clasohm@923 ` 162` ```by (nat_ind_tac "n" 1); ``` clasohm@1264 ` 163` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 164` ```qed "diff_add_0"; ``` clasohm@923 ` 165` clasohm@923 ` 166` ```(*In ordinary notation: if 0 m - n < m"; ``` clasohm@923 ` 168` ```by (subgoal_tac "0 ~ m m - n < m" 1); ``` clasohm@923 ` 169` ```by (fast_tac HOL_cs 1); ``` clasohm@923 ` 170` ```by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); ``` clasohm@1264 ` 171` ```by (ALLGOALS(asm_simp_tac(!simpset addsimps [diff_less_Suc]))); ``` clasohm@923 ` 172` ```qed "div_termination"; ``` clasohm@923 ` 173` clasohm@923 ` 174` ```val wf_less_trans = wf_pred_nat RS wf_trancl RSN (2, def_wfrec RS trans); ``` clasohm@923 ` 175` clasohm@972 ` 176` ```goalw Nat.thy [less_def] "(m,n) : pred_nat^+ = (m m mod n = m"; ``` clasohm@923 ` 181` ```by (rtac (mod_def RS wf_less_trans) 1); ``` clasohm@1264 ` 182` ```by(Asm_simp_tac 1); ``` clasohm@923 ` 183` ```qed "mod_less"; ``` clasohm@923 ` 184` clasohm@923 ` 185` ```goal Arith.thy "!!m. [| 0 m mod n = (m-n) mod n"; ``` clasohm@923 ` 186` ```by (rtac (mod_def RS wf_less_trans) 1); ``` clasohm@1264 ` 187` ```by(asm_simp_tac (!simpset addsimps [div_termination, cut_apply, less_eq]) 1); ``` clasohm@923 ` 188` ```qed "mod_geq"; ``` clasohm@923 ` 189` clasohm@923 ` 190` clasohm@923 ` 191` ```(*** Quotient ***) ``` clasohm@923 ` 192` clasohm@923 ` 193` ```goal Arith.thy "!!m. m m div n = 0"; ``` clasohm@923 ` 194` ```by (rtac (div_def RS wf_less_trans) 1); ``` clasohm@1264 ` 195` ```by(Asm_simp_tac 1); ``` clasohm@923 ` 196` ```qed "div_less"; ``` clasohm@923 ` 197` clasohm@923 ` 198` ```goal Arith.thy "!!M. [| 0 m div n = Suc((m-n) div n)"; ``` clasohm@923 ` 199` ```by (rtac (div_def RS wf_less_trans) 1); ``` clasohm@1264 ` 200` ```by(asm_simp_tac (!simpset addsimps [div_termination, cut_apply, less_eq]) 1); ``` clasohm@923 ` 201` ```qed "div_geq"; ``` clasohm@923 ` 202` clasohm@923 ` 203` ```(*Main Result about quotient and remainder.*) ``` clasohm@923 ` 204` ```goal Arith.thy "!!m. 0 (m div n)*n + m mod n = m"; ``` clasohm@923 ` 205` ```by (res_inst_tac [("n","m")] less_induct 1); ``` clasohm@923 ` 206` ```by (rename_tac "k" 1); (*Variable name used in line below*) ``` clasohm@923 ` 207` ```by (case_tac "k m-n = 0"; ``` clasohm@923 ` 217` ```by (rtac (prem RS rev_mp) 1); ``` clasohm@923 ` 218` ```by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); ``` clasohm@1264 ` 219` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 220` ```qed "less_imp_diff_is_0"; ``` clasohm@923 ` 221` clasohm@923 ` 222` ```val prems = goal Arith.thy "m-n = 0 --> n-m = 0 --> m=n"; ``` clasohm@923 ` 223` ```by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); ``` clasohm@1264 ` 224` ```by (REPEAT(Simp_tac 1 THEN TRY(atac 1))); ``` clasohm@923 ` 225` ```qed "diffs0_imp_equal_lemma"; ``` clasohm@923 ` 226` clasohm@923 ` 227` ```(* [| m-n = 0; n-m = 0 |] ==> m=n *) ``` clasohm@923 ` 228` ```bind_thm ("diffs0_imp_equal", (diffs0_imp_equal_lemma RS mp RS mp)); ``` clasohm@923 ` 229` clasohm@923 ` 230` ```val [prem] = goal Arith.thy "m 0 Suc(m)-n = Suc(m-n)"; ``` clasohm@923 ` 237` ```by (rtac (prem RS rev_mp) 1); ``` clasohm@923 ` 238` ```by (res_inst_tac [("m","m"),("n","n")] diff_induct 1); ``` clasohm@1264 ` 239` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 240` ```qed "Suc_diff_n"; ``` clasohm@923 ` 241` clasohm@965 ` 242` ```goal Arith.thy "Suc(m)-n = (if m (!n. P(Suc(n))--> P(n)) --> P(k-i)"; ``` clasohm@923 ` 248` ```by (res_inst_tac [("m","k"),("n","i")] diff_induct 1); ``` clasohm@1264 ` 249` ```by (ALLGOALS (strip_tac THEN' Simp_tac THEN' TRY o fast_tac HOL_cs)); ``` clasohm@923 ` 250` ```qed "zero_induct_lemma"; ``` clasohm@923 ` 251` clasohm@923 ` 252` ```val prems = goal Arith.thy "[| P(k); !!n. P(Suc(n)) ==> P(n) |] ==> P(0)"; ``` clasohm@923 ` 253` ```by (rtac (diff_self_eq_0 RS subst) 1); ``` clasohm@923 ` 254` ```by (rtac (zero_induct_lemma RS mp RS mp) 1); ``` clasohm@923 ` 255` ```by (REPEAT (ares_tac ([impI,allI]@prems) 1)); ``` clasohm@923 ` 256` ```qed "zero_induct"; ``` clasohm@923 ` 257` clasohm@923 ` 258` ```(*13 July 1992: loaded in 105.7s*) ``` clasohm@923 ` 259` clasohm@923 ` 260` ```(**** Additional theorems about "less than" ****) ``` clasohm@923 ` 261` clasohm@923 ` 262` ```goal Arith.thy "!!m. m (? k. n=Suc(m+k))"; ``` clasohm@923 ` 263` ```by (nat_ind_tac "n" 1); ``` clasohm@1264 ` 264` ```by (ALLGOALS(Simp_tac)); ``` clasohm@923 ` 265` ```by (REPEAT_FIRST (ares_tac [conjI, impI])); ``` clasohm@923 ` 266` ```by (res_inst_tac [("x","0")] exI 2); ``` clasohm@1264 ` 267` ```by (Simp_tac 2); ``` clasohm@923 ` 268` ```by (safe_tac HOL_cs); ``` clasohm@923 ` 269` ```by (res_inst_tac [("x","Suc(k)")] exI 1); ``` clasohm@1264 ` 270` ```by (Simp_tac 1); ``` clasohm@923 ` 271` ```val less_eq_Suc_add_lemma = result(); ``` clasohm@923 ` 272` clasohm@923 ` 273` ```(*"m ? k. n = Suc(m+k)"*) ``` clasohm@923 ` 274` ```bind_thm ("less_eq_Suc_add", less_eq_Suc_add_lemma RS mp); ``` clasohm@923 ` 275` clasohm@923 ` 276` clasohm@923 ` 277` ```goal Arith.thy "n <= ((m + n)::nat)"; ``` clasohm@923 ` 278` ```by (nat_ind_tac "m" 1); ``` clasohm@1264 ` 279` ```by (ALLGOALS Simp_tac); ``` clasohm@923 ` 280` ```by (etac le_trans 1); ``` clasohm@923 ` 281` ```by (rtac (lessI RS less_imp_le) 1); ``` clasohm@923 ` 282` ```qed "le_add2"; ``` clasohm@923 ` 283` clasohm@923 ` 284` ```goal Arith.thy "n <= ((n + m)::nat)"; ``` clasohm@1264 ` 285` ```by (simp_tac (!simpset addsimps add_ac) 1); ``` clasohm@923 ` 286` ```by (rtac le_add2 1); ``` clasohm@923 ` 287` ```qed "le_add1"; ``` clasohm@923 ` 288` clasohm@923 ` 289` ```bind_thm ("less_add_Suc1", (lessI RS (le_add1 RS le_less_trans))); ``` clasohm@923 ` 290` ```bind_thm ("less_add_Suc2", (lessI RS (le_add2 RS le_less_trans))); ``` clasohm@923 ` 291` clasohm@923 ` 292` ```(*"i <= j ==> i <= j+m"*) ``` clasohm@923 ` 293` ```bind_thm ("trans_le_add1", le_add1 RSN (2,le_trans)); ``` clasohm@923 ` 294` clasohm@923 ` 295` ```(*"i <= j ==> i <= m+j"*) ``` clasohm@923 ` 296` ```bind_thm ("trans_le_add2", le_add2 RSN (2,le_trans)); ``` clasohm@923 ` 297` clasohm@923 ` 298` ```(*"i < j ==> i < j+m"*) ``` clasohm@923 ` 299` ```bind_thm ("trans_less_add1", le_add1 RSN (2,less_le_trans)); ``` clasohm@923 ` 300` clasohm@923 ` 301` ```(*"i < j ==> i < m+j"*) ``` clasohm@923 ` 302` ```bind_thm ("trans_less_add2", le_add2 RSN (2,less_le_trans)); ``` clasohm@923 ` 303` nipkow@1152 ` 304` ```goal Arith.thy "!!i. i+j < (k::nat) ==> i m <= n+k"; ``` clasohm@923 ` 312` ```by (eresolve_tac [le_trans] 1); ``` clasohm@923 ` 313` ```by (resolve_tac [le_add1] 1); ``` clasohm@923 ` 314` ```qed "le_imp_add_le"; ``` clasohm@923 ` 315` clasohm@923 ` 316` ```goal Arith.thy "!!k::nat. m < n ==> m < n+k"; ``` clasohm@923 ` 317` ```by (eresolve_tac [less_le_trans] 1); ``` clasohm@923 ` 318` ```by (resolve_tac [le_add1] 1); ``` clasohm@923 ` 319` ```qed "less_imp_add_less"; ``` clasohm@923 ` 320` clasohm@923 ` 321` ```goal Arith.thy "m+k<=n --> m<=(n::nat)"; ``` clasohm@923 ` 322` ```by (nat_ind_tac "k" 1); ``` clasohm@1264 ` 323` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 324` ```by (fast_tac (HOL_cs addDs [Suc_leD]) 1); ``` clasohm@923 ` 325` ```val add_leD1_lemma = result(); ``` clasohm@1264 ` 326` ```bind_thm ("add_leD1", add_leD1_lemma RS mp); ``` clasohm@923 ` 327` clasohm@923 ` 328` ```goal Arith.thy "!!k l::nat. [| k m i + k < j + k"; ``` clasohm@923 ` 344` ```by (nat_ind_tac "k" 1); ``` clasohm@1264 ` 345` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 346` ```qed "add_less_mono1"; ``` clasohm@923 ` 347` clasohm@923 ` 348` ```(*strict, in both arguments*) ``` clasohm@923 ` 349` ```goal Arith.thy "!!i j k::nat. [|i < j; k < l|] ==> i + k < j + l"; ``` clasohm@923 ` 350` ```by (rtac (add_less_mono1 RS less_trans) 1); ``` lcp@1198 ` 351` ```by (REPEAT (assume_tac 1)); ``` clasohm@923 ` 352` ```by (nat_ind_tac "j" 1); ``` clasohm@1264 ` 353` ```by (ALLGOALS Asm_simp_tac); ``` clasohm@923 ` 354` ```qed "add_less_mono"; ``` clasohm@923 ` 355` clasohm@923 ` 356` ```(*A [clumsy] way of lifting < monotonicity to <= monotonicity *) ``` clasohm@923 ` 357` ```val [lt_mono,le] = goal Arith.thy ``` clasohm@923 ` 358` ``` "[| !!i j::nat. i f(i) < f(j); \ ``` clasohm@923 ` 359` ```\ i <= j \ ``` clasohm@923 ` 360` ```\ |] ==> f(i) <= (f(j)::nat)"; ``` clasohm@923 ` 361` ```by (cut_facts_tac [le] 1); ``` clasohm@1264 ` 362` ```by (asm_full_simp_tac (!simpset addsimps [le_eq_less_or_eq]) 1); ``` clasohm@923 ` 363` ```by (fast_tac (HOL_cs addSIs [lt_mono]) 1); ``` clasohm@923 ` 364` ```qed "less_mono_imp_le_mono"; ``` clasohm@923 ` 365` clasohm@923 ` 366` ```(*non-strict, in 1st argument*) ``` clasohm@923 ` 367` ```goal Arith.thy "!!i j k::nat. i<=j ==> i + k <= j + k"; ``` clasohm@923 ` 368` ```by (res_inst_tac [("f", "%j.j+k")] less_mono_imp_le_mono 1); ``` clasohm@923 ` 369` ```by (eresolve_tac [add_less_mono1] 1); ``` clasohm@923 ` 370` ```by (assume_tac 1); ``` clasohm@923 ` 371` ```qed "add_le_mono1"; ``` clasohm@923 ` 372` clasohm@923 ` 373` ```(*non-strict, in both arguments*) ``` clasohm@923 ` 374` ```goal Arith.thy "!!k l::nat. [|i<=j; k<=l |] ==> i + k <= j + l"; ``` clasohm@923 ` 375` ```by (etac (add_le_mono1 RS le_trans) 1); ``` clasohm@1264 ` 376` ```by (simp_tac (!simpset addsimps [add_commute]) 1); ``` clasohm@923 ` 377` ```(*j moves to the end because it is free while k, l are bound*) ``` clasohm@923 ` 378` ```by (eresolve_tac [add_le_mono1] 1); ``` clasohm@923 ` 379` ```qed "add_le_mono"; ```