src/HOL/Hyperreal/Lim.ML
changeset 13810 c3fbfd472365
parent 13630 a013a9dd370f
child 14262 e7db45b74b3a
equal deleted inserted replaced
13809:a4cd9057d2ee 13810:c3fbfd472365
   436     Continuity 
   436     Continuity 
   437  ---------------*)
   437  ---------------*)
   438 
   438 
   439 Goalw [isNSCont_def] 
   439 Goalw [isNSCont_def] 
   440       "[| isNSCont f a; y \\<approx> hypreal_of_real a |] \
   440       "[| isNSCont f a; y \\<approx> hypreal_of_real a |] \
   441 \           ==> (*f* f) y \\<approx> hypreal_of_real (f a)";
   441 \           ==> ( *f* f) y \\<approx> hypreal_of_real (f a)";
   442 by (Blast_tac 1);
   442 by (Blast_tac 1);
   443 qed "isNSContD";
   443 qed "isNSContD";
   444 
   444 
   445 Goalw [isNSCont_def,NSLIM_def] 
   445 Goalw [isNSCont_def,NSLIM_def] 
   446       "isNSCont f a ==> f -- a --NS> (f a) ";
   446       "isNSCont f a ==> f -- a --NS> (f a) ";
   660 
   660 
   661 (*-----------------------------------------------------------------
   661 (*-----------------------------------------------------------------
   662                         Uniform continuity
   662                         Uniform continuity
   663  ------------------------------------------------------------------*)
   663  ------------------------------------------------------------------*)
   664 Goalw [isNSUCont_def] 
   664 Goalw [isNSUCont_def] 
   665       "[| isNSUCont f; x \\<approx> y|] ==> (*f* f) x \\<approx> (*f* f) y";
   665       "[| isNSUCont f; x \\<approx> y|] ==> ( *f* f) x \\<approx> ( *f* f) y";
   666 by (Blast_tac 1);
   666 by (Blast_tac 1);
   667 qed "isNSUContD";
   667 qed "isNSUContD";
   668 
   668 
   669 Goalw [isUCont_def,isCont_def,LIM_def]
   669 Goalw [isUCont_def,isCont_def,LIM_def]
   670      "isUCont f ==> isCont f x";
   670      "isUCont f ==> isCont f x";
   857 (* while we're at it! *)
   857 (* while we're at it! *)
   858 Goalw [real_diff_def]
   858 Goalw [real_diff_def]
   859      "(NSDERIV f x :> D) = \
   859      "(NSDERIV f x :> D) = \
   860 \     (\\<forall>xa. \
   860 \     (\\<forall>xa. \
   861 \       xa \\<noteq> hypreal_of_real x & xa \\<approx> hypreal_of_real x --> \
   861 \       xa \\<noteq> hypreal_of_real x & xa \\<approx> hypreal_of_real x --> \
   862 \       (*f* (%z. (f z - f x) / (z - x))) xa \\<approx> hypreal_of_real D)";
   862 \       ( *f* (%z. (f z - f x) / (z - x))) xa \\<approx> hypreal_of_real D)";
   863 by (auto_tac (claset(), simpset() addsimps [NSDERIV_NSLIM_iff2, NSLIM_def]));
   863 by (auto_tac (claset(), simpset() addsimps [NSDERIV_NSLIM_iff2, NSLIM_def]));
   864 qed "NSDERIV_iff2";
   864 qed "NSDERIV_iff2";
   865 
   865 
   866 
   866 
   867 Goal "(NSDERIV f x :> D) ==> \
   867 Goal "(NSDERIV f x :> D) ==> \
   868 \    (\\<forall>u. \
   868 \    (\\<forall>u. \
   869 \       u \\<approx> hypreal_of_real x --> \
   869 \       u \\<approx> hypreal_of_real x --> \
   870 \       (*f* (%z. f z - f x)) u \\<approx> hypreal_of_real D * (u - hypreal_of_real x))";
   870 \       ( *f* (%z. f z - f x)) u \\<approx> hypreal_of_real D * (u - hypreal_of_real x))";
   871 by (auto_tac (claset(), simpset() addsimps [NSDERIV_iff2]));
   871 by (auto_tac (claset(), simpset() addsimps [NSDERIV_iff2]));
   872 by (case_tac "u = hypreal_of_real x" 1);
   872 by (case_tac "u = hypreal_of_real x" 1);
   873 by (auto_tac (claset(), simpset() addsimps [hypreal_diff_def]));
   873 by (auto_tac (claset(), simpset() addsimps [hypreal_diff_def]));
   874 by (dres_inst_tac [("x","u")] spec 1);
   874 by (dres_inst_tac [("x","u")] spec 1);
   875 by Auto_tac;
   875 by Auto_tac;
   876 by (dres_inst_tac [("c","u - hypreal_of_real x"),("b","hypreal_of_real D")]
   876 by (dres_inst_tac [("c","u - hypreal_of_real x"),("b","hypreal_of_real D")]
   877      approx_mult1 1);
   877      approx_mult1 1);
   878 by (ALLGOALS(dtac (hypreal_not_eq_minus_iff RS iffD1)));
   878 by (ALLGOALS(dtac (hypreal_not_eq_minus_iff RS iffD1)));
   879 by (subgoal_tac "(*f* (%z. z - x)) u \\<noteq> (0::hypreal)" 2);
   879 by (subgoal_tac "( *f* (%z. z - x)) u \\<noteq> (0::hypreal)" 2);
   880 by (auto_tac (claset(),
   880 by (auto_tac (claset(),
   881     simpset() addsimps [real_diff_def, hypreal_diff_def, 
   881     simpset() addsimps [real_diff_def, hypreal_diff_def, 
   882 		(approx_minus_iff RS iffD1) RS (mem_infmal_iff RS iffD2),  
   882 		(approx_minus_iff RS iffD1) RS (mem_infmal_iff RS iffD2),  
   883 			Infinitesimal_subset_HFinite RS subsetD]));
   883 			Infinitesimal_subset_HFinite RS subsetD]));
   884 qed "NSDERIVD5";
   884 qed "NSDERIVD5";
   885 
   885 
   886 Goal "(NSDERIV f x :> D) ==> \
   886 Goal "(NSDERIV f x :> D) ==> \
   887 \     (\\<forall>h \\<in> Infinitesimal. \
   887 \     (\\<forall>h \\<in> Infinitesimal. \
   888 \              ((*f* f)(hypreal_of_real x + h) - \
   888 \              (( *f* f)(hypreal_of_real x + h) - \
   889 \                hypreal_of_real (f x))\\<approx> (hypreal_of_real D) * h)";
   889 \                hypreal_of_real (f x))\\<approx> (hypreal_of_real D) * h)";
   890 by (auto_tac (claset(),simpset() addsimps [nsderiv_def]));
   890 by (auto_tac (claset(),simpset() addsimps [nsderiv_def]));
   891 by (case_tac "h = (0::hypreal)" 1);
   891 by (case_tac "h = (0::hypreal)" 1);
   892 by (auto_tac (claset(),simpset() addsimps [hypreal_diff_def]));
   892 by (auto_tac (claset(),simpset() addsimps [hypreal_diff_def]));
   893 by (dres_inst_tac [("x","h")] bspec 1);
   893 by (dres_inst_tac [("x","h")] bspec 1);
   896               simpset() addsimps [hypreal_diff_def]));
   896               simpset() addsimps [hypreal_diff_def]));
   897 qed "NSDERIVD4";
   897 qed "NSDERIVD4";
   898 
   898 
   899 Goal "(NSDERIV f x :> D) ==> \
   899 Goal "(NSDERIV f x :> D) ==> \
   900 \     (\\<forall>h \\<in> Infinitesimal - {0}. \
   900 \     (\\<forall>h \\<in> Infinitesimal - {0}. \
   901 \              ((*f* f)(hypreal_of_real x + h) - \
   901 \              (( *f* f)(hypreal_of_real x + h) - \
   902 \                hypreal_of_real (f x))\\<approx> (hypreal_of_real D) * h)";
   902 \                hypreal_of_real (f x))\\<approx> (hypreal_of_real D) * h)";
   903 by (auto_tac (claset(),simpset() addsimps [nsderiv_def]));
   903 by (auto_tac (claset(),simpset() addsimps [nsderiv_def]));
   904 by (rtac ccontr 1 THEN dres_inst_tac [("x","h")] bspec 1);
   904 by (rtac ccontr 1 THEN dres_inst_tac [("x","h")] bspec 1);
   905 by (dres_inst_tac [("c","h")] approx_mult1 2);
   905 by (dres_inst_tac [("c","h")] approx_mult1 2);
   906 by (auto_tac (claset() addIs [Infinitesimal_subset_HFinite RS subsetD],
   906 by (auto_tac (claset() addIs [Infinitesimal_subset_HFinite RS subsetD],
  1112 (*---------------------------------------------------------------
  1112 (*---------------------------------------------------------------
  1113                      (NS) Increment
  1113                      (NS) Increment
  1114  ---------------------------------------------------------------*)
  1114  ---------------------------------------------------------------*)
  1115 Goalw [increment_def] 
  1115 Goalw [increment_def] 
  1116       "f NSdifferentiable x ==> \
  1116       "f NSdifferentiable x ==> \
  1117 \     increment f x h = (*f* f) (hypreal_of_real(x) + h) + \
  1117 \     increment f x h = ( *f* f) (hypreal_of_real(x) + h) + \
  1118 \     -hypreal_of_real (f x)";
  1118 \     -hypreal_of_real (f x)";
  1119 by (Blast_tac 1);
  1119 by (Blast_tac 1);
  1120 qed "incrementI";
  1120 qed "incrementI";
  1121 
  1121 
  1122 Goal "NSDERIV f x :> D ==> \
  1122 Goal "NSDERIV f x :> D ==> \
  1123 \    increment f x h = (*f* f) (hypreal_of_real(x) + h) + \
  1123 \    increment f x h = ( *f* f) (hypreal_of_real(x) + h) + \
  1124 \    -hypreal_of_real (f x)";
  1124 \    -hypreal_of_real (f x)";
  1125 by (etac (NSdifferentiableI RS incrementI) 1);
  1125 by (etac (NSdifferentiableI RS incrementI) 1);
  1126 qed "incrementI2";
  1126 qed "incrementI2";
  1127 
  1127 
  1128 (* The Increment theorem -- Keisler p. 65 *)
  1128 (* The Increment theorem -- Keisler p. 65 *)
  1131 by (forw_inst_tac [("h","h")] incrementI2 1 THEN rewtac nsderiv_def);
  1131 by (forw_inst_tac [("h","h")] incrementI2 1 THEN rewtac nsderiv_def);
  1132 by (dtac bspec 1 THEN Auto_tac);
  1132 by (dtac bspec 1 THEN Auto_tac);
  1133 by (dtac (bex_Infinitesimal_iff2 RS iffD2) 1 THEN Step_tac 1);
  1133 by (dtac (bex_Infinitesimal_iff2 RS iffD2) 1 THEN Step_tac 1);
  1134 by (forw_inst_tac [("b1","hypreal_of_real(D) + y")] 
  1134 by (forw_inst_tac [("b1","hypreal_of_real(D) + y")] 
  1135     ((hypreal_mult_right_cancel RS iffD2)) 1);
  1135     ((hypreal_mult_right_cancel RS iffD2)) 1);
  1136 by (thin_tac "((*f* f) (hypreal_of_real(x) + h) + \
  1136 by (thin_tac "(( *f* f) (hypreal_of_real(x) + h) + \
  1137 \   - hypreal_of_real (f x)) / h = hypreal_of_real(D) + y" 2);
  1137 \   - hypreal_of_real (f x)) / h = hypreal_of_real(D) + y" 2);
  1138 by (assume_tac 1);
  1138 by (assume_tac 1);
  1139 by (asm_full_simp_tac (simpset() addsimps [hypreal_times_divide1_eq RS sym]
  1139 by (asm_full_simp_tac (simpset() addsimps [hypreal_times_divide1_eq RS sym]
  1140              delsimps [hypreal_times_divide1_eq]) 1);
  1140              delsimps [hypreal_times_divide1_eq]) 1);
  1141 by (auto_tac (claset(),
  1141 by (auto_tac (claset(),
  1167  --------------------------------------------------------------*)
  1167  --------------------------------------------------------------*)
  1168 
  1168 
  1169 (* lemmas *)
  1169 (* lemmas *)
  1170 Goalw [nsderiv_def] 
  1170 Goalw [nsderiv_def] 
  1171       "[| NSDERIV g x :> D; \
  1171       "[| NSDERIV g x :> D; \
  1172 \              (*f* g) (hypreal_of_real(x) + xa) = hypreal_of_real(g x);\
  1172 \              ( *f* g) (hypreal_of_real(x) + xa) = hypreal_of_real(g x);\
  1173 \              xa \\<in> Infinitesimal;\
  1173 \              xa \\<in> Infinitesimal;\
  1174 \              xa \\<noteq> 0 \
  1174 \              xa \\<noteq> 0 \
  1175 \           |] ==> D = 0";
  1175 \           |] ==> D = 0";
  1176 by (dtac bspec 1);
  1176 by (dtac bspec 1);
  1177 by Auto_tac;
  1177 by Auto_tac;
  1178 qed "NSDERIV_zero";
  1178 qed "NSDERIV_zero";
  1179 
  1179 
  1180 (* can be proved differently using NSLIM_isCont_iff *)
  1180 (* can be proved differently using NSLIM_isCont_iff *)
  1181 Goalw [nsderiv_def] 
  1181 Goalw [nsderiv_def] 
  1182      "[| NSDERIV f x :> D;  h \\<in> Infinitesimal;  h \\<noteq> 0 |]  \
  1182      "[| NSDERIV f x :> D;  h \\<in> Infinitesimal;  h \\<noteq> 0 |]  \
  1183 \     ==> (*f* f) (hypreal_of_real(x) + h) + -hypreal_of_real(f x) \\<approx> 0";    
  1183 \     ==> ( *f* f) (hypreal_of_real(x) + h) + -hypreal_of_real(f x) \\<approx> 0";    
  1184 by (asm_full_simp_tac (simpset() addsimps 
  1184 by (asm_full_simp_tac (simpset() addsimps 
  1185     [mem_infmal_iff RS sym]) 1);
  1185     [mem_infmal_iff RS sym]) 1);
  1186 by (rtac Infinitesimal_ratio 1);
  1186 by (rtac Infinitesimal_ratio 1);
  1187 by (rtac approx_hypreal_of_real_HFinite 3);
  1187 by (rtac approx_hypreal_of_real_HFinite 3);
  1188 by Auto_tac;
  1188 by Auto_tac;
  1194                 f(x) - f(a)
  1194                 f(x) - f(a)
  1195               --------------- \\<approx> Db
  1195               --------------- \\<approx> Db
  1196                   x - a
  1196                   x - a
  1197  ---------------------------------------------------------------*)
  1197  ---------------------------------------------------------------*)
  1198 Goal "[| NSDERIV f (g x) :> Da; \
  1198 Goal "[| NSDERIV f (g x) :> Da; \
  1199 \        (*f* g) (hypreal_of_real(x) + xa) \\<noteq> hypreal_of_real (g x); \
  1199 \        ( *f* g) (hypreal_of_real(x) + xa) \\<noteq> hypreal_of_real (g x); \
  1200 \        (*f* g) (hypreal_of_real(x) + xa) \\<approx> hypreal_of_real (g x) \
  1200 \        ( *f* g) (hypreal_of_real(x) + xa) \\<approx> hypreal_of_real (g x) \
  1201 \     |] ==> ((*f* f) ((*f* g) (hypreal_of_real(x) + xa)) \
  1201 \     |] ==> (( *f* f) (( *f* g) (hypreal_of_real(x) + xa)) \
  1202 \                  + - hypreal_of_real (f (g x))) \
  1202 \                  + - hypreal_of_real (f (g x))) \
  1203 \             / ((*f* g) (hypreal_of_real(x) + xa) + - hypreal_of_real (g x)) \
  1203 \             / (( *f* g) (hypreal_of_real(x) + xa) + - hypreal_of_real (g x)) \
  1204 \            \\<approx> hypreal_of_real(Da)";
  1204 \            \\<approx> hypreal_of_real(Da)";
  1205 by (auto_tac (claset(),
  1205 by (auto_tac (claset(),
  1206        simpset() addsimps [NSDERIV_NSLIM_iff2, NSLIM_def]));
  1206        simpset() addsimps [NSDERIV_NSLIM_iff2, NSLIM_def]));
  1207 qed "NSDERIVD1";
  1207 qed "NSDERIVD1";
  1208 
  1208 
  1212                 f(x + h) - f(x)
  1212                 f(x + h) - f(x)
  1213                ----------------- \\<approx> Db
  1213                ----------------- \\<approx> Db
  1214                        h
  1214                        h
  1215  --------------------------------------------------------------*)
  1215  --------------------------------------------------------------*)
  1216 Goal "[| NSDERIV g x :> Db; xa \\<in> Infinitesimal; xa \\<noteq> 0 |] \
  1216 Goal "[| NSDERIV g x :> Db; xa \\<in> Infinitesimal; xa \\<noteq> 0 |] \
  1217 \     ==> ((*f* g) (hypreal_of_real(x) + xa) + - hypreal_of_real(g x)) / xa \
  1217 \     ==> (( *f* g) (hypreal_of_real(x) + xa) + - hypreal_of_real(g x)) / xa \
  1218 \         \\<approx> hypreal_of_real(Db)";
  1218 \         \\<approx> hypreal_of_real(Db)";
  1219 by (auto_tac (claset(),
  1219 by (auto_tac (claset(),
  1220     simpset() addsimps [NSDERIV_NSLIM_iff, NSLIM_def, 
  1220     simpset() addsimps [NSDERIV_NSLIM_iff, NSLIM_def, 
  1221 		        mem_infmal_iff, starfun_lambda_cancel]));
  1221 		        mem_infmal_iff, starfun_lambda_cancel]));
  1222 qed "NSDERIVD2";
  1222 qed "NSDERIVD2";
  1233 by (asm_simp_tac (simpset() addsimps [NSDERIV_NSLIM_iff,
  1233 by (asm_simp_tac (simpset() addsimps [NSDERIV_NSLIM_iff,
  1234     NSLIM_def,mem_infmal_iff RS sym]) 1 THEN Step_tac 1);
  1234     NSLIM_def,mem_infmal_iff RS sym]) 1 THEN Step_tac 1);
  1235 by (forw_inst_tac [("f","g")] NSDERIV_approx 1);
  1235 by (forw_inst_tac [("f","g")] NSDERIV_approx 1);
  1236 by (auto_tac (claset(),
  1236 by (auto_tac (claset(),
  1237               simpset() addsimps [starfun_lambda_cancel2, starfun_o RS sym]));
  1237               simpset() addsimps [starfun_lambda_cancel2, starfun_o RS sym]));
  1238 by (case_tac "(*f* g) (hypreal_of_real(x) + xa) = hypreal_of_real (g x)" 1);
  1238 by (case_tac "( *f* g) (hypreal_of_real(x) + xa) = hypreal_of_real (g x)" 1);
  1239 by (dres_inst_tac [("g","g")] NSDERIV_zero 1);
  1239 by (dres_inst_tac [("g","g")] NSDERIV_zero 1);
  1240 by (auto_tac (claset(), simpset() addsimps [hypreal_divide_def]));
  1240 by (auto_tac (claset(), simpset() addsimps [hypreal_divide_def]));
  1241 by (res_inst_tac [("z1","(*f* g) (hypreal_of_real(x) + xa) + -hypreal_of_real (g x)"),
  1241 by (res_inst_tac [("z1","( *f* g) (hypreal_of_real(x) + xa) + -hypreal_of_real (g x)"),
  1242     ("y1","inverse xa")] (lemma_chain RS ssubst) 1);
  1242     ("y1","inverse xa")] (lemma_chain RS ssubst) 1);
  1243 by (etac (hypreal_not_eq_minus_iff RS iffD1) 1);
  1243 by (etac (hypreal_not_eq_minus_iff RS iffD1) 1);
  1244 by (rtac approx_mult_hypreal_of_real 1);
  1244 by (rtac approx_mult_hypreal_of_real 1);
  1245 by (fold_tac [hypreal_divide_def]);
  1245 by (fold_tac [hypreal_divide_def]);
  1246 by (blast_tac (claset() addIs [NSDERIVD1,
  1246 by (blast_tac (claset() addIs [NSDERIVD1,