src/HOL/Real/Hyperreal/SEQ.ML
changeset 10677 36625483213f
parent 10648 a8c647cfa31f
child 10699 f0c3da8477e9
equal deleted inserted replaced
10676:06f390008ceb 10677:36625483213f
    24                   Rules for LIMSEQ and NSLIMSEQ etc.
    24                   Rules for LIMSEQ and NSLIMSEQ etc.
    25  --------------------------------------------------------------------------*)
    25  --------------------------------------------------------------------------*)
    26 
    26 
    27 (*** LIMSEQ ***)
    27 (*** LIMSEQ ***)
    28 Goalw [LIMSEQ_def] 
    28 Goalw [LIMSEQ_def] 
    29       "!!X. X ----> L ==> \
    29       "X ----> L ==> \
    30 \      ALL r. #0 < r --> (EX no. ALL n. no <= n --> abs(X n + -L) < r)";
    30 \      ALL r. #0 < r --> (EX no. ALL n. no <= n --> abs(X n + -L) < r)";
    31 by (Asm_simp_tac 1);
    31 by (Asm_simp_tac 1);
    32 qed "LIMSEQD1";
    32 qed "LIMSEQD1";
    33 
    33 
    34 Goalw [LIMSEQ_def] 
    34 Goalw [LIMSEQ_def] 
    35       "!!X. [| X ----> L; #0 < r|] ==> \
    35       "[| X ----> L; #0 < r|] ==> \
    36 \      EX no. ALL n. no <= n --> abs(X n + -L) < r";
    36 \      EX no. ALL n. no <= n --> abs(X n + -L) < r";
    37 by (Asm_simp_tac 1);
    37 by (Asm_simp_tac 1);
    38 qed "LIMSEQD2";
    38 qed "LIMSEQD2";
    39 
    39 
    40 Goalw [LIMSEQ_def] 
    40 Goalw [LIMSEQ_def] 
    41       "!!X. ALL r. #0 < r --> (EX no. ALL n. \
    41       "ALL r. #0 < r --> (EX no. ALL n. \
    42 \      no <= n --> abs(X n + -L) < r) ==> X ----> L";
    42 \      no <= n --> abs(X n + -L) < r) ==> X ----> L";
    43 by (Asm_simp_tac 1);
    43 by (Asm_simp_tac 1);
    44 qed "LIMSEQI";
    44 qed "LIMSEQI";
    45 
    45 
    46 Goalw [LIMSEQ_def] 
    46 Goalw [LIMSEQ_def] 
    47       "!!X. (X ----> L) = \
    47       "(X ----> L) = \
    48 \      (ALL r. #0 <r --> (EX no. ALL n. no <= n --> abs(X n + -L) < r))";
    48 \      (ALL r. #0 <r --> (EX no. ALL n. no <= n --> abs(X n + -L) < r))";
    49 by (Simp_tac 1);
    49 by (Simp_tac 1);
    50 qed "LIMSEQ_iff";
    50 qed "LIMSEQ_iff";
    51 
    51 
    52 (*** NSLIMSEQ ***)
    52 (*** NSLIMSEQ ***)
    53 Goalw [NSLIMSEQ_def] 
    53 Goalw [NSLIMSEQ_def] 
    54       "!!X. X ----NS> L ==> ALL N: HNatInfinite. (*fNat* X) N @= hypreal_of_real L";
    54       "X ----NS> L ==> ALL N: HNatInfinite. (*fNat* X) N @= hypreal_of_real L";
    55 by (Asm_simp_tac 1);
    55 by (Asm_simp_tac 1);
    56 qed "NSLIMSEQD1";
    56 qed "NSLIMSEQD1";
    57 
    57 
    58 Goalw [NSLIMSEQ_def] 
    58 Goalw [NSLIMSEQ_def] 
    59       "!!X. [| X ----NS> L; N: HNatInfinite |] ==> (*fNat* X) N @= hypreal_of_real L";
    59       "[| X ----NS> L; N: HNatInfinite |] ==> (*fNat* X) N @= hypreal_of_real L";
    60 by (Asm_simp_tac 1);
    60 by (Asm_simp_tac 1);
    61 qed "NSLIMSEQD2";
    61 qed "NSLIMSEQD2";
    62 
    62 
    63 Goalw [NSLIMSEQ_def] 
    63 Goalw [NSLIMSEQ_def] 
    64       "!!X. ALL N: HNatInfinite. (*fNat* X) N @= hypreal_of_real L ==> X ----NS> L";
    64       "ALL N: HNatInfinite. (*fNat* X) N @= hypreal_of_real L ==> X ----NS> L";
    65 by (Asm_simp_tac 1);
    65 by (Asm_simp_tac 1);
    66 qed "NSLIMSEQI";
    66 qed "NSLIMSEQI";
    67 
    67 
    68 Goalw [NSLIMSEQ_def] 
    68 Goalw [NSLIMSEQ_def] 
    69       "!!X. (X ----NS> L) = (ALL N: HNatInfinite. (*fNat* X) N @= hypreal_of_real L)";
    69       "(X ----NS> L) = (ALL N: HNatInfinite. (*fNat* X) N @= hypreal_of_real L)";
    70 by (Simp_tac 1);
    70 by (Simp_tac 1);
    71 qed "NSLIMSEQ_iff";
    71 qed "NSLIMSEQ_iff";
    72 
    72 
    73 (*----------------------------------------
    73 (*----------------------------------------
    74           LIMSEQ ==> NSLIMSEQ
    74           LIMSEQ ==> NSLIMSEQ
    75  ---------------------------------------*)
    75  ---------------------------------------*)
    76 Goalw [LIMSEQ_def,NSLIMSEQ_def] 
    76 Goalw [LIMSEQ_def,NSLIMSEQ_def] 
    77       "!!X. X ----> L ==> X ----NS> L";
    77       "X ----> L ==> X ----NS> L";
    78 by (auto_tac (claset(),simpset() addsimps 
    78 by (auto_tac (claset(),simpset() addsimps 
    79     [HNatInfinite_FreeUltrafilterNat_iff]));
    79     [HNatInfinite_FreeUltrafilterNat_iff]));
    80 by (res_inst_tac [("z","N")] eq_Abs_hypnat 1);
    80 by (res_inst_tac [("z","N")] eq_Abs_hypnat 1);
    81 by (rtac (inf_close_minus_iff RS iffD2) 1);
    81 by (rtac (inf_close_minus_iff RS iffD2) 1);
    82 by (auto_tac (claset(),simpset() addsimps [starfunNat,
    82 by (auto_tac (claset(),simpset() addsimps [starfunNat,
   138 by (auto_tac (claset() addDs [NSLIMSEQ_finite_set],
   138 by (auto_tac (claset() addDs [NSLIMSEQ_finite_set],
   139     simpset() addsimps [Compl_less_set]));
   139     simpset() addsimps [Compl_less_set]));
   140 qed "FreeUltrafilterNat_NSLIMSEQ";
   140 qed "FreeUltrafilterNat_NSLIMSEQ";
   141 
   141 
   142 (* thus, the sequence defines an infinite hypernatural! *)
   142 (* thus, the sequence defines an infinite hypernatural! *)
   143 Goal "!!f. ALL n. n <= f n \
   143 Goal "ALL n. n <= f n \
   144 \         ==> Abs_hypnat (hypnatrel ^^ {f}) : HNatInfinite";
   144 \         ==> Abs_hypnat (hypnatrel ^^ {f}) : HNatInfinite";
   145 by (auto_tac (claset(),simpset() addsimps [HNatInfinite_FreeUltrafilterNat_iff]));
   145 by (auto_tac (claset(),simpset() addsimps [HNatInfinite_FreeUltrafilterNat_iff]));
   146 by (EVERY[rtac bexI 1, rtac lemma_hypnatrel_refl 2, Step_tac 1]);
   146 by (EVERY[rtac bexI 1, rtac lemma_hypnatrel_refl 2, Step_tac 1]);
   147 by (etac FreeUltrafilterNat_NSLIMSEQ 1);
   147 by (etac FreeUltrafilterNat_NSLIMSEQ 1);
   148 qed "HNatInfinite_NSLIMSEQ";
   148 qed "HNatInfinite_NSLIMSEQ";
   154 \         {n. r <= abs (X (f n) + - (L::real))} = {}";
   154 \         {n. r <= abs (X (f n) + - (L::real))} = {}";
   155 by (auto_tac (claset() addDs [real_less_le_trans] 
   155 by (auto_tac (claset() addDs [real_less_le_trans] 
   156     addIs [real_less_irrefl], simpset()));
   156     addIs [real_less_irrefl], simpset()));
   157 val lemmaLIM2 = result();
   157 val lemmaLIM2 = result();
   158 
   158 
   159 Goal "!!f. [| #0 < r; ALL n. r <= abs (X (f n) + - L); \
   159 Goal "[| #0 < r; ALL n. r <= abs (X (f n) + - L); \
   160 \          (*fNat* X) (Abs_hypnat (hypnatrel ^^ {f})) + \
   160 \          (*fNat* X) (Abs_hypnat (hypnatrel ^^ {f})) + \
   161 \          - hypreal_of_real  L @= 0 |] ==> False";
   161 \          - hypreal_of_real  L @= 0 |] ==> False";
   162 by (auto_tac (claset(),simpset() addsimps [starfunNat,
   162 by (auto_tac (claset(),simpset() addsimps [starfunNat,
   163     mem_infmal_iff RS sym,hypreal_of_real_def,
   163     mem_infmal_iff RS sym,hypreal_of_real_def,
   164     hypreal_minus,hypreal_add,
   164     hypreal_minus,hypreal_add,
   172 by (asm_full_simp_tac (simpset() addsimps [lemmaLIM2,
   172 by (asm_full_simp_tac (simpset() addsimps [lemmaLIM2,
   173     FreeUltrafilterNat_empty]) 1);
   173     FreeUltrafilterNat_empty]) 1);
   174 val lemmaLIM3 = result();
   174 val lemmaLIM3 = result();
   175 
   175 
   176 Goalw [LIMSEQ_def,NSLIMSEQ_def] 
   176 Goalw [LIMSEQ_def,NSLIMSEQ_def] 
   177       "!!X. X ----NS> L ==> X ----> L";
   177       "X ----NS> L ==> X ----> L";
   178 by (rtac ccontr 1 THEN Asm_full_simp_tac 1);
   178 by (rtac ccontr 1 THEN Asm_full_simp_tac 1);
   179 by (Step_tac 1);
   179 by (Step_tac 1);
   180 (* skolemization step *)
   180 (* skolemization step *)
   181 by (dtac choice 1 THEN Step_tac 1);
   181 by (dtac choice 1 THEN Step_tac 1);
   182 by (dres_inst_tac [("x","Abs_hypnat(hypnatrel^^{f})")] bspec 1);
   182 by (dres_inst_tac [("x","Abs_hypnat(hypnatrel^^{f})")] bspec 1);
   201 Goalw [LIMSEQ_def] "(%n. k) ----> k";
   201 Goalw [LIMSEQ_def] "(%n. k) ----> k";
   202 by (Auto_tac);
   202 by (Auto_tac);
   203 qed "LIMSEQ_const";
   203 qed "LIMSEQ_const";
   204 
   204 
   205 Goalw [NSLIMSEQ_def]
   205 Goalw [NSLIMSEQ_def]
   206       "!!X. [| X ----NS> a; Y ----NS> b |] \
   206       "[| X ----NS> a; Y ----NS> b |] \
   207 \           ==> (%n. X n + Y n) ----NS> a + b";
   207 \           ==> (%n. X n + Y n) ----NS> a + b";
   208 by (auto_tac (claset() addIs [inf_close_add],
   208 by (auto_tac (claset() addIs [inf_close_add],
   209     simpset() addsimps [starfunNat_add RS sym,hypreal_of_real_add]));
   209     simpset() addsimps [starfunNat_add RS sym,hypreal_of_real_add]));
   210 qed "NSLIMSEQ_add";
   210 qed "NSLIMSEQ_add";
   211 
   211 
   212 Goal "!!X. [| X ----> a; Y ----> b |] \
   212 Goal "[| X ----> a; Y ----> b |] \
   213 \           ==> (%n. X n + Y n) ----> a + b";
   213 \           ==> (%n. X n + Y n) ----> a + b";
   214 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   214 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   215     NSLIMSEQ_add]) 1);
   215     NSLIMSEQ_add]) 1);
   216 qed "LIMSEQ_add";
   216 qed "LIMSEQ_add";
   217 
   217 
   218 Goalw [NSLIMSEQ_def]
   218 Goalw [NSLIMSEQ_def]
   219       "!!X. [| X ----NS> a; Y ----NS> b |] \
   219       "[| X ----NS> a; Y ----NS> b |] \
   220 \           ==> (%n. X n * Y n) ----NS> a * b";
   220 \           ==> (%n. X n * Y n) ----NS> a * b";
   221 by (auto_tac (claset() addSIs [starfunNat_mult_HFinite_inf_close],
   221 by (auto_tac (claset() addSIs [starfunNat_mult_HFinite_inf_close],
   222     simpset() addsimps [hypreal_of_real_mult]));
   222     simpset() addsimps [hypreal_of_real_mult]));
   223 qed "NSLIMSEQ_mult";
   223 qed "NSLIMSEQ_mult";
   224 
   224 
   225 Goal "!!X. [| X ----> a; Y ----> b |] \
   225 Goal "[| X ----> a; Y ----> b |] \
   226 \           ==> (%n. X n * Y n) ----> a * b";
   226 \           ==> (%n. X n * Y n) ----> a * b";
   227 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   227 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   228     NSLIMSEQ_mult]) 1);
   228     NSLIMSEQ_mult]) 1);
   229 qed "LIMSEQ_mult";
   229 qed "LIMSEQ_mult";
   230 
   230 
   231 Goalw [NSLIMSEQ_def] 
   231 Goalw [NSLIMSEQ_def] 
   232       "!!X. X ----NS> a ==> (%n. -(X n)) ----NS> -a";
   232       "X ----NS> a ==> (%n. -(X n)) ----NS> -a";
   233 by (auto_tac (claset() addIs [inf_close_minus],
   233 by (auto_tac (claset() addIs [inf_close_minus],
   234     simpset() addsimps [starfunNat_minus RS sym,
   234     simpset() addsimps [starfunNat_minus RS sym,
   235     hypreal_of_real_minus]));
   235     hypreal_of_real_minus]));
   236 qed "NSLIMSEQ_minus";
   236 qed "NSLIMSEQ_minus";
   237 
   237 
   238 Goal "!!X. X ----> a ==> (%n. -(X n)) ----> -a";
   238 Goal "X ----> a ==> (%n. -(X n)) ----> -a";
   239 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   239 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   240     NSLIMSEQ_minus]) 1);
   240     NSLIMSEQ_minus]) 1);
   241 qed "LIMSEQ_minus";
   241 qed "LIMSEQ_minus";
   242 
   242 
   243 Goal "(%n. -(X n)) ----> -a ==> X ----> a";
   243 Goal "(%n. -(X n)) ----> -a ==> X ----> a";
   248 Goal "(%n. -(X n)) ----NS> -a ==> X ----NS> a";
   248 Goal "(%n. -(X n)) ----NS> -a ==> X ----NS> a";
   249 by (dtac NSLIMSEQ_minus 1);
   249 by (dtac NSLIMSEQ_minus 1);
   250 by (Asm_full_simp_tac 1);
   250 by (Asm_full_simp_tac 1);
   251 qed "NSLIMSEQ_minus_cancel";
   251 qed "NSLIMSEQ_minus_cancel";
   252 
   252 
   253 Goal "!!X. [| X ----NS> a; Y ----NS> b |] \
   253 Goal "[| X ----NS> a; Y ----NS> b |] \
   254 \               ==> (%n. X n + -Y n) ----NS> a + -b";
   254 \               ==> (%n. X n + -Y n) ----NS> a + -b";
   255 by (dres_inst_tac [("X","Y")] NSLIMSEQ_minus 1);
   255 by (dres_inst_tac [("X","Y")] NSLIMSEQ_minus 1);
   256 by (auto_tac (claset(),simpset() addsimps [NSLIMSEQ_add]));
   256 by (auto_tac (claset(),simpset() addsimps [NSLIMSEQ_add]));
   257 qed "NSLIMSEQ_add_minus";
   257 qed "NSLIMSEQ_add_minus";
   258 
   258 
   259 Goal "!!X. [| X ----> a; Y ----> b |] \
   259 Goal "[| X ----> a; Y ----> b |] \
   260 \               ==> (%n. X n + -Y n) ----> a + -b";
   260 \               ==> (%n. X n + -Y n) ----> a + -b";
   261 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   261 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   262     NSLIMSEQ_add_minus]) 1);
   262     NSLIMSEQ_add_minus]) 1);
   263 qed "LIMSEQ_add_minus";
   263 qed "LIMSEQ_add_minus";
   264 
   264 
   265 goalw SEQ.thy [real_diff_def] 
   265 Goalw [real_diff_def] 
   266       "!!X. [| X ----> a; Y ----> b |] \
   266      "[| X ----> a; Y ----> b |] ==> (%n. X n - Y n) ----> a - b";
   267 \               ==> (%n. X n - Y n) ----> a - b";
       
   268 by (blast_tac (claset() addIs [LIMSEQ_add_minus]) 1);
   267 by (blast_tac (claset() addIs [LIMSEQ_add_minus]) 1);
   269 qed "LIMSEQ_diff";
   268 qed "LIMSEQ_diff";
   270 
   269 
   271 goalw SEQ.thy [real_diff_def] 
   270 Goalw [real_diff_def] 
   272       "!!X. [| X ----NS> a; Y ----NS> b |] \
   271      "[| X ----NS> a; Y ----NS> b |] ==> (%n. X n - Y n) ----NS> a - b";
   273 \               ==> (%n. X n - Y n) ----NS> a - b";
       
   274 by (blast_tac (claset() addIs [NSLIMSEQ_add_minus]) 1);
   272 by (blast_tac (claset() addIs [NSLIMSEQ_add_minus]) 1);
   275 qed "NSLIMSEQ_diff";
   273 qed "NSLIMSEQ_diff";
   276 
   274 
   277 (*---------------------------------------------------------------
   275 (*---------------------------------------------------------------
   278     Proof is exactly same as that of NSLIM_inverse except 
   276     Proof is like that of NSLIM_inverse.
   279     for starfunNat_inverse2 --- would not be the case if we
       
   280     had generalised net theorems for example. Not our
       
   281     real concern though.
       
   282  --------------------------------------------------------------*)
   277  --------------------------------------------------------------*)
   283 Goalw [NSLIMSEQ_def] 
   278 Goalw [NSLIMSEQ_def] 
   284        "!!X. [| X ----NS> a; a ~= #0 |] \
   279      "[| X ----NS> a;  a ~= #0 |] ==> (%n. inverse(X n)) ----NS> inverse(a)";
   285 \            ==> (%n. inverse(X n)) ----NS> inverse(a)";
   280 by (Clarify_tac 1);
   286 by (Step_tac 1);
   281 by (dtac bspec 1);
   287 by (dtac bspec 1 THEN auto_tac (claset(),simpset() 
   282 by (auto_tac (claset(),
   288     addsimps [hypreal_of_real_not_zero_iff RS sym,
   283               simpset() addsimps [hypreal_of_real_not_zero_iff RS sym,
   289     hypreal_of_real_inverse RS sym]));
   284                                   hypreal_of_real_inverse RS sym]));
   290 by (forward_tac [inf_close_hypreal_of_real_not_zero] 1 
   285 by (forward_tac [inf_close_hypreal_of_real_not_zero] 1 THEN assume_tac 1);
   291     THEN assume_tac 1);
   286 by (dtac hypreal_of_real_HFinite_diff_Infinitesimal 1);
   292 by (auto_tac (claset() addSEs [(starfunNat_inverse2 RS subst),
   287 by (stac (starfunNat_inverse RS sym) 1);
   293     inf_close_inverse,hypreal_of_real_HFinite_diff_Infinitesimal],
   288 by (auto_tac (claset() addSEs [inf_close_inverse],
   294     simpset()));
   289               simpset() addsimps [hypreal_of_real_zero_iff]));
   295 qed "NSLIMSEQ_inverse";
   290 qed "NSLIMSEQ_inverse";
   296 
   291 
       
   292 
   297 (*------ Standard version of theorem -------*)
   293 (*------ Standard version of theorem -------*)
   298 Goal
   294 Goal "[| X ----> a; a ~= #0 |] ==> (%n. inverse(X n)) ----> inverse(a)";
   299        "!!X. [| X ----> a; a ~= #0 |] \
       
   300 \            ==> (%n. inverse(X n)) ----> inverse(a)";
       
   301 by (asm_full_simp_tac (simpset() addsimps [NSLIMSEQ_inverse,
   295 by (asm_full_simp_tac (simpset() addsimps [NSLIMSEQ_inverse,
   302     LIMSEQ_NSLIMSEQ_iff]) 1);
   296     LIMSEQ_NSLIMSEQ_iff]) 1);
   303 qed "LIMSEQ_inverse";
   297 qed "LIMSEQ_inverse";
   304 
   298 
   305 (* trivially proved *)
   299 (* trivially proved *)
   306 Goal
   300 Goal "[| X ----NS> a; Y ----NS> b; b ~= #0 |] \
   307      "!!X. [| X ----NS> a; Y ----NS> b; b ~= #0 |] \
   301 \     ==> (%n. (X n) * inverse(Y n)) ----NS> a*inverse(b)";
   308 \          ==> (%n. (X n) * inverse(Y n)) ----NS> a*inverse(b)";
       
   309 by (blast_tac (claset() addDs [NSLIMSEQ_inverse,NSLIMSEQ_mult]) 1);
   302 by (blast_tac (claset() addDs [NSLIMSEQ_inverse,NSLIMSEQ_mult]) 1);
   310 qed "NSLIMSEQ_mult_inverse";
   303 qed "NSLIMSEQ_mult_inverse";
   311 
   304 
   312 (* let's give a standard proof of theorem *)
   305 (* let's give a standard proof of theorem *)
   313 Goal 
   306 Goal "[| X ----> a; Y ----> b; b ~= #0 |] \
   314      "!!X. [| X ----> a; Y ----> b; b ~= #0 |] \
   307 \     ==> (%n. (X n) * inverse(Y n)) ----> a*inverse(b)";
   315 \          ==> (%n. (X n) * inverse(Y n)) ----> a*inverse(b)";
       
   316 by (blast_tac (claset() addDs [LIMSEQ_inverse,LIMSEQ_mult]) 1);
   308 by (blast_tac (claset() addDs [LIMSEQ_inverse,LIMSEQ_mult]) 1);
   317 qed "LIMSEQ_mult_inverse";
   309 qed "LIMSEQ_mult_inverse";
   318 
   310 
   319 (*-----------------------------------------------
   311 (*-----------------------------------------------
   320             Uniqueness of limit
   312             Uniqueness of limit
   321  ----------------------------------------------*)
   313  ----------------------------------------------*)
   322 Goalw [NSLIMSEQ_def] 
   314 Goalw [NSLIMSEQ_def] 
   323       "!!X. [| X ----NS> a; X ----NS> b |] \
   315      "[| X ----NS> a; X ----NS> b |] ==> a = b";
   324 \           ==> a = b";
       
   325 by (REPEAT(dtac (HNatInfinite_whn RSN (2,bspec)) 1));
   316 by (REPEAT(dtac (HNatInfinite_whn RSN (2,bspec)) 1));
   326 by (auto_tac (claset() addDs [inf_close_trans3], simpset()));
   317 by (auto_tac (claset() addDs [inf_close_trans3], simpset()));
   327 qed "NSLIMSEQ_unique";
   318 qed "NSLIMSEQ_unique";
   328 
   319 
   329 Goal "!!X. [| X ----> a; X ----> b |] \
   320 Goal "[| X ----> a; X ----> b |] ==> a = b";
   330 \              ==> a = b";
       
   331 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   321 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff,
   332     NSLIMSEQ_unique]) 1);
   322     NSLIMSEQ_unique]) 1);
   333 qed "LIMSEQ_unique";
   323 qed "LIMSEQ_unique";
   334 
   324 
   335 (*-----------------------------------------------------------------
   325 (*-----------------------------------------------------------------
   336     theorems about nslim and lim
   326     theorems about nslim and lim
   337  ----------------------------------------------------------------*)
   327  ----------------------------------------------------------------*)
   338 Goalw [lim_def] "!!X. X ----> L ==> lim X = L";
   328 Goalw [lim_def] "X ----> L ==> lim X = L";
   339 by (blast_tac (claset() addIs [LIMSEQ_unique]) 1);
   329 by (blast_tac (claset() addIs [LIMSEQ_unique]) 1);
   340 qed "limI";
   330 qed "limI";
   341 
   331 
   342 Goalw [nslim_def] "!!X. X ----NS> L ==> nslim X = L";
   332 Goalw [nslim_def] "X ----NS> L ==> nslim X = L";
   343 by (blast_tac (claset() addIs [NSLIMSEQ_unique]) 1);
   333 by (blast_tac (claset() addIs [NSLIMSEQ_unique]) 1);
   344 qed "nslimI";
   334 qed "nslimI";
   345 
   335 
   346 Goalw [lim_def,nslim_def] "lim X = nslim X";
   336 Goalw [lim_def,nslim_def] "lim X = nslim X";
   347 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff]) 1);
   337 by (asm_full_simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff]) 1);
   349 
   339 
   350 (*------------------------------------------------------------------
   340 (*------------------------------------------------------------------
   351                       Convergence
   341                       Convergence
   352  -----------------------------------------------------------------*)
   342  -----------------------------------------------------------------*)
   353 Goalw [convergent_def]
   343 Goalw [convergent_def]
   354       "!!f. convergent X ==> EX L. (X ----> L)";
   344      "convergent X ==> EX L. (X ----> L)";
   355 by (assume_tac 1);
   345 by (assume_tac 1);
   356 qed "convergentD";
   346 qed "convergentD";
   357 
   347 
   358 Goalw [convergent_def]
   348 Goalw [convergent_def]
   359       "!!f. (X ----> L) ==> convergent X";
   349      "(X ----> L) ==> convergent X";
   360 by (Blast_tac 1);
   350 by (Blast_tac 1);
   361 qed "convergentI";
   351 qed "convergentI";
   362 
   352 
   363 Goalw [NSconvergent_def]
   353 Goalw [NSconvergent_def]
   364       "!!f. NSconvergent X ==> EX L. (X ----NS> L)";
   354      "NSconvergent X ==> EX L. (X ----NS> L)";
   365 by (assume_tac 1);
   355 by (assume_tac 1);
   366 qed "NSconvergentD";
   356 qed "NSconvergentD";
   367 
   357 
   368 Goalw [NSconvergent_def]
   358 Goalw [NSconvergent_def]
   369       "!!f. (X ----NS> L) ==> NSconvergent X";
   359      "(X ----NS> L) ==> NSconvergent X";
   370 by (Blast_tac 1);
   360 by (Blast_tac 1);
   371 qed "NSconvergentI";
   361 qed "NSconvergentI";
   372 
   362 
   373 Goalw [convergent_def,NSconvergent_def] 
   363 Goalw [convergent_def,NSconvergent_def] 
   374       "convergent X = NSconvergent X";
   364      "convergent X = NSconvergent X";
   375 by (simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff]) 1);
   365 by (simp_tac (simpset() addsimps [LIMSEQ_NSLIMSEQ_iff]) 1);
   376 qed "convergent_NSconvergent_iff";
   366 qed "convergent_NSconvergent_iff";
   377 
   367 
   378 Goalw [NSconvergent_def,nslim_def] 
   368 Goalw [NSconvergent_def,nslim_def] 
   379       "NSconvergent X = (X ----NS> nslim X)";
   369      "NSconvergent X = (X ----NS> nslim X)";
   380 by (auto_tac (claset() addIs [someI], simpset()));
   370 by (auto_tac (claset() addIs [someI], simpset()));
   381 qed "NSconvergent_NSLIMSEQ_iff";
   371 qed "NSconvergent_NSLIMSEQ_iff";
   382 
   372 
   383 Goalw [convergent_def,lim_def] 
   373 Goalw [convergent_def,lim_def] 
   384       "convergent X = (X ----> lim X)";
   374      "convergent X = (X ----> lim X)";
   385 by (auto_tac (claset() addIs [someI], simpset()));
   375 by (auto_tac (claset() addIs [someI], simpset()));
   386 qed "convergent_LIMSEQ_iff";
   376 qed "convergent_LIMSEQ_iff";
   387 
   377 
   388 (*-------------------------------------------------------------------
   378 (*-------------------------------------------------------------------
   389          Subsequence (alternative definition) (e.g. Hoskins)
   379          Subsequence (alternative definition) (e.g. Hoskins)
   412 by (induct_tac "k" 1);
   402 by (induct_tac "k" 1);
   413 by (auto_tac (claset() addIs [real_le_trans], simpset()));
   403 by (auto_tac (claset() addIs [real_le_trans], simpset()));
   414 qed "monoseq_Suc";
   404 qed "monoseq_Suc";
   415 
   405 
   416 Goalw [monoseq_def] 
   406 Goalw [monoseq_def] 
   417        "!!X. ALL m n. m <= n --> X m <= X n ==> monoseq X";
   407        "ALL m n. m <= n --> X m <= X n ==> monoseq X";
   418 by (Blast_tac 1);
   408 by (Blast_tac 1);
   419 qed "monoI1";
   409 qed "monoI1";
   420 
   410 
   421 Goalw [monoseq_def] 
   411 Goalw [monoseq_def] 
   422        "!!X. ALL m n. m <= n --> X n <= X m ==> monoseq X";
   412        "ALL m n. m <= n --> X n <= X m ==> monoseq X";
   423 by (Blast_tac 1);
   413 by (Blast_tac 1);
   424 qed "monoI2";
   414 qed "monoI2";
   425 
   415 
   426 Goal "!!X. ALL n. X n <= X (Suc n) ==> monoseq X";
   416 Goal "ALL n. X n <= X (Suc n) ==> monoseq X";
   427 by (asm_simp_tac (simpset() addsimps [monoseq_Suc]) 1);
   417 by (asm_simp_tac (simpset() addsimps [monoseq_Suc]) 1);
   428 qed "mono_SucI1";
   418 qed "mono_SucI1";
   429 
   419 
   430 Goal "!!X. ALL n. X (Suc n) <= X n ==> monoseq X";
   420 Goal "ALL n. X (Suc n) <= X n ==> monoseq X";
   431 by (asm_simp_tac (simpset() addsimps [monoseq_Suc]) 1);
   421 by (asm_simp_tac (simpset() addsimps [monoseq_Suc]) 1);
   432 qed "mono_SucI2";
   422 qed "mono_SucI2";
   433 
   423 
   434 (*-------------------------------------------------------------------
   424 (*-------------------------------------------------------------------
   435                   Bounded Sequence
   425                   Bounded Sequence
   436  ------------------------------------------------------------------*)
   426  ------------------------------------------------------------------*)
   437 Goalw [Bseq_def] 
   427 Goalw [Bseq_def] 
   438       "!!X. Bseq X ==> EX K. #0 < K & (ALL n. abs(X n) <= K)";
   428       "Bseq X ==> EX K. #0 < K & (ALL n. abs(X n) <= K)";
   439 by (assume_tac 1);
   429 by (assume_tac 1);
   440 qed "BseqD";
   430 qed "BseqD";
   441 
   431 
   442 Goalw [Bseq_def]
   432 Goalw [Bseq_def]
   443       "!!X. [| #0 < K; ALL n. abs(X n) <= K |] \
   433       "[| #0 < K; ALL n. abs(X n) <= K |] \
   444 \           ==> Bseq X";
   434 \           ==> Bseq X";
   445 by (Blast_tac 1);
   435 by (Blast_tac 1);
   446 qed "BseqI";
   436 qed "BseqI";
   447 
   437 
   448 Goal "(EX K. #0 < K & (ALL n. abs(X n) <= K)) = \
   438 Goal "(EX K. #0 < K & (ALL n. abs(X n) <= K)) = \
   477       "Bseq X = (EX N. ALL n. abs(X n) < real_of_posnat N)";
   467       "Bseq X = (EX N. ALL n. abs(X n) < real_of_posnat N)";
   478 by (simp_tac (simpset() addsimps [lemma_NBseq_def2]) 1);
   468 by (simp_tac (simpset() addsimps [lemma_NBseq_def2]) 1);
   479 qed "Bseq_iff1a";
   469 qed "Bseq_iff1a";
   480 
   470 
   481 Goalw [NSBseq_def]
   471 Goalw [NSBseq_def]
   482       "!!X. [| NSBseq X; N: HNatInfinite |] \
   472       "[| NSBseq X; N: HNatInfinite |] \
   483 \           ==> (*fNat* X) N : HFinite";
   473 \           ==> (*fNat* X) N : HFinite";
   484 by (Blast_tac 1);
   474 by (Blast_tac 1);
   485 qed "NSBseqD";
   475 qed "NSBseqD";
   486 
   476 
   487 Goalw [NSBseq_def]
   477 Goalw [NSBseq_def]
   488       "!!X. ALL N: HNatInfinite. (*fNat* X) N : HFinite \
   478       "ALL N: HNatInfinite. (*fNat* X) N : HFinite \
   489 \           ==> NSBseq X";
   479 \           ==> NSBseq X";
   490 by (assume_tac 1);
   480 by (assume_tac 1);
   491 qed "NSBseqI";
   481 qed "NSBseqI";
   492 
   482 
   493 (*-----------------------------------------------------------
   483 (*-----------------------------------------------------------
   522    When we skolemize we then get the required function f::nat=>nat 
   512    When we skolemize we then get the required function f::nat=>nat 
   523    o/w we would be stuck with a skolem function f :: real=>nat which
   513    o/w we would be stuck with a skolem function f :: real=>nat which
   524    is not what we want (read useless!)
   514    is not what we want (read useless!)
   525  -------------------------------------------------------------------*)
   515  -------------------------------------------------------------------*)
   526  
   516  
   527 Goal "!!X. ALL K. #0 < K --> (EX n. K < abs (X n)) \
   517 Goal "ALL K. #0 < K --> (EX n. K < abs (X n)) \
   528 \          ==> ALL N. EX n. real_of_posnat  N < abs (X n)";
   518 \          ==> ALL N. EX n. real_of_posnat  N < abs (X n)";
   529 by (Step_tac 1);
   519 by (Step_tac 1);
   530 by (cut_inst_tac [("n","N")] (rename_numerals real_of_posnat_gt_zero) 1);
   520 by (cut_inst_tac [("n","N")] (rename_numerals real_of_posnat_gt_zero) 1);
   531 by (Blast_tac 1);
   521 by (Blast_tac 1);
   532 val lemmaNSBseq = result();
   522 val lemmaNSBseq = result();
   533 
   523 
   534 Goal "!!X. ALL K. #0 < K --> (EX n. K < abs (X n)) \
   524 Goal "ALL K. #0 < K --> (EX n. K < abs (X n)) \
   535 \         ==> EX f. ALL N. real_of_posnat  N < abs (X (f N))";
   525 \         ==> EX f. ALL N. real_of_posnat  N < abs (X (f N))";
   536 by (dtac lemmaNSBseq 1);
   526 by (dtac lemmaNSBseq 1);
   537 by (dtac choice 1);
   527 by (dtac choice 1);
   538 by (Blast_tac 1);
   528 by (Blast_tac 1);
   539 val lemmaNSBseq2 = result();
   529 val lemmaNSBseq2 = result();
   540 
   530 
   541 Goal "!!X. ALL N. real_of_posnat  N < abs (X (f N)) \
   531 Goal "ALL N. real_of_posnat  N < abs (X (f N)) \
   542 \         ==>  Abs_hypreal(hyprel^^{X o f}) : HInfinite";
   532 \         ==>  Abs_hypreal(hyprel^^{X o f}) : HInfinite";
   543 by (auto_tac (claset(),simpset() addsimps 
   533 by (auto_tac (claset(),simpset() addsimps 
   544     [HInfinite_FreeUltrafilterNat_iff,o_def]));
   534     [HInfinite_FreeUltrafilterNat_iff,o_def]));
   545 by (EVERY[rtac bexI 1, rtac lemma_hyprel_refl 2, 
   535 by (EVERY[rtac bexI 1, rtac lemma_hyprel_refl 2, 
   546     Step_tac 1]);
   536     Step_tac 1]);
   613    A convergent sequence is bounded
   603    A convergent sequence is bounded
   614    (Boundedness as a necessary condition for convergence)
   604    (Boundedness as a necessary condition for convergence)
   615  -----------------------------------------------------------------------*)
   605  -----------------------------------------------------------------------*)
   616 (* easier --- nonstandard version - no existential as usual *)
   606 (* easier --- nonstandard version - no existential as usual *)
   617 Goalw [NSconvergent_def,NSBseq_def,NSLIMSEQ_def] 
   607 Goalw [NSconvergent_def,NSBseq_def,NSLIMSEQ_def] 
   618           "!!X. NSconvergent X ==> NSBseq X";
   608           "NSconvergent X ==> NSBseq X";
   619 by (blast_tac (claset() addDs [HFinite_hypreal_of_real RS 
   609 by (blast_tac (claset() addDs [HFinite_hypreal_of_real RS 
   620                (inf_close_sym RSN (2,inf_close_HFinite))]) 1);
   610                (inf_close_sym RSN (2,inf_close_HFinite))]) 1);
   621 qed "NSconvergent_NSBseq";
   611 qed "NSconvergent_NSBseq";
   622 
   612 
   623 (* standard version - easily now proved using *)
   613 (* standard version - easily now proved using *)
   624 (* equivalence of NS and standard definitions *)
   614 (* equivalence of NS and standard definitions *)
   625 Goal "!!X. convergent X ==> Bseq X";
   615 Goal "convergent X ==> Bseq X";
   626 by (asm_full_simp_tac (simpset() addsimps [NSconvergent_NSBseq,
   616 by (asm_full_simp_tac (simpset() addsimps [NSconvergent_NSBseq,
   627     convergent_NSconvergent_iff,Bseq_NSBseq_iff]) 1);
   617     convergent_NSconvergent_iff,Bseq_NSBseq_iff]) 1);
   628 qed "convergent_Bseq";
   618 qed "convergent_Bseq";
   629 
   619 
   630 (*----------------------------------------------------------------------
   620 (*----------------------------------------------------------------------
   648     Bseq_isUb]) 1);
   638     Bseq_isUb]) 1);
   649 qed "Bseq_isLub";
   639 qed "Bseq_isLub";
   650 
   640 
   651 (* nonstandard version of premise will be *)
   641 (* nonstandard version of premise will be *)
   652 (* handy when we work in NS universe      *)
   642 (* handy when we work in NS universe      *)
   653 Goal   "!!X. NSBseq X ==> \
   643 Goal   "NSBseq X ==> \
   654 \  EX U. isUb (UNIV::real set) {x. EX n. X n = x} U";
   644 \  EX U. isUb (UNIV::real set) {x. EX n. X n = x} U";
   655 by (asm_full_simp_tac (simpset() addsimps 
   645 by (asm_full_simp_tac (simpset() addsimps 
   656     [Bseq_NSBseq_iff RS sym,Bseq_isUb]) 1);
   646     [Bseq_NSBseq_iff RS sym,Bseq_isUb]) 1);
   657 qed "NSBseq_isUb";
   647 qed "NSBseq_isUb";
   658 
   648 
   659 Goal
   649 Goal
   660   "!!X. NSBseq X ==> \
   650   "NSBseq X ==> \
   661 \  EX U. isLub (UNIV::real set) {x. EX n. X n = x} U";
   651 \  EX U. isLub (UNIV::real set) {x. EX n. X n = x} U";
   662 by (asm_full_simp_tac (simpset() addsimps 
   652 by (asm_full_simp_tac (simpset() addsimps 
   663     [Bseq_NSBseq_iff RS sym,Bseq_isLub]) 1);
   653     [Bseq_NSBseq_iff RS sym,Bseq_isLub]) 1);
   664 qed "NSBseq_isLub";
   654 qed "NSBseq_isLub";
   665 
   655 
   680    The best of both world: Easier to prove this result as a standard
   670    The best of both world: Easier to prove this result as a standard
   681    theorem and then use equivalence to "transfer" it into the
   671    theorem and then use equivalence to "transfer" it into the
   682    equivalent nonstandard form if needed!
   672    equivalent nonstandard form if needed!
   683  -------------------------------------------------------------------*)
   673  -------------------------------------------------------------------*)
   684 Goalw [LIMSEQ_def] 
   674 Goalw [LIMSEQ_def] 
   685          "!!X. ALL n. m <= n --> X n = X m \
   675          "ALL n. m <= n --> X n = X m \
   686 \         ==> EX L. (X ----> L)";  
   676 \         ==> EX L. (X ----> L)";  
   687 by (res_inst_tac [("x","X m")] exI 1);
   677 by (res_inst_tac [("x","X m")] exI 1);
   688 by (Step_tac 1);
   678 by (Step_tac 1);
   689 by (res_inst_tac [("x","m")] exI 1);
   679 by (res_inst_tac [("x","m")] exI 1);
   690 by (Step_tac 1);
   680 by (Step_tac 1);
   691 by (dtac spec 1 THEN etac impE 1);
   681 by (dtac spec 1 THEN etac impE 1);
   692 by (Auto_tac);
   682 by (Auto_tac);
   693 qed "Bmonoseq_LIMSEQ";
   683 qed "Bmonoseq_LIMSEQ";
   694 
   684 
   695 (* Now same theorem in terms of NS limit *)
   685 (* Now same theorem in terms of NS limit *)
   696 Goal "!!X. ALL n. m <= n --> X n = X m \
   686 Goal "ALL n. m <= n --> X n = X m \
   697 \         ==> EX L. (X ----NS> L)";  
   687 \         ==> EX L. (X ----NS> L)";  
   698 by (auto_tac (claset() addSDs [Bmonoseq_LIMSEQ],
   688 by (auto_tac (claset() addSDs [Bmonoseq_LIMSEQ],
   699     simpset() addsimps [LIMSEQ_NSLIMSEQ_iff]));
   689     simpset() addsimps [LIMSEQ_NSLIMSEQ_iff]));
   700 qed "Bmonoseq_NSLIMSEQ";
   690 qed "Bmonoseq_NSLIMSEQ";
   701 
   691 
   735 (*-------------------------------------------------------------------
   725 (*-------------------------------------------------------------------
   736   A standard proof of the theorem for monotone increasing sequence
   726   A standard proof of the theorem for monotone increasing sequence
   737  ------------------------------------------------------------------*)
   727  ------------------------------------------------------------------*)
   738 
   728 
   739 Goalw [convergent_def] 
   729 Goalw [convergent_def] 
   740      "!!X. [| Bseq X; ALL m n. m <= n --> X m <= X n |] \
   730      "[| Bseq X; ALL m n. m <= n --> X m <= X n |] \
   741 \                ==> convergent X";
   731 \                ==> convergent X";
   742 by (forward_tac [Bseq_isLub] 1);
   732 by (forward_tac [Bseq_isLub] 1);
   743 by (Step_tac 1);
   733 by (Step_tac 1);
   744 by (case_tac "EX m. X m = U" 1 THEN Auto_tac);
   734 by (case_tac "EX m. X m = U" 1 THEN Auto_tac);
   745 by (blast_tac (claset() addDs [lemma_converg1,
   735 by (blast_tac (claset() addDs [lemma_converg1,
   755 by (arith_tac 1);
   745 by (arith_tac 1);
   756 qed "Bseq_mono_convergent";
   746 qed "Bseq_mono_convergent";
   757 
   747 
   758 (* NS version of theorem *)
   748 (* NS version of theorem *)
   759 Goalw [convergent_def] 
   749 Goalw [convergent_def] 
   760      "!!X. [| NSBseq X; ALL m n. m <= n --> X m <= X n |] \
   750      "[| NSBseq X; ALL m n. m <= n --> X m <= X n |] \
   761 \                ==> NSconvergent X";
   751 \                ==> NSconvergent X";
   762 by (auto_tac (claset() addIs [Bseq_mono_convergent], 
   752 by (auto_tac (claset() addIs [Bseq_mono_convergent], 
   763     simpset() addsimps [convergent_NSconvergent_iff RS sym,
   753     simpset() addsimps [convergent_NSconvergent_iff RS sym,
   764     Bseq_NSBseq_iff RS sym]));
   754     Bseq_NSBseq_iff RS sym]));
   765 qed "NSBseq_mono_NSconvergent";
   755 qed "NSBseq_mono_NSconvergent";
   766 
   756 
   767 Goalw [convergent_def] 
   757 Goalw [convergent_def] 
   768       "!!X. (convergent X) = (convergent (%n. -(X n)))";
   758       "(convergent X) = (convergent (%n. -(X n)))";
   769 by (auto_tac (claset() addDs [LIMSEQ_minus], simpset()));
   759 by (auto_tac (claset() addDs [LIMSEQ_minus], simpset()));
   770 by (dtac LIMSEQ_minus 1 THEN Auto_tac);
   760 by (dtac LIMSEQ_minus 1 THEN Auto_tac);
   771 qed "convergent_minus_iff";
   761 qed "convergent_minus_iff";
   772 
   762 
   773 Goalw [Bseq_def] "Bseq (%n. -(X n)) = Bseq X";
   763 Goalw [Bseq_def] "Bseq (%n. -(X n)) = Bseq X";
   776 
   766 
   777 (*--------------------------------
   767 (*--------------------------------
   778    **** main mono theorem ****
   768    **** main mono theorem ****
   779  -------------------------------*)
   769  -------------------------------*)
   780 Goalw [monoseq_def] 
   770 Goalw [monoseq_def] 
   781       "!!X. [| Bseq X; monoseq X |] ==> convergent X";
   771       "[| Bseq X; monoseq X |] ==> convergent X";
   782 by (Step_tac 1);
   772 by (Step_tac 1);
   783 by (rtac (convergent_minus_iff RS ssubst) 2);
   773 by (rtac (convergent_minus_iff RS ssubst) 2);
   784 by (dtac (Bseq_minus_iff RS ssubst) 2);
   774 by (dtac (Bseq_minus_iff RS ssubst) 2);
   785 by (auto_tac (claset() addSIs [Bseq_mono_convergent], simpset()));
   775 by (auto_tac (claset() addSIs [Bseq_mono_convergent], simpset()));
   786 qed "Bseq_monoseq_convergent";
   776 qed "Bseq_monoseq_convergent";
   791  
   781  
   792 (***--- alternative formulation for boundedness---***)
   782 (***--- alternative formulation for boundedness---***)
   793 Goalw [Bseq_def] 
   783 Goalw [Bseq_def] 
   794    "Bseq X = (EX k x. #0 < k & (ALL n. abs(X(n) + -x) <= k))";
   784    "Bseq X = (EX k x. #0 < k & (ALL n. abs(X(n) + -x) <= k))";
   795 by (Step_tac 1);
   785 by (Step_tac 1);
       
   786 by (res_inst_tac [("x","k + abs(x)")] exI 2);
   796 by (res_inst_tac [("x","K")] exI 1);
   787 by (res_inst_tac [("x","K")] exI 1);
   797 by (res_inst_tac [("x","0")] exI 1);
   788 by (res_inst_tac [("x","0")] exI 1);
   798 by (Auto_tac);
   789 by (Auto_tac);
   799 by (res_inst_tac [("x","k + abs(x)")] exI 1);
   790 by (ALLGOALS (dres_inst_tac [("x","n")] spec));
   800 by (Step_tac 1);
   791 by (ALLGOALS arith_tac);
   801 by (dres_inst_tac [("x","n")] spec 2);
       
   802 by (ALLGOALS(arith_tac));
       
   803 qed "Bseq_iff2";
   792 qed "Bseq_iff2";
   804 
   793 
   805 (***--- alternative formulation for boundedness ---***)
   794 (***--- alternative formulation for boundedness ---***)
   806 Goal "Bseq X = (EX k N. #0 < k & (ALL n. \
   795 Goal "Bseq X = (EX k N. #0 < k & (ALL n. abs(X(n) + -X(N)) <= k))";
   807 \                        abs(X(n) + -X(N)) <= k))";
       
   808 by (Step_tac 1);
   796 by (Step_tac 1);
   809 by (asm_full_simp_tac (simpset() addsimps [Bseq_def]) 1);
   797 by (asm_full_simp_tac (simpset() addsimps [Bseq_def]) 1);
   810 by (Step_tac 1);
   798 by (Step_tac 1);
   811 by (res_inst_tac [("x","K + abs(X N)")] exI 1);
   799 by (res_inst_tac [("x","K + abs(X N)")] exI 1);
   812 by (Auto_tac);
   800 by (Auto_tac);
   813 by (etac abs_add_pos_gt_zero 1);
   801 by (arith_tac 1);
   814 by (res_inst_tac [("x","N")] exI 1);
   802 by (res_inst_tac [("x","N")] exI 1);
   815 by (Step_tac 1);
   803 by (Step_tac 1);
   816 by (res_inst_tac [("j","abs(X n) + abs (X N)")] 
   804 by (dres_inst_tac [("x","n")] spec 1);
   817     real_le_trans 1);
   805 by (arith_tac 1);
   818 by (auto_tac (claset() addIs [abs_triangle_minus_ineq,
   806 by (auto_tac (claset(), simpset() addsimps [Bseq_iff2]));
   819     real_add_le_mono1], simpset() addsimps [Bseq_iff2]));
       
   820 qed "Bseq_iff3";
   807 qed "Bseq_iff3";
   821 
       
   822 val real_not_leE = CLAIM "~ m <= n ==> n < (m::real)";
       
   823 
   808 
   824 Goalw [Bseq_def] "(ALL n. k <= f n & f n <= K) ==> Bseq f";
   809 Goalw [Bseq_def] "(ALL n. k <= f n & f n <= K) ==> Bseq f";
   825 by (res_inst_tac [("x","(abs(k) + abs(K)) + #1")] exI 1);
   810 by (res_inst_tac [("x","(abs(k) + abs(K)) + #1")] exI 1);
   826 by (Auto_tac);
   811 by (Auto_tac);
   827 by (arith_tac 1);
   812 by (dres_inst_tac [("x","n")] spec 2);
   828 by (case_tac "#0 <= f n" 1);
   813 by (ALLGOALS arith_tac);
   829 by (auto_tac (claset(),simpset() addsimps [abs_eqI1,
       
   830     real_not_leE RS abs_minus_eqI2]));
       
   831 by (res_inst_tac [("j","abs K")] real_le_trans 1);
       
   832 by (res_inst_tac [("j","abs k")] real_le_trans 3);
       
   833 by (auto_tac (claset() addSIs [rename_numerals real_le_add_order] addDs 
       
   834     [real_le_trans], simpset() 
       
   835     addsimps [abs_ge_zero,rename_numerals real_zero_less_one,abs_eqI1]));
       
   836 by (subgoal_tac "k < 0" 1);
       
   837 by (rtac (real_not_leE RSN (2,real_le_less_trans)) 2);
       
   838 by (auto_tac (claset(),simpset() addsimps [abs_minus_eqI2]));
       
   839 qed "BseqI2";
   814 qed "BseqI2";
   840 
   815 
   841 (*-------------------------------------------------------------------
   816 (*-------------------------------------------------------------------
   842    Equivalence between NS and standard definitions of Cauchy seqs
   817    Equivalence between NS and standard definitions of Cauchy seqs
   843  ------------------------------------------------------------------*)
   818  ------------------------------------------------------------------*)
   844 (*-------------------------------
   819 (*-------------------------------
   845       Standard def => NS def
   820       Standard def => NS def
   846  -------------------------------*)
   821  -------------------------------*)
   847 Goal "!!x. Abs_hypnat (hypnatrel ^^ {x}) : HNatInfinite \
   822 Goal "Abs_hypnat (hypnatrel ^^ {x}) : HNatInfinite \
   848 \         ==> {n. M <= x n} : FreeUltrafilterNat";
   823 \         ==> {n. M <= x n} : FreeUltrafilterNat";
   849 by (auto_tac (claset(),simpset() addsimps 
   824 by (auto_tac (claset(),
   850      [HNatInfinite_FreeUltrafilterNat_iff]));
   825               simpset() addsimps [HNatInfinite_FreeUltrafilterNat_iff]));
   851 by (dres_inst_tac [("x","M")] spec 1);
   826 by (dres_inst_tac [("x","M")] spec 1);
   852 by (ultra_tac (claset(),simpset() addsimps [less_imp_le]) 1);
   827 by (ultra_tac (claset(),simpset() addsimps [less_imp_le]) 1);
   853 val lemmaCauchy1 = result();
   828 val lemmaCauchy1 = result();
   854 
   829 
   855 Goal "{n. ALL m n. M <= m & M <= (n::nat) --> abs (X m + - X n) < u} Int \
   830 Goal "{n. ALL m n. M <= m & M <= (n::nat) --> abs (X m + - X n) < u} Int \
   922   Cauchy sequence is bounded -- this is the standard 
   897   Cauchy sequence is bounded -- this is the standard 
   923   proof mechanization rather than the nonstandard proof 
   898   proof mechanization rather than the nonstandard proof 
   924  -------------------------------------------------------*)
   899  -------------------------------------------------------*)
   925 
   900 
   926 (***-------------  VARIOUS LEMMAS --------------***)
   901 (***-------------  VARIOUS LEMMAS --------------***)
   927 Goal "!!X. ALL n. M <= n --> abs (X M + - X n) < (#1::real) \
   902 Goal "ALL n. M <= n --> abs (X M + - X n) < (#1::real) \
   928 \         ==>  ALL n. M <= n --> abs(X n) < #1 + abs(X M)";
   903 \         ==>  ALL n. M <= n --> abs(X n) < #1 + abs(X M)";
   929 by (Step_tac 1);
   904 by (Step_tac 1);
   930 by (dtac spec 1 THEN Auto_tac);
   905 by (dtac spec 1 THEN Auto_tac);
   931 by (arith_tac 1);
   906 by (arith_tac 1);
   932 val lemmaCauchy = result();
   907 val lemmaCauchy = result();
  1019 by (res_inst_tac [("x","#1 + abs(X M)")] exI 1);
   994 by (res_inst_tac [("x","#1 + abs(X M)")] exI 1);
  1020 by (res_inst_tac [("x","#1 + abs(X M)")] exI 2);
   995 by (res_inst_tac [("x","#1 + abs(X M)")] exI 2);
  1021 by (res_inst_tac [("x","abs(X m)")] exI 3);
   996 by (res_inst_tac [("x","abs(X m)")] exI 3);
  1022 by (auto_tac (claset() addSEs [lemma_Nat_covered],
   997 by (auto_tac (claset() addSEs [lemma_Nat_covered],
  1023               simpset()));
   998               simpset()));
       
   999 by (ALLGOALS arith_tac);
  1024 qed "Cauchy_Bseq";
  1000 qed "Cauchy_Bseq";
  1025 
  1001 
  1026 (*------------------------------------------------
  1002 (*------------------------------------------------
  1027   Cauchy sequence is bounded -- NSformulation
  1003   Cauchy sequence is bounded -- NSformulation
  1028  ------------------------------------------------*)
  1004  ------------------------------------------------*)
  1067 (*-----------------------------------------------------------------
  1043 (*-----------------------------------------------------------------
  1068      We can now try and derive a few properties of sequences
  1044      We can now try and derive a few properties of sequences
  1069      starting with the limit comparison property for sequences
  1045      starting with the limit comparison property for sequences
  1070  -----------------------------------------------------------------*)
  1046  -----------------------------------------------------------------*)
  1071 Goalw [NSLIMSEQ_def]
  1047 Goalw [NSLIMSEQ_def]
  1072        "!!f. [| f ----NS> l; g ----NS> m; \
  1048        "[| f ----NS> l; g ----NS> m; \
  1073 \                  EX N. ALL n. N <= n --> f(n) <= g(n) \
  1049 \                  EX N. ALL n. N <= n --> f(n) <= g(n) \
  1074 \               |] ==> l <= m";
  1050 \               |] ==> l <= m";
  1075 by (Step_tac 1);
  1051 by (Step_tac 1);
  1076 by (dtac starfun_le_mono 1);
  1052 by (dtac starfun_le_mono 1);
  1077 by (REPEAT(dtac (HNatInfinite_whn RSN (2,bspec)) 1));
  1053 by (REPEAT(dtac (HNatInfinite_whn RSN (2,bspec)) 1));
  1395     in order to prove equivalence between Cauchy criterion 
  1371     in order to prove equivalence between Cauchy criterion 
  1396     and convergence:
  1372     and convergence:
  1397  -- Show that every sequence contains a monotonic subsequence   
  1373  -- Show that every sequence contains a monotonic subsequence   
  1398 Goal "EX f. subseq f & monoseq (%n. s (f n))";
  1374 Goal "EX f. subseq f & monoseq (%n. s (f n))";
  1399  -- Show that a subsequence of a bounded sequence is bounded
  1375  -- Show that a subsequence of a bounded sequence is bounded
  1400 Goal "!!X. Bseq X ==> Bseq (%n. X (f n))";
  1376 Goal "Bseq X ==> Bseq (%n. X (f n))";
  1401  -- Show we can take subsequential terms arbitrarily far 
  1377  -- Show we can take subsequential terms arbitrarily far 
  1402     up a sequence       
  1378     up a sequence       
  1403 Goal "!!f. subseq f ==> n <= f(n)";
  1379 Goal "subseq f ==> n <= f(n)";
  1404 Goal "!!f. subseq f ==> EX n. N1 <= n & N2 <= f(n)";
  1380 Goal "subseq f ==> EX n. N1 <= n & N2 <= f(n)";
  1405  ---------------------------------------------------------------***)
  1381  ---------------------------------------------------------------***)