src/HOL/Nat.ML
changeset 11701 3d51fbf81c17
parent 11464 ddea204de5bc
child 11868 56db9f3a6b3e
equal deleted inserted replaced
11700:a0e6bda62b7b 11701:3d51fbf81c17
    66 Goal "(m < Suc n) = (m=0 | (EX j. m = Suc j & j < n))";
    66 Goal "(m < Suc n) = (m=0 | (EX j. m = Suc j & j < n))";
    67 by (case_tac "m" 1);
    67 by (case_tac "m" 1);
    68 by Auto_tac;
    68 by Auto_tac;
    69 qed "less_Suc_eq_0_disj";
    69 qed "less_Suc_eq_0_disj";
    70 
    70 
    71 val prems = Goal "[| P 0; P(1'); !!k. P k ==> P (Suc (Suc k)) |] ==> P n";
    71 val prems = Goal "[| P 0; P(Suc 0); !!k. P k ==> P (Suc (Suc k)) |] ==> P n";
    72 by (rtac nat_less_induct 1);
    72 by (rtac nat_less_induct 1);
    73 by (case_tac "n" 1);
    73 by (case_tac "n" 1);
    74 by (case_tac "nat" 2);
    74 by (case_tac "nat" 2);
    75 by (ALLGOALS (blast_tac (claset() addIs prems@[less_trans])));
    75 by (ALLGOALS (blast_tac (claset() addIs prems@[less_trans])));
    76 qed "nat_induct2";
    76 qed "nat_induct2";
   155 Addsimps [diff_0_eq_0, diff_Suc_Suc];
   155 Addsimps [diff_0_eq_0, diff_Suc_Suc];
   156 
   156 
   157 (* Could be (and is, below) generalized in various ways;
   157 (* Could be (and is, below) generalized in various ways;
   158    However, none of the generalizations are currently in the simpset,
   158    However, none of the generalizations are currently in the simpset,
   159    and I dread to think what happens if I put them in *)
   159    and I dread to think what happens if I put them in *)
   160 Goal "0 < n ==> Suc(n-1') = n";
   160 Goal "0 < n ==> Suc(n - Suc 0) = n";
   161 by (asm_simp_tac (simpset() addsplits [nat.split]) 1);
   161 by (asm_simp_tac (simpset() addsplits [nat.split]) 1);
   162 qed "Suc_pred";
   162 qed "Suc_pred";
   163 Addsimps [Suc_pred];
   163 Addsimps [Suc_pred];
   164 
   164 
   165 Delsimps [diff_Suc];
   165 Delsimps [diff_Suc];
   236 by (case_tac "m" 1);
   236 by (case_tac "m" 1);
   237 by (Auto_tac);
   237 by (Auto_tac);
   238 qed "add_is_0";
   238 qed "add_is_0";
   239 AddIffs [add_is_0];
   239 AddIffs [add_is_0];
   240 
   240 
   241 Goal "(m+n=1') = (m=1' & n=0 | m=0 & n=1')";
   241 Goal "(m+n= Suc 0) = (m= Suc 0 & n=0 | m=0 & n= Suc 0)";
   242 by (case_tac "m" 1);
   242 by (case_tac "m" 1);
   243 by (Auto_tac);
   243 by (Auto_tac);
   244 qed "add_is_1";
   244 qed "add_is_1";
   245 
   245 
   246 Goal "(1' = m+n) = (m=1' & n=0 | m=0 & n=1')";
   246 Goal "(Suc 0 = m+n) = (m=Suc 0 & n=0 | m=0 & n= Suc 0)";
   247 by (case_tac "m" 1);
   247 by (case_tac "m" 1);
   248 by (Auto_tac);
   248 by (Auto_tac);
   249 qed "one_is_add";
   249 qed "one_is_add";
   250 
   250 
   251 Goal "!!m::nat. (0<m+n) = (0<m | 0<n)";
   251 Goal "!!m::nat. (0<m+n) = (0<m | 0<n)";
   394 by (ALLGOALS(asm_simp_tac (simpset() addsimps add_ac)));
   394 by (ALLGOALS(asm_simp_tac (simpset() addsimps add_ac)));
   395 qed "mult_Suc_right";
   395 qed "mult_Suc_right";
   396 
   396 
   397 Addsimps [mult_0_right, mult_Suc_right];
   397 Addsimps [mult_0_right, mult_Suc_right];
   398 
   398 
   399 Goal "1 * n = n";
   399 Goal "(1::nat) * n = n";
   400 by (Asm_simp_tac 1);
   400 by (Asm_simp_tac 1);
   401 qed "mult_1";
   401 qed "mult_1";
   402 
   402 
   403 Goal "n * 1 = n";
   403 Goal "n * (1::nat) = n";
   404 by (Asm_simp_tac 1);
   404 by (Asm_simp_tac 1);
   405 qed "mult_1_right";
   405 qed "mult_1_right";
   406 
   406 
   407 (*Commutative law for multiplication*)
   407 (*Commutative law for multiplication*)
   408 Goal "m * n = n * (m::nat)";
   408 Goal "m * n = n * (m::nat)";
   636 by (case_tac "n" 2);
   636 by (case_tac "n" 2);
   637 by (ALLGOALS Asm_simp_tac);
   637 by (ALLGOALS Asm_simp_tac);
   638 qed "zero_less_mult_iff";
   638 qed "zero_less_mult_iff";
   639 Addsimps [zero_less_mult_iff];
   639 Addsimps [zero_less_mult_iff];
   640 
   640 
   641 Goal "(1' <= m*n) = (1<=m & 1<=n)";
   641 Goal "(Suc 0 <= m*n) = (1<=m & 1<=n)";
   642 by (induct_tac "m" 1);
   642 by (induct_tac "m" 1);
   643 by (case_tac "n" 2);
   643 by (case_tac "n" 2);
   644 by (ALLGOALS Asm_simp_tac);
   644 by (ALLGOALS Asm_simp_tac);
   645 qed "one_le_mult_iff";
   645 qed "one_le_mult_iff";
   646 Addsimps [one_le_mult_iff];
   646 Addsimps [one_le_mult_iff];
   647 
   647 
   648 Goal "(m*n = 1') = (m=1 & n=1)";
   648 Goal "(m*n = Suc 0) = (m=1 & n=1)";
   649 by (induct_tac "m" 1);
   649 by (induct_tac "m" 1);
   650 by (Simp_tac 1);
   650 by (Simp_tac 1);
   651 by (induct_tac "n" 1);
   651 by (induct_tac "n" 1);
   652 by (Simp_tac 1);
   652 by (Simp_tac 1);
   653 by (fast_tac (claset() addss simpset()) 1);
   653 by (fast_tac (claset() addss simpset()) 1);
   654 qed "mult_eq_1_iff";
   654 qed "mult_eq_1_iff";
   655 Addsimps [mult_eq_1_iff];
   655 Addsimps [mult_eq_1_iff];
   656 
   656 
   657 Goal "(1' = m*n) = (m=1 & n=1)";
   657 Goal "(Suc 0 = m*n) = (m=1 & n=1)";
   658 by(rtac (mult_eq_1_iff RSN (2,trans)) 1);
   658 by(rtac (mult_eq_1_iff RSN (2,trans)) 1);
   659 by (fast_tac (claset() addss simpset()) 1);
   659 by (fast_tac (claset() addss simpset()) 1);
   660 qed "one_eq_mult_iff";
   660 qed "one_eq_mult_iff";
   661 Addsimps [one_eq_mult_iff];
   661 Addsimps [one_eq_mult_iff];
   662 
   662