src/HOL/Limits.thy
changeset 50346 a75c6429c3c3
parent 50331 4b6dc5077e98
child 50347 77e3effa50b6
equal deleted inserted replaced
50345:8cf33d605e81 50346:a75c6429c3c3
   296   then obtain i j where "\<forall>n\<ge>i. P n" and "\<forall>n\<ge>j. Q n" by auto
   296   then obtain i j where "\<forall>n\<ge>i. P n" and "\<forall>n\<ge>j. Q n" by auto
   297   then have "\<forall>n\<ge>max i j. P n \<and> Q n" by simp
   297   then have "\<forall>n\<ge>max i j. P n \<and> Q n" by simp
   298   then show "\<exists>k. \<forall>n\<ge>k. P n \<and> Q n" ..
   298   then show "\<exists>k. \<forall>n\<ge>k. P n \<and> Q n" ..
   299 qed auto
   299 qed auto
   300 
   300 
       
   301 lemma eventually_ge_at_top:
       
   302   "eventually (\<lambda>x. (c::_::linorder) \<le> x) at_top"
       
   303   unfolding eventually_at_top_linorder by auto
       
   304 
   301 lemma eventually_at_top_dense: "eventually P at_top \<longleftrightarrow> (\<exists>N::'a::dense_linorder. \<forall>n>N. P n)"
   305 lemma eventually_at_top_dense: "eventually P at_top \<longleftrightarrow> (\<exists>N::'a::dense_linorder. \<forall>n>N. P n)"
   302   unfolding eventually_at_top_linorder
   306   unfolding eventually_at_top_linorder
   303 proof safe
   307 proof safe
   304   fix N assume "\<forall>n\<ge>N. P n" then show "\<exists>N. \<forall>n>N. P n" by (auto intro!: exI[of _ N])
   308   fix N assume "\<forall>n\<ge>N. P n" then show "\<exists>N. \<forall>n>N. P n" by (auto intro!: exI[of _ N])
   305 next
   309 next
   306   fix N assume "\<forall>n>N. P n"
   310   fix N assume "\<forall>n>N. P n"
   307   moreover from gt_ex[of N] guess y ..
   311   moreover from gt_ex[of N] guess y ..
   308   ultimately show "\<exists>N. \<forall>n\<ge>N. P n" by (auto intro!: exI[of _ y])
   312   ultimately show "\<exists>N. \<forall>n\<ge>N. P n" by (auto intro!: exI[of _ y])
   309 qed
   313 qed
       
   314 
       
   315 lemma eventually_gt_at_top:
       
   316   "eventually (\<lambda>x. (c::_::dense_linorder) < x) at_top"
       
   317   unfolding eventually_at_top_dense by auto
   310 
   318 
   311 definition at_bot :: "('a::order) filter"
   319 definition at_bot :: "('a::order) filter"
   312   where "at_bot = Abs_filter (\<lambda>P. \<exists>k. \<forall>n\<le>k. P n)"
   320   where "at_bot = Abs_filter (\<lambda>P. \<exists>k. \<forall>n\<le>k. P n)"
   313 
   321 
   314 lemma eventually_at_bot_linorder:
   322 lemma eventually_at_bot_linorder:
   320   then obtain i j where "\<forall>n\<le>i. P n" and "\<forall>n\<le>j. Q n" by auto
   328   then obtain i j where "\<forall>n\<le>i. P n" and "\<forall>n\<le>j. Q n" by auto
   321   then have "\<forall>n\<le>min i j. P n \<and> Q n" by simp
   329   then have "\<forall>n\<le>min i j. P n \<and> Q n" by simp
   322   then show "\<exists>k. \<forall>n\<le>k. P n \<and> Q n" ..
   330   then show "\<exists>k. \<forall>n\<le>k. P n \<and> Q n" ..
   323 qed auto
   331 qed auto
   324 
   332 
       
   333 lemma eventually_le_at_bot:
       
   334   "eventually (\<lambda>x. x \<le> (c::_::linorder)) at_bot"
       
   335   unfolding eventually_at_bot_linorder by auto
       
   336 
   325 lemma eventually_at_bot_dense:
   337 lemma eventually_at_bot_dense:
   326   fixes P :: "'a::dense_linorder \<Rightarrow> bool" shows "eventually P at_bot \<longleftrightarrow> (\<exists>N. \<forall>n<N. P n)"
   338   fixes P :: "'a::dense_linorder \<Rightarrow> bool" shows "eventually P at_bot \<longleftrightarrow> (\<exists>N. \<forall>n<N. P n)"
   327   unfolding eventually_at_bot_linorder
   339   unfolding eventually_at_bot_linorder
   328 proof safe
   340 proof safe
   329   fix N assume "\<forall>n\<le>N. P n" then show "\<exists>N. \<forall>n<N. P n" by (auto intro!: exI[of _ N])
   341   fix N assume "\<forall>n\<le>N. P n" then show "\<exists>N. \<forall>n<N. P n" by (auto intro!: exI[of _ N])
   330 next
   342 next
   331   fix N assume "\<forall>n<N. P n" 
   343   fix N assume "\<forall>n<N. P n" 
   332   moreover from lt_ex[of N] guess y ..
   344   moreover from lt_ex[of N] guess y ..
   333   ultimately show "\<exists>N. \<forall>n\<le>N. P n" by (auto intro!: exI[of _ y])
   345   ultimately show "\<exists>N. \<forall>n\<le>N. P n" by (auto intro!: exI[of _ y])
   334 qed
   346 qed
       
   347 
       
   348 lemma eventually_gt_at_bot:
       
   349   "eventually (\<lambda>x. x < (c::_::dense_linorder)) at_bot"
       
   350   unfolding eventually_at_bot_dense by auto
   335 
   351 
   336 subsection {* Sequentially *}
   352 subsection {* Sequentially *}
   337 
   353 
   338 abbreviation sequentially :: "nat filter"
   354 abbreviation sequentially :: "nat filter"
   339   where "sequentially == at_top"
   355   where "sequentially == at_top"
  1191   unfolding sgn_div_norm by (simp add: tendsto_intros)
  1207   unfolding sgn_div_norm by (simp add: tendsto_intros)
  1192 
  1208 
  1193 subsection {* Limits to @{const at_top} and @{const at_bot} *}
  1209 subsection {* Limits to @{const at_top} and @{const at_bot} *}
  1194 
  1210 
  1195 lemma filterlim_at_top:
  1211 lemma filterlim_at_top:
       
  1212   fixes f :: "'a \<Rightarrow> ('b::linorder)"
       
  1213   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. Z \<le> f x) F)"
       
  1214   by (auto simp: filterlim_iff eventually_at_top_linorder elim!: eventually_elim1)
       
  1215 
       
  1216 lemma filterlim_at_top_dense:
  1196   fixes f :: "'a \<Rightarrow> ('b::dense_linorder)"
  1217   fixes f :: "'a \<Rightarrow> ('b::dense_linorder)"
  1197   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. Z < f x) F)"
  1218   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. Z < f x) F)"
  1198   by (auto simp: filterlim_iff eventually_at_top_dense elim!: eventually_elim1)
  1219   by (metis eventually_elim1[of _ F] eventually_gt_at_top order_less_imp_le
       
  1220             filterlim_at_top[of f F] filterlim_iff[of f at_top F])
       
  1221 
       
  1222 lemma filterlim_at_top_ge:
       
  1223   fixes f :: "'a \<Rightarrow> ('b::linorder)" and c :: "'b"
       
  1224   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z\<ge>c. eventually (\<lambda>x. Z \<le> f x) F)"
       
  1225   unfolding filterlim_at_top
       
  1226 proof safe
       
  1227   fix Z assume *: "\<forall>Z\<ge>c. eventually (\<lambda>x. Z \<le> f x) F"
       
  1228   with *[THEN spec, of "max Z c"] show "eventually (\<lambda>x. Z \<le> f x) F"
       
  1229     by (auto elim!: eventually_elim1)
       
  1230 qed simp
       
  1231 
       
  1232 lemma filterlim_at_top_at_top:
       
  1233   fixes f :: "'a::linorder \<Rightarrow> 'b::linorder"
       
  1234   assumes mono: "\<And>x y. Q x \<Longrightarrow> Q y \<Longrightarrow> x \<le> y \<Longrightarrow> f x \<le> f y"
       
  1235   assumes bij: "\<And>x. P x \<Longrightarrow> f (g x) = x" "\<And>x. P x \<Longrightarrow> Q (g x)"
       
  1236   assumes Q: "eventually Q at_top"
       
  1237   assumes P: "eventually P at_top"
       
  1238   shows "filterlim f at_top at_top"
       
  1239 proof -
       
  1240   from P obtain x where x: "\<And>y. x \<le> y \<Longrightarrow> P y"
       
  1241     unfolding eventually_at_top_linorder by auto
       
  1242   show ?thesis
       
  1243   proof (intro filterlim_at_top_ge[THEN iffD2] allI impI)
       
  1244     fix z assume "x \<le> z"
       
  1245     with x have "P z" by auto
       
  1246     have "eventually (\<lambda>x. g z \<le> x) at_top"
       
  1247       by (rule eventually_ge_at_top)
       
  1248     with Q show "eventually (\<lambda>x. z \<le> f x) at_top"
       
  1249       by eventually_elim (metis mono bij `P z`)
       
  1250   qed
       
  1251 qed
  1199 
  1252 
  1200 lemma filterlim_at_top_gt:
  1253 lemma filterlim_at_top_gt:
  1201   fixes f :: "'a \<Rightarrow> ('b::dense_linorder)" and c :: "'b"
  1254   fixes f :: "'a \<Rightarrow> ('b::dense_linorder)" and c :: "'b"
  1202   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z>c. eventually (\<lambda>x. Z < f x) F)"
  1255   shows "(LIM x F. f x :> at_top) \<longleftrightarrow> (\<forall>Z>c. eventually (\<lambda>x. Z \<le> f x) F)"
  1203   unfolding filterlim_at_top
  1256   by (metis filterlim_at_top order_less_le_trans gt_ex filterlim_at_top_ge)
       
  1257 
       
  1258 lemma filterlim_at_bot: 
       
  1259   fixes f :: "'a \<Rightarrow> ('b::linorder)"
       
  1260   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. f x \<le> Z) F)"
       
  1261   by (auto simp: filterlim_iff eventually_at_bot_linorder elim!: eventually_elim1)
       
  1262 
       
  1263 lemma filterlim_at_bot_le:
       
  1264   fixes f :: "'a \<Rightarrow> ('b::linorder)" and c :: "'b"
       
  1265   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z\<le>c. eventually (\<lambda>x. Z \<ge> f x) F)"
       
  1266   unfolding filterlim_at_bot
  1204 proof safe
  1267 proof safe
  1205   fix Z assume *: "\<forall>Z>c. eventually (\<lambda>x. Z < f x) F"
  1268   fix Z assume *: "\<forall>Z\<le>c. eventually (\<lambda>x. Z \<ge> f x) F"
  1206   from gt_ex[of "max Z c"] guess x ..
  1269   with *[THEN spec, of "min Z c"] show "eventually (\<lambda>x. Z \<ge> f x) F"
  1207   with *[THEN spec, of x] show "eventually (\<lambda>x. Z < f x) F"
       
  1208     by (auto elim!: eventually_elim1)
  1270     by (auto elim!: eventually_elim1)
  1209 qed simp
  1271 qed simp
  1210 
  1272 
  1211 lemma filterlim_at_bot: 
       
  1212   fixes f :: "'a \<Rightarrow> ('b::dense_linorder)"
       
  1213   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z. eventually (\<lambda>x. f x < Z) F)"
       
  1214   by (auto simp: filterlim_iff eventually_at_bot_dense elim!: eventually_elim1)
       
  1215 
       
  1216 lemma filterlim_at_bot_lt:
  1273 lemma filterlim_at_bot_lt:
  1217   fixes f :: "'a \<Rightarrow> ('b::dense_linorder)" and c :: "'b"
  1274   fixes f :: "'a \<Rightarrow> ('b::dense_linorder)" and c :: "'b"
  1218   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z<c. eventually (\<lambda>x. Z > f x) F)"
  1275   shows "(LIM x F. f x :> at_bot) \<longleftrightarrow> (\<forall>Z<c. eventually (\<lambda>x. Z \<ge> f x) F)"
  1219   unfolding filterlim_at_bot
  1276   by (metis filterlim_at_bot filterlim_at_bot_le lt_ex order_le_less_trans)
  1220 proof safe
  1277 
  1221   fix Z assume *: "\<forall>Z<c. eventually (\<lambda>x. Z > f x) F"
  1278 lemma filterlim_at_bot_at_right:
  1222   from lt_ex[of "min Z c"] guess x ..
  1279   fixes f :: "real \<Rightarrow> 'b::linorder"
  1223   with *[THEN spec, of x] show "eventually (\<lambda>x. Z > f x) F"
  1280   assumes mono: "\<And>x y. Q x \<Longrightarrow> Q y \<Longrightarrow> x \<le> y \<Longrightarrow> f x \<le> f y"
  1224     by (auto elim!: eventually_elim1)
  1281   assumes bij: "\<And>x. P x \<Longrightarrow> f (g x) = x" "\<And>x. P x \<Longrightarrow> Q (g x)"
  1225 qed simp
  1282   assumes Q: "eventually Q (at_right a)" and bound: "\<And>b. Q b \<Longrightarrow> a < b"
       
  1283   assumes P: "eventually P at_bot"
       
  1284   shows "filterlim f at_bot (at_right a)"
       
  1285 proof -
       
  1286   from P obtain x where x: "\<And>y. y \<le> x \<Longrightarrow> P y"
       
  1287     unfolding eventually_at_bot_linorder by auto
       
  1288   show ?thesis
       
  1289   proof (intro filterlim_at_bot_le[THEN iffD2] allI impI)
       
  1290     fix z assume "z \<le> x"
       
  1291     with x have "P z" by auto
       
  1292     have "eventually (\<lambda>x. x \<le> g z) (at_right a)"
       
  1293       using bound[OF bij(2)[OF `P z`]]
       
  1294       by (auto simp add: eventually_within_less dist_real_def intro!:  exI[of _ "g z - a"])
       
  1295     with Q show "eventually (\<lambda>x. f x \<le> z) (at_right a)"
       
  1296       by eventually_elim (metis bij `P z` mono)
       
  1297   qed
       
  1298 qed
       
  1299 
       
  1300 lemma filterlim_at_top_at_left:
       
  1301   fixes f :: "real \<Rightarrow> 'b::linorder"
       
  1302   assumes mono: "\<And>x y. Q x \<Longrightarrow> Q y \<Longrightarrow> x \<le> y \<Longrightarrow> f x \<le> f y"
       
  1303   assumes bij: "\<And>x. P x \<Longrightarrow> f (g x) = x" "\<And>x. P x \<Longrightarrow> Q (g x)"
       
  1304   assumes Q: "eventually Q (at_left a)" and bound: "\<And>b. Q b \<Longrightarrow> b < a"
       
  1305   assumes P: "eventually P at_top"
       
  1306   shows "filterlim f at_top (at_left a)"
       
  1307 proof -
       
  1308   from P obtain x where x: "\<And>y. x \<le> y \<Longrightarrow> P y"
       
  1309     unfolding eventually_at_top_linorder by auto
       
  1310   show ?thesis
       
  1311   proof (intro filterlim_at_top_ge[THEN iffD2] allI impI)
       
  1312     fix z assume "x \<le> z"
       
  1313     with x have "P z" by auto
       
  1314     have "eventually (\<lambda>x. g z \<le> x) (at_left a)"
       
  1315       using bound[OF bij(2)[OF `P z`]]
       
  1316       by (auto simp add: eventually_within_less dist_real_def intro!:  exI[of _ "a - g z"])
       
  1317     with Q show "eventually (\<lambda>x. z \<le> f x) (at_left a)"
       
  1318       by eventually_elim (metis bij `P z` mono)
       
  1319   qed
       
  1320 qed
  1226 
  1321 
  1227 lemma filterlim_at_infinity:
  1322 lemma filterlim_at_infinity:
  1228   fixes f :: "_ \<Rightarrow> 'a\<Colon>real_normed_vector"
  1323   fixes f :: "_ \<Rightarrow> 'a\<Colon>real_normed_vector"
  1229   assumes "0 \<le> c"
  1324   assumes "0 \<le> c"
  1230   shows "(LIM x F. f x :> at_infinity) \<longleftrightarrow> (\<forall>r>c. eventually (\<lambda>x. r \<le> norm (f x)) F)"
  1325   shows "(LIM x F. f x :> at_infinity) \<longleftrightarrow> (\<forall>r>c. eventually (\<lambda>x. r \<le> norm (f x)) F)"
  1255   unfolding filterlim_at_top_gt[where c=0] eventually_within
  1350   unfolding filterlim_at_top_gt[where c=0] eventually_within
  1256 proof safe
  1351 proof safe
  1257   fix Z :: real assume [arith]: "0 < Z"
  1352   fix Z :: real assume [arith]: "0 < Z"
  1258   then have "eventually (\<lambda>x. x < inverse Z) (nhds 0)"
  1353   then have "eventually (\<lambda>x. x < inverse Z) (nhds 0)"
  1259     by (auto simp add: eventually_nhds_metric dist_real_def intro!: exI[of _ "\<bar>inverse Z\<bar>"])
  1354     by (auto simp add: eventually_nhds_metric dist_real_def intro!: exI[of _ "\<bar>inverse Z\<bar>"])
  1260   then show "eventually (\<lambda>x. x \<in> {0<..} \<longrightarrow> Z < inverse x) (nhds 0)"
  1355   then show "eventually (\<lambda>x. x \<in> {0<..} \<longrightarrow> Z \<le> inverse x) (nhds 0)"
  1261     by (auto elim!: eventually_elim1 simp: inverse_eq_divide field_simps)
  1356     by (auto elim!: eventually_elim1 simp: inverse_eq_divide field_simps)
  1262 qed
  1357 qed
  1263 
  1358 
  1264 lemma filterlim_inverse_at_top:
  1359 lemma filterlim_inverse_at_top:
  1265   "(f ---> (0 :: real)) F \<Longrightarrow> eventually (\<lambda>x. 0 < f x) F \<Longrightarrow> LIM x F. inverse (f x) :> at_top"
  1360   "(f ---> (0 :: real)) F \<Longrightarrow> eventually (\<lambda>x. 0 < f x) F \<Longrightarrow> LIM x F. inverse (f x) :> at_top"
  1271   unfolding filterlim_at_bot_lt[where c=0] eventually_within
  1366   unfolding filterlim_at_bot_lt[where c=0] eventually_within
  1272 proof safe
  1367 proof safe
  1273   fix Z :: real assume [arith]: "Z < 0"
  1368   fix Z :: real assume [arith]: "Z < 0"
  1274   have "eventually (\<lambda>x. inverse Z < x) (nhds 0)"
  1369   have "eventually (\<lambda>x. inverse Z < x) (nhds 0)"
  1275     by (auto simp add: eventually_nhds_metric dist_real_def intro!: exI[of _ "\<bar>inverse Z\<bar>"])
  1370     by (auto simp add: eventually_nhds_metric dist_real_def intro!: exI[of _ "\<bar>inverse Z\<bar>"])
  1276   then show "eventually (\<lambda>x. x \<in> {..< 0} \<longrightarrow> inverse x < Z) (nhds 0)"
  1371   then show "eventually (\<lambda>x. x \<in> {..< 0} \<longrightarrow> inverse x \<le> Z) (nhds 0)"
  1277     by (auto elim!: eventually_elim1 simp: inverse_eq_divide field_simps)
  1372     by (auto elim!: eventually_elim1 simp: inverse_eq_divide field_simps)
  1278 qed
  1373 qed
  1279 
  1374 
  1280 lemma filterlim_inverse_at_bot:
  1375 lemma filterlim_inverse_at_bot:
  1281   "(f ---> (0 :: real)) F \<Longrightarrow> eventually (\<lambda>x. f x < 0) F \<Longrightarrow> LIM x F. inverse (f x) :> at_bot"
  1376   "(f ---> (0 :: real)) F \<Longrightarrow> eventually (\<lambda>x. f x < 0) F \<Longrightarrow> LIM x F. inverse (f x) :> at_bot"
  1282   by (intro filterlim_compose[OF filterlim_inverse_at_bot_neg])
  1377   by (intro filterlim_compose[OF filterlim_inverse_at_bot_neg])
  1283      (simp add: filterlim_def eventually_filtermap le_within_iff)
  1378      (simp add: filterlim_def eventually_filtermap le_within_iff)
  1284 
  1379 
       
  1380 lemma at_top_mirror: "at_top = filtermap uminus (at_bot :: real filter)"
       
  1381   unfolding filter_eq_iff eventually_filtermap eventually_at_top_linorder eventually_at_bot_linorder
       
  1382   by (metis le_minus_iff minus_minus)
       
  1383 
       
  1384 lemma at_bot_mirror: "at_bot = filtermap uminus (at_top :: real filter)"
       
  1385   unfolding at_top_mirror filtermap_filtermap by (simp add: filtermap_ident)
       
  1386 
       
  1387 lemma filterlim_at_top_mirror: "(LIM x at_top. f x :> F) \<longleftrightarrow> (LIM x at_bot. f (-x::real) :> F)"
       
  1388   unfolding filterlim_def at_top_mirror filtermap_filtermap ..
       
  1389 
       
  1390 lemma filterlim_at_bot_mirror: "(LIM x at_bot. f x :> F) \<longleftrightarrow> (LIM x at_top. f (-x::real) :> F)"
       
  1391   unfolding filterlim_def at_bot_mirror filtermap_filtermap ..
       
  1392 
  1285 lemma filterlim_uminus_at_top_at_bot: "LIM x at_bot. - x :: real :> at_top"
  1393 lemma filterlim_uminus_at_top_at_bot: "LIM x at_bot. - x :: real :> at_top"
  1286   unfolding filterlim_at_top eventually_at_bot_dense
  1394   unfolding filterlim_at_top eventually_at_bot_dense
  1287   by (blast intro: less_minus_iff[THEN iffD1])
  1395   by (metis leI minus_less_iff order_less_asym)
  1288 
       
  1289 lemma filterlim_uminus_at_top: "LIM x F. f x :> at_bot \<Longrightarrow> LIM x F. - (f x) :: real :> at_top"
       
  1290   by (rule filterlim_compose[OF filterlim_uminus_at_top_at_bot])
       
  1291 
  1396 
  1292 lemma filterlim_uminus_at_bot_at_top: "LIM x at_top. - x :: real :> at_bot"
  1397 lemma filterlim_uminus_at_bot_at_top: "LIM x at_top. - x :: real :> at_bot"
  1293   unfolding filterlim_at_bot eventually_at_top_dense
  1398   unfolding filterlim_at_bot eventually_at_top_dense
  1294   by (blast intro: minus_less_iff[THEN iffD1])
  1399   by (metis leI less_minus_iff order_less_asym)
  1295 
  1400 
  1296 lemma filterlim_uminus_at_bot: "LIM x F. f x :> at_top \<Longrightarrow> LIM x F. - (f x) :: real :> at_bot"
  1401 lemma filterlim_uminus_at_top: "(LIM x F. f x :> at_top) \<longleftrightarrow> (LIM x F. - (f x) :: real :> at_bot)"
  1297   by (rule filterlim_compose[OF filterlim_uminus_at_bot_at_top])
  1402   using filterlim_compose[OF filterlim_uminus_at_bot_at_top, of f F]
       
  1403   using filterlim_compose[OF filterlim_uminus_at_top_at_bot, of "\<lambda>x. - f x" F]
       
  1404   by auto
       
  1405 
       
  1406 lemma filterlim_uminus_at_bot: "(LIM x F. f x :> at_bot) \<longleftrightarrow> (LIM x F. - (f x) :: real :> at_top)"
       
  1407   unfolding filterlim_uminus_at_top by simp
  1298 
  1408 
  1299 lemma tendsto_inverse_0:
  1409 lemma tendsto_inverse_0:
  1300   fixes x :: "_ \<Rightarrow> 'a\<Colon>real_normed_div_algebra"
  1410   fixes x :: "_ \<Rightarrow> 'a\<Colon>real_normed_div_algebra"
  1301   shows "(inverse ---> (0::'a)) at_infinity"
  1411   shows "(inverse ---> (0::'a)) at_infinity"
  1302   unfolding tendsto_Zfun_iff diff_0_right Zfun_def eventually_at_infinity
  1412   unfolding tendsto_Zfun_iff diff_0_right Zfun_def eventually_at_infinity
  1360 proof safe
  1470 proof safe
  1361   fix Z :: real assume "0 < Z"
  1471   fix Z :: real assume "0 < Z"
  1362   from f `0 < c` have "eventually (\<lambda>x. c / 2 < f x) F"
  1472   from f `0 < c` have "eventually (\<lambda>x. c / 2 < f x) F"
  1363     by (auto dest!: tendstoD[where e="c / 2"] elim!: eventually_elim1
  1473     by (auto dest!: tendstoD[where e="c / 2"] elim!: eventually_elim1
  1364              simp: dist_real_def abs_real_def split: split_if_asm)
  1474              simp: dist_real_def abs_real_def split: split_if_asm)
  1365   moreover from g have "eventually (\<lambda>x. (Z / c * 2) < g x) F"
  1475   moreover from g have "eventually (\<lambda>x. (Z / c * 2) \<le> g x) F"
  1366     unfolding filterlim_at_top by auto
  1476     unfolding filterlim_at_top by auto
  1367   ultimately show "eventually (\<lambda>x. Z < f x * g x) F"
  1477   ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F"
  1368   proof eventually_elim
  1478   proof eventually_elim
  1369     fix x assume "c / 2 < f x" "Z / c * 2 < g x"
  1479     fix x assume "c / 2 < f x" "Z / c * 2 \<le> g x"
  1370     with `0 < Z` `0 < c` have "c / 2 * (Z / c * 2) < f x * g x"
  1480     with `0 < Z` `0 < c` have "c / 2 * (Z / c * 2) \<le> f x * g x"
  1371       by (intro mult_strict_mono) (auto simp: zero_le_divide_iff)
  1481       by (intro mult_mono) (auto simp: zero_le_divide_iff)
  1372     with `0 < c` show "Z < f x * g x"
  1482     with `0 < c` show "Z \<le> f x * g x"
  1373        by simp
  1483        by simp
  1374   qed
  1484   qed
  1375 qed
  1485 qed
  1376 
  1486 
  1377 lemma filterlim_at_top_mult_at_top: 
  1487 lemma filterlim_at_top_mult_at_top: 
  1379   assumes g: "LIM x F. g x :> at_top"
  1489   assumes g: "LIM x F. g x :> at_top"
  1380   shows "LIM x F. (f x * g x :: real) :> at_top"
  1490   shows "LIM x F. (f x * g x :: real) :> at_top"
  1381   unfolding filterlim_at_top_gt[where c=0]
  1491   unfolding filterlim_at_top_gt[where c=0]
  1382 proof safe
  1492 proof safe
  1383   fix Z :: real assume "0 < Z"
  1493   fix Z :: real assume "0 < Z"
  1384   from f have "eventually (\<lambda>x. 1 < f x) F"
  1494   from f have "eventually (\<lambda>x. 1 \<le> f x) F"
  1385     unfolding filterlim_at_top by auto
  1495     unfolding filterlim_at_top by auto
  1386   moreover from g have "eventually (\<lambda>x. Z < g x) F"
  1496   moreover from g have "eventually (\<lambda>x. Z \<le> g x) F"
  1387     unfolding filterlim_at_top by auto
  1497     unfolding filterlim_at_top by auto
  1388   ultimately show "eventually (\<lambda>x. Z < f x * g x) F"
  1498   ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F"
  1389   proof eventually_elim
  1499   proof eventually_elim
  1390     fix x assume "1 < f x" "Z < g x"
  1500     fix x assume "1 \<le> f x" "Z \<le> g x"
  1391     with `0 < Z` have "1 * Z < f x * g x"
  1501     with `0 < Z` have "1 * Z \<le> f x * g x"
  1392       by (intro mult_strict_mono) (auto simp: zero_le_divide_iff)
  1502       by (intro mult_mono) (auto simp: zero_le_divide_iff)
  1393     then show "Z < f x * g x"
  1503     then show "Z \<le> f x * g x"
  1394        by simp
  1504        by simp
  1395   qed
  1505   qed
  1396 qed
  1506 qed
  1397 
  1507 
  1398 lemma filterlim_tendsto_add_at_top: 
  1508 lemma filterlim_tendsto_add_at_top: 
  1402   unfolding filterlim_at_top_gt[where c=0]
  1512   unfolding filterlim_at_top_gt[where c=0]
  1403 proof safe
  1513 proof safe
  1404   fix Z :: real assume "0 < Z"
  1514   fix Z :: real assume "0 < Z"
  1405   from f have "eventually (\<lambda>x. c - 1 < f x) F"
  1515   from f have "eventually (\<lambda>x. c - 1 < f x) F"
  1406     by (auto dest!: tendstoD[where e=1] elim!: eventually_elim1 simp: dist_real_def)
  1516     by (auto dest!: tendstoD[where e=1] elim!: eventually_elim1 simp: dist_real_def)
  1407   moreover from g have "eventually (\<lambda>x. Z - (c - 1) < g x) F"
  1517   moreover from g have "eventually (\<lambda>x. Z - (c - 1) \<le> g x) F"
  1408     unfolding filterlim_at_top by auto
  1518     unfolding filterlim_at_top by auto
  1409   ultimately show "eventually (\<lambda>x. Z < f x + g x) F"
  1519   ultimately show "eventually (\<lambda>x. Z \<le> f x + g x) F"
  1410     by eventually_elim simp
  1520     by eventually_elim simp
  1411 qed
  1521 qed
  1412 
  1522 
  1413 lemma filterlim_at_top_add_at_top: 
  1523 lemma filterlim_at_top_add_at_top: 
  1414   assumes f: "LIM x F. f x :> at_top"
  1524   assumes f: "LIM x F. f x :> at_top"
  1415   assumes g: "LIM x F. g x :> at_top"
  1525   assumes g: "LIM x F. g x :> at_top"
  1416   shows "LIM x F. (f x + g x :: real) :> at_top"
  1526   shows "LIM x F. (f x + g x :: real) :> at_top"
  1417   unfolding filterlim_at_top_gt[where c=0]
  1527   unfolding filterlim_at_top_gt[where c=0]
  1418 proof safe
  1528 proof safe
  1419   fix Z :: real assume "0 < Z"
  1529   fix Z :: real assume "0 < Z"
  1420   from f have "eventually (\<lambda>x. 0 < f x) F"
  1530   from f have "eventually (\<lambda>x. 0 \<le> f x) F"
  1421     unfolding filterlim_at_top by auto
  1531     unfolding filterlim_at_top by auto
  1422   moreover from g have "eventually (\<lambda>x. Z < g x) F"
  1532   moreover from g have "eventually (\<lambda>x. Z \<le> g x) F"
  1423     unfolding filterlim_at_top by auto
  1533     unfolding filterlim_at_top by auto
  1424   ultimately show "eventually (\<lambda>x. Z < f x + g x) F"
  1534   ultimately show "eventually (\<lambda>x. Z \<le> f x + g x) F"
  1425     by eventually_elim simp
  1535     by eventually_elim simp
  1426 qed
  1536 qed
  1427 
  1537 
  1428 lemma tendsto_divide_0:
  1538 lemma tendsto_divide_0:
  1429   fixes f :: "_ \<Rightarrow> 'a\<Colon>{real_normed_div_algebra, division_ring_inverse_zero}"
  1539   fixes f :: "_ \<Rightarrow> 'a\<Colon>{real_normed_div_algebra, division_ring_inverse_zero}"