src/HOL/Arith.ML
changeset 1485 240cc98b94a7
parent 1475 7f5a4cd08209
child 1496 c443b2adaf52
equal deleted inserted replaced
1484:b43cd8a8061f 1485:240cc98b94a7
   250 qed "less_imp_diff_is_0";
   250 qed "less_imp_diff_is_0";
   251 
   251 
   252 val prems = goal Arith.thy "m-n = 0  -->  n-m = 0  -->  m=n";
   252 val prems = goal Arith.thy "m-n = 0  -->  n-m = 0  -->  m=n";
   253 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   253 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   254 by (REPEAT(Simp_tac 1 THEN TRY(atac 1)));
   254 by (REPEAT(Simp_tac 1 THEN TRY(atac 1)));
   255 qed "diffs0_imp_equal_lemma";
   255 qed_spec_mp "diffs0_imp_equal";
   256 
       
   257 (*  [| m-n = 0;  n-m = 0 |] ==> m=n  *)
       
   258 bind_thm ("diffs0_imp_equal", (diffs0_imp_equal_lemma RS mp RS mp));
       
   259 
   256 
   260 val [prem] = goal Arith.thy "m<n ==> 0<n-m";
   257 val [prem] = goal Arith.thy "m<n ==> 0<n-m";
   261 by (rtac (prem RS rev_mp) 1);
   258 by (rtac (prem RS rev_mp) 1);
   262 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   259 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   263 by (ALLGOALS Asm_simp_tac);
   260 by (ALLGOALS Asm_simp_tac);
   296 by (res_inst_tac [("x","0")] exI 2);
   293 by (res_inst_tac [("x","0")] exI 2);
   297 by (Simp_tac 2);
   294 by (Simp_tac 2);
   298 by (safe_tac HOL_cs);
   295 by (safe_tac HOL_cs);
   299 by (res_inst_tac [("x","Suc(k)")] exI 1);
   296 by (res_inst_tac [("x","Suc(k)")] exI 1);
   300 by (Simp_tac 1);
   297 by (Simp_tac 1);
   301 val less_eq_Suc_add_lemma = result();
   298 qed_spec_mp "less_eq_Suc_add";
   302 
       
   303 (*"m<n ==> ? k. n = Suc(m+k)"*)
       
   304 bind_thm ("less_eq_Suc_add", less_eq_Suc_add_lemma RS mp);
       
   305 
       
   306 
   299 
   307 goal Arith.thy "n <= ((m + n)::nat)";
   300 goal Arith.thy "n <= ((m + n)::nat)";
   308 by (nat_ind_tac "m" 1);
   301 by (nat_ind_tac "m" 1);
   309 by (ALLGOALS Simp_tac);
   302 by (ALLGOALS Simp_tac);
   310 by (etac le_trans 1);
   303 by (etac le_trans 1);
   350 
   343 
   351 goal Arith.thy "m+k<=n --> m<=(n::nat)";
   344 goal Arith.thy "m+k<=n --> m<=(n::nat)";
   352 by (nat_ind_tac "k" 1);
   345 by (nat_ind_tac "k" 1);
   353 by (ALLGOALS Asm_simp_tac);
   346 by (ALLGOALS Asm_simp_tac);
   354 by (fast_tac (HOL_cs addDs [Suc_leD]) 1);
   347 by (fast_tac (HOL_cs addDs [Suc_leD]) 1);
   355 val add_leD1_lemma = result();
   348 qed_spec_mp "add_leD1";
   356 bind_thm ("add_leD1", add_leD1_lemma RS mp);
       
   357 
   349 
   358 goal Arith.thy "!!k l::nat. [| k<l; m+l = k+n |] ==> m<n";
   350 goal Arith.thy "!!k l::nat. [| k<l; m+l = k+n |] ==> m<n";
   359 by (safe_tac (HOL_cs addSDs [less_eq_Suc_add]));
   351 by (safe_tac (HOL_cs addSDs [less_eq_Suc_add]));
   360 by (asm_full_simp_tac
   352 by (asm_full_simp_tac
   361     (!simpset delsimps [add_Suc_right]
   353     (!simpset delsimps [add_Suc_right]