src/HOL/NatDef.ML
author wenzelm
Thu Jun 22 23:04:34 2000 +0200 (2000-06-22)
changeset 9108 9fff97d29837
parent 8942 6aad5381ba83
child 9160 7a98dbf3e579
permissions -rw-r--r--
bind_thm(s);
     1 (*  Title:      HOL/NatDef.ML
     2     ID:         $Id$
     3     Author:     Tobias Nipkow, Cambridge University Computer Laboratory
     4     Copyright   1991  University of Cambridge
     5 *)
     6 
     7 Goal "mono(%X. {Zero_Rep} Un (Suc_Rep``X))";
     8 by (REPEAT (ares_tac [monoI, subset_refl, image_mono, Un_mono] 1));
     9 qed "Nat_fun_mono";
    10 
    11 bind_thm ("Nat_unfold", Nat_fun_mono RS (Nat_def RS def_lfp_Tarski));
    12 
    13 (* Zero is a natural number -- this also justifies the type definition*)
    14 Goal "Zero_Rep: Nat";
    15 by (stac Nat_unfold 1);
    16 by (rtac (singletonI RS UnI1) 1);
    17 qed "Zero_RepI";
    18 
    19 Goal "i: Nat ==> Suc_Rep(i) : Nat";
    20 by (stac Nat_unfold 1);
    21 by (rtac (imageI RS UnI2) 1);
    22 by (assume_tac 1);
    23 qed "Suc_RepI";
    24 
    25 (*** Induction ***)
    26 
    27 val major::prems = Goal
    28     "[| i: Nat;  P(Zero_Rep);   \
    29 \       !!j. [| j: Nat; P(j) |] ==> P(Suc_Rep(j)) |]  ==> P(i)";
    30 by (rtac ([Nat_def, Nat_fun_mono, major] MRS def_induct) 1);
    31 by (blast_tac (claset() addIs prems) 1);
    32 qed "Nat_induct";
    33 
    34 val prems = Goalw [Zero_def,Suc_def]
    35     "[| P(0);   \
    36 \       !!n. P(n) ==> P(Suc(n)) |]  ==> P(n)";
    37 by (rtac (Rep_Nat_inverse RS subst) 1);   (*types force good instantiation*)
    38 by (rtac (Rep_Nat RS Nat_induct) 1);
    39 by (REPEAT (ares_tac prems 1
    40      ORELSE eresolve_tac [Abs_Nat_inverse RS subst] 1));
    41 qed "nat_induct";
    42 
    43 (*Perform induction on n. *)
    44 fun nat_ind_tac a i = 
    45   res_inst_tac [("n",a)] nat_induct i  THEN  rename_last_tac a [""] (i+1);
    46 
    47 (*A special form of induction for reasoning about m<n and m-n*)
    48 val prems = Goal
    49     "[| !!x. P x 0;  \
    50 \       !!y. P 0 (Suc y);  \
    51 \       !!x y. [| P x y |] ==> P (Suc x) (Suc y)  \
    52 \    |] ==> P m n";
    53 by (res_inst_tac [("x","m")] spec 1);
    54 by (nat_ind_tac "n" 1);
    55 by (rtac allI 2);
    56 by (nat_ind_tac "x" 2);
    57 by (REPEAT (ares_tac (prems@[allI]) 1 ORELSE etac spec 1));
    58 qed "diff_induct";
    59 
    60 (*** Isomorphisms: Abs_Nat and Rep_Nat ***)
    61 
    62 (*We can't take these properties as axioms, or take Abs_Nat==Inv(Rep_Nat),
    63   since we assume the isomorphism equations will one day be given by Isabelle*)
    64 
    65 Goal "inj(Rep_Nat)";
    66 by (rtac inj_inverseI 1);
    67 by (rtac Rep_Nat_inverse 1);
    68 qed "inj_Rep_Nat";
    69 
    70 Goal "inj_on Abs_Nat Nat";
    71 by (rtac inj_on_inverseI 1);
    72 by (etac Abs_Nat_inverse 1);
    73 qed "inj_on_Abs_Nat";
    74 
    75 (*** Distinctness of constructors ***)
    76 
    77 Goalw [Zero_def,Suc_def] "Suc(m) ~= 0";
    78 by (rtac (inj_on_Abs_Nat RS inj_on_contraD) 1);
    79 by (rtac Suc_Rep_not_Zero_Rep 1);
    80 by (REPEAT (resolve_tac [Rep_Nat, Suc_RepI, Zero_RepI] 1));
    81 qed "Suc_not_Zero";
    82 
    83 bind_thm ("Zero_not_Suc", Suc_not_Zero RS not_sym);
    84 
    85 AddIffs [Suc_not_Zero,Zero_not_Suc];
    86 
    87 bind_thm ("Suc_neq_Zero", (Suc_not_Zero RS notE));
    88 bind_thm ("Zero_neq_Suc", sym RS Suc_neq_Zero);
    89 
    90 (** Injectiveness of Suc **)
    91 
    92 Goalw [Suc_def] "inj(Suc)";
    93 by (rtac injI 1);
    94 by (dtac (inj_on_Abs_Nat RS inj_onD) 1);
    95 by (REPEAT (resolve_tac [Rep_Nat, Suc_RepI] 1));
    96 by (dtac (inj_Suc_Rep RS injD) 1);
    97 by (etac (inj_Rep_Nat RS injD) 1);
    98 qed "inj_Suc";
    99 
   100 bind_thm ("Suc_inject", inj_Suc RS injD);
   101 
   102 Goal "(Suc(m)=Suc(n)) = (m=n)";
   103 by (EVERY1 [rtac iffI, etac Suc_inject, etac arg_cong]); 
   104 qed "Suc_Suc_eq";
   105 
   106 AddIffs [Suc_Suc_eq];
   107 
   108 Goal "n ~= Suc(n)";
   109 by (nat_ind_tac "n" 1);
   110 by (ALLGOALS Asm_simp_tac);
   111 qed "n_not_Suc_n";
   112 
   113 bind_thm ("Suc_n_not_n", n_not_Suc_n RS not_sym);
   114 
   115 (*** Basic properties of "less than" ***)
   116 
   117 Goalw [wf_def, pred_nat_def] "wf(pred_nat)";
   118 by (Clarify_tac 1);
   119 by (nat_ind_tac "x" 1);
   120 by (ALLGOALS Blast_tac);
   121 qed "wf_pred_nat";
   122 
   123 (*Used in TFL/post.sml*)
   124 Goalw [less_def] "(m,n) : pred_nat^+ = (m<n)";
   125 by (rtac refl 1);
   126 qed "less_eq";
   127 
   128 (** Introduction properties **)
   129 
   130 Goalw [less_def] "[| i<j;  j<k |] ==> i<(k::nat)";
   131 by (rtac (trans_trancl RS transD) 1);
   132 by (assume_tac 1);
   133 by (assume_tac 1);
   134 qed "less_trans";
   135 
   136 Goalw [less_def, pred_nat_def] "n < Suc(n)";
   137 by (simp_tac (simpset() addsimps [r_into_trancl]) 1);
   138 qed "lessI";
   139 AddIffs [lessI];
   140 
   141 (* i<j ==> i<Suc(j) *)
   142 bind_thm("less_SucI", lessI RSN (2, less_trans));
   143 
   144 Goal "0 < Suc(n)";
   145 by (nat_ind_tac "n" 1);
   146 by (rtac lessI 1);
   147 by (etac less_trans 1);
   148 by (rtac lessI 1);
   149 qed "zero_less_Suc";
   150 AddIffs [zero_less_Suc];
   151 
   152 (** Elimination properties **)
   153 
   154 Goalw [less_def] "n<m ==> ~ m<(n::nat)";
   155 by (blast_tac (claset() addIs [wf_pred_nat, wf_trancl RS wf_asym])1);
   156 qed "less_not_sym";
   157 
   158 (* [| n<m; ~P ==> m<n |] ==> P *)
   159 bind_thm ("less_asym", less_not_sym RS swap);
   160 
   161 Goalw [less_def] "~ n<(n::nat)";
   162 by (rtac notI 1);
   163 by (etac (wf_pred_nat RS wf_trancl RS wf_irrefl) 1);
   164 qed "less_not_refl";
   165 
   166 (* n<n ==> R *)
   167 bind_thm ("less_irrefl", (less_not_refl RS notE));
   168 AddSEs [less_irrefl];
   169 
   170 Goal "n<m ==> m ~= (n::nat)";
   171 by (Blast_tac 1);
   172 qed "less_not_refl2";
   173 
   174 (* s < t ==> s ~= t *)
   175 bind_thm ("less_not_refl3", less_not_refl2 RS not_sym);
   176 
   177 
   178 val major::prems = Goalw [less_def, pred_nat_def]
   179     "[| i<k;  k=Suc(i) ==> P;  !!j. [| i<j;  k=Suc(j) |] ==> P \
   180 \    |] ==> P";
   181 by (rtac (major RS tranclE) 1);
   182 by (ALLGOALS Full_simp_tac); 
   183 by (REPEAT_FIRST (bound_hyp_subst_tac ORELSE'
   184                   eresolve_tac (prems@[asm_rl, Pair_inject])));
   185 qed "lessE";
   186 
   187 Goal "~ n < (0::nat)";
   188 by (blast_tac (claset() addEs [lessE]) 1);
   189 qed "not_less0";
   190 AddIffs [not_less0];
   191 
   192 (* n<0 ==> R *)
   193 bind_thm ("less_zeroE", not_less0 RS notE);
   194 
   195 val [major,less,eq] = Goal
   196     "[| m < Suc(n);  m<n ==> P;  m=n ==> P |] ==> P";
   197 by (rtac (major RS lessE) 1);
   198 by (rtac eq 1);
   199 by (Blast_tac 1);
   200 by (rtac less 1);
   201 by (Blast_tac 1);
   202 qed "less_SucE";
   203 
   204 Goal "(m < Suc(n)) = (m < n | m = n)";
   205 by (blast_tac (claset() addSEs [less_SucE] addIs [less_trans]) 1);
   206 qed "less_Suc_eq";
   207 
   208 Goal "(n<1) = (n=0)";
   209 by (simp_tac (simpset() addsimps [less_Suc_eq]) 1);
   210 qed "less_one";
   211 AddIffs [less_one];
   212 
   213 Goal "m<n ==> Suc(m) < Suc(n)";
   214 by (etac rev_mp 1);
   215 by (nat_ind_tac "n" 1);
   216 by (ALLGOALS (fast_tac (claset() addEs [less_trans, lessE])));
   217 qed "Suc_mono";
   218 
   219 (*"Less than" is a linear ordering*)
   220 Goal "m<n | m=n | n<(m::nat)";
   221 by (nat_ind_tac "m" 1);
   222 by (nat_ind_tac "n" 1);
   223 by (rtac (refl RS disjI1 RS disjI2) 1);
   224 by (rtac (zero_less_Suc RS disjI1) 1);
   225 by (blast_tac (claset() addIs [Suc_mono, less_SucI] addEs [lessE]) 1);
   226 qed "less_linear";
   227 
   228 Goal "!!m::nat. (m ~= n) = (m<n | n<m)";
   229 by (cut_facts_tac [less_linear] 1);
   230 by (Blast_tac 1);
   231 qed "nat_neq_iff";
   232 
   233 val [major,eqCase,lessCase] = Goal 
   234    "[| (m::nat)<n ==> P n m; m=n ==> P n m; n<m ==> P n m |] ==> P n m";
   235 by (rtac (less_linear RS disjE) 1);
   236 by (etac disjE 2);
   237 by (etac lessCase 1);
   238 by (etac (sym RS eqCase) 1);
   239 by (etac major 1);
   240 qed "nat_less_cases";
   241 
   242 
   243 (** Inductive (?) properties **)
   244 
   245 Goal "[| m<n; Suc m ~= n |] ==> Suc(m) < n";
   246 by (full_simp_tac (simpset() addsimps [nat_neq_iff]) 1);
   247 by (blast_tac (claset() addSEs [less_irrefl, less_SucE] addEs [less_asym]) 1);
   248 qed "Suc_lessI";
   249 
   250 Goal "Suc(m) < n ==> m<n";
   251 by (etac rev_mp 1);
   252 by (nat_ind_tac "n" 1);
   253 by (ALLGOALS (fast_tac (claset() addSIs [lessI RS less_SucI]
   254                                  addEs  [less_trans, lessE])));
   255 qed "Suc_lessD";
   256 
   257 val [major,minor] = Goal 
   258     "[| Suc(i)<k;  !!j. [| i<j;  k=Suc(j) |] ==> P \
   259 \    |] ==> P";
   260 by (rtac (major RS lessE) 1);
   261 by (etac (lessI RS minor) 1);
   262 by (etac (Suc_lessD RS minor) 1);
   263 by (assume_tac 1);
   264 qed "Suc_lessE";
   265 
   266 Goal "Suc(m) < Suc(n) ==> m<n";
   267 by (blast_tac (claset() addEs [lessE, make_elim Suc_lessD]) 1);
   268 qed "Suc_less_SucD";
   269 
   270 
   271 Goal "(Suc(m) < Suc(n)) = (m<n)";
   272 by (EVERY1 [rtac iffI, etac Suc_less_SucD, etac Suc_mono]);
   273 qed "Suc_less_eq";
   274 AddIffs [Suc_less_eq];
   275 
   276 (*Goal "~(Suc(n) < n)";
   277 by (blast_tac (claset() addEs [Suc_lessD RS less_irrefl]) 1);
   278 qed "not_Suc_n_less_n";
   279 Addsimps [not_Suc_n_less_n];*)
   280 
   281 Goal "i<j ==> j<k --> Suc i < k";
   282 by (nat_ind_tac "k" 1);
   283 by (ALLGOALS (asm_simp_tac (simpset())));
   284 by (asm_simp_tac (simpset() addsimps [less_Suc_eq]) 1);
   285 by (blast_tac (claset() addDs [Suc_lessD]) 1);
   286 qed_spec_mp "less_trans_Suc";
   287 
   288 (*Can be used with less_Suc_eq to get n=m | n<m *)
   289 Goal "(~ m < n) = (n < Suc(m))";
   290 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   291 by (ALLGOALS Asm_simp_tac);
   292 qed "not_less_eq";
   293 
   294 (*Complete induction, aka course-of-values induction*)
   295 val prems = Goalw [less_def]
   296     "[| !!n. [| ! m::nat. m<n --> P(m) |] ==> P(n) |]  ==>  P(n)";
   297 by (wf_ind_tac "n" [wf_pred_nat RS wf_trancl] 1);
   298 by (eresolve_tac prems 1);
   299 qed "less_induct";
   300 
   301 (*** Properties of <= ***)
   302 
   303 (*Was le_eq_less_Suc, but this orientation is more useful*)
   304 Goalw [le_def] "(m < Suc n) = (m <= n)";
   305 by (rtac (not_less_eq RS sym) 1);
   306 qed "less_Suc_eq_le";
   307 
   308 (*  m<=n ==> m < Suc n  *)
   309 bind_thm ("le_imp_less_Suc", less_Suc_eq_le RS iffD2);
   310 
   311 Goalw [le_def] "(0::nat) <= n";
   312 by (rtac not_less0 1);
   313 qed "le0";
   314 AddIffs [le0];
   315 
   316 Goalw [le_def] "~ Suc n <= n";
   317 by (Simp_tac 1);
   318 qed "Suc_n_not_le_n";
   319 
   320 Goalw [le_def] "!!i::nat. (i <= 0) = (i = 0)";
   321 by (nat_ind_tac "i" 1);
   322 by (ALLGOALS Asm_simp_tac);
   323 qed "le_0_eq";
   324 AddIffs [le_0_eq];
   325 
   326 Goal "(m <= Suc(n)) = (m<=n | m = Suc n)";
   327 by (simp_tac (simpset() delsimps [less_Suc_eq_le]
   328 			addsimps [less_Suc_eq_le RS sym, less_Suc_eq]) 1);
   329 qed "le_Suc_eq";
   330 
   331 (* [| m <= Suc n;  m <= n ==> R;  m = Suc n ==> R |] ==> R *)
   332 bind_thm ("le_SucE", le_Suc_eq RS iffD1 RS disjE);
   333 
   334 Goalw [le_def] "~n<m ==> m<=(n::nat)";
   335 by (assume_tac 1);
   336 qed "leI";
   337 
   338 Goalw [le_def] "m<=n ==> ~ n < (m::nat)";
   339 by (assume_tac 1);
   340 qed "leD";
   341 
   342 bind_thm ("leE", make_elim leD);
   343 
   344 Goal "(~n<m) = (m<=(n::nat))";
   345 by (blast_tac (claset() addIs [leI] addEs [leE]) 1);
   346 qed "not_less_iff_le";
   347 
   348 Goalw [le_def] "~ m <= n ==> n<(m::nat)";
   349 by (Blast_tac 1);
   350 qed "not_leE";
   351 
   352 Goalw [le_def] "(~n<=m) = (m<(n::nat))";
   353 by (Simp_tac 1);
   354 qed "not_le_iff_less";
   355 
   356 Goalw [le_def] "m < n ==> Suc(m) <= n";
   357 by (simp_tac (simpset() addsimps [less_Suc_eq]) 1);
   358 by (blast_tac (claset() addSEs [less_irrefl,less_asym]) 1);
   359 qed "Suc_leI";  (*formerly called lessD*)
   360 
   361 Goalw [le_def] "Suc(m) <= n ==> m <= n";
   362 by (asm_full_simp_tac (simpset() addsimps [less_Suc_eq]) 1);
   363 qed "Suc_leD";
   364 
   365 (* stronger version of Suc_leD *)
   366 Goalw [le_def] "Suc m <= n ==> m < n";
   367 by (asm_full_simp_tac (simpset() addsimps [less_Suc_eq]) 1);
   368 by (cut_facts_tac [less_linear] 1);
   369 by (Blast_tac 1);
   370 qed "Suc_le_lessD";
   371 
   372 Goal "(Suc m <= n) = (m < n)";
   373 by (blast_tac (claset() addIs [Suc_leI, Suc_le_lessD]) 1);
   374 qed "Suc_le_eq";
   375 
   376 Goalw [le_def] "m <= n ==> m <= Suc n";
   377 by (blast_tac (claset() addDs [Suc_lessD]) 1);
   378 qed "le_SucI";
   379 
   380 (*bind_thm ("le_Suc", not_Suc_n_less_n RS leI);*)
   381 
   382 Goalw [le_def] "m < n ==> m <= (n::nat)";
   383 by (blast_tac (claset() addEs [less_asym]) 1);
   384 qed "less_imp_le";
   385 
   386 (*For instance, (Suc m < Suc n)  =   (Suc m <= n)  =  (m<n) *)
   387 bind_thms ("le_simps", [less_imp_le, less_Suc_eq_le, Suc_le_eq]);
   388 
   389 
   390 (** Equivalence of m<=n and  m<n | m=n **)
   391 
   392 Goalw [le_def] "m <= n ==> m < n | m=(n::nat)";
   393 by (cut_facts_tac [less_linear] 1);
   394 by (blast_tac (claset() addEs [less_irrefl,less_asym]) 1);
   395 qed "le_imp_less_or_eq";
   396 
   397 Goalw [le_def] "m<n | m=n ==> m <=(n::nat)";
   398 by (cut_facts_tac [less_linear] 1);
   399 by (blast_tac (claset() addSEs [less_irrefl] addEs [less_asym]) 1);
   400 qed "less_or_eq_imp_le";
   401 
   402 Goal "(m <= (n::nat)) = (m < n | m=n)";
   403 by (REPEAT(ares_tac [iffI,less_or_eq_imp_le,le_imp_less_or_eq] 1));
   404 qed "le_eq_less_or_eq";
   405 
   406 (*Useful with Blast_tac.   m=n ==> m<=n *)
   407 bind_thm ("eq_imp_le", disjI2 RS less_or_eq_imp_le);
   408 
   409 Goal "n <= (n::nat)";
   410 by (simp_tac (simpset() addsimps [le_eq_less_or_eq]) 1);
   411 qed "le_refl";
   412 
   413 
   414 Goal "[| i <= j; j < k |] ==> i < (k::nat)";
   415 by (blast_tac (claset() addSDs [le_imp_less_or_eq]
   416 	                addIs [less_trans]) 1);
   417 qed "le_less_trans";
   418 
   419 Goal "[| i < j; j <= k |] ==> i < (k::nat)";
   420 by (blast_tac (claset() addSDs [le_imp_less_or_eq]
   421 	                addIs [less_trans]) 1);
   422 qed "less_le_trans";
   423 
   424 Goal "[| i <= j; j <= k |] ==> i <= (k::nat)";
   425 by (blast_tac (claset() addSDs [le_imp_less_or_eq]
   426 	                addIs [less_or_eq_imp_le, less_trans]) 1);
   427 qed "le_trans";
   428 
   429 Goal "[| m <= n; n <= m |] ==> m = (n::nat)";
   430 (*order_less_irrefl could make this proof fail*)
   431 by (blast_tac (claset() addSDs [le_imp_less_or_eq]
   432 	                addSEs [less_irrefl] addEs [less_asym]) 1);
   433 qed "le_anti_sym";
   434 
   435 Goal "(Suc(n) <= Suc(m)) = (n <= m)";
   436 by (simp_tac (simpset() addsimps le_simps) 1);
   437 qed "Suc_le_mono";
   438 
   439 AddIffs [Suc_le_mono];
   440 
   441 (* Axiom 'order_less_le' of class 'order': *)
   442 Goal "(m::nat) < n = (m <= n & m ~= n)";
   443 by (simp_tac (simpset() addsimps [le_def, nat_neq_iff]) 1);
   444 by (blast_tac (claset() addSEs [less_asym]) 1);
   445 qed "nat_less_le";
   446 
   447 (* [| m <= n; m ~= n |] ==> m < n *)
   448 bind_thm ("le_neq_implies_less", [nat_less_le, conjI] MRS iffD2);
   449 
   450 (* Axiom 'linorder_linear' of class 'linorder': *)
   451 Goal "(m::nat) <= n | n <= m";
   452 by (simp_tac (simpset() addsimps [le_eq_less_or_eq]) 1);
   453 by (cut_facts_tac [less_linear] 1);
   454 by (Blast_tac 1);
   455 qed "nat_le_linear";
   456 
   457 Goal "~ n < m ==> (n < Suc m) = (n = m)";
   458 by (blast_tac (claset() addSEs [less_SucE]) 1);
   459 qed "not_less_less_Suc_eq";
   460 
   461 
   462 (*Rewrite (n < Suc m) to (n=m) if  ~ n<m or m<=n hold.
   463   Not suitable as default simprules because they often lead to looping*)
   464 bind_thms ("not_less_simps", [not_less_less_Suc_eq, leD RS not_less_less_Suc_eq]);
   465 
   466 (** LEAST -- the least number operator **)
   467 
   468 Goal "(! m::nat. P m --> n <= m) = (! m. m < n --> ~ P m)";
   469 by (blast_tac (claset() addIs [leI] addEs [leE]) 1);
   470 val lemma = result();
   471 
   472 (* This is an old def of Least for nat, which is derived for compatibility *)
   473 Goalw [Least_def]
   474   "(LEAST n::nat. P n) == (@n. P(n) & (ALL m. m < n --> ~P(m)))";
   475 by (simp_tac (simpset() addsimps [lemma]) 1);
   476 qed "Least_nat_def";
   477 
   478 val [prem1,prem2] = Goalw [Least_nat_def]
   479     "[| P(k::nat);  !!x. x<k ==> ~P(x) |] ==> (LEAST x. P(x)) = k";
   480 by (rtac select_equality 1);
   481 by (blast_tac (claset() addSIs [prem1,prem2]) 1);
   482 by (cut_facts_tac [less_linear] 1);
   483 by (blast_tac (claset() addSIs [prem1] addSDs [prem2]) 1);
   484 qed "Least_equality";
   485 
   486 Goal "P(k::nat) ==> P(LEAST x. P(x))";
   487 by (etac rev_mp 1);
   488 by (res_inst_tac [("n","k")] less_induct 1);
   489 by (rtac impI 1);
   490 by (rtac classical 1);
   491 by (res_inst_tac [("s","n")] (Least_equality RS ssubst) 1);
   492 by (assume_tac 1);
   493 by (assume_tac 2);
   494 by (Blast_tac 1);
   495 qed "LeastI";
   496 
   497 (*Proof is almost identical to the one above!*)
   498 Goal "P(k::nat) ==> (LEAST x. P(x)) <= k";
   499 by (etac rev_mp 1);
   500 by (res_inst_tac [("n","k")] less_induct 1);
   501 by (rtac impI 1);
   502 by (rtac classical 1);
   503 by (res_inst_tac [("s","n")] (Least_equality RS ssubst) 1);
   504 by (assume_tac 1);
   505 by (rtac le_refl 2);
   506 by (blast_tac (claset() addIs [less_imp_le,le_trans]) 1);
   507 qed "Least_le";
   508 
   509 Goal "k < (LEAST x. P(x)) ==> ~P(k::nat)";
   510 by (rtac notI 1);
   511 by (etac (rewrite_rule [le_def] Least_le RS notE) 1 THEN assume_tac 1);
   512 qed "not_less_Least";
   513 
   514 (* [| m ~= n; m < n ==> P; n < m ==> P |] ==> P *)
   515 bind_thm("nat_neqE", nat_neq_iff RS iffD1 RS disjE);
   516 
   517 Goal "(S::nat set) ~= {} ==> ? x:S. ! y:S. x <= y";
   518 by (cut_facts_tac [wf_pred_nat RS wf_trancl RS (wf_eq_minimal RS iffD1)] 1);
   519 by (dres_inst_tac [("x","S")] spec 1);
   520 by (Asm_full_simp_tac 1);
   521 by (etac impE 1);
   522 by (Force_tac 1);
   523 by (force_tac (claset(), simpset() addsimps [less_eq,not_le_iff_less]) 1);
   524 qed "nonempty_has_least";