src/HOL/Analysis/Infinite_Products.thy
changeset 66277 512b0dc09061
child 68064 b249fab48c76
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Analysis/Infinite_Products.thy	Sat Jul 15 14:33:56 2017 +0100
     1.3 @@ -0,0 +1,479 @@
     1.4 +(*
     1.5 +  File:      HOL/Analysis/Infinite_Product.thy
     1.6 +  Author:    Manuel Eberl
     1.7 +
     1.8 +  Basic results about convergence and absolute convergence of infinite products
     1.9 +  and their connection to summability.
    1.10 +*)
    1.11 +section \<open>Infinite Products\<close>
    1.12 +theory Infinite_Products
    1.13 +  imports Complex_Main
    1.14 +begin
    1.15 +
    1.16 +lemma sum_le_prod:
    1.17 +  fixes f :: "'a \<Rightarrow> 'b :: linordered_semidom"
    1.18 +  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 0"
    1.19 +  shows   "sum f A \<le> (\<Prod>x\<in>A. 1 + f x)"
    1.20 +  using assms
    1.21 +proof (induction A rule: infinite_finite_induct)
    1.22 +  case (insert x A)
    1.23 +  from insert.hyps have "sum f A + f x * (\<Prod>x\<in>A. 1) \<le> (\<Prod>x\<in>A. 1 + f x) + f x * (\<Prod>x\<in>A. 1 + f x)"
    1.24 +    by (intro add_mono insert mult_left_mono prod_mono) (auto intro: insert.prems)
    1.25 +  with insert.hyps show ?case by (simp add: algebra_simps)
    1.26 +qed simp_all
    1.27 +
    1.28 +lemma prod_le_exp_sum:
    1.29 +  fixes f :: "'a \<Rightarrow> real"
    1.30 +  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 0"
    1.31 +  shows   "prod (\<lambda>x. 1 + f x) A \<le> exp (sum f A)"
    1.32 +  using assms
    1.33 +proof (induction A rule: infinite_finite_induct)
    1.34 +  case (insert x A)
    1.35 +  have "(1 + f x) * (\<Prod>x\<in>A. 1 + f x) \<le> exp (f x) * exp (sum f A)"
    1.36 +    using insert.prems by (intro mult_mono insert prod_nonneg exp_ge_add_one_self) auto
    1.37 +  with insert.hyps show ?case by (simp add: algebra_simps exp_add)
    1.38 +qed simp_all
    1.39 +
    1.40 +lemma lim_ln_1_plus_x_over_x_at_0: "(\<lambda>x::real. ln (1 + x) / x) \<midarrow>0\<rightarrow> 1"
    1.41 +proof (rule lhopital)
    1.42 +  show "(\<lambda>x::real. ln (1 + x)) \<midarrow>0\<rightarrow> 0"
    1.43 +    by (rule tendsto_eq_intros refl | simp)+
    1.44 +  have "eventually (\<lambda>x::real. x \<in> {-1/2<..<1/2}) (nhds 0)"
    1.45 +    by (rule eventually_nhds_in_open) auto
    1.46 +  hence *: "eventually (\<lambda>x::real. x \<in> {-1/2<..<1/2}) (at 0)"
    1.47 +    by (rule filter_leD [rotated]) (simp_all add: at_within_def)   
    1.48 +  show "eventually (\<lambda>x::real. ((\<lambda>x. ln (1 + x)) has_field_derivative inverse (1 + x)) (at x)) (at 0)"
    1.49 +    using * by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)
    1.50 +  show "eventually (\<lambda>x::real. ((\<lambda>x. x) has_field_derivative 1) (at x)) (at 0)"
    1.51 +    using * by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)
    1.52 +  show "\<forall>\<^sub>F x in at 0. x \<noteq> 0" by (auto simp: at_within_def eventually_inf_principal)
    1.53 +  show "(\<lambda>x::real. inverse (1 + x) / 1) \<midarrow>0\<rightarrow> 1"
    1.54 +    by (rule tendsto_eq_intros refl | simp)+
    1.55 +qed auto
    1.56 +
    1.57 +definition convergent_prod :: "(nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}) \<Rightarrow> bool" where
    1.58 +  "convergent_prod f \<longleftrightarrow> (\<exists>M L. (\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> L \<and> L \<noteq> 0)"
    1.59 +
    1.60 +lemma convergent_prod_altdef:
    1.61 +  fixes f :: "nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}"
    1.62 +  shows "convergent_prod f \<longleftrightarrow> (\<exists>M L. (\<forall>n\<ge>M. f n \<noteq> 0) \<and> (\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> L \<and> L \<noteq> 0)"
    1.63 +proof
    1.64 +  assume "convergent_prod f"
    1.65 +  then obtain M L where *: "(\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> L" "L \<noteq> 0"
    1.66 +    by (auto simp: convergent_prod_def)
    1.67 +  have "f i \<noteq> 0" if "i \<ge> M" for i
    1.68 +  proof
    1.69 +    assume "f i = 0"
    1.70 +    have **: "eventually (\<lambda>n. (\<Prod>i\<le>n. f (i+M)) = 0) sequentially"
    1.71 +      using eventually_ge_at_top[of "i - M"]
    1.72 +    proof eventually_elim
    1.73 +      case (elim n)
    1.74 +      with \<open>f i = 0\<close> and \<open>i \<ge> M\<close> show ?case
    1.75 +        by (auto intro!: bexI[of _ "i - M"] prod_zero)
    1.76 +    qed
    1.77 +    have "(\<lambda>n. (\<Prod>i\<le>n. f (i+M))) \<longlonglongrightarrow> 0"
    1.78 +      unfolding filterlim_iff
    1.79 +      by (auto dest!: eventually_nhds_x_imp_x intro!: eventually_mono[OF **])
    1.80 +    from tendsto_unique[OF _ this *(1)] and *(2)
    1.81 +      show False by simp
    1.82 +  qed
    1.83 +  with * show "(\<exists>M L. (\<forall>n\<ge>M. f n \<noteq> 0) \<and> (\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> L \<and> L \<noteq> 0)" 
    1.84 +    by blast
    1.85 +qed (auto simp: convergent_prod_def)
    1.86 +
    1.87 +definition abs_convergent_prod :: "(nat \<Rightarrow> _) \<Rightarrow> bool" where
    1.88 +  "abs_convergent_prod f \<longleftrightarrow> convergent_prod (\<lambda>i. 1 + norm (f i - 1))"
    1.89 +
    1.90 +lemma abs_convergent_prodI:
    1.91 +  assumes "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
    1.92 +  shows   "abs_convergent_prod f"
    1.93 +proof -
    1.94 +  from assms obtain L where L: "(\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1)) \<longlonglongrightarrow> L"
    1.95 +    by (auto simp: convergent_def)
    1.96 +  have "L \<ge> 1"
    1.97 +  proof (rule tendsto_le)
    1.98 +    show "eventually (\<lambda>n. (\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> 1) sequentially"
    1.99 +    proof (intro always_eventually allI)
   1.100 +      fix n
   1.101 +      have "(\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> (\<Prod>i\<le>n. 1)"
   1.102 +        by (intro prod_mono) auto
   1.103 +      thus "(\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> 1" by simp
   1.104 +    qed
   1.105 +  qed (use L in simp_all)
   1.106 +  hence "L \<noteq> 0" by auto
   1.107 +  with L show ?thesis unfolding abs_convergent_prod_def convergent_prod_def
   1.108 +    by (intro exI[of _ "0::nat"] exI[of _ L]) auto
   1.109 +qed
   1.110 +
   1.111 +lemma
   1.112 +  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,idom}"
   1.113 +  assumes "convergent_prod f"
   1.114 +  shows   convergent_prod_imp_convergent: "convergent (\<lambda>n. \<Prod>i\<le>n. f i)"
   1.115 +    and   convergent_prod_to_zero_iff:    "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<exists>i. f i = 0)"
   1.116 +proof -
   1.117 +  from assms obtain M L 
   1.118 +    where M: "\<And>n. n \<ge> M \<Longrightarrow> f n \<noteq> 0" and "(\<lambda>n. \<Prod>i\<le>n. f (i + M)) \<longlonglongrightarrow> L" and "L \<noteq> 0"
   1.119 +    by (auto simp: convergent_prod_altdef)
   1.120 +  note this(2)
   1.121 +  also have "(\<lambda>n. \<Prod>i\<le>n. f (i + M)) = (\<lambda>n. \<Prod>i=M..M+n. f i)"
   1.122 +    by (intro ext prod.reindex_bij_witness[of _ "\<lambda>n. n - M" "\<lambda>n. n + M"]) auto
   1.123 +  finally have "(\<lambda>n. (\<Prod>i<M. f i) * (\<Prod>i=M..M+n. f i)) \<longlonglongrightarrow> (\<Prod>i<M. f i) * L"
   1.124 +    by (intro tendsto_mult tendsto_const)
   1.125 +  also have "(\<lambda>n. (\<Prod>i<M. f i) * (\<Prod>i=M..M+n. f i)) = (\<lambda>n. (\<Prod>i\<in>{..<M}\<union>{M..M+n}. f i))"
   1.126 +    by (subst prod.union_disjoint) auto
   1.127 +  also have "(\<lambda>n. {..<M} \<union> {M..M+n}) = (\<lambda>n. {..n+M})" by auto
   1.128 +  finally have lim: "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f {..<M} * L" 
   1.129 +    by (rule LIMSEQ_offset)
   1.130 +  thus "convergent (\<lambda>n. \<Prod>i\<le>n. f i)"
   1.131 +    by (auto simp: convergent_def)
   1.132 +
   1.133 +  show "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<exists>i. f i = 0)"
   1.134 +  proof
   1.135 +    assume "\<exists>i. f i = 0"
   1.136 +    then obtain i where "f i = 0" by auto
   1.137 +    moreover with M have "i < M" by (cases "i < M") auto
   1.138 +    ultimately have "(\<Prod>i<M. f i) = 0" by auto
   1.139 +    with lim show "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0" by simp
   1.140 +  next
   1.141 +    assume "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0"
   1.142 +    from tendsto_unique[OF _ this lim] and \<open>L \<noteq> 0\<close>
   1.143 +    show "\<exists>i. f i = 0" by auto
   1.144 +  qed
   1.145 +qed
   1.146 +
   1.147 +lemma abs_convergent_prod_altdef:
   1.148 +  "abs_convergent_prod f \<longleftrightarrow> convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
   1.149 +proof
   1.150 +  assume "abs_convergent_prod f"
   1.151 +  thus "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
   1.152 +    by (auto simp: abs_convergent_prod_def intro!: convergent_prod_imp_convergent)
   1.153 +qed (auto intro: abs_convergent_prodI)
   1.154 +
   1.155 +lemma weierstrass_prod_ineq:
   1.156 +  fixes f :: "'a \<Rightarrow> real" 
   1.157 +  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<in> {0..1}"
   1.158 +  shows   "1 - sum f A \<le> (\<Prod>x\<in>A. 1 - f x)"
   1.159 +  using assms
   1.160 +proof (induction A rule: infinite_finite_induct)
   1.161 +  case (insert x A)
   1.162 +  from insert.hyps and insert.prems 
   1.163 +    have "1 - sum f A + f x * (\<Prod>x\<in>A. 1 - f x) \<le> (\<Prod>x\<in>A. 1 - f x) + f x * (\<Prod>x\<in>A. 1)"
   1.164 +    by (intro insert.IH add_mono mult_left_mono prod_mono) auto
   1.165 +  with insert.hyps show ?case by (simp add: algebra_simps)
   1.166 +qed simp_all
   1.167 +
   1.168 +lemma norm_prod_minus1_le_prod_minus1:
   1.169 +  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,comm_ring_1}"  
   1.170 +  shows "norm (prod (\<lambda>n. 1 + f n) A - 1) \<le> prod (\<lambda>n. 1 + norm (f n)) A - 1"
   1.171 +proof (induction A rule: infinite_finite_induct)
   1.172 +  case (insert x A)
   1.173 +  from insert.hyps have 
   1.174 +    "norm ((\<Prod>n\<in>insert x A. 1 + f n) - 1) = 
   1.175 +       norm ((\<Prod>n\<in>A. 1 + f n) - 1 + f x * (\<Prod>n\<in>A. 1 + f n))"
   1.176 +    by (simp add: algebra_simps)
   1.177 +  also have "\<dots> \<le> norm ((\<Prod>n\<in>A. 1 + f n) - 1) + norm (f x * (\<Prod>n\<in>A. 1 + f n))"
   1.178 +    by (rule norm_triangle_ineq)
   1.179 +  also have "norm (f x * (\<Prod>n\<in>A. 1 + f n)) = norm (f x) * (\<Prod>x\<in>A. norm (1 + f x))"
   1.180 +    by (simp add: prod_norm norm_mult)
   1.181 +  also have "(\<Prod>x\<in>A. norm (1 + f x)) \<le> (\<Prod>x\<in>A. norm (1::'a) + norm (f x))"
   1.182 +    by (intro prod_mono norm_triangle_ineq ballI conjI) auto
   1.183 +  also have "norm (1::'a) = 1" by simp
   1.184 +  also note insert.IH
   1.185 +  also have "(\<Prod>n\<in>A. 1 + norm (f n)) - 1 + norm (f x) * (\<Prod>x\<in>A. 1 + norm (f x)) =
   1.186 +               (\<Prod>n\<in>insert x A. 1 + norm (f n)) - 1"
   1.187 +    using insert.hyps by (simp add: algebra_simps)
   1.188 +  finally show ?case by - (simp_all add: mult_left_mono)
   1.189 +qed simp_all
   1.190 +
   1.191 +lemma convergent_prod_imp_ev_nonzero:
   1.192 +  fixes f :: "nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}"
   1.193 +  assumes "convergent_prod f"
   1.194 +  shows   "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
   1.195 +  using assms by (auto simp: eventually_at_top_linorder convergent_prod_altdef)
   1.196 +
   1.197 +lemma convergent_prod_imp_LIMSEQ:
   1.198 +  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_field}"
   1.199 +  assumes "convergent_prod f"
   1.200 +  shows   "f \<longlonglongrightarrow> 1"
   1.201 +proof -
   1.202 +  from assms obtain M L where L: "(\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> L" "\<And>n. n \<ge> M \<Longrightarrow> f n \<noteq> 0" "L \<noteq> 0"
   1.203 +    by (auto simp: convergent_prod_altdef)
   1.204 +  hence L': "(\<lambda>n. \<Prod>i\<le>Suc n. f (i+M)) \<longlonglongrightarrow> L" by (subst filterlim_sequentially_Suc)
   1.205 +  have "(\<lambda>n. (\<Prod>i\<le>Suc n. f (i+M)) / (\<Prod>i\<le>n. f (i+M))) \<longlonglongrightarrow> L / L"
   1.206 +    using L L' by (intro tendsto_divide) simp_all
   1.207 +  also from L have "L / L = 1" by simp
   1.208 +  also have "(\<lambda>n. (\<Prod>i\<le>Suc n. f (i+M)) / (\<Prod>i\<le>n. f (i+M))) = (\<lambda>n. f (n + Suc M))"
   1.209 +    using assms L by (auto simp: fun_eq_iff atMost_Suc)
   1.210 +  finally show ?thesis by (rule LIMSEQ_offset)
   1.211 +qed
   1.212 +
   1.213 +lemma abs_convergent_prod_imp_summable:
   1.214 +  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
   1.215 +  assumes "abs_convergent_prod f"
   1.216 +  shows "summable (\<lambda>i. norm (f i - 1))"
   1.217 +proof -
   1.218 +  from assms have "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))" 
   1.219 +    unfolding abs_convergent_prod_def by (rule convergent_prod_imp_convergent)
   1.220 +  then obtain L where L: "(\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1)) \<longlonglongrightarrow> L"
   1.221 +    unfolding convergent_def by blast
   1.222 +  have "convergent (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))"
   1.223 +  proof (rule Bseq_monoseq_convergent)
   1.224 +    have "eventually (\<lambda>n. (\<Prod>i\<le>n. 1 + norm (f i - 1)) < L + 1) sequentially"
   1.225 +      using L(1) by (rule order_tendstoD) simp_all
   1.226 +    hence "\<forall>\<^sub>F x in sequentially. norm (\<Sum>i\<le>x. norm (f i - 1)) \<le> L + 1"
   1.227 +    proof eventually_elim
   1.228 +      case (elim n)
   1.229 +      have "norm (\<Sum>i\<le>n. norm (f i - 1)) = (\<Sum>i\<le>n. norm (f i - 1))"
   1.230 +        unfolding real_norm_def by (intro abs_of_nonneg sum_nonneg) simp_all
   1.231 +      also have "\<dots> \<le> (\<Prod>i\<le>n. 1 + norm (f i - 1))" by (rule sum_le_prod) auto
   1.232 +      also have "\<dots> < L + 1" by (rule elim)
   1.233 +      finally show ?case by simp
   1.234 +    qed
   1.235 +    thus "Bseq (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))" by (rule BfunI)
   1.236 +  next
   1.237 +    show "monoseq (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))"
   1.238 +      by (rule mono_SucI1) auto
   1.239 +  qed
   1.240 +  thus "summable (\<lambda>i. norm (f i - 1))" by (simp add: summable_iff_convergent')
   1.241 +qed
   1.242 +
   1.243 +lemma summable_imp_abs_convergent_prod:
   1.244 +  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
   1.245 +  assumes "summable (\<lambda>i. norm (f i - 1))"
   1.246 +  shows   "abs_convergent_prod f"
   1.247 +proof (intro abs_convergent_prodI Bseq_monoseq_convergent)
   1.248 +  show "monoseq (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
   1.249 +    by (intro mono_SucI1) 
   1.250 +       (auto simp: atMost_Suc algebra_simps intro!: mult_nonneg_nonneg prod_nonneg)
   1.251 +next
   1.252 +  show "Bseq (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
   1.253 +  proof (rule Bseq_eventually_mono)
   1.254 +    show "eventually (\<lambda>n. norm (\<Prod>i\<le>n. 1 + norm (f i - 1)) \<le> 
   1.255 +            norm (exp (\<Sum>i\<le>n. norm (f i - 1)))) sequentially"
   1.256 +      by (intro always_eventually allI) (auto simp: abs_prod exp_sum intro!: prod_mono)
   1.257 +  next
   1.258 +    from assms have "(\<lambda>n. \<Sum>i\<le>n. norm (f i - 1)) \<longlonglongrightarrow> (\<Sum>i. norm (f i - 1))"
   1.259 +      using sums_def_le by blast
   1.260 +    hence "(\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1))) \<longlonglongrightarrow> exp (\<Sum>i. norm (f i - 1))"
   1.261 +      by (rule tendsto_exp)
   1.262 +    hence "convergent (\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1)))"
   1.263 +      by (rule convergentI)
   1.264 +    thus "Bseq (\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1)))"
   1.265 +      by (rule convergent_imp_Bseq)
   1.266 +  qed
   1.267 +qed
   1.268 +
   1.269 +lemma abs_convergent_prod_conv_summable:
   1.270 +  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
   1.271 +  shows "abs_convergent_prod f \<longleftrightarrow> summable (\<lambda>i. norm (f i - 1))"
   1.272 +  by (blast intro: abs_convergent_prod_imp_summable summable_imp_abs_convergent_prod)
   1.273 +
   1.274 +lemma abs_convergent_prod_imp_LIMSEQ:
   1.275 +  fixes f :: "nat \<Rightarrow> 'a :: {comm_ring_1,real_normed_div_algebra}"
   1.276 +  assumes "abs_convergent_prod f"
   1.277 +  shows   "f \<longlonglongrightarrow> 1"
   1.278 +proof -
   1.279 +  from assms have "summable (\<lambda>n. norm (f n - 1))"
   1.280 +    by (rule abs_convergent_prod_imp_summable)
   1.281 +  from summable_LIMSEQ_zero[OF this] have "(\<lambda>n. f n - 1) \<longlonglongrightarrow> 0"
   1.282 +    by (simp add: tendsto_norm_zero_iff)
   1.283 +  from tendsto_add[OF this tendsto_const[of 1]] show ?thesis by simp
   1.284 +qed
   1.285 +
   1.286 +lemma abs_convergent_prod_imp_ev_nonzero:
   1.287 +  fixes f :: "nat \<Rightarrow> 'a :: {comm_ring_1,real_normed_div_algebra}"
   1.288 +  assumes "abs_convergent_prod f"
   1.289 +  shows   "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
   1.290 +proof -
   1.291 +  from assms have "f \<longlonglongrightarrow> 1" 
   1.292 +    by (rule abs_convergent_prod_imp_LIMSEQ)
   1.293 +  hence "eventually (\<lambda>n. dist (f n) 1 < 1) at_top"
   1.294 +    by (auto simp: tendsto_iff)
   1.295 +  thus ?thesis by eventually_elim auto
   1.296 +qed
   1.297 +
   1.298 +lemma convergent_prod_offset:
   1.299 +  assumes "convergent_prod (\<lambda>n. f (n + m))"  
   1.300 +  shows   "convergent_prod f"
   1.301 +proof -
   1.302 +  from assms obtain M L where "(\<lambda>n. \<Prod>k\<le>n. f (k + (M + m))) \<longlonglongrightarrow> L" "L \<noteq> 0"
   1.303 +    by (auto simp: convergent_prod_def add.assoc)
   1.304 +  thus "convergent_prod f" unfolding convergent_prod_def by blast
   1.305 +qed
   1.306 +
   1.307 +lemma abs_convergent_prod_offset:
   1.308 +  assumes "abs_convergent_prod (\<lambda>n. f (n + m))"  
   1.309 +  shows   "abs_convergent_prod f"
   1.310 +  using assms unfolding abs_convergent_prod_def by (rule convergent_prod_offset)
   1.311 +
   1.312 +lemma convergent_prod_ignore_initial_segment:
   1.313 +  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_field}"
   1.314 +  assumes "convergent_prod f"
   1.315 +  shows   "convergent_prod (\<lambda>n. f (n + m))"
   1.316 +proof -
   1.317 +  from assms obtain M L 
   1.318 +    where L: "(\<lambda>n. \<Prod>k\<le>n. f (k + M)) \<longlonglongrightarrow> L" "L \<noteq> 0" and nz: "\<And>n. n \<ge> M \<Longrightarrow> f n \<noteq> 0"
   1.319 +    by (auto simp: convergent_prod_altdef)
   1.320 +  define C where "C = (\<Prod>k<m. f (k + M))"
   1.321 +  from nz have [simp]: "C \<noteq> 0" 
   1.322 +    by (auto simp: C_def)
   1.323 +
   1.324 +  from L(1) have "(\<lambda>n. \<Prod>k\<le>n+m. f (k + M)) \<longlonglongrightarrow> L" 
   1.325 +    by (rule LIMSEQ_ignore_initial_segment)
   1.326 +  also have "(\<lambda>n. \<Prod>k\<le>n+m. f (k + M)) = (\<lambda>n. C * (\<Prod>k\<le>n. f (k + M + m)))"
   1.327 +  proof (rule ext, goal_cases)
   1.328 +    case (1 n)
   1.329 +    have "{..n+m} = {..<m} \<union> {m..n+m}" by auto
   1.330 +    also have "(\<Prod>k\<in>\<dots>. f (k + M)) = C * (\<Prod>k=m..n+m. f (k + M))"
   1.331 +      unfolding C_def by (rule prod.union_disjoint) auto
   1.332 +    also have "(\<Prod>k=m..n+m. f (k + M)) = (\<Prod>k\<le>n. f (k + m + M))"
   1.333 +      by (intro ext prod.reindex_bij_witness[of _ "\<lambda>k. k + m" "\<lambda>k. k - m"]) auto
   1.334 +    finally show ?case by (simp add: add_ac)
   1.335 +  qed
   1.336 +  finally have "(\<lambda>n. C * (\<Prod>k\<le>n. f (k + M + m)) / C) \<longlonglongrightarrow> L / C"
   1.337 +    by (intro tendsto_divide tendsto_const) auto
   1.338 +  hence "(\<lambda>n. \<Prod>k\<le>n. f (k + M + m)) \<longlonglongrightarrow> L / C" by simp
   1.339 +  moreover from \<open>L \<noteq> 0\<close> have "L / C \<noteq> 0" by simp
   1.340 +  ultimately show ?thesis unfolding convergent_prod_def by blast
   1.341 +qed
   1.342 +
   1.343 +lemma abs_convergent_prod_ignore_initial_segment:
   1.344 +  assumes "abs_convergent_prod f"
   1.345 +  shows   "abs_convergent_prod (\<lambda>n. f (n + m))"
   1.346 +  using assms unfolding abs_convergent_prod_def 
   1.347 +  by (rule convergent_prod_ignore_initial_segment)
   1.348 +
   1.349 +lemma summable_LIMSEQ': 
   1.350 +  assumes "summable (f::nat\<Rightarrow>'a::{t2_space,comm_monoid_add})"
   1.351 +  shows   "(\<lambda>n. \<Sum>i\<le>n. f i) \<longlonglongrightarrow> suminf f"
   1.352 +  using assms sums_def_le by blast
   1.353 +
   1.354 +lemma abs_convergent_prod_imp_convergent_prod:
   1.355 +  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,complete_space,comm_ring_1}"
   1.356 +  assumes "abs_convergent_prod f"
   1.357 +  shows   "convergent_prod f"
   1.358 +proof -
   1.359 +  from assms have "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
   1.360 +    by (rule abs_convergent_prod_imp_ev_nonzero)
   1.361 +  then obtain N where N: "f n \<noteq> 0" if "n \<ge> N" for n 
   1.362 +    by (auto simp: eventually_at_top_linorder)
   1.363 +  let ?P = "\<lambda>n. \<Prod>i\<le>n. f (i + N)" and ?Q = "\<lambda>n. \<Prod>i\<le>n. 1 + norm (f (i + N) - 1)"
   1.364 +
   1.365 +  have "Cauchy ?P"
   1.366 +  proof (rule CauchyI', goal_cases)
   1.367 +    case (1 \<epsilon>)
   1.368 +    from assms have "abs_convergent_prod (\<lambda>n. f (n + N))"
   1.369 +      by (rule abs_convergent_prod_ignore_initial_segment)
   1.370 +    hence "Cauchy ?Q"
   1.371 +      unfolding abs_convergent_prod_def
   1.372 +      by (intro convergent_Cauchy convergent_prod_imp_convergent)
   1.373 +    from CauchyD[OF this 1] obtain M where M: "norm (?Q m - ?Q n) < \<epsilon>" if "m \<ge> M" "n \<ge> M" for m n
   1.374 +      by blast
   1.375 +    show ?case
   1.376 +    proof (rule exI[of _ M], safe, goal_cases)
   1.377 +      case (1 m n)
   1.378 +      have "dist (?P m) (?P n) = norm (?P n - ?P m)"
   1.379 +        by (simp add: dist_norm norm_minus_commute)
   1.380 +      also from 1 have "{..n} = {..m} \<union> {m<..n}" by auto
   1.381 +      hence "norm (?P n - ?P m) = norm (?P m * (\<Prod>k\<in>{m<..n}. f (k + N)) - ?P m)"
   1.382 +        by (subst prod.union_disjoint [symmetric]) (auto simp: algebra_simps)
   1.383 +      also have "\<dots> = norm (?P m * ((\<Prod>k\<in>{m<..n}. f (k + N)) - 1))"
   1.384 +        by (simp add: algebra_simps)
   1.385 +      also have "\<dots> = (\<Prod>k\<le>m. norm (f (k + N))) * norm ((\<Prod>k\<in>{m<..n}. f (k + N)) - 1)"
   1.386 +        by (simp add: norm_mult prod_norm)
   1.387 +      also have "\<dots> \<le> ?Q m * ((\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) - 1)"
   1.388 +        using norm_prod_minus1_le_prod_minus1[of "\<lambda>k. f (k + N) - 1" "{m<..n}"]
   1.389 +              norm_triangle_ineq[of 1 "f k - 1" for k]
   1.390 +        by (intro mult_mono prod_mono ballI conjI norm_prod_minus1_le_prod_minus1 prod_nonneg) auto
   1.391 +      also have "\<dots> = ?Q m * (\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) - ?Q m"
   1.392 +        by (simp add: algebra_simps)
   1.393 +      also have "?Q m * (\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) = 
   1.394 +                   (\<Prod>k\<in>{..m}\<union>{m<..n}. 1 + norm (f (k + N) - 1))"
   1.395 +        by (rule prod.union_disjoint [symmetric]) auto
   1.396 +      also from 1 have "{..m}\<union>{m<..n} = {..n}" by auto
   1.397 +      also have "?Q n - ?Q m \<le> norm (?Q n - ?Q m)" by simp
   1.398 +      also from 1 have "\<dots> < \<epsilon>" by (intro M) auto
   1.399 +      finally show ?case .
   1.400 +    qed
   1.401 +  qed
   1.402 +  hence conv: "convergent ?P" by (rule Cauchy_convergent)
   1.403 +  then obtain L where L: "?P \<longlonglongrightarrow> L"
   1.404 +    by (auto simp: convergent_def)
   1.405 +
   1.406 +  have "L \<noteq> 0"
   1.407 +  proof
   1.408 +    assume [simp]: "L = 0"
   1.409 +    from tendsto_norm[OF L] have limit: "(\<lambda>n. \<Prod>k\<le>n. norm (f (k + N))) \<longlonglongrightarrow> 0" 
   1.410 +      by (simp add: prod_norm)
   1.411 +
   1.412 +    from assms have "(\<lambda>n. f (n + N)) \<longlonglongrightarrow> 1"
   1.413 +      by (intro abs_convergent_prod_imp_LIMSEQ abs_convergent_prod_ignore_initial_segment)
   1.414 +    hence "eventually (\<lambda>n. norm (f (n + N) - 1) < 1) sequentially"
   1.415 +      by (auto simp: tendsto_iff dist_norm)
   1.416 +    then obtain M0 where M0: "norm (f (n + N) - 1) < 1" if "n \<ge> M0" for n
   1.417 +      by (auto simp: eventually_at_top_linorder)
   1.418 +
   1.419 +    {
   1.420 +      fix M assume M: "M \<ge> M0"
   1.421 +      with M0 have M: "norm (f (n + N) - 1) < 1" if "n \<ge> M" for n using that by simp
   1.422 +
   1.423 +      have "(\<lambda>n. \<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<longlonglongrightarrow> 0"
   1.424 +      proof (rule tendsto_sandwich)
   1.425 +        show "eventually (\<lambda>n. (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<ge> 0) sequentially"
   1.426 +          using M by (intro always_eventually prod_nonneg allI ballI) (auto intro: less_imp_le)
   1.427 +        have "norm (1::'a) - norm (f (i + M + N) - 1) \<le> norm (f (i + M + N))" for i
   1.428 +          using norm_triangle_ineq3[of "f (i + M + N)" 1] by simp
   1.429 +        thus "eventually (\<lambda>n. (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<le> (\<Prod>k\<le>n. norm (f (k+M+N)))) at_top"
   1.430 +          using M by (intro always_eventually allI prod_mono ballI conjI) (auto intro: less_imp_le)
   1.431 +        
   1.432 +        define C where "C = (\<Prod>k<M. norm (f (k + N)))"
   1.433 +        from N have [simp]: "C \<noteq> 0" by (auto simp: C_def)
   1.434 +        from L have "(\<lambda>n. norm (\<Prod>k\<le>n+M. f (k + N))) \<longlonglongrightarrow> 0"
   1.435 +          by (intro LIMSEQ_ignore_initial_segment) (simp add: tendsto_norm_zero_iff)
   1.436 +        also have "(\<lambda>n. norm (\<Prod>k\<le>n+M. f (k + N))) = (\<lambda>n. C * (\<Prod>k\<le>n. norm (f (k + M + N))))"
   1.437 +        proof (rule ext, goal_cases)
   1.438 +          case (1 n)
   1.439 +          have "{..n+M} = {..<M} \<union> {M..n+M}" by auto
   1.440 +          also have "norm (\<Prod>k\<in>\<dots>. f (k + N)) = C * norm (\<Prod>k=M..n+M. f (k + N))"
   1.441 +            unfolding C_def by (subst prod.union_disjoint) (auto simp: norm_mult prod_norm)
   1.442 +          also have "(\<Prod>k=M..n+M. f (k + N)) = (\<Prod>k\<le>n. f (k + N + M))"
   1.443 +            by (intro prod.reindex_bij_witness[of _ "\<lambda>i. i + M" "\<lambda>i. i - M"]) auto
   1.444 +          finally show ?case by (simp add: add_ac prod_norm)
   1.445 +        qed
   1.446 +        finally have "(\<lambda>n. C * (\<Prod>k\<le>n. norm (f (k + M + N))) / C) \<longlonglongrightarrow> 0 / C"
   1.447 +          by (intro tendsto_divide tendsto_const) auto
   1.448 +        thus "(\<lambda>n. \<Prod>k\<le>n. norm (f (k + M + N))) \<longlonglongrightarrow> 0" by simp
   1.449 +      qed simp_all
   1.450 +
   1.451 +      have "1 - (\<Sum>i. norm (f (i + M + N) - 1)) \<le> 0"
   1.452 +      proof (rule tendsto_le)
   1.453 +        show "eventually (\<lambda>n. 1 - (\<Sum>k\<le>n. norm (f (k+M+N) - 1)) \<le> 
   1.454 +                                (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1))) at_top"
   1.455 +          using M by (intro always_eventually allI weierstrass_prod_ineq) (auto intro: less_imp_le)
   1.456 +        show "(\<lambda>n. \<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<longlonglongrightarrow> 0" by fact
   1.457 +        show "(\<lambda>n. 1 - (\<Sum>k\<le>n. norm (f (k + M + N) - 1)))
   1.458 +                  \<longlonglongrightarrow> 1 - (\<Sum>i. norm (f (i + M + N) - 1))"
   1.459 +          by (intro tendsto_intros summable_LIMSEQ' summable_ignore_initial_segment 
   1.460 +                abs_convergent_prod_imp_summable assms)
   1.461 +      qed simp_all
   1.462 +      hence "(\<Sum>i. norm (f (i + M + N) - 1)) \<ge> 1" by simp
   1.463 +      also have "\<dots> + (\<Sum>i<M. norm (f (i + N) - 1)) = (\<Sum>i. norm (f (i + N) - 1))"
   1.464 +        by (intro suminf_split_initial_segment [symmetric] summable_ignore_initial_segment
   1.465 +              abs_convergent_prod_imp_summable assms)
   1.466 +      finally have "1 + (\<Sum>i<M. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))" by simp
   1.467 +    } note * = this
   1.468 +
   1.469 +    have "1 + (\<Sum>i. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))"
   1.470 +    proof (rule tendsto_le)
   1.471 +      show "(\<lambda>M. 1 + (\<Sum>i<M. norm (f (i + N) - 1))) \<longlonglongrightarrow> 1 + (\<Sum>i. norm (f (i + N) - 1))"
   1.472 +        by (intro tendsto_intros summable_LIMSEQ summable_ignore_initial_segment 
   1.473 +                abs_convergent_prod_imp_summable assms)
   1.474 +      show "eventually (\<lambda>M. 1 + (\<Sum>i<M. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))) at_top"
   1.475 +        using eventually_ge_at_top[of M0] by eventually_elim (use * in auto)
   1.476 +    qed simp_all
   1.477 +    thus False by simp
   1.478 +  qed
   1.479 +  with L show ?thesis by (auto simp: convergent_prod_def)
   1.480 +qed
   1.481 +
   1.482 +end