src/HOL/Nat.ML
changeset 923 ff1574a81019
child 962 136308504cd9
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Nat.ML	Fri Mar 03 12:02:25 1995 +0100
     1.3 @@ -0,0 +1,436 @@
     1.4 +(*  Title: 	HOL/nat
     1.5 +    ID:         $Id$
     1.6 +    Author: 	Tobias Nipkow, Cambridge University Computer Laboratory
     1.7 +    Copyright   1991  University of Cambridge
     1.8 +
     1.9 +For nat.thy.  Type nat is defined as a set (Nat) over the type ind.
    1.10 +*)
    1.11 +
    1.12 +open Nat;
    1.13 +
    1.14 +goal Nat.thy "mono(%X. {Zero_Rep} Un (Suc_Rep``X))";
    1.15 +by (REPEAT (ares_tac [monoI, subset_refl, image_mono, Un_mono] 1));
    1.16 +qed "Nat_fun_mono";
    1.17 +
    1.18 +val Nat_unfold = Nat_fun_mono RS (Nat_def RS def_lfp_Tarski);
    1.19 +
    1.20 +(* Zero is a natural number -- this also justifies the type definition*)
    1.21 +goal Nat.thy "Zero_Rep: Nat";
    1.22 +by (rtac (Nat_unfold RS ssubst) 1);
    1.23 +by (rtac (singletonI RS UnI1) 1);
    1.24 +qed "Zero_RepI";
    1.25 +
    1.26 +val prems = goal Nat.thy "i: Nat ==> Suc_Rep(i) : Nat";
    1.27 +by (rtac (Nat_unfold RS ssubst) 1);
    1.28 +by (rtac (imageI RS UnI2) 1);
    1.29 +by (resolve_tac prems 1);
    1.30 +qed "Suc_RepI";
    1.31 +
    1.32 +(*** Induction ***)
    1.33 +
    1.34 +val major::prems = goal Nat.thy
    1.35 +    "[| i: Nat;  P(Zero_Rep);   \
    1.36 +\       !!j. [| j: Nat; P(j) |] ==> P(Suc_Rep(j)) |]  ==> P(i)";
    1.37 +by (rtac ([Nat_def, Nat_fun_mono, major] MRS def_induct) 1);
    1.38 +by (fast_tac (set_cs addIs prems) 1);
    1.39 +qed "Nat_induct";
    1.40 +
    1.41 +val prems = goalw Nat.thy [Zero_def,Suc_def]
    1.42 +    "[| P(0);   \
    1.43 +\       !!k. P(k) ==> P(Suc(k)) |]  ==> P(n)";
    1.44 +by (rtac (Rep_Nat_inverse RS subst) 1);   (*types force good instantiation*)
    1.45 +by (rtac (Rep_Nat RS Nat_induct) 1);
    1.46 +by (REPEAT (ares_tac prems 1
    1.47 +     ORELSE eresolve_tac [Abs_Nat_inverse RS subst] 1));
    1.48 +qed "nat_induct";
    1.49 +
    1.50 +(*Perform induction on n. *)
    1.51 +fun nat_ind_tac a i = 
    1.52 +    EVERY [res_inst_tac [("n",a)] nat_induct i,
    1.53 +	   rename_last_tac a ["1"] (i+1)];
    1.54 +
    1.55 +(*A special form of induction for reasoning about m<n and m-n*)
    1.56 +val prems = goal Nat.thy
    1.57 +    "[| !!x. P x 0;  \
    1.58 +\       !!y. P 0 (Suc y);  \
    1.59 +\       !!x y. [| P x y |] ==> P (Suc x) (Suc y)  \
    1.60 +\    |] ==> P m n";
    1.61 +by (res_inst_tac [("x","m")] spec 1);
    1.62 +by (nat_ind_tac "n" 1);
    1.63 +by (rtac allI 2);
    1.64 +by (nat_ind_tac "x" 2);
    1.65 +by (REPEAT (ares_tac (prems@[allI]) 1 ORELSE etac spec 1));
    1.66 +qed "diff_induct";
    1.67 +
    1.68 +(*Case analysis on the natural numbers*)
    1.69 +val prems = goal Nat.thy 
    1.70 +    "[| n=0 ==> P;  !!x. n = Suc(x) ==> P |] ==> P";
    1.71 +by (subgoal_tac "n=0 | (EX x. n = Suc(x))" 1);
    1.72 +by (fast_tac (HOL_cs addSEs prems) 1);
    1.73 +by (nat_ind_tac "n" 1);
    1.74 +by (rtac (refl RS disjI1) 1);
    1.75 +by (fast_tac HOL_cs 1);
    1.76 +qed "natE";
    1.77 +
    1.78 +(*** Isomorphisms: Abs_Nat and Rep_Nat ***)
    1.79 +
    1.80 +(*We can't take these properties as axioms, or take Abs_Nat==Inv(Rep_Nat),
    1.81 +  since we assume the isomorphism equations will one day be given by Isabelle*)
    1.82 +
    1.83 +goal Nat.thy "inj(Rep_Nat)";
    1.84 +by (rtac inj_inverseI 1);
    1.85 +by (rtac Rep_Nat_inverse 1);
    1.86 +qed "inj_Rep_Nat";
    1.87 +
    1.88 +goal Nat.thy "inj_onto Abs_Nat Nat";
    1.89 +by (rtac inj_onto_inverseI 1);
    1.90 +by (etac Abs_Nat_inverse 1);
    1.91 +qed "inj_onto_Abs_Nat";
    1.92 +
    1.93 +(*** Distinctness of constructors ***)
    1.94 +
    1.95 +goalw Nat.thy [Zero_def,Suc_def] "Suc(m) ~= 0";
    1.96 +by (rtac (inj_onto_Abs_Nat RS inj_onto_contraD) 1);
    1.97 +by (rtac Suc_Rep_not_Zero_Rep 1);
    1.98 +by (REPEAT (resolve_tac [Rep_Nat, Suc_RepI, Zero_RepI] 1));
    1.99 +qed "Suc_not_Zero";
   1.100 +
   1.101 +bind_thm ("Zero_not_Suc", (Suc_not_Zero RS not_sym));
   1.102 +
   1.103 +bind_thm ("Suc_neq_Zero", (Suc_not_Zero RS notE));
   1.104 +val Zero_neq_Suc = sym RS Suc_neq_Zero;
   1.105 +
   1.106 +(** Injectiveness of Suc **)
   1.107 +
   1.108 +goalw Nat.thy [Suc_def] "inj(Suc)";
   1.109 +by (rtac injI 1);
   1.110 +by (dtac (inj_onto_Abs_Nat RS inj_ontoD) 1);
   1.111 +by (REPEAT (resolve_tac [Rep_Nat, Suc_RepI] 1));
   1.112 +by (dtac (inj_Suc_Rep RS injD) 1);
   1.113 +by (etac (inj_Rep_Nat RS injD) 1);
   1.114 +qed "inj_Suc";
   1.115 +
   1.116 +val Suc_inject = inj_Suc RS injD;;
   1.117 +
   1.118 +goal Nat.thy "(Suc(m)=Suc(n)) = (m=n)";
   1.119 +by (EVERY1 [rtac iffI, etac Suc_inject, etac arg_cong]); 
   1.120 +qed "Suc_Suc_eq";
   1.121 +
   1.122 +goal Nat.thy "n ~= Suc(n)";
   1.123 +by (nat_ind_tac "n" 1);
   1.124 +by (ALLGOALS(asm_simp_tac (HOL_ss addsimps [Zero_not_Suc,Suc_Suc_eq])));
   1.125 +qed "n_not_Suc_n";
   1.126 +
   1.127 +val Suc_n_not_n = n_not_Suc_n RS not_sym;
   1.128 +
   1.129 +(*** nat_case -- the selection operator for nat ***)
   1.130 +
   1.131 +goalw Nat.thy [nat_case_def] "nat_case a f 0 = a";
   1.132 +by (fast_tac (set_cs addIs [select_equality] addEs [Zero_neq_Suc]) 1);
   1.133 +qed "nat_case_0";
   1.134 +
   1.135 +goalw Nat.thy [nat_case_def] "nat_case a f (Suc k) = f(k)";
   1.136 +by (fast_tac (set_cs addIs [select_equality] 
   1.137 +	               addEs [make_elim Suc_inject, Suc_neq_Zero]) 1);
   1.138 +qed "nat_case_Suc";
   1.139 +
   1.140 +(** Introduction rules for 'pred_nat' **)
   1.141 +
   1.142 +goalw Nat.thy [pred_nat_def] "<n, Suc(n)> : pred_nat";
   1.143 +by (fast_tac set_cs 1);
   1.144 +qed "pred_natI";
   1.145 +
   1.146 +val major::prems = goalw Nat.thy [pred_nat_def]
   1.147 +    "[| p : pred_nat;  !!x n. [| p = <n, Suc(n)> |] ==> R \
   1.148 +\    |] ==> R";
   1.149 +by (rtac (major RS CollectE) 1);
   1.150 +by (REPEAT (eresolve_tac ([asm_rl,exE]@prems) 1));
   1.151 +qed "pred_natE";
   1.152 +
   1.153 +goalw Nat.thy [wf_def] "wf(pred_nat)";
   1.154 +by (strip_tac 1);
   1.155 +by (nat_ind_tac "x" 1);
   1.156 +by (fast_tac (HOL_cs addSEs [mp, pred_natE, Pair_inject, 
   1.157 +			     make_elim Suc_inject]) 2);
   1.158 +by (fast_tac (HOL_cs addSEs [mp, pred_natE, Pair_inject, Zero_neq_Suc]) 1);
   1.159 +qed "wf_pred_nat";
   1.160 +
   1.161 +
   1.162 +(*** nat_rec -- by wf recursion on pred_nat ***)
   1.163 +
   1.164 +bind_thm ("nat_rec_unfold", (wf_pred_nat RS (nat_rec_def RS def_wfrec)));
   1.165 +
   1.166 +(** conversion rules **)
   1.167 +
   1.168 +goal Nat.thy "nat_rec 0 c h = c";
   1.169 +by (rtac (nat_rec_unfold RS trans) 1);
   1.170 +by (simp_tac (HOL_ss addsimps [nat_case_0]) 1);
   1.171 +qed "nat_rec_0";
   1.172 +
   1.173 +goal Nat.thy "nat_rec (Suc n) c h = h n (nat_rec n c h)";
   1.174 +by (rtac (nat_rec_unfold RS trans) 1);
   1.175 +by (simp_tac (HOL_ss addsimps [nat_case_Suc, pred_natI, cut_apply]) 1);
   1.176 +qed "nat_rec_Suc";
   1.177 +
   1.178 +(*These 2 rules ease the use of primitive recursion.  NOTE USE OF == *)
   1.179 +val [rew] = goal Nat.thy
   1.180 +    "[| !!n. f(n) == nat_rec n c h |] ==> f(0) = c";
   1.181 +by (rewtac rew);
   1.182 +by (rtac nat_rec_0 1);
   1.183 +qed "def_nat_rec_0";
   1.184 +
   1.185 +val [rew] = goal Nat.thy
   1.186 +    "[| !!n. f(n) == nat_rec n c h |] ==> f(Suc(n)) = h n (f n)";
   1.187 +by (rewtac rew);
   1.188 +by (rtac nat_rec_Suc 1);
   1.189 +qed "def_nat_rec_Suc";
   1.190 +
   1.191 +fun nat_recs def =
   1.192 +      [standard (def RS def_nat_rec_0),
   1.193 +       standard (def RS def_nat_rec_Suc)];
   1.194 +
   1.195 +
   1.196 +(*** Basic properties of "less than" ***)
   1.197 +
   1.198 +(** Introduction properties **)
   1.199 +
   1.200 +val prems = goalw Nat.thy [less_def] "[| i<j;  j<k |] ==> i<(k::nat)";
   1.201 +by (rtac (trans_trancl RS transD) 1);
   1.202 +by (resolve_tac prems 1);
   1.203 +by (resolve_tac prems 1);
   1.204 +qed "less_trans";
   1.205 +
   1.206 +goalw Nat.thy [less_def] "n < Suc(n)";
   1.207 +by (rtac (pred_natI RS r_into_trancl) 1);
   1.208 +qed "lessI";
   1.209 +
   1.210 +(* i<j ==> i<Suc(j) *)
   1.211 +val less_SucI = lessI RSN (2, less_trans);
   1.212 +
   1.213 +goal Nat.thy "0 < Suc(n)";
   1.214 +by (nat_ind_tac "n" 1);
   1.215 +by (rtac lessI 1);
   1.216 +by (etac less_trans 1);
   1.217 +by (rtac lessI 1);
   1.218 +qed "zero_less_Suc";
   1.219 +
   1.220 +(** Elimination properties **)
   1.221 +
   1.222 +val prems = goalw Nat.thy [less_def] "n<m ==> ~ m<(n::nat)";
   1.223 +by(fast_tac (HOL_cs addIs ([wf_pred_nat, wf_trancl RS wf_asym]@prems))1);
   1.224 +qed "less_not_sym";
   1.225 +
   1.226 +(* [| n<m; m<n |] ==> R *)
   1.227 +bind_thm ("less_asym", (less_not_sym RS notE));
   1.228 +
   1.229 +goalw Nat.thy [less_def] "~ n<(n::nat)";
   1.230 +by (rtac notI 1);
   1.231 +by (etac (wf_pred_nat RS wf_trancl RS wf_anti_refl) 1);
   1.232 +qed "less_not_refl";
   1.233 +
   1.234 +(* n<n ==> R *)
   1.235 +bind_thm ("less_anti_refl", (less_not_refl RS notE));
   1.236 +
   1.237 +goal Nat.thy "!!m. n<m ==> m ~= (n::nat)";
   1.238 +by(fast_tac (HOL_cs addEs [less_anti_refl]) 1);
   1.239 +qed "less_not_refl2";
   1.240 +
   1.241 +
   1.242 +val major::prems = goalw Nat.thy [less_def]
   1.243 +    "[| i<k;  k=Suc(i) ==> P;  !!j. [| i<j;  k=Suc(j) |] ==> P \
   1.244 +\    |] ==> P";
   1.245 +by (rtac (major RS tranclE) 1);
   1.246 +by (fast_tac (HOL_cs addSEs (prems@[pred_natE, Pair_inject])) 1);
   1.247 +by (fast_tac (HOL_cs addSEs (prems@[pred_natE, Pair_inject])) 1);
   1.248 +qed "lessE";
   1.249 +
   1.250 +goal Nat.thy "~ n<0";
   1.251 +by (rtac notI 1);
   1.252 +by (etac lessE 1);
   1.253 +by (etac Zero_neq_Suc 1);
   1.254 +by (etac Zero_neq_Suc 1);
   1.255 +qed "not_less0";
   1.256 +
   1.257 +(* n<0 ==> R *)
   1.258 +bind_thm ("less_zeroE", (not_less0 RS notE));
   1.259 +
   1.260 +val [major,less,eq] = goal Nat.thy
   1.261 +    "[| m < Suc(n);  m<n ==> P;  m=n ==> P |] ==> P";
   1.262 +by (rtac (major RS lessE) 1);
   1.263 +by (rtac eq 1);
   1.264 +by (fast_tac (HOL_cs addSDs [Suc_inject]) 1);
   1.265 +by (rtac less 1);
   1.266 +by (fast_tac (HOL_cs addSDs [Suc_inject]) 1);
   1.267 +qed "less_SucE";
   1.268 +
   1.269 +goal Nat.thy "(m < Suc(n)) = (m < n | m = n)";
   1.270 +by (fast_tac (HOL_cs addSIs [lessI]
   1.271 +		     addEs  [less_trans, less_SucE]) 1);
   1.272 +qed "less_Suc_eq";
   1.273 +
   1.274 +
   1.275 +(** Inductive (?) properties **)
   1.276 +
   1.277 +val [prem] = goal Nat.thy "Suc(m) < n ==> m<n";
   1.278 +by (rtac (prem RS rev_mp) 1);
   1.279 +by (nat_ind_tac "n" 1);
   1.280 +by (rtac impI 1);
   1.281 +by (etac less_zeroE 1);
   1.282 +by (fast_tac (HOL_cs addSIs [lessI RS less_SucI]
   1.283 +	 	     addSDs [Suc_inject]
   1.284 +		     addEs  [less_trans, lessE]) 1);
   1.285 +qed "Suc_lessD";
   1.286 +
   1.287 +val [major,minor] = goal Nat.thy 
   1.288 +    "[| Suc(i)<k;  !!j. [| i<j;  k=Suc(j) |] ==> P \
   1.289 +\    |] ==> P";
   1.290 +by (rtac (major RS lessE) 1);
   1.291 +by (etac (lessI RS minor) 1);
   1.292 +by (etac (Suc_lessD RS minor) 1);
   1.293 +by (assume_tac 1);
   1.294 +qed "Suc_lessE";
   1.295 +
   1.296 +val [major] = goal Nat.thy "Suc(m) < Suc(n) ==> m<n";
   1.297 +by (rtac (major RS lessE) 1);
   1.298 +by (REPEAT (rtac lessI 1
   1.299 +     ORELSE eresolve_tac [make_elim Suc_inject, ssubst, Suc_lessD] 1));
   1.300 +qed "Suc_less_SucD";
   1.301 +
   1.302 +val prems = goal Nat.thy "m<n ==> Suc(m) < Suc(n)";
   1.303 +by (subgoal_tac "m<n --> Suc(m) < Suc(n)" 1);
   1.304 +by (fast_tac (HOL_cs addIs prems) 1);
   1.305 +by (nat_ind_tac "n" 1);
   1.306 +by (rtac impI 1);
   1.307 +by (etac less_zeroE 1);
   1.308 +by (fast_tac (HOL_cs addSIs [lessI]
   1.309 +	 	     addSDs [Suc_inject]
   1.310 +		     addEs  [less_trans, lessE]) 1);
   1.311 +qed "Suc_mono";
   1.312 +
   1.313 +goal Nat.thy "(Suc(m) < Suc(n)) = (m<n)";
   1.314 +by (EVERY1 [rtac iffI, etac Suc_less_SucD, etac Suc_mono]);
   1.315 +qed "Suc_less_eq";
   1.316 +
   1.317 +goal Nat.thy "~(Suc(n) < n)";
   1.318 +by(fast_tac (HOL_cs addEs [Suc_lessD RS less_anti_refl]) 1);
   1.319 +qed "not_Suc_n_less_n";
   1.320 +
   1.321 +(*"Less than" is a linear ordering*)
   1.322 +goal Nat.thy "m<n | m=n | n<(m::nat)";
   1.323 +by (nat_ind_tac "m" 1);
   1.324 +by (nat_ind_tac "n" 1);
   1.325 +by (rtac (refl RS disjI1 RS disjI2) 1);
   1.326 +by (rtac (zero_less_Suc RS disjI1) 1);
   1.327 +by (fast_tac (HOL_cs addIs [lessI, Suc_mono, less_SucI] addEs [lessE]) 1);
   1.328 +qed "less_linear";
   1.329 +
   1.330 +(*Can be used with less_Suc_eq to get n=m | n<m *)
   1.331 +goal Nat.thy "(~ m < n) = (n < Suc(m))";
   1.332 +by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   1.333 +by(ALLGOALS(asm_simp_tac (HOL_ss addsimps
   1.334 +                          [not_less0,zero_less_Suc,Suc_less_eq])));
   1.335 +qed "not_less_eq";
   1.336 +
   1.337 +(*Complete induction, aka course-of-values induction*)
   1.338 +val prems = goalw Nat.thy [less_def]
   1.339 +    "[| !!n. [| ! m::nat. m<n --> P(m) |] ==> P(n) |]  ==>  P(n)";
   1.340 +by (wf_ind_tac "n" [wf_pred_nat RS wf_trancl] 1);
   1.341 +by (eresolve_tac prems 1);
   1.342 +qed "less_induct";
   1.343 +
   1.344 +
   1.345 +(*** Properties of <= ***)
   1.346 +
   1.347 +goalw Nat.thy [le_def] "0 <= n";
   1.348 +by (rtac not_less0 1);
   1.349 +qed "le0";
   1.350 +
   1.351 +val nat_simps = [not_less0, less_not_refl, zero_less_Suc, lessI, 
   1.352 +		 Suc_less_eq, less_Suc_eq, le0, not_Suc_n_less_n,
   1.353 +		 Suc_not_Zero, Zero_not_Suc, Suc_Suc_eq,
   1.354 +		 n_not_Suc_n, Suc_n_not_n,
   1.355 +		 nat_case_0, nat_case_Suc, nat_rec_0, nat_rec_Suc];
   1.356 +
   1.357 +val nat_ss0 = sum_ss  addsimps  nat_simps;
   1.358 +
   1.359 +(*Prevents simplification of f and g: much faster*)
   1.360 +qed_goal "nat_case_weak_cong" Nat.thy
   1.361 +  "m=n ==> nat_case a f m = nat_case a f n"
   1.362 +  (fn [prem] => [rtac (prem RS arg_cong) 1]);
   1.363 +
   1.364 +qed_goal "nat_rec_weak_cong" Nat.thy
   1.365 +  "m=n ==> nat_rec m a f = nat_rec n a f"
   1.366 +  (fn [prem] => [rtac (prem RS arg_cong) 1]);
   1.367 +
   1.368 +val prems = goalw Nat.thy [le_def] "~(n<m) ==> m<=(n::nat)";
   1.369 +by (resolve_tac prems 1);
   1.370 +qed "leI";
   1.371 +
   1.372 +val prems = goalw Nat.thy [le_def] "m<=n ==> ~(n<(m::nat))";
   1.373 +by (resolve_tac prems 1);
   1.374 +qed "leD";
   1.375 +
   1.376 +val leE = make_elim leD;
   1.377 +
   1.378 +goalw Nat.thy [le_def] "!!m. ~ m <= n ==> n<(m::nat)";
   1.379 +by (fast_tac HOL_cs 1);
   1.380 +qed "not_leE";
   1.381 +
   1.382 +goalw Nat.thy [le_def] "!!m. m < n ==> Suc(m) <= n";
   1.383 +by(simp_tac nat_ss0 1);
   1.384 +by (fast_tac (HOL_cs addEs [less_anti_refl,less_asym]) 1);
   1.385 +qed "lessD";
   1.386 +
   1.387 +goalw Nat.thy [le_def] "!!m. Suc(m) <= n ==> m <= n";
   1.388 +by(asm_full_simp_tac nat_ss0 1);
   1.389 +by(fast_tac HOL_cs 1);
   1.390 +qed "Suc_leD";
   1.391 +
   1.392 +goalw Nat.thy [le_def] "!!m. m < n ==> m <= (n::nat)";
   1.393 +by (fast_tac (HOL_cs addEs [less_asym]) 1);
   1.394 +qed "less_imp_le";
   1.395 +
   1.396 +goalw Nat.thy [le_def] "!!m. m <= n ==> m < n | m=(n::nat)";
   1.397 +by (cut_facts_tac [less_linear] 1);
   1.398 +by (fast_tac (HOL_cs addEs [less_anti_refl,less_asym]) 1);
   1.399 +qed "le_imp_less_or_eq";
   1.400 +
   1.401 +goalw Nat.thy [le_def] "!!m. m<n | m=n ==> m <=(n::nat)";
   1.402 +by (cut_facts_tac [less_linear] 1);
   1.403 +by (fast_tac (HOL_cs addEs [less_anti_refl,less_asym]) 1);
   1.404 +by (flexflex_tac);
   1.405 +qed "less_or_eq_imp_le";
   1.406 +
   1.407 +goal Nat.thy "(x <= (y::nat)) = (x < y | x=y)";
   1.408 +by (REPEAT(ares_tac [iffI,less_or_eq_imp_le,le_imp_less_or_eq] 1));
   1.409 +qed "le_eq_less_or_eq";
   1.410 +
   1.411 +goal Nat.thy "n <= (n::nat)";
   1.412 +by(simp_tac (HOL_ss addsimps [le_eq_less_or_eq]) 1);
   1.413 +qed "le_refl";
   1.414 +
   1.415 +val prems = goal Nat.thy "!!i. [| i <= j; j < k |] ==> i < (k::nat)";
   1.416 +by (dtac le_imp_less_or_eq 1);
   1.417 +by (fast_tac (HOL_cs addIs [less_trans]) 1);
   1.418 +qed "le_less_trans";
   1.419 +
   1.420 +goal Nat.thy "!!i. [| i < j; j <= k |] ==> i < (k::nat)";
   1.421 +by (dtac le_imp_less_or_eq 1);
   1.422 +by (fast_tac (HOL_cs addIs [less_trans]) 1);
   1.423 +qed "less_le_trans";
   1.424 +
   1.425 +goal Nat.thy "!!i. [| i <= j; j <= k |] ==> i <= (k::nat)";
   1.426 +by (EVERY1[dtac le_imp_less_or_eq, dtac le_imp_less_or_eq,
   1.427 +          rtac less_or_eq_imp_le, fast_tac (HOL_cs addIs [less_trans])]);
   1.428 +qed "le_trans";
   1.429 +
   1.430 +val prems = goal Nat.thy "!!m. [| m <= n; n <= m |] ==> m = (n::nat)";
   1.431 +by (EVERY1[dtac le_imp_less_or_eq, dtac le_imp_less_or_eq,
   1.432 +          fast_tac (HOL_cs addEs [less_anti_refl,less_asym])]);
   1.433 +qed "le_anti_sym";
   1.434 +
   1.435 +goal Nat.thy "(Suc(n) <= Suc(m)) = (n <= m)";
   1.436 +by (simp_tac (nat_ss0 addsimps [le_eq_less_or_eq]) 1);
   1.437 +qed "Suc_le_mono";
   1.438 +
   1.439 +val nat_ss = nat_ss0 addsimps [le_refl];