src/HOL/Limits.thy
changeset 72219 0f38c96a0a74
parent 71837 dca11678c495
child 72220 bb29e4eb938d
equal deleted inserted replaced
72211:a6cbf8ce979e 72219:0f38c96a0a74
   112 qed
   112 qed
   113 
   113 
   114 subsubsection \<open>Bounded Sequences\<close>
   114 subsubsection \<open>Bounded Sequences\<close>
   115 
   115 
   116 lemma BseqI': "(\<And>n. norm (X n) \<le> K) \<Longrightarrow> Bseq X"
   116 lemma BseqI': "(\<And>n. norm (X n) \<le> K) \<Longrightarrow> Bseq X"
   117   by (intro BfunI) (auto simp: eventually_sequentially)
       
   118 
       
   119 lemma BseqI2': "\<forall>n\<ge>N. norm (X n) \<le> K \<Longrightarrow> Bseq X"
       
   120   by (intro BfunI) (auto simp: eventually_sequentially)
   117   by (intro BfunI) (auto simp: eventually_sequentially)
   121 
   118 
   122 lemma Bseq_def: "Bseq X \<longleftrightarrow> (\<exists>K>0. \<forall>n. norm (X n) \<le> K)"
   119 lemma Bseq_def: "Bseq X \<longleftrightarrow> (\<exists>K>0. \<forall>n. norm (X n) \<le> K)"
   123   unfolding Bfun_def eventually_sequentially
   120   unfolding Bfun_def eventually_sequentially
   124 proof safe
   121 proof safe
   341   by (intro Bseq_eq_bounded[of X B "X 0"]) (auto simp: decseq_def)
   338   by (intro Bseq_eq_bounded[of X B "X 0"]) (auto simp: decseq_def)
   342 
   339 
   343 
   340 
   344 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Polynomal function extremal theorem, from HOL Light\<close>
   341 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Polynomal function extremal theorem, from HOL Light\<close>
   345 
   342 
   346 lemma polyfun_extremal_lemma: (*COMPLEX_POLYFUN_EXTREMAL_LEMMA in HOL Light*)
   343 lemma polyfun_extremal_lemma: 
   347     fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
   344     fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
   348   assumes "0 < e"
   345   assumes "0 < e"
   349     shows "\<exists>M. \<forall>z. M \<le> norm(z) \<longrightarrow> norm (\<Sum>i\<le>n. c(i) * z^i) \<le> e * norm(z) ^ (Suc n)"
   346     shows "\<exists>M. \<forall>z. M \<le> norm(z) \<longrightarrow> norm (\<Sum>i\<le>n. c(i) * z^i) \<le> e * norm(z) ^ (Suc n)"
   350 proof (induct n)
   347 proof (induct n)
   351   case 0 with assms
   348   case 0 with assms
   384     shows "eventually (\<lambda>z. norm (\<Sum>i\<le>n. c(i) * z^i) \<ge> B) at_infinity"
   381     shows "eventually (\<lambda>z. norm (\<Sum>i\<le>n. c(i) * z^i) \<ge> B) at_infinity"
   385 using kn
   382 using kn
   386 proof (induction n)
   383 proof (induction n)
   387   case 0
   384   case 0
   388   then show ?case
   385   then show ?case
   389     using k  by simp
   386     using k by simp
   390 next
   387 next
   391   case (Suc m)
   388   case (Suc m)
   392   let ?even = ?case
   389   show ?case
   393   show ?even
       
   394   proof (cases "c (Suc m) = 0")
   390   proof (cases "c (Suc m) = 0")
   395     case True
   391     case True
   396     then show ?even using Suc k
   392     then show ?thesis using Suc k
   397       by auto (metis antisym_conv less_eq_Suc_le not_le)
   393       by auto (metis antisym_conv less_eq_Suc_le not_le)
   398   next
   394   next
   399     case False
   395     case False
   400     then obtain M where M:
   396     then obtain M where M:
   401           "\<And>z. M \<le> norm z \<Longrightarrow> norm (\<Sum>i\<le>m. c i * z^i) \<le> norm (c (Suc m)) / 2 * norm z ^ Suc m"
   397           "\<And>z. M \<le> norm z \<Longrightarrow> norm (\<Sum>i\<le>m. c i * z^i) \<le> norm (c (Suc m)) / 2 * norm z ^ Suc m"
   422         apply (auto simp: eventually_at_infinity)
   418         apply (auto simp: eventually_at_infinity)
   423         apply (rule *)
   419         apply (rule *)
   424         apply (simp add: field_simps norm_mult norm_power)
   420         apply (simp add: field_simps norm_mult norm_power)
   425         done
   421         done
   426     qed
   422     qed
   427     then show ?even
   423     then show ?thesis
   428       by (simp add: eventually_at_infinity)
   424       by (simp add: eventually_at_infinity)
   429   qed
   425   qed
   430 qed
   426 qed
   431 
   427 
   432 subsection \<open>Convergence to Zero\<close>
   428 subsection \<open>Convergence to Zero\<close>
  1524   unfolding filterlim_at_bot eventually_at_top_dense
  1520   unfolding filterlim_at_bot eventually_at_top_dense
  1525   by (metis leI less_minus_iff order_less_asym)
  1521   by (metis leI less_minus_iff order_less_asym)
  1526 
  1522 
  1527 lemma at_bot_mirror :
  1523 lemma at_bot_mirror :
  1528   shows "(at_bot::('a::{ordered_ab_group_add,linorder} filter)) = filtermap uminus at_top"
  1524   shows "(at_bot::('a::{ordered_ab_group_add,linorder} filter)) = filtermap uminus at_top"
  1529   apply (rule filtermap_fun_inverse[of uminus, symmetric])
  1525 proof (rule filtermap_fun_inverse[symmetric])
  1530   subgoal unfolding filterlim_at_top filterlim_at_bot eventually_at_bot_linorder using le_minus_iff by auto
  1526   show "filterlim uminus at_top (at_bot::'a filter)"
  1531   subgoal unfolding filterlim_at_bot eventually_at_top_linorder using minus_le_iff by auto
  1527     using eventually_at_bot_linorder filterlim_at_top le_minus_iff by force
  1532   by auto
  1528   show "filterlim uminus (at_bot::'a filter) at_top"
       
  1529     by (simp add: filterlim_at_bot minus_le_iff)
       
  1530 qed auto
  1533 
  1531 
  1534 lemma at_top_mirror :
  1532 lemma at_top_mirror :
  1535   shows "(at_top::('a::{ordered_ab_group_add,linorder} filter)) = filtermap uminus at_bot"
  1533   shows "(at_top::('a::{ordered_ab_group_add,linorder} filter)) = filtermap uminus at_bot"
  1536   apply (subst at_bot_mirror)
  1534   apply (subst at_bot_mirror)
  1537   by (auto simp: filtermap_filtermap)
  1535   by (auto simp: filtermap_filtermap)
  1990   assumes x[arith]: "1 < norm x"
  1988   assumes x[arith]: "1 < norm x"
  1991   shows "LIM n sequentially. x ^ n :> at_infinity"
  1989   shows "LIM n sequentially. x ^ n :> at_infinity"
  1992 proof (intro filterlim_at_infinity[THEN iffD2] allI impI)
  1990 proof (intro filterlim_at_infinity[THEN iffD2] allI impI)
  1993   fix y :: real
  1991   fix y :: real
  1994   assume "0 < y"
  1992   assume "0 < y"
  1995   have "0 < norm x - 1" by simp
  1993   obtain N :: nat where "y < real N * (norm x - 1)"
  1996   then obtain N :: nat where "y < real N * (norm x - 1)"
  1994     by (meson diff_gt_0_iff_gt reals_Archimedean3 x)
  1997     by (blast dest: reals_Archimedean3)
       
  1998   also have "\<dots> \<le> real N * (norm x - 1) + 1"
  1995   also have "\<dots> \<le> real N * (norm x - 1) + 1"
  1999     by simp
  1996     by simp
  2000   also have "\<dots> \<le> (norm x - 1 + 1) ^ N"
  1997   also have "\<dots> \<le> (norm x - 1 + 1) ^ N"
  2001     by (rule linear_plus_1_le_power) simp
  1998     by (rule linear_plus_1_le_power) simp
  2002   also have "\<dots> = norm x ^ N"
  1999   also have "\<dots> = norm x ^ N"
  2179 qed
  2176 qed
  2180 
  2177 
  2181 
  2178 
  2182 text \<open>A congruence rule allowing us to transform limits assuming not at point.\<close>
  2179 text \<open>A congruence rule allowing us to transform limits assuming not at point.\<close>
  2183 
  2180 
  2184 (* FIXME: Only one congruence rule for tendsto can be used at a time! *)
  2181 lemma Lim_cong_within [cong]:
  2185 
       
  2186 lemma Lim_cong_within(*[cong add]*):
       
  2187   assumes "a = b"
  2182   assumes "a = b"
  2188     and "x = y"
  2183     and "x = y"
  2189     and "S = T"
  2184     and "S = T"
  2190     and "\<And>x. x \<noteq> b \<Longrightarrow> x \<in> T \<Longrightarrow> f x = g x"
  2185     and "\<And>x. x \<noteq> b \<Longrightarrow> x \<in> T \<Longrightarrow> f x = g x"
  2191   shows "(f \<longlongrightarrow> x) (at a within S) \<longleftrightarrow> (g \<longlongrightarrow> y) (at b within T)"
  2186   shows "(f \<longlongrightarrow> x) (at a within S) \<longleftrightarrow> (g \<longlongrightarrow> y) (at b within T)"
  2192   unfolding tendsto_def eventually_at_topological
       
  2193   using assms by simp
       
  2194 
       
  2195 lemma Lim_cong_at(*[cong add]*):
       
  2196   assumes "a = b" "x = y"
       
  2197     and "\<And>x. x \<noteq> a \<Longrightarrow> f x = g x"
       
  2198   shows "((\<lambda>x. f x) \<longlongrightarrow> x) (at a) \<longleftrightarrow> ((g \<longlongrightarrow> y) (at a))"
       
  2199   unfolding tendsto_def eventually_at_topological
  2187   unfolding tendsto_def eventually_at_topological
  2200   using assms by simp
  2188   using assms by simp
  2201 
  2189 
  2202 text \<open>An unbounded sequence's inverse tends to 0.\<close>
  2190 text \<open>An unbounded sequence's inverse tends to 0.\<close>
  2203 lemma LIMSEQ_inverse_zero:
  2191 lemma LIMSEQ_inverse_zero:
  2961   fixes f :: "real \<Rightarrow> 'a::linorder_topology"
  2949   fixes f :: "real \<Rightarrow> 'a::linorder_topology"
  2962   shows "a \<le> b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
  2950   shows "a \<le> b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
  2963     \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M) \<and> (\<forall>N. N < M \<longrightarrow> (\<exists>x. a \<le> x \<and> x \<le> b \<and> N < f x))"
  2951     \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M) \<and> (\<forall>N. N < M \<longrightarrow> (\<exists>x. a \<le> x \<and> x \<le> b \<and> N < f x))"
  2964   using isCont_eq_Ub[of a b f] by auto
  2952   using isCont_eq_Ub[of a b f] by auto
  2965 
  2953 
  2966 (*HOL style here: object-level formulations*)
       
  2967 lemma IVT_objl:
       
  2968   "(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>
       
  2969     (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = y)"
       
  2970   for a y :: real
       
  2971   by (blast intro: IVT)
       
  2972 
       
  2973 lemma IVT2_objl:
       
  2974   "(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>
       
  2975     (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = y)"
       
  2976   for b y :: real
       
  2977   by (blast intro: IVT2)
       
  2978 
       
  2979 lemma isCont_Lb_Ub:
  2954 lemma isCont_Lb_Ub:
  2980   fixes f :: "real \<Rightarrow> real"
  2955   fixes f :: "real \<Rightarrow> real"
  2981   assumes "a \<le> b" "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x"
  2956   assumes "a \<le> b" "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x"
  2982   shows "\<exists>L M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> L \<le> f x \<and> f x \<le> M) \<and>
  2957   shows "\<exists>L M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> L \<le> f x \<and> f x \<le> M) \<and>
  2983     (\<forall>y. L \<le> y \<and> y \<le> M \<longrightarrow> (\<exists>x. a \<le> x \<and> x \<le> b \<and> (f x = y)))"
  2958     (\<forall>y. L \<le> y \<and> y \<le> M \<longrightarrow> (\<exists>x. a \<le> x \<and> x \<le> b \<and> (f x = y)))"