src/HOL/Nat.ML
changeset 10710 0c8d58332658
parent 10558 09a91221ced1
child 10850 e1a793957a8f
equal deleted inserted replaced
10709:7a29b71d6352 10710:0c8d58332658
    40 Goal "!!n::nat. (n ~= 0) = (0 < n)";
    40 Goal "!!n::nat. (n ~= 0) = (0 < n)";
    41 by (case_tac "n" 1);
    41 by (case_tac "n" 1);
    42 by Auto_tac;
    42 by Auto_tac;
    43 qed "neq0_conv";
    43 qed "neq0_conv";
    44 AddIffs [neq0_conv];
    44 AddIffs [neq0_conv];
    45 
       
    46 Goal "!!n::nat. (0 ~= n) = (0 < n)";
       
    47 by (case_tac "n" 1);
       
    48 by Auto_tac;
       
    49 qed "zero_neq_conv";
       
    50 AddIffs [zero_neq_conv];
       
    51 
    45 
    52 (*This theorem is useful with blast_tac: (n=0 ==> False) ==> 0<n *)
    46 (*This theorem is useful with blast_tac: (n=0 ==> False) ==> 0<n *)
    53 bind_thm ("gr0I", [neq0_conv, notI] MRS iffD1);
    47 bind_thm ("gr0I", [neq0_conv, notI] MRS iffD1);
    54 
    48 
    55 Goal "(0<n) = (EX m. n = Suc m)";
    49 Goal "(0<n) = (EX m. n = Suc m)";
   233 by (case_tac "m" 1);
   227 by (case_tac "m" 1);
   234 by (Auto_tac);
   228 by (Auto_tac);
   235 qed "add_is_0";
   229 qed "add_is_0";
   236 AddIffs [add_is_0];
   230 AddIffs [add_is_0];
   237 
   231 
   238 Goal "!!m::nat. (0 = m+n) = (m=0 & n=0)";
       
   239 by (case_tac "m" 1);
       
   240 by (Auto_tac);
       
   241 qed "zero_is_add";
       
   242 AddIffs [zero_is_add];
       
   243 
       
   244 Goal "!!m::nat. (m+n=1) = (m=1 & n=0 | m=0 & n=1)";
   232 Goal "!!m::nat. (m+n=1) = (m=1 & n=0 | m=0 & n=1)";
   245 by (case_tac "m" 1);
   233 by (case_tac "m" 1);
   246 by (Auto_tac);
   234 by (Auto_tac);
   247 qed "add_is_1";
   235 qed "add_is_1";
   248 
       
   249 Goal "!!m::nat. (1=m+n) = (m=1 & n=0 | m=0 & n=1)";
       
   250 by (case_tac "m" 1);
       
   251 by (Auto_tac);
       
   252 qed "one_is_add";
       
   253 
   236 
   254 Goal "!!m::nat. (0<m+n) = (0<m | 0<n)";
   237 Goal "!!m::nat. (0<m+n) = (0<m | 0<n)";
   255 by (simp_tac (simpset() delsimps [neq0_conv] addsimps [neq0_conv RS sym]) 1);
   238 by (simp_tac (simpset() delsimps [neq0_conv] addsimps [neq0_conv RS sym]) 1);
   256 qed "add_gr_0";
   239 qed "add_gr_0";
   257 AddIffs [add_gr_0];
   240 AddIffs [add_gr_0];
   443 Goal "!!m::nat. (m*n = 0) = (m=0 | n=0)";
   426 Goal "!!m::nat. (m*n = 0) = (m=0 | n=0)";
   444 by (induct_tac "m" 1);
   427 by (induct_tac "m" 1);
   445 by (induct_tac "n" 2);
   428 by (induct_tac "n" 2);
   446 by (ALLGOALS Asm_simp_tac);
   429 by (ALLGOALS Asm_simp_tac);
   447 qed "mult_is_0";
   430 qed "mult_is_0";
   448 
   431 Addsimps [mult_is_0];
   449 Goal "!!m::nat. (0 = m*n) = (0=m | 0=n)";
       
   450 by (stac eq_commute 1 THEN stac mult_is_0 1);
       
   451 by Auto_tac;
       
   452 qed "zero_is_mult";
       
   453 
       
   454 Addsimps [mult_is_0, zero_is_mult];
       
   455 
   432 
   456 
   433 
   457 (*** Difference ***)
   434 (*** Difference ***)
   458 
   435 
   459 Goal "!!m::nat. m - m = 0";
   436 Goal "!!m::nat. m - m = 0";
   550 
   527 
   551 Goal "!!m::nat. (m-n = 0) = (m <= n)";
   528 Goal "!!m::nat. (m-n = 0) = (m <= n)";
   552 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   529 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   553 by (ALLGOALS Asm_simp_tac);
   530 by (ALLGOALS Asm_simp_tac);
   554 qed "diff_is_0_eq";
   531 qed "diff_is_0_eq";
   555 
   532 Addsimps [diff_is_0_eq];
   556 Goal "!!m::nat. (0 = m-n) = (m <= n)";
       
   557 by (stac (diff_is_0_eq RS sym) 1);
       
   558 by (rtac eq_sym_conv 1);
       
   559 qed "zero_is_diff_eq";
       
   560 Addsimps [diff_is_0_eq, zero_is_diff_eq];
       
   561 
   533 
   562 Goal "!!m::nat. (0<n-m) = (m<n)";
   534 Goal "!!m::nat. (0<n-m) = (m<n)";
   563 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   535 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   564 by (ALLGOALS Asm_simp_tac);
   536 by (ALLGOALS Asm_simp_tac);
   565 qed "zero_less_diff";
   537 qed "zero_less_diff";