src/HOL/Hyperreal/NSA.ML
changeset 12018 ec054019c910
parent 11704 3c50a2cd6f00
child 12486 0ed8bdd883e0
equal deleted inserted replaced
12017:78b8f9e13300 12018:ec054019c910
    66 
    66 
    67 Goalw [hypreal_number_of_def] "(number_of w ::hypreal) : Reals";
    67 Goalw [hypreal_number_of_def] "(number_of w ::hypreal) : Reals";
    68 by (rtac SReal_hypreal_of_real 1);
    68 by (rtac SReal_hypreal_of_real 1);
    69 qed "SReal_number_of";
    69 qed "SReal_number_of";
    70 Addsimps [SReal_number_of];
    70 Addsimps [SReal_number_of];
       
    71 
       
    72 (** As always with numerals, 0 and 1 are special cases **)
       
    73 
       
    74 Goal "(0::hypreal) : Reals";
       
    75 by (stac (hypreal_numeral_0_eq_0 RS sym) 1);
       
    76 by (rtac SReal_number_of 1); 
       
    77 qed "Reals_0";
       
    78 Addsimps [Reals_0];
       
    79 
       
    80 Goal "(1::hypreal) : Reals";
       
    81 by (stac (hypreal_numeral_1_eq_1 RS sym) 1);
       
    82 by (rtac SReal_number_of 1); 
       
    83 qed "Reals_1";
       
    84 Addsimps [Reals_1];
    71 
    85 
    72 Goalw [hypreal_divide_def] "r : Reals ==> r/(number_of w::hypreal) : Reals";
    86 Goalw [hypreal_divide_def] "r : Reals ==> r/(number_of w::hypreal) : Reals";
    73 by (blast_tac (claset() addSIs [SReal_number_of, SReal_mult, 
    87 by (blast_tac (claset() addSIs [SReal_number_of, SReal_mult, 
    74                                 SReal_inverse]) 1);
    88                                 SReal_inverse]) 1);
    75 qed "SReal_divide_number_of";
    89 qed "SReal_divide_number_of";
   209 by (Simp_tac 1);
   223 by (Simp_tac 1);
   210 qed "HFinite_minus_iff";
   224 qed "HFinite_minus_iff";
   211 
   225 
   212 Goalw [SReal_def,HFinite_def] "Reals <= HFinite";
   226 Goalw [SReal_def,HFinite_def] "Reals <= HFinite";
   213 by Auto_tac;
   227 by Auto_tac;
   214 by (res_inst_tac [("x","Numeral1 + abs(hypreal_of_real r)")] exI 1);
   228 by (res_inst_tac [("x","1 + abs(hypreal_of_real r)")] exI 1);
   215 by (auto_tac (claset(), simpset() addsimps [hypreal_of_real_hrabs]));
   229 by (auto_tac (claset(), simpset() addsimps [hypreal_of_real_hrabs]));
   216 by (res_inst_tac [("x","Numeral1 + abs r")] exI 1);
   230 by (res_inst_tac [("x","1 + abs r")] exI 1);
   217 by (Simp_tac 1);
   231 by (Simp_tac 1);
   218 qed "SReal_subset_HFinite";
   232 qed "SReal_subset_HFinite";
   219 
   233 
   220 Goal "hypreal_of_real x : HFinite";
   234 Goal "hypreal_of_real x : HFinite";
   221 by (auto_tac (claset() addIs [(SReal_subset_HFinite RS subsetD)],
   235 by (auto_tac (claset() addIs [(SReal_subset_HFinite RS subsetD)],
   236 Goal "number_of w : HFinite";
   250 Goal "number_of w : HFinite";
   237 by (rtac (SReal_number_of RS (SReal_subset_HFinite RS subsetD)) 1);
   251 by (rtac (SReal_number_of RS (SReal_subset_HFinite RS subsetD)) 1);
   238 qed "HFinite_number_of";
   252 qed "HFinite_number_of";
   239 Addsimps [HFinite_number_of];
   253 Addsimps [HFinite_number_of];
   240 
   254 
   241 Goal "[|x : HFinite; y <= x; Numeral0 <= y |] ==> y: HFinite";
   255 (** As always with numerals, 0 and 1 are special cases **)
   242 by (case_tac "x <= Numeral0" 1);
   256 
       
   257 Goal "0 : HFinite";
       
   258 by (stac (hypreal_numeral_0_eq_0 RS sym) 1);
       
   259 by (rtac HFinite_number_of 1); 
       
   260 qed "HFinite_0";
       
   261 Addsimps [HFinite_0];
       
   262 
       
   263 Goal "1 : HFinite";
       
   264 by (stac (hypreal_numeral_1_eq_1 RS sym) 1);
       
   265 by (rtac HFinite_number_of 1); 
       
   266 qed "HFinite_1";
       
   267 Addsimps [HFinite_1];
       
   268 
       
   269 Goal "[|x : HFinite; y <= x; 0 <= y |] ==> y: HFinite";
       
   270 by (case_tac "x <= 0" 1);
   243 by (dres_inst_tac [("y","x")] order_trans 1);
   271 by (dres_inst_tac [("y","x")] order_trans 1);
   244 by (dtac hypreal_le_anti_sym 2);
   272 by (dtac hypreal_le_anti_sym 2);
   245 by (auto_tac (claset() addSDs [not_hypreal_leE], simpset()));
   273 by (auto_tac (claset() addSDs [not_hypreal_leE], simpset()));
   246 by (auto_tac (claset() addSIs [bexI] addIs [order_le_less_trans],
   274 by (auto_tac (claset() addSIs [bexI] addIs [order_le_less_trans],
   247      simpset() addsimps [hrabs_eqI1,hrabs_eqI2,hrabs_minus_eqI1,HFinite_def]));
   275      simpset() addsimps [hrabs_eqI1,hrabs_eqI2,hrabs_minus_eqI1,HFinite_def]));
   249 
   277 
   250 (*------------------------------------------------------------------
   278 (*------------------------------------------------------------------
   251        Set of infinitesimals is a subring of the hyperreals   
   279        Set of infinitesimals is a subring of the hyperreals   
   252  ------------------------------------------------------------------*)
   280  ------------------------------------------------------------------*)
   253 Goalw [Infinitesimal_def]
   281 Goalw [Infinitesimal_def]
   254       "x : Infinitesimal ==> ALL r: Reals. Numeral0 < r --> abs x < r";
   282       "x : Infinitesimal ==> ALL r: Reals. 0 < r --> abs x < r";
   255 by Auto_tac;
   283 by Auto_tac;
   256 qed "InfinitesimalD";
   284 qed "InfinitesimalD";
   257 
   285 
   258 Goalw [Infinitesimal_def] "Numeral0 : Infinitesimal";
   286 Goalw [Infinitesimal_def] "0 : Infinitesimal";
   259 by (simp_tac (simpset() addsimps [hrabs_zero]) 1);
   287 by (simp_tac (simpset() addsimps [hrabs_zero]) 1);
   260 qed "Infinitesimal_zero";
   288 qed "Infinitesimal_zero";
   261 AddIffs [Infinitesimal_zero];
   289 AddIffs [Infinitesimal_zero];
   262 
   290 
   263 Goal "x/(2::hypreal) + x/(2::hypreal) = x";
   291 Goal "x/(2::hypreal) + x/(2::hypreal) = x";
   264 by Auto_tac;  
   292 by Auto_tac;  
   265 qed "hypreal_sum_of_halves";
   293 qed "hypreal_sum_of_halves";
   266 
   294 
   267 Goal "Numeral0 < r ==> Numeral0 < r/(2::hypreal)";
   295 Goal "0 < r ==> 0 < r/(2::hypreal)";
   268 by Auto_tac;  
   296 by Auto_tac;  
   269 qed "hypreal_half_gt_zero";
   297 qed "hypreal_half_gt_zero";
   270 
   298 
   271 Goalw [Infinitesimal_def] 
   299 Goalw [Infinitesimal_def] 
   272      "[| x : Infinitesimal; y : Infinitesimal |] ==> (x+y) : Infinitesimal";
   300      "[| x : Infinitesimal; y : Infinitesimal |] ==> (x+y) : Infinitesimal";
   288 qed "Infinitesimal_diff";
   316 qed "Infinitesimal_diff";
   289 
   317 
   290 Goalw [Infinitesimal_def] 
   318 Goalw [Infinitesimal_def] 
   291      "[| x : Infinitesimal; y : Infinitesimal |] ==> (x * y) : Infinitesimal";
   319      "[| x : Infinitesimal; y : Infinitesimal |] ==> (x * y) : Infinitesimal";
   292 by Auto_tac;
   320 by Auto_tac;
   293 by (case_tac "y=Numeral0" 1);
   321 by (case_tac "y=0" 1);
   294 by (cut_inst_tac [("u","abs x"),("v","Numeral1"),("x","abs y"),("y","r")] 
   322 by (cut_inst_tac [("u","abs x"),("v","1"),("x","abs y"),("y","r")] 
   295     hypreal_mult_less_mono 2);
   323     hypreal_mult_less_mono 2);
   296 by Auto_tac;  
   324 by Auto_tac;
   297 qed "Infinitesimal_mult";
   325 qed "Infinitesimal_mult";
   298 
   326 
   299 Goal "[| x : Infinitesimal; y : HFinite |] ==> (x * y) : Infinitesimal";
   327 Goal "[| x : Infinitesimal; y : HFinite |] ==> (x * y) : Infinitesimal";
   300 by (auto_tac (claset() addSDs [HFiniteD],
   328 by (auto_tac (claset() addSDs [HFiniteD],
   301               simpset() addsimps [Infinitesimal_def]));
   329               simpset() addsimps [Infinitesimal_def]));
   330 
   358 
   331 
   359 
   332 
   360 
   333 Goalw [HInfinite_def] "[|x: HInfinite;y: HInfinite|] ==> (x*y): HInfinite";
   361 Goalw [HInfinite_def] "[|x: HInfinite;y: HInfinite|] ==> (x*y): HInfinite";
   334 by Auto_tac;
   362 by Auto_tac;
   335 by (eres_inst_tac [("x","Numeral1")] ballE 1);
   363 by (eres_inst_tac [("x","1")] ballE 1);
   336 by (eres_inst_tac [("x","r")] ballE 1);
   364 by (eres_inst_tac [("x","r")] ballE 1);
   337 by (case_tac "y=0" 1); 
   365 by (case_tac "y=0" 1); 
   338 by (cut_inst_tac [("x","Numeral1"),("y","abs x"),
   366 by (cut_inst_tac [("x","1"),("y","abs x"),
   339                   ("u","r"),("v","abs y")] hypreal_mult_less_mono 2);
   367                   ("u","r"),("v","abs y")] hypreal_mult_less_mono 2);
   340 by (auto_tac (claset(), simpset() addsimps hypreal_mult_ac));  
   368 by (auto_tac (claset(), simpset() addsimps hypreal_mult_ac));  
   341 qed "HInfinite_mult";
   369 qed "HInfinite_mult";
   342 
   370 
   343 Goalw [HInfinite_def] 
   371 Goalw [HInfinite_def] 
   344       "[|x: HInfinite; Numeral0 <= y; Numeral0 <= x|] ==> (x + y): HInfinite";
   372       "[|x: HInfinite; 0 <= y; 0 <= x|] ==> (x + y): HInfinite";
   345 by (auto_tac (claset() addSIs [hypreal_add_zero_less_le_mono],
   373 by (auto_tac (claset() addSIs [hypreal_add_zero_less_le_mono],
   346               simpset() addsimps [hrabs_eqI1, hypreal_add_commute,
   374               simpset() addsimps [hrabs_eqI1, hypreal_add_commute,
   347                                   hypreal_le_add_order]));
   375                                   hypreal_le_add_order]));
   348 qed "HInfinite_add_ge_zero";
   376 qed "HInfinite_add_ge_zero";
   349 
   377 
   350 Goal "[|x: HInfinite; Numeral0 <= y; Numeral0 <= x|] ==> (y + x): HInfinite";
   378 Goal "[|x: HInfinite; 0 <= y; 0 <= x|] ==> (y + x): HInfinite";
   351 by (auto_tac (claset() addSIs [HInfinite_add_ge_zero],
   379 by (auto_tac (claset() addSIs [HInfinite_add_ge_zero],
   352               simpset() addsimps [hypreal_add_commute]));
   380               simpset() addsimps [hypreal_add_commute]));
   353 qed "HInfinite_add_ge_zero2";
   381 qed "HInfinite_add_ge_zero2";
   354 
   382 
   355 Goal "[|x: HInfinite; Numeral0 < y; Numeral0 < x|] ==> (x + y): HInfinite";
   383 Goal "[|x: HInfinite; 0 < y; 0 < x|] ==> (x + y): HInfinite";
   356 by (blast_tac (claset() addIs [HInfinite_add_ge_zero,
   384 by (blast_tac (claset() addIs [HInfinite_add_ge_zero,
   357                     order_less_imp_le]) 1);
   385                     order_less_imp_le]) 1);
   358 qed "HInfinite_add_gt_zero";
   386 qed "HInfinite_add_gt_zero";
   359 
   387 
   360 Goalw [HInfinite_def] "(-x: HInfinite) = (x: HInfinite)";
   388 Goalw [HInfinite_def] "(-x: HInfinite) = (x: HInfinite)";
   361 by Auto_tac;
   389 by Auto_tac;
   362 qed "HInfinite_minus_iff";
   390 qed "HInfinite_minus_iff";
   363 
   391 
   364 Goal "[|x: HInfinite; y <= Numeral0; x <= Numeral0|] ==> (x + y): HInfinite";
   392 Goal "[|x: HInfinite; y <= 0; x <= 0|] ==> (x + y): HInfinite";
   365 by (dtac (HInfinite_minus_iff RS iffD2) 1);
   393 by (dtac (HInfinite_minus_iff RS iffD2) 1);
   366 by (rtac (HInfinite_minus_iff RS iffD1) 1);
   394 by (rtac (HInfinite_minus_iff RS iffD1) 1);
   367 by (auto_tac (claset() addIs [HInfinite_add_ge_zero],
   395 by (auto_tac (claset() addIs [HInfinite_add_ge_zero],
   368               simpset() addsimps [hypreal_minus_zero_le_iff]));
   396               simpset() addsimps [hypreal_minus_zero_le_iff]));
   369 qed "HInfinite_add_le_zero";
   397 qed "HInfinite_add_le_zero";
   370 
   398 
   371 Goal "[|x: HInfinite; y < Numeral0; x < Numeral0|] ==> (x + y): HInfinite";
   399 Goal "[|x: HInfinite; y < 0; x < 0|] ==> (x + y): HInfinite";
   372 by (blast_tac (claset() addIs [HInfinite_add_le_zero,
   400 by (blast_tac (claset() addIs [HInfinite_add_le_zero,
   373                                order_less_imp_le]) 1);
   401                                order_less_imp_le]) 1);
   374 qed "HInfinite_add_lt_zero";
   402 qed "HInfinite_add_lt_zero";
   375 
   403 
   376 Goal "[|a: HFinite; b: HFinite; c: HFinite|] \ 
   404 Goal "[|a: HFinite; b: HFinite; c: HFinite|] \ 
   377 \     ==> a*a + b*b + c*c : HFinite";
   405 \     ==> a*a + b*b + c*c : HFinite";
   378 by (auto_tac (claset() addIs [HFinite_mult,HFinite_add], simpset()));
   406 by (auto_tac (claset() addIs [HFinite_mult,HFinite_add], simpset()));
   379 qed "HFinite_sum_squares";
   407 qed "HFinite_sum_squares";
   380 
   408 
   381 Goal "x ~: Infinitesimal ==> x ~= Numeral0";
   409 Goal "x ~: Infinitesimal ==> x ~= 0";
   382 by Auto_tac;
   410 by Auto_tac;
   383 qed "not_Infinitesimal_not_zero";
   411 qed "not_Infinitesimal_not_zero";
   384 
   412 
   385 Goal "x: HFinite - Infinitesimal ==> x ~= Numeral0";
   413 Goal "x: HFinite - Infinitesimal ==> x ~= 0";
   386 by Auto_tac;
   414 by Auto_tac;
   387 qed "not_Infinitesimal_not_zero2";
   415 qed "not_Infinitesimal_not_zero2";
   388 
   416 
   389 Goal "(abs x : Infinitesimal) = (x : Infinitesimal)";
   417 Goal "(abs x : Infinitesimal) = (x : Infinitesimal)";
   390 by (auto_tac (claset(), simpset() addsimps [hrabs_def]));
   418 by (auto_tac (claset(), simpset() addsimps [hrabs_def]));
   439 by (rtac ccontr 1);
   467 by (rtac ccontr 1);
   440 by (dtac (de_Morgan_disj RS iffD1) 1);
   468 by (dtac (de_Morgan_disj RS iffD1) 1);
   441 by (fast_tac (claset() addDs [not_Infinitesimal_mult]) 1);
   469 by (fast_tac (claset() addDs [not_Infinitesimal_mult]) 1);
   442 qed "Infinitesimal_mult_disj";
   470 qed "Infinitesimal_mult_disj";
   443 
   471 
   444 Goal "x: HFinite-Infinitesimal ==> x ~= Numeral0";
   472 Goal "x: HFinite-Infinitesimal ==> x ~= 0";
   445 by (Blast_tac 1);
   473 by (Blast_tac 1);
   446 qed "HFinite_Infinitesimal_not_zero";
   474 qed "HFinite_Infinitesimal_not_zero";
   447 
   475 
   448 Goal "[| x : HFinite - Infinitesimal; \
   476 Goal "[| x : HFinite - Infinitesimal; \
   449 \                  y : HFinite - Infinitesimal \
   477 \                  y : HFinite - Infinitesimal \
   453 qed "HFinite_Infinitesimal_diff_mult";
   481 qed "HFinite_Infinitesimal_diff_mult";
   454 
   482 
   455 Goalw [Infinitesimal_def,HFinite_def]  
   483 Goalw [Infinitesimal_def,HFinite_def]  
   456       "Infinitesimal <= HFinite";
   484       "Infinitesimal <= HFinite";
   457 by Auto_tac;  
   485 by Auto_tac;  
   458 by (res_inst_tac [("x","Numeral1")] bexI 1); 
   486 by (res_inst_tac [("x","1")] bexI 1); 
   459 by Auto_tac;  
   487 by Auto_tac;  
   460 qed "Infinitesimal_subset_HFinite";
   488 qed "Infinitesimal_subset_HFinite";
   461 
   489 
   462 Goal "x: Infinitesimal ==> x * hypreal_of_real r : Infinitesimal";
   490 Goal "x: Infinitesimal ==> x * hypreal_of_real r : Infinitesimal";
   463 by (etac (HFinite_hypreal_of_real RSN 
   491 by (etac (HFinite_hypreal_of_real RSN 
   472 (*----------------------------------------------------------------------
   500 (*----------------------------------------------------------------------
   473                    Infinitely close relation @=
   501                    Infinitely close relation @=
   474  ----------------------------------------------------------------------*)
   502  ----------------------------------------------------------------------*)
   475 
   503 
   476 Goalw [Infinitesimal_def,approx_def] 
   504 Goalw [Infinitesimal_def,approx_def] 
   477         "(x:Infinitesimal) = (x @= Numeral0)";
   505         "(x:Infinitesimal) = (x @= 0)";
   478 by (Simp_tac 1);
   506 by (Simp_tac 1);
   479 qed "mem_infmal_iff";
   507 qed "mem_infmal_iff";
   480 
   508 
   481 Goalw [approx_def]" (x @= y) = (x + -y @= Numeral0)";
   509 Goalw [approx_def]" (x @= y) = (x + -y @= 0)";
   482 by (Simp_tac 1);
   510 by (Simp_tac 1);
   483 qed "approx_minus_iff";
   511 qed "approx_minus_iff";
   484 
   512 
   485 Goalw [approx_def]" (x @= y) = (-y + x @= Numeral0)";
   513 Goalw [approx_def]" (x @= y) = (-y + x @= 0)";
   486 by (simp_tac (simpset() addsimps [hypreal_add_commute]) 1);
   514 by (simp_tac (simpset() addsimps [hypreal_add_commute]) 1);
   487 qed "approx_minus_iff2";
   515 qed "approx_minus_iff2";
   488 
   516 
   489 Goalw [approx_def,Infinitesimal_def]  "x @= x";
   517 Goalw [approx_def,Infinitesimal_def]  "x @= x";
   490 by (Simp_tac 1);
   518 by (Simp_tac 1);
   508 
   536 
   509 Goal "[| x @= r; x @= s|] ==> r @= s";
   537 Goal "[| x @= r; x @= s|] ==> r @= s";
   510 by (blast_tac (claset() addIs [approx_sym, approx_trans]) 1); 
   538 by (blast_tac (claset() addIs [approx_sym, approx_trans]) 1); 
   511 qed "approx_trans3";
   539 qed "approx_trans3";
   512 
   540 
   513 Goal "(number_of w @= x) = (x @= number_of w)";
   541 Goal "(number_of w @= x) = (x @= number_of w)"; 
   514 by (blast_tac (claset() addIs [approx_sym]) 1); 
   542 by (blast_tac (claset() addIs [approx_sym]) 1); 
   515 qed "number_of_approx_reorient";
   543 qed "number_of_approx_reorient";
   516 Addsimps [number_of_approx_reorient];
   544 
       
   545 Goal "(0 @= x) = (x @= 0)"; 
       
   546 by (blast_tac (claset() addIs [approx_sym]) 1); 
       
   547 qed "zero_approx_reorient";
       
   548 
       
   549 Goal "(1 @= x) = (x @= 1)"; 
       
   550 by (blast_tac (claset() addIs [approx_sym]) 1); 
       
   551 qed "one_approx_reorient";
       
   552 
       
   553 
       
   554 (*** re-orientation, following HOL/Integ/Bin.ML 
       
   555      We re-orient x @=y where x is 0, 1 or a numeral, unless y is as well!
       
   556  ***)
       
   557 
       
   558 (*reorientation simprules using ==, for the following simproc*)
       
   559 val meta_zero_approx_reorient = zero_approx_reorient RS eq_reflection;
       
   560 val meta_one_approx_reorient = one_approx_reorient RS eq_reflection;
       
   561 val meta_number_of_approx_reorient = number_of_approx_reorient RS eq_reflection;
       
   562 
       
   563 (*reorientation simplification procedure: reorients (polymorphic) 
       
   564   0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
       
   565 fun reorient_proc sg _ (_ $ t $ u) =
       
   566   case u of
       
   567       Const("0", _) => None
       
   568     | Const("1", _) => None
       
   569     | Const("Numeral.number_of", _) $ _ => None
       
   570     | _ => Some (case t of
       
   571 		Const("0", _) => meta_zero_approx_reorient
       
   572 	      | Const("1", _) => meta_one_approx_reorient
       
   573 	      | Const("Numeral.number_of", _) $ _ => 
       
   574                                  meta_number_of_approx_reorient);
       
   575 
       
   576 val approx_reorient_simproc = 
       
   577     Bin_Simprocs.prep_simproc ("reorient_simproc",
       
   578 		  Bin_Simprocs.prep_pats ["0@=x", "1@=x", "number_of w @= x"], 
       
   579 		  reorient_proc);
       
   580 
       
   581 Addsimprocs [approx_reorient_simproc];
       
   582 
   517 
   583 
   518 Goal "(x-y : Infinitesimal) = (x @= y)";
   584 Goal "(x-y : Infinitesimal) = (x @= y)";
   519 by (auto_tac (claset(),
   585 by (auto_tac (claset(),
   520               simpset() addsimps [hypreal_diff_def, approx_minus_iff RS sym,
   586               simpset() addsimps [hypreal_diff_def, approx_minus_iff RS sym,
   521                                   mem_infmal_iff]));
   587                                   mem_infmal_iff]));
   702 \     ==> a*c @= hypreal_of_real b*hypreal_of_real d";
   768 \     ==> a*c @= hypreal_of_real b*hypreal_of_real d";
   703 by (blast_tac (claset() addSIs [approx_mult_HFinite,
   769 by (blast_tac (claset() addSIs [approx_mult_HFinite,
   704             approx_hypreal_of_real_HFinite,HFinite_hypreal_of_real]) 1);
   770             approx_hypreal_of_real_HFinite,HFinite_hypreal_of_real]) 1);
   705 qed "approx_mult_hypreal_of_real";
   771 qed "approx_mult_hypreal_of_real";
   706 
   772 
   707 Goal "[| a: Reals; a ~= Numeral0; a*x @= Numeral0 |] ==> x @= Numeral0";
   773 Goal "[| a: Reals; a ~= 0; a*x @= 0 |] ==> x @= 0";
   708 by (dtac (SReal_inverse RS (SReal_subset_HFinite RS subsetD)) 1);
   774 by (dtac (SReal_inverse RS (SReal_subset_HFinite RS subsetD)) 1);
   709 by (auto_tac (claset() addDs [approx_mult2],
   775 by (auto_tac (claset() addDs [approx_mult2],
   710     simpset() addsimps [hypreal_mult_assoc RS sym]));
   776     simpset() addsimps [hypreal_mult_assoc RS sym]));
   711 qed "approx_SReal_mult_cancel_zero";
   777 qed "approx_SReal_mult_cancel_zero";
   712 
   778 
   713 (* REM comments: newly added *)
   779 (* REM comments: newly added *)
   714 Goal "[| a: Reals; x @= Numeral0 |] ==> x*a @= Numeral0";
   780 Goal "[| a: Reals; x @= 0 |] ==> x*a @= 0";
   715 by (auto_tac (claset() addDs [(SReal_subset_HFinite RS subsetD),
   781 by (auto_tac (claset() addDs [(SReal_subset_HFinite RS subsetD),
   716               approx_mult1], simpset()));
   782               approx_mult1], simpset()));
   717 qed "approx_mult_SReal1";
   783 qed "approx_mult_SReal1";
   718 
   784 
   719 Goal "[| a: Reals; x @= Numeral0 |] ==> a*x @= Numeral0";
   785 Goal "[| a: Reals; x @= 0 |] ==> a*x @= 0";
   720 by (auto_tac (claset() addDs [(SReal_subset_HFinite RS subsetD),
   786 by (auto_tac (claset() addDs [(SReal_subset_HFinite RS subsetD),
   721               approx_mult2], simpset()));
   787               approx_mult2], simpset()));
   722 qed "approx_mult_SReal2";
   788 qed "approx_mult_SReal2";
   723 
   789 
   724 Goal "[|a : Reals; a ~= Numeral0 |] ==> (a*x @= Numeral0) = (x @= Numeral0)";
   790 Goal "[|a : Reals; a ~= 0 |] ==> (a*x @= 0) = (x @= 0)";
   725 by (blast_tac (claset() addIs [approx_SReal_mult_cancel_zero,
   791 by (blast_tac (claset() addIs [approx_SReal_mult_cancel_zero,
   726     approx_mult_SReal2]) 1);
   792     approx_mult_SReal2]) 1);
   727 qed "approx_mult_SReal_zero_cancel_iff";
   793 qed "approx_mult_SReal_zero_cancel_iff";
   728 Addsimps [approx_mult_SReal_zero_cancel_iff];
   794 Addsimps [approx_mult_SReal_zero_cancel_iff];
   729 
   795 
   730 Goal "[| a: Reals; a ~= Numeral0; a* w @= a*z |] ==> w @= z";
   796 Goal "[| a: Reals; a ~= 0; a* w @= a*z |] ==> w @= z";
   731 by (dtac (SReal_inverse RS (SReal_subset_HFinite RS subsetD)) 1);
   797 by (dtac (SReal_inverse RS (SReal_subset_HFinite RS subsetD)) 1);
   732 by (auto_tac (claset() addDs [approx_mult2],
   798 by (auto_tac (claset() addDs [approx_mult2],
   733     simpset() addsimps [hypreal_mult_assoc RS sym]));
   799     simpset() addsimps [hypreal_mult_assoc RS sym]));
   734 qed "approx_SReal_mult_cancel";
   800 qed "approx_SReal_mult_cancel";
   735 
   801 
   736 Goal "[| a: Reals; a ~= Numeral0|] ==> (a* w @= a*z) = (w @= z)";
   802 Goal "[| a: Reals; a ~= 0|] ==> (a* w @= a*z) = (w @= z)";
   737 by (auto_tac (claset() addSIs [approx_mult2,SReal_subset_HFinite RS subsetD] 
   803 by (auto_tac (claset() addSIs [approx_mult2,SReal_subset_HFinite RS subsetD] 
   738     addIs [approx_SReal_mult_cancel], simpset()));
   804     addIs [approx_SReal_mult_cancel], simpset()));
   739 qed "approx_SReal_mult_cancel_iff1";
   805 qed "approx_SReal_mult_cancel_iff1";
   740 Addsimps [approx_SReal_mult_cancel_iff1];
   806 Addsimps [approx_SReal_mult_cancel_iff1];
   741 
   807 
   752 (*-----------------------------------------------------------------
   818 (*-----------------------------------------------------------------
   753     Zero is the only infinitesimal that is also a real
   819     Zero is the only infinitesimal that is also a real
   754  -----------------------------------------------------------------*)
   820  -----------------------------------------------------------------*)
   755 
   821 
   756 Goalw [Infinitesimal_def] 
   822 Goalw [Infinitesimal_def] 
   757      "[| x: Reals; y: Infinitesimal; Numeral0 < x |] ==> y < x";
   823      "[| x: Reals; y: Infinitesimal; 0 < x |] ==> y < x";
   758 by (rtac (hrabs_ge_self RS order_le_less_trans) 1);
   824 by (rtac (hrabs_ge_self RS order_le_less_trans) 1);
   759 by Auto_tac;  
   825 by Auto_tac;  
   760 qed "Infinitesimal_less_SReal";
   826 qed "Infinitesimal_less_SReal";
   761 
   827 
   762 Goal "y: Infinitesimal ==> ALL r: Reals. Numeral0 < r --> y < r";
   828 Goal "y: Infinitesimal ==> ALL r: Reals. 0 < r --> y < r";
   763 by (blast_tac (claset() addIs [Infinitesimal_less_SReal]) 1);
   829 by (blast_tac (claset() addIs [Infinitesimal_less_SReal]) 1);
   764 qed "Infinitesimal_less_SReal2";
   830 qed "Infinitesimal_less_SReal2";
   765 
   831 
   766 Goalw [Infinitesimal_def] 
   832 Goalw [Infinitesimal_def] 
   767      "[| Numeral0 < y;  y: Reals|] ==> y ~: Infinitesimal";
   833      "[| 0 < y;  y: Reals|] ==> y ~: Infinitesimal";
   768 by (auto_tac (claset(), simpset() addsimps [hrabs_def]));
   834 by (auto_tac (claset(), simpset() addsimps [hrabs_def]));
   769 qed "SReal_not_Infinitesimal";
   835 qed "SReal_not_Infinitesimal";
   770 
   836 
   771 Goal "[| y < Numeral0;  y : Reals |] ==> y ~: Infinitesimal";
   837 Goal "[| y < 0;  y : Reals |] ==> y ~: Infinitesimal";
   772 by (stac (Infinitesimal_minus_iff RS sym) 1); 
   838 by (stac (Infinitesimal_minus_iff RS sym) 1); 
   773 by (rtac SReal_not_Infinitesimal 1); 
   839 by (rtac SReal_not_Infinitesimal 1); 
   774 by Auto_tac;  
   840 by Auto_tac;  
   775 qed "SReal_minus_not_Infinitesimal";
   841 qed "SReal_minus_not_Infinitesimal";
   776 
   842 
   777 Goal "Reals Int Infinitesimal = {Numeral0}";
   843 Goal "Reals Int Infinitesimal = {0}";
   778 by Auto_tac;
   844 by Auto_tac;
   779 by (cut_inst_tac [("x","x"),("y","Numeral0")] hypreal_linear 1);
   845 by (cut_inst_tac [("x","x"),("y","0")] hypreal_linear 1);
   780 by (blast_tac (claset() addDs [SReal_not_Infinitesimal,
   846 by (blast_tac (claset() addDs [SReal_not_Infinitesimal,
   781                                SReal_minus_not_Infinitesimal]) 1);
   847                                SReal_minus_not_Infinitesimal]) 1);
   782 qed "SReal_Int_Infinitesimal_zero";
   848 qed "SReal_Int_Infinitesimal_zero";
   783 
   849 
   784 Goal "[| x: Reals; x: Infinitesimal|] ==> x = Numeral0";
   850 Goal "[| x: Reals; x: Infinitesimal|] ==> x = 0";
   785 by (cut_facts_tac [SReal_Int_Infinitesimal_zero] 1);
   851 by (cut_facts_tac [SReal_Int_Infinitesimal_zero] 1);
   786 by (Blast_tac 1);
   852 by (Blast_tac 1);
   787 qed "SReal_Infinitesimal_zero";
   853 qed "SReal_Infinitesimal_zero";
   788 
   854 
   789 Goal "[| x : Reals; x ~= Numeral0 |] ==> x : HFinite - Infinitesimal";
   855 Goal "[| x : Reals; x ~= 0 |] ==> x : HFinite - Infinitesimal";
   790 by (auto_tac (claset() addDs [SReal_Infinitesimal_zero,
   856 by (auto_tac (claset() addDs [SReal_Infinitesimal_zero,
   791                               SReal_subset_HFinite RS subsetD], 
   857                               SReal_subset_HFinite RS subsetD], 
   792               simpset()));
   858               simpset()));
   793 qed "SReal_HFinite_diff_Infinitesimal";
   859 qed "SReal_HFinite_diff_Infinitesimal";
   794 
   860 
   795 Goal "hypreal_of_real x ~= Numeral0 ==> hypreal_of_real x : HFinite - Infinitesimal";
   861 Goal "hypreal_of_real x ~= 0 ==> hypreal_of_real x : HFinite - Infinitesimal";
   796 by (rtac SReal_HFinite_diff_Infinitesimal 1);
   862 by (rtac SReal_HFinite_diff_Infinitesimal 1);
   797 by Auto_tac;
   863 by Auto_tac;
   798 qed "hypreal_of_real_HFinite_diff_Infinitesimal";
   864 qed "hypreal_of_real_HFinite_diff_Infinitesimal";
   799 
   865 
   800 Goal "(hypreal_of_real x : Infinitesimal) = (x=Numeral0)";
   866 Goal "(hypreal_of_real x : Infinitesimal) = (x=0)";
   801 by (auto_tac (claset(), simpset() addsimps [hypreal_of_real_zero]));  
   867 by Auto_tac;  
   802 by (rtac ccontr 1); 
   868 by (rtac ccontr 1); 
   803 by (rtac (hypreal_of_real_HFinite_diff_Infinitesimal RS DiffD2) 1); 
   869 by (rtac (hypreal_of_real_HFinite_diff_Infinitesimal RS DiffD2) 1); 
   804 by Auto_tac;  
   870 by Auto_tac;
   805 qed "hypreal_of_real_Infinitesimal_iff_0";
   871 qed "hypreal_of_real_Infinitesimal_iff_0";
   806 AddIffs [hypreal_of_real_Infinitesimal_iff_0];
   872 AddIffs [hypreal_of_real_Infinitesimal_iff_0];
   807 
   873 
   808 Goal "number_of w ~= (Numeral0::hypreal) ==> number_of w ~: Infinitesimal";
   874 Goal "number_of w ~= (0::hypreal) ==> number_of w ~: Infinitesimal";
   809 by (fast_tac (claset() addDs [SReal_number_of RS SReal_Infinitesimal_zero]) 1);
   875 by (fast_tac (claset() addDs [SReal_number_of RS SReal_Infinitesimal_zero]) 1);
   810 qed "number_of_not_Infinitesimal";
   876 qed "number_of_not_Infinitesimal";
   811 Addsimps [number_of_not_Infinitesimal];
   877 Addsimps [number_of_not_Infinitesimal];
   812 
   878 
   813 Goal "[| y: Reals; x @= y; y~= Numeral0 |] ==> x ~= Numeral0";
   879 (*again: 1 is a special case, but not 0 this time*)
       
   880 Goal "1 ~: Infinitesimal";
       
   881 by (stac (hypreal_numeral_1_eq_1 RS sym) 1);
       
   882 by (rtac number_of_not_Infinitesimal 1); 
       
   883 by (Simp_tac 1); 
       
   884 qed "one_not_Infinitesimal";
       
   885 Addsimps [one_not_Infinitesimal];
       
   886 
       
   887 Goal "[| y: Reals; x @= y; y~= 0 |] ==> x ~= 0";
   814 by (cut_inst_tac [("x","y")] hypreal_trichotomy 1);
   888 by (cut_inst_tac [("x","y")] hypreal_trichotomy 1);
   815 by (Asm_full_simp_tac 1); 
   889 by (Asm_full_simp_tac 1); 
   816 by (blast_tac (claset() addDs 
   890 by (blast_tac (claset() addDs 
   817 		[approx_sym RS (mem_infmal_iff RS iffD2),
   891 		[approx_sym RS (mem_infmal_iff RS iffD2),
   818 		 SReal_not_Infinitesimal, SReal_minus_not_Infinitesimal]) 1);
   892 		 SReal_not_Infinitesimal, SReal_minus_not_Infinitesimal]) 1);
   826 by (blast_tac (claset() addDs [approx_sym]) 1);
   900 by (blast_tac (claset() addDs [approx_sym]) 1);
   827 qed "HFinite_diff_Infinitesimal_approx";
   901 qed "HFinite_diff_Infinitesimal_approx";
   828 
   902 
   829 (*The premise y~=0 is essential; otherwise x/y =0 and we lose the 
   903 (*The premise y~=0 is essential; otherwise x/y =0 and we lose the 
   830   HFinite premise.*)
   904   HFinite premise.*)
   831 Goal "[| y ~= Numeral0;  y: Infinitesimal;  x/y : HFinite |] ==> x : Infinitesimal";
   905 Goal "[| y ~= 0;  y: Infinitesimal;  x/y : HFinite |] ==> x : Infinitesimal";
   832 by (dtac Infinitesimal_HFinite_mult2 1);
   906 by (dtac Infinitesimal_HFinite_mult2 1);
   833 by (assume_tac 1);
   907 by (assume_tac 1);
   834 by (asm_full_simp_tac 
   908 by (asm_full_simp_tac 
   835     (simpset() addsimps [hypreal_divide_def, hypreal_mult_assoc]) 1);
   909     (simpset() addsimps [hypreal_divide_def, hypreal_mult_assoc]) 1);
   836 qed "Infinitesimal_ratio";
   910 qed "Infinitesimal_ratio";
   857 by (rtac SReal_approx_iff 1); 
   931 by (rtac SReal_approx_iff 1); 
   858 by Auto_tac;  
   932 by Auto_tac;  
   859 qed "number_of_approx_iff";
   933 qed "number_of_approx_iff";
   860 Addsimps [number_of_approx_iff];
   934 Addsimps [number_of_approx_iff];
   861 
   935 
       
   936 (*And also for 0 @= #nn and 1 @= #nn, #nn @= 0 and #nn @= 1.*)
       
   937 Addsimps
       
   938  (map (simplify (simpset()))
       
   939       [inst "v" "Pls" number_of_approx_iff, 
       
   940        inst "v" "Pls BIT True" number_of_approx_iff,
       
   941        inst "w" "Pls" number_of_approx_iff, 
       
   942        inst "w" "Pls BIT True" number_of_approx_iff]);
       
   943 
       
   944 
       
   945 Goal "~ (0 @= 1)";
       
   946 by (stac SReal_approx_iff 1); 
       
   947 by Auto_tac;  
       
   948 qed "not_0_approx_1";
       
   949 Addsimps [not_0_approx_1];
       
   950 
       
   951 Goal "~ (1 @= 0)";
       
   952 by (stac SReal_approx_iff 1); 
       
   953 by Auto_tac;  
       
   954 qed "not_1_approx_0";
       
   955 Addsimps [not_1_approx_0];
       
   956 
   862 Goal "(hypreal_of_real k @= hypreal_of_real m) = (k = m)";
   957 Goal "(hypreal_of_real k @= hypreal_of_real m) = (k = m)";
   863 by Auto_tac;  
   958 by Auto_tac;  
   864 by (rtac (inj_hypreal_of_real RS injD) 1); 
   959 by (rtac (inj_hypreal_of_real RS injD) 1); 
   865 by (rtac (SReal_approx_iff RS iffD1) 1); 
   960 by (rtac (SReal_approx_iff RS iffD1) 1); 
   866 by Auto_tac;  
   961 by Auto_tac;  
   870 Goal "(hypreal_of_real k @= number_of w) = (k = number_of w)";
   965 Goal "(hypreal_of_real k @= number_of w) = (k = number_of w)";
   871 by (stac (hypreal_of_real_approx_iff RS sym) 1); 
   966 by (stac (hypreal_of_real_approx_iff RS sym) 1); 
   872 by Auto_tac;  
   967 by Auto_tac;  
   873 qed "hypreal_of_real_approx_number_of_iff";
   968 qed "hypreal_of_real_approx_number_of_iff";
   874 Addsimps [hypreal_of_real_approx_number_of_iff];
   969 Addsimps [hypreal_of_real_approx_number_of_iff];
       
   970 
       
   971 (*And also for 0 and 1.*)
       
   972 Addsimps
       
   973  (map (simplify (simpset()))
       
   974       [inst "w" "Pls" hypreal_of_real_approx_number_of_iff, 
       
   975        inst "w" "Pls BIT True" hypreal_of_real_approx_number_of_iff]);
   875 
   976 
   876 Goal "[| r: Reals; s: Reals; r @= x; s @= x|] ==> r = s";
   977 Goal "[| r: Reals; s: Reals; r @= x; s @= x|] ==> r = s";
   877 by (blast_tac (claset() addIs [(SReal_approx_iff RS iffD1),
   978 by (blast_tac (claset() addIs [(SReal_approx_iff RS iffD1),
   878                approx_trans2]) 1);
   979                approx_trans2]) 1);
   879 qed "approx_unique_real";
   980 qed "approx_unique_real";
   910 Goal "x: HFinite ==> EX t. isLub Reals {s. s: Reals & s < x} t";
  1011 Goal "x: HFinite ==> EX t. isLub Reals {s. s: Reals & s < x} t";
   911 by (blast_tac (claset() addSIs [SReal_complete,lemma_st_part_ub,
  1012 by (blast_tac (claset() addSIs [SReal_complete,lemma_st_part_ub,
   912     lemma_st_part_nonempty, lemma_st_part_subset]) 1);
  1013     lemma_st_part_nonempty, lemma_st_part_subset]) 1);
   913 qed "lemma_st_part_lub";
  1014 qed "lemma_st_part_lub";
   914 
  1015 
   915 Goal "((t::hypreal) + r <= t) = (r <= Numeral0)";
  1016 Goal "((t::hypreal) + r <= t) = (r <= 0)";
   916 by (Step_tac 1);
  1017 by (Step_tac 1);
   917 by (dres_inst_tac [("x","-t")] hypreal_add_left_le_mono1 1);
  1018 by (dres_inst_tac [("x","-t")] hypreal_add_left_le_mono1 1);
   918 by (dres_inst_tac [("x","t")] hypreal_add_left_le_mono1 2);
  1019 by (dres_inst_tac [("x","t")] hypreal_add_left_le_mono1 2);
   919 by (auto_tac (claset(), simpset() addsimps [hypreal_add_assoc RS sym]));
  1020 by (auto_tac (claset(), simpset() addsimps [hypreal_add_assoc RS sym]));
   920 qed "lemma_hypreal_le_left_cancel";
  1021 qed "lemma_hypreal_le_left_cancel";
   921 
  1022 
   922 Goal "[| x: HFinite;  isLub Reals {s. s: Reals & s < x} t; \
  1023 Goal "[| x: HFinite;  isLub Reals {s. s: Reals & s < x} t; \
   923 \        r: Reals;  Numeral0 < r |] ==> x <= t + r";
  1024 \        r: Reals;  0 < r |] ==> x <= t + r";
   924 by (forward_tac [isLubD1a] 1);
  1025 by (forward_tac [isLubD1a] 1);
   925 by (rtac ccontr 1 THEN dtac (linorder_not_le RS iffD2) 1);
  1026 by (rtac ccontr 1 THEN dtac (linorder_not_le RS iffD2) 1);
   926 by (dres_inst_tac [("x","t")] SReal_add 1 THEN assume_tac 1);
  1027 by (dres_inst_tac [("x","t")] SReal_add 1 THEN assume_tac 1);
   927 by (dres_inst_tac [("y","t + r")] (isLubD1 RS setleD) 1);
  1028 by (dres_inst_tac [("y","t + r")] (isLubD1 RS setleD) 1);
   928 by Auto_tac;  
  1029 by Auto_tac;  
   943 \              ==> isUb Reals {s. s: Reals & s < x} y";
  1044 \              ==> isUb Reals {s. s: Reals & s < x} y";
   944 by (auto_tac (claset() addDs [order_less_trans]
  1045 by (auto_tac (claset() addDs [order_less_trans]
   945     addIs [order_less_imp_le] addSIs [isUbI,setleI], simpset()));
  1046     addIs [order_less_imp_le] addSIs [isUbI,setleI], simpset()));
   946 qed "lemma_st_part_gt_ub";
  1047 qed "lemma_st_part_gt_ub";
   947 
  1048 
   948 Goal "t <= t + -r ==> r <= (Numeral0::hypreal)";
  1049 Goal "t <= t + -r ==> r <= (0::hypreal)";
   949 by (dres_inst_tac [("x","-t")] hypreal_add_left_le_mono1 1);
  1050 by (dres_inst_tac [("x","-t")] hypreal_add_left_le_mono1 1);
   950 by (auto_tac (claset(), simpset() addsimps [hypreal_add_assoc RS sym]));
  1051 by (auto_tac (claset(), simpset() addsimps [hypreal_add_assoc RS sym]));
   951 qed "lemma_minus_le_zero";
  1052 qed "lemma_minus_le_zero";
   952 
  1053 
   953 Goal "[| x: HFinite; \
  1054 Goal "[| x: HFinite; \
   954 \        isLub Reals {s. s: Reals & s < x} t; \
  1055 \        isLub Reals {s. s: Reals & s < x} t; \
   955 \        r: Reals; Numeral0 < r |] \
  1056 \        r: Reals; 0 < r |] \
   956 \     ==> t + -r <= x";
  1057 \     ==> t + -r <= x";
   957 by (forward_tac [isLubD1a] 1);
  1058 by (forward_tac [isLubD1a] 1);
   958 by (rtac ccontr 1 THEN dtac not_hypreal_leE 1);
  1059 by (rtac ccontr 1 THEN dtac not_hypreal_leE 1);
   959 by (dtac SReal_minus 1 THEN dres_inst_tac [("x","t")] 
  1060 by (dtac SReal_minus 1 THEN dres_inst_tac [("x","t")] 
   960     SReal_add 1 THEN assume_tac 1);
  1061     SReal_add 1 THEN assume_tac 1);
   968 by Auto_tac;  
  1069 by Auto_tac;  
   969 qed "lemma_hypreal_le_swap";
  1070 qed "lemma_hypreal_le_swap";
   970 
  1071 
   971 Goal "[| x: HFinite; \
  1072 Goal "[| x: HFinite; \
   972 \        isLub Reals {s. s: Reals & s < x} t; \
  1073 \        isLub Reals {s. s: Reals & s < x} t; \
   973 \        r: Reals; Numeral0 < r |] \
  1074 \        r: Reals; 0 < r |] \
   974 \     ==> x + -t <= r";
  1075 \     ==> x + -t <= r";
   975 by (blast_tac (claset() addSIs [lemma_hypreal_le_swap RS iffD1,
  1076 by (blast_tac (claset() addSIs [lemma_hypreal_le_swap RS iffD1,
   976                                 lemma_st_part_le1]) 1);
  1077                                 lemma_st_part_le1]) 1);
   977 qed "lemma_st_part1a";
  1078 qed "lemma_st_part1a";
   978 
  1079 
   980 by Auto_tac;  
  1081 by Auto_tac;  
   981 qed "lemma_hypreal_le_swap2";
  1082 qed "lemma_hypreal_le_swap2";
   982 
  1083 
   983 Goal "[| x: HFinite; \
  1084 Goal "[| x: HFinite; \
   984 \        isLub Reals {s. s: Reals & s < x} t; \
  1085 \        isLub Reals {s. s: Reals & s < x} t; \
   985 \        r: Reals;  Numeral0 < r |] \
  1086 \        r: Reals;  0 < r |] \
   986 \     ==> -(x + -t) <= r";
  1087 \     ==> -(x + -t) <= r";
   987 by (blast_tac (claset() addSIs [lemma_hypreal_le_swap2 RS iffD1,
  1088 by (blast_tac (claset() addSIs [lemma_hypreal_le_swap2 RS iffD1,
   988                                 lemma_st_part_le2]) 1);
  1089                                 lemma_st_part_le2]) 1);
   989 qed "lemma_st_part2a";
  1090 qed "lemma_st_part2a";
   990 
  1091 
  1002 by (auto_tac (claset() addDs [order_less_le_trans], simpset()));
  1103 by (auto_tac (claset() addDs [order_less_le_trans], simpset()));
  1003 qed "lemma_SReal_lub";
  1104 qed "lemma_SReal_lub";
  1004 
  1105 
  1005 Goal "[| x: HFinite; \
  1106 Goal "[| x: HFinite; \
  1006 \        isLub Reals {s. s: Reals & s < x} t; \
  1107 \        isLub Reals {s. s: Reals & s < x} t; \
  1007 \        r: Reals; Numeral0 < r |] \
  1108 \        r: Reals; 0 < r |] \
  1008 \     ==> x + -t ~= r";
  1109 \     ==> x + -t ~= r";
  1009 by Auto_tac;
  1110 by Auto_tac;
  1010 by (forward_tac [isLubD1a RS SReal_minus] 1);
  1111 by (forward_tac [isLubD1a RS SReal_minus] 1);
  1011 by (dtac SReal_add_cancel 1 THEN assume_tac 1);
  1112 by (dtac SReal_add_cancel 1 THEN assume_tac 1);
  1012 by (dres_inst_tac [("x","x")] lemma_SReal_lub 1);
  1113 by (dres_inst_tac [("x","x")] lemma_SReal_lub 1);
  1014 by Auto_tac;
  1115 by Auto_tac;
  1015 qed "lemma_st_part_not_eq1";
  1116 qed "lemma_st_part_not_eq1";
  1016 
  1117 
  1017 Goal "[| x: HFinite; \
  1118 Goal "[| x: HFinite; \
  1018 \        isLub Reals {s. s: Reals & s < x} t; \
  1119 \        isLub Reals {s. s: Reals & s < x} t; \
  1019 \        r: Reals; Numeral0 < r |] \
  1120 \        r: Reals; 0 < r |] \
  1020 \     ==> -(x + -t) ~= r";
  1121 \     ==> -(x + -t) ~= r";
  1021 by (auto_tac (claset(), simpset() addsimps [hypreal_minus_add_distrib]));
  1122 by (auto_tac (claset(), simpset() addsimps [hypreal_minus_add_distrib]));
  1022 by (forward_tac [isLubD1a] 1);
  1123 by (forward_tac [isLubD1a] 1);
  1023 by (dtac SReal_add_cancel 1 THEN assume_tac 1);
  1124 by (dtac SReal_add_cancel 1 THEN assume_tac 1);
  1024 by (dres_inst_tac [("x","-x")] SReal_minus 1);
  1125 by (dres_inst_tac [("x","-x")] SReal_minus 1);
  1028 by Auto_tac;
  1129 by Auto_tac;
  1029 qed "lemma_st_part_not_eq2";
  1130 qed "lemma_st_part_not_eq2";
  1030 
  1131 
  1031 Goal "[| x: HFinite; \
  1132 Goal "[| x: HFinite; \
  1032 \        isLub Reals {s. s: Reals & s < x} t; \
  1133 \        isLub Reals {s. s: Reals & s < x} t; \
  1033 \        r: Reals; Numeral0 < r |] \
  1134 \        r: Reals; 0 < r |] \
  1034 \     ==> abs (x + -t) < r";
  1135 \     ==> abs (x + -t) < r";
  1035 by (forward_tac [lemma_st_part1a] 1);
  1136 by (forward_tac [lemma_st_part1a] 1);
  1036 by (forward_tac [lemma_st_part2a] 4);
  1137 by (forward_tac [lemma_st_part2a] 4);
  1037 by Auto_tac;
  1138 by Auto_tac;
  1038 by (REPEAT(dtac order_le_imp_less_or_eq 1));
  1139 by (REPEAT(dtac order_le_imp_less_or_eq 1));
  1040     lemma_st_part_not_eq2], simpset() addsimps [hrabs_interval_iff2]));
  1141     lemma_st_part_not_eq2], simpset() addsimps [hrabs_interval_iff2]));
  1041 qed "lemma_st_part_major";
  1142 qed "lemma_st_part_major";
  1042 
  1143 
  1043 Goal "[| x: HFinite; \
  1144 Goal "[| x: HFinite; \
  1044 \        isLub Reals {s. s: Reals & s < x} t |] \
  1145 \        isLub Reals {s. s: Reals & s < x} t |] \
  1045 \     ==> ALL r: Reals. Numeral0 < r --> abs (x + -t) < r";
  1146 \     ==> ALL r: Reals. 0 < r --> abs (x + -t) < r";
  1046 by (blast_tac (claset() addSDs [lemma_st_part_major]) 1);
  1147 by (blast_tac (claset() addSDs [lemma_st_part_major]) 1);
  1047 qed "lemma_st_part_major2";
  1148 qed "lemma_st_part_major2";
  1048 
  1149 
  1049 (*----------------------------------------------
  1150 (*----------------------------------------------
  1050   Existence of real and Standard Part Theorem
  1151   Existence of real and Standard Part Theorem
  1051  ----------------------------------------------*)
  1152  ----------------------------------------------*)
  1052 Goal "x: HFinite ==> \
  1153 Goal "x: HFinite ==> \
  1053 \     EX t: Reals. ALL r: Reals. Numeral0 < r --> abs (x + -t) < r";
  1154 \     EX t: Reals. ALL r: Reals. 0 < r --> abs (x + -t) < r";
  1054 by (forward_tac [lemma_st_part_lub] 1 THEN Step_tac 1);
  1155 by (forward_tac [lemma_st_part_lub] 1 THEN Step_tac 1);
  1055 by (forward_tac [isLubD1a] 1);
  1156 by (forward_tac [isLubD1a] 1);
  1056 by (blast_tac (claset() addDs [lemma_st_part_major2]) 1);
  1157 by (blast_tac (claset() addDs [lemma_st_part_major2]) 1);
  1057 qed "lemma_st_part_Ex";
  1158 qed "lemma_st_part_Ex";
  1058 
  1159 
  1087 by Auto_tac;
  1188 by Auto_tac;
  1088 qed "HFinite_not_HInfinite";
  1189 qed "HFinite_not_HInfinite";
  1089 
  1190 
  1090 Goalw [HInfinite_def, HFinite_def] "x~: HFinite ==> x: HInfinite";
  1191 Goalw [HInfinite_def, HFinite_def] "x~: HFinite ==> x: HInfinite";
  1091 by Auto_tac;  
  1192 by Auto_tac;  
  1092 by (dres_inst_tac [("x","r + Numeral1")] bspec 1);
  1193 by (dres_inst_tac [("x","r + 1")] bspec 1);
  1093 by (auto_tac (claset(), simpset() addsimps [SReal_add]));   
  1194 by (auto_tac (claset(), simpset() addsimps [SReal_add]));   
  1094 qed "not_HFinite_HInfinite";
  1195 qed "not_HFinite_HInfinite";
  1095 
  1196 
  1096 Goal "x : HInfinite | x : HFinite";
  1197 Goal "x : HInfinite | x : HFinite";
  1097 by (blast_tac (claset() addIs [not_HFinite_HInfinite]) 1);
  1198 by (blast_tac (claset() addIs [not_HFinite_HInfinite]) 1);
  1239 
  1340 
  1240 Goalw [monad_def] "(u:monad x) = (-u:monad (-x))";
  1341 Goalw [monad_def] "(u:monad x) = (-u:monad (-x))";
  1241 by Auto_tac;
  1342 by Auto_tac;
  1242 qed "mem_monad_iff";
  1343 qed "mem_monad_iff";
  1243 
  1344 
  1244 Goalw [monad_def] "(x:Infinitesimal) = (x:monad Numeral0)";
  1345 Goalw [monad_def] "(x:Infinitesimal) = (x:monad 0)";
  1245 by (auto_tac (claset() addIs [approx_sym],
  1346 by (auto_tac (claset() addIs [approx_sym],
  1246     simpset() addsimps [mem_infmal_iff]));
  1347     simpset() addsimps [mem_infmal_iff]));
  1247 qed "Infinitesimal_monad_zero_iff";
  1348 qed "Infinitesimal_monad_zero_iff";
  1248 
  1349 
  1249 Goal "(x:monad Numeral0) = (-x:monad Numeral0)";
  1350 Goal "(x:monad 0) = (-x:monad 0)";
  1250 by (simp_tac (simpset() addsimps [Infinitesimal_monad_zero_iff RS sym]) 1);
  1351 by (simp_tac (simpset() addsimps [Infinitesimal_monad_zero_iff RS sym]) 1);
  1251 qed "monad_zero_minus_iff";
  1352 qed "monad_zero_minus_iff";
  1252 
  1353 
  1253 Goal "(x:monad Numeral0) = (abs x:monad Numeral0)";
  1354 Goal "(x:monad 0) = (abs x:monad 0)";
  1254 by (res_inst_tac [("x1","x")] (hrabs_disj RS disjE) 1);
  1355 by (res_inst_tac [("x1","x")] (hrabs_disj RS disjE) 1);
  1255 by (auto_tac (claset(), simpset() addsimps [monad_zero_minus_iff RS sym]));
  1356 by (auto_tac (claset(), simpset() addsimps [monad_zero_minus_iff RS sym]));
  1256 qed "monad_zero_hrabs_iff";
  1357 qed "monad_zero_hrabs_iff";
  1257 
  1358 
  1258 Goalw [monad_def] "x:monad x";
  1359 Goalw [monad_def] "x:monad x";
  1284 
  1385 
  1285 Goalw [monad_def] "x @= u ==> x:monad u";
  1386 Goalw [monad_def] "x @= u ==> x:monad u";
  1286 by (blast_tac (claset() addSIs [approx_sym]) 1);
  1387 by (blast_tac (claset() addSIs [approx_sym]) 1);
  1287 qed "approx_mem_monad2";
  1388 qed "approx_mem_monad2";
  1288 
  1389 
  1289 Goal "[| x @= y;x:monad Numeral0 |] ==> y:monad Numeral0";
  1390 Goal "[| x @= y;x:monad 0 |] ==> y:monad 0";
  1290 by (dtac mem_monad_approx 1);
  1391 by (dtac mem_monad_approx 1);
  1291 by (fast_tac (claset() addIs [approx_mem_monad,approx_trans]) 1);
  1392 by (fast_tac (claset() addIs [approx_mem_monad,approx_trans]) 1);
  1292 qed "approx_mem_monad_zero";
  1393 qed "approx_mem_monad_zero";
  1293 
  1394 
  1294 Goal "[| x @= y; x: Infinitesimal |] ==> abs x @= abs y";
  1395 Goal "[| x @= y; x: Infinitesimal |] ==> abs x @= abs y";
  1295 by (dtac (Infinitesimal_monad_zero_iff RS iffD1) 1); 
  1396 by (dtac (Infinitesimal_monad_zero_iff RS iffD1) 1); 
  1296 by (blast_tac (claset() addIs [approx_mem_monad_zero, 
  1397 by (blast_tac (claset() addIs [approx_mem_monad_zero, 
  1297      monad_zero_hrabs_iff RS iffD1, mem_monad_approx, approx_trans3]) 1);
  1398      monad_zero_hrabs_iff RS iffD1, mem_monad_approx, approx_trans3]) 1);
  1298 qed "Infinitesimal_approx_hrabs";
  1399 qed "Infinitesimal_approx_hrabs";
  1299 
  1400 
  1300 Goal "[| Numeral0 < x;  x ~:Infinitesimal;  e :Infinitesimal |] ==> e < x";
  1401 Goal "[| 0 < x;  x ~:Infinitesimal;  e :Infinitesimal |] ==> e < x";
  1301 by (rtac ccontr 1);
  1402 by (rtac ccontr 1);
  1302 by (auto_tac (claset()
  1403 by (auto_tac (claset()
  1303                addIs [Infinitesimal_zero RSN (2, Infinitesimal_interval)] 
  1404                addIs [Infinitesimal_zero RSN (2, Infinitesimal_interval)] 
  1304                addSDs [hypreal_leI, order_le_imp_less_or_eq],
  1405                addSDs [hypreal_leI, order_le_imp_less_or_eq],
  1305               simpset()));
  1406               simpset()));
  1306 qed "less_Infinitesimal_less";
  1407 qed "less_Infinitesimal_less";
  1307 
  1408 
  1308 Goal "[| Numeral0 < x;  x ~: Infinitesimal; u: monad x |] ==> Numeral0 < u";
  1409 Goal "[| 0 < x;  x ~: Infinitesimal; u: monad x |] ==> 0 < u";
  1309 by (dtac (mem_monad_approx RS approx_sym) 1);
  1410 by (dtac (mem_monad_approx RS approx_sym) 1);
  1310 by (etac (bex_Infinitesimal_iff2 RS iffD2 RS bexE) 1);
  1411 by (etac (bex_Infinitesimal_iff2 RS iffD2 RS bexE) 1);
  1311 by (dres_inst_tac [("e","-xa")] less_Infinitesimal_less 1);
  1412 by (dres_inst_tac [("e","-xa")] less_Infinitesimal_less 1);
  1312 by Auto_tac;  
  1413 by Auto_tac;  
  1313 qed "Ball_mem_monad_gt_zero";
  1414 qed "Ball_mem_monad_gt_zero";
  1314 
  1415 
  1315 Goal "[| x < Numeral0; x ~: Infinitesimal; u: monad x |] ==> u < Numeral0";
  1416 Goal "[| x < 0; x ~: Infinitesimal; u: monad x |] ==> u < 0";
  1316 by (dtac (mem_monad_approx RS approx_sym) 1);
  1417 by (dtac (mem_monad_approx RS approx_sym) 1);
  1317 by (etac (bex_Infinitesimal_iff RS iffD2 RS bexE) 1);
  1418 by (etac (bex_Infinitesimal_iff RS iffD2 RS bexE) 1);
  1318 by (cut_inst_tac [("x","-x"),("e","xa")] less_Infinitesimal_less 1);
  1419 by (cut_inst_tac [("x","-x"),("e","xa")] less_Infinitesimal_less 1);
  1319 by Auto_tac;  
  1420 by Auto_tac;  
  1320 qed "Ball_mem_monad_less_zero";
  1421 qed "Ball_mem_monad_less_zero";
  1321 
  1422 
  1322 Goal "[|Numeral0 < x; x ~: Infinitesimal; x @= y|] ==> Numeral0 < y";
  1423 Goal "[|0 < x; x ~: Infinitesimal; x @= y|] ==> 0 < y";
  1323 by (blast_tac (claset() addDs [Ball_mem_monad_gt_zero,
  1424 by (blast_tac (claset() addDs [Ball_mem_monad_gt_zero,
  1324                                approx_subset_monad]) 1);
  1425                                approx_subset_monad]) 1);
  1325 qed "lemma_approx_gt_zero";
  1426 qed "lemma_approx_gt_zero";
  1326 
  1427 
  1327 Goal "[|x < Numeral0; x ~: Infinitesimal; x @= y|] ==> y < Numeral0";
  1428 Goal "[|x < 0; x ~: Infinitesimal; x @= y|] ==> y < 0";
  1328 by (blast_tac (claset() addDs [Ball_mem_monad_less_zero,
  1429 by (blast_tac (claset() addDs [Ball_mem_monad_less_zero,
  1329     approx_subset_monad]) 1);
  1430     approx_subset_monad]) 1);
  1330 qed "lemma_approx_less_zero";
  1431 qed "lemma_approx_less_zero";
  1331 
  1432 
  1332 Goal "[| x @= y; x < Numeral0; x ~: Infinitesimal |] ==> abs x @= abs y";
  1433 Goal "[| x @= y; x < 0; x ~: Infinitesimal |] ==> abs x @= abs y";
  1333 by (forward_tac [lemma_approx_less_zero] 1);
  1434 by (forward_tac [lemma_approx_less_zero] 1);
  1334 by (REPEAT(assume_tac 1));
  1435 by (REPEAT(assume_tac 1));
  1335 by (REPEAT(dtac hrabs_minus_eqI2 1));
  1436 by (REPEAT(dtac hrabs_minus_eqI2 1));
  1336 by Auto_tac;
  1437 by Auto_tac;
  1337 qed "approx_hrabs1";
  1438 qed "approx_hrabs1";
  1338 
  1439 
  1339 Goal "[| x @= y; Numeral0 < x; x ~: Infinitesimal |] ==> abs x @= abs y";
  1440 Goal "[| x @= y; 0 < x; x ~: Infinitesimal |] ==> abs x @= abs y";
  1340 by (forward_tac [lemma_approx_gt_zero] 1);
  1441 by (forward_tac [lemma_approx_gt_zero] 1);
  1341 by (REPEAT(assume_tac 1));
  1442 by (REPEAT(assume_tac 1));
  1342 by (REPEAT(dtac hrabs_eqI2 1));
  1443 by (REPEAT(dtac hrabs_eqI2 1));
  1343 by Auto_tac;
  1444 by Auto_tac;
  1344 qed "approx_hrabs2";
  1445 qed "approx_hrabs2";
  1345 
  1446 
  1346 Goal "x @= y ==> abs x @= abs y";
  1447 Goal "x @= y ==> abs x @= abs y";
  1347 by (res_inst_tac [("Q","x:Infinitesimal")] (excluded_middle RS disjE) 1);
  1448 by (res_inst_tac [("Q","x:Infinitesimal")] (excluded_middle RS disjE) 1);
  1348 by (res_inst_tac [("x1","x"),("y1","Numeral0")] (hypreal_linear RS disjE) 1);
  1449 by (res_inst_tac [("x1","x"),("y1","0")] (hypreal_linear RS disjE) 1);
  1349 by (auto_tac (claset() addIs [approx_hrabs1,approx_hrabs2,
  1450 by (auto_tac (claset() addIs [approx_hrabs1,approx_hrabs2,
  1350     Infinitesimal_approx_hrabs], simpset()));
  1451     Infinitesimal_approx_hrabs], simpset()));
  1351 qed "approx_hrabs";
  1452 qed "approx_hrabs";
  1352 
  1453 
  1353 Goal "abs(x) @= Numeral0 ==> x @= Numeral0";
  1454 Goal "abs(x) @= 0 ==> x @= 0";
  1354 by (cut_inst_tac [("x","x")] hrabs_disj 1);
  1455 by (cut_inst_tac [("x","x")] hrabs_disj 1);
  1355 by (auto_tac (claset() addDs [approx_minus], simpset()));
  1456 by (auto_tac (claset() addDs [approx_minus], simpset()));
  1356 qed "approx_hrabs_zero_cancel";
  1457 qed "approx_hrabs_zero_cancel";
  1357 
  1458 
  1358 Goal "e: Infinitesimal ==> abs x @= abs(x+e)";
  1459 Goal "e: Infinitesimal ==> abs x @= abs(x+e)";
  1443 \     ==> x <= y";
  1544 \     ==> x <= y";
  1444 by (blast_tac (claset() addSIs [hypreal_of_real_le_iff RS iffD1,
  1545 by (blast_tac (claset() addSIs [hypreal_of_real_le_iff RS iffD1,
  1445                           hypreal_of_real_le_add_Infininitesimal_cancel]) 1);
  1546                           hypreal_of_real_le_add_Infininitesimal_cancel]) 1);
  1446 qed "hypreal_of_real_le_add_Infininitesimal_cancel2";
  1547 qed "hypreal_of_real_le_add_Infininitesimal_cancel2";
  1447 
  1548 
  1448 Goal "[| hypreal_of_real x < e; e: Infinitesimal |] ==> hypreal_of_real x <= Numeral0";
  1549 Goal "[| hypreal_of_real x < e; e: Infinitesimal |] ==> hypreal_of_real x <= 0";
  1449 by (rtac hypreal_leI 1 THEN Step_tac 1);
  1550 by (rtac hypreal_leI 1 THEN Step_tac 1);
  1450 by (dtac Infinitesimal_interval 1);
  1551 by (dtac Infinitesimal_interval 1);
  1451 by (dtac (SReal_hypreal_of_real RS SReal_Infinitesimal_zero) 4);
  1552 by (dtac (SReal_hypreal_of_real RS SReal_Infinitesimal_zero) 4);
  1452 by (auto_tac (claset(), simpset() addsimps [hypreal_of_real_zero]));
  1553 by Auto_tac;
  1453 qed "hypreal_of_real_less_Infinitesimal_le_zero";
  1554 qed "hypreal_of_real_less_Infinitesimal_le_zero";
  1454 
  1555 
  1455 (*used once, in NSDERIV_inverse*)
  1556 (*used once, in NSDERIV_inverse*)
  1456 Goal "[| h: Infinitesimal; x ~= Numeral0 |] ==> hypreal_of_real x + h ~= Numeral0";
  1557 Goal "[| h: Infinitesimal; x ~= 0 |] ==> hypreal_of_real x + h ~= 0";
  1457 by Auto_tac;  
  1558 by Auto_tac;  
  1458 qed "Infinitesimal_add_not_zero";
  1559 qed "Infinitesimal_add_not_zero";
  1459 
  1560 
  1460 Goal "x*x + y*y : Infinitesimal ==> x*x : Infinitesimal";
  1561 Goal "x*x + y*y : Infinitesimal ==> x*x : Infinitesimal";
  1461 by (rtac Infinitesimal_interval2 1); 
  1562 by (rtac Infinitesimal_interval2 1); 
  1466 Addsimps [Infinitesimal_square_cancel];
  1567 Addsimps [Infinitesimal_square_cancel];
  1467 
  1568 
  1468 Goal "x*x + y*y : HFinite ==> x*x : HFinite";
  1569 Goal "x*x + y*y : HFinite ==> x*x : HFinite";
  1469 by (rtac HFinite_bounded 1); 
  1570 by (rtac HFinite_bounded 1); 
  1470 by (rtac hypreal_self_le_add_pos 2); 
  1571 by (rtac hypreal_self_le_add_pos 2); 
  1471 by (rtac (rename_numerals hypreal_le_square) 2); 
  1572 by (rtac (hypreal_le_square) 2); 
  1472 by (assume_tac 1); 
  1573 by (assume_tac 1); 
  1473 qed "HFinite_square_cancel";
  1574 qed "HFinite_square_cancel";
  1474 Addsimps [HFinite_square_cancel];
  1575 Addsimps [HFinite_square_cancel];
  1475 
  1576 
  1476 Goal "x*x + y*y : Infinitesimal ==> y*y : Infinitesimal";
  1577 Goal "x*x + y*y : Infinitesimal ==> y*y : Infinitesimal";
  1487 qed "HFinite_square_cancel2";
  1588 qed "HFinite_square_cancel2";
  1488 Addsimps [HFinite_square_cancel2];
  1589 Addsimps [HFinite_square_cancel2];
  1489 
  1590 
  1490 Goal "x*x + y*y + z*z : Infinitesimal ==> x*x : Infinitesimal";
  1591 Goal "x*x + y*y + z*z : Infinitesimal ==> x*x : Infinitesimal";
  1491 by (blast_tac (claset() addIs [hypreal_self_le_add_pos2,
  1592 by (blast_tac (claset() addIs [hypreal_self_le_add_pos2,
  1492     Infinitesimal_interval2, rename_numerals hypreal_le_square]) 1);
  1593     Infinitesimal_interval2, hypreal_le_square]) 1);
  1493 qed "Infinitesimal_sum_square_cancel";
  1594 qed "Infinitesimal_sum_square_cancel";
  1494 Addsimps [Infinitesimal_sum_square_cancel];
  1595 Addsimps [Infinitesimal_sum_square_cancel];
  1495 
  1596 
  1496 Goal "x*x + y*y + z*z : HFinite ==> x*x : HFinite";
  1597 Goal "x*x + y*y + z*z : HFinite ==> x*x : HFinite";
  1497 by (blast_tac (claset() addIs [hypreal_self_le_add_pos2, HFinite_bounded, 
  1598 by (blast_tac (claset() addIs [hypreal_self_le_add_pos2, HFinite_bounded, 
  1498                                rename_numerals hypreal_le_square,
  1599                                hypreal_le_square,
  1499 		               HFinite_number_of]) 1);
  1600 		               HFinite_number_of]) 1);
  1500 qed "HFinite_sum_square_cancel";
  1601 qed "HFinite_sum_square_cancel";
  1501 Addsimps [HFinite_sum_square_cancel];
  1602 Addsimps [HFinite_sum_square_cancel];
  1502 
  1603 
  1503 Goal "y*y + x*x + z*z : Infinitesimal ==> x*x : Infinitesimal";
  1604 Goal "y*y + x*x + z*z : Infinitesimal ==> x*x : Infinitesimal";
  1522 by (rtac HFinite_sum_square_cancel 1);
  1623 by (rtac HFinite_sum_square_cancel 1);
  1523 by (asm_full_simp_tac (simpset() addsimps hypreal_add_ac) 1);
  1624 by (asm_full_simp_tac (simpset() addsimps hypreal_add_ac) 1);
  1524 qed "HFinite_sum_square_cancel3";
  1625 qed "HFinite_sum_square_cancel3";
  1525 Addsimps [HFinite_sum_square_cancel3];
  1626 Addsimps [HFinite_sum_square_cancel3];
  1526 
  1627 
  1527 Goal "[| y: monad x; Numeral0 < hypreal_of_real e |] \
  1628 Goal "[| y: monad x; 0 < hypreal_of_real e |] \
  1528 \     ==> abs (y + -x) < hypreal_of_real e";
  1629 \     ==> abs (y + -x) < hypreal_of_real e";
  1529 by (dtac (mem_monad_approx RS approx_sym) 1);
  1630 by (dtac (mem_monad_approx RS approx_sym) 1);
  1530 by (dtac (bex_Infinitesimal_iff RS iffD2) 1);
  1631 by (dtac (bex_Infinitesimal_iff RS iffD2) 1);
  1531 by (auto_tac (claset() addSDs [InfinitesimalD], simpset()));
  1632 by (auto_tac (claset() addSDs [InfinitesimalD], simpset()));
  1532 qed "monad_hrabs_less";
  1633 qed "monad_hrabs_less";
  1612 \     EX e: Infinitesimal. x = st(x) + e";
  1713 \     EX e: Infinitesimal. x = st(x) + e";
  1613 by (blast_tac (claset() addSDs [(st_approx_self RS 
  1714 by (blast_tac (claset() addSDs [(st_approx_self RS 
  1614     approx_sym),bex_Infinitesimal_iff2 RS iffD2]) 1);
  1715     approx_sym),bex_Infinitesimal_iff2 RS iffD2]) 1);
  1615 qed "HFinite_st_Infinitesimal_add";
  1716 qed "HFinite_st_Infinitesimal_add";
  1616 
  1717 
  1617 Goal "[| x: HFinite; y: HFinite |] \
  1718 Goal "[| x: HFinite; y: HFinite |] ==> st (x + y) = st(x) + st(y)";
  1618 \     ==> st (x + y) = st(x) + st(y)";
       
  1619 by (forward_tac [HFinite_st_Infinitesimal_add] 1);
  1719 by (forward_tac [HFinite_st_Infinitesimal_add] 1);
  1620 by (forw_inst_tac [("x","y")] HFinite_st_Infinitesimal_add 1);
  1720 by (forw_inst_tac [("x","y")] HFinite_st_Infinitesimal_add 1);
  1621 by (Step_tac 1);
  1721 by (Step_tac 1);
  1622 by (subgoal_tac "st (x + y) = st ((st x + e) + (st y + ea))" 1);
  1722 by (subgoal_tac "st (x + y) = st ((st x + e) + (st y + ea))" 1);
  1623 by (dtac sym 2 THEN dtac sym 2);
  1723 by (dtac sym 2 THEN dtac sym 2);
  1632 
  1732 
  1633 Goal "st (number_of w) = number_of w";
  1733 Goal "st (number_of w) = number_of w";
  1634 by (rtac (SReal_number_of RS st_SReal_eq) 1);
  1734 by (rtac (SReal_number_of RS st_SReal_eq) 1);
  1635 qed "st_number_of";
  1735 qed "st_number_of";
  1636 Addsimps [st_number_of];
  1736 Addsimps [st_number_of];
       
  1737 
       
  1738 (*the theorem above for the special cases of zero and one*)
       
  1739 Addsimps
       
  1740   (map (simplify (simpset()))
       
  1741    [inst "w" "Pls" st_number_of, inst "w" "Pls BIT True" st_number_of]);
  1637 
  1742 
  1638 Goal "y: HFinite ==> st(-y) = -st(y)";
  1743 Goal "y: HFinite ==> st(-y) = -st(y)";
  1639 by (forward_tac [HFinite_minus_iff RS iffD2] 1);
  1744 by (forward_tac [HFinite_minus_iff RS iffD2] 1);
  1640 by (rtac hypreal_add_minus_eq_minus 1);
  1745 by (rtac hypreal_add_minus_eq_minus 1);
  1641 by (dtac (st_add RS sym) 1 THEN assume_tac 1);
  1746 by (dtac (st_add RS sym) 1 THEN assume_tac 1);
  1680 by (REPEAT(dtac (SReal_subset_HFinite RS subsetD) 1));
  1785 by (REPEAT(dtac (SReal_subset_HFinite RS subsetD) 1));
  1681 by (rtac (hypreal_add_assoc RS subst) 1);
  1786 by (rtac (hypreal_add_assoc RS subst) 1);
  1682 by (blast_tac (claset() addSIs [lemma_st_mult]) 1);
  1787 by (blast_tac (claset() addSIs [lemma_st_mult]) 1);
  1683 qed "st_mult";
  1788 qed "st_mult";
  1684 
  1789 
  1685 Goal "x: Infinitesimal ==> st x = Numeral0";
  1790 Goal "x: Infinitesimal ==> st x = 0";
       
  1791 by (stac (hypreal_numeral_0_eq_0 RS sym) 1); 
  1686 by (rtac (st_number_of RS subst) 1);
  1792 by (rtac (st_number_of RS subst) 1);
  1687 by (rtac approx_st_eq 1);
  1793 by (rtac approx_st_eq 1);
  1688 by (auto_tac (claset() addIs [Infinitesimal_subset_HFinite RS subsetD],
  1794 by (auto_tac (claset() addIs [Infinitesimal_subset_HFinite RS subsetD],
  1689               simpset() addsimps [mem_infmal_iff RS sym]));
  1795               simpset() addsimps [mem_infmal_iff RS sym]));
  1690 qed "st_Infinitesimal";
  1796 qed "st_Infinitesimal";
  1691 
  1797 
  1692 Goal "st(x) ~= Numeral0 ==> x ~: Infinitesimal";
  1798 Goal "st(x) ~= 0 ==> x ~: Infinitesimal";
  1693 by (fast_tac (claset() addIs [st_Infinitesimal]) 1);
  1799 by (fast_tac (claset() addIs [st_Infinitesimal]) 1);
  1694 qed "st_not_Infinitesimal";
  1800 qed "st_not_Infinitesimal";
  1695 
  1801 
  1696 Goal "[| x: HFinite; st x ~= Numeral0 |] \
  1802 Goal "[| x: HFinite; st x ~= 0 |] \
  1697 \     ==> st(inverse x) = inverse (st x)";
  1803 \     ==> st(inverse x) = inverse (st x)";
  1698 by (res_inst_tac [("c1","st x")] (hypreal_mult_left_cancel RS iffD1) 1);
  1804 by (res_inst_tac [("c1","st x")] (hypreal_mult_left_cancel RS iffD1) 1);
  1699 by (auto_tac (claset(),
  1805 by (auto_tac (claset(),
  1700        simpset() addsimps [st_mult RS sym, st_not_Infinitesimal,
  1806        simpset() addsimps [st_mult RS sym, st_not_Infinitesimal,
  1701                            HFinite_inverse]));
  1807                            HFinite_inverse]));
  1702 by (stac hypreal_mult_inverse 1); 
  1808 by (stac hypreal_mult_inverse 1); 
  1703 by Auto_tac;  
  1809 by Auto_tac;  
  1704 qed "st_inverse";
  1810 qed "st_inverse";
  1705 
  1811 
  1706 Goal "[| x: HFinite; y: HFinite; st y ~= Numeral0 |] \
  1812 Goal "[| x: HFinite; y: HFinite; st y ~= 0 |] \
  1707 \     ==> st(x/y) = (st x) / (st y)";
  1813 \     ==> st(x/y) = (st x) / (st y)";
  1708 by (auto_tac (claset(),
  1814 by (auto_tac (claset(),
  1709       simpset() addsimps [hypreal_divide_def, st_mult, st_not_Infinitesimal, 
  1815       simpset() addsimps [hypreal_divide_def, st_mult, st_not_Infinitesimal, 
  1710                           HFinite_inverse, st_inverse]));
  1816                           HFinite_inverse, st_inverse]));
  1711 qed "st_divide";
  1817 qed "st_divide";
  1732 \     |] ==> st x <= st y";
  1838 \     |] ==> st x <= st y";
  1733 by (auto_tac (claset() addDs [Infinitesimal_add_st_less],
  1839 by (auto_tac (claset() addDs [Infinitesimal_add_st_less],
  1734               simpset()));
  1840               simpset()));
  1735 qed "Infinitesimal_add_st_le_cancel";
  1841 qed "Infinitesimal_add_st_le_cancel";
  1736 
  1842 
  1737 Goal "[| x: HFinite; y: HFinite; x <= y |] \
  1843 Goal "[| x: HFinite; y: HFinite; x <= y |] ==> st(x) <= st(y)";
  1738 \     ==> st(x) <= st(y)";
       
  1739 by (forward_tac [HFinite_st_Infinitesimal_add] 1);
  1844 by (forward_tac [HFinite_st_Infinitesimal_add] 1);
  1740 by (rotate_tac 1 1);
  1845 by (rotate_tac 1 1);
  1741 by (forward_tac [HFinite_st_Infinitesimal_add] 1);
  1846 by (forward_tac [HFinite_st_Infinitesimal_add] 1);
  1742 by (Step_tac 1);
  1847 by (Step_tac 1);
  1743 by (rtac Infinitesimal_add_st_le_cancel 1);
  1848 by (rtac Infinitesimal_add_st_le_cancel 1);
  1744 by (res_inst_tac [("x","ea"),("y","e")] 
  1849 by (res_inst_tac [("x","ea"),("y","e")] 
  1745              Infinitesimal_diff 3);
  1850              Infinitesimal_diff 3);
  1746 by (auto_tac (claset(),
  1851 by (auto_tac (claset(), simpset() addsimps [hypreal_add_assoc RS sym]));
  1747          simpset() addsimps [hypreal_add_assoc RS sym]));
       
  1748 qed "st_le";
  1852 qed "st_le";
  1749 
  1853 
  1750 Goal "[| Numeral0 <= x;  x: HFinite |] ==> Numeral0 <= st x";
  1854 Goal "[| 0 <= x;  x: HFinite |] ==> 0 <= st x";
       
  1855 by (stac (hypreal_numeral_0_eq_0 RS sym) 1); 
  1751 by (rtac (st_number_of RS subst) 1);
  1856 by (rtac (st_number_of RS subst) 1);
  1752 by (auto_tac (claset() addIs [st_le],
  1857 by (rtac st_le 1); 
  1753               simpset() delsimps [st_number_of]));
  1858 by Auto_tac; 
  1754 qed "st_zero_le";
  1859 qed "st_zero_le";
  1755 
  1860 
  1756 Goal "[| x <= Numeral0;  x: HFinite |] ==> st x <= Numeral0";
  1861 Goal "[| x <= 0;  x: HFinite |] ==> st x <= 0";
       
  1862 by (stac (hypreal_numeral_0_eq_0 RS sym) 1); 
  1757 by (rtac (st_number_of RS subst) 1);
  1863 by (rtac (st_number_of RS subst) 1);
  1758 by (auto_tac (claset() addIs [st_le],
  1864 by (rtac st_le 1); 
  1759               simpset() delsimps [st_number_of]));
  1865 by Auto_tac; 
  1760 qed "st_zero_ge";
  1866 qed "st_zero_ge";
  1761 
  1867 
  1762 Goal "x: HFinite ==> abs(st x) = st(abs x)";
  1868 Goal "x: HFinite ==> abs(st x) = st(abs x)";
  1763 by (case_tac "Numeral0 <= x" 1);
  1869 by (case_tac "0 <= x" 1);
  1764 by (auto_tac (claset() addSDs [not_hypreal_leE, order_less_imp_le],
  1870 by (auto_tac (claset() addSDs [not_hypreal_leE, order_less_imp_le],
  1765               simpset() addsimps [st_zero_le,hrabs_eqI1, hrabs_minus_eqI1,
  1871               simpset() addsimps [st_zero_le,hrabs_eqI1, hrabs_minus_eqI1,
  1766                                   st_zero_ge,st_minus]));
  1872                                   st_zero_ge,st_minus]));
  1767 qed "st_hrabs";
  1873 qed "st_hrabs";
  1768 
  1874 
  1832 Goal "{n. abs (xa n) <= (u::real)} Int {n. u <= abs (xa n)} \
  1938 Goal "{n. abs (xa n) <= (u::real)} Int {n. u <= abs (xa n)} \
  1833 \         = {n. abs(xa n) = u}";
  1939 \         = {n. abs(xa n) = u}";
  1834 by Auto_tac;
  1940 by Auto_tac;
  1835 qed "lemma_Int_eq1";
  1941 qed "lemma_Int_eq1";
  1836 
  1942 
  1837 Goal "{n. abs (xa n) = u} <= {n. abs (xa n) < u + (Numeral1::real)}";
  1943 Goal "{n. abs (xa n) = u} <= {n. abs (xa n) < u + (1::real)}";
  1838 by Auto_tac;
  1944 by Auto_tac;
  1839 qed "lemma_FreeUltrafilterNat_one";
  1945 qed "lemma_FreeUltrafilterNat_one";
  1840 
  1946 
  1841 (*-------------------------------------
  1947 (*-------------------------------------
  1842   Exclude this type of sets from free 
  1948   Exclude this type of sets from free 
  1845 Goal "[| xa: Rep_hypreal x; \
  1951 Goal "[| xa: Rep_hypreal x; \
  1846 \                 {n. abs (xa n) = u} : FreeUltrafilterNat \
  1952 \                 {n. abs (xa n) = u} : FreeUltrafilterNat \
  1847 \              |] ==> x: HFinite";
  1953 \              |] ==> x: HFinite";
  1848 by (rtac FreeUltrafilterNat_HFinite 1);
  1954 by (rtac FreeUltrafilterNat_HFinite 1);
  1849 by (res_inst_tac [("x","xa")] bexI 1);
  1955 by (res_inst_tac [("x","xa")] bexI 1);
  1850 by (res_inst_tac [("x","u + Numeral1")] exI 1);
  1956 by (res_inst_tac [("x","u + 1")] exI 1);
  1851 by (Ultra_tac 1 THEN assume_tac 1);
  1957 by (Ultra_tac 1 THEN assume_tac 1);
  1852 qed "FreeUltrafilterNat_const_Finite";
  1958 qed "FreeUltrafilterNat_const_Finite";
  1853 
  1959 
  1854 val [prem] = goal thy "x : HInfinite ==> EX X: Rep_hypreal x. \
  1960 val [prem] = goal thy "x : HInfinite ==> EX X: Rep_hypreal x. \
  1855 \          ALL u. {n. u < abs (X n)}:  FreeUltrafilterNat";
  1961 \          ALL u. {n. u < abs (X n)}:  FreeUltrafilterNat";
  1913 by Auto_tac;
  2019 by Auto_tac;
  1914 qed "lemma_free5";
  2020 qed "lemma_free5";
  1915 
  2021 
  1916 Goalw [Infinitesimal_def] 
  2022 Goalw [Infinitesimal_def] 
  1917           "x : Infinitesimal ==> EX X: Rep_hypreal x. \
  2023           "x : Infinitesimal ==> EX X: Rep_hypreal x. \
  1918 \          ALL u. Numeral0 < u --> {n. abs (X n) < u}:  FreeUltrafilterNat";
  2024 \          ALL u. 0 < u --> {n. abs (X n) < u}:  FreeUltrafilterNat";
  1919 by (auto_tac (claset(), simpset() addsimps [hrabs_interval_iff]));
  2025 by (auto_tac (claset(), simpset() addsimps [hrabs_interval_iff]));
  1920 by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  2026 by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  1921 by (EVERY[Auto_tac, rtac bexI 1, rtac lemma_hyprel_refl 2, Step_tac 1]);
  2027 by (EVERY[Auto_tac, rtac bexI 1, rtac lemma_hyprel_refl 2, Step_tac 1]);
  1922 by (dtac (hypreal_of_real_less_iff RS iffD2) 1);
  2028 by (dtac (hypreal_of_real_less_iff RS iffD2) 1);
  1923 by (dres_inst_tac [("x","hypreal_of_real u")] bspec 1);
  2029 by (dres_inst_tac [("x","hypreal_of_real u")] bspec 1);
  1924 by (auto_tac (claset(), simpset() addsimps [hypreal_of_real_zero]));
  2030 by Auto_tac;
  1925 by (auto_tac (claset(), 
  2031 by (auto_tac (claset(), 
  1926               simpset() addsimps [hypreal_less_def, hypreal_minus,
  2032               simpset() addsimps [hypreal_less_def, hypreal_minus,
  1927                                   hypreal_of_real_def,hypreal_of_real_zero]));
  2033                                   hypreal_of_real_def]));
  1928 by (Ultra_tac 1 THEN arith_tac 1);
  2034 by (Ultra_tac 1 THEN arith_tac 1);
  1929 qed "Infinitesimal_FreeUltrafilterNat";
  2035 qed "Infinitesimal_FreeUltrafilterNat";
  1930 
  2036 
  1931 Goalw [Infinitesimal_def] 
  2037 Goalw [Infinitesimal_def] 
  1932      "EX X: Rep_hypreal x. \
  2038      "EX X: Rep_hypreal x. \
  1933 \           ALL u. Numeral0 < u --> {n. abs (X n) < u} : FreeUltrafilterNat \
  2039 \           ALL u. 0 < u --> {n. abs (X n) < u} : FreeUltrafilterNat \
  1934 \     ==> x : Infinitesimal";
  2040 \     ==> x : Infinitesimal";
  1935 by (auto_tac (claset(),
  2041 by (auto_tac (claset(),
  1936               simpset() addsimps [hrabs_interval_iff,abs_interval_iff]));
  2042               simpset() addsimps [hrabs_interval_iff,abs_interval_iff]));
  1937 by (auto_tac (claset(),
  2043 by (auto_tac (claset(),
  1938               simpset() addsimps [SReal_iff]));
  2044               simpset() addsimps [SReal_iff]));
  1940                                addIs [FreeUltrafilterNat_subset],
  2046                                addIs [FreeUltrafilterNat_subset],
  1941     simpset() addsimps [hypreal_less_def, hypreal_minus,hypreal_of_real_def]));
  2047     simpset() addsimps [hypreal_less_def, hypreal_minus,hypreal_of_real_def]));
  1942 qed "FreeUltrafilterNat_Infinitesimal";
  2048 qed "FreeUltrafilterNat_Infinitesimal";
  1943 
  2049 
  1944 Goal "(x : Infinitesimal) = (EX X: Rep_hypreal x. \
  2050 Goal "(x : Infinitesimal) = (EX X: Rep_hypreal x. \
  1945 \          ALL u. Numeral0 < u --> {n. abs (X n) < u}:  FreeUltrafilterNat)";
  2051 \          ALL u. 0 < u --> {n. abs (X n) < u}:  FreeUltrafilterNat)";
  1946 by (blast_tac (claset() addSIs [Infinitesimal_FreeUltrafilterNat,
  2052 by (blast_tac (claset() addSIs [Infinitesimal_FreeUltrafilterNat,
  1947                FreeUltrafilterNat_Infinitesimal]) 1);
  2053                FreeUltrafilterNat_Infinitesimal]) 1);
  1948 qed "Infinitesimal_FreeUltrafilterNat_iff";
  2054 qed "Infinitesimal_FreeUltrafilterNat_iff";
  1949 
  2055 
  1950 (*------------------------------------------------------------------------
  2056 (*------------------------------------------------------------------------
  1951          Infinitesimals as smaller than 1/n for all n::nat (> 0)
  2057          Infinitesimals as smaller than 1/n for all n::nat (> 0)
  1952  ------------------------------------------------------------------------*)
  2058  ------------------------------------------------------------------------*)
  1953 
  2059 
  1954 Goal "(ALL r. Numeral0 < r --> x < r) = (ALL n. x < inverse(real (Suc n)))";
  2060 Goal "(ALL r. 0 < r --> x < r) = (ALL n. x < inverse(real (Suc n)))";
  1955 by (auto_tac (claset(), simpset() addsimps [real_of_nat_Suc_gt_zero]));
  2061 by (auto_tac (claset(), simpset() addsimps [real_of_nat_Suc_gt_zero]));
  1956 by (blast_tac (claset() addSDs [reals_Archimedean] 
  2062 by (blast_tac (claset() addSDs [reals_Archimedean] 
  1957                         addIs [order_less_trans]) 1);
  2063                         addIs [order_less_trans]) 1);
  1958 qed "lemma_Infinitesimal";
  2064 qed "lemma_Infinitesimal";
  1959 
  2065 
  1960 Goal "(ALL r: Reals. Numeral0 < r --> x < r) = \
  2066 Goal "(ALL r: Reals. 0 < r --> x < r) = \
  1961 \     (ALL n. x < inverse(hypreal_of_nat (Suc n)))";
  2067 \     (ALL n. x < inverse(hypreal_of_nat (Suc n)))";
  1962 by (Step_tac 1);
  2068 by (Step_tac 1);
  1963 by (dres_inst_tac [("x","inverse (hypreal_of_real(real (Suc n)))")] 
  2069 by (dres_inst_tac [("x","inverse (hypreal_of_real(real (Suc n)))")] 
  1964     bspec 1);
  2070     bspec 1);
  1965 by (full_simp_tac (simpset() addsimps [SReal_inverse]) 1); 
  2071 by (full_simp_tac (simpset() addsimps [SReal_inverse]) 1); 
  1966 by (rtac (real_of_nat_Suc_gt_zero RS rename_numerals real_inverse_gt_zero RS 
  2072 by (rtac (real_of_nat_Suc_gt_zero RS real_inverse_gt_0 RS 
  1967           (hypreal_of_real_less_iff RS iffD2) RSN(2,impE)) 1);
  2073           (hypreal_of_real_less_iff RS iffD2) RSN(2,impE)) 1);
  1968 by (assume_tac 2);
  2074 by (assume_tac 2);
  1969 by (asm_full_simp_tac (simpset() addsimps 
  2075 by (asm_full_simp_tac (simpset() addsimps 
  1970        [real_of_nat_Suc_gt_zero, hypreal_of_real_zero, hypreal_of_nat_def]) 1);
  2076        [real_of_nat_Suc_gt_zero, hypreal_of_nat_def]) 1);
  1971 by (auto_tac (claset() addSDs [reals_Archimedean],
  2077 by (auto_tac (claset() addSDs [reals_Archimedean],
  1972               simpset() addsimps [SReal_iff,hypreal_of_real_zero RS sym]));
  2078               simpset() addsimps [SReal_iff]));
  1973 by (dtac (hypreal_of_real_less_iff RS iffD2) 1);
  2079 by (dtac (hypreal_of_real_less_iff RS iffD2) 1);
  1974 by (asm_full_simp_tac (simpset() addsimps 
  2080 by (asm_full_simp_tac (simpset() addsimps 
  1975          [real_of_nat_Suc_gt_zero, hypreal_of_nat_def])1);
  2081          [real_of_nat_Suc_gt_zero, hypreal_of_nat_def])1);
  1976 by (blast_tac (claset() addIs [order_less_trans]) 1);
  2082 by (blast_tac (claset() addIs [order_less_trans]) 1);
  1977 qed "lemma_Infinitesimal2";
  2083 qed "lemma_Infinitesimal2";
  2087 by (auto_tac (claset() addIs [Infinitesimal_subset_HFinite RS subsetD],
  2193 by (auto_tac (claset() addIs [Infinitesimal_subset_HFinite RS subsetD],
  2088     simpset()));
  2194     simpset()));
  2089 qed "HFinite_epsilon";
  2195 qed "HFinite_epsilon";
  2090 Addsimps [HFinite_epsilon];
  2196 Addsimps [HFinite_epsilon];
  2091 
  2197 
  2092 Goal "epsilon @= Numeral0";
  2198 Goal "epsilon @= 0";
  2093 by (simp_tac (simpset() addsimps [mem_infmal_iff RS sym]) 1);
  2199 by (simp_tac (simpset() addsimps [mem_infmal_iff RS sym]) 1);
  2094 qed "epsilon_approx_zero";
  2200 qed "epsilon_approx_zero";
  2095 Addsimps [epsilon_approx_zero];
  2201 Addsimps [epsilon_approx_zero];
  2096 
  2202 
  2097 (*------------------------------------------------------------------------
  2203 (*------------------------------------------------------------------------
  2107 by (stac pos_real_less_divide_eq 1); 
  2213 by (stac pos_real_less_divide_eq 1); 
  2108 by (simp_tac (simpset() addsimps [real_mult_commute]) 2); 
  2214 by (simp_tac (simpset() addsimps [real_mult_commute]) 2); 
  2109 by (simp_tac (simpset() addsimps [real_of_nat_Suc_gt_zero]) 1); 
  2215 by (simp_tac (simpset() addsimps [real_of_nat_Suc_gt_zero]) 1); 
  2110 qed "real_of_nat_less_inverse_iff";
  2216 qed "real_of_nat_less_inverse_iff";
  2111 
  2217 
  2112 Goal "Numeral0 < u ==> finite {n. u < inverse(real(Suc n))}";
  2218 Goal "0 < u ==> finite {n. u < inverse(real(Suc n))}";
  2113 by (asm_simp_tac (simpset() addsimps [real_of_nat_less_inverse_iff]) 1);
  2219 by (asm_simp_tac (simpset() addsimps [real_of_nat_less_inverse_iff]) 1);
  2114 by (asm_simp_tac (simpset() addsimps [real_of_nat_Suc, 
  2220 by (asm_simp_tac (simpset() addsimps [real_of_nat_Suc, 
  2115                          real_less_diff_eq RS sym]) 1); 
  2221                          real_less_diff_eq RS sym]) 1); 
  2116 by (rtac finite_real_of_nat_less_real 1);
  2222 by (rtac finite_real_of_nat_less_real 1);
  2117 qed "finite_inverse_real_of_posnat_gt_real";
  2223 qed "finite_inverse_real_of_posnat_gt_real";
  2120 \    {n. u < inverse(real(Suc n))} Un {n. u = inverse(real(Suc n))}";
  2226 \    {n. u < inverse(real(Suc n))} Un {n. u = inverse(real(Suc n))}";
  2121 by (auto_tac (claset() addDs [order_le_imp_less_or_eq],
  2227 by (auto_tac (claset() addDs [order_le_imp_less_or_eq],
  2122               simpset() addsimps [order_less_imp_le]));
  2228               simpset() addsimps [order_less_imp_le]));
  2123 qed "lemma_real_le_Un_eq2";
  2229 qed "lemma_real_le_Un_eq2";
  2124 
  2230 
  2125 Goal "(inverse (real(Suc n)) <= r) = (Numeral1 <= r * real(Suc n))";
  2231 Goal "(inverse (real(Suc n)) <= r) = (1 <= r * real(Suc n))";
  2126 by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); 
  2232 by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); 
  2127 by (simp_tac (simpset() addsimps [real_inverse_eq_divide]) 1);
  2233 by (simp_tac (simpset() addsimps [real_inverse_eq_divide]) 1);
  2128 by (stac pos_real_less_divide_eq 1); 
  2234 by (stac pos_real_less_divide_eq 1); 
  2129 by (simp_tac (simpset() addsimps [real_of_nat_Suc_gt_zero]) 1); 
  2235 by (simp_tac (simpset() addsimps [real_of_nat_Suc_gt_zero]) 1); 
  2130 by (simp_tac (simpset() addsimps [real_mult_commute]) 1); 
  2236 by (simp_tac (simpset() addsimps [real_mult_commute]) 1); 
  2136 			  real_not_refl2 RS not_sym]));
  2242 			  real_not_refl2 RS not_sym]));
  2137 qed "real_of_nat_inverse_eq_iff";
  2243 qed "real_of_nat_inverse_eq_iff";
  2138 
  2244 
  2139 Goal "finite {n::nat. u = inverse(real(Suc n))}";
  2245 Goal "finite {n::nat. u = inverse(real(Suc n))}";
  2140 by (asm_simp_tac (simpset() addsimps [real_of_nat_inverse_eq_iff]) 1);
  2246 by (asm_simp_tac (simpset() addsimps [real_of_nat_inverse_eq_iff]) 1);
  2141 by (cut_inst_tac [("x","inverse u - Numeral1")] lemma_finite_omega_set 1);
  2247 by (cut_inst_tac [("x","inverse u - 1")] lemma_finite_omega_set 1);
  2142 by (asm_full_simp_tac (simpset() addsimps [real_of_nat_Suc, 
  2248 by (asm_full_simp_tac (simpset() addsimps [real_of_nat_Suc, 
  2143                          real_diff_eq_eq RS sym, eq_commute]) 1); 
  2249                          real_diff_eq_eq RS sym, eq_commute]) 1); 
  2144 qed "lemma_finite_omega_set2";
  2250 qed "lemma_finite_omega_set2";
  2145 
  2251 
  2146 Goal "Numeral0 < u ==> finite {n. u <= inverse(real(Suc n))}";
  2252 Goal "0 < u ==> finite {n. u <= inverse(real(Suc n))}";
  2147 by (auto_tac (claset(), 
  2253 by (auto_tac (claset(), 
  2148       simpset() addsimps [lemma_real_le_Un_eq2,lemma_finite_omega_set2,
  2254       simpset() addsimps [lemma_real_le_Un_eq2,lemma_finite_omega_set2,
  2149                           finite_inverse_real_of_posnat_gt_real]));
  2255                           finite_inverse_real_of_posnat_gt_real]));
  2150 qed "finite_inverse_real_of_posnat_ge_real";
  2256 qed "finite_inverse_real_of_posnat_ge_real";
  2151 
  2257 
  2152 Goal "Numeral0 < u ==> \
  2258 Goal "0 < u ==> \
  2153 \      {n. u <= inverse(real(Suc n))} ~: FreeUltrafilterNat";
  2259 \      {n. u <= inverse(real(Suc n))} ~: FreeUltrafilterNat";
  2154 by (blast_tac (claset() addSIs [FreeUltrafilterNat_finite,
  2260 by (blast_tac (claset() addSIs [FreeUltrafilterNat_finite,
  2155                                 finite_inverse_real_of_posnat_ge_real]) 1);
  2261                                 finite_inverse_real_of_posnat_ge_real]) 1);
  2156 qed "inverse_real_of_posnat_ge_real_FreeUltrafilterNat";
  2262 qed "inverse_real_of_posnat_ge_real_FreeUltrafilterNat";
  2157 
  2263 
  2164 \     {n. inverse(real(Suc n)) < u}";
  2270 \     {n. inverse(real(Suc n)) < u}";
  2165 by (auto_tac (claset() addSDs [order_le_less_trans],
  2271 by (auto_tac (claset() addSDs [order_le_less_trans],
  2166               simpset() addsimps [not_real_leE]));
  2272               simpset() addsimps [not_real_leE]));
  2167 val lemma = result();
  2273 val lemma = result();
  2168 
  2274 
  2169 Goal "Numeral0 < u ==> \
  2275 Goal "0 < u ==> \
  2170 \     {n. inverse(real(Suc n)) < u} : FreeUltrafilterNat";
  2276 \     {n. inverse(real(Suc n)) < u} : FreeUltrafilterNat";
  2171 by (cut_inst_tac [("u","u")]  inverse_real_of_posnat_ge_real_FreeUltrafilterNat 1);
  2277 by (cut_inst_tac [("u","u")]  inverse_real_of_posnat_ge_real_FreeUltrafilterNat 1);
  2172 by (auto_tac (claset() addDs [FreeUltrafilterNat_Compl_mem],
  2278 by (auto_tac (claset() addDs [FreeUltrafilterNat_Compl_mem],
  2173     simpset() addsimps [lemma]));
  2279     simpset() addsimps [lemma]));
  2174 qed "FreeUltrafilterNat_inverse_real_of_posnat";
  2280 qed "FreeUltrafilterNat_inverse_real_of_posnat";
  2185     |X(n) - x| < 1/n ==> [<X n>] - hypreal_of_real x|: Infinitesimal 
  2291     |X(n) - x| < 1/n ==> [<X n>] - hypreal_of_real x|: Infinitesimal 
  2186  -----------------------------------------------------*)
  2292  -----------------------------------------------------*)
  2187 Goal "ALL n. abs(X n + -x) < inverse(real(Suc n)) \ 
  2293 Goal "ALL n. abs(X n + -x) < inverse(real(Suc n)) \ 
  2188 \    ==> Abs_hypreal(hyprel``{X}) + -hypreal_of_real x : Infinitesimal";
  2294 \    ==> Abs_hypreal(hyprel``{X}) + -hypreal_of_real x : Infinitesimal";
  2189 by (auto_tac (claset() addSIs [bexI] 
  2295 by (auto_tac (claset() addSIs [bexI] 
  2190            addDs [rename_numerals FreeUltrafilterNat_inverse_real_of_posnat,
  2296            addDs [FreeUltrafilterNat_inverse_real_of_posnat,
  2191                   FreeUltrafilterNat_all,FreeUltrafilterNat_Int] 
  2297                   FreeUltrafilterNat_all,FreeUltrafilterNat_Int] 
  2192            addIs [order_less_trans, FreeUltrafilterNat_subset],
  2298            addIs [order_less_trans, FreeUltrafilterNat_subset],
  2193       simpset() addsimps [hypreal_minus, 
  2299       simpset() addsimps [hypreal_minus, 
  2194                           hypreal_of_real_def,hypreal_add,
  2300                           hypreal_of_real_def,hypreal_add,
  2195                       Infinitesimal_FreeUltrafilterNat_iff,hypreal_inverse]));
  2301                       Infinitesimal_FreeUltrafilterNat_iff,hypreal_inverse]));
  2210 
  2316 
  2211 Goal "ALL n. abs(X n + -Y n) < inverse(real(Suc n)) \ 
  2317 Goal "ALL n. abs(X n + -Y n) < inverse(real(Suc n)) \ 
  2212 \     ==> Abs_hypreal(hyprel``{X}) + \
  2318 \     ==> Abs_hypreal(hyprel``{X}) + \
  2213 \         -Abs_hypreal(hyprel``{Y}) : Infinitesimal";
  2319 \         -Abs_hypreal(hyprel``{Y}) : Infinitesimal";
  2214 by (auto_tac (claset() addSIs [bexI] 
  2320 by (auto_tac (claset() addSIs [bexI] 
  2215                   addDs [rename_numerals 
  2321                   addDs [FreeUltrafilterNat_inverse_real_of_posnat,
  2216                          FreeUltrafilterNat_inverse_real_of_posnat,
       
  2217                          FreeUltrafilterNat_all,FreeUltrafilterNat_Int] 
  2322                          FreeUltrafilterNat_all,FreeUltrafilterNat_Int] 
  2218         addIs [order_less_trans, FreeUltrafilterNat_subset],
  2323         addIs [order_less_trans, FreeUltrafilterNat_subset],
  2219      simpset() addsimps 
  2324      simpset() addsimps 
  2220             [Infinitesimal_FreeUltrafilterNat_iff,hypreal_minus,hypreal_add, 
  2325             [Infinitesimal_FreeUltrafilterNat_iff,hypreal_minus,hypreal_add, 
  2221              hypreal_inverse]));
  2326              hypreal_inverse]));