src/HOL/Real/RealOrd.ML
changeset 10778 2c6605049646
parent 10752 c4f1bf2acf4c
child 10784 27e4d90b35b5
equal deleted inserted replaced
10777:a5a6255748c3 10778:2c6605049646
   140 by (dtac order_le_imp_less_or_eq 1);
   140 by (dtac order_le_imp_less_or_eq 1);
   141 by (auto_tac (claset() addIs [real_mult_order, order_less_imp_le], 
   141 by (auto_tac (claset() addIs [real_mult_order, order_less_imp_le], 
   142               simpset()));
   142               simpset()));
   143 qed "real_less_le_mult_order";
   143 qed "real_less_le_mult_order";
   144 
   144 
   145 Goal "[| x <= 0; y <= 0 |] ==> (0::real) <= x * y";
       
   146 by (rtac real_less_or_eq_imp_le 1);
       
   147 by (dtac order_le_imp_less_or_eq 1 THEN etac disjE 1);
       
   148 by Auto_tac;
       
   149 by (dtac order_le_imp_less_or_eq 1);
       
   150 by (auto_tac (claset() addDs [real_mult_less_zero1],simpset()));
       
   151 qed "real_mult_le_zero1";
       
   152 
       
   153 Goal "[| 0 <= x; y < 0 |] ==> x * y <= (0::real)";
       
   154 by (rtac real_less_or_eq_imp_le 1);
       
   155 by (dtac order_le_imp_less_or_eq 1 THEN etac disjE 1);
       
   156 by Auto_tac;
       
   157 by (dtac (real_minus_zero_less_iff RS iffD2) 1);
       
   158 by (rtac (real_minus_zero_less_iff RS subst) 1);
       
   159 by (blast_tac (claset() addDs [real_mult_order] 
       
   160 	                addIs [real_minus_mult_eq2 RS ssubst]) 1);
       
   161 qed "real_mult_le_zero";
       
   162 
       
   163 Goal "[| 0 < x; y < 0 |] ==> x*y < (0::real)";
   145 Goal "[| 0 < x; y < 0 |] ==> x*y < (0::real)";
   164 by (dtac (real_minus_zero_less_iff RS iffD2) 1);
   146 by (dtac (real_minus_zero_less_iff RS iffD2) 1);
   165 by (dtac real_mult_order 1 THEN assume_tac 1);
   147 by (dtac real_mult_order 1 THEN assume_tac 1);
   166 by (rtac (real_minus_zero_less_iff RS iffD1) 1);
   148 by (rtac (real_minus_zero_less_iff RS iffD1) 1);
   167 by (Asm_full_simp_tac 1);
   149 by (Asm_full_simp_tac 1);
   279 by (dres_inst_tac [("z","-r")] real_add_le_mono1 1);
   261 by (dres_inst_tac [("z","-r")] real_add_le_mono1 1);
   280 by (dres_inst_tac [("z","s")] real_add_le_mono1 2);
   262 by (dres_inst_tac [("z","s")] real_add_le_mono1 2);
   281 by (auto_tac (claset(), simpset() addsimps [real_add_assoc]));
   263 by (auto_tac (claset(), simpset() addsimps [real_add_assoc]));
   282 qed "real_le_minus_iff";
   264 qed "real_le_minus_iff";
   283 Addsimps [real_le_minus_iff];
   265 Addsimps [real_le_minus_iff];
   284           
       
   285 Goal "0 <= 1r";
       
   286 by (rtac (real_zero_less_one RS order_less_imp_le) 1);
       
   287 qed "real_zero_le_one";
       
   288 Addsimps [real_zero_le_one];
       
   289 
   266 
   290 Goal "(0::real) <= x*x";
   267 Goal "(0::real) <= x*x";
   291 by (res_inst_tac [("R2.0","0"),("R1.0","x")] real_linear_less2 1);
   268 by (res_inst_tac [("R2.0","0"),("R1.0","x")] real_linear_less2 1);
   292 by (auto_tac (claset() addIs [real_mult_order,
   269 by (auto_tac (claset() addIs [real_mult_order,
   293 			      real_mult_less_zero1,order_less_imp_le],
   270 			      real_mult_less_zero1,order_less_imp_le],
   298 (*----------------------------------------------------------------------------
   275 (*----------------------------------------------------------------------------
   299              An embedding of the naturals in the reals
   276              An embedding of the naturals in the reals
   300  ----------------------------------------------------------------------------*)
   277  ----------------------------------------------------------------------------*)
   301 
   278 
   302 Goalw [real_of_posnat_def] "real_of_posnat 0 = 1r";
   279 Goalw [real_of_posnat_def] "real_of_posnat 0 = 1r";
   303 by (full_simp_tac (simpset() addsimps [pnat_one_iff RS sym,real_of_preal_def]) 1);
   280 by (simp_tac (simpset() addsimps [pnat_one_iff RS sym,real_of_preal_def,
   304 by (fold_tac [real_one_def]);
   281                        symmetric real_one_def]) 1);
   305 by (rtac refl 1);
       
   306 qed "real_of_posnat_one";
   282 qed "real_of_posnat_one";
   307 
   283 
   308 Goalw [real_of_posnat_def] "real_of_posnat 1 = 1r + 1r";
   284 Goalw [real_of_posnat_def] "real_of_posnat 1 = 1r + 1r";
   309 by (full_simp_tac (simpset() addsimps [real_of_preal_def,real_one_def,
   285 by (simp_tac (simpset() addsimps [real_of_preal_def,real_one_def,
   310     pnat_two_eq,real_add,prat_of_pnat_add RS sym,preal_of_prat_add RS sym
   286                                pnat_two_eq,real_add,prat_of_pnat_add RS sym,
   311     ] @ pnat_add_ac) 1);
   287                                preal_of_prat_add RS sym] @ pnat_add_ac) 1);
   312 qed "real_of_posnat_two";
   288 qed "real_of_posnat_two";
   313 
   289 
   314 Goalw [real_of_posnat_def]
   290 Goalw [real_of_posnat_def]
   315     "real_of_posnat n1 + real_of_posnat n2 = real_of_posnat (n1 + n2) + 1r";
   291      "real_of_posnat n1 + real_of_posnat n2 = real_of_posnat (n1 + n2) + 1r";
   316 by (full_simp_tac (simpset() addsimps [real_of_posnat_one RS sym,
   292 by (full_simp_tac (simpset() addsimps [real_of_posnat_one RS sym,
   317     real_of_posnat_def,real_of_preal_add RS sym,preal_of_prat_add RS sym,
   293     real_of_posnat_def,real_of_preal_add RS sym,preal_of_prat_add RS sym,
   318     prat_of_pnat_add RS sym,pnat_of_nat_add]) 1);
   294     prat_of_pnat_add RS sym,pnat_of_nat_add]) 1);
   319 qed "real_of_posnat_add";
   295 qed "real_of_posnat_add";
   320 
   296 
   336 by (dtac (inj_preal_of_prat RS injD) 1);
   312 by (dtac (inj_preal_of_prat RS injD) 1);
   337 by (dtac (inj_prat_of_pnat RS injD) 1);
   313 by (dtac (inj_prat_of_pnat RS injD) 1);
   338 by (etac (inj_pnat_of_nat RS injD) 1);
   314 by (etac (inj_pnat_of_nat RS injD) 1);
   339 qed "inj_real_of_posnat";
   315 qed "inj_real_of_posnat";
   340 
   316 
   341 Goalw [real_of_posnat_def] "0 < real_of_posnat n";
   317 Goalw [real_of_nat_def] "real_of_nat 0 = 0";
   342 by (rtac (real_gt_zero_preal_Ex RS iffD2) 1);
   318 by (simp_tac (simpset() addsimps [real_of_posnat_one]) 1);
   343 by (Blast_tac 1);
   319 qed "real_of_nat_zero";
   344 qed "real_of_posnat_gt_zero";
   320 
   345 
   321 Goalw [real_of_nat_def] "real_of_nat 1 = 1r";
   346 Goal "real_of_posnat n ~= 0";
   322 by (simp_tac (simpset() addsimps [real_of_posnat_two, real_add_assoc]) 1);
   347 by (rtac (real_of_posnat_gt_zero RS real_not_refl2 RS not_sym) 1);
   323 qed "real_of_nat_one";
   348 qed "real_of_posnat_not_eq_zero";
   324 Addsimps [real_of_nat_zero, real_of_nat_one];
   349 Addsimps[real_of_posnat_not_eq_zero];
   325 
   350 
   326 Goalw [real_of_nat_def]
   351 Goal "1r <= real_of_posnat n";
   327      "real_of_nat (m + n) = real_of_nat m + real_of_nat n";
   352 by (simp_tac (simpset() addsimps [real_of_posnat_one RS sym]) 1);
   328 by (simp_tac (simpset() addsimps 
       
   329               [real_of_posnat_add,real_add_assoc RS sym]) 1);
       
   330 qed "real_of_nat_add";
       
   331 
       
   332 (*Not for addsimps: often the LHS is used to represent a positive natural*)
       
   333 Goalw [real_of_nat_def] "real_of_nat (Suc n) = real_of_nat n + 1r";
       
   334 by (simp_tac (simpset() addsimps [real_of_posnat_Suc] @ real_add_ac) 1);
       
   335 qed "real_of_nat_Suc";
       
   336 
       
   337 Goalw [real_of_nat_def, real_of_posnat_def]
       
   338      "(real_of_nat n < real_of_nat m) = (n < m)";
       
   339 by Auto_tac;
       
   340 qed "real_of_nat_less_iff";
       
   341 AddIffs [real_of_nat_less_iff];
       
   342 
       
   343 Goal "(real_of_nat n <= real_of_nat m) = (n <= m)";
       
   344 by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); 
       
   345 qed "real_of_nat_le_iff";
       
   346 AddIffs [real_of_nat_le_iff];
       
   347 
       
   348 Goal "inj real_of_nat";
       
   349 by (rtac injI 1);
       
   350 by (auto_tac (claset() addSIs [inj_real_of_posnat RS injD],
       
   351 	      simpset() addsimps [real_of_nat_def,real_add_right_cancel]));
       
   352 qed "inj_real_of_nat";
       
   353 
       
   354 Goal "0 <= real_of_nat n";
   353 by (induct_tac "n" 1);
   355 by (induct_tac "n" 1);
   354 by (auto_tac (claset(),
   356 by (auto_tac (claset(),
   355 	      simpset () addsimps [real_of_posnat_Suc,real_of_posnat_one,
   357               simpset () addsimps [real_of_nat_Suc]));
   356 			   real_of_posnat_gt_zero, order_less_imp_le]));
   358 by (dtac real_add_le_less_mono 1); 
   357 qed "real_of_posnat_less_one";
   359 by (rtac real_zero_less_one 1); 
   358 Addsimps [real_of_posnat_less_one];
   360 by (asm_full_simp_tac (simpset() addsimps [order_less_imp_le]) 1); 
   359 
   361 qed "real_of_nat_ge_zero";
   360 Goal "inverse (real_of_posnat n) ~= 0";
   362 AddIffs [real_of_nat_ge_zero];
   361 by (rtac ((real_of_posnat_gt_zero RS 
   363 
   362     real_not_refl2 RS not_sym) RS real_inverse_not_zero) 1);
   364 Goal "real_of_nat (m * n) = real_of_nat m * real_of_nat n";
   363 qed "real_of_posnat_inverse_not_zero";
   365 by (induct_tac "m" 1);
   364 Addsimps [real_of_posnat_inverse_not_zero];
   366 by (auto_tac (claset(),
   365 
   367 	      simpset() addsimps [real_of_nat_add, real_of_nat_Suc,
   366 Goal "inverse (real_of_posnat x) = inverse (real_of_posnat y) ==> x = y";
   368 				  real_add_mult_distrib, real_add_commute]));
   367 by (rtac (inj_real_of_posnat RS injD) 1);
   369 qed "real_of_nat_mult";
   368 by (res_inst_tac [("n2","x")] 
   370 
   369     (real_of_posnat_inverse_not_zero RS real_mult_left_cancel RS iffD1) 1);
   371 Goal "(real_of_nat n = real_of_nat m) = (n = m)";
   370 by (full_simp_tac (simpset() addsimps [(real_of_posnat_gt_zero RS 
   372 by (auto_tac (claset() addDs [inj_real_of_nat RS injD], simpset()));
   371     real_not_refl2 RS not_sym) RS real_mult_inv_left]) 1);
   373 qed "real_of_nat_eq_cancel";
   372 by (asm_full_simp_tac (simpset() addsimps [(real_of_posnat_gt_zero RS 
   374 Addsimps [real_of_nat_eq_cancel];
   373     real_not_refl2 RS not_sym)]) 1);
   375 
   374 qed "real_of_posnat_inverse_inj";
   376 Goal "n <= m --> real_of_nat (m - n) = real_of_nat m + (-real_of_nat n)";
       
   377 by (induct_tac "m" 1);
       
   378 by (auto_tac (claset(),
       
   379 	      simpset() addsimps [Suc_diff_le, le_Suc_eq, real_of_nat_Suc, 
       
   380 				  real_of_nat_zero] @ real_add_ac));
       
   381 qed_spec_mp "real_of_nat_minus";
       
   382 
       
   383 Goalw [real_diff_def]
       
   384      "n < m ==> real_of_nat (m - n) = real_of_nat m - real_of_nat n";
       
   385 by (auto_tac (claset() addIs [real_of_nat_minus], simpset()));
       
   386 qed "real_of_nat_diff";
       
   387 
       
   388 Goalw [real_diff_def]
       
   389      "n <= m ==> real_of_nat (m - n) = real_of_nat m - real_of_nat n";
       
   390 by (etac real_of_nat_minus 1);
       
   391 qed "real_of_nat_diff2";
       
   392 
       
   393 Goal "(real_of_nat n = 0) = (n = 0)";
       
   394 by (auto_tac (claset() addIs [inj_real_of_nat RS injD], simpset()));
       
   395 qed "real_of_nat_zero_iff";
       
   396 Addsimps [real_of_nat_zero_iff];
       
   397 
       
   398 Goal "neg z ==> real_of_nat (nat z) = 0";
       
   399 by (asm_simp_tac (simpset() addsimps [neg_nat, real_of_nat_zero]) 1);
       
   400 qed "real_of_nat_neg_int";
       
   401 Addsimps [real_of_nat_neg_int];
       
   402 
       
   403 
       
   404 (*----------------------------------------------------------------------------
       
   405      inverse, etc.
       
   406  ----------------------------------------------------------------------------*)
   375 
   407 
   376 Goal "0 < x ==> 0 < inverse (x::real)";
   408 Goal "0 < x ==> 0 < inverse (x::real)";
   377 by (EVERY1[rtac ccontr, dtac real_leI]);
   409 by (EVERY1[rtac ccontr, dtac real_leI]);
   378 by (forward_tac [real_minus_zero_less_iff2 RS iffD2] 1);
   410 by (forward_tac [real_minus_zero_less_iff2 RS iffD2] 1);
   379 by (forward_tac [real_not_refl2 RS not_sym] 1);
   411 by (forward_tac [real_not_refl2 RS not_sym] 1);
   390 by (rtac (real_minus_zero_less_iff RS iffD1) 1);
   422 by (rtac (real_minus_zero_less_iff RS iffD1) 1);
   391 by (stac (real_minus_inverse RS sym) 1);
   423 by (stac (real_minus_inverse RS sym) 1);
   392 by (auto_tac (claset() addIs [real_inverse_gt_zero], simpset()));
   424 by (auto_tac (claset() addIs [real_inverse_gt_zero], simpset()));
   393 qed "real_inverse_less_zero";
   425 qed "real_inverse_less_zero";
   394 
   426 
   395 Goal "0 < inverse (real_of_posnat n)";
       
   396 by (rtac (real_of_posnat_gt_zero RS real_inverse_gt_zero) 1);
       
   397 qed "real_of_posnat_inverse_gt_zero";
       
   398 Addsimps [real_of_posnat_inverse_gt_zero];
       
   399 
       
   400 Goal "real_of_preal (preal_of_prat (prat_of_pnat (pnat_of_nat N))) = \
       
   401 \     real_of_nat (Suc N)";
       
   402 by (simp_tac (simpset() addsimps [real_of_nat_def,real_of_posnat_Suc,
       
   403     real_add_assoc,(real_of_posnat_def RS meta_eq_to_obj_eq) RS sym]) 1);
       
   404 qed "real_of_preal_real_of_nat_Suc";
       
   405 
       
   406 Goal "x+x = x*(1r+1r)";
       
   407 by (simp_tac (simpset() addsimps [real_add_mult_distrib2]) 1);
       
   408 qed "real_add_self";
       
   409 
       
   410 Goal "x < x + 1r";
       
   411 by (rtac (real_less_sum_gt_0_iff RS iffD1) 1);
       
   412 by (full_simp_tac (simpset() addsimps [real_zero_less_one,
       
   413 				real_add_assoc, real_add_left_commute]) 1);
       
   414 qed "real_self_less_add_one";
       
   415 
       
   416 Goal "1r < 1r + 1r";
       
   417 by (rtac real_self_less_add_one 1);
       
   418 qed "real_one_less_two";
       
   419 
       
   420 Goal "0 < 1r + 1r";
       
   421 by (rtac ([real_zero_less_one, real_one_less_two] MRS order_less_trans) 1);
       
   422 qed "real_zero_less_two";
       
   423 
       
   424 Goal "1r + 1r ~= 0";
       
   425 by (rtac (real_zero_less_two RS real_not_refl2 RS not_sym) 1);
       
   426 qed "real_two_not_zero";
       
   427 Addsimps [real_two_not_zero];
       
   428 
       
   429 Goal "[| (0::real) < z; x < y |] ==> x*z < y*z";       
   427 Goal "[| (0::real) < z; x < y |] ==> x*z < y*z";       
   430 by (rotate_tac 1 1);
   428 by (rotate_tac 1 1);
   431 by (dtac real_less_sum_gt_zero 1);
   429 by (dtac real_less_sum_gt_zero 1);
   432 by (rtac real_sum_gt_zero_less 1);
   430 by (rtac real_sum_gt_zero_less 1);
   433 by (dtac real_mult_order 1 THEN assume_tac 1);
   431 by (dtac real_mult_order 1 THEN assume_tac 1);
   547 
   545 
   548 Goal "[| 1r <= r; 1r <= x |]  ==> x <= r * x";
   546 Goal "[| 1r <= r; 1r <= x |]  ==> x <= r * x";
   549 by (dtac order_le_imp_less_or_eq 1);
   547 by (dtac order_le_imp_less_or_eq 1);
   550 by (auto_tac (claset() addIs [real_mult_self_le], simpset()));
   548 by (auto_tac (claset() addIs [real_mult_self_le], simpset()));
   551 qed "real_mult_self_le2";
   549 qed "real_mult_self_le2";
   552 
       
   553 Goal "(EX n. inverse (real_of_posnat n) < r) = (EX n. 1r < r * real_of_posnat n)";
       
   554 by (Step_tac 1);
       
   555 by (dres_inst_tac [("n1","n")] (real_of_posnat_gt_zero 
       
   556 				RS real_mult_less_mono1) 1);
       
   557 by (dres_inst_tac [("n2","n")] (real_of_posnat_gt_zero RS 
       
   558 				real_inverse_gt_zero RS real_mult_less_mono1) 2);
       
   559 by (auto_tac (claset(),
       
   560 	      simpset() addsimps [(real_of_posnat_gt_zero RS 
       
   561 				   real_not_refl2 RS not_sym),
       
   562 				  real_mult_assoc]));
       
   563 qed "real_of_posnat_inverse_Ex_iff";
       
   564 
       
   565 Goal "(inverse(real_of_posnat n) < r) = (1r < r * real_of_posnat n)";
       
   566 by (Step_tac 1);
       
   567 by (dres_inst_tac [("n1","n")] (real_of_posnat_gt_zero 
       
   568                        RS real_mult_less_mono1) 1);
       
   569 by (dres_inst_tac [("n2","n")] (real_of_posnat_gt_zero RS 
       
   570 				real_inverse_gt_zero RS real_mult_less_mono1) 2);
       
   571 by (auto_tac (claset(), simpset() addsimps [real_mult_assoc]));
       
   572 qed "real_of_posnat_inverse_iff";
       
   573 
       
   574 Goal "(inverse (real_of_posnat n) <= r) = (1r <= r * real_of_posnat n)";
       
   575 by (Step_tac 1);
       
   576 by (dres_inst_tac [("n2","n")] (real_of_posnat_gt_zero RS 
       
   577     order_less_imp_le RS real_mult_le_le_mono1) 1);
       
   578 by (dres_inst_tac [("n3","n")] (real_of_posnat_gt_zero RS 
       
   579         real_inverse_gt_zero RS order_less_imp_le RS 
       
   580         real_mult_le_le_mono1) 2);
       
   581 by (auto_tac (claset(), simpset() addsimps real_mult_ac));
       
   582 qed "real_of_posnat_inverse_le_iff";
       
   583 
       
   584 Goalw [real_of_posnat_def] "(real_of_posnat n < real_of_posnat m) = (n < m)";
       
   585 by Auto_tac;
       
   586 qed "real_of_posnat_less_iff";
       
   587 
       
   588 Addsimps [real_of_posnat_less_iff];
       
   589 
       
   590 Goal "0 < u  ==> (u < inverse (real_of_posnat n)) = (real_of_posnat n < inverse u)";
       
   591 by (Step_tac 1);
       
   592 by (res_inst_tac [("n2","n")] (real_of_posnat_gt_zero RS 
       
   593     real_inverse_gt_zero RS real_mult_less_cancel1) 1);
       
   594 by (res_inst_tac [("x1","u")] ( real_inverse_gt_zero
       
   595    RS real_mult_less_cancel1) 2);
       
   596 by (auto_tac (claset(),
       
   597 	      simpset() addsimps [real_of_posnat_gt_zero, 
       
   598     real_not_refl2 RS not_sym]));
       
   599 by (res_inst_tac [("z","u")] real_mult_less_cancel2 1);
       
   600 by (res_inst_tac [("n1","n")] (real_of_posnat_gt_zero RS 
       
   601     real_mult_less_cancel2) 3);
       
   602 by (auto_tac (claset(),
       
   603 	      simpset() addsimps [real_of_posnat_gt_zero, 
       
   604     real_not_refl2 RS not_sym,real_mult_assoc RS sym]));
       
   605 qed "real_of_posnat_less_inverse_iff";
       
   606 
       
   607 Goal "0 < u ==> (u = inverse (real_of_posnat n)) = (real_of_posnat n = inverse u)";
       
   608 by (auto_tac (claset(),
       
   609 	      simpset() addsimps [real_inverse_inverse, real_of_posnat_gt_zero, 
       
   610 				  real_not_refl2 RS not_sym]));
       
   611 qed "real_of_posnat_inverse_eq_iff";
       
   612 
   550 
   613 Goal "[| 0 < r; r < x |] ==> inverse x < inverse (r::real)";
   551 Goal "[| 0 < r; r < x |] ==> inverse x < inverse (r::real)";
   614 by (ftac order_less_trans 1 THEN assume_tac 1);
   552 by (ftac order_less_trans 1 THEN assume_tac 1);
   615 by (ftac real_inverse_gt_zero 1);
   553 by (ftac real_inverse_gt_zero 1);
   616 by (forw_inst_tac [("x","x")] real_inverse_gt_zero 1);
   554 by (forw_inst_tac [("x","x")] real_inverse_gt_zero 1);
   623 by (assume_tac 1);
   561 by (assume_tac 1);
   624 by (asm_full_simp_tac (simpset() addsimps [real_not_refl2 RS 
   562 by (asm_full_simp_tac (simpset() addsimps [real_not_refl2 RS 
   625          not_sym RS real_mult_inv_left,real_mult_assoc RS sym]) 1);
   563          not_sym RS real_mult_inv_left,real_mult_assoc RS sym]) 1);
   626 qed "real_inverse_less_swap";
   564 qed "real_inverse_less_swap";
   627 
   565 
   628 Goal "r < r + inverse (real_of_posnat n)";
       
   629 by (res_inst_tac [("C","-r")] real_less_add_left_cancel 1);
       
   630 by (full_simp_tac (simpset() addsimps [real_add_assoc RS sym]) 1);
       
   631 qed "real_add_inverse_real_of_posnat_less";
       
   632 Addsimps [real_add_inverse_real_of_posnat_less];
       
   633 
       
   634 Goal "r <= r + inverse (real_of_posnat n)";
       
   635 by (rtac order_less_imp_le 1);
       
   636 by (Simp_tac 1);
       
   637 qed "real_add_inverse_real_of_posnat_le";
       
   638 Addsimps [real_add_inverse_real_of_posnat_le];
       
   639 
       
   640 Goal "r + (-inverse (real_of_posnat n)) < r";
       
   641 by (res_inst_tac [("C","-r")] real_less_add_left_cancel 1);
       
   642 by (full_simp_tac (simpset() addsimps [real_add_assoc RS sym,
       
   643 				       real_minus_zero_less_iff2]) 1);
       
   644 qed "real_add_minus_inverse_real_of_posnat_less";
       
   645 Addsimps [real_add_minus_inverse_real_of_posnat_less];
       
   646 
       
   647 Goal "r + (-inverse (real_of_posnat n)) <= r";
       
   648 by (rtac order_less_imp_le 1);
       
   649 by (Simp_tac 1);
       
   650 qed "real_add_minus_inverse_real_of_posnat_le";
       
   651 Addsimps [real_add_minus_inverse_real_of_posnat_le];
       
   652 
       
   653 Goal "0 < r ==> r*(1r + (-inverse (real_of_posnat n))) < r";
       
   654 by (simp_tac (simpset() addsimps [real_add_mult_distrib2]) 1);
       
   655 by (res_inst_tac [("C","-r")] real_less_add_left_cancel 1);
       
   656 by (auto_tac (claset() addIs [real_mult_order],
       
   657 	      simpset() addsimps [real_add_assoc RS sym,
       
   658 				  real_minus_zero_less_iff2]));
       
   659 qed "real_mult_less_self";
       
   660 
       
   661 Goal "0 <= 1r + (-inverse (real_of_posnat n))";
       
   662 by (res_inst_tac [("C","inverse (real_of_posnat n)")] real_le_add_right_cancel 1);
       
   663 by (simp_tac (simpset() addsimps [real_add_assoc,
       
   664 				  real_of_posnat_inverse_le_iff]) 1);
       
   665 qed "real_add_one_minus_inverse_ge_zero";
       
   666 
       
   667 Goal "0 < r ==> 0 <= r*(1r + (-inverse (real_of_posnat n)))";
       
   668 by (dtac (real_add_one_minus_inverse_ge_zero RS real_mult_le_less_mono1) 1);
       
   669 by Auto_tac;
       
   670 qed "real_mult_add_one_minus_ge_zero";
       
   671 
       
   672 Goal "(x*y = 0) = (x = 0 | y = (0::real))";
   566 Goal "(x*y = 0) = (x = 0 | y = (0::real))";
   673 by Auto_tac;
   567 by Auto_tac;
   674 by (blast_tac (claset() addIs [ccontr] addDs [real_mult_not_zero]) 1);
   568 by (blast_tac (claset() addIs [ccontr] addDs [real_mult_not_zero]) 1);
   675 qed "real_mult_is_0";
   569 qed "real_mult_is_0";
   676 AddIffs [real_mult_is_0];
   570 AddIffs [real_mult_is_0];
   677 
   571 
   678 Goal "[| 0 <= x * y; 0 < x |] ==> (0::real) <= y";
   572 Goal "[| x ~= 0; y ~= 0 |] \
   679 by (ftac real_inverse_gt_zero 1);
   573 \     ==> inverse x + inverse y = (x + y) * inverse (x * (y::real))";
   680 by (dres_inst_tac [("x","inverse x")] real_less_le_mult_order 1);
       
   681 by (dtac (real_not_refl2 RS not_sym RS real_mult_inv_left) 2);
       
   682 by (auto_tac (claset(),
       
   683 	      simpset() addsimps [real_mult_assoc RS sym]));
       
   684 qed "real_mult_ge_zero_cancel";
       
   685 
       
   686 Goal "[|x ~= 0; y ~= 0 |] ==> inverse x + inverse y = (x + y) * inverse (x * (y::real))";
       
   687 by (asm_full_simp_tac (simpset() addsimps 
   574 by (asm_full_simp_tac (simpset() addsimps 
   688 		       [real_inverse_distrib,real_add_mult_distrib,
   575 		       [real_inverse_distrib,real_add_mult_distrib,
   689 			real_mult_assoc RS sym]) 1);
   576 			real_mult_assoc RS sym]) 1);
   690 by (stac real_mult_assoc 1);
   577 by (stac real_mult_assoc 1);
   691 by (rtac (real_mult_left_commute RS subst) 1);
   578 by (rtac (real_mult_left_commute RS subst) 1);
   751 by (auto_tac (claset() addDs [order_less_not_sym], 
   638 by (auto_tac (claset() addDs [order_less_not_sym], 
   752               simpset() addsimps [real_zero_less_mult_iff, 
   639               simpset() addsimps [real_zero_less_mult_iff, 
   753                                   linorder_not_less RS sym]));
   640                                   linorder_not_less RS sym]));
   754 qed "real_mult_le_zero_iff";
   641 qed "real_mult_le_zero_iff";
   755 
   642 
   756 
       
   757 (*----------------------------------------------------------------------------
       
   758      Another embedding of the naturals in the reals (see real_of_posnat)
       
   759  ----------------------------------------------------------------------------*)
       
   760 Goalw [real_of_nat_def] "real_of_nat 0 = 0";
       
   761 by (simp_tac (simpset() addsimps [real_of_posnat_one]) 1);
       
   762 qed "real_of_nat_zero";
       
   763 
       
   764 Goalw [real_of_nat_def] "real_of_nat 1 = 1r";
       
   765 by (simp_tac (simpset() addsimps [real_of_posnat_two, real_add_assoc]) 1);
       
   766 qed "real_of_nat_one";
       
   767 Addsimps [real_of_nat_zero, real_of_nat_one];
       
   768 
       
   769 Goalw [real_of_nat_def]
       
   770      "real_of_nat (m + n) = real_of_nat m + real_of_nat n";
       
   771 by (simp_tac (simpset() addsimps 
       
   772               [real_of_posnat_add,real_add_assoc RS sym]) 1);
       
   773 qed "real_of_nat_add";
       
   774 
       
   775 Goalw [real_of_nat_def] "real_of_nat (Suc n) = real_of_nat n + 1r";
       
   776 by (simp_tac (simpset() addsimps [real_of_posnat_Suc] @ real_add_ac) 1);
       
   777 qed "real_of_nat_Suc";
       
   778 Addsimps [real_of_nat_Suc];
       
   779     
       
   780 Goalw [real_of_nat_def] "(real_of_nat n < real_of_nat m) = (n < m)";
       
   781 by Auto_tac;
       
   782 qed "real_of_nat_less_iff";
       
   783 
       
   784 AddIffs [real_of_nat_less_iff];
       
   785 
       
   786 Goal "inj real_of_nat";
       
   787 by (rtac injI 1);
       
   788 by (auto_tac (claset() addSIs [inj_real_of_posnat RS injD],
       
   789 	      simpset() addsimps [real_of_nat_def,real_add_right_cancel]));
       
   790 qed "inj_real_of_nat";
       
   791 
       
   792 Goalw [real_of_nat_def] "0 <= real_of_nat n";
       
   793 by (res_inst_tac [("C","1r")] real_le_add_right_cancel 1);
       
   794 by (asm_full_simp_tac (simpset() addsimps [real_add_assoc]) 1);
       
   795 qed "real_of_nat_ge_zero";
       
   796 AddIffs [real_of_nat_ge_zero];
       
   797 
       
   798 Goal "real_of_nat (m * n) = real_of_nat m * real_of_nat n";
       
   799 by (induct_tac "m" 1);
       
   800 by (auto_tac (claset(),
       
   801 	      simpset() addsimps [real_of_nat_add,
       
   802 				  real_add_mult_distrib, real_add_commute]));
       
   803 qed "real_of_nat_mult";
       
   804 
       
   805 Goal "(real_of_nat n = real_of_nat m) = (n = m)";
       
   806 by (auto_tac (claset() addDs [inj_real_of_nat RS injD],
       
   807               simpset()));
       
   808 qed "real_of_nat_eq_cancel";
       
   809 
       
   810 Goal "n <= m --> real_of_nat (m - n) = real_of_nat m + (-real_of_nat n)";
       
   811 by (induct_tac "m" 1);
       
   812 by (auto_tac (claset(),
       
   813 	      simpset() addsimps [Suc_diff_le, le_Suc_eq, real_of_nat_Suc, 
       
   814 				  real_of_nat_zero] @ real_add_ac));
       
   815 qed_spec_mp "real_of_nat_minus";
       
   816 
       
   817 (* 05/00 *)
       
   818 Goal "n < m ==> real_of_nat (m - n) = \
       
   819 \     real_of_nat m + -real_of_nat n";
       
   820 by (auto_tac (claset() addIs [real_of_nat_minus],simpset()));
       
   821 qed "real_of_nat_minus2";
       
   822 
       
   823 Goalw [real_diff_def]
       
   824      "n < m ==> real_of_nat (m - n) = real_of_nat m - real_of_nat n";
       
   825 by (etac real_of_nat_minus2 1);
       
   826 qed "real_of_nat_diff";
       
   827 
       
   828 Goalw [real_diff_def]
       
   829      "n <= m ==> real_of_nat (m - n) = real_of_nat m - real_of_nat n";
       
   830 by (etac real_of_nat_minus 1);
       
   831 qed "real_of_nat_diff2";
       
   832 
       
   833 Goal "(real_of_nat n = 0) = (n = 0)";
       
   834 by (auto_tac (claset() addIs [inj_real_of_nat RS injD], simpset()));
       
   835 qed "real_of_nat_zero_iff";
       
   836 AddIffs [real_of_nat_zero_iff];
       
   837 
       
   838 Goal "neg z ==> real_of_nat (nat z) = 0";
       
   839 by (asm_simp_tac (simpset() addsimps [neg_nat, real_of_nat_zero]) 1);
       
   840 qed "real_of_nat_neg_int";
       
   841 Addsimps [real_of_nat_neg_int];
       
   842