src/HOL/Limits.thy
 changeset 63546 5f097087fa1e parent 63301 d3c87eb0bad2 child 63548 6c2c16fef8f1
```     1.1 --- a/src/HOL/Limits.thy	Fri Jul 22 21:43:56 2016 +0200
1.2 +++ b/src/HOL/Limits.thy	Fri Jul 22 23:55:47 2016 +0200
1.3 @@ -8,13 +8,13 @@
1.4  section \<open>Limits on Real Vector Spaces\<close>
1.5
1.6  theory Limits
1.7 -imports Real_Vector_Spaces
1.8 +  imports Real_Vector_Spaces
1.9  begin
1.10
1.11  subsection \<open>Filter going to infinity norm\<close>
1.12
1.13 -definition at_infinity :: "'a::real_normed_vector filter" where
1.14 -  "at_infinity = (INF r. principal {x. r \<le> norm x})"
1.15 +definition at_infinity :: "'a::real_normed_vector filter"
1.16 +  where "at_infinity = (INF r. principal {x. r \<le> norm x})"
1.17
1.18  lemma eventually_at_infinity: "eventually P at_infinity \<longleftrightarrow> (\<exists>b. \<forall>x. b \<le> norm x \<longrightarrow> P x)"
1.19    unfolding at_infinity_def
1.20 @@ -22,21 +22,24 @@
1.21       (auto simp: subset_eq eventually_principal intro!: exI[of _ "max a b" for a b])
1.22
1.23  corollary eventually_at_infinity_pos:
1.24 -   "eventually p at_infinity \<longleftrightarrow> (\<exists>b. 0 < b \<and> (\<forall>x. norm x \<ge> b \<longrightarrow> p x))"
1.25 -apply (simp add: eventually_at_infinity, auto)
1.26 -apply (case_tac "b \<le> 0")
1.27 -using norm_ge_zero order_trans zero_less_one apply blast
1.28 -apply (force simp:)
1.29 -done
1.30 -
1.31 -lemma at_infinity_eq_at_top_bot:
1.32 -  "(at_infinity :: real filter) = sup at_top at_bot"
1.33 +  "eventually p at_infinity \<longleftrightarrow> (\<exists>b. 0 < b \<and> (\<forall>x. norm x \<ge> b \<longrightarrow> p x))"
1.34 +  apply (simp add: eventually_at_infinity)
1.35 +  apply auto
1.36 +  apply (case_tac "b \<le> 0")
1.37 +  using norm_ge_zero order_trans zero_less_one apply blast
1.38 +  apply force
1.39 +  done
1.40 +
1.41 +lemma at_infinity_eq_at_top_bot: "(at_infinity :: real filter) = sup at_top at_bot"
1.42    apply (simp add: filter_eq_iff eventually_sup eventually_at_infinity
1.43 -                   eventually_at_top_linorder eventually_at_bot_linorder)
1.44 +      eventually_at_top_linorder eventually_at_bot_linorder)
1.45    apply safe
1.46 -  apply (rule_tac x="b" in exI, simp)
1.47 -  apply (rule_tac x="- b" in exI, simp)
1.48 -  apply (rule_tac x="max (- Na) N" in exI, auto simp: abs_real_def)
1.49 +    apply (rule_tac x="b" in exI)
1.50 +    apply simp
1.51 +   apply (rule_tac x="- b" in exI)
1.52 +   apply simp
1.53 +  apply (rule_tac x="max (- Na) N" in exI)
1.54 +  apply (auto simp: abs_real_def)
1.55    done
1.56
1.57  lemma at_top_le_at_infinity: "at_top \<le> (at_infinity :: real filter)"
1.58 @@ -45,23 +48,21 @@
1.59  lemma at_bot_le_at_infinity: "at_bot \<le> (at_infinity :: real filter)"
1.60    unfolding at_infinity_eq_at_top_bot by simp
1.61
1.62 -lemma filterlim_at_top_imp_at_infinity:
1.63 -  fixes f :: "_ \<Rightarrow> real"
1.64 -  shows "filterlim f at_top F \<Longrightarrow> filterlim f at_infinity F"
1.65 +lemma filterlim_at_top_imp_at_infinity: "filterlim f at_top F \<Longrightarrow> filterlim f at_infinity F"
1.66 +  for f :: "_ \<Rightarrow> real"
1.67    by (rule filterlim_mono[OF _ at_top_le_at_infinity order_refl])
1.68
1.69 -lemma lim_infinity_imp_sequentially:
1.70 -  "(f \<longlongrightarrow> l) at_infinity \<Longrightarrow> ((\<lambda>n. f(n)) \<longlongrightarrow> l) sequentially"
1.71 -by (simp add: filterlim_at_top_imp_at_infinity filterlim_compose filterlim_real_sequentially)
1.72 +lemma lim_infinity_imp_sequentially: "(f \<longlongrightarrow> l) at_infinity \<Longrightarrow> ((\<lambda>n. f(n)) \<longlongrightarrow> l) sequentially"
1.73 +  by (simp add: filterlim_at_top_imp_at_infinity filterlim_compose filterlim_real_sequentially)
1.74
1.75
1.76  subsubsection \<open>Boundedness\<close>
1.77
1.78 -definition Bfun :: "('a \<Rightarrow> 'b::metric_space) \<Rightarrow> 'a filter \<Rightarrow> bool" where
1.79 -  Bfun_metric_def: "Bfun f F = (\<exists>y. \<exists>K>0. eventually (\<lambda>x. dist (f x) y \<le> K) F)"
1.80 -
1.81 -abbreviation Bseq :: "(nat \<Rightarrow> 'a::metric_space) \<Rightarrow> bool" where
1.82 -  "Bseq X \<equiv> Bfun X sequentially"
1.83 +definition Bfun :: "('a \<Rightarrow> 'b::metric_space) \<Rightarrow> 'a filter \<Rightarrow> bool"
1.84 +  where Bfun_metric_def: "Bfun f F = (\<exists>y. \<exists>K>0. eventually (\<lambda>x. dist (f x) y \<le> K) F)"
1.85 +
1.86 +abbreviation Bseq :: "(nat \<Rightarrow> 'a::metric_space) \<Rightarrow> bool"
1.87 +  where "Bseq X \<equiv> Bfun X sequentially"
1.88
1.89  lemma Bseq_conv_Bfun: "Bseq X \<longleftrightarrow> Bfun X sequentially" ..
1.90
1.91 @@ -71,11 +72,11 @@
1.92  lemma Bseq_offset: "Bseq (\<lambda>n. X (n + k)) \<Longrightarrow> Bseq X"
1.93    unfolding Bfun_metric_def by (subst (asm) eventually_sequentially_seg)
1.94
1.95 -lemma Bfun_def:
1.96 -  "Bfun f F \<longleftrightarrow> (\<exists>K>0. eventually (\<lambda>x. norm (f x) \<le> K) F)"
1.97 +lemma Bfun_def: "Bfun f F \<longleftrightarrow> (\<exists>K>0. eventually (\<lambda>x. norm (f x) \<le> K) F)"
1.98    unfolding Bfun_metric_def norm_conv_dist
1.99  proof safe
1.100 -  fix y K assume K: "0 < K" and *: "eventually (\<lambda>x. dist (f x) y \<le> K) F"
1.101 +  fix y K
1.102 +  assume K: "0 < K" and *: "eventually (\<lambda>x. dist (f x) y \<le> K) F"
1.103    moreover have "eventually (\<lambda>x. dist (f x) 0 \<le> dist (f x) y + dist 0 y) F"
1.104      by (intro always_eventually) (metis dist_commute dist_triangle)
1.105    with * have "eventually (\<lambda>x. dist (f x) 0 \<le> K + dist 0 y) F"
1.106 @@ -85,19 +86,19 @@
1.107  qed (force simp del: norm_conv_dist [symmetric])
1.108
1.109  lemma BfunI:
1.110 -  assumes K: "eventually (\<lambda>x. norm (f x) \<le> K) F" shows "Bfun f F"
1.111 -unfolding Bfun_def
1.112 +  assumes K: "eventually (\<lambda>x. norm (f x) \<le> K) F"
1.113 +  shows "Bfun f F"
1.114 +  unfolding Bfun_def
1.115  proof (intro exI conjI allI)
1.116    show "0 < max K 1" by simp
1.117 -next
1.118    show "eventually (\<lambda>x. norm (f x) \<le> max K 1) F"
1.119 -    using K by (rule eventually_mono, simp)
1.120 +    using K by (rule eventually_mono) simp
1.121  qed
1.122
1.123  lemma BfunE:
1.124    assumes "Bfun f F"
1.125    obtains B where "0 < B" and "eventually (\<lambda>x. norm (f x) \<le> B) F"
1.126 -using assms unfolding Bfun_def by blast
1.127 +  using assms unfolding Bfun_def by blast
1.128
1.129  lemma Cauchy_Bseq: "Cauchy X \<Longrightarrow> Bseq X"
1.130    unfolding Cauchy_def Bfun_metric_def eventually_sequentially
1.131 @@ -124,57 +125,66 @@
1.132  lemma Bseq_def: "Bseq X \<longleftrightarrow> (\<exists>K>0. \<forall>n. norm (X n) \<le> K)"
1.133    unfolding Bfun_def eventually_sequentially
1.134  proof safe
1.135 -  fix N K assume "0 < K" "\<forall>n\<ge>N. norm (X n) \<le> K"
1.136 +  fix N K
1.137 +  assume "0 < K" "\<forall>n\<ge>N. norm (X n) \<le> K"
1.138    then show "\<exists>K>0. \<forall>n. norm (X n) \<le> K"
1.139      by (intro exI[of _ "max (Max (norm ` X ` {..N})) K"] max.strict_coboundedI2)
1.140         (auto intro!: imageI not_less[where 'a=nat, THEN iffD1] Max_ge simp: le_max_iff_disj)
1.141  qed auto
1.142
1.143 -lemma BseqE: "\<lbrakk>Bseq X; \<And>K. \<lbrakk>0 < K; \<forall>n. norm (X n) \<le> K\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
1.144 -unfolding Bseq_def by auto
1.145 -
1.146 -lemma BseqD: "Bseq X ==> \<exists>K. 0 < K & (\<forall>n. norm (X n) \<le> K)"
1.148 -
1.149 -lemma BseqI: "[| 0 < K; \<forall>n. norm (X n) \<le> K |] ==> Bseq X"
1.150 -by (auto simp add: Bseq_def)
1.151 -
1.152 -lemma Bseq_bdd_above: "Bseq (X::nat \<Rightarrow> real) \<Longrightarrow> bdd_above (range X)"
1.153 +lemma BseqE: "Bseq X \<Longrightarrow> (\<And>K. 0 < K \<Longrightarrow> \<forall>n. norm (X n) \<le> K \<Longrightarrow> Q) \<Longrightarrow> Q"
1.154 +  unfolding Bseq_def by auto
1.155 +
1.156 +lemma BseqD: "Bseq X \<Longrightarrow> \<exists>K. 0 < K \<and> (\<forall>n. norm (X n) \<le> K)"
1.157 +  by (simp add: Bseq_def)
1.158 +
1.159 +lemma BseqI: "0 < K \<Longrightarrow> \<forall>n. norm (X n) \<le> K \<Longrightarrow> Bseq X"
1.160 +  by (auto simp add: Bseq_def)
1.161 +
1.162 +lemma Bseq_bdd_above: "Bseq X \<Longrightarrow> bdd_above (range X)"
1.163 +  for X :: "nat \<Rightarrow> real"
1.164  proof (elim BseqE, intro bdd_aboveI2)
1.165 -  fix K n assume "0 < K" "\<forall>n. norm (X n) \<le> K" then show "X n \<le> K"
1.166 +  fix K n
1.167 +  assume "0 < K" "\<forall>n. norm (X n) \<le> K"
1.168 +  then show "X n \<le> K"
1.169      by (auto elim!: allE[of _ n])
1.170  qed
1.171
1.172 -lemma Bseq_bdd_above':
1.173 -  "Bseq (X::nat \<Rightarrow> 'a :: real_normed_vector) \<Longrightarrow> bdd_above (range (\<lambda>n. norm (X n)))"
1.174 +lemma Bseq_bdd_above': "Bseq X \<Longrightarrow> bdd_above (range (\<lambda>n. norm (X n)))"
1.175 +  for X :: "nat \<Rightarrow> 'a :: real_normed_vector"
1.176  proof (elim BseqE, intro bdd_aboveI2)
1.177 -  fix K n assume "0 < K" "\<forall>n. norm (X n) \<le> K" then show "norm (X n) \<le> K"
1.178 +  fix K n
1.179 +  assume "0 < K" "\<forall>n. norm (X n) \<le> K"
1.180 +  then show "norm (X n) \<le> K"
1.181      by (auto elim!: allE[of _ n])
1.182  qed
1.183
1.184 -lemma Bseq_bdd_below: "Bseq (X::nat \<Rightarrow> real) \<Longrightarrow> bdd_below (range X)"
1.185 +lemma Bseq_bdd_below: "Bseq X \<Longrightarrow> bdd_below (range X)"
1.186 +  for X :: "nat \<Rightarrow> real"
1.187  proof (elim BseqE, intro bdd_belowI2)
1.188 -  fix K n assume "0 < K" "\<forall>n. norm (X n) \<le> K" then show "- K \<le> X n"
1.189 +  fix K n
1.190 +  assume "0 < K" "\<forall>n. norm (X n) \<le> K"
1.191 +  then show "- K \<le> X n"
1.192      by (auto elim!: allE[of _ n])
1.193  qed
1.194
1.195  lemma Bseq_eventually_mono:
1.196    assumes "eventually (\<lambda>n. norm (f n) \<le> norm (g n)) sequentially" "Bseq g"
1.197 -  shows   "Bseq f"
1.198 +  shows "Bseq f"
1.199  proof -
1.200    from assms(1) obtain N where N: "\<And>n. n \<ge> N \<Longrightarrow> norm (f n) \<le> norm (g n)"
1.201      by (auto simp: eventually_at_top_linorder)
1.202 -  moreover from assms(2) obtain K where K: "\<And>n. norm (g n) \<le> K" by (blast elim!: BseqE)
1.203 +  moreover from assms(2) obtain K where K: "\<And>n. norm (g n) \<le> K"
1.204 +    by (blast elim!: BseqE)
1.205    ultimately have "norm (f n) \<le> max K (Max {norm (f n) |n. n < N})" for n
1.206      apply (cases "n < N")
1.207 -    apply (rule max.coboundedI2, rule Max.coboundedI, auto) []
1.208 -    apply (rule max.coboundedI1, force intro: order.trans[OF N K])
1.209 +    subgoal by (rule max.coboundedI2, rule Max.coboundedI) auto
1.210 +    subgoal by (rule max.coboundedI1) (force intro: order.trans[OF N K])
1.211      done
1.212 -  thus ?thesis by (blast intro: BseqI')
1.213 +  then show ?thesis by (blast intro: BseqI')
1.214  qed
1.215
1.216 -lemma lemma_NBseq_def:
1.217 -  "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) = (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
1.218 +lemma lemma_NBseq_def: "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) \<longleftrightarrow> (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
1.219  proof safe
1.220    fix K :: real
1.221    from reals_Archimedean2 obtain n :: nat where "K < real n" ..
1.222 @@ -188,47 +198,50 @@
1.223      using of_nat_0_less_iff by blast
1.224  qed
1.225
1.226 -text\<open>alternative definition for Bseq\<close>
1.227 -lemma Bseq_iff: "Bseq X = (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
1.229 -apply (simp (no_asm) add: lemma_NBseq_def)
1.230 -done
1.231 -
1.232 -lemma lemma_NBseq_def2:
1.233 -     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
1.234 -apply (subst lemma_NBseq_def, auto)
1.235 -apply (rule_tac x = "Suc N" in exI)
1.236 -apply (rule_tac [2] x = N in exI)
1.237 -apply (auto simp add: of_nat_Suc)
1.238 - prefer 2 apply (blast intro: order_less_imp_le)
1.239 -apply (drule_tac x = n in spec, simp)
1.240 -done
1.241 -
1.242 -(* yet another definition for Bseq *)
1.243 -lemma Bseq_iff1a: "Bseq X = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
1.244 -by (simp add: Bseq_def lemma_NBseq_def2)
1.245 -
1.246 -subsubsection\<open>A Few More Equivalence Theorems for Boundedness\<close>
1.247 -
1.248 -text\<open>alternative formulation for boundedness\<close>
1.249 -lemma Bseq_iff2: "Bseq X = (\<exists>k > 0. \<exists>x. \<forall>n. norm (X(n) + -x) \<le> k)"
1.250 -apply (unfold Bseq_def, safe)
1.251 -apply (rule_tac [2] x = "k + norm x" in exI)
1.252 -apply (rule_tac x = K in exI, simp)
1.253 -apply (rule exI [where x = 0], auto)
1.254 -apply (erule order_less_le_trans, simp)
1.255 -apply (drule_tac x=n in spec)
1.256 -apply (drule order_trans [OF norm_triangle_ineq2])
1.257 -apply simp
1.258 -done
1.259 -
1.260 -text\<open>alternative formulation for boundedness\<close>
1.261 -lemma Bseq_iff3:
1.262 -  "Bseq X \<longleftrightarrow> (\<exists>k>0. \<exists>N. \<forall>n. norm (X n + - X N) \<le> k)" (is "?P \<longleftrightarrow> ?Q")
1.263 +text \<open>Alternative definition for \<open>Bseq\<close>.\<close>
1.264 +lemma Bseq_iff: "Bseq X \<longleftrightarrow> (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
1.266 +
1.267 +lemma lemma_NBseq_def2: "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
1.268 +  apply (subst lemma_NBseq_def)
1.269 +  apply auto
1.270 +   apply (rule_tac x = "Suc N" in exI)
1.271 +   apply (rule_tac [2] x = N in exI)
1.272 +   apply auto
1.273 +   prefer 2 apply (blast intro: order_less_imp_le)
1.274 +  apply (drule_tac x = n in spec)
1.275 +  apply simp
1.276 +  done
1.277 +
1.278 +text \<open>Yet another definition for Bseq.\<close>
1.279 +lemma Bseq_iff1a: "Bseq X \<longleftrightarrow> (\<exists>N. \<forall>n. norm (X n) < real (Suc N))"
1.280 +  by (simp add: Bseq_def lemma_NBseq_def2)
1.281 +
1.282 +subsubsection \<open>A Few More Equivalence Theorems for Boundedness\<close>
1.283 +
1.284 +text \<open>Alternative formulation for boundedness.\<close>
1.285 +lemma Bseq_iff2: "Bseq X \<longleftrightarrow> (\<exists>k > 0. \<exists>x. \<forall>n. norm (X n + - x) \<le> k)"
1.286 +  apply (unfold Bseq_def)
1.287 +  apply safe
1.288 +   apply (rule_tac [2] x = "k + norm x" in exI)
1.289 +   apply (rule_tac x = K in exI)
1.290 +   apply simp
1.291 +   apply (rule exI [where x = 0])
1.292 +   apply auto
1.293 +   apply (erule order_less_le_trans)
1.294 +   apply simp
1.295 +  apply (drule_tac x=n in spec)
1.296 +  apply (drule order_trans [OF norm_triangle_ineq2])
1.297 +  apply simp
1.298 +  done
1.299 +
1.300 +text \<open>Alternative formulation for boundedness.\<close>
1.301 +lemma Bseq_iff3: "Bseq X \<longleftrightarrow> (\<exists>k>0. \<exists>N. \<forall>n. norm (X n + - X N) \<le> k)"
1.302 +  (is "?P \<longleftrightarrow> ?Q")
1.303  proof
1.304    assume ?P
1.305 -  then obtain K
1.306 -    where *: "0 < K" and **: "\<And>n. norm (X n) \<le> K" by (auto simp add: Bseq_def)
1.307 +  then obtain K where *: "0 < K" and **: "\<And>n. norm (X n) \<le> K"
1.308 +    by (auto simp add: Bseq_def)
1.309    from * have "0 < K + norm (X 0)" by (rule order_less_le_trans) simp
1.310    from ** have "\<forall>n. norm (X n - X 0) \<le> K + norm (X 0)"
1.311      by (auto intro: order_trans norm_triangle_ineq4)
1.312 @@ -236,129 +249,150 @@
1.313      by simp
1.314    with \<open>0 < K + norm (X 0)\<close> show ?Q by blast
1.315  next
1.316 -  assume ?Q then show ?P by (auto simp add: Bseq_iff2)
1.317 +  assume ?Q
1.318 +  then show ?P by (auto simp add: Bseq_iff2)
1.319  qed
1.320
1.321 -lemma BseqI2: "(\<forall>n. k \<le> f n & f n \<le> (K::real)) ==> Bseq f"
1.323 -apply (rule_tac x = " (\<bar>k\<bar> + \<bar>K\<bar>) + 1" in exI, auto)
1.324 -apply (drule_tac x = n in spec, arith)
1.325 -done
1.326 -
1.327 -
1.328 -subsubsection\<open>Upper Bounds and Lubs of Bounded Sequences\<close>
1.329 -
1.330 -lemma Bseq_minus_iff: "Bseq (%n. -(X n) :: 'a :: real_normed_vector) = Bseq X"
1.331 +lemma BseqI2: "\<forall>n. k \<le> f n \<and> f n \<le> K \<Longrightarrow> Bseq f"
1.332 +  for k K :: real
1.333 +  apply (simp add: Bseq_def)
1.334 +  apply (rule_tac x = "(\<bar>k\<bar> + \<bar>K\<bar>) + 1" in exI)
1.335 +  apply auto
1.336 +  apply (drule_tac x = n in spec)
1.337 +  apply arith
1.338 +  done
1.339 +
1.340 +
1.341 +subsubsection \<open>Upper Bounds and Lubs of Bounded Sequences\<close>
1.342 +
1.343 +lemma Bseq_minus_iff: "Bseq (\<lambda>n. - (X n) :: 'a::real_normed_vector) \<longleftrightarrow> Bseq X"
1.345
1.347 -  assumes "Bseq (f :: nat \<Rightarrow> 'a :: real_normed_vector)"
1.348 -  shows   "Bseq (\<lambda>x. f x + c)"
1.349 +  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.350 +  assumes "Bseq f"
1.351 +  shows "Bseq (\<lambda>x. f x + c)"
1.352  proof -
1.353 -  from assms obtain K where K: "\<And>x. norm (f x) \<le> K" unfolding Bseq_def by blast
1.354 +  from assms obtain K where K: "\<And>x. norm (f x) \<le> K"
1.355 +    unfolding Bseq_def by blast
1.356    {
1.357      fix x :: nat
1.358      have "norm (f x + c) \<le> norm (f x) + norm c" by (rule norm_triangle_ineq)
1.359      also have "norm (f x) \<le> K" by (rule K)
1.360      finally have "norm (f x + c) \<le> K + norm c" by simp
1.361    }
1.362 -  thus ?thesis by (rule BseqI')
1.363 +  then show ?thesis by (rule BseqI')
1.364  qed
1.365
1.366 -lemma Bseq_add_iff: "Bseq (\<lambda>x. f x + c) \<longleftrightarrow> Bseq (f :: nat \<Rightarrow> 'a :: real_normed_vector)"
1.367 +lemma Bseq_add_iff: "Bseq (\<lambda>x. f x + c) \<longleftrightarrow> Bseq f"
1.368 +  for f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.369    using Bseq_add[of f c] Bseq_add[of "\<lambda>x. f x + c" "-c"] by auto
1.370
1.371  lemma Bseq_mult:
1.372 -  assumes "Bseq (f :: nat \<Rightarrow> 'a :: real_normed_field)"
1.373 -  assumes "Bseq (g :: nat \<Rightarrow> 'a :: real_normed_field)"
1.374 -  shows   "Bseq (\<lambda>x. f x * g x)"
1.375 +  fixes f g :: "nat \<Rightarrow> 'a::real_normed_field"
1.376 +  assumes "Bseq f" and "Bseq g"
1.377 +  shows "Bseq (\<lambda>x. f x * g x)"
1.378  proof -
1.379 -  from assms obtain K1 K2 where K: "\<And>x. norm (f x) \<le> K1" "K1 > 0" "\<And>x. norm (g x) \<le> K2" "K2 > 0"
1.380 +  from assms obtain K1 K2 where K: "norm (f x) \<le> K1" "K1 > 0" "norm (g x) \<le> K2" "K2 > 0"
1.381 +    for x
1.382      unfolding Bseq_def by blast
1.383 -  hence "\<And>x. norm (f x * g x) \<le> K1 * K2" by (auto simp: norm_mult intro!: mult_mono)
1.384 -  thus ?thesis by (rule BseqI')
1.385 +  then have "norm (f x * g x) \<le> K1 * K2" for x
1.386 +    by (auto simp: norm_mult intro!: mult_mono)
1.387 +  then show ?thesis by (rule BseqI')
1.388  qed
1.389
1.390  lemma Bfun_const [simp]: "Bfun (\<lambda>_. c) F"
1.391    unfolding Bfun_metric_def by (auto intro!: exI[of _ c] exI[of _ "1::real"])
1.392
1.393 -lemma Bseq_cmult_iff: "(c :: 'a :: real_normed_field) \<noteq> 0 \<Longrightarrow> Bseq (\<lambda>x. c * f x) \<longleftrightarrow> Bseq f"
1.394 +lemma Bseq_cmult_iff:
1.395 +  fixes c :: "'a::real_normed_field"
1.396 +  assumes "c \<noteq> 0"
1.397 +  shows "Bseq (\<lambda>x. c * f x) \<longleftrightarrow> Bseq f"
1.398  proof
1.399 -  assume "c \<noteq> 0" "Bseq (\<lambda>x. c * f x)"
1.400 -  find_theorems "Bfun (\<lambda>_. ?c) _"
1.401 -  from Bfun_const this(2) have "Bseq (\<lambda>x. inverse c * (c * f x))" by (rule Bseq_mult)
1.402 -  with \<open>c \<noteq> 0\<close> show "Bseq f" by (simp add: divide_simps)
1.403 +  assume "Bseq (\<lambda>x. c * f x)"
1.404 +  with Bfun_const have "Bseq (\<lambda>x. inverse c * (c * f x))"
1.405 +    by (rule Bseq_mult)
1.406 +  with \<open>c \<noteq> 0\<close> show "Bseq f"
1.407 +    by (simp add: divide_simps)
1.408  qed (intro Bseq_mult Bfun_const)
1.409
1.410 -lemma Bseq_subseq: "Bseq (f :: nat \<Rightarrow> 'a :: real_normed_vector) \<Longrightarrow> Bseq (\<lambda>x. f (g x))"
1.411 +lemma Bseq_subseq: "Bseq f \<Longrightarrow> Bseq (\<lambda>x. f (g x))"
1.412 +  for f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.413    unfolding Bseq_def by auto
1.414
1.415 -lemma Bseq_Suc_iff: "Bseq (\<lambda>n. f (Suc n)) \<longleftrightarrow> Bseq (f :: nat \<Rightarrow> 'a :: real_normed_vector)"
1.416 +lemma Bseq_Suc_iff: "Bseq (\<lambda>n. f (Suc n)) \<longleftrightarrow> Bseq f"
1.417 +  for f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.418    using Bseq_offset[of f 1] by (auto intro: Bseq_subseq)
1.419
1.420  lemma increasing_Bseq_subseq_iff:
1.421 -  assumes "\<And>x y. x \<le> y \<Longrightarrow> norm (f x :: 'a :: real_normed_vector) \<le> norm (f y)" "subseq g"
1.422 -  shows   "Bseq (\<lambda>x. f (g x)) \<longleftrightarrow> Bseq f"
1.423 +  assumes "\<And>x y. x \<le> y \<Longrightarrow> norm (f x :: 'a::real_normed_vector) \<le> norm (f y)" "subseq g"
1.424 +  shows "Bseq (\<lambda>x. f (g x)) \<longleftrightarrow> Bseq f"
1.425  proof
1.426    assume "Bseq (\<lambda>x. f (g x))"
1.427 -  then obtain K where K: "\<And>x. norm (f (g x)) \<le> K" unfolding Bseq_def by auto
1.428 +  then obtain K where K: "\<And>x. norm (f (g x)) \<le> K"
1.429 +    unfolding Bseq_def by auto
1.430    {
1.431      fix x :: nat
1.432      from filterlim_subseq[OF assms(2)] obtain y where "g y \<ge> x"
1.433        by (auto simp: filterlim_at_top eventually_at_top_linorder)
1.434 -    hence "norm (f x) \<le> norm (f (g y))" using assms(1) by blast
1.435 +    then have "norm (f x) \<le> norm (f (g y))"
1.436 +      using assms(1) by blast
1.437      also have "norm (f (g y)) \<le> K" by (rule K)
1.438      finally have "norm (f x) \<le> K" .
1.439    }
1.440 -  thus "Bseq f" by (rule BseqI')
1.441 -qed (insert Bseq_subseq[of f g], simp_all)
1.442 +  then show "Bseq f" by (rule BseqI')
1.443 +qed (use Bseq_subseq[of f g] in simp_all)
1.444
1.445  lemma nonneg_incseq_Bseq_subseq_iff:
1.446 -  assumes "\<And>x. f x \<ge> 0" "incseq (f :: nat \<Rightarrow> real)" "subseq g"
1.447 -  shows   "Bseq (\<lambda>x. f (g x)) \<longleftrightarrow> Bseq f"
1.448 +  fixes f :: "nat \<Rightarrow> real"
1.449 +    and g :: "nat \<Rightarrow> nat"
1.450 +  assumes "\<And>x. f x \<ge> 0" "incseq f" "subseq g"
1.451 +  shows "Bseq (\<lambda>x. f (g x)) \<longleftrightarrow> Bseq f"
1.452    using assms by (intro increasing_Bseq_subseq_iff) (auto simp: incseq_def)
1.453
1.454 -lemma Bseq_eq_bounded: "range f \<subseteq> {a .. b::real} \<Longrightarrow> Bseq f"
1.455 +lemma Bseq_eq_bounded: "range f \<subseteq> {a..b} \<Longrightarrow> Bseq f"
1.456 +  for a b :: real
1.458    apply (rule BseqI'[where K="max (norm a) (norm b)"])
1.459    apply (erule_tac x=n in allE)
1.460    apply auto
1.461    done
1.462
1.463 -lemma incseq_bounded: "incseq X \<Longrightarrow> \<forall>i. X i \<le> (B::real) \<Longrightarrow> Bseq X"
1.464 +lemma incseq_bounded: "incseq X \<Longrightarrow> \<forall>i. X i \<le> B \<Longrightarrow> Bseq X"
1.465 +  for B :: real
1.466    by (intro Bseq_eq_bounded[of X "X 0" B]) (auto simp: incseq_def)
1.467
1.468 -lemma decseq_bounded: "decseq X \<Longrightarrow> \<forall>i. (B::real) \<le> X i \<Longrightarrow> Bseq X"
1.469 +lemma decseq_bounded: "decseq X \<Longrightarrow> \<forall>i. B \<le> X i \<Longrightarrow> Bseq X"
1.470 +  for B :: real
1.471    by (intro Bseq_eq_bounded[of X B "X 0"]) (auto simp: decseq_def)
1.472
1.473 +
1.474  subsection \<open>Bounded Monotonic Sequences\<close>
1.475
1.476 -subsubsection\<open>A Bounded and Monotonic Sequence Converges\<close>
1.477 +subsubsection \<open>A Bounded and Monotonic Sequence Converges\<close>
1.478
1.479  (* TODO: delete *)
1.480  (* FIXME: one use in NSA/HSEQ.thy *)
1.481 -lemma Bmonoseq_LIMSEQ: "\<forall>n. m \<le> n --> X n = X m ==> \<exists>L. (X \<longlonglongrightarrow> L)"
1.482 +lemma Bmonoseq_LIMSEQ: "\<forall>n. m \<le> n \<longrightarrow> X n = X m \<Longrightarrow> \<exists>L. X \<longlonglongrightarrow> L"
1.483    apply (rule_tac x="X m" in exI)
1.484    apply (rule filterlim_cong[THEN iffD2, OF refl refl _ tendsto_const])
1.485    unfolding eventually_sequentially
1.486    apply blast
1.487    done
1.488
1.489 +
1.490  subsection \<open>Convergence to Zero\<close>
1.491
1.492  definition Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool"
1.493    where "Zfun f F = (\<forall>r>0. eventually (\<lambda>x. norm (f x) < r) F)"
1.494
1.495 -lemma ZfunI:
1.496 -  "(\<And>r. 0 < r \<Longrightarrow> eventually (\<lambda>x. norm (f x) < r) F) \<Longrightarrow> Zfun f F"
1.497 -  unfolding Zfun_def by simp
1.498 -
1.499 -lemma ZfunD:
1.500 -  "\<lbrakk>Zfun f F; 0 < r\<rbrakk> \<Longrightarrow> eventually (\<lambda>x. norm (f x) < r) F"
1.501 -  unfolding Zfun_def by simp
1.502 -
1.503 -lemma Zfun_ssubst:
1.504 -  "eventually (\<lambda>x. f x = g x) F \<Longrightarrow> Zfun g F \<Longrightarrow> Zfun f F"
1.505 +lemma ZfunI: "(\<And>r. 0 < r \<Longrightarrow> eventually (\<lambda>x. norm (f x) < r) F) \<Longrightarrow> Zfun f F"
1.506 +  by (simp add: Zfun_def)
1.507 +
1.508 +lemma ZfunD: "Zfun f F \<Longrightarrow> 0 < r \<Longrightarrow> eventually (\<lambda>x. norm (f x) < r) F"
1.509 +  by (simp add: Zfun_def)
1.510 +
1.511 +lemma Zfun_ssubst: "eventually (\<lambda>x. f x = g x) F \<Longrightarrow> Zfun g F \<Longrightarrow> Zfun f F"
1.512    unfolding Zfun_def by (auto elim!: eventually_rev_mp)
1.513
1.514  lemma Zfun_zero: "Zfun (\<lambda>x. 0) F"
1.515 @@ -369,28 +403,29 @@
1.516
1.517  lemma Zfun_imp_Zfun:
1.518    assumes f: "Zfun f F"
1.519 -  assumes g: "eventually (\<lambda>x. norm (g x) \<le> norm (f x) * K) F"
1.520 +    and g: "eventually (\<lambda>x. norm (g x) \<le> norm (f x) * K) F"
1.521    shows "Zfun (\<lambda>x. g x) F"
1.522 -proof (cases)
1.523 -  assume K: "0 < K"
1.524 +proof (cases "0 < K")
1.525 +  case K: True
1.526    show ?thesis
1.527    proof (rule ZfunI)
1.528 -    fix r::real assume "0 < r"
1.529 -    hence "0 < r / K" using K by simp
1.530 +    fix r :: real
1.531 +    assume "0 < r"
1.532 +    then have "0 < r / K" using K by simp
1.533      then have "eventually (\<lambda>x. norm (f x) < r / K) F"
1.534        using ZfunD [OF f] by blast
1.535      with g show "eventually (\<lambda>x. norm (g x) < r) F"
1.536      proof eventually_elim
1.537        case (elim x)
1.538 -      hence "norm (f x) * K < r"
1.539 +      then have "norm (f x) * K < r"
1.540          by (simp add: pos_less_divide_eq K)
1.541 -      thus ?case
1.542 +      then show ?case
1.543          by (simp add: order_le_less_trans [OF elim(1)])
1.544      qed
1.545    qed
1.546  next
1.547 -  assume "\<not> 0 < K"
1.548 -  hence K: "K \<le> 0" by (simp only: not_less)
1.549 +  case False
1.550 +  then have K: "K \<le> 0" by (simp only: not_less)
1.551    show ?thesis
1.552    proof (rule ZfunI)
1.553      fix r :: real
1.554 @@ -406,15 +441,17 @@
1.555    qed
1.556  qed
1.557
1.558 -lemma Zfun_le: "\<lbrakk>Zfun g F; \<forall>x. norm (f x) \<le> norm (g x)\<rbrakk> \<Longrightarrow> Zfun f F"
1.559 -  by (erule_tac K="1" in Zfun_imp_Zfun, simp)
1.560 +lemma Zfun_le: "Zfun g F \<Longrightarrow> \<forall>x. norm (f x) \<le> norm (g x) \<Longrightarrow> Zfun f F"
1.561 +  by (erule Zfun_imp_Zfun [where K = 1]) simp
1.562
1.564 -  assumes f: "Zfun f F" and g: "Zfun g F"
1.565 +  assumes f: "Zfun f F"
1.566 +    and g: "Zfun g F"
1.567    shows "Zfun (\<lambda>x. f x + g x) F"
1.568  proof (rule ZfunI)
1.569 -  fix r::real assume "0 < r"
1.570 -  hence r: "0 < r / 2" by simp
1.571 +  fix r :: real
1.572 +  assume "0 < r"
1.573 +  then have r: "0 < r / 2" by simp
1.574    have "eventually (\<lambda>x. norm (f x) < r/2) F"
1.575      using f r by (rule ZfunD)
1.576    moreover
1.577 @@ -436,14 +473,14 @@
1.578  lemma Zfun_minus: "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. - f x) F"
1.579    unfolding Zfun_def by simp
1.580
1.581 -lemma Zfun_diff: "\<lbrakk>Zfun f F; Zfun g F\<rbrakk> \<Longrightarrow> Zfun (\<lambda>x. f x - g x) F"
1.582 +lemma Zfun_diff: "Zfun f F \<Longrightarrow> Zfun g F \<Longrightarrow> Zfun (\<lambda>x. f x - g x) F"
1.583    using Zfun_add [of f F "\<lambda>x. - g x"] by (simp add: Zfun_minus)
1.584
1.585  lemma (in bounded_linear) Zfun:
1.586    assumes g: "Zfun g F"
1.587    shows "Zfun (\<lambda>x. f (g x)) F"
1.588  proof -
1.589 -  obtain K where "\<And>x. norm (f x) \<le> norm x * K"
1.590 +  obtain K where "norm (f x) \<le> norm x * K" for x
1.591      using bounded by blast
1.592    then have "eventually (\<lambda>x. norm (f (g x)) \<le> norm (g x) * K) F"
1.593      by simp
1.594 @@ -453,12 +490,13 @@
1.595
1.596  lemma (in bounded_bilinear) Zfun:
1.597    assumes f: "Zfun f F"
1.598 -  assumes g: "Zfun g F"
1.599 +    and g: "Zfun g F"
1.600    shows "Zfun (\<lambda>x. f x ** g x) F"
1.601  proof (rule ZfunI)
1.602 -  fix r::real assume r: "0 < r"
1.603 +  fix r :: real
1.604 +  assume r: "0 < r"
1.605    obtain K where K: "0 < K"
1.606 -    and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
1.607 +    and norm_le: "norm (x ** y) \<le> norm x * norm y * K" for x y
1.608      using pos_bounded by blast
1.609    from K have K': "0 < inverse K"
1.610      by (rule positive_imp_inverse_positive)
1.611 @@ -481,12 +519,10 @@
1.612    qed
1.613  qed
1.614
1.615 -lemma (in bounded_bilinear) Zfun_left:
1.616 -  "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. f x ** a) F"
1.617 +lemma (in bounded_bilinear) Zfun_left: "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. f x ** a) F"
1.618    by (rule bounded_linear_left [THEN bounded_linear.Zfun])
1.619
1.620 -lemma (in bounded_bilinear) Zfun_right:
1.621 -  "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. a ** f x) F"
1.622 +lemma (in bounded_bilinear) Zfun_right: "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. a ** f x) F"
1.623    by (rule bounded_linear_right [THEN bounded_linear.Zfun])
1.624
1.625  lemmas Zfun_mult = bounded_bilinear.Zfun [OF bounded_bilinear_mult]
1.626 @@ -496,19 +532,22 @@
1.627  lemma tendsto_Zfun_iff: "(f \<longlongrightarrow> a) F = Zfun (\<lambda>x. f x - a) F"
1.628    by (simp only: tendsto_iff Zfun_def dist_norm)
1.629
1.630 -lemma tendsto_0_le: "\<lbrakk>(f \<longlongrightarrow> 0) F; eventually (\<lambda>x. norm (g x) \<le> norm (f x) * K) F\<rbrakk>
1.631 -                     \<Longrightarrow> (g \<longlongrightarrow> 0) F"
1.632 +lemma tendsto_0_le:
1.633 +  "(f \<longlongrightarrow> 0) F \<Longrightarrow> eventually (\<lambda>x. norm (g x) \<le> norm (f x) * K) F \<Longrightarrow> (g \<longlongrightarrow> 0) F"
1.634    by (simp add: Zfun_imp_Zfun tendsto_Zfun_iff)
1.635
1.636 +
1.637  subsubsection \<open>Distance and norms\<close>
1.638
1.639  lemma tendsto_dist [tendsto_intros]:
1.640 -  fixes l m :: "'a :: metric_space"
1.641 -  assumes f: "(f \<longlongrightarrow> l) F" and g: "(g \<longlongrightarrow> m) F"
1.642 +  fixes l m :: "'a::metric_space"
1.643 +  assumes f: "(f \<longlongrightarrow> l) F"
1.644 +    and g: "(g \<longlongrightarrow> m) F"
1.645    shows "((\<lambda>x. dist (f x) (g x)) \<longlongrightarrow> dist l m) F"
1.646  proof (rule tendstoI)
1.647 -  fix e :: real assume "0 < e"
1.648 -  hence e2: "0 < e/2" by simp
1.649 +  fix e :: real
1.650 +  assume "0 < e"
1.651 +  then have e2: "0 < e/2" by simp
1.652    from tendstoD [OF f e2] tendstoD [OF g e2]
1.653    show "eventually (\<lambda>x. dist (dist (f x) (g x)) (dist l m) < e) F"
1.654    proof (eventually_elim)
1.655 @@ -516,9 +555,9 @@
1.656      then show "dist (dist (f x) (g x)) (dist l m) < e"
1.657        unfolding dist_real_def
1.658        using dist_triangle2 [of "f x" "g x" "l"]
1.659 -      using dist_triangle2 [of "g x" "l" "m"]
1.660 -      using dist_triangle3 [of "l" "m" "f x"]
1.661 -      using dist_triangle [of "f x" "m" "g x"]
1.662 +        and dist_triangle2 [of "g x" "l" "m"]
1.663 +        and dist_triangle3 [of "l" "m" "f x"]
1.664 +        and dist_triangle [of "f x" "m" "g x"]
1.665        by arith
1.666    qed
1.667  qed
1.668 @@ -533,33 +572,28 @@
1.669    shows "continuous_on s f \<Longrightarrow> continuous_on s g \<Longrightarrow> continuous_on s (\<lambda>x. dist (f x) (g x))"
1.670    unfolding continuous_on_def by (auto intro: tendsto_dist)
1.671
1.672 -lemma tendsto_norm [tendsto_intros]:
1.673 -  "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. norm (f x)) \<longlongrightarrow> norm a) F"
1.674 +lemma tendsto_norm [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. norm (f x)) \<longlongrightarrow> norm a) F"
1.675    unfolding norm_conv_dist by (intro tendsto_intros)
1.676
1.677 -lemma continuous_norm [continuous_intros]:
1.678 -  "continuous F f \<Longrightarrow> continuous F (\<lambda>x. norm (f x))"
1.679 +lemma continuous_norm [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. norm (f x))"
1.680    unfolding continuous_def by (rule tendsto_norm)
1.681
1.682  lemma continuous_on_norm [continuous_intros]:
1.683    "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. norm (f x))"
1.684    unfolding continuous_on_def by (auto intro: tendsto_norm)
1.685
1.686 -lemma tendsto_norm_zero:
1.687 -  "(f \<longlongrightarrow> 0) F \<Longrightarrow> ((\<lambda>x. norm (f x)) \<longlongrightarrow> 0) F"
1.688 -  by (drule tendsto_norm, simp)
1.689 -
1.690 -lemma tendsto_norm_zero_cancel:
1.691 -  "((\<lambda>x. norm (f x)) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> 0) F"
1.692 +lemma tendsto_norm_zero: "(f \<longlongrightarrow> 0) F \<Longrightarrow> ((\<lambda>x. norm (f x)) \<longlongrightarrow> 0) F"
1.693 +  by (drule tendsto_norm) simp
1.694 +
1.695 +lemma tendsto_norm_zero_cancel: "((\<lambda>x. norm (f x)) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> 0) F"
1.696    unfolding tendsto_iff dist_norm by simp
1.697
1.698 -lemma tendsto_norm_zero_iff:
1.699 -  "((\<lambda>x. norm (f x)) \<longlongrightarrow> 0) F \<longleftrightarrow> (f \<longlongrightarrow> 0) F"
1.700 +lemma tendsto_norm_zero_iff: "((\<lambda>x. norm (f x)) \<longlongrightarrow> 0) F \<longleftrightarrow> (f \<longlongrightarrow> 0) F"
1.701    unfolding tendsto_iff dist_norm by simp
1.702
1.703 -lemma tendsto_rabs [tendsto_intros]:
1.704 -  "(f \<longlongrightarrow> (l::real)) F \<Longrightarrow> ((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> \<bar>l\<bar>) F"
1.705 -  by (fold real_norm_def, rule tendsto_norm)
1.706 +lemma tendsto_rabs [tendsto_intros]: "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> \<bar>l\<bar>) F"
1.707 +  for l :: real
1.708 +  by (fold real_norm_def) (rule tendsto_norm)
1.709
1.710  lemma continuous_rabs [continuous_intros]:
1.711    "continuous F f \<Longrightarrow> continuous F (\<lambda>x. \<bar>f x :: real\<bar>)"
1.712 @@ -569,17 +603,15 @@
1.713    "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. \<bar>f x :: real\<bar>)"
1.714    unfolding real_norm_def[symmetric] by (rule continuous_on_norm)
1.715
1.716 -lemma tendsto_rabs_zero:
1.717 -  "(f \<longlongrightarrow> (0::real)) F \<Longrightarrow> ((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> 0) F"
1.718 -  by (fold real_norm_def, rule tendsto_norm_zero)
1.719 -
1.720 -lemma tendsto_rabs_zero_cancel:
1.721 -  "((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> (0::real)) F \<Longrightarrow> (f \<longlongrightarrow> 0) F"
1.722 -  by (fold real_norm_def, rule tendsto_norm_zero_cancel)
1.723 -
1.724 -lemma tendsto_rabs_zero_iff:
1.725 -  "((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> (0::real)) F \<longleftrightarrow> (f \<longlongrightarrow> 0) F"
1.726 -  by (fold real_norm_def, rule tendsto_norm_zero_iff)
1.727 +lemma tendsto_rabs_zero: "(f \<longlongrightarrow> (0::real)) F \<Longrightarrow> ((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> 0) F"
1.728 +  by (fold real_norm_def) (rule tendsto_norm_zero)
1.729 +
1.730 +lemma tendsto_rabs_zero_cancel: "((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> (0::real)) F \<Longrightarrow> (f \<longlongrightarrow> 0) F"
1.731 +  by (fold real_norm_def) (rule tendsto_norm_zero_cancel)
1.732 +
1.733 +lemma tendsto_rabs_zero_iff: "((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> (0::real)) F \<longleftrightarrow> (f \<longlongrightarrow> 0) F"
1.734 +  by (fold real_norm_def) (rule tendsto_norm_zero_iff)
1.735 +
1.736
1.737  subsection \<open>Topological Monoid\<close>
1.738
1.739 @@ -606,17 +638,22 @@
1.740
1.742    fixes f g :: "_ \<Rightarrow> 'b::topological_monoid_add"
1.743 -  shows "\<lbrakk>(f \<longlongrightarrow> 0) F; (g \<longlongrightarrow> 0) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x + g x) \<longlongrightarrow> 0) F"
1.744 -  by (drule (1) tendsto_add, simp)
1.745 +  shows "(f \<longlongrightarrow> 0) F \<Longrightarrow> (g \<longlongrightarrow> 0) F \<Longrightarrow> ((\<lambda>x. f x + g x) \<longlongrightarrow> 0) F"
1.746 +  by (drule (1) tendsto_add) simp
1.747
1.748  lemma tendsto_setsum [tendsto_intros]:
1.749    fixes f :: "'a \<Rightarrow> 'b \<Rightarrow> 'c::topological_comm_monoid_add"
1.750    assumes "\<And>i. i \<in> I \<Longrightarrow> (f i \<longlongrightarrow> a i) F"
1.751    shows "((\<lambda>x. \<Sum>i\<in>I. f i x) \<longlongrightarrow> (\<Sum>i\<in>I. a i)) F"
1.752  proof (cases "finite I")
1.753 -  assume "finite I" thus ?thesis using assms
1.755 -qed simp
1.756 +  case True
1.757 +  then show ?thesis
1.759 +next
1.760 +  case False
1.761 +  then show ?thesis
1.762 +    by simp
1.763 +qed
1.764
1.765  lemma continuous_setsum [continuous_intros]:
1.766    fixes f :: "'a \<Rightarrow> 'b::t2_space \<Rightarrow> 'c::topological_comm_monoid_add"
1.767 @@ -629,10 +666,13 @@
1.768    unfolding continuous_on_def by (auto intro: tendsto_setsum)
1.769
1.771 -  proof qed (simp add: nhds_discrete principal_prod_principal filterlim_principal eventually_principal)
1.772 +  by standard
1.773 +    (simp add: nhds_discrete principal_prod_principal filterlim_principal eventually_principal)
1.774
1.776 -  proof qed (simp add: nhds_discrete principal_prod_principal filterlim_principal eventually_principal)
1.777 +  by standard
1.778 +    (simp add: nhds_discrete principal_prod_principal filterlim_principal eventually_principal)
1.779 +
1.780
1.781  subsubsection \<open>Topological group\<close>
1.782
1.783 @@ -640,7 +680,7 @@
1.784    assumes tendsto_uminus_nhds: "(uminus \<longlongrightarrow> - a) (nhds a)"
1.785  begin
1.786
1.787 -lemma tendsto_minus [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. - f x) \<longlongrightarrow> -a) F"
1.788 +lemma tendsto_minus [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. - f x) \<longlongrightarrow> - a) F"
1.789    by (rule filterlim_compose[OF tendsto_uminus_nhds])
1.790
1.791  end
1.792 @@ -649,29 +689,26 @@
1.793
1.795
1.796 -lemma continuous_minus [continuous_intros]:
1.797 -  fixes f :: "'a::t2_space \<Rightarrow> 'b::topological_group_add"
1.798 -  shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. - f x)"
1.799 +lemma continuous_minus [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. - f x)"
1.800 +  for f :: "'a::t2_space \<Rightarrow> 'b::topological_group_add"
1.801    unfolding continuous_def by (rule tendsto_minus)
1.802
1.803 -lemma continuous_on_minus [continuous_intros]:
1.804 -  fixes f :: "_ \<Rightarrow> 'b::topological_group_add"
1.805 -  shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. - f x)"
1.806 +lemma continuous_on_minus [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. - f x)"
1.807 +  for f :: "_ \<Rightarrow> 'b::topological_group_add"
1.808    unfolding continuous_on_def by (auto intro: tendsto_minus)
1.809
1.810 -lemma tendsto_minus_cancel:
1.811 -  fixes a :: "'a::topological_group_add"
1.812 -  shows "((\<lambda>x. - f x) \<longlongrightarrow> - a) F \<Longrightarrow> (f \<longlongrightarrow> a) F"
1.813 -  by (drule tendsto_minus, simp)
1.814 +lemma tendsto_minus_cancel: "((\<lambda>x. - f x) \<longlongrightarrow> - a) F \<Longrightarrow> (f \<longlongrightarrow> a) F"
1.815 +  for a :: "'a::topological_group_add"
1.816 +  by (drule tendsto_minus) simp
1.817
1.818  lemma tendsto_minus_cancel_left:
1.819 -    "(f \<longlongrightarrow> - (y::_::topological_group_add)) F \<longleftrightarrow> ((\<lambda>x. - f x) \<longlongrightarrow> y) F"
1.820 +  "(f \<longlongrightarrow> - (y::_::topological_group_add)) F \<longleftrightarrow> ((\<lambda>x. - f x) \<longlongrightarrow> y) F"
1.821    using tendsto_minus_cancel[of f "- y" F]  tendsto_minus[of f "- y" F]
1.822    by auto
1.823
1.824  lemma tendsto_diff [tendsto_intros]:
1.825    fixes a b :: "'a::topological_group_add"
1.826 -  shows "\<lbrakk>(f \<longlongrightarrow> a) F; (g \<longlongrightarrow> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x - g x) \<longlongrightarrow> a - b) F"
1.827 +  shows "(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> ((\<lambda>x. f x - g x) \<longlongrightarrow> a - b) F"
1.828    using tendsto_add [of f a F "\<lambda>x. - g x" "- b"] by (simp add: tendsto_minus)
1.829
1.830  lemma continuous_diff [continuous_intros]:
1.831 @@ -689,7 +726,8 @@
1.832
1.834  proof
1.835 -  fix a b :: 'a show "((\<lambda>x. fst x + snd x) \<longlongrightarrow> a + b) (nhds a \<times>\<^sub>F nhds b)"
1.836 +  fix a b :: 'a
1.837 +  show "((\<lambda>x. fst x + snd x) \<longlongrightarrow> a + b) (nhds a \<times>\<^sub>F nhds b)"
1.839      using tendsto_fst[OF filterlim_ident, of "(a,b)"] tendsto_snd[OF filterlim_ident, of "(a,b)"]
1.841 @@ -702,32 +740,28 @@
1.842
1.843  lemmas real_tendsto_sandwich = tendsto_sandwich[where 'b=real]
1.844
1.845 +
1.846  subsubsection \<open>Linear operators and multiplication\<close>
1.847
1.848 -lemma linear_times:
1.849 -  fixes c::"'a::real_algebra" shows "linear (\<lambda>x. c * x)"
1.850 +lemma linear_times: "linear (\<lambda>x. c * x)"
1.851 +  for c :: "'a::real_algebra"
1.852    by (auto simp: linearI distrib_left)
1.853
1.854 -lemma (in bounded_linear) tendsto:
1.855 -  "(g \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. f (g x)) \<longlongrightarrow> f a) F"
1.856 +lemma (in bounded_linear) tendsto: "(g \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. f (g x)) \<longlongrightarrow> f a) F"
1.857    by (simp only: tendsto_Zfun_iff diff [symmetric] Zfun)
1.858
1.859 -lemma (in bounded_linear) continuous:
1.860 -  "continuous F g \<Longrightarrow> continuous F (\<lambda>x. f (g x))"
1.861 +lemma (in bounded_linear) continuous: "continuous F g \<Longrightarrow> continuous F (\<lambda>x. f (g x))"
1.862    using tendsto[of g _ F] by (auto simp: continuous_def)
1.863
1.864 -lemma (in bounded_linear) continuous_on:
1.865 -  "continuous_on s g \<Longrightarrow> continuous_on s (\<lambda>x. f (g x))"
1.866 +lemma (in bounded_linear) continuous_on: "continuous_on s g \<Longrightarrow> continuous_on s (\<lambda>x. f (g x))"
1.867    using tendsto[of g] by (auto simp: continuous_on_def)
1.868
1.869 -lemma (in bounded_linear) tendsto_zero:
1.870 -  "(g \<longlongrightarrow> 0) F \<Longrightarrow> ((\<lambda>x. f (g x)) \<longlongrightarrow> 0) F"
1.871 -  by (drule tendsto, simp only: zero)
1.872 +lemma (in bounded_linear) tendsto_zero: "(g \<longlongrightarrow> 0) F \<Longrightarrow> ((\<lambda>x. f (g x)) \<longlongrightarrow> 0) F"
1.873 +  by (drule tendsto) (simp only: zero)
1.874
1.875  lemma (in bounded_bilinear) tendsto:
1.876 -  "\<lbrakk>(f \<longlongrightarrow> a) F; (g \<longlongrightarrow> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x ** g x) \<longlongrightarrow> a ** b) F"
1.877 -  by (simp only: tendsto_Zfun_iff prod_diff_prod
1.878 -                 Zfun_add Zfun Zfun_left Zfun_right)
1.879 +  "(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> ((\<lambda>x. f x ** g x) \<longlongrightarrow> a ** b) F"
1.880 +  by (simp only: tendsto_Zfun_iff prod_diff_prod Zfun_add Zfun Zfun_left Zfun_right)
1.881
1.882  lemma (in bounded_bilinear) continuous:
1.883    "continuous F f \<Longrightarrow> continuous F g \<Longrightarrow> continuous F (\<lambda>x. f x ** g x)"
1.884 @@ -739,7 +773,7 @@
1.885
1.886  lemma (in bounded_bilinear) tendsto_zero:
1.887    assumes f: "(f \<longlongrightarrow> 0) F"
1.888 -  assumes g: "(g \<longlongrightarrow> 0) F"
1.889 +    and g: "(g \<longlongrightarrow> 0) F"
1.890    shows "((\<lambda>x. f x ** g x) \<longlongrightarrow> 0) F"
1.891    using tendsto [OF f g] by (simp add: zero_left)
1.892
1.893 @@ -760,15 +794,13 @@
1.894  lemmas tendsto_mult [tendsto_intros] =
1.895    bounded_bilinear.tendsto [OF bounded_bilinear_mult]
1.896
1.897 -lemma tendsto_mult_left:
1.898 -  fixes c::"'a::real_normed_algebra"
1.899 -  shows "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. c * (f x)) \<longlongrightarrow> c * l) F"
1.900 -by (rule tendsto_mult [OF tendsto_const])
1.901 -
1.902 -lemma tendsto_mult_right:
1.903 -  fixes c::"'a::real_normed_algebra"
1.904 -  shows "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. (f x) * c) \<longlongrightarrow> l * c) F"
1.905 -by (rule tendsto_mult [OF _ tendsto_const])
1.906 +lemma tendsto_mult_left: "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. c * (f x)) \<longlongrightarrow> c * l) F"
1.907 +  for c :: "'a::real_normed_algebra"
1.908 +  by (rule tendsto_mult [OF tendsto_const])
1.909 +
1.910 +lemma tendsto_mult_right: "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. (f x) * c) \<longlongrightarrow> l * c) F"
1.911 +  for c :: "'a::real_normed_algebra"
1.912 +  by (rule tendsto_mult [OF _ tendsto_const])
1.913
1.914  lemmas continuous_of_real [continuous_intros] =
1.915    bounded_linear.continuous [OF bounded_linear_of_real]
1.916 @@ -797,14 +829,12 @@
1.917  lemmas tendsto_mult_right_zero =
1.918    bounded_bilinear.tendsto_right_zero [OF bounded_bilinear_mult]
1.919
1.920 -lemma tendsto_power [tendsto_intros]:
1.921 -  fixes f :: "'a \<Rightarrow> 'b::{power,real_normed_algebra}"
1.922 -  shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. f x ^ n) \<longlongrightarrow> a ^ n) F"
1.923 +lemma tendsto_power [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. f x ^ n) \<longlongrightarrow> a ^ n) F"
1.924 +  for f :: "'a \<Rightarrow> 'b::{power,real_normed_algebra}"
1.925    by (induct n) (simp_all add: tendsto_mult)
1.926
1.927 -lemma continuous_power [continuous_intros]:
1.928 -  fixes f :: "'a::t2_space \<Rightarrow> 'b::{power,real_normed_algebra}"
1.929 -  shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. (f x)^n)"
1.930 +lemma continuous_power [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. (f x)^n)"
1.931 +  for f :: "'a::t2_space \<Rightarrow> 'b::{power,real_normed_algebra}"
1.932    unfolding continuous_def by (rule tendsto_power)
1.933
1.934  lemma continuous_on_power [continuous_intros]:
1.935 @@ -817,9 +847,13 @@
1.936    assumes "\<And>i. i \<in> S \<Longrightarrow> (f i \<longlongrightarrow> L i) F"
1.937    shows "((\<lambda>x. \<Prod>i\<in>S. f i x) \<longlongrightarrow> (\<Prod>i\<in>S. L i)) F"
1.938  proof (cases "finite S")
1.939 -  assume "finite S" thus ?thesis using assms
1.940 -    by (induct, simp, simp add: tendsto_mult)
1.941 -qed simp
1.942 +  case True
1.943 +  then show ?thesis using assms
1.944 +    by induct (simp_all add: tendsto_mult)
1.945 +next
1.946 +  case False
1.947 +  then show ?thesis by simp
1.948 +qed
1.949
1.950  lemma continuous_setprod [continuous_intros]:
1.951    fixes f :: "'a \<Rightarrow> 'b::t2_space \<Rightarrow> 'c::{real_normed_algebra,comm_ring_1}"
1.952 @@ -832,20 +866,20 @@
1.953    unfolding continuous_on_def by (auto intro: tendsto_setprod)
1.954
1.955  lemma tendsto_of_real_iff:
1.956 -  "((\<lambda>x. of_real (f x) :: 'a :: real_normed_div_algebra) \<longlongrightarrow> of_real c) F \<longleftrightarrow> (f \<longlongrightarrow> c) F"
1.957 +  "((\<lambda>x. of_real (f x) :: 'a::real_normed_div_algebra) \<longlongrightarrow> of_real c) F \<longleftrightarrow> (f \<longlongrightarrow> c) F"
1.958    unfolding tendsto_iff by simp
1.959
1.961 -  "((\<lambda>x. c + f x :: 'a :: real_normed_vector) \<longlongrightarrow> c + d) F \<longleftrightarrow> (f \<longlongrightarrow> d) F"
1.962 +  "((\<lambda>x. c + f x :: 'a::real_normed_vector) \<longlongrightarrow> c + d) F \<longleftrightarrow> (f \<longlongrightarrow> d) F"
1.963    using tendsto_add[OF tendsto_const[of c], of f d]
1.964 -        tendsto_add[OF tendsto_const[of "-c"], of "\<lambda>x. c + f x" "c + d"] by auto
1.965 +    and tendsto_add[OF tendsto_const[of "-c"], of "\<lambda>x. c + f x" "c + d"] by auto
1.966
1.967
1.968  subsubsection \<open>Inverse and division\<close>
1.969
1.970  lemma (in bounded_bilinear) Zfun_prod_Bfun:
1.971    assumes f: "Zfun f F"
1.972 -  assumes g: "Bfun g F"
1.973 +    and g: "Bfun g F"
1.974    shows "Zfun (\<lambda>x. f x ** g x) F"
1.975  proof -
1.976    obtain K where K: "0 \<le> K"
1.977 @@ -860,8 +894,7 @@
1.978      have "norm (f x ** g x) \<le> norm (f x) * norm (g x) * K"
1.979        by (rule norm_le)
1.980      also have "\<dots> \<le> norm (f x) * B * K"
1.981 -      by (intro mult_mono' order_refl norm_g norm_ge_zero
1.982 -                mult_nonneg_nonneg K elim)
1.983 +      by (intro mult_mono' order_refl norm_g norm_ge_zero mult_nonneg_nonneg K elim)
1.984      also have "\<dots> = norm (f x) * (B * K)"
1.985        by (rule mult.assoc)
1.986      finally show "norm (f x ** g x) \<le> norm (f x) * (B * K)" .
1.987 @@ -872,14 +905,15 @@
1.988
1.989  lemma (in bounded_bilinear) Bfun_prod_Zfun:
1.990    assumes f: "Bfun f F"
1.991 -  assumes g: "Zfun g F"
1.992 +    and g: "Zfun g F"
1.993    shows "Zfun (\<lambda>x. f x ** g x) F"
1.994    using flip g f by (rule bounded_bilinear.Zfun_prod_Bfun)
1.995
1.996  lemma Bfun_inverse_lemma:
1.997    fixes x :: "'a::real_normed_div_algebra"
1.998 -  shows "\<lbrakk>r \<le> norm x; 0 < r\<rbrakk> \<Longrightarrow> norm (inverse x) \<le> inverse r"
1.999 -  apply (subst nonzero_norm_inverse, clarsimp)
1.1000 +  shows "r \<le> norm x \<Longrightarrow> 0 < r \<Longrightarrow> norm (inverse x) \<le> inverse r"
1.1001 +  apply (subst nonzero_norm_inverse)
1.1002 +  apply clarsimp
1.1003    apply (erule (1) le_imp_inverse_le)
1.1004    done
1.1005
1.1006 @@ -890,38 +924,40 @@
1.1007    shows "Bfun (\<lambda>x. inverse (f x)) F"
1.1008  proof -
1.1009    from a have "0 < norm a" by simp
1.1010 -  hence "\<exists>r>0. r < norm a" by (rule dense)
1.1011 -  then obtain r where r1: "0 < r" and r2: "r < norm a" by blast
1.1012 +  then have "\<exists>r>0. r < norm a" by (rule dense)
1.1013 +  then obtain r where r1: "0 < r" and r2: "r < norm a"
1.1014 +    by blast
1.1015    have "eventually (\<lambda>x. dist (f x) a < r) F"
1.1016      using tendstoD [OF f r1] by blast
1.1017 -  hence "eventually (\<lambda>x. norm (inverse (f x)) \<le> inverse (norm a - r)) F"
1.1018 +  then have "eventually (\<lambda>x. norm (inverse (f x)) \<le> inverse (norm a - r)) F"
1.1019    proof eventually_elim
1.1020      case (elim x)
1.1021 -    hence 1: "norm (f x - a) < r"
1.1022 +    then have 1: "norm (f x - a) < r"
1.1024 -    hence 2: "f x \<noteq> 0" using r2 by auto
1.1025 -    hence "norm (inverse (f x)) = inverse (norm (f x))"
1.1026 +    then have 2: "f x \<noteq> 0" using r2 by auto
1.1027 +    then have "norm (inverse (f x)) = inverse (norm (f x))"
1.1028        by (rule nonzero_norm_inverse)
1.1029      also have "\<dots> \<le> inverse (norm a - r)"
1.1030      proof (rule le_imp_inverse_le)
1.1031 -      show "0 < norm a - r" using r2 by simp
1.1032 -    next
1.1033 +      show "0 < norm a - r"
1.1034 +        using r2 by simp
1.1035        have "norm a - norm (f x) \<le> norm (a - f x)"
1.1036          by (rule norm_triangle_ineq2)
1.1037        also have "\<dots> = norm (f x - a)"
1.1038          by (rule norm_minus_commute)
1.1039        also have "\<dots> < r" using 1 .
1.1040 -      finally show "norm a - r \<le> norm (f x)" by simp
1.1041 +      finally show "norm a - r \<le> norm (f x)"
1.1042 +        by simp
1.1043      qed
1.1044      finally show "norm (inverse (f x)) \<le> inverse (norm a - r)" .
1.1045    qed
1.1046 -  thus ?thesis by (rule BfunI)
1.1047 +  then show ?thesis by (rule BfunI)
1.1048  qed
1.1049
1.1050  lemma tendsto_inverse [tendsto_intros]:
1.1051    fixes a :: "'a::real_normed_div_algebra"
1.1052    assumes f: "(f \<longlongrightarrow> a) F"
1.1053 -  assumes a: "a \<noteq> 0"
1.1054 +    and a: "a \<noteq> 0"
1.1055    shows "((\<lambda>x. inverse (f x)) \<longlongrightarrow> inverse a) F"
1.1056  proof -
1.1057    from a have "0 < norm a" by simp
1.1058 @@ -942,43 +978,49 @@
1.1059
1.1060  lemma continuous_inverse:
1.1061    fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_div_algebra"
1.1062 -  assumes "continuous F f" and "f (Lim F (\<lambda>x. x)) \<noteq> 0"
1.1063 +  assumes "continuous F f"
1.1064 +    and "f (Lim F (\<lambda>x. x)) \<noteq> 0"
1.1065    shows "continuous F (\<lambda>x. inverse (f x))"
1.1066    using assms unfolding continuous_def by (rule tendsto_inverse)
1.1067
1.1068  lemma continuous_at_within_inverse[continuous_intros]:
1.1069    fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_div_algebra"
1.1070 -  assumes "continuous (at a within s) f" and "f a \<noteq> 0"
1.1071 +  assumes "continuous (at a within s) f"
1.1072 +    and "f a \<noteq> 0"
1.1073    shows "continuous (at a within s) (\<lambda>x. inverse (f x))"
1.1074    using assms unfolding continuous_within by (rule tendsto_inverse)
1.1075
1.1076  lemma isCont_inverse[continuous_intros, simp]:
1.1077    fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_div_algebra"
1.1078 -  assumes "isCont f a" and "f a \<noteq> 0"
1.1079 +  assumes "isCont f a"
1.1080 +    and "f a \<noteq> 0"
1.1081    shows "isCont (\<lambda>x. inverse (f x)) a"
1.1082    using assms unfolding continuous_at by (rule tendsto_inverse)
1.1083
1.1084  lemma continuous_on_inverse[continuous_intros]:
1.1085    fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_div_algebra"
1.1086 -  assumes "continuous_on s f" and "\<forall>x\<in>s. f x \<noteq> 0"
1.1087 +  assumes "continuous_on s f"
1.1088 +    and "\<forall>x\<in>s. f x \<noteq> 0"
1.1089    shows "continuous_on s (\<lambda>x. inverse (f x))"
1.1090    using assms unfolding continuous_on_def by (blast intro: tendsto_inverse)
1.1091
1.1092  lemma tendsto_divide [tendsto_intros]:
1.1093    fixes a b :: "'a::real_normed_field"
1.1094 -  shows "\<lbrakk>(f \<longlongrightarrow> a) F; (g \<longlongrightarrow> b) F; b \<noteq> 0\<rbrakk>
1.1095 -    \<Longrightarrow> ((\<lambda>x. f x / g x) \<longlongrightarrow> a / b) F"
1.1096 +  shows "(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> ((\<lambda>x. f x / g x) \<longlongrightarrow> a / b) F"
1.1097    by (simp add: tendsto_mult tendsto_inverse divide_inverse)
1.1098
1.1099  lemma continuous_divide:
1.1100    fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_field"
1.1101 -  assumes "continuous F f" and "continuous F g" and "g (Lim F (\<lambda>x. x)) \<noteq> 0"
1.1102 +  assumes "continuous F f"
1.1103 +    and "continuous F g"
1.1104 +    and "g (Lim F (\<lambda>x. x)) \<noteq> 0"
1.1105    shows "continuous F (\<lambda>x. (f x) / (g x))"
1.1106    using assms unfolding continuous_def by (rule tendsto_divide)
1.1107
1.1108  lemma continuous_at_within_divide[continuous_intros]:
1.1109    fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_field"
1.1110 -  assumes "continuous (at a within s) f" "continuous (at a within s) g" and "g a \<noteq> 0"
1.1111 +  assumes "continuous (at a within s) f" "continuous (at a within s) g"
1.1112 +    and "g a \<noteq> 0"
1.1113    shows "continuous (at a within s) (\<lambda>x. (f x) / (g x))"
1.1114    using assms unfolding continuous_within by (rule tendsto_divide)
1.1115
1.1116 @@ -990,36 +1032,40 @@
1.1117
1.1118  lemma continuous_on_divide[continuous_intros]:
1.1119    fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_field"
1.1120 -  assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. g x \<noteq> 0"
1.1121 +  assumes "continuous_on s f" "continuous_on s g"
1.1122 +    and "\<forall>x\<in>s. g x \<noteq> 0"
1.1123    shows "continuous_on s (\<lambda>x. (f x) / (g x))"
1.1124    using assms unfolding continuous_on_def by (blast intro: tendsto_divide)
1.1125
1.1126 -lemma tendsto_sgn [tendsto_intros]:
1.1127 -  fixes l :: "'a::real_normed_vector"
1.1128 -  shows "\<lbrakk>(f \<longlongrightarrow> l) F; l \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. sgn (f x)) \<longlongrightarrow> sgn l) F"
1.1129 +lemma tendsto_sgn [tendsto_intros]: "(f \<longlongrightarrow> l) F \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> ((\<lambda>x. sgn (f x)) \<longlongrightarrow> sgn l) F"
1.1130 +  for l :: "'a::real_normed_vector"
1.1131    unfolding sgn_div_norm by (simp add: tendsto_intros)
1.1132
1.1133  lemma continuous_sgn:
1.1134    fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.1135 -  assumes "continuous F f" and "f (Lim F (\<lambda>x. x)) \<noteq> 0"
1.1136 +  assumes "continuous F f"
1.1137 +    and "f (Lim F (\<lambda>x. x)) \<noteq> 0"
1.1138    shows "continuous F (\<lambda>x. sgn (f x))"
1.1139    using assms unfolding continuous_def by (rule tendsto_sgn)
1.1140
1.1141  lemma continuous_at_within_sgn[continuous_intros]:
1.1142    fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.1143 -  assumes "continuous (at a within s) f" and "f a \<noteq> 0"
1.1144 +  assumes "continuous (at a within s) f"
1.1145 +    and "f a \<noteq> 0"
1.1146    shows "continuous (at a within s) (\<lambda>x. sgn (f x))"
1.1147    using assms unfolding continuous_within by (rule tendsto_sgn)
1.1148
1.1149  lemma isCont_sgn[continuous_intros]:
1.1150    fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.1151 -  assumes "isCont f a" and "f a \<noteq> 0"
1.1152 +  assumes "isCont f a"
1.1153 +    and "f a \<noteq> 0"
1.1154    shows "isCont (\<lambda>x. sgn (f x)) a"
1.1155    using assms unfolding continuous_at by (rule tendsto_sgn)
1.1156
1.1157  lemma continuous_on_sgn[continuous_intros]:
1.1158    fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
1.1159 -  assumes "continuous_on s f" and "\<forall>x\<in>s. f x \<noteq> 0"
1.1160 +  assumes "continuous_on s f"
1.1161 +    and "\<forall>x\<in>s. f x \<noteq> 0"
1.1162    shows "continuous_on s (\<lambda>x. sgn (f x))"
1.1163    using assms unfolding continuous_on_def by (blast intro: tendsto_sgn)
1.1164
1.1165 @@ -1029,35 +1075,40 @@
1.1166    shows "(LIM x F. f x :> at_infinity) \<longleftrightarrow> (\<forall>r>c. eventually (\<lambda>x. r \<le> norm (f x)) F)"
1.1167    unfolding filterlim_iff eventually_at_infinity
1.1168  proof safe
1.1169 -  fix P :: "'a \<Rightarrow> bool" and b
1.1170 +  fix P :: "'a \<Rightarrow> bool"
1.1171 +  fix b
1.1172    assume *: "\<forall>r>c. eventually (\<lambda>x. r \<le> norm (f x)) F"
1.1173 -    and P: "\<forall>x. b \<le> norm x \<longrightarrow> P x"
1.1174 +  assume P: "\<forall>x. b \<le> norm x \<longrightarrow> P x"
1.1175    have "max b (c + 1) > c" by auto
1.1176    with * have "eventually (\<lambda>x. max b (c + 1) \<le> norm (f x)) F"
1.1177      by auto
1.1178    then show "eventually (\<lambda>x. P (f x)) F"
1.1179    proof eventually_elim
1.1180 -    fix x assume "max b (c + 1) \<le> norm (f x)"
1.1181 +    case (elim x)
1.1182      with P show "P (f x)" by auto
1.1183    qed
1.1184  qed force
1.1185
1.1186  lemma not_tendsto_and_filterlim_at_infinity:
1.1187 +  fixes c :: "'a::real_normed_vector"
1.1188    assumes "F \<noteq> bot"
1.1189 -  assumes "(f \<longlongrightarrow> (c :: 'a :: real_normed_vector)) F"
1.1190 -  assumes "filterlim f at_infinity F"
1.1191 -  shows   False
1.1192 +    and "(f \<longlongrightarrow> c) F"
1.1193 +    and "filterlim f at_infinity F"
1.1194 +  shows False
1.1195  proof -
1.1196    from tendstoD[OF assms(2), of "1/2"]
1.1197 -    have "eventually (\<lambda>x. dist (f x) c < 1/2) F" by simp
1.1198 -  moreover from filterlim_at_infinity[of "norm c" f F] assms(3)
1.1199 -    have "eventually (\<lambda>x. norm (f x) \<ge> norm c + 1) F" by simp
1.1200 +  have "eventually (\<lambda>x. dist (f x) c < 1/2) F"
1.1201 +    by simp
1.1202 +  moreover
1.1203 +  from filterlim_at_infinity[of "norm c" f F] assms(3)
1.1204 +  have "eventually (\<lambda>x. norm (f x) \<ge> norm c + 1) F" by simp
1.1205    ultimately have "eventually (\<lambda>x. False) F"
1.1206    proof eventually_elim
1.1207 -    fix x assume A: "dist (f x) c < 1/2" and B: "norm (f x) \<ge> norm c + 1"
1.1208 -    note B
1.1209 +    fix x
1.1210 +    assume A: "dist (f x) c < 1/2"
1.1211 +    assume "norm (f x) \<ge> norm c + 1"
1.1212      also have "norm (f x) = dist (f x) 0" by simp
1.1213 -    also have "... \<le> dist (f x) c + dist c 0" by (rule dist_triangle)
1.1214 +    also have "\<dots> \<le> dist (f x) c + dist c 0" by (rule dist_triangle)
1.1215      finally show False using A by simp
1.1216    qed
1.1217    with assms show False by simp
1.1218 @@ -1065,83 +1116,97 @@
1.1219
1.1220  lemma filterlim_at_infinity_imp_not_convergent:
1.1221    assumes "filterlim f at_infinity sequentially"
1.1222 -  shows   "\<not>convergent f"
1.1223 +  shows "\<not> convergent f"
1.1224    by (rule notI, rule not_tendsto_and_filterlim_at_infinity[OF _ _ assms])
1.1226
1.1227  lemma filterlim_at_infinity_imp_eventually_ne:
1.1228    assumes "filterlim f at_infinity F"
1.1229 -  shows   "eventually (\<lambda>z. f z \<noteq> c) F"
1.1230 +  shows "eventually (\<lambda>z. f z \<noteq> c) F"
1.1231  proof -
1.1232 -  have "norm c + 1 > 0" by (intro add_nonneg_pos) simp_all
1.1233 +  have "norm c + 1 > 0"
1.1234 +    by (intro add_nonneg_pos) simp_all
1.1235    with filterlim_at_infinity[OF order.refl, of f F] assms
1.1236 -    have "eventually (\<lambda>z. norm (f z) \<ge> norm c + 1) F" by blast
1.1237 -  thus ?thesis by eventually_elim auto
1.1238 +  have "eventually (\<lambda>z. norm (f z) \<ge> norm c + 1) F"
1.1239 +    by blast
1.1240 +  then show ?thesis
1.1241 +    by eventually_elim auto
1.1242  qed
1.1243
1.1244  lemma tendsto_of_nat [tendsto_intros]:
1.1245 -  "filterlim (of_nat :: nat \<Rightarrow> 'a :: real_normed_algebra_1) at_infinity sequentially"
1.1246 +  "filterlim (of_nat :: nat \<Rightarrow> 'a::real_normed_algebra_1) at_infinity sequentially"
1.1247  proof (subst filterlim_at_infinity[OF order.refl], intro allI impI)
1.1248    fix r :: real
1.1249    assume r: "r > 0"
1.1250    define n where "n = nat \<lceil>r\<rceil>"
1.1251 -  from r have n: "\<forall>m\<ge>n. of_nat m \<ge> r" unfolding n_def by linarith
1.1252 +  from r have n: "\<forall>m\<ge>n. of_nat m \<ge> r"
1.1253 +    unfolding n_def by linarith
1.1254    from eventually_ge_at_top[of n] show "eventually (\<lambda>m. norm (of_nat m :: 'a) \<ge> r) sequentially"
1.1255 -    by eventually_elim (insert n, simp_all)
1.1256 +    by eventually_elim (use n in simp_all)
1.1257  qed
1.1258
1.1259
1.1260  subsection \<open>Relate @{const at}, @{const at_left} and @{const at_right}\<close>
1.1261
1.1262  text \<open>
1.1263 -
1.1264 -This lemmas are useful for conversion between @{term "at x"} to @{term "at_left x"} and
1.1265 -@{term "at_right x"} and also @{term "at_right 0"}.
1.1266 -
1.1267 +  This lemmas are useful for conversion between @{term "at x"} to @{term "at_left x"} and
1.1268 +  @{term "at_right x"} and also @{term "at_right 0"}.
1.1269  \<close>
1.1270
1.1271  lemmas filterlim_split_at_real = filterlim_split_at[where 'a=real]
1.1272
1.1273 -lemma filtermap_nhds_shift: "filtermap (\<lambda>x. x - d) (nhds a) = nhds (a - d::'a::real_normed_vector)"
1.1274 +lemma filtermap_nhds_shift: "filtermap (\<lambda>x. x - d) (nhds a) = nhds (a - d)"
1.1275 +  for a d :: "'a::real_normed_vector"
1.1276    by (rule filtermap_fun_inverse[where g="\<lambda>x. x + d"])
1.1277 -     (auto intro!: tendsto_eq_intros filterlim_ident)
1.1278 -
1.1279 -lemma filtermap_nhds_minus: "filtermap (\<lambda>x. - x) (nhds a) = nhds (- a::'a::real_normed_vector)"
1.1280 +    (auto intro!: tendsto_eq_intros filterlim_ident)
1.1281 +
1.1282 +lemma filtermap_nhds_minus: "filtermap (\<lambda>x. - x) (nhds a) = nhds (- a)"
1.1283 +  for a :: "'a::real_normed_vector"
1.1284    by (rule filtermap_fun_inverse[where g=uminus])
1.1285 -     (auto intro!: tendsto_eq_intros filterlim_ident)
1.1286 -
1.1287 -lemma filtermap_at_shift: "filtermap (\<lambda>x. x - d) (at a) = at (a - d::'a::real_normed_vector)"
1.1288 +    (auto intro!: tendsto_eq_intros filterlim_ident)
1.1289 +
1.1290 +lemma filtermap_at_shift: "filtermap (\<lambda>x. x - d) (at a) = at (a - d)"
1.1291 +  for a d :: "'a::real_normed_vector"
1.1292    by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_shift[symmetric])
1.1293
1.1294 -lemma filtermap_at_right_shift: "filtermap (\<lambda>x. x - d) (at_right a) = at_right (a - d::real)"
1.1295 +lemma filtermap_at_right_shift: "filtermap (\<lambda>x. x - d) (at_right a) = at_right (a - d)"
1.1296 +  for a d :: "real"
1.1297    by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_shift[symmetric])
1.1298
1.1299 -lemma at_right_to_0: "at_right (a::real) = filtermap (\<lambda>x. x + a) (at_right 0)"
1.1300 +lemma at_right_to_0: "at_right a = filtermap (\<lambda>x. x + a) (at_right 0)"
1.1301 +  for a :: real
1.1302    using filtermap_at_right_shift[of "-a" 0] by simp
1.1303
1.1304  lemma filterlim_at_right_to_0:
1.1305 -  "filterlim f F (at_right (a::real)) \<longleftrightarrow> filterlim (\<lambda>x. f (x + a)) F (at_right 0)"
1.1306 +  "filterlim f F (at_right a) \<longleftrightarrow> filterlim (\<lambda>x. f (x + a)) F (at_right 0)"
1.1307 +  for a :: real
1.1308    unfolding filterlim_def filtermap_filtermap at_right_to_0[of a] ..
1.1309
1.1310  lemma eventually_at_right_to_0:
1.1311 -  "eventually P (at_right (a::real)) \<longleftrightarrow> eventually (\<lambda>x. P (x + a)) (at_right 0)"
1.1312 +  "eventually P (at_right a) \<longleftrightarrow> eventually (\<lambda>x. P (x + a)) (at_right 0)"
1.1313 +  for a :: real
1.1314    unfolding at_right_to_0[of a] by (simp add: eventually_filtermap)
1.1315
1.1316 -lemma filtermap_at_minus: "filtermap (\<lambda>x. - x) (at a) = at (- a::'a::real_normed_vector)"
1.1317 +lemma filtermap_at_minus: "filtermap (\<lambda>x. - x) (at a) = at (- a)"
1.1318 +  for a :: "'a::real_normed_vector"
1.1319    by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_minus[symmetric])
1.1320
1.1321 -lemma at_left_minus: "at_left (a::real) = filtermap (\<lambda>x. - x) (at_right (- a))"
1.1322 +lemma at_left_minus: "at_left a = filtermap (\<lambda>x. - x) (at_right (- a))"
1.1323 +  for a :: real
1.1324    by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_minus[symmetric])
1.1325
1.1326 -lemma at_right_minus: "at_right (a::real) = filtermap (\<lambda>x. - x) (at_left (- a))"
1.1327 +lemma at_right_minus: "at_right a = filtermap (\<lambda>x. - x) (at_left (- a))"
1.1328 +  for a :: real
1.1329    by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_minus[symmetric])
1.1330
1.1331  lemma filterlim_at_left_to_right:
1.1332 -  "filterlim f F (at_left (a::real)) \<longleftrightarrow> filterlim (\<lambda>x. f (- x)) F (at_right (-a))"
1.1333 +  "filterlim f F (at_left a) \<longleftrightarrow> filterlim (\<lambda>x. f (- x)) F (at_right (-a))"
1.1334 +  for a :: real
1.1335    unfolding filterlim_def filtermap_filtermap at_left_minus[of a] ..
1.1336
1.1337  lemma eventually_at_left_to_right:
1.1338 -  "eventually P (at_left (a::real)) \<longleftrightarrow> eventually (\<lambda>x. P (- x)) (at_right (-a))"
1.1339 +  "eventually P (at_left a) \<longleftrightarrow> eventually (\<lambda>x. P (- x)) (at_right (-a))"
1.1340 +  for a :: real
1.1341    unfolding at_left_minus[of a] by (simp add: eventually_filtermap)
1.1342
1.1343  lemma filterlim_uminus_at_top_at_bot: "LIM x at_bot. - x :: real :> at_top"
1.1344 @@ -1167,7 +1232,7 @@
1.1345
1.1346  lemma filterlim_uminus_at_top: "(LIM x F. f x :> at_top) \<longleftrightarrow> (LIM x F. - (f x) :: real :> at_bot)"
1.1347    using filterlim_compose[OF filterlim_uminus_at_bot_at_top, of f F]
1.1348 -  using filterlim_compose[OF filterlim_uminus_at_top_at_bot, of "\<lambda>x. - f x" F]
1.1349 +    and filterlim_compose[OF filterlim_uminus_at_top_at_bot, of "\<lambda>x. - f x" F]
1.1350    by auto
1.1351
1.1352  lemma filterlim_uminus_at_bot: "(LIM x F. f x :> at_bot) \<longleftrightarrow> (LIM x F. - (f x) :: real :> at_top)"
1.1353 @@ -1176,7 +1241,8 @@
1.1354  lemma filterlim_inverse_at_top_right: "LIM x at_right (0::real). inverse x :> at_top"
1.1355    unfolding filterlim_at_top_gt[where c=0] eventually_at_filter
1.1356  proof safe
1.1357 -  fix Z :: real assume [arith]: "0 < Z"
1.1358 +  fix Z :: real
1.1359 +  assume [arith]: "0 < Z"
1.1360    then have "eventually (\<lambda>x. x < inverse Z) (nhds 0)"
1.1361      by (auto simp add: eventually_nhds_metric dist_real_def intro!: exI[of _ "\<bar>inverse Z\<bar>"])
1.1362    then show "eventually (\<lambda>x. x \<noteq> 0 \<longrightarrow> x \<in> {0<..} \<longrightarrow> Z \<le> inverse x) (nhds 0)"
1.1363 @@ -1188,41 +1254,56 @@
1.1364    shows "(inverse \<longlongrightarrow> (0::'a)) at_infinity"
1.1365    unfolding tendsto_Zfun_iff diff_0_right Zfun_def eventually_at_infinity
1.1366  proof safe
1.1367 -  fix r :: real assume "0 < r"
1.1368 +  fix r :: real
1.1369 +  assume "0 < r"
1.1370    show "\<exists>b. \<forall>x. b \<le> norm x \<longrightarrow> norm (inverse x :: 'a) < r"
1.1371    proof (intro exI[of _ "inverse (r / 2)"] allI impI)
1.1372      fix x :: 'a
1.1373      from \<open>0 < r\<close> have "0 < inverse (r / 2)" by simp
1.1374      also assume *: "inverse (r / 2) \<le> norm x"
1.1375      finally show "norm (inverse x) < r"
1.1376 -      using * \<open>0 < r\<close> by (subst nonzero_norm_inverse) (simp_all add: inverse_eq_divide field_simps)
1.1377 +      using * \<open>0 < r\<close>
1.1378 +      by (subst nonzero_norm_inverse) (simp_all add: inverse_eq_divide field_simps)
1.1379    qed
1.1380  qed
1.1381
1.1383 -  assumes "(f \<longlongrightarrow> (c :: 'b :: real_normed_vector)) (F :: 'a filter)"
1.1384 -  assumes "filterlim g at_infinity F"
1.1385 -  shows   "filterlim (\<lambda>x. f x + g x) at_infinity F"
1.1386 +  fixes c :: "'b::real_normed_vector"
1.1387 +    and F :: "'a filter"
1.1388 +  assumes "(f \<longlongrightarrow> c) F"
1.1389 +    and "filterlim g at_infinity F"
1.1390 +  shows "filterlim (\<lambda>x. f x + g x) at_infinity F"
1.1391  proof (subst filterlim_at_infinity[OF order_refl], safe)
1.1392 -  fix r :: real assume r: "r > 0"
1.1393 -  from assms(1) have "((\<lambda>x. norm (f x)) \<longlongrightarrow> norm c) F" by (rule tendsto_norm)
1.1394 -  hence "eventually (\<lambda>x. norm (f x) < norm c + 1) F" by (rule order_tendstoD) simp_all
1.1395 -  moreover from r have "r + norm c + 1 > 0" by (intro add_pos_nonneg) simp_all
1.1396 +  fix r :: real
1.1397 +  assume r: "r > 0"
1.1398 +  from assms(1) have "((\<lambda>x. norm (f x)) \<longlongrightarrow> norm c) F"
1.1399 +    by (rule tendsto_norm)
1.1400 +  then have "eventually (\<lambda>x. norm (f x) < norm c + 1) F"
1.1401 +    by (rule order_tendstoD) simp_all
1.1402 +  moreover from r have "r + norm c + 1 > 0"
1.1403 +    by (intro add_pos_nonneg) simp_all
1.1404    with assms(2) have "eventually (\<lambda>x. norm (g x) \<ge> r + norm c + 1) F"
1.1405 -    unfolding filterlim_at_infinity[OF order_refl] by (elim allE[of _ "r + norm c + 1"]) simp_all
1.1406 +    unfolding filterlim_at_infinity[OF order_refl]
1.1407 +    by (elim allE[of _ "r + norm c + 1"]) simp_all
1.1408    ultimately show "eventually (\<lambda>x. norm (f x + g x) \<ge> r) F"
1.1409    proof eventually_elim
1.1410 -    fix x :: 'a assume A: "norm (f x) < norm c + 1" and B: "r + norm c + 1 \<le> norm (g x)"
1.1411 -    from A B have "r \<le> norm (g x) - norm (f x)" by simp
1.1412 -    also have "norm (g x) - norm (f x) \<le> norm (g x + f x)" by (rule norm_diff_ineq)
1.1413 -    finally show "r \<le> norm (f x + g x)" by (simp add: add_ac)
1.1414 +    fix x :: 'a
1.1415 +    assume A: "norm (f x) < norm c + 1" and B: "r + norm c + 1 \<le> norm (g x)"
1.1416 +    from A B have "r \<le> norm (g x) - norm (f x)"
1.1417 +      by simp
1.1418 +    also have "norm (g x) - norm (f x) \<le> norm (g x + f x)"
1.1419 +      by (rule norm_diff_ineq)
1.1420 +    finally show "r \<le> norm (f x + g x)"
1.1422    qed
1.1423  qed
1.1424
1.1426 +  fixes c :: "'b::real_normed_vector"
1.1427 +    and F :: "'a filter"
1.1428    assumes "filterlim f at_infinity F"
1.1429 -  assumes "(g \<longlongrightarrow> (c :: 'b :: real_normed_vector)) (F :: 'a filter)"
1.1430 -  shows   "filterlim (\<lambda>x. f x + g x) at_infinity F"
1.1431 +    and "(g \<longlongrightarrow> c) F"
1.1432 +  shows "filterlim (\<lambda>x. f x + g x) at_infinity F"
1.1434
1.1435  lemma filterlim_inverse_at_right_top: "LIM x at_top. inverse x :> at_right (0::real)"
1.1436 @@ -1272,7 +1353,8 @@
1.1437    shows "filterlim inverse at_infinity (at (0::'a))"
1.1438    unfolding filterlim_at_infinity[OF order_refl]
1.1439  proof safe
1.1440 -  fix r :: real assume "0 < r"
1.1441 +  fix r :: real
1.1442 +  assume "0 < r"
1.1443    then show "eventually (\<lambda>x::'a. r \<le> norm (inverse x)) (at 0)"
1.1444      unfolding eventually_at norm_inverse
1.1445      by (intro exI[of _ "inverse r"])
1.1446 @@ -1290,7 +1372,7 @@
1.1447    also have "\<dots> \<le> at 0"
1.1448      using tendsto_inverse_0[where 'a='b]
1.1449      by (auto intro!: exI[of _ 1]
1.1450 -             simp: le_principal eventually_filtermap filterlim_def at_within_def eventually_at_infinity)
1.1451 +        simp: le_principal eventually_filtermap filterlim_def at_within_def eventually_at_infinity)
1.1452    finally show "filtermap inverse (filtermap g F) \<le> at 0" .
1.1453  next
1.1454    assume "filtermap inverse (filtermap g F) \<le> at 0"
1.1455 @@ -1301,36 +1383,40 @@
1.1456  qed
1.1457
1.1458  lemma tendsto_mult_filterlim_at_infinity:
1.1459 -  assumes "F \<noteq> bot" "(f \<longlongrightarrow> (c :: 'a :: real_normed_field)) F" "c \<noteq> 0"
1.1460 +  fixes c :: "'a::real_normed_field"
1.1461 +  assumes "F \<noteq> bot" "(f \<longlongrightarrow> c) F" "c \<noteq> 0"
1.1462    assumes "filterlim g at_infinity F"
1.1463 -  shows   "filterlim (\<lambda>x. f x * g x) at_infinity F"
1.1464 +  shows "filterlim (\<lambda>x. f x * g x) at_infinity F"
1.1465  proof -
1.1466    have "((\<lambda>x. inverse (f x) * inverse (g x)) \<longlongrightarrow> inverse c * 0) F"
1.1467      by (intro tendsto_mult tendsto_inverse assms filterlim_compose[OF tendsto_inverse_0])
1.1468 -  hence "filterlim (\<lambda>x. inverse (f x) * inverse (g x)) (at (inverse c * 0)) F"
1.1469 -    unfolding filterlim_at using assms
1.1470 +  then have "filterlim (\<lambda>x. inverse (f x) * inverse (g x)) (at (inverse c * 0)) F"
1.1471 +    unfolding filterlim_at
1.1472 +    using assms
1.1473      by (auto intro: filterlim_at_infinity_imp_eventually_ne tendsto_imp_eventually_ne eventually_conj)
1.1474 -  thus ?thesis by (subst filterlim_inverse_at_iff[symmetric]) simp_all
1.1475 +  then show ?thesis
1.1476 +    by (subst filterlim_inverse_at_iff[symmetric]) simp_all
1.1477  qed
1.1478
1.1479  lemma tendsto_inverse_0_at_top: "LIM x F. f x :> at_top \<Longrightarrow> ((\<lambda>x. inverse (f x) :: real) \<longlongrightarrow> 0) F"
1.1480   by (metis filterlim_at filterlim_mono[OF _ at_top_le_at_infinity order_refl] filterlim_inverse_at_iff)
1.1481
1.1482 -lemma mult_nat_left_at_top: "c > 0 \<Longrightarrow> filterlim (\<lambda>x. c * x :: nat) at_top sequentially"
1.1483 -  by (rule filterlim_subseq) (auto simp: subseq_def)
1.1484 -
1.1485 -lemma mult_nat_right_at_top: "c > 0 \<Longrightarrow> filterlim (\<lambda>x. x * c :: nat) at_top sequentially"
1.1486 +lemma mult_nat_left_at_top: "c > 0 \<Longrightarrow> filterlim (\<lambda>x. c * x) at_top sequentially"
1.1487 +  for c :: nat
1.1488    by (rule filterlim_subseq) (auto simp: subseq_def)
1.1489
1.1490 -lemma at_to_infinity:
1.1491 -  fixes x :: "'a :: {real_normed_field,field}"
1.1492 -  shows "(at (0::'a)) = filtermap inverse at_infinity"
1.1493 +lemma mult_nat_right_at_top: "c > 0 \<Longrightarrow> filterlim (\<lambda>x. x * c) at_top sequentially"
1.1494 +  for c :: nat
1.1495 +  by (rule filterlim_subseq) (auto simp: subseq_def)
1.1496 +
1.1497 +lemma at_to_infinity: "(at (0::'a::{real_normed_field,field})) = filtermap inverse at_infinity"
1.1498  proof (rule antisym)
1.1499    have "(inverse \<longlongrightarrow> (0::'a)) at_infinity"
1.1500      by (fact tendsto_inverse_0)
1.1501    then show "filtermap inverse at_infinity \<le> at (0::'a)"
1.1502      apply (simp add: le_principal eventually_filtermap eventually_at_infinity filterlim_def at_within_def)
1.1503 -    apply (rule_tac x="1" in exI, auto)
1.1504 +    apply (rule_tac x="1" in exI)
1.1505 +    apply auto
1.1506      done
1.1507  next
1.1508    have "filtermap inverse (filtermap inverse (at (0::'a))) \<le> filtermap inverse at_infinity"
1.1509 @@ -1341,38 +1427,39 @@
1.1510  qed
1.1511
1.1512  lemma lim_at_infinity_0:
1.1513 -  fixes l :: "'a :: {real_normed_field,field}"
1.1514 -  shows "(f \<longlongrightarrow> l) at_infinity \<longleftrightarrow> ((f o inverse) \<longlongrightarrow> l) (at (0::'a))"
1.1515 -by (simp add: tendsto_compose_filtermap at_to_infinity filtermap_filtermap)
1.1516 +  fixes l :: "'a::{real_normed_field,field}"
1.1517 +  shows "(f \<longlongrightarrow> l) at_infinity \<longleftrightarrow> ((f \<circ> inverse) \<longlongrightarrow> l) (at (0::'a))"
1.1518 +  by (simp add: tendsto_compose_filtermap at_to_infinity filtermap_filtermap)
1.1519
1.1520  lemma lim_zero_infinity:
1.1521 -  fixes l :: "'a :: {real_normed_field,field}"
1.1522 +  fixes l :: "'a::{real_normed_field,field}"
1.1523    shows "((\<lambda>x. f(1 / x)) \<longlongrightarrow> l) (at (0::'a)) \<Longrightarrow> (f \<longlongrightarrow> l) at_infinity"
1.1524 -by (simp add: inverse_eq_divide lim_at_infinity_0 comp_def)
1.1525 +  by (simp add: inverse_eq_divide lim_at_infinity_0 comp_def)
1.1526
1.1527
1.1528  text \<open>
1.1529 -
1.1530 -We only show rules for multiplication and addition when the functions are either against a real
1.1531 -value or against infinity. Further rules are easy to derive by using @{thm filterlim_uminus_at_top}.
1.1532 -
1.1533 +  We only show rules for multiplication and addition when the functions are either against a real
1.1534 +  value or against infinity. Further rules are easy to derive by using @{thm
1.1535 +  filterlim_uminus_at_top}.
1.1536  \<close>
1.1537
1.1538  lemma filterlim_tendsto_pos_mult_at_top:
1.1539 -  assumes f: "(f \<longlongrightarrow> c) F" and c: "0 < c"
1.1540 -  assumes g: "LIM x F. g x :> at_top"
1.1541 +  assumes f: "(f \<longlongrightarrow> c) F"
1.1542 +    and c: "0 < c"
1.1543 +    and g: "LIM x F. g x :> at_top"
1.1544    shows "LIM x F. (f x * g x :: real) :> at_top"
1.1545    unfolding filterlim_at_top_gt[where c=0]
1.1546  proof safe
1.1547 -  fix Z :: real assume "0 < Z"
1.1548 +  fix Z :: real
1.1549 +  assume "0 < Z"
1.1550    from f \<open>0 < c\<close> have "eventually (\<lambda>x. c / 2 < f x) F"
1.1551      by (auto dest!: tendstoD[where e="c / 2"] elim!: eventually_mono
1.1552 -             simp: dist_real_def abs_real_def split: if_split_asm)
1.1553 +        simp: dist_real_def abs_real_def split: if_split_asm)
1.1554    moreover from g have "eventually (\<lambda>x. (Z / c * 2) \<le> g x) F"
1.1555      unfolding filterlim_at_top by auto
1.1556    ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F"
1.1557    proof eventually_elim
1.1558 -    fix x assume "c / 2 < f x" "Z / c * 2 \<le> g x"
1.1559 +    case (elim x)
1.1560      with \<open>0 < Z\<close> \<open>0 < c\<close> have "c / 2 * (Z / c * 2) \<le> f x * g x"
1.1561        by (intro mult_mono) (auto simp: zero_le_divide_iff)
1.1562      with \<open>0 < c\<close> show "Z \<le> f x * g x"
1.1563 @@ -1382,18 +1469,19 @@
1.1564
1.1565  lemma filterlim_at_top_mult_at_top:
1.1566    assumes f: "LIM x F. f x :> at_top"
1.1567 -  assumes g: "LIM x F. g x :> at_top"
1.1568 +    and g: "LIM x F. g x :> at_top"
1.1569    shows "LIM x F. (f x * g x :: real) :> at_top"
1.1570    unfolding filterlim_at_top_gt[where c=0]
1.1571  proof safe
1.1572 -  fix Z :: real assume "0 < Z"
1.1573 +  fix Z :: real
1.1574 +  assume "0 < Z"
1.1575    from f have "eventually (\<lambda>x. 1 \<le> f x) F"
1.1576      unfolding filterlim_at_top by auto
1.1577    moreover from g have "eventually (\<lambda>x. Z \<le> g x) F"
1.1578      unfolding filterlim_at_top by auto
1.1579    ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F"
1.1580    proof eventually_elim
1.1581 -    fix x assume "1 \<le> f x" "Z \<le> g x"
1.1582 +    case (elim x)
1.1583      with \<open>0 < Z\<close> have "1 * Z \<le> f x * g x"
1.1584        by (intro mult_mono) (auto simp: zero_le_divide_iff)
1.1585      then show "Z \<le> f x * g x"
1.1586 @@ -1402,25 +1490,32 @@
1.1587  qed
1.1588
1.1589  lemma filterlim_tendsto_pos_mult_at_bot:
1.1590 -  assumes "(f \<longlongrightarrow> c) F" "0 < (c::real)" "filterlim g at_bot F"
1.1591 +  fixes c :: real
1.1592 +  assumes "(f \<longlongrightarrow> c) F" "0 < c" "filterlim g at_bot F"
1.1593    shows "LIM x F. f x * g x :> at_bot"
1.1594    using filterlim_tendsto_pos_mult_at_top[OF assms(1,2), of "\<lambda>x. - g x"] assms(3)
1.1595    unfolding filterlim_uminus_at_bot by simp
1.1596
1.1597  lemma filterlim_tendsto_neg_mult_at_bot:
1.1598 -  assumes c: "(f \<longlongrightarrow> c) F" "(c::real) < 0" and g: "filterlim g at_top F"
1.1599 +  fixes c :: real
1.1600 +  assumes c: "(f \<longlongrightarrow> c) F" "c < 0" and g: "filterlim g at_top F"
1.1601    shows "LIM x F. f x * g x :> at_bot"
1.1602    using c filterlim_tendsto_pos_mult_at_top[of "\<lambda>x. - f x" "- c" F, OF _ _ g]
1.1603    unfolding filterlim_uminus_at_bot tendsto_minus_cancel_left by simp
1.1604
1.1605  lemma filterlim_pow_at_top:
1.1606    fixes f :: "real \<Rightarrow> real"
1.1607 -  assumes "0 < n" and f: "LIM x F. f x :> at_top"
1.1608 +  assumes "0 < n"
1.1609 +    and f: "LIM x F. f x :> at_top"
1.1610    shows "LIM x F. (f x)^n :: real :> at_top"
1.1611 -using \<open>0 < n\<close> proof (induct n)
1.1612 +  using \<open>0 < n\<close>
1.1613 +proof (induct n)
1.1614 +  case 0
1.1615 +  then show ?case by simp
1.1616 +next
1.1617    case (Suc n) with f show ?case
1.1618      by (cases "n = 0") (auto intro!: filterlim_at_top_mult_at_top)
1.1619 -qed simp
1.1620 +qed
1.1621
1.1622  lemma filterlim_pow_at_bot_even:
1.1623    fixes f :: "real \<Rightarrow> real"
1.1624 @@ -1434,11 +1529,12 @@
1.1625
1.1627    assumes f: "(f \<longlongrightarrow> c) F"
1.1628 -  assumes g: "LIM x F. g x :> at_top"
1.1629 +    and g: "LIM x F. g x :> at_top"
1.1630    shows "LIM x F. (f x + g x :: real) :> at_top"
1.1631    unfolding filterlim_at_top_gt[where c=0]
1.1632  proof safe
1.1633 -  fix Z :: real assume "0 < Z"
1.1634 +  fix Z :: real
1.1635 +  assume "0 < Z"
1.1636    from f have "eventually (\<lambda>x. c - 1 < f x) F"
1.1637      by (auto dest!: tendstoD[where e=1] elim!: eventually_mono simp: dist_real_def)
1.1638    moreover from g have "eventually (\<lambda>x. Z - (c - 1) \<le> g x) F"
1.1639 @@ -1450,18 +1546,19 @@
1.1640  lemma LIM_at_top_divide:
1.1641    fixes f g :: "'a \<Rightarrow> real"
1.1642    assumes f: "(f \<longlongrightarrow> a) F" "0 < a"
1.1643 -  assumes g: "(g \<longlongrightarrow> 0) F" "eventually (\<lambda>x. 0 < g x) F"
1.1644 +    and g: "(g \<longlongrightarrow> 0) F" "eventually (\<lambda>x. 0 < g x) F"
1.1645    shows "LIM x F. f x / g x :> at_top"
1.1646    unfolding divide_inverse
1.1647    by (rule filterlim_tendsto_pos_mult_at_top[OF f]) (rule filterlim_inverse_at_top[OF g])
1.1648
1.1650    assumes f: "LIM x F. f x :> at_top"
1.1651 -  assumes g: "LIM x F. g x :> at_top"
1.1652 +    and g: "LIM x F. g x :> at_top"
1.1653    shows "LIM x F. (f x + g x :: real) :> at_top"
1.1654    unfolding filterlim_at_top_gt[where c=0]
1.1655  proof safe
1.1656 -  fix Z :: real assume "0 < Z"
1.1657 +  fix Z :: real
1.1658 +  assume "0 < Z"
1.1659    from f have "eventually (\<lambda>x. 0 \<le> f x) F"
1.1660      unfolding filterlim_at_top by auto
1.1661    moreover from g have "eventually (\<lambda>x. Z \<le> g x) F"
1.1662 @@ -1473,34 +1570,43 @@
1.1663  lemma tendsto_divide_0:
1.1664    fixes f :: "_ \<Rightarrow> 'a::{real_normed_div_algebra, division_ring}"
1.1665    assumes f: "(f \<longlongrightarrow> c) F"
1.1666 -  assumes g: "LIM x F. g x :> at_infinity"
1.1667 +    and g: "LIM x F. g x :> at_infinity"
1.1668    shows "((\<lambda>x. f x / g x) \<longlongrightarrow> 0) F"
1.1669 -  using tendsto_mult[OF f filterlim_compose[OF tendsto_inverse_0 g]] by (simp add: divide_inverse)
1.1670 +  using tendsto_mult[OF f filterlim_compose[OF tendsto_inverse_0 g]]
1.1671 +  by (simp add: divide_inverse)
1.1672
1.1673  lemma linear_plus_1_le_power:
1.1674    fixes x :: real
1.1675    assumes x: "0 \<le> x"
1.1676    shows "real n * x + 1 \<le> (x + 1) ^ n"
1.1677  proof (induct n)
1.1678 +  case 0
1.1679 +  then show ?case by simp
1.1680 +next
1.1681    case (Suc n)
1.1682 -  have "real (Suc n) * x + 1 \<le> (x + 1) * (real n * x + 1)"
1.1683 -    by (simp add: field_simps of_nat_Suc x)
1.1684 +  from x have "real (Suc n) * x + 1 \<le> (x + 1) * (real n * x + 1)"
1.1685 +    by (simp add: field_simps)
1.1686    also have "\<dots> \<le> (x + 1)^Suc n"
1.1687      using Suc x by (simp add: mult_left_mono)
1.1688    finally show ?case .
1.1689 -qed simp
1.1690 +qed
1.1691
1.1692  lemma filterlim_realpow_sequentially_gt1:
1.1693    fixes x :: "'a :: real_normed_div_algebra"
1.1694    assumes x[arith]: "1 < norm x"
1.1695    shows "LIM n sequentially. x ^ n :> at_infinity"
1.1696  proof (intro filterlim_at_infinity[THEN iffD2] allI impI)
1.1697 -  fix y :: real assume "0 < y"
1.1698 +  fix y :: real
1.1699 +  assume "0 < y"
1.1700    have "0 < norm x - 1" by simp
1.1701 -  then obtain N::nat where "y < real N * (norm x - 1)" by (blast dest: reals_Archimedean3)
1.1702 -  also have "\<dots> \<le> real N * (norm x - 1) + 1" by simp
1.1703 -  also have "\<dots> \<le> (norm x - 1 + 1) ^ N" by (rule linear_plus_1_le_power) simp
1.1704 -  also have "\<dots> = norm x ^ N" by simp
1.1705 +  then obtain N :: nat where "y < real N * (norm x - 1)"
1.1706 +    by (blast dest: reals_Archimedean3)
1.1707 +  also have "\<dots> \<le> real N * (norm x - 1) + 1"
1.1708 +    by simp
1.1709 +  also have "\<dots> \<le> (norm x - 1 + 1) ^ N"
1.1710 +    by (rule linear_plus_1_le_power) simp
1.1711 +  also have "\<dots> = norm x ^ N"
1.1712 +    by simp
1.1713    finally have "\<forall>n\<ge>N. y \<le> norm x ^ n"
1.1714      by (metis order_less_le_trans power_increasing order_less_imp_le x)
1.1715    then show "eventually (\<lambda>n. y \<le> norm (x ^ n)) sequentially"
1.1716 @@ -1512,48 +1618,48 @@
1.1717  subsection \<open>Floor and Ceiling\<close>
1.1718
1.1719  lemma eventually_floor_less:
1.1720 -  fixes f::"'a \<Rightarrow> 'b::{order_topology, floor_ceiling}"
1.1721 +  fixes f :: "'a \<Rightarrow> 'b::{order_topology,floor_ceiling}"
1.1722    assumes f: "(f \<longlongrightarrow> l) F"
1.1723 -  assumes l: "l \<notin> \<int>"
1.1724 +    and l: "l \<notin> \<int>"
1.1725    shows "\<forall>\<^sub>F x in F. of_int (floor l) < f x"
1.1726    by (intro order_tendstoD[OF f]) (metis Ints_of_int antisym_conv2 floor_correct l)
1.1727
1.1728  lemma eventually_less_ceiling:
1.1729 -  fixes f::"'a \<Rightarrow> 'b::{order_topology, floor_ceiling}"
1.1730 +  fixes f :: "'a \<Rightarrow> 'b::{order_topology,floor_ceiling}"
1.1731    assumes f: "(f \<longlongrightarrow> l) F"
1.1732 -  assumes l: "l \<notin> \<int>"
1.1733 +    and l: "l \<notin> \<int>"
1.1734    shows "\<forall>\<^sub>F x in F. f x < of_int (ceiling l)"
1.1735    by (intro order_tendstoD[OF f]) (metis Ints_of_int l le_of_int_ceiling less_le)
1.1736
1.1737  lemma eventually_floor_eq:
1.1738 -  fixes f::"'a \<Rightarrow> 'b::{order_topology, floor_ceiling}"
1.1739 +  fixes f::"'a \<Rightarrow> 'b::{order_topology,floor_ceiling}"
1.1740    assumes f: "(f \<longlongrightarrow> l) F"
1.1741 -  assumes l: "l \<notin> \<int>"
1.1742 +    and l: "l \<notin> \<int>"
1.1743    shows "\<forall>\<^sub>F x in F. floor (f x) = floor l"
1.1744    using eventually_floor_less[OF assms] eventually_less_ceiling[OF assms]
1.1745    by eventually_elim (meson floor_less_iff less_ceiling_iff not_less_iff_gr_or_eq)
1.1746
1.1747  lemma eventually_ceiling_eq:
1.1748 -  fixes f::"'a \<Rightarrow> 'b::{order_topology, floor_ceiling}"
1.1749 +  fixes f::"'a \<Rightarrow> 'b::{order_topology,floor_ceiling}"
1.1750    assumes f: "(f \<longlongrightarrow> l) F"
1.1751 -  assumes l: "l \<notin> \<int>"
1.1752 +    and l: "l \<notin> \<int>"
1.1753    shows "\<forall>\<^sub>F x in F. ceiling (f x) = ceiling l"
1.1754    using eventually_floor_less[OF assms] eventually_less_ceiling[OF assms]
1.1755    by eventually_elim (meson floor_less_iff less_ceiling_iff not_less_iff_gr_or_eq)
1.1756
1.1757  lemma tendsto_of_int_floor:
1.1758 -  fixes f::"'a \<Rightarrow> 'b::{order_topology, floor_ceiling}"
1.1759 +  fixes f::"'a \<Rightarrow> 'b::{order_topology,floor_ceiling}"
1.1760    assumes "(f \<longlongrightarrow> l) F"
1.1761 -  assumes "l \<notin> \<int>"
1.1762 -  shows "((\<lambda>x. of_int (floor (f x))::'c::{ring_1, topological_space}) \<longlongrightarrow> of_int (floor l)) F"
1.1763 +    and "l \<notin> \<int>"
1.1764 +  shows "((\<lambda>x. of_int (floor (f x)) :: 'c::{ring_1,topological_space}) \<longlongrightarrow> of_int (floor l)) F"
1.1765    using eventually_floor_eq[OF assms]
1.1766    by (simp add: eventually_mono topological_tendstoI)
1.1767
1.1768  lemma tendsto_of_int_ceiling:
1.1769 -  fixes f::"'a \<Rightarrow> 'b::{order_topology, floor_ceiling}"
1.1770 +  fixes f::"'a \<Rightarrow> 'b::{order_topology,floor_ceiling}"
1.1771    assumes "(f \<longlongrightarrow> l) F"
1.1772 -  assumes "l \<notin> \<int>"
1.1773 -  shows "((\<lambda>x. of_int (ceiling (f x))::'c::{ring_1, topological_space}) \<longlongrightarrow> of_int (ceiling l)) F"
1.1774 +    and "l \<notin> \<int>"
1.1775 +  shows "((\<lambda>x. of_int (ceiling (f x)):: 'c::{ring_1,topological_space}) \<longlongrightarrow> of_int (ceiling l)) F"
1.1776    using eventually_ceiling_eq[OF assms]
1.1777    by (simp add: eventually_mono topological_tendstoI)
1.1778
1.1779 @@ -1580,69 +1686,64 @@
1.1780    shows "(X \<longlonglongrightarrow> L) = (\<forall>r>0. \<exists>no. \<forall>n \<ge> no. norm (X n - L) < r)"
1.1781  unfolding lim_sequentially dist_norm ..
1.1782
1.1783 -lemma LIMSEQ_I:
1.1784 -  fixes L :: "'a::real_normed_vector"
1.1785 -  shows "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r) \<Longrightarrow> X \<longlonglongrightarrow> L"
1.1787 -
1.1788 -lemma LIMSEQ_D:
1.1789 -  fixes L :: "'a::real_normed_vector"
1.1790 -  shows "\<lbrakk>X \<longlonglongrightarrow> L; 0 < r\<rbrakk> \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r"
1.1792 -
1.1793 -lemma LIMSEQ_linear: "\<lbrakk> X \<longlonglongrightarrow> x ; l > 0 \<rbrakk> \<Longrightarrow> (\<lambda> n. X (n * l)) \<longlonglongrightarrow> x"
1.1794 +lemma LIMSEQ_I: "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r) \<Longrightarrow> X \<longlonglongrightarrow> L"
1.1795 +  for L :: "'a::real_normed_vector"
1.1796 +  by (simp add: LIMSEQ_iff)
1.1797 +
1.1798 +lemma LIMSEQ_D: "X \<longlonglongrightarrow> L \<Longrightarrow> 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r"
1.1799 +  for L :: "'a::real_normed_vector"
1.1800 +  by (simp add: LIMSEQ_iff)
1.1801 +
1.1802 +lemma LIMSEQ_linear: "X \<longlonglongrightarrow> x \<Longrightarrow> l > 0 \<Longrightarrow> (\<lambda> n. X (n * l)) \<longlonglongrightarrow> x"
1.1803    unfolding tendsto_def eventually_sequentially
1.1804    by (metis div_le_dividend div_mult_self1_is_m le_trans mult.commute)
1.1805
1.1806 -lemma Bseq_inverse_lemma:
1.1807 -  fixes x :: "'a::real_normed_div_algebra"
1.1808 -  shows "\<lbrakk>r \<le> norm x; 0 < r\<rbrakk> \<Longrightarrow> norm (inverse x) \<le> inverse r"
1.1809 -apply (subst nonzero_norm_inverse, clarsimp)
1.1810 -apply (erule (1) le_imp_inverse_le)
1.1811 -done
1.1812 -
1.1813 -lemma Bseq_inverse:
1.1814 -  fixes a :: "'a::real_normed_div_algebra"
1.1815 -  shows "\<lbrakk>X \<longlonglongrightarrow> a; a \<noteq> 0\<rbrakk> \<Longrightarrow> Bseq (\<lambda>n. inverse (X n))"
1.1816 +lemma Bseq_inverse_lemma: "r \<le> norm x \<Longrightarrow> 0 < r \<Longrightarrow> norm (inverse x) \<le> inverse r"
1.1817 +  for x :: "'a::real_normed_div_algebra"
1.1818 +  apply (subst nonzero_norm_inverse, clarsimp)
1.1819 +  apply (erule (1) le_imp_inverse_le)
1.1820 +  done
1.1821 +
1.1822 +lemma Bseq_inverse: "X \<longlonglongrightarrow> a \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> Bseq (\<lambda>n. inverse (X n))"
1.1823 +  for a :: "'a::real_normed_div_algebra"
1.1824    by (rule Bfun_inverse)
1.1825
1.1826 -text\<open>Transformation of limit.\<close>
1.1827 -
1.1828 -lemma Lim_transform:
1.1829 -  fixes a b :: "'a::real_normed_vector"
1.1830 -  shows "\<lbrakk>(g \<longlongrightarrow> a) F; ((\<lambda>x. f x - g x) \<longlongrightarrow> 0) F\<rbrakk> \<Longrightarrow> (f \<longlongrightarrow> a) F"
1.1831 +
1.1832 +text \<open>Transformation of limit.\<close>
1.1833 +
1.1834 +lemma Lim_transform: "(g \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. f x - g x) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> a) F"
1.1835 +  for a b :: "'a::real_normed_vector"
1.1836    using tendsto_add [of g a F "\<lambda>x. f x - g x" 0] by simp
1.1837
1.1838 -lemma Lim_transform2:
1.1839 -  fixes a b :: "'a::real_normed_vector"
1.1840 -  shows "\<lbrakk>(f \<longlongrightarrow> a) F; ((\<lambda>x. f x - g x) \<longlongrightarrow> 0) F\<rbrakk> \<Longrightarrow> (g \<longlongrightarrow> a) F"
1.1841 +lemma Lim_transform2: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. f x - g x) \<longlongrightarrow> 0) F \<Longrightarrow> (g \<longlongrightarrow> a) F"
1.1842 +  for a b :: "'a::real_normed_vector"
1.1843    by (erule Lim_transform) (simp add: tendsto_minus_cancel)
1.1844
1.1845 -proposition Lim_transform_eq:
1.1846 -  fixes a :: "'a::real_normed_vector"
1.1847 -  shows "((\<lambda>x. f x - g x) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> a) F \<longleftrightarrow> (g \<longlongrightarrow> a) F"
1.1848 -using Lim_transform Lim_transform2 by blast
1.1849 +proposition Lim_transform_eq: "((\<lambda>x. f x - g x) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> a) F \<longleftrightarrow> (g \<longlongrightarrow> a) F"
1.1850 +  for a :: "'a::real_normed_vector"
1.1851 +  using Lim_transform Lim_transform2 by blast
1.1852
1.1853  lemma Lim_transform_eventually:
1.1854    "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f \<longlongrightarrow> l) net \<Longrightarrow> (g \<longlongrightarrow> l) net"
1.1855    apply (rule topological_tendstoI)
1.1856    apply (drule (2) topological_tendstoD)
1.1857 -  apply (erule (1) eventually_elim2, simp)
1.1858 +  apply (erule (1) eventually_elim2)
1.1859 +  apply simp
1.1860    done
1.1861
1.1862  lemma Lim_transform_within:
1.1863    assumes "(f \<longlongrightarrow> l) (at x within S)"
1.1864      and "0 < d"
1.1865 -    and "\<And>x'. \<lbrakk>x'\<in>S; 0 < dist x' x; dist x' x < d\<rbrakk> \<Longrightarrow> f x' = g x'"
1.1866 +    and "\<And>x'. x'\<in>S \<Longrightarrow> 0 < dist x' x \<Longrightarrow> dist x' x < d \<Longrightarrow> f x' = g x'"
1.1867    shows "(g \<longlongrightarrow> l) (at x within S)"
1.1868  proof (rule Lim_transform_eventually)
1.1869    show "eventually (\<lambda>x. f x = g x) (at x within S)"
1.1870      using assms by (auto simp: eventually_at)
1.1871 -  show "(f \<longlongrightarrow> l) (at x within S)" by fact
1.1872 +  show "(f \<longlongrightarrow> l) (at x within S)"
1.1873 +    by fact
1.1874  qed
1.1875
1.1876 -text\<open>Common case assuming being away from some crucial point like 0.\<close>
1.1877 -
1.1878 +text \<open>Common case assuming being away from some crucial point like 0.\<close>
1.1879  lemma Lim_transform_away_within:
1.1880    fixes a b :: "'a::t1_space"
1.1881    assumes "a \<noteq> b"
1.1882 @@ -1650,26 +1751,26 @@
1.1883      and "(f \<longlongrightarrow> l) (at a within S)"
1.1884    shows "(g \<longlongrightarrow> l) (at a within S)"
1.1885  proof (rule Lim_transform_eventually)
1.1886 -  show "(f \<longlongrightarrow> l) (at a within S)" by fact
1.1887 +  show "(f \<longlongrightarrow> l) (at a within S)"
1.1888 +    by fact
1.1889    show "eventually (\<lambda>x. f x = g x) (at a within S)"
1.1890      unfolding eventually_at_topological
1.1891 -    by (rule exI [where x="- {b}"], simp add: open_Compl assms)
1.1892 +    by (rule exI [where x="- {b}"]) (simp add: open_Compl assms)
1.1893  qed
1.1894
1.1895  lemma Lim_transform_away_at:
1.1896    fixes a b :: "'a::t1_space"
1.1897 -  assumes ab: "a\<noteq>b"
1.1898 +  assumes ab: "a \<noteq> b"
1.1899      and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x"
1.1900      and fl: "(f \<longlongrightarrow> l) (at a)"
1.1901    shows "(g \<longlongrightarrow> l) (at a)"
1.1902    using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl by simp
1.1903
1.1904 -text\<open>Alternatively, within an open set.\<close>
1.1905 -
1.1906 +text \<open>Alternatively, within an open set.\<close>
1.1907  lemma Lim_transform_within_open:
1.1908    assumes "(f \<longlongrightarrow> l) (at a within T)"
1.1909      and "open s" and "a \<in> s"
1.1910 -    and "\<And>x. \<lbrakk>x\<in>s; x \<noteq> a\<rbrakk> \<Longrightarrow> f x = g x"
1.1911 +    and "\<And>x. x\<in>s \<Longrightarrow> x \<noteq> a \<Longrightarrow> f x = g x"
1.1912    shows "(g \<longlongrightarrow> l) (at a within T)"
1.1913  proof (rule Lim_transform_eventually)
1.1914    show "eventually (\<lambda>x. f x = g x) (at a within T)"
1.1915 @@ -1678,7 +1779,8 @@
1.1916    show "(f \<longlongrightarrow> l) (at a within T)" by fact
1.1917  qed
1.1918
1.1919 -text\<open>A congruence rule allowing us to transform limits assuming not at point.\<close>
1.1920 +
1.1921 +text \<open>A congruence rule allowing us to transform limits assuming not at point.\<close>
1.1922
1.1923  (* FIXME: Only one congruence rule for tendsto can be used at a time! *)
1.1924
1.1925 @@ -1697,35 +1799,32 @@
1.1926    shows "((\<lambda>x. f x) \<longlongrightarrow> x) (at a) \<longleftrightarrow> ((g \<longlongrightarrow> y) (at a))"
1.1927    unfolding tendsto_def eventually_at_topological
1.1928    using assms by simp
1.1929 -text\<open>An unbounded sequence's inverse tends to 0\<close>
1.1930 -
1.1931 -lemma LIMSEQ_inverse_zero:
1.1932 -  "\<forall>r::real. \<exists>N. \<forall>n\<ge>N. r < X n \<Longrightarrow> (\<lambda>n. inverse (X n)) \<longlonglongrightarrow> 0"
1.1933 +
1.1934 +text \<open>An unbounded sequence's inverse tends to 0.\<close>
1.1935 +lemma LIMSEQ_inverse_zero: "\<forall>r::real. \<exists>N. \<forall>n\<ge>N. r < X n \<Longrightarrow> (\<lambda>n. inverse (X n)) \<longlonglongrightarrow> 0"
1.1936    apply (rule filterlim_compose[OF tendsto_inverse_0])
1.1937    apply (simp add: filterlim_at_infinity[OF order_refl] eventually_sequentially)
1.1938    apply (metis abs_le_D1 linorder_le_cases linorder_not_le)
1.1939    done
1.1940
1.1941 -text\<open>The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity\<close>
1.1942 -
1.1943 -lemma LIMSEQ_inverse_real_of_nat: "(%n. inverse(real(Suc n))) \<longlonglongrightarrow> 0"
1.1944 +text \<open>The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity.\<close>
1.1945 +lemma LIMSEQ_inverse_real_of_nat: "(\<lambda>n. inverse (real (Suc n))) \<longlonglongrightarrow> 0"
1.1946    by (metis filterlim_compose tendsto_inverse_0 filterlim_mono order_refl filterlim_Suc
1.1947 -            filterlim_compose[OF filterlim_real_sequentially] at_top_le_at_infinity)
1.1948 -
1.1949 -text\<open>The sequence @{term "r + 1/n"} tends to @{term r} as @{term n} tends to
1.1950 -infinity is now easily proved\<close>
1.1951 -
1.1953 -     "(%n. r + inverse(real(Suc n))) \<longlonglongrightarrow> r"
1.1954 +      filterlim_compose[OF filterlim_real_sequentially] at_top_le_at_infinity)
1.1955 +
1.1956 +text \<open>
1.1957 +  The sequence @{term "r + 1/n"} tends to @{term r} as @{term n} tends to
1.1958 +  infinity is now easily proved.
1.1959 +\<close>
1.1960 +
1.1961 +lemma LIMSEQ_inverse_real_of_nat_add: "(\<lambda>n. r + inverse (real (Suc n))) \<longlonglongrightarrow> r"
1.1962    using tendsto_add [OF tendsto_const LIMSEQ_inverse_real_of_nat] by auto
1.1963
1.1965 -     "(%n. r + -inverse(real(Suc n))) \<longlonglongrightarrow> r"
1.1966 +lemma LIMSEQ_inverse_real_of_nat_add_minus: "(\<lambda>n. r + -inverse (real (Suc n))) \<longlonglongrightarrow> r"
1.1967    using tendsto_add [OF tendsto_const tendsto_minus [OF LIMSEQ_inverse_real_of_nat]]
1.1968    by auto
1.1969
1.1971 -     "(%n. r*( 1 + -inverse(real(Suc n)))) \<longlonglongrightarrow> r"
1.1972 +lemma LIMSEQ_inverse_real_of_nat_add_minus_mult: "(\<lambda>n. r * (1 + - inverse (real (Suc n)))) \<longlonglongrightarrow> r"
1.1973    using tendsto_mult [OF tendsto_const LIMSEQ_inverse_real_of_nat_add_minus [of 1]]
1.1974    by auto
1.1975
1.1976 @@ -1735,46 +1834,57 @@
1.1977  lemma LIMSEQ_Suc_n_over_n: "(\<lambda>n. of_nat (Suc n) / of_nat n :: 'a :: real_normed_field) \<longlonglongrightarrow> 1"
1.1978  proof (rule Lim_transform_eventually)
1.1979    show "eventually (\<lambda>n. 1 + inverse (of_nat n :: 'a) = of_nat (Suc n) / of_nat n) sequentially"
1.1980 -    using eventually_gt_at_top[of "0::nat"] by eventually_elim (simp add: field_simps)
1.1981 +    using eventually_gt_at_top[of "0::nat"]
1.1982 +    by eventually_elim (simp add: field_simps)
1.1983    have "(\<lambda>n. 1 + inverse (of_nat n) :: 'a) \<longlonglongrightarrow> 1 + 0"
1.1984      by (intro tendsto_add tendsto_const lim_inverse_n)
1.1985 -  thus "(\<lambda>n. 1 + inverse (of_nat n) :: 'a) \<longlonglongrightarrow> 1" by simp
1.1986 +  then show "(\<lambda>n. 1 + inverse (of_nat n) :: 'a) \<longlonglongrightarrow> 1"
1.1987 +    by simp
1.1988  qed
1.1989
1.1990  lemma LIMSEQ_n_over_Suc_n: "(\<lambda>n. of_nat n / of_nat (Suc n) :: 'a :: real_normed_field) \<longlonglongrightarrow> 1"
1.1991  proof (rule Lim_transform_eventually)
1.1992    show "eventually (\<lambda>n. inverse (of_nat (Suc n) / of_nat n :: 'a) =
1.1993 -                        of_nat n / of_nat (Suc n)) sequentially"
1.1994 +      of_nat n / of_nat (Suc n)) sequentially"
1.1995      using eventually_gt_at_top[of "0::nat"]
1.1996      by eventually_elim (simp add: field_simps del: of_nat_Suc)
1.1997    have "(\<lambda>n. inverse (of_nat (Suc n) / of_nat n :: 'a)) \<longlonglongrightarrow> inverse 1"
1.1998      by (intro tendsto_inverse LIMSEQ_Suc_n_over_n) simp_all
1.1999 -  thus "(\<lambda>n. inverse (of_nat (Suc n) / of_nat n :: 'a)) \<longlonglongrightarrow> 1" by simp
1.2000 +  then show "(\<lambda>n. inverse (of_nat (Suc n) / of_nat n :: 'a)) \<longlonglongrightarrow> 1"
1.2001 +    by simp
1.2002  qed
1.2003
1.2004 +
1.2005  subsection \<open>Convergence on sequences\<close>
1.2006
1.2007  lemma convergent_cong:
1.2008    assumes "eventually (\<lambda>x. f x = g x) sequentially"
1.2009 -  shows   "convergent f \<longleftrightarrow> convergent g"
1.2010 -  unfolding convergent_def by (subst filterlim_cong[OF refl refl assms]) (rule refl)
1.2011 +  shows "convergent f \<longleftrightarrow> convergent g"
1.2012 +  unfolding convergent_def
1.2013 +  by (subst filterlim_cong[OF refl refl assms]) (rule refl)
1.2014
1.2015  lemma convergent_Suc_iff: "convergent (\<lambda>n. f (Suc n)) \<longleftrightarrow> convergent f"
1.2016    by (auto simp: convergent_def LIMSEQ_Suc_iff)
1.2017
1.2018  lemma convergent_ignore_initial_segment: "convergent (\<lambda>n. f (n + m)) = convergent f"
1.2019 -proof (induction m arbitrary: f)
1.2020 +proof (induct m arbitrary: f)
1.2021 +  case 0
1.2022 +  then show ?case by simp
1.2023 +next
1.2024    case (Suc m)
1.2025 -  have "convergent (\<lambda>n. f (n + Suc m)) \<longleftrightarrow> convergent (\<lambda>n. f (Suc n + m))" by simp
1.2026 -  also have "\<dots> \<longleftrightarrow> convergent (\<lambda>n. f (n + m))" by (rule convergent_Suc_iff)
1.2027 -  also have "\<dots> \<longleftrightarrow> convergent f" by (rule Suc)
1.2028 +  have "convergent (\<lambda>n. f (n + Suc m)) \<longleftrightarrow> convergent (\<lambda>n. f (Suc n + m))"
1.2029 +    by simp
1.2030 +  also have "\<dots> \<longleftrightarrow> convergent (\<lambda>n. f (n + m))"
1.2031 +    by (rule convergent_Suc_iff)
1.2032 +  also have "\<dots> \<longleftrightarrow> convergent f"
1.2033 +    by (rule Suc)
1.2034    finally show ?case .
1.2035 -qed simp_all
1.2036 +qed
1.2037
1.2039    fixes X Y :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2040    assumes "convergent (\<lambda>n. X n)"
1.2041 -  assumes "convergent (\<lambda>n. Y n)"
1.2042 +    and "convergent (\<lambda>n. Y n)"
1.2043    shows "convergent (\<lambda>n. X n + Y n)"
1.2044    using assms unfolding convergent_def by (blast intro: tendsto_add)
1.2045
1.2046 @@ -1783,9 +1893,14 @@
1.2047    assumes "\<And>i. i \<in> A \<Longrightarrow> convergent (\<lambda>n. X i n)"
1.2048    shows "convergent (\<lambda>n. \<Sum>i\<in>A. X i n)"
1.2049  proof (cases "finite A")
1.2050 -  case True from this and assms show ?thesis
1.2053 +  case True
1.2054 +  then show ?thesis
1.2055 +    using assms by (induct A set: finite) (simp_all add: convergent_const convergent_add)
1.2056 +next
1.2057 +  case False
1.2058 +  then show ?thesis
1.2059 +    by (simp add: convergent_const)
1.2060 +qed
1.2061
1.2062  lemma (in bounded_linear) convergent:
1.2063    assumes "convergent (\<lambda>n. X n)"
1.2064 @@ -1793,17 +1908,18 @@
1.2065    using assms unfolding convergent_def by (blast intro: tendsto)
1.2066
1.2067  lemma (in bounded_bilinear) convergent:
1.2068 -  assumes "convergent (\<lambda>n. X n)" and "convergent (\<lambda>n. Y n)"
1.2069 +  assumes "convergent (\<lambda>n. X n)"
1.2070 +    and "convergent (\<lambda>n. Y n)"
1.2071    shows "convergent (\<lambda>n. X n ** Y n)"
1.2072    using assms unfolding convergent_def by (blast intro: tendsto)
1.2073
1.2074 -lemma convergent_minus_iff:
1.2075 -  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2076 -  shows "convergent X \<longleftrightarrow> convergent (\<lambda>n. - X n)"
1.2078 -apply (auto dest: tendsto_minus)
1.2079 -apply (drule tendsto_minus, auto)
1.2080 -done
1.2081 +lemma convergent_minus_iff: "convergent X \<longleftrightarrow> convergent (\<lambda>n. - X n)"
1.2082 +  for X :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2083 +  apply (simp add: convergent_def)
1.2084 +  apply (auto dest: tendsto_minus)
1.2085 +  apply (drule tendsto_minus)
1.2086 +  apply auto
1.2087 +  done
1.2088
1.2089  lemma convergent_diff:
1.2090    fixes X Y :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2091 @@ -1814,57 +1930,64 @@
1.2092
1.2093  lemma convergent_norm:
1.2094    assumes "convergent f"
1.2095 -  shows   "convergent (\<lambda>n. norm (f n))"
1.2096 +  shows "convergent (\<lambda>n. norm (f n))"
1.2097  proof -
1.2098 -  from assms have "f \<longlonglongrightarrow> lim f" by (simp add: convergent_LIMSEQ_iff)
1.2099 -  hence "(\<lambda>n. norm (f n)) \<longlonglongrightarrow> norm (lim f)" by (rule tendsto_norm)
1.2100 -  thus ?thesis by (auto simp: convergent_def)
1.2101 +  from assms have "f \<longlonglongrightarrow> lim f"
1.2102 +    by (simp add: convergent_LIMSEQ_iff)
1.2103 +  then have "(\<lambda>n. norm (f n)) \<longlonglongrightarrow> norm (lim f)"
1.2104 +    by (rule tendsto_norm)
1.2105 +  then show ?thesis
1.2106 +    by (auto simp: convergent_def)
1.2107  qed
1.2108
1.2109  lemma convergent_of_real:
1.2110 -  "convergent f \<Longrightarrow> convergent (\<lambda>n. of_real (f n) :: 'a :: real_normed_algebra_1)"
1.2111 +  "convergent f \<Longrightarrow> convergent (\<lambda>n. of_real (f n) :: 'a::real_normed_algebra_1)"
1.2112    unfolding convergent_def by (blast intro!: tendsto_of_real)
1.2113
1.2115 -  "convergent (\<lambda>n. c + f n :: 'a :: real_normed_vector) \<longleftrightarrow> convergent f"
1.2116 +  "convergent (\<lambda>n. c + f n :: 'a::real_normed_vector) \<longleftrightarrow> convergent f"
1.2117  proof
1.2118    assume "convergent (\<lambda>n. c + f n)"
1.2119 -  from convergent_diff[OF this convergent_const[of c]] show "convergent f" by simp
1.2120 +  from convergent_diff[OF this convergent_const[of c]] show "convergent f"
1.2121 +    by simp
1.2122  next
1.2123    assume "convergent f"
1.2124 -  from convergent_add[OF convergent_const[of c] this] show "convergent (\<lambda>n. c + f n)" by simp
1.2125 +  from convergent_add[OF convergent_const[of c] this] show "convergent (\<lambda>n. c + f n)"
1.2126 +    by simp
1.2127  qed
1.2128
1.2130 -  "convergent (\<lambda>n. f n + c :: 'a :: real_normed_vector) \<longleftrightarrow> convergent f"
1.2131 +  "convergent (\<lambda>n. f n + c :: 'a::real_normed_vector) \<longleftrightarrow> convergent f"
1.2133
1.2134  lemma convergent_diff_const_right_iff:
1.2135 -  "convergent (\<lambda>n. f n - c :: 'a :: real_normed_vector) \<longleftrightarrow> convergent f"
1.2136 +  "convergent (\<lambda>n. f n - c :: 'a::real_normed_vector) \<longleftrightarrow> convergent f"
1.2138
1.2139  lemma convergent_mult:
1.2140    fixes X Y :: "nat \<Rightarrow> 'a::real_normed_field"
1.2141    assumes "convergent (\<lambda>n. X n)"
1.2142 -  assumes "convergent (\<lambda>n. Y n)"
1.2143 +    and "convergent (\<lambda>n. Y n)"
1.2144    shows "convergent (\<lambda>n. X n * Y n)"
1.2145    using assms unfolding convergent_def by (blast intro: tendsto_mult)
1.2146
1.2147  lemma convergent_mult_const_iff:
1.2148    assumes "c \<noteq> 0"
1.2149 -  shows   "convergent (\<lambda>n. c * f n :: 'a :: real_normed_field) \<longleftrightarrow> convergent f"
1.2150 +  shows "convergent (\<lambda>n. c * f n :: 'a::real_normed_field) \<longleftrightarrow> convergent f"
1.2151  proof
1.2152    assume "convergent (\<lambda>n. c * f n)"
1.2153    from assms convergent_mult[OF this convergent_const[of "inverse c"]]
1.2154      show "convergent f" by (simp add: field_simps)
1.2155  next
1.2156    assume "convergent f"
1.2157 -  from convergent_mult[OF convergent_const[of c] this] show "convergent (\<lambda>n. c * f n)" by simp
1.2158 +  from convergent_mult[OF convergent_const[of c] this] show "convergent (\<lambda>n. c * f n)"
1.2159 +    by simp
1.2160  qed
1.2161
1.2162  lemma convergent_mult_const_right_iff:
1.2163 +  fixes c :: "'a::real_normed_field"
1.2164    assumes "c \<noteq> 0"
1.2165 -  shows   "convergent (\<lambda>n. (f n :: 'a :: real_normed_field) * c) \<longleftrightarrow> convergent f"
1.2166 +  shows "convergent (\<lambda>n. f n * c) \<longleftrightarrow> convergent f"
1.2167    using convergent_mult_const_iff[OF assms, of f] by (simp add: mult_ac)
1.2168
1.2169  lemma convergent_imp_Bseq: "convergent f \<Longrightarrow> Bseq f"
1.2170 @@ -1874,60 +1997,66 @@
1.2171  text \<open>A monotone sequence converges to its least upper bound.\<close>
1.2172
1.2173  lemma LIMSEQ_incseq_SUP:
1.2174 -  fixes X :: "nat \<Rightarrow> 'a::{conditionally_complete_linorder, linorder_topology}"
1.2175 +  fixes X :: "nat \<Rightarrow> 'a::{conditionally_complete_linorder,linorder_topology}"
1.2176    assumes u: "bdd_above (range X)"
1.2177 -  assumes X: "incseq X"
1.2178 +    and X: "incseq X"
1.2179    shows "X \<longlonglongrightarrow> (SUP i. X i)"
1.2180    by (rule order_tendstoI)
1.2181 -     (auto simp: eventually_sequentially u less_cSUP_iff intro: X[THEN incseqD] less_le_trans cSUP_lessD[OF u])
1.2182 +    (auto simp: eventually_sequentially u less_cSUP_iff
1.2183 +      intro: X[THEN incseqD] less_le_trans cSUP_lessD[OF u])
1.2184
1.2185  lemma LIMSEQ_decseq_INF:
1.2186    fixes X :: "nat \<Rightarrow> 'a::{conditionally_complete_linorder, linorder_topology}"
1.2187    assumes u: "bdd_below (range X)"
1.2188 -  assumes X: "decseq X"
1.2189 +    and X: "decseq X"
1.2190    shows "X \<longlonglongrightarrow> (INF i. X i)"
1.2191    by (rule order_tendstoI)
1.2192 -     (auto simp: eventually_sequentially u cINF_less_iff intro: X[THEN decseqD] le_less_trans less_cINF_D[OF u])
1.2193 -
1.2194 -text\<open>Main monotonicity theorem\<close>
1.2195 -
1.2196 -lemma Bseq_monoseq_convergent: "Bseq X \<Longrightarrow> monoseq X \<Longrightarrow> convergent (X::nat\<Rightarrow>real)"
1.2197 -  by (auto simp: monoseq_iff convergent_def intro: LIMSEQ_decseq_INF LIMSEQ_incseq_SUP dest: Bseq_bdd_above Bseq_bdd_below)
1.2198 -
1.2199 -lemma Bseq_mono_convergent: "Bseq X \<Longrightarrow> (\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n) \<Longrightarrow> convergent (X::nat\<Rightarrow>real)"
1.2200 +     (auto simp: eventually_sequentially u cINF_less_iff
1.2201 +       intro: X[THEN decseqD] le_less_trans less_cINF_D[OF u])
1.2202 +
1.2203 +text \<open>Main monotonicity theorem.\<close>
1.2204 +
1.2205 +lemma Bseq_monoseq_convergent: "Bseq X \<Longrightarrow> monoseq X \<Longrightarrow> convergent X"
1.2206 +  for X :: "nat \<Rightarrow> real"
1.2207 +  by (auto simp: monoseq_iff convergent_def intro: LIMSEQ_decseq_INF LIMSEQ_incseq_SUP
1.2208 +      dest: Bseq_bdd_above Bseq_bdd_below)
1.2209 +
1.2210 +lemma Bseq_mono_convergent: "Bseq X \<Longrightarrow> (\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n) \<Longrightarrow> convergent X"
1.2211 +  for X :: "nat \<Rightarrow> real"
1.2212    by (auto intro!: Bseq_monoseq_convergent incseq_imp_monoseq simp: incseq_def)
1.2213
1.2214 -lemma monoseq_imp_convergent_iff_Bseq: "monoseq (f :: nat \<Rightarrow> real) \<Longrightarrow> convergent f \<longleftrightarrow> Bseq f"
1.2215 +lemma monoseq_imp_convergent_iff_Bseq: "monoseq f \<Longrightarrow> convergent f \<longleftrightarrow> Bseq f"
1.2216 +  for f :: "nat \<Rightarrow> real"
1.2217    using Bseq_monoseq_convergent[of f] convergent_imp_Bseq[of f] by blast
1.2218
1.2219  lemma Bseq_monoseq_convergent'_inc:
1.2220 -  "Bseq (\<lambda>n. f (n + M) :: real) \<Longrightarrow> (\<And>m n. M \<le> m \<Longrightarrow> m \<le> n \<Longrightarrow> f m \<le> f n) \<Longrightarrow> convergent f"
1.2221 +  fixes f :: "nat \<Rightarrow> real"
1.2222 +  shows "Bseq (\<lambda>n. f (n + M)) \<Longrightarrow> (\<And>m n. M \<le> m \<Longrightarrow> m \<le> n \<Longrightarrow> f m \<le> f n) \<Longrightarrow> convergent f"
1.2223    by (subst convergent_ignore_initial_segment [symmetric, of _ M])
1.2224       (auto intro!: Bseq_monoseq_convergent simp: monoseq_def)
1.2225
1.2226  lemma Bseq_monoseq_convergent'_dec:
1.2227 -  "Bseq (\<lambda>n. f (n + M) :: real) \<Longrightarrow> (\<And>m n. M \<le> m \<Longrightarrow> m \<le> n \<Longrightarrow> f m \<ge> f n) \<Longrightarrow> convergent f"
1.2228 +  fixes f :: "nat \<Rightarrow> real"
1.2229 +  shows "Bseq (\<lambda>n. f (n + M)) \<Longrightarrow> (\<And>m n. M \<le> m \<Longrightarrow> m \<le> n \<Longrightarrow> f m \<ge> f n) \<Longrightarrow> convergent f"
1.2230    by (subst convergent_ignore_initial_segment [symmetric, of _ M])
1.2231 -     (auto intro!: Bseq_monoseq_convergent simp: monoseq_def)
1.2232 -
1.2233 -lemma Cauchy_iff:
1.2234 -  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2235 -  shows "Cauchy X \<longleftrightarrow> (\<forall>e>0. \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e)"
1.2236 +    (auto intro!: Bseq_monoseq_convergent simp: monoseq_def)
1.2237 +
1.2238 +lemma Cauchy_iff: "Cauchy X \<longleftrightarrow> (\<forall>e>0. \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e)"
1.2239 +  for X :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2240    unfolding Cauchy_def dist_norm ..
1.2241
1.2242 -lemma CauchyI:
1.2243 -  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2244 -  shows "(\<And>e. 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e) \<Longrightarrow> Cauchy X"
1.2246 -
1.2247 -lemma CauchyD:
1.2248 -  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2249 -  shows "\<lbrakk>Cauchy X; 0 < e\<rbrakk> \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e"
1.2251 +lemma CauchyI: "(\<And>e. 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e) \<Longrightarrow> Cauchy X"
1.2252 +  for X :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2253 +  by (simp add: Cauchy_iff)
1.2254 +
1.2255 +lemma CauchyD: "Cauchy X \<Longrightarrow> 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e"
1.2256 +  for X :: "nat \<Rightarrow> 'a::real_normed_vector"
1.2257 +  by (simp add: Cauchy_iff)
1.2258
1.2259  lemma incseq_convergent:
1.2260    fixes X :: "nat \<Rightarrow> real"
1.2261 -  assumes "incseq X" and "\<forall>i. X i \<le> B"
1.2262 +  assumes "incseq X"
1.2263 +    and "\<forall>i. X i \<le> B"
1.2264    obtains L where "X \<longlonglongrightarrow> L" "\<forall>i. X i \<le> L"
1.2265  proof atomize_elim
1.2266    from incseq_bounded[OF assms] \<open>incseq X\<close> Bseq_monoseq_convergent[of X]
1.2267 @@ -1939,7 +2068,8 @@
1.2268
1.2269  lemma decseq_convergent:
1.2270    fixes X :: "nat \<Rightarrow> real"
1.2271 -  assumes "decseq X" and "\<forall>i. B \<le> X i"
1.2272 +  assumes "decseq X"
1.2273 +    and "\<forall>i. B \<le> X i"
1.2274    obtains L where "X \<longlonglongrightarrow> L" "\<forall>i. L \<le> X i"
1.2275  proof atomize_elim
1.2276    from decseq_bounded[OF assms] \<open>decseq X\<close> Bseq_monoseq_convergent[of X]
1.2277 @@ -1949,69 +2079,85 @@
1.2278      by (auto intro!: exI[of _ L] decseq_le)
1.2279  qed
1.2280
1.2281 +
1.2282  subsubsection \<open>Cauchy Sequences are Bounded\<close>
1.2283
1.2284 -text\<open>A Cauchy sequence is bounded -- this is the standard
1.2285 -  proof mechanization rather than the nonstandard proof\<close>
1.2286 -
1.2287 -lemma lemmaCauchy: "\<forall>n \<ge> M. norm (X M - X n) < (1::real)
1.2288 -          ==>  \<forall>n \<ge> M. norm (X n :: 'a::real_normed_vector) < 1 + norm (X M)"
1.2289 -apply (clarify, drule spec, drule (1) mp)
1.2290 -apply (simp only: norm_minus_commute)
1.2291 -apply (drule order_le_less_trans [OF norm_triangle_ineq2])
1.2292 -apply simp
1.2293 -done
1.2294 +text \<open>
1.2295 +  A Cauchy sequence is bounded -- this is the standard
1.2296 +  proof mechanization rather than the nonstandard proof.
1.2297 +\<close>
1.2298 +
1.2299 +lemma lemmaCauchy: "\<forall>n \<ge> M. norm (X M - X n) < (1::real) \<Longrightarrow>
1.2300 +  \<forall>n \<ge> M. norm (X n :: 'a::real_normed_vector) < 1 + norm (X M)"
1.2301 +  apply clarify
1.2302 +  apply (drule spec)
1.2303 +  apply (drule (1) mp)
1.2304 +  apply (simp only: norm_minus_commute)
1.2305 +  apply (drule order_le_less_trans [OF norm_triangle_ineq2])
1.2306 +  apply simp
1.2307 +  done
1.2308 +
1.2309
1.2310  subsection \<open>Power Sequences\<close>
1.2311
1.2312 -text\<open>The sequence @{term "x^n"} tends to 0 if @{term "0\<le>x"} and @{term
1.2313 -"x<1"}.  Proof will use (NS) Cauchy equivalence for convergence and
1.2314 -  also fact that bounded and monotonic sequence converges.\<close>
1.2315 -
1.2316 -lemma Bseq_realpow: "[| 0 \<le> (x::real); x \<le> 1 |] ==> Bseq (%n. x ^ n)"
1.2318 -apply (rule_tac x = 1 in exI)
1.2320 -apply (auto dest: power_mono)
1.2321 -done
1.2322 -
1.2323 -lemma monoseq_realpow: fixes x :: real shows "[| 0 \<le> x; x \<le> 1 |] ==> monoseq (%n. x ^ n)"
1.2324 -apply (clarify intro!: mono_SucI2)
1.2325 -apply (cut_tac n = n and N = "Suc n" and a = x in power_decreasing, auto)
1.2326 -done
1.2327 -
1.2328 -lemma convergent_realpow:
1.2329 -  "[| 0 \<le> (x::real); x \<le> 1 |] ==> convergent (%n. x ^ n)"
1.2330 -by (blast intro!: Bseq_monoseq_convergent Bseq_realpow monoseq_realpow)
1.2331 -
1.2332 -lemma LIMSEQ_inverse_realpow_zero: "1 < (x::real) \<Longrightarrow> (\<lambda>n. inverse (x ^ n)) \<longlonglongrightarrow> 0"
1.2333 +text \<open>
1.2334 +  The sequence @{term "x^n"} tends to 0 if @{term "0\<le>x"} and @{term
1.2335 +  "x<1"}.  Proof will use (NS) Cauchy equivalence for convergence and
1.2336 +  also fact that bounded and monotonic sequence converges.
1.2337 +\<close>
1.2338 +
1.2339 +lemma Bseq_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> Bseq (\<lambda>n. x ^ n)"
1.2340 +  for x :: real
1.2341 +  apply (simp add: Bseq_def)
1.2342 +  apply (rule_tac x = 1 in exI)
1.2343 +  apply (simp add: power_abs)
1.2344 +  apply (auto dest: power_mono)
1.2345 +  done
1.2346 +
1.2347 +lemma monoseq_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> monoseq (\<lambda>n. x ^ n)"
1.2348 +  for x :: real
1.2349 +  apply (clarify intro!: mono_SucI2)
1.2350 +  apply (cut_tac n = n and N = "Suc n" and a = x in power_decreasing)
1.2351 +     apply auto
1.2352 +  done
1.2353 +
1.2354 +lemma convergent_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> convergent (\<lambda>n. x ^ n)"
1.2355 +  for x :: real
1.2356 +  by (blast intro!: Bseq_monoseq_convergent Bseq_realpow monoseq_realpow)
1.2357 +
1.2358 +lemma LIMSEQ_inverse_realpow_zero: "1 < x \<Longrightarrow> (\<lambda>n. inverse (x ^ n)) \<longlonglongrightarrow> 0"
1.2359 +  for x :: real
1.2360    by (rule filterlim_compose[OF tendsto_inverse_0 filterlim_realpow_sequentially_gt1]) simp
1.2361
1.2362  lemma LIMSEQ_realpow_zero:
1.2363 -  "\<lbrakk>0 \<le> (x::real); x < 1\<rbrakk> \<Longrightarrow> (\<lambda>n. x ^ n) \<longlonglongrightarrow> 0"
1.2364 -proof cases
1.2365 -  assume "0 \<le> x" and "x \<noteq> 0"
1.2366 -  hence x0: "0 < x" by simp
1.2367 -  assume x1: "x < 1"
1.2368 -  from x0 x1 have "1 < inverse x"
1.2369 -    by (rule one_less_inverse)
1.2370 -  hence "(\<lambda>n. inverse (inverse x ^ n)) \<longlonglongrightarrow> 0"
1.2371 +  fixes x :: real
1.2372 +  assumes "0 \<le> x" "x < 1"
1.2373 +  shows "(\<lambda>n. x ^ n) \<longlonglongrightarrow> 0"
1.2374 +proof (cases "x = 0")
1.2375 +  case False
1.2376 +  with \<open>0 \<le> x\<close> have x0: "0 < x" by simp
1.2377 +  then have "1 < inverse x"
1.2378 +    using \<open>x < 1\<close> by (rule one_less_inverse)
1.2379 +  then have "(\<lambda>n. inverse (inverse x ^ n)) \<longlonglongrightarrow> 0"
1.2380      by (rule LIMSEQ_inverse_realpow_zero)
1.2381 -  thus ?thesis by (simp add: power_inverse)
1.2382 -qed (rule LIMSEQ_imp_Suc, simp)
1.2383 -
1.2384 -lemma LIMSEQ_power_zero:
1.2385 -  fixes x :: "'a::{real_normed_algebra_1}"
1.2386 -  shows "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) \<longlonglongrightarrow> 0"
1.2387 -apply (drule LIMSEQ_realpow_zero [OF norm_ge_zero])
1.2388 -apply (simp only: tendsto_Zfun_iff, erule Zfun_le)
1.2389 -apply (simp add: power_abs norm_power_ineq)
1.2390 -done
1.2391 +  then show ?thesis by (simp add: power_inverse)
1.2392 +next
1.2393 +  case True
1.2394 +  show ?thesis
1.2395 +    by (rule LIMSEQ_imp_Suc) (simp add: True)
1.2396 +qed
1.2397 +
1.2398 +lemma LIMSEQ_power_zero: "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) \<longlonglongrightarrow> 0"
1.2399 +  for x :: "'a::real_normed_algebra_1"
1.2400 +  apply (drule LIMSEQ_realpow_zero [OF norm_ge_zero])
1.2401 +  apply (simp only: tendsto_Zfun_iff, erule Zfun_le)
1.2402 +  apply (simp add: power_abs norm_power_ineq)
1.2403 +  done
1.2404
1.2405  lemma LIMSEQ_divide_realpow_zero: "1 < x \<Longrightarrow> (\<lambda>n. a / (x ^ n) :: real) \<longlonglongrightarrow> 0"
1.2406    by (rule tendsto_divide_0 [OF tendsto_const filterlim_realpow_sequentially_gt1]) simp
1.2407
1.2408 -text\<open>Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}\<close>
1.2409 +text \<open>Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}.\<close>
1.2410
1.2411  lemma LIMSEQ_rabs_realpow_zero: "\<bar>c\<bar> < 1 \<Longrightarrow> (\<lambda>n. \<bar>c\<bar> ^ n :: real) \<longlonglongrightarrow> 0"
1.2412    by (rule LIMSEQ_realpow_zero [OF abs_ge_zero])
1.2413 @@ -2022,92 +2168,81 @@
1.2414
1.2415  subsection \<open>Limits of Functions\<close>
1.2416
1.2417 -lemma LIM_eq:
1.2418 -  fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
1.2419 -  shows "f \<midarrow>a\<rightarrow> L =
1.2420 -     (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)"
1.2421 -by (simp add: LIM_def dist_norm)
1.2422 +lemma LIM_eq: "f \<midarrow>a\<rightarrow> L = (\<forall>r>0. \<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r)"
1.2423 +  for a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
1.2424 +  by (simp add: LIM_def dist_norm)
1.2425
1.2426  lemma LIM_I:
1.2427 -  fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
1.2428 -  shows "(!!r. 0<r ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)
1.2429 -      ==> f \<midarrow>a\<rightarrow> L"
1.2431 -
1.2432 -lemma LIM_D:
1.2433 -  fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
1.2434 -  shows "[| f \<midarrow>a\<rightarrow> L; 0<r |]
1.2435 -      ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r"
1.2437 -
1.2438 -lemma LIM_offset:
1.2439 -  fixes a :: "'a::real_normed_vector"
1.2440 -  shows "f \<midarrow>a\<rightarrow> L \<Longrightarrow> (\<lambda>x. f (x + k)) \<midarrow>(a - k)\<rightarrow> L"
1.2441 -  unfolding filtermap_at_shift[symmetric, of a k] filterlim_def filtermap_filtermap by simp
1.2442 -
1.2443 -lemma LIM_offset_zero:
1.2444 -  fixes a :: "'a::real_normed_vector"
1.2445 -  shows "f \<midarrow>a\<rightarrow> L \<Longrightarrow> (\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L"
1.2447 -
1.2448 -lemma LIM_offset_zero_cancel:
1.2449 -  fixes a :: "'a::real_normed_vector"
1.2450 -  shows "(\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L \<Longrightarrow> f \<midarrow>a\<rightarrow> L"
1.2451 -by (drule_tac k="- a" in LIM_offset, simp)
1.2452 -
1.2453 -lemma LIM_offset_zero_iff:
1.2454 -  fixes f :: "'a :: real_normed_vector \<Rightarrow> _"
1.2455 -  shows  "f \<midarrow>a\<rightarrow> L \<longleftrightarrow> (\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L"
1.2456 +  "(\<And>r. 0 < r \<Longrightarrow> \<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r) \<Longrightarrow> f \<midarrow>a\<rightarrow> L"
1.2457 +  for a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
1.2458 +  by (simp add: LIM_eq)
1.2459 +
1.2460 +lemma LIM_D: "f \<midarrow>a\<rightarrow> L \<Longrightarrow> 0 < r \<Longrightarrow> \<exists>s>0.\<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r"
1.2461 +  for a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
1.2462 +  by (simp add: LIM_eq)
1.2463 +
1.2464 +lemma LIM_offset: "f \<midarrow>a\<rightarrow> L \<Longrightarrow> (\<lambda>x. f (x + k)) \<midarrow>(a - k)\<rightarrow> L"
1.2465 +  for a :: "'a::real_normed_vector"
1.2466 +  by (simp add: filtermap_at_shift[symmetric, of a k] filterlim_def filtermap_filtermap)
1.2467 +
1.2468 +lemma LIM_offset_zero: "f \<midarrow>a\<rightarrow> L \<Longrightarrow> (\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L"
1.2469 +  for a :: "'a::real_normed_vector"
1.2470 +  by (drule LIM_offset [where k = a]) (simp add: add.commute)
1.2471 +
1.2472 +lemma LIM_offset_zero_cancel: "(\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L \<Longrightarrow> f \<midarrow>a\<rightarrow> L"
1.2473 +  for a :: "'a::real_normed_vector"
1.2474 +  by (drule LIM_offset [where k = "- a"]) simp
1.2475 +
1.2476 +lemma LIM_offset_zero_iff: "f \<midarrow>a\<rightarrow> L \<longleftrightarrow> (\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L"
1.2477 +  for f :: "'a :: real_normed_vector \<Rightarrow> _"
1.2478    using LIM_offset_zero_cancel[of f a L] LIM_offset_zero[of f L a] by auto
1.2479
1.2480 -lemma LIM_zero:
1.2481 -  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
1.2482 -  shows "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. f x - l) \<longlongrightarrow> 0) F"
1.2483 -unfolding tendsto_iff dist_norm by simp
1.2484 +lemma LIM_zero: "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. f x - l) \<longlongrightarrow> 0) F"
1.2485 +  for f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
1.2486 +  unfolding tendsto_iff dist_norm by simp
1.2487
1.2488  lemma LIM_zero_cancel:
1.2489    fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
1.2490    shows "((\<lambda>x. f x - l) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> l) F"
1.2491  unfolding tendsto_iff dist_norm by simp
1.2492
1.2493 -lemma LIM_zero_iff:
1.2494 -  fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
1.2495 -  shows "((\<lambda>x. f x - l) \<longlongrightarrow> 0) F = (f \<longlongrightarrow> l) F"
1.2496 -unfolding tendsto_iff dist_norm by simp
1.2497 +lemma LIM_zero_iff: "((\<lambda>x. f x - l) \<longlongrightarrow> 0) F = (f \<longlongrightarrow> l) F"
1.2498 +  for f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
1.2499 +  unfolding tendsto_iff dist_norm by simp
1.2500
1.2501  lemma LIM_imp_LIM:
1.2502    fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
1.2503    fixes g :: "'a::topological_space \<Rightarrow> 'c::real_normed_vector"
1.2504    assumes f: "f \<midarrow>a\<rightarrow> l"
1.2505 -  assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
1.2506 +    and le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
1.2507    shows "g \<midarrow>a\<rightarrow> m"
1.2508 -  by (rule metric_LIM_imp_LIM [OF f],
1.2509 -    simp add: dist_norm le)
1.2510 +  by (rule metric_LIM_imp_LIM [OF f]) (simp add: dist_norm le)
1.2511
1.2512  lemma LIM_equal2:
1.2513    fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
1.2514 -  assumes 1: "0 < R"
1.2515 -  assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
1.2516 +  assumes "0 < R"
1.2517 +    and "\<And>x. x \<noteq> a \<Longrightarrow> norm (x - a) < R \<Longrightarrow> f x = g x"
1.2518    shows "g \<midarrow>a\<rightarrow> l \<Longrightarrow> f \<midarrow>a\<rightarrow> l"
1.2519 -by (rule metric_LIM_equal2 [OF 1 2], simp_all add: dist_norm)
1.2520 +  by (rule metric_LIM_equal2 [OF assms]) (simp_all add: dist_norm)
1.2521
1.2522  lemma LIM_compose2:
1.2523    fixes a :: "'a::real_normed_vector"
1.2524    assumes f: "f \<midarrow>a\<rightarrow> b"
1.2525 -  assumes g: "g \<midarrow>b\<rightarrow> c"
1.2526 -  assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
1.2527 +    and g: "g \<midarrow>b\<rightarrow> c"
1.2528 +    and inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
1.2529    shows "(\<lambda>x. g (f x)) \<midarrow>a\<rightarrow> c"
1.2530 -by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
1.2531 +  by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
1.2532
1.2533  lemma real_LIM_sandwich_zero:
1.2534    fixes f g :: "'a::topological_space \<Rightarrow> real"
1.2535    assumes f: "f \<midarrow>a\<rightarrow> 0"
1.2536 -  assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
1.2537 -  assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
1.2538 +    and 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
1.2539 +    and 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
1.2540    shows "g \<midarrow>a\<rightarrow> 0"
1.2541  proof (rule LIM_imp_LIM [OF f]) (* FIXME: use tendsto_sandwich *)
1.2542 -  fix x assume x: "x \<noteq> a"
1.2543 -  have "norm (g x - 0) = g x" by (simp add: 1 x)
1.2544 +  fix x
1.2545 +  assume x: "x \<noteq> a"
1.2546 +  with 1 have "norm (g x - 0) = g x" by simp
1.2547    also have "g x \<le> f x" by (rule 2 [OF x])
1.2548    also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
1.2549    also have "\<bar>f x\<bar> = norm (f x - 0)" by simp
1.2550 @@ -2117,61 +2252,50 @@
1.2551
1.2552  subsection \<open>Continuity\<close>
1.2553
1.2554 -lemma LIM_isCont_iff:
1.2555 -  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
1.2556 -  shows "(f \<midarrow>a\<rightarrow> f a) = ((\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> f a)"
1.2557 -by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
1.2558 -
1.2559 -lemma isCont_iff:
1.2560 -  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
1.2561 -  shows "isCont f x = (\<lambda>h. f (x + h)) \<midarrow>0\<rightarrow> f x"
1.2562 -by (simp add: isCont_def LIM_isCont_iff)
1.2563 +lemma LIM_isCont_iff: "(f \<midarrow>a\<rightarrow> f a) = ((\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> f a)"
1.2564 +  for f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
1.2565 +  by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
1.2566 +
1.2567 +lemma isCont_iff: "isCont f x = (\<lambda>h. f (x + h)) \<midarrow>0\<rightarrow> f x"
1.2568 +  for f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
1.2569 +  by (simp add: isCont_def LIM_isCont_iff)
1.2570
1.2571  lemma isCont_LIM_compose2:
1.2572    fixes a :: "'a::real_normed_vector"
1.2573    assumes f [unfolded isCont_def]: "isCont f a"
1.2574 -  assumes g: "g \<midarrow>f a\<rightarrow> l"
1.2575 -  assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
1.2576 +    and g: "g \<midarrow>f a\<rightarrow> l"
1.2577 +    and inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
1.2578    shows "(\<lambda>x. g (f x)) \<midarrow>a\<rightarrow> l"
1.2579 -by (rule LIM_compose2 [OF f g inj])
1.2580 -
1.2581 -
1.2582 -lemma isCont_norm [simp]:
1.2583 -  fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.2584 -  shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a"
1.2585 +  by (rule LIM_compose2 [OF f g inj])
1.2586 +
1.2587 +lemma isCont_norm [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a"
1.2588 +  for f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.2589    by (fact continuous_norm)
1.2590
1.2591 -lemma isCont_rabs [simp]:
1.2592 -  fixes f :: "'a::t2_space \<Rightarrow> real"
1.2593 -  shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. \<bar>f x\<bar>) a"
1.2594 +lemma isCont_rabs [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. \<bar>f x\<bar>) a"
1.2595 +  for f :: "'a::t2_space \<Rightarrow> real"
1.2596    by (fact continuous_rabs)
1.2597
1.2599 -  fixes f :: "'a::t2_space \<Rightarrow> 'b::topological_monoid_add"
1.2600 -  shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
1.2601 +lemma isCont_add [simp]: "isCont f a \<Longrightarrow> isCont g a \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
1.2602 +  for f :: "'a::t2_space \<Rightarrow> 'b::topological_monoid_add"
1.2604
1.2605 -lemma isCont_minus [simp]:
1.2606 -  fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.2607 -  shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
1.2608 +lemma isCont_minus [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
1.2609 +  for f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.2610    by (fact continuous_minus)
1.2611
1.2612 -lemma isCont_diff [simp]:
1.2613 -  fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.2614 -  shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
1.2615 +lemma isCont_diff [simp]: "isCont f a \<Longrightarrow> isCont g a \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
1.2616 +  for f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
1.2617    by (fact continuous_diff)
1.2618
1.2619 -lemma isCont_mult [simp]:
1.2620 -  fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_algebra"
1.2621 -  shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x * g x) a"
1.2622 +lemma isCont_mult [simp]: "isCont f a \<Longrightarrow> isCont g a \<Longrightarrow> isCont (\<lambda>x. f x * g x) a"
1.2623 +  for f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_algebra"
1.2624    by (fact continuous_mult)
1.2625
1.2626 -lemma (in bounded_linear) isCont:
1.2627 -  "isCont g a \<Longrightarrow> isCont (\<lambda>x. f (g x)) a"
1.2628 +lemma (in bounded_linear) isCont: "isCont g a \<Longrightarrow> isCont (\<lambda>x. f (g x)) a"
1.2629    by (fact continuous)
1.2630
1.2631 -lemma (in bounded_bilinear) isCont:
1.2632 -  "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x ** g x) a"
1.2633 +lemma (in bounded_bilinear) isCont: "isCont f a \<Longrightarrow> isCont g a \<Longrightarrow> isCont (\<lambda>x. f x ** g x) a"
1.2634    by (fact continuous)
1.2635
1.2636  lemmas isCont_scaleR [simp] =
1.2637 @@ -2180,16 +2304,15 @@
1.2638  lemmas isCont_of_real [simp] =
1.2639    bounded_linear.isCont [OF bounded_linear_of_real]
1.2640
1.2641 -lemma isCont_power [simp]:
1.2642 -  fixes f :: "'a::t2_space \<Rightarrow> 'b::{power,real_normed_algebra}"
1.2643 -  shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. f x ^ n) a"
1.2644 +lemma isCont_power [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. f x ^ n) a"
1.2645 +  for f :: "'a::t2_space \<Rightarrow> 'b::{power,real_normed_algebra}"
1.2646    by (fact continuous_power)
1.2647
1.2648 -lemma isCont_setsum [simp]:
1.2649 -  fixes f :: "'a \<Rightarrow> 'b::t2_space \<Rightarrow> 'c::topological_comm_monoid_add"
1.2650 -  shows "\<forall>i\<in>A. isCont (f i) a \<Longrightarrow> isCont (\<lambda>x. \<Sum>i\<in>A. f i x) a"
1.2651 +lemma isCont_setsum [simp]: "\<forall>i\<in>A. isCont (f i) a \<Longrightarrow> isCont (\<lambda>x. \<Sum>i\<in>A. f i x) a"
1.2652 +  for f :: "'a \<Rightarrow> 'b::t2_space \<Rightarrow> 'c::topological_comm_monoid_add"
1.2653    by (auto intro: continuous_setsum)
1.2654
1.2655 +
1.2656  subsection \<open>Uniform Continuity\<close>
1.2657
1.2658  lemma uniformly_continuous_on_def:
1.2659 @@ -2200,37 +2323,39 @@
1.2660      uniformity_dist filterlim_INF filterlim_principal eventually_inf_principal
1.2661    by (force simp: Ball_def uniformity_dist[symmetric] eventually_uniformity_metric)
1.2662
1.2663 -abbreviation isUCont :: "['a::metric_space \<Rightarrow> 'b::metric_space] \<Rightarrow> bool" where
1.2664 -  "isUCont f \<equiv> uniformly_continuous_on UNIV f"
1.2665 -
1.2666 -lemma isUCont_def: "isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. dist x y < s \<longrightarrow> dist (f x) (f y) < r)"
1.2667 +abbreviation isUCont :: "['a::metric_space \<Rightarrow> 'b::metric_space] \<Rightarrow> bool"
1.2668 +  where "isUCont f \<equiv> uniformly_continuous_on UNIV f"
1.2669 +
1.2670 +lemma isUCont_def: "isUCont f \<longleftrightarrow> (\<forall>r>0. \<exists>s>0. \<forall>x y. dist x y < s \<longrightarrow> dist (f x) (f y) < r)"
1.2671    by (auto simp: uniformly_continuous_on_def dist_commute)
1.2672
1.2673 -lemma isUCont_isCont: "isUCont f ==> isCont f x"
1.2674 +lemma isUCont_isCont: "isUCont f \<Longrightarrow> isCont f x"
1.2675    by (drule uniformly_continuous_imp_continuous) (simp add: continuous_on_eq_continuous_at)
1.2676
1.2677  lemma uniformly_continuous_on_Cauchy:
1.2678 -  fixes f::"'a::metric_space \<Rightarrow> 'b::metric_space"
1.2679 +  fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space"
1.2680    assumes "uniformly_continuous_on S f" "Cauchy X" "\<And>n. X n \<in> S"
1.2681    shows "Cauchy (\<lambda>n. f (X n))"
1.2682    using assms
1.2683 -  unfolding uniformly_continuous_on_def
1.2684 -  apply -
1.2685 +  apply (simp only: uniformly_continuous_on_def)
1.2686    apply (rule metric_CauchyI)
1.2687 -  apply (drule_tac x=e in spec, safe)
1.2688 -  apply (drule_tac e=d in metric_CauchyD, safe)
1.2689 -  apply (rule_tac x=M in exI, simp)
1.2690 +  apply (drule_tac x=e in spec)
1.2691 +  apply safe
1.2692 +  apply (drule_tac e=d in metric_CauchyD)
1.2693 +   apply safe
1.2694 +  apply (rule_tac x=M in exI)
1.2695 +  apply simp
1.2696    done
1.2697
1.2698 -lemma isUCont_Cauchy:
1.2699 -  "\<lbrakk>isUCont f; Cauchy X\<rbrakk> \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
1.2700 +lemma isUCont_Cauchy: "isUCont f \<Longrightarrow> Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
1.2701    by (rule uniformly_continuous_on_Cauchy[where S=UNIV and f=f]) simp_all
1.2702
1.2703  lemma (in bounded_linear) isUCont: "isUCont f"
1.2704 -unfolding isUCont_def dist_norm
1.2705 +  unfolding isUCont_def dist_norm
1.2706  proof (intro allI impI)
1.2707 -  fix r::real assume r: "0 < r"
1.2708 -  obtain K where K: "0 < K" and norm_le: "\<And>x. norm (f x) \<le> norm x * K"
1.2709 +  fix r :: real
1.2710 +  assume r: "0 < r"
1.2711 +  obtain K where K: "0 < K" and norm_le: "norm (f x) \<le> norm x * K" for x
1.2712      using pos_bounded by blast
1.2713    show "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
1.2714    proof (rule exI, safe)
1.2715 @@ -2246,7 +2371,7 @@
1.2716  qed
1.2717
1.2718  lemma (in bounded_linear) Cauchy: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
1.2719 -by (rule isUCont [THEN isUCont_Cauchy])
1.2720 +  by (rule isUCont [THEN isUCont_Cauchy])
1.2721
1.2722  lemma LIM_less_bound:
1.2723    fixes f :: "real \<Rightarrow> real"
1.2724 @@ -2268,16 +2393,21 @@
1.2725  proof -
1.2726    have "incseq f" unfolding incseq_Suc_iff by fact
1.2727    have "decseq g" unfolding decseq_Suc_iff by fact
1.2728 -
1.2729 -  { fix n
1.2730 -    from \<open>decseq g\<close> have "g n \<le> g 0" by (rule decseqD) simp
1.2731 -    with \<open>\<forall>n. f n \<le> g n\<close>[THEN spec, of n] have "f n \<le> g 0" by auto }
1.2732 +  have "f n \<le> g 0" for n
1.2733 +  proof -
1.2734 +    from \<open>decseq g\<close> have "g n \<le> g 0"
1.2735 +      by (rule decseqD) simp
1.2736 +    with \<open>\<forall>n. f n \<le> g n\<close>[THEN spec, of n] show ?thesis
1.2737 +      by auto
1.2738 +  qed
1.2739    then obtain u where "f \<longlonglongrightarrow> u" "\<forall>i. f i \<le> u"
1.2740      using incseq_convergent[OF \<open>incseq f\<close>] by auto
1.2741 -  moreover
1.2742 -  { fix n
1.2743 +  moreover have "f 0 \<le> g n" for n
1.2744 +  proof -
1.2745      from \<open>incseq f\<close> have "f 0 \<le> f n" by (rule incseqD) simp
1.2746 -    with \<open>\<forall>n. f n \<le> g n\<close>[THEN spec, of n] have "f 0 \<le> g n" by simp }
1.2747 +    with \<open>\<forall>n. f n \<le> g n\<close>[THEN spec, of n] show ?thesis
1.2748 +      by simp
1.2749 +  qed
1.2750    then obtain l where "g \<longlonglongrightarrow> l" "\<forall>i. l \<le> g i"
1.2751      using decseq_convergent[OF \<open>decseq g\<close>] by auto
1.2752    moreover note LIMSEQ_unique[OF assms(4) tendsto_diff[OF \<open>f \<longlonglongrightarrow> u\<close> \<open>g \<longlonglongrightarrow> l\<close>]]
1.2753 @@ -2287,8 +2417,8 @@
1.2754  lemma Bolzano[consumes 1, case_names trans local]:
1.2755    fixes P :: "real \<Rightarrow> real \<Rightarrow> bool"
1.2756    assumes [arith]: "a \<le> b"
1.2757 -  assumes trans: "\<And>a b c. \<lbrakk>P a b; P b c; a \<le> b; b \<le> c\<rbrakk> \<Longrightarrow> P a c"
1.2758 -  assumes local: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> P a b"
1.2759 +    and trans: "\<And>a b c. P a b \<Longrightarrow> P b c \<Longrightarrow> a \<le> b \<Longrightarrow> b \<le> c \<Longrightarrow> P a c"
1.2760 +    and local: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> \<exists>d>0. \<forall>a b. a \<le> x \<and> x \<le> b \<and> b - a < d \<longrightarrow> P a b"
1.2761    shows "P a b"
1.2762  proof -
1.2763    define bisect where "bisect =
1.2764 @@ -2298,57 +2428,73 @@
1.2765      and u[simp]: "u 0 = b" "\<And>n. u (Suc n) = (if P (l n) ((l n + u n) / 2) then u n else (l n + u n) / 2)"
1.2766      by (simp_all add: l_def u_def bisect_def split: prod.split)
1.2767
1.2768 -  { fix n have "l n \<le> u n" by (induct n) auto } note this[simp]
1.2769 +  have [simp]: "l n \<le> u n" for n by (induct n) auto
1.2770
1.2771    have "\<exists>x. ((\<forall>n. l n \<le> x) \<and> l \<longlonglongrightarrow> x) \<and> ((\<forall>n. x \<le> u n) \<and> u \<longlonglongrightarrow> x)"
1.2772    proof (safe intro!: nested_sequence_unique)
1.2773 -    fix n show "l n \<le> l (Suc n)" "u (Suc n) \<le> u n" by (induct n) auto
1.2774 +    show "l n \<le> l (Suc n)" "u (Suc n) \<le> u n" for n
1.2775 +      by (induct n) auto
1.2776    next
1.2777 -    { fix n have "l n - u n = (a - b) / 2^n" by (induct n) (auto simp: field_simps) }
1.2778 -    then show "(\<lambda>n. l n - u n) \<longlonglongrightarrow> 0" by (simp add: LIMSEQ_divide_realpow_zero)
1.2779 +    have "l n - u n = (a - b) / 2^n" for n
1.2780 +      by (induct n) (auto simp: field_simps)
1.2781 +    then show "(\<lambda>n. l n - u n) \<longlonglongrightarrow> 0"
1.2782 +      by (simp add: LIMSEQ_divide_realpow_zero)
1.2783    qed fact
1.2784 -  then obtain x where x: "\<And>n. l n \<le> x" "\<And>n. x \<le> u n" and "l \<longlonglongrightarrow> x" "u \<longlonglongrightarrow> x" by auto
1.2785 -  obtain d where "0 < d" and d: "\<And>a b. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> b - a < d \<Longrightarrow> P a b"
1.2786 +  then obtain x where x: "\<And>n. l n \<le> x" "\<And>n. x \<le> u n" and "l \<longlonglongrightarrow> x" "u \<longlonglongrightarrow> x"
1.2787 +    by auto
1.2788 +  obtain d where "0 < d" and d: "a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> b - a < d \<Longrightarrow> P a b" for a b
1.2789      using \<open>l 0 \<le> x\<close> \<open>x \<le> u 0\<close> local[of x] by auto
1.2790
1.2791    show "P a b"
1.2792    proof (rule ccontr)
1.2793      assume "\<not> P a b"
1.2794 -    { fix n have "\<not> P (l n) (u n)"
1.2795 -      proof (induct n)
1.2796 -        case (Suc n) with trans[of "l n" "(l n + u n) / 2" "u n"] show ?case by auto
1.2797 -      qed (simp add: \<open>\<not> P a b\<close>) }
1.2798 +    have "\<not> P (l n) (u n)" for n
1.2799 +    proof (induct n)
1.2800 +      case 0
1.2801 +      then show ?case
1.2802 +        by (simp add: \<open>\<not> P a b\<close>)
1.2803 +    next
1.2804 +      case (Suc n)
1.2805 +      with trans[of "l n" "(l n + u n) / 2" "u n"] show ?case
1.2806 +        by auto
1.2807 +    qed
1.2808      moreover
1.2809 -    { have "eventually (\<lambda>n. x - d / 2 < l n) sequentially"
1.2810 +    {
1.2811 +      have "eventually (\<lambda>n. x - d / 2 < l n) sequentially"
1.2812          using \<open>0 < d\<close> \<open>l \<longlonglongrightarrow> x\<close> by (intro order_tendstoD[of _ x]) auto
1.2813        moreover have "eventually (\<lambda>n. u n < x + d / 2) sequentially"
1.2814          using \<open>0 < d\<close> \<open>u \<longlonglongrightarrow> x\<close> by (intro order_tendstoD[of _ x]) auto
1.2815        ultimately have "eventually (\<lambda>n. P (l n) (u n)) sequentially"
1.2816        proof eventually_elim
1.2817 -        fix n assume "x - d / 2 < l n" "u n < x + d / 2"
1.2818 +        case (elim n)
1.2819          from add_strict_mono[OF this] have "u n - l n < d" by simp
1.2820          with x show "P (l n) (u n)" by (rule d)
1.2821 -      qed }
1.2822 +      qed
1.2823 +    }
1.2824      ultimately show False by simp
1.2825    qed
1.2826  qed
1.2827
1.2828  lemma compact_Icc[simp, intro]: "compact {a .. b::real}"
1.2829  proof (cases "a \<le> b", rule compactI)
1.2830 -  fix C assume C: "a \<le> b" "\<forall>t\<in>C. open t" "{a..b} \<subseteq> \<Union>C"
1.2831 +  fix C
1.2832 +  assume C: "a \<le> b" "\<forall>t\<in>C. open t" "{a..b} \<subseteq> \<Union>C"
1.2833    define T where "T = {a .. b}"
1.2834    from C(1,3) show "\<exists>C'\<subseteq>C. finite C' \<and> {a..b} \<subseteq> \<Union>C'"
1.2835    proof (induct rule: Bolzano)
1.2836      case (trans a b c)
1.2837 -    then have *: "{a .. c} = {a .. b} \<union> {b .. c}" by auto
1.2838 -    from trans obtain C1 C2 where "C1\<subseteq>C \<and> finite C1 \<and> {a..b} \<subseteq> \<Union>C1" "C2\<subseteq>C \<and> finite C2 \<and> {b..c} \<subseteq> \<Union>C2"
1.2839 -      by (auto simp: *)
1.2840 +    then have *: "{a..c} = {a..b} \<union> {b..c}"
1.2841 +      by auto
1.2842 +    with trans obtain C1 C2
1.2843 +      where "C1\<subseteq>C" "finite C1" "{a..b} \<subseteq> \<Union>C1" "C2\<subseteq>C" "finite C2" "{b..c} \<subseteq> \<Union>C2"
1.2844 +      by auto
1.2845      with trans show ?case
1.2846        unfolding * by (intro exI[of _ "C1 \<union> C2"]) auto
1.2847    next
1.2848      case (local x)
1.2849 -    then have "x \<in> \<Union>C" using C by auto
1.2850 -    with C(2) obtain c where "x \<in> c" "open c" "c \<in> C" by auto
1.2851 +    with C have "x \<in> \<Union>C" by auto
1.2852 +    with C(2) obtain c where "x \<in> c" "open c" "c \<in> C"
1.2853 +      by auto
1.2854      then obtain e where "0 < e" "{x - e <..< x + e} \<subseteq> c"
1.2855        by (auto simp: open_dist dist_real_def subset_eq Ball_def abs_less_iff)
1.2856      with \<open>c \<in> C\<close> show ?case
1.2857 @@ -2378,17 +2524,18 @@
1.2858  qed
1.2859
1.2860  lemma open_Collect_positive:
1.2861 - fixes f :: "'a::t2_space \<Rightarrow> real"
1.2862 - assumes f: "continuous_on s f"
1.2863 - shows "\<exists>A. open A \<and> A \<inter> s = {x\<in>s. 0 < f x}"
1.2864 - using continuous_on_open_invariant[THEN iffD1, OF f, rule_format, of "{0 <..}"]
1.2865 - by (auto simp: Int_def field_simps)
1.2866 +  fixes f :: "'a::t2_space \<Rightarrow> real"
1.2867 +  assumes f: "continuous_on s f"
1.2868 +  shows "\<exists>A. open A \<and> A \<inter> s = {x\<in>s. 0 < f x}"
1.2869 +  using continuous_on_open_invariant[THEN iffD1, OF f, rule_format, of "{0 <..}"]
1.2870 +  by (auto simp: Int_def field_simps)
1.2871
1.2872  lemma open_Collect_less_Int:
1.2873 - fixes f g :: "'a::t2_space \<Rightarrow> real"
1.2874 - assumes f: "continuous_on s f" and g: "continuous_on s g"
1.2875 - shows "\<exists>A. open A \<and> A \<inter> s = {x\<in>s. f x < g x}"
1.2876 - using open_Collect_positive[OF continuous_on_diff[OF g f]] by (simp add: field_simps)
1.2877 +  fixes f g :: "'a::t2_space \<Rightarrow> real"
1.2878 +  assumes f: "continuous_on s f"
1.2879 +    and g: "continuous_on s g"
1.2880 +  shows "\<exists>A. open A \<and> A \<inter> s = {x\<in>s. f x < g x}"
1.2881 +  using open_Collect_positive[OF continuous_on_diff[OF g f]] by (simp add: field_simps)
1.2882
1.2883
1.2884  subsection \<open>Boundedness of continuous functions\<close>
1.2885 @@ -2399,14 +2546,14 @@
1.2886    fixes f :: "real \<Rightarrow> 'a::linorder_topology"
1.2887    shows "a \<le> b \<Longrightarrow> \<forall>x::real. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
1.2888      \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M) \<and> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)"
1.2889 -  using continuous_attains_sup[of "{a .. b}" f]
1.2890 +  using continuous_attains_sup[of "{a..b}" f]
1.2891    by (auto simp add: continuous_at_imp_continuous_on Ball_def Bex_def)
1.2892
1.2893  lemma isCont_eq_Lb:
1.2894    fixes f :: "real \<Rightarrow> 'a::linorder_topology"
1.2895    shows "a \<le> b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
1.2896      \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> M \<le> f x) \<and> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)"
1.2897 -  using continuous_attains_inf[of "{a .. b}" f]
1.2898 +  using continuous_attains_inf[of "{a..b}" f]
1.2899    by (auto simp add: continuous_at_imp_continuous_on Ball_def Bex_def)
1.2900
1.2901  lemma isCont_bounded:
1.2902 @@ -2421,21 +2568,23 @@
1.2903    using isCont_eq_Ub[of a b f] by auto
1.2904
1.2905  (*HOL style here: object-level formulations*)
1.2906 -lemma IVT_objl: "(f(a::real) \<le> (y::real) & y \<le> f(b) & a \<le> b &
1.2907 -      (\<forall>x. a \<le> x & x \<le> b --> isCont f x))
1.2908 -      --> (\<exists>x. a \<le> x & x \<le> b & f(x) = y)"
1.2909 +lemma IVT_objl:
1.2910 +  "(f a \<le> y \<and> y \<le> f b \<and> a \<le> b \<and> (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x)) \<longrightarrow>
1.2911 +    (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = y)"
1.2912 +  for a y :: real
1.2913    by (blast intro: IVT)
1.2914
1.2915 -lemma IVT2_objl: "(f(b::real) \<le> (y::real) & y \<le> f(a) & a \<le> b &
1.2916 -      (\<forall>x. a \<le> x & x \<le> b --> isCont f x))
1.2917 -      --> (\<exists>x. a \<le> x & x \<le> b & f(x) = y)"
1.2918 +lemma IVT2_objl:
1.2919 +  "(f b \<le> y \<and> y \<le> f a \<and> a \<le> b \<and> (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x)) \<longrightarrow>
1.2920 +    (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = y)"
1.2921 +  for b y :: real
1.2922    by (blast intro: IVT2)
1.2923
1.2924  lemma isCont_Lb_Ub:
1.2925    fixes f :: "real \<Rightarrow> real"
1.2926    assumes "a \<le> b" "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x"
1.2927    shows "\<exists>L M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> L \<le> f x \<and> f x \<le> M) \<and>
1.2928 -               (\<forall>y. L \<le> y \<and> y \<le> M \<longrightarrow> (\<exists>x. a \<le> x \<and> x \<le> b \<and> (f x = y)))"
1.2929 +    (\<forall>y. L \<le> y \<and> y \<le> M \<longrightarrow> (\<exists>x. a \<le> x \<and> x \<le> b \<and> (f x = y)))"
1.2930  proof -
1.2931    obtain M where M: "a \<le> M" "M \<le> b" "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> f M"
1.2932      using isCont_eq_Ub[OF assms] by auto
1.2933 @@ -2446,22 +2595,26 @@
1.2934      apply (rule_tac x="f L" in exI)
1.2935      apply (rule_tac x="f M" in exI)
1.2936      apply (cases "L \<le> M")
1.2937 -    apply (simp, metis order_trans)
1.2938 -    apply (simp, metis order_trans)
1.2939 +     apply simp
1.2940 +     apply (metis order_trans)
1.2941 +    apply simp
1.2942 +    apply (metis order_trans)
1.2943      done
1.2944  qed
1.2945
1.2946
1.2947 -text\<open>Continuity of inverse function\<close>
1.2948 +text \<open>Continuity of inverse function.\<close>
1.2949
1.2950  lemma isCont_inverse_function:
1.2951    fixes f g :: "real \<Rightarrow> real"
1.2952    assumes d: "0 < d"
1.2953 -      and inj: "\<forall>z. \<bar>z-x\<bar> \<le> d \<longrightarrow> g (f z) = z"
1.2954 -      and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d \<longrightarrow> isCont f z"
1.2955 +    and inj: "\<forall>z. \<bar>z-x\<bar> \<le> d \<longrightarrow> g (f z) = z"
1.2956 +    and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d \<longrightarrow> isCont f z"
1.2957    shows "isCont g (f x)"
1.2958  proof -
1.2959 -  let ?A = "f (x - d)" and ?B = "f (x + d)" and ?D = "{x - d..x + d}"
1.2960 +  let ?A = "f (x - d)"
1.2961 +  let ?B = "f (x + d)"
1.2962 +  let ?D = "{x - d..x + d}"
1.2963
1.2964    have f: "continuous_on ?D f"
1.2965      using cont by (intro continuous_at_imp_continuous_on ballI) auto
1.2966 @@ -2483,45 +2636,42 @@
1.2967  qed
1.2968
1.2969  lemma isCont_inverse_function2:
1.2970 -  fixes f g :: "real \<Rightarrow> real" shows
1.2971 -  "\<lbrakk>a < x; x < b;
1.2972 -    \<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> g (f z) = z;
1.2973 -    \<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> isCont f z\<rbrakk>
1.2974 -   \<Longrightarrow> isCont g (f x)"
1.2975 -apply (rule isCont_inverse_function
1.2976 -       [where f=f and d="min (x - a) (b - x)"])
1.2978 -done
1.2979 +  fixes f g :: "real \<Rightarrow> real"
1.2980 +  shows
1.2981 +    "a < x \<Longrightarrow> x < b \<Longrightarrow>
1.2982 +      \<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> g (f z) = z \<Longrightarrow>
1.2983 +      \<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> isCont f z \<Longrightarrow> isCont g (f x)"
1.2984 +  apply (rule isCont_inverse_function [where f=f and d="min (x - a) (b - x)"])
1.2985 +  apply (simp_all add: abs_le_iff)
1.2986 +  done
1.2987
1.2988  (* need to rename second isCont_inverse *)
1.2989 -
1.2990  lemma isCont_inv_fun:
1.2991    fixes f g :: "real \<Rightarrow> real"
1.2992 -  shows "[| 0 < d; \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z;
1.2993 -         \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |]
1.2994 -      ==> isCont g (f x)"
1.2995 -by (rule isCont_inverse_function)
1.2996 -
1.2997 -text\<open>Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110\<close>
1.2998 -lemma LIM_fun_gt_zero:
1.2999 -  fixes f :: "real \<Rightarrow> real"
1.3000 -  shows "f \<midarrow>c\<rightarrow> l \<Longrightarrow> 0 < l \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> 0 < f x)"
1.3001 -apply (drule (1) LIM_D, clarify)
1.3002 -apply (rule_tac x = s in exI)
1.3004 -done
1.3005 -
1.3006 -lemma LIM_fun_less_zero:
1.3007 -  fixes f :: "real \<Rightarrow> real"
1.3008 -  shows "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l < 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x < 0)"
1.3009 -apply (drule LIM_D [where r="-l"], simp, clarify)
1.3010 -apply (rule_tac x = s in exI)
1.3012 -done
1.3013 -
1.3014 -lemma LIM_fun_not_zero:
1.3015 -  fixes f :: "real \<Rightarrow> real"
1.3016 -  shows "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x \<noteq> 0)"
1.3017 +  shows "0 < d \<Longrightarrow> (\<forall>z. \<bar>z - x\<bar> \<le> d \<longrightarrow> g (f z) = z) \<Longrightarrow>
1.3018 +    \<forall>z. \<bar>z - x\<bar> \<le> d \<longrightarrow> isCont f z \<Longrightarrow> isCont g (f x)"
1.3019 +  by (rule isCont_inverse_function)
1.3020 +
1.3021 +text \<open>Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110.\<close>
1.3022 +lemma LIM_fun_gt_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> 0 < l \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> 0 < f x)"
1.3023 +  for f :: "real \<Rightarrow> real"
1.3024 +  apply (drule (1) LIM_D)
1.3025 +  apply clarify
1.3026 +  apply (rule_tac x = s in exI)
1.3027 +  apply (simp add: abs_less_iff)
1.3028 +  done
1.3029 +
1.3030 +lemma LIM_fun_less_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l < 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x < 0)"
1.3031 +  for f :: "real \<Rightarrow> real"
1.3032 +  apply (drule LIM_D [where r="-l"])
1.3033 +   apply simp
1.3034 +  apply clarify
1.3035 +  apply (rule_tac x = s in exI)
1.3036 +  apply (simp add: abs_less_iff)
1.3037 +  done
1.3038 +
1.3039 +lemma LIM_fun_not_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x \<noteq> 0)"
1.3040 +  for f :: "real \<Rightarrow> real"
1.3041    using LIM_fun_gt_zero[of f l c] LIM_fun_less_zero[of f l c] by (auto simp add: neq_iff)
1.3042
1.3043  end
```