src/HOL/Real/Hyperreal/NSA.ML
changeset 10712 351ba950d4d9
parent 10690 cd80241125b0
child 10715 c838477b5c18
equal deleted inserted replaced
10711:a9f6994fb906 10712:351ba950d4d9
    91 by (auto_tac (claset(),
    91 by (auto_tac (claset(),
    92               simpset() addsimps [hypreal_of_real_not_eq_omega RS not_sym]));
    92               simpset() addsimps [hypreal_of_real_not_eq_omega RS not_sym]));
    93 qed "SReal_omega_not_mem";
    93 qed "SReal_omega_not_mem";
    94 
    94 
    95 Goalw [SReal_def] "{x. hypreal_of_real x : SReal} = (UNIV::real set)";
    95 Goalw [SReal_def] "{x. hypreal_of_real x : SReal} = (UNIV::real set)";
    96 by (Auto_tac);
    96 by Auto_tac;
    97 qed "SReal_UNIV_real";
    97 qed "SReal_UNIV_real";
    98 
    98 
    99 Goalw [SReal_def] "(x: SReal) = (EX y. x = hypreal_of_real  y)";
    99 Goalw [SReal_def] "(x: SReal) = (EX y. x = hypreal_of_real  y)";
   100 by (Auto_tac);
   100 by Auto_tac;
   101 qed "SReal_iff";
   101 qed "SReal_iff";
   102 
   102 
   103 Goalw [SReal_def] "hypreal_of_real ``(UNIV::real set) = SReal";
   103 Goalw [SReal_def] "hypreal_of_real ``(UNIV::real set) = SReal";
   104 by (Auto_tac);
   104 by Auto_tac;
   105 qed "hypreal_of_real_image";
   105 qed "hypreal_of_real_image";
   106 
   106 
   107 Goalw [SReal_def] "inv hypreal_of_real ``SReal = (UNIV::real set)";
   107 Goalw [SReal_def] "inv hypreal_of_real ``SReal = (UNIV::real set)";
   108 by (Auto_tac);
   108 by Auto_tac;
   109 by (rtac (inj_hypreal_of_real RS inv_f_f RS subst) 1);
   109 by (rtac (inj_hypreal_of_real RS inv_f_f RS subst) 1);
   110 by (Blast_tac 1);
   110 by (Blast_tac 1);
   111 qed "inv_hypreal_of_real_image";
   111 qed "inv_hypreal_of_real_image";
   112 
   112 
   113 Goalw [SReal_def] 
   113 Goalw [SReal_def] 
   117 
   117 
   118 Goal "[| x: SReal; y: SReal; x < y |] ==> EX r: SReal. x < r & r < y";
   118 Goal "[| x: SReal; y: SReal; x < y |] ==> EX r: SReal. x < r & r < y";
   119 by (auto_tac (claset(),simpset() addsimps [SReal_iff]));
   119 by (auto_tac (claset(),simpset() addsimps [SReal_iff]));
   120 by (dtac real_dense 1 THEN Step_tac 1);
   120 by (dtac real_dense 1 THEN Step_tac 1);
   121 by (res_inst_tac [("x","hypreal_of_real r")] bexI 1);
   121 by (res_inst_tac [("x","hypreal_of_real r")] bexI 1);
   122 by (Auto_tac);
   122 by Auto_tac;
   123 qed "SReal_dense";
   123 qed "SReal_dense";
   124 
   124 
   125 (*------------------------------------------------------------------
   125 (*------------------------------------------------------------------
   126                    Completeness of SReal
   126                    Completeness of SReal
   127  ------------------------------------------------------------------*)
   127  ------------------------------------------------------------------*)
   193 qed "lemma_isLub_hypreal_of_real";
   193 qed "lemma_isLub_hypreal_of_real";
   194 
   194 
   195 Goalw [isLub_def,leastP_def,isUb_def] 
   195 Goalw [isLub_def,leastP_def,isUb_def] 
   196       "EX Yo. isLub SReal P (hypreal_of_real Yo) \
   196       "EX Yo. isLub SReal P (hypreal_of_real Yo) \
   197 \      ==> EX Y. isLub SReal P Y";
   197 \      ==> EX Y. isLub SReal P Y";
   198 by (Auto_tac);
   198 by Auto_tac;
   199 qed "lemma_isLub_hypreal_of_real2";
   199 qed "lemma_isLub_hypreal_of_real2";
   200 
   200 
   201 Goal "[| P <= SReal; EX x. x: P; \
   201 Goal "[| P <= SReal; EX x. x: P; \
   202 \        EX Y. isUb SReal P Y |] \
   202 \        EX Y. isUb SReal P Y |] \
   203 \     ==> EX t. isLub SReal P t";
   203 \     ==> EX t. isLub SReal P t";
   241 qed "HFinite_hypreal_of_real";
   241 qed "HFinite_hypreal_of_real";
   242 
   242 
   243 Addsimps [HFinite_hypreal_of_real];
   243 Addsimps [HFinite_hypreal_of_real];
   244 
   244 
   245 Goalw [HFinite_def] "x : HFinite ==> EX t: SReal. abs x < t";
   245 Goalw [HFinite_def] "x : HFinite ==> EX t: SReal. abs x < t";
   246 by (Auto_tac);
   246 by Auto_tac;
   247 qed "HFiniteD";
   247 qed "HFiniteD";
   248 
   248 
   249 Goalw [HFinite_def] "x : HFinite ==> abs x : HFinite";
   249 Goalw [HFinite_def] "x : HFinite ==> abs x : HFinite";
   250 by (auto_tac (claset(),simpset() addsimps [hrabs_idempotent]));
   250 by (auto_tac (claset(),simpset() addsimps [hrabs_idempotent]));
   251 qed "HFinite_hrabs";
   251 qed "HFinite_hrabs";
   277 (*------------------------------------------------------------------
   277 (*------------------------------------------------------------------
   278        Set of infinitesimals is a subring of the hyperreals   
   278        Set of infinitesimals is a subring of the hyperreals   
   279  ------------------------------------------------------------------*)
   279  ------------------------------------------------------------------*)
   280 Goalw [Infinitesimal_def]
   280 Goalw [Infinitesimal_def]
   281       "x : Infinitesimal ==> ALL r: SReal. 0 < r --> abs x < r";
   281       "x : Infinitesimal ==> ALL r: SReal. 0 < r --> abs x < r";
   282 by (Auto_tac);
   282 by Auto_tac;
   283 qed "InfinitesimalD";
   283 qed "InfinitesimalD";
   284 
   284 
   285 Goalw [Infinitesimal_def] "0 : Infinitesimal";
   285 Goalw [Infinitesimal_def] "0 : Infinitesimal";
   286 by (simp_tac (simpset() addsimps [hrabs_zero]) 1);
   286 by (simp_tac (simpset() addsimps [hrabs_zero]) 1);
   287 qed "Infinitesimal_zero";
   287 qed "Infinitesimal_zero";
   288 Addsimps [Infinitesimal_zero];
   288 Addsimps [Infinitesimal_zero];
   289 
   289 
   290 Goalw [Infinitesimal_def] 
   290 Goalw [Infinitesimal_def] 
   291       "[| x : Infinitesimal; y : Infinitesimal |] ==> (x + y) : Infinitesimal";
   291       "[| x : Infinitesimal; y : Infinitesimal |] ==> (x + y) : Infinitesimal";
   292 by (Auto_tac);
   292 by Auto_tac;
   293 by (rtac (hypreal_sum_of_halves RS subst) 1);
   293 by (rtac (hypreal_sum_of_halves RS subst) 1);
   294 by (dtac hypreal_half_gt_zero 1);
   294 by (dtac hypreal_half_gt_zero 1);
   295 by (dtac SReal_half 1);
   295 by (dtac SReal_half 1);
   296 by (auto_tac (claset() addSDs [bspec] addIs [hrabs_add_less], simpset()));
   296 by (auto_tac (claset() addSDs [bspec] addIs [hrabs_add_less], simpset()));
   297 qed "Infinitesimal_add";
   297 qed "Infinitesimal_add";
   312 qed "Infinitesimal_add_minus";
   312 qed "Infinitesimal_add_minus";
   313 
   313 
   314 Goalw [Infinitesimal_def] 
   314 Goalw [Infinitesimal_def] 
   315       "[| x : Infinitesimal; y : Infinitesimal |] \
   315       "[| x : Infinitesimal; y : Infinitesimal |] \
   316 \      ==> (x * y) : Infinitesimal";
   316 \      ==> (x * y) : Infinitesimal";
   317 by (Auto_tac);
   317 by Auto_tac;
   318 by (rtac (hypreal_mult_1_right RS subst) 1);
   318 by (rtac (hypreal_mult_1_right RS subst) 1);
   319 by (rtac hrabs_mult_less 1);
   319 by (rtac hrabs_mult_less 1);
   320 by (cut_facts_tac [SReal_one,hypreal_zero_less_one] 2);
   320 by (cut_facts_tac [SReal_one,hypreal_zero_less_one] 2);
   321 by (ALLGOALS(blast_tac (claset() addSDs [bspec])));
   321 by (ALLGOALS(blast_tac (claset() addSDs [bspec])));
   322 qed "Infinitesimal_mult";
   322 qed "Infinitesimal_mult";
   344 qed "Infinitesimal_HFinite_mult2";
   344 qed "Infinitesimal_HFinite_mult2";
   345 
   345 
   346 (*** rather long proof ***)
   346 (*** rather long proof ***)
   347 Goalw [HInfinite_def,Infinitesimal_def] 
   347 Goalw [HInfinite_def,Infinitesimal_def] 
   348      "x: HInfinite ==> inverse x: Infinitesimal";
   348      "x: HInfinite ==> inverse x: Infinitesimal";
   349 by (Auto_tac);
   349 by Auto_tac;
   350 by (eres_inst_tac [("x","inverse r")] ballE 1);
   350 by (eres_inst_tac [("x","inverse r")] ballE 1);
   351 by (rtac (hrabs_inverse RS ssubst) 1);
   351 by (rtac (hrabs_inverse RS ssubst) 1);
   352 by (forw_inst_tac [("x1","r"),("R3.0","abs x")] 
   352 by (forw_inst_tac [("x1","r"),("R3.0","abs x")] 
   353     (hypreal_inverse_gt_zero RS hypreal_less_trans) 1);
   353     (hypreal_inverse_gt_zero RS hypreal_less_trans) 1);
   354 by (assume_tac 1);
   354 by (assume_tac 1);
   361     simpset() addsimps [hypreal_not_refl2 RS not_sym, hypreal_less_not_refl]));
   361     simpset() addsimps [hypreal_not_refl2 RS not_sym, hypreal_less_not_refl]));
   362 qed "HInfinite_inverse_Infinitesimal";
   362 qed "HInfinite_inverse_Infinitesimal";
   363 
   363 
   364 Goalw [HInfinite_def] 
   364 Goalw [HInfinite_def] 
   365    "[|x: HInfinite;y: HInfinite|] ==> (x*y): HInfinite";
   365    "[|x: HInfinite;y: HInfinite|] ==> (x*y): HInfinite";
   366 by (Auto_tac);
   366 by Auto_tac;
   367 by (cut_facts_tac [SReal_one] 1);
   367 by (cut_facts_tac [SReal_one] 1);
   368 by (eres_inst_tac [("x","1hr")] ballE 1);
   368 by (eres_inst_tac [("x","1hr")] ballE 1);
   369 by (eres_inst_tac [("x","r")] ballE 1);
   369 by (eres_inst_tac [("x","r")] ballE 1);
   370 by (REPEAT(fast_tac (HOL_cs addSIs [hrabs_mult_gt]) 1));
   370 by (REPEAT(fast_tac (HOL_cs addSIs [hrabs_mult_gt]) 1));
   371 qed "HInfinite_mult";
   371 qed "HInfinite_mult";
   386 Goal "[|x: HInfinite; 0 < y; 0 < x|] ==> (x + y): HInfinite";
   386 Goal "[|x: HInfinite; 0 < y; 0 < x|] ==> (x + y): HInfinite";
   387 by (blast_tac (claset() addIs [HInfinite_add_ge_zero,
   387 by (blast_tac (claset() addIs [HInfinite_add_ge_zero,
   388     hypreal_less_imp_le]) 1);
   388     hypreal_less_imp_le]) 1);
   389 qed "HInfinite_add_gt_zero";
   389 qed "HInfinite_add_gt_zero";
   390 
   390 
   391 Goalw [HInfinite_def] 
   391 Goalw [HInfinite_def] "(-x: HInfinite) = (x: HInfinite)";
   392      "(-x: HInfinite) = (x: HInfinite)";
       
   393 by (auto_tac (claset(),simpset() addsimps 
   392 by (auto_tac (claset(),simpset() addsimps 
   394     [hrabs_minus_cancel]));
   393     [hrabs_minus_cancel]));
   395 qed "HInfinite_minus_iff";
   394 qed "HInfinite_minus_iff";
   396 
   395 
   397 Goal "[|x: HInfinite; y <= 0; x <= 0|] \
   396 Goal "[|x: HInfinite; y <= 0; x <= 0|] ==> (x + y): HInfinite";
   398 \      ==> (x + y): HInfinite";
       
   399 by (dtac (HInfinite_minus_iff RS iffD2) 1);
   397 by (dtac (HInfinite_minus_iff RS iffD2) 1);
   400 by (rtac (HInfinite_minus_iff RS iffD1) 1);
   398 by (rtac (HInfinite_minus_iff RS iffD1) 1);
   401 by (auto_tac (claset() addIs [HInfinite_add_ge_zero],
   399 by (auto_tac (claset() addIs [HInfinite_add_ge_zero],
   402     simpset() addsimps [hypreal_minus_zero_le_iff RS sym,
   400               simpset() addsimps [hypreal_minus_zero_le_iff]));
   403     hypreal_minus_add_distrib]));
       
   404 qed "HInfinite_add_le_zero";
   401 qed "HInfinite_add_le_zero";
   405 
   402 
   406 Goal "[|x: HInfinite; y < 0; x < 0|] \
   403 Goal "[|x: HInfinite; y < 0; x < 0|] ==> (x + y): HInfinite";
   407 \      ==> (x + y): HInfinite";
       
   408 by (blast_tac (claset() addIs [HInfinite_add_le_zero,
   404 by (blast_tac (claset() addIs [HInfinite_add_le_zero,
   409     hypreal_less_imp_le]) 1);
   405                                hypreal_less_imp_le]) 1);
   410 qed "HInfinite_add_lt_zero";
   406 qed "HInfinite_add_lt_zero";
   411 
   407 
   412 Goal "[|a: HFinite; b: HFinite; c: HFinite|] \ 
   408 Goal "[|a: HFinite; b: HFinite; c: HFinite|] \ 
   413 \     ==> a*a + b*b + c*c : HFinite";
   409 \     ==> a*a + b*b + c*c : HFinite";
   414 by (auto_tac (claset() addIs [HFinite_mult,HFinite_add],
   410 by (auto_tac (claset() addIs [HFinite_mult,HFinite_add], simpset()));
   415     simpset()));
       
   416 qed "HFinite_sum_squares";
   411 qed "HFinite_sum_squares";
   417 
   412 
   418 Goal "x ~: Infinitesimal ==> x ~= 0";
   413 Goal "x ~: Infinitesimal ==> x ~= 0";
   419 by (Auto_tac);
   414 by Auto_tac;
   420 qed "not_Infinitesimal_not_zero";
   415 qed "not_Infinitesimal_not_zero";
   421 
   416 
   422 Goal "x: HFinite - Infinitesimal ==> x ~= 0";
   417 Goal "x: HFinite - Infinitesimal ==> x ~= 0";
   423 by (Auto_tac);
   418 by Auto_tac;
   424 qed "not_Infinitesimal_not_zero2";
   419 qed "not_Infinitesimal_not_zero2";
   425 
   420 
   426 Goal "x : Infinitesimal ==> abs x : Infinitesimal";
   421 Goal "x : Infinitesimal ==> abs x : Infinitesimal";
   427 by (res_inst_tac [("x1","x")] (hrabs_disj RS disjE) 1);
   422 by (res_inst_tac [("x1","x")] (hrabs_disj RS disjE) 1);
   428 by (auto_tac (claset(),simpset() addsimps [Infinitesimal_minus_iff RS sym]));
   423 by (auto_tac (claset(),simpset() addsimps [Infinitesimal_minus_iff RS sym]));
   650 Goalw [inf_close_def]  "(EX y: Infinitesimal. x + -z = y) = (x @= z)";
   645 Goalw [inf_close_def]  "(EX y: Infinitesimal. x + -z = y) = (x @= z)";
   651 by (Blast_tac 1);
   646 by (Blast_tac 1);
   652 qed "bex_Infinitesimal_iff";
   647 qed "bex_Infinitesimal_iff";
   653 
   648 
   654 Goal "(EX y: Infinitesimal. x = z + y) = (x @= z)";
   649 Goal "(EX y: Infinitesimal. x = z + y) = (x @= z)";
   655 by (asm_full_simp_tac (simpset() addsimps [hypreal_eq_minus_iff4,
   650 by (asm_full_simp_tac (simpset() addsimps [bex_Infinitesimal_iff RS sym]) 1);
   656     bex_Infinitesimal_iff RS sym]) 1);
   651 by (Force_tac 1);
   657 qed "bex_Infinitesimal_iff2";
   652 qed "bex_Infinitesimal_iff2";
   658 
   653 
   659 Goal "[| y: Infinitesimal; x + y = z |] ==> x @= z";
   654 Goal "[| y: Infinitesimal; x + y = z |] ==> x @= z";
   660 by (rtac (bex_Infinitesimal_iff RS iffD1) 1);
   655 by (rtac (bex_Infinitesimal_iff RS iffD1) 1);
   661 by (dtac (Infinitesimal_minus_iff RS iffD1) 1);
   656 by (dtac (Infinitesimal_minus_iff RS iffD1) 1);
   740 by (auto_tac (claset(),simpset() addsimps [hypreal_add_assoc]));
   735 by (auto_tac (claset(),simpset() addsimps [hypreal_add_assoc]));
   741 qed "inf_close_HFinite";
   736 qed "inf_close_HFinite";
   742 
   737 
   743 Goal "x @= hypreal_of_real D ==> x: HFinite";
   738 Goal "x @= hypreal_of_real D ==> x: HFinite";
   744 by (rtac (inf_close_sym RSN (2,inf_close_HFinite)) 1);
   739 by (rtac (inf_close_sym RSN (2,inf_close_HFinite)) 1);
   745 by (Auto_tac);
   740 by Auto_tac;
   746 qed "inf_close_hypreal_of_real_HFinite";
   741 qed "inf_close_hypreal_of_real_HFinite";
   747 
   742 
   748 Goal "[|a @= hypreal_of_real b; c @= hypreal_of_real d |] \
   743 Goal "[|a @= hypreal_of_real b; c @= hypreal_of_real d |] \
   749 \     ==> a*c @= hypreal_of_real b*hypreal_of_real d";
   744 \     ==> a*c @= hypreal_of_real b*hypreal_of_real d";
   750 by (blast_tac (claset() addSIs [inf_close_mult_HFinite,
   745 by (blast_tac (claset() addSIs [inf_close_mult_HFinite,
   786 qed "inf_close_SReal_mult_cancel_iff1";
   781 qed "inf_close_SReal_mult_cancel_iff1";
   787 Addsimps [inf_close_SReal_mult_cancel_iff1];
   782 Addsimps [inf_close_SReal_mult_cancel_iff1];
   788 
   783 
   789 Goal "[| z <= f; f @= g; g <= z |] ==> f @= z";
   784 Goal "[| z <= f; f @= g; g <= z |] ==> f @= z";
   790 by (dtac (bex_Infinitesimal_iff2 RS iffD2) 1);
   785 by (dtac (bex_Infinitesimal_iff2 RS iffD2) 1);
   791 by (Auto_tac);
   786 by Auto_tac;
   792 by (dres_inst_tac [("x","-g")] hypreal_add_left_le_mono1 1);
   787 by (dres_inst_tac [("x","-g")] hypreal_add_left_le_mono1 1);
   793 by (dres_inst_tac [("x","-g")] hypreal_add_le_mono1 1);
   788 by (dres_inst_tac [("x","-g")] hypreal_add_le_mono1 1);
   794 by (res_inst_tac [("y","-y")] Infinitesimal_add_cancel 1);
   789 by (res_inst_tac [("y","-y")] Infinitesimal_add_cancel 1);
   795 by (auto_tac (claset(),simpset() addsimps [hypreal_add_assoc RS sym,
   790 by (auto_tac (claset(),simpset() addsimps [hypreal_add_assoc RS sym,
   796     Infinitesimal_minus_iff RS sym]));
   791     Infinitesimal_minus_iff RS sym]));
   860           SReal_subset_HFinite RS subsetD],simpset()));
   855           SReal_subset_HFinite RS subsetD],simpset()));
   861 qed "SReal_HFinite_diff_Infinitesimal";
   856 qed "SReal_HFinite_diff_Infinitesimal";
   862 
   857 
   863 Goal "hypreal_of_real x ~= 0 ==> hypreal_of_real x : HFinite - Infinitesimal";
   858 Goal "hypreal_of_real x ~= 0 ==> hypreal_of_real x : HFinite - Infinitesimal";
   864 by (rtac SReal_HFinite_diff_Infinitesimal 1);
   859 by (rtac SReal_HFinite_diff_Infinitesimal 1);
   865 by (Auto_tac);
   860 by Auto_tac;
   866 qed "hypreal_of_real_HFinite_diff_Infinitesimal";
   861 qed "hypreal_of_real_HFinite_diff_Infinitesimal";
   867 
   862 
   868 Goal "1hr+1hr ~: Infinitesimal";
   863 Goal "1hr+1hr ~: Infinitesimal";
   869 by (fast_tac (claset() addIs [SReal_two RS SReal_Infinitesimal_zero,
   864 by (fast_tac (claset() addDs [SReal_two RS SReal_Infinitesimal_zero]
   870     hypreal_two_not_zero RS notE]) 1);
   865                        addSEs [hypreal_two_not_zero RS notE]) 1);
   871 qed "two_not_Infinitesimal";
   866 qed "two_not_Infinitesimal";
   872 
   867 
   873 Goal "1hr ~: Infinitesimal";
   868 Goal "1hr ~: Infinitesimal";
   874 by (auto_tac (claset() addSDs [SReal_one RS SReal_Infinitesimal_zero],
   869 by (auto_tac (claset() addSDs [SReal_one RS SReal_Infinitesimal_zero],
   875     simpset() addsimps [hypreal_zero_not_eq_one RS not_sym]));
   870                 simpset() addsimps [hypreal_zero_not_eq_one RS not_sym]));
   876 qed "hypreal_one_not_Infinitesimal";
   871 qed "hypreal_one_not_Infinitesimal";
   877 Addsimps [hypreal_one_not_Infinitesimal];
   872 Addsimps [hypreal_one_not_Infinitesimal];
   878 
   873 
   879 Goal "[| y: SReal; x @= y; y~= 0 |] ==> x ~= 0";
   874 Goal "[| y: SReal; x @= y; y~= 0 |] ==> x ~= 0";
   880 by (cut_inst_tac [("x","y")] hypreal_trichotomy 1);
   875 by (cut_inst_tac [("x","y")] hypreal_trichotomy 1);
   881 by (blast_tac (claset() addDs 
   876 by (blast_tac (claset() addDs 
   882     [inf_close_sym RS (mem_infmal_iff RS iffD2),
   877 		[inf_close_sym RS (mem_infmal_iff RS iffD2),
   883      SReal_not_Infinitesimal,SReal_minus_not_Infinitesimal]) 1);
   878 		 SReal_not_Infinitesimal,SReal_minus_not_Infinitesimal]) 1);
   884 qed "inf_close_SReal_not_zero";
   879 qed "inf_close_SReal_not_zero";
   885 
   880 
   886 Goal "[| x @= hypreal_of_real y; hypreal_of_real y ~= 0 |] ==> x ~= 0";
   881 Goal "[| x @= hypreal_of_real y; hypreal_of_real y ~= 0 |] ==> x ~= 0";
   887 by (rtac inf_close_SReal_not_zero 1);
   882 by (rtac inf_close_SReal_not_zero 1);
   888 by (Auto_tac);
   883 by Auto_tac;
   889 qed "inf_close_hypreal_of_real_not_zero";
   884 qed "inf_close_hypreal_of_real_not_zero";
   890 
   885 
   891 Goal "[| x @= y; y : HFinite - Infinitesimal |] \
   886 Goal "[| x @= y; y : HFinite - Infinitesimal |] \
   892 \     ==> x : HFinite - Infinitesimal";
   887 \     ==> x : HFinite - Infinitesimal";
   893 by (auto_tac (claset() addIs [inf_close_sym RSN (2,inf_close_HFinite)],
   888 by (auto_tac (claset() addIs [inf_close_sym RSN (2,inf_close_HFinite)],
   958 by (dtac SReal_minus 1);
   953 by (dtac SReal_minus 1);
   959 by (auto_tac (claset(),simpset() addsimps [hrabs_interval_iff]));
   954 by (auto_tac (claset(),simpset() addsimps [hrabs_interval_iff]));
   960 qed "lemma_st_part_nonempty";
   955 qed "lemma_st_part_nonempty";
   961 
   956 
   962 Goal "{s. s: SReal & s < x} <= SReal";
   957 Goal "{s. s: SReal & s < x} <= SReal";
   963 by (Auto_tac);
   958 by Auto_tac;
   964 qed "lemma_st_part_subset";
   959 qed "lemma_st_part_subset";
   965 
   960 
   966 Goal "x: HFinite ==> EX t. isLub SReal {s. s: SReal & s < x} t";
   961 Goal "x: HFinite ==> EX t. isLub SReal {s. s: SReal & s < x} t";
   967 by (blast_tac (claset() addSIs [SReal_complete,lemma_st_part_ub,
   962 by (blast_tac (claset() addSIs [SReal_complete,lemma_st_part_ub,
   968     lemma_st_part_nonempty, lemma_st_part_subset]) 1);
   963     lemma_st_part_nonempty, lemma_st_part_subset]) 1);
  1005 qed "lemma_st_part_gt_ub";
  1000 qed "lemma_st_part_gt_ub";
  1006 
  1001 
  1007 Goal "t <= t + -r ==> r <= (0::hypreal)";
  1002 Goal "t <= t + -r ==> r <= (0::hypreal)";
  1008 by (dres_inst_tac [("x","-t")] hypreal_add_left_le_mono1 1);
  1003 by (dres_inst_tac [("x","-t")] hypreal_add_left_le_mono1 1);
  1009 by (auto_tac (claset(),simpset() addsimps [hypreal_add_assoc RS sym]));
  1004 by (auto_tac (claset(),simpset() addsimps [hypreal_add_assoc RS sym]));
  1010 by (dres_inst_tac [("x","r")] hypreal_add_left_le_mono1 1);
       
  1011 by (Auto_tac);
       
  1012 qed "lemma_minus_le_zero";
  1005 qed "lemma_minus_le_zero";
  1013 
  1006 
  1014 Goal "[| x: HFinite; \
  1007 Goal "[| x: HFinite; \
  1015 \        isLub SReal {s. s: SReal & s < x} t; \
  1008 \        isLub SReal {s. s: SReal & s < x} t; \
  1016 \        r: SReal; 0 < r |] \
  1009 \        r: SReal; 0 < r |] \
  1073 
  1066 
  1074 Goal "[| x: HFinite; \
  1067 Goal "[| x: HFinite; \
  1075 \        isLub SReal {s. s: SReal & s < x} t; \
  1068 \        isLub SReal {s. s: SReal & s < x} t; \
  1076 \        r: SReal; 0 < r |] \
  1069 \        r: SReal; 0 < r |] \
  1077 \     ==> x + -t ~= r";
  1070 \     ==> x + -t ~= r";
  1078 by (Auto_tac);
  1071 by Auto_tac;
  1079 by (forward_tac [isLubD1a RS SReal_minus] 1);
  1072 by (forward_tac [isLubD1a RS SReal_minus] 1);
  1080 by (dtac SReal_add_cancel 1 THEN assume_tac 1);
  1073 by (dtac SReal_add_cancel 1 THEN assume_tac 1);
  1081 by (dres_inst_tac [("x","x")] lemma_SReal_lub 1);
  1074 by (dres_inst_tac [("x","x")] lemma_SReal_lub 1);
  1082 by (dtac hypreal_isLub_unique 1 THEN assume_tac 1);
  1075 by (dtac hypreal_isLub_unique 1 THEN assume_tac 1);
  1083 by (auto_tac (claset(),simpset() addsimps [hypreal_less_not_refl]));
  1076 by (auto_tac (claset(),simpset() addsimps [hypreal_less_not_refl]));
  1101 \        isLub SReal {s. s: SReal & s < x} t; \
  1094 \        isLub SReal {s. s: SReal & s < x} t; \
  1102 \        r: SReal; 0 < r |] \
  1095 \        r: SReal; 0 < r |] \
  1103 \     ==> abs (x + -t) < r";
  1096 \     ==> abs (x + -t) < r";
  1104 by (forward_tac [lemma_st_part1a] 1);
  1097 by (forward_tac [lemma_st_part1a] 1);
  1105 by (forward_tac [lemma_st_part2a] 4);
  1098 by (forward_tac [lemma_st_part2a] 4);
  1106 by (Auto_tac);
  1099 by Auto_tac;
  1107 by (REPEAT(dtac hypreal_le_imp_less_or_eq 1));
  1100 by (REPEAT(dtac hypreal_le_imp_less_or_eq 1));
  1108 by (auto_tac (claset() addDs [lemma_st_part_not_eq1,
  1101 by (auto_tac (claset() addDs [lemma_st_part_not_eq1,
  1109     lemma_st_part_not_eq2],simpset() addsimps [hrabs_interval_iff2]));
  1102     lemma_st_part_not_eq2],simpset() addsimps [hrabs_interval_iff2]));
  1110 qed "lemma_st_part_major";
  1103 qed "lemma_st_part_major";
  1111 
  1104 
  1151 qed "HFinite_Int_HInfinite_empty";
  1144 qed "HFinite_Int_HInfinite_empty";
  1152 Addsimps [HFinite_Int_HInfinite_empty];
  1145 Addsimps [HFinite_Int_HInfinite_empty];
  1153 
  1146 
  1154 Goal "x: HFinite ==> x ~: HInfinite";
  1147 Goal "x: HFinite ==> x ~: HInfinite";
  1155 by (EVERY1[Step_tac, dtac IntI, assume_tac]);
  1148 by (EVERY1[Step_tac, dtac IntI, assume_tac]);
  1156 by (Auto_tac);
  1149 by Auto_tac;
  1157 qed "HFinite_not_HInfinite";
  1150 qed "HFinite_not_HInfinite";
  1158 
  1151 
  1159 val [prem] = goalw thy [HInfinite_def] "x~: HFinite ==> x: HInfinite";
  1152 val [prem] = goalw thy [HInfinite_def] "x~: HFinite ==> x: HInfinite";
  1160 by (cut_facts_tac [prem] 1);
  1153 by (cut_facts_tac [prem] 1);
  1161 by (Clarify_tac 1);
  1154 by (Clarify_tac 1);
  1217 by (assume_tac 1);
  1210 by (assume_tac 1);
  1218 by (forward_tac [not_Infinitesimal_not_zero2] 1);
  1211 by (forward_tac [not_Infinitesimal_not_zero2] 1);
  1219 by (forw_inst_tac [("x","x")] not_Infinitesimal_not_zero2 1);
  1212 by (forw_inst_tac [("x","x")] not_Infinitesimal_not_zero2 1);
  1220 by (REPEAT(dtac HFinite_inverse2 1));
  1213 by (REPEAT(dtac HFinite_inverse2 1));
  1221 by (dtac inf_close_mult2 1 THEN assume_tac 1);
  1214 by (dtac inf_close_mult2 1 THEN assume_tac 1);
  1222 by (Auto_tac);
  1215 by Auto_tac;
  1223 by (dres_inst_tac [("c","inverse x")] inf_close_mult1 1 
  1216 by (dres_inst_tac [("c","inverse x")] inf_close_mult1 1 
  1224     THEN assume_tac 1);
  1217     THEN assume_tac 1);
  1225 by (auto_tac (claset() addIs [inf_close_sym],
  1218 by (auto_tac (claset() addIs [inf_close_sym],
  1226     simpset() addsimps [hypreal_mult_assoc]));
  1219     simpset() addsimps [hypreal_mult_assoc]));
  1227 qed "inf_close_inverse";
  1220 qed "inf_close_inverse";
  1294                   Theorems about monads
  1287                   Theorems about monads
  1295  ------------------------------------------------------------------*)
  1288  ------------------------------------------------------------------*)
  1296 
  1289 
  1297 Goal "monad (abs x) <= monad(x) Un monad(-x)";
  1290 Goal "monad (abs x) <= monad(x) Un monad(-x)";
  1298 by (res_inst_tac [("x1","x")] (hrabs_disj RS disjE) 1);
  1291 by (res_inst_tac [("x1","x")] (hrabs_disj RS disjE) 1);
  1299 by (Auto_tac);
  1292 by Auto_tac;
  1300 qed "monad_hrabs_Un_subset";
  1293 qed "monad_hrabs_Un_subset";
  1301 
  1294 
  1302 Goal "!! e. e : Infinitesimal ==> monad (x+e) = monad x";
  1295 Goal "!! e. e : Infinitesimal ==> monad (x+e) = monad x";
  1303 by (fast_tac (claset() addSIs [Infinitesimal_add_inf_close_self RS inf_close_sym,
  1296 by (fast_tac (claset() addSIs [Infinitesimal_add_inf_close_self RS inf_close_sym,
  1304     inf_close_monad_iff RS iffD1]) 1);
  1297     inf_close_monad_iff RS iffD1]) 1);
  1305 qed "Infinitesimal_monad_eq";
  1298 qed "Infinitesimal_monad_eq";
  1306 
  1299 
  1307 Goalw [monad_def] "(u:monad x) = (-u:monad (-x))";
  1300 Goalw [monad_def] "(u:monad x) = (-u:monad (-x))";
  1308 by (Auto_tac);
  1301 by Auto_tac;
  1309 qed "mem_monad_iff";
  1302 qed "mem_monad_iff";
  1310 
  1303 
  1311 Goalw [monad_def] "(x:Infinitesimal) = (x:monad 0)";
  1304 Goalw [monad_def] "(x:Infinitesimal) = (x:monad 0)";
  1312 by (auto_tac (claset() addIs [inf_close_sym],
  1305 by (auto_tac (claset() addIs [inf_close_sym],
  1313     simpset() addsimps [mem_infmal_iff]));
  1306     simpset() addsimps [mem_infmal_iff]));
  1406 Goal "[| x @= y; x < 0; x ~: Infinitesimal |] \
  1399 Goal "[| x @= y; x < 0; x ~: Infinitesimal |] \
  1407 \     ==> abs x @= abs y";
  1400 \     ==> abs x @= abs y";
  1408 by (forward_tac [lemma_inf_close_less_zero] 1);
  1401 by (forward_tac [lemma_inf_close_less_zero] 1);
  1409 by (REPEAT(assume_tac 1));
  1402 by (REPEAT(assume_tac 1));
  1410 by (REPEAT(dtac hrabs_minus_eqI2 1));
  1403 by (REPEAT(dtac hrabs_minus_eqI2 1));
  1411 by (Auto_tac);
  1404 by Auto_tac;
  1412 qed "inf_close_hrabs1";
  1405 qed "inf_close_hrabs1";
  1413 
  1406 
  1414 Goal "[| x @= y; 0 < x; x ~: Infinitesimal |] \
  1407 Goal "[| x @= y; 0 < x; x ~: Infinitesimal |] \
  1415 \     ==> abs x @= abs y";
  1408 \     ==> abs x @= abs y";
  1416 by (forward_tac [lemma_inf_close_gt_zero] 1);
  1409 by (forward_tac [lemma_inf_close_gt_zero] 1);
  1417 by (REPEAT(assume_tac 1));
  1410 by (REPEAT(assume_tac 1));
  1418 by (REPEAT(dtac hrabs_eqI2 1));
  1411 by (REPEAT(dtac hrabs_eqI2 1));
  1419 by (Auto_tac);
  1412 by Auto_tac;
  1420 qed "inf_close_hrabs2";
  1413 qed "inf_close_hrabs2";
  1421 
  1414 
  1422 Goal "x @= y ==> abs x @= abs y";
  1415 Goal "x @= y ==> abs x @= abs y";
  1423 by (res_inst_tac [("Q","x:Infinitesimal")] (excluded_middle RS disjE) 1);
  1416 by (res_inst_tac [("Q","x:Infinitesimal")] (excluded_middle RS disjE) 1);
  1424 by (res_inst_tac [("x1","x"),("y1","0")] (hypreal_linear RS disjE) 1);
  1417 by (res_inst_tac [("x1","x"),("y1","0")] (hypreal_linear RS disjE) 1);
  1863  --------------------------------------------------------------------*)
  1856  --------------------------------------------------------------------*)
  1864 
  1857 
  1865 Goal "[| X: Rep_hypreal x; Y: Rep_hypreal x |] \
  1858 Goal "[| X: Rep_hypreal x; Y: Rep_hypreal x |] \
  1866 \              ==> {n. X n = Y n} : FreeUltrafilterNat";
  1859 \              ==> {n. X n = Y n} : FreeUltrafilterNat";
  1867 by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  1860 by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  1868 by (Auto_tac);
  1861 by Auto_tac;
  1869 by (Ultra_tac 1);
  1862 by (Ultra_tac 1);
  1870 qed "FreeUltrafilterNat_Rep_hypreal";
  1863 qed "FreeUltrafilterNat_Rep_hypreal";
  1871 
  1864 
  1872 Goal "{n. Yb n < Y n} Int {n. -y = Yb n} <= {n. -y < Y n}";
  1865 Goal "{n. Yb n < Y n} Int {n. -y = Yb n} <= {n. -y < Y n}";
  1873 by (Auto_tac);
  1866 by Auto_tac;
  1874 qed "lemma_free1";
  1867 qed "lemma_free1";
  1875 
  1868 
  1876 Goal "{n. Xa n < Yc n} Int {n. y = Yc n} <= {n. Xa n < y}";
  1869 Goal "{n. Xa n < Yc n} Int {n. y = Yc n} <= {n. Xa n < y}";
  1877 by (Auto_tac);
  1870 by Auto_tac;
  1878 qed "lemma_free2";
  1871 qed "lemma_free2";
  1879 
  1872 
  1880 Goalw [HFinite_def] 
  1873 Goalw [HFinite_def] 
  1881     "x : HFinite ==> EX X: Rep_hypreal x. \
  1874     "x : HFinite ==> EX X: Rep_hypreal x. \
  1882 \    EX u. {n. abs (X n) < u}:  FreeUltrafilterNat";
  1875 \    EX u. {n. abs (X n) < u}:  FreeUltrafilterNat";
  1948 by (cut_facts_tac [(prem RS (HInfinite_HFinite_iff RS iffD1))] 1);
  1941 by (cut_facts_tac [(prem RS (HInfinite_HFinite_iff RS iffD1))] 1);
  1949 by (cut_inst_tac [("x","x")] Rep_hypreal_nonempty 1);
  1942 by (cut_inst_tac [("x","x")] Rep_hypreal_nonempty 1);
  1950 by (auto_tac (claset(),simpset() delsimps [Rep_hypreal_nonempty] 
  1943 by (auto_tac (claset(),simpset() delsimps [Rep_hypreal_nonempty] 
  1951     addsimps [HFinite_FreeUltrafilterNat_iff,Bex_def]));
  1944     addsimps [HFinite_FreeUltrafilterNat_iff,Bex_def]));
  1952 by (REPEAT(dtac spec 1));
  1945 by (REPEAT(dtac spec 1));
  1953 by (Auto_tac);
  1946 by Auto_tac;
  1954 by (dres_inst_tac [("x","u")] spec 1 THEN 
  1947 by (dres_inst_tac [("x","u")] spec 1 THEN 
  1955     REPEAT(dtac FreeUltrafilterNat_Compl_mem 1));
  1948     REPEAT(dtac FreeUltrafilterNat_Compl_mem 1));
  1956 by (dtac FreeUltrafilterNat_Int 1 THEN assume_tac 1);
  1949 by (dtac FreeUltrafilterNat_Int 1 THEN assume_tac 1);
  1957 
  1950 
  1958 
  1951 
  1963 qed "HInfinite_FreeUltrafilterNat";
  1956 qed "HInfinite_FreeUltrafilterNat";
  1964 
  1957 
  1965 (* yet more lemmas! *)
  1958 (* yet more lemmas! *)
  1966 Goal "{n. abs (Xa n) < u} Int {n. X n = Xa n} \
  1959 Goal "{n. abs (Xa n) < u} Int {n. X n = Xa n} \
  1967 \         <= {n. abs (X n) < (u::real)}";
  1960 \         <= {n. abs (X n) < (u::real)}";
  1968 by (Auto_tac);
  1961 by Auto_tac;
  1969 qed "lemma_Int_HI";
  1962 qed "lemma_Int_HI";
  1970 
  1963 
  1971 Goal "{n. u < abs (X n)} Int {n. abs (X n) < (u::real)} = {}";
  1964 Goal "{n. u < abs (X n)} Int {n. abs (X n) < (u::real)} = {}";
  1972 by (auto_tac (claset() addIs [real_less_asym],simpset()));
  1965 by (auto_tac (claset() addIs [real_less_asym],simpset()));
  1973 qed "lemma_Int_HIa";
  1966 qed "lemma_Int_HIa";
  1975 Goal "EX X: Rep_hypreal x. ALL u. \
  1968 Goal "EX X: Rep_hypreal x. ALL u. \
  1976 \              {n. u < abs (X n)}: FreeUltrafilterNat\
  1969 \              {n. u < abs (X n)}: FreeUltrafilterNat\
  1977 \              ==>  x : HInfinite";
  1970 \              ==>  x : HInfinite";
  1978 by (rtac (HInfinite_HFinite_iff RS iffD2) 1);
  1971 by (rtac (HInfinite_HFinite_iff RS iffD2) 1);
  1979 by (Step_tac 1 THEN dtac HFinite_FreeUltrafilterNat 1);
  1972 by (Step_tac 1 THEN dtac HFinite_FreeUltrafilterNat 1);
  1980 by (Auto_tac);
  1973 by Auto_tac;
  1981 by (dres_inst_tac [("x","u")] spec 1);
  1974 by (dres_inst_tac [("x","u")] spec 1);
  1982 by (dtac FreeUltrafilterNat_Rep_hypreal 1 THEN assume_tac 1);
  1975 by (dtac FreeUltrafilterNat_Rep_hypreal 1 THEN assume_tac 1);
  1983 by (dres_inst_tac [("Y","{n. X n = Xa n}")] FreeUltrafilterNat_Int 1);
  1976 by (dres_inst_tac [("Y","{n. X n = Xa n}")] FreeUltrafilterNat_Int 1);
  1984 by (dtac (lemma_Int_HI RSN (2,FreeUltrafilterNat_subset)) 2);
  1977 by (dtac (lemma_Int_HI RSN (2,FreeUltrafilterNat_subset)) 2);
  1985 by (dres_inst_tac [("Y","{n. abs (X n) < u}")] FreeUltrafilterNat_Int 2);
  1978 by (dres_inst_tac [("Y","{n. abs (X n) < u}")] FreeUltrafilterNat_Int 2);
  1996 (*--------------------------------------------------------------------
  1989 (*--------------------------------------------------------------------
  1997    Alternative definitions for Infinitesimal using Free ultrafilter
  1990    Alternative definitions for Infinitesimal using Free ultrafilter
  1998  --------------------------------------------------------------------*)
  1991  --------------------------------------------------------------------*)
  1999 
  1992 
  2000 Goal "{n. - u < Yd n} Int {n. xa n = Yd n} <= {n. -u < xa n}";
  1993 Goal "{n. - u < Yd n} Int {n. xa n = Yd n} <= {n. -u < xa n}";
  2001 by (Auto_tac);
  1994 by Auto_tac;
  2002 qed "lemma_free4";
  1995 qed "lemma_free4";
  2003 
  1996 
  2004 Goal "{n. Yb n < u} Int {n. xa n = Yb n} <= {n. xa n < u}";
  1997 Goal "{n. Yb n < u} Int {n. xa n = Yb n} <= {n. xa n < u}";
  2005 by (Auto_tac);
  1998 by Auto_tac;
  2006 qed "lemma_free5";
  1999 qed "lemma_free5";
  2007 
  2000 
  2008 Goalw [Infinitesimal_def] 
  2001 Goalw [Infinitesimal_def] 
  2009           "x : Infinitesimal ==> EX X: Rep_hypreal x. \
  2002           "x : Infinitesimal ==> EX X: Rep_hypreal x. \
  2010 \          ALL u. 0 < u --> {n. abs (X n) < u}:  FreeUltrafilterNat";
  2003 \          ALL u. 0 < u --> {n. abs (X n) < u}:  FreeUltrafilterNat";