src/HOL/Analysis/Infinite_Products.thy
 author paulson Thu May 03 18:40:14 2018 +0100 (14 months ago) changeset 68076 315043faa871 parent 68071 c18af2b0f83e child 68127 137d5d0112bb permissions -rw-r--r--
tidied up Infinite_Products
     1 (*File:      HOL/Analysis/Infinite_Product.thy

     2   Author:    Manuel Eberl & LC Paulson

     3

     4   Basic results about convergence and absolute convergence of infinite products

     5   and their connection to summability.

     6 *)

     7 section \<open>Infinite Products\<close>

     8 theory Infinite_Products

     9   imports Complex_Main

    10 begin

    11

    12 lemma sum_le_prod:

    13   fixes f :: "'a \<Rightarrow> 'b :: linordered_semidom"

    14   assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 0"

    15   shows   "sum f A \<le> (\<Prod>x\<in>A. 1 + f x)"

    16   using assms

    17 proof (induction A rule: infinite_finite_induct)

    18   case (insert x A)

    19   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)"

    20     by (intro add_mono insert mult_left_mono prod_mono) (auto intro: insert.prems)

    21   with insert.hyps show ?case by (simp add: algebra_simps)

    22 qed simp_all

    23

    24 lemma prod_le_exp_sum:

    25   fixes f :: "'a \<Rightarrow> real"

    26   assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 0"

    27   shows   "prod (\<lambda>x. 1 + f x) A \<le> exp (sum f A)"

    28   using assms

    29 proof (induction A rule: infinite_finite_induct)

    30   case (insert x A)

    31   have "(1 + f x) * (\<Prod>x\<in>A. 1 + f x) \<le> exp (f x) * exp (sum f A)"

    32     using insert.prems by (intro mult_mono insert prod_nonneg exp_ge_add_one_self) auto

    33   with insert.hyps show ?case by (simp add: algebra_simps exp_add)

    34 qed simp_all

    35

    36 lemma lim_ln_1_plus_x_over_x_at_0: "(\<lambda>x::real. ln (1 + x) / x) \<midarrow>0\<rightarrow> 1"

    37 proof (rule lhopital)

    38   show "(\<lambda>x::real. ln (1 + x)) \<midarrow>0\<rightarrow> 0"

    39     by (rule tendsto_eq_intros refl | simp)+

    40   have "eventually (\<lambda>x::real. x \<in> {-1/2<..<1/2}) (nhds 0)"

    41     by (rule eventually_nhds_in_open) auto

    42   hence *: "eventually (\<lambda>x::real. x \<in> {-1/2<..<1/2}) (at 0)"

    43     by (rule filter_leD [rotated]) (simp_all add: at_within_def)

    44   show "eventually (\<lambda>x::real. ((\<lambda>x. ln (1 + x)) has_field_derivative inverse (1 + x)) (at x)) (at 0)"

    45     using * by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)

    46   show "eventually (\<lambda>x::real. ((\<lambda>x. x) has_field_derivative 1) (at x)) (at 0)"

    47     using * by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)

    48   show "\<forall>\<^sub>F x in at 0. x \<noteq> 0" by (auto simp: at_within_def eventually_inf_principal)

    49   show "(\<lambda>x::real. inverse (1 + x) / 1) \<midarrow>0\<rightarrow> 1"

    50     by (rule tendsto_eq_intros refl | simp)+

    51 qed auto

    52

    53 definition gen_has_prod :: "[nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}, nat, 'a] \<Rightarrow> bool"

    54   where "gen_has_prod f M p \<equiv> (\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> p \<and> p \<noteq> 0"

    55

    56 text\<open>The nonzero and zero cases, as in \emph{Complex Analysis} by Joseph Bak and Donald J.Newman, page 241\<close>

    57 definition has_prod :: "(nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}) \<Rightarrow> 'a \<Rightarrow> bool" (infixr "has'_prod" 80)

    58   where "f has_prod p \<equiv> gen_has_prod f 0 p \<or> (\<exists>i q. p = 0 \<and> f i = 0 \<and> gen_has_prod f (Suc i) q)"

    59

    60 definition convergent_prod :: "(nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}) \<Rightarrow> bool" where

    61   "convergent_prod f \<equiv> \<exists>M p. gen_has_prod f M p"

    62

    63 definition prodinf :: "(nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}) \<Rightarrow> 'a"

    64     (binder "\<Prod>" 10)

    65   where "prodinf f = (THE p. f has_prod p)"

    66

    67 lemmas prod_defs = gen_has_prod_def has_prod_def convergent_prod_def prodinf_def

    68

    69 lemma has_prod_subst[trans]: "f = g \<Longrightarrow> g has_prod z \<Longrightarrow> f has_prod z"

    70   by simp

    71

    72 lemma has_prod_cong: "(\<And>n. f n = g n) \<Longrightarrow> f has_prod c \<longleftrightarrow> g has_prod c"

    73   by presburger

    74

    75 lemma gen_has_prod_nonzero [simp]: "\<not> gen_has_prod f M 0"

    76   by (simp add: gen_has_prod_def)

    77

    78 lemma has_prod_0_iff: "f has_prod 0 \<longleftrightarrow> (\<exists>i. f i = 0 \<and> (\<exists>p. gen_has_prod f (Suc i) p))"

    79   by (simp add: has_prod_def)

    80

    81 lemma convergent_prod_altdef:

    82   fixes f :: "nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}"

    83   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)"

    84 proof

    85   assume "convergent_prod f"

    86   then obtain M L where *: "(\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> L" "L \<noteq> 0"

    87     by (auto simp: prod_defs)

    88   have "f i \<noteq> 0" if "i \<ge> M" for i

    89   proof

    90     assume "f i = 0"

    91     have **: "eventually (\<lambda>n. (\<Prod>i\<le>n. f (i+M)) = 0) sequentially"

    92       using eventually_ge_at_top[of "i - M"]

    93     proof eventually_elim

    94       case (elim n)

    95       with \<open>f i = 0\<close> and \<open>i \<ge> M\<close> show ?case

    96         by (auto intro!: bexI[of _ "i - M"] prod_zero)

    97     qed

    98     have "(\<lambda>n. (\<Prod>i\<le>n. f (i+M))) \<longlonglongrightarrow> 0"

    99       unfolding filterlim_iff

   100       by (auto dest!: eventually_nhds_x_imp_x intro!: eventually_mono[OF **])

   101     from tendsto_unique[OF _ this *(1)] and *(2)

   102       show False by simp

   103   qed

   104   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)"

   105     by blast

   106 qed (auto simp: prod_defs)

   107

   108 definition abs_convergent_prod :: "(nat \<Rightarrow> _) \<Rightarrow> bool" where

   109   "abs_convergent_prod f \<longleftrightarrow> convergent_prod (\<lambda>i. 1 + norm (f i - 1))"

   110

   111 lemma abs_convergent_prodI:

   112   assumes "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"

   113   shows   "abs_convergent_prod f"

   114 proof -

   115   from assms obtain L where L: "(\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1)) \<longlonglongrightarrow> L"

   116     by (auto simp: convergent_def)

   117   have "L \<ge> 1"

   118   proof (rule tendsto_le)

   119     show "eventually (\<lambda>n. (\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> 1) sequentially"

   120     proof (intro always_eventually allI)

   121       fix n

   122       have "(\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> (\<Prod>i\<le>n. 1)"

   123         by (intro prod_mono) auto

   124       thus "(\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> 1" by simp

   125     qed

   126   qed (use L in simp_all)

   127   hence "L \<noteq> 0" by auto

   128   with L show ?thesis unfolding abs_convergent_prod_def prod_defs

   129     by (intro exI[of _ "0::nat"] exI[of _ L]) auto

   130 qed

   131

   132 lemma

   133   fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"

   134   assumes "convergent_prod f"

   135   shows   convergent_prod_imp_convergent: "convergent (\<lambda>n. \<Prod>i\<le>n. f i)"

   136     and   convergent_prod_to_zero_iff:    "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<exists>i. f i = 0)"

   137 proof -

   138   from assms obtain M L

   139     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"

   140     by (auto simp: convergent_prod_altdef)

   141   note this(2)

   142   also have "(\<lambda>n. \<Prod>i\<le>n. f (i + M)) = (\<lambda>n. \<Prod>i=M..M+n. f i)"

   143     by (intro ext prod.reindex_bij_witness[of _ "\<lambda>n. n - M" "\<lambda>n. n + M"]) auto

   144   finally have "(\<lambda>n. (\<Prod>i<M. f i) * (\<Prod>i=M..M+n. f i)) \<longlonglongrightarrow> (\<Prod>i<M. f i) * L"

   145     by (intro tendsto_mult tendsto_const)

   146   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))"

   147     by (subst prod.union_disjoint) auto

   148   also have "(\<lambda>n. {..<M} \<union> {M..M+n}) = (\<lambda>n. {..n+M})" by auto

   149   finally have lim: "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f {..<M} * L"

   150     by (rule LIMSEQ_offset)

   151   thus "convergent (\<lambda>n. \<Prod>i\<le>n. f i)"

   152     by (auto simp: convergent_def)

   153

   154   show "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<exists>i. f i = 0)"

   155   proof

   156     assume "\<exists>i. f i = 0"

   157     then obtain i where "f i = 0" by auto

   158     moreover with M have "i < M" by (cases "i < M") auto

   159     ultimately have "(\<Prod>i<M. f i) = 0" by auto

   160     with lim show "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0" by simp

   161   next

   162     assume "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0"

   163     from tendsto_unique[OF _ this lim] and \<open>L \<noteq> 0\<close>

   164     show "\<exists>i. f i = 0" by auto

   165   qed

   166 qed

   167

   168 lemma convergent_prod_iff_nz_lim:

   169   fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"

   170   assumes "\<And>i. f i \<noteq> 0"

   171   shows "convergent_prod f \<longleftrightarrow> (\<exists>L. (\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> L \<and> L \<noteq> 0)"

   172     (is "?lhs \<longleftrightarrow> ?rhs")

   173 proof

   174   assume ?lhs then show ?rhs

   175     using assms convergentD convergent_prod_imp_convergent convergent_prod_to_zero_iff by blast

   176 next

   177   assume ?rhs then show ?lhs

   178     unfolding prod_defs

   179     by (rule_tac x="0" in exI) (auto simp: )

   180 qed

   181

   182 lemma convergent_prod_iff_convergent:

   183   fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"

   184   assumes "\<And>i. f i \<noteq> 0"

   185   shows "convergent_prod f \<longleftrightarrow> convergent (\<lambda>n. \<Prod>i\<le>n. f i) \<and> lim (\<lambda>n. \<Prod>i\<le>n. f i) \<noteq> 0"

   186   by (force simp add: convergent_prod_iff_nz_lim assms convergent_def limI)

   187

   188

   189 lemma abs_convergent_prod_altdef:

   190   fixes f :: "nat \<Rightarrow> 'a :: {one,real_normed_vector}"

   191   shows  "abs_convergent_prod f \<longleftrightarrow> convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"

   192 proof

   193   assume "abs_convergent_prod f"

   194   thus "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"

   195     by (auto simp: abs_convergent_prod_def intro!: convergent_prod_imp_convergent)

   196 qed (auto intro: abs_convergent_prodI)

   197

   198 lemma weierstrass_prod_ineq:

   199   fixes f :: "'a \<Rightarrow> real"

   200   assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<in> {0..1}"

   201   shows   "1 - sum f A \<le> (\<Prod>x\<in>A. 1 - f x)"

   202   using assms

   203 proof (induction A rule: infinite_finite_induct)

   204   case (insert x A)

   205   from insert.hyps and insert.prems

   206     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)"

   207     by (intro insert.IH add_mono mult_left_mono prod_mono) auto

   208   with insert.hyps show ?case by (simp add: algebra_simps)

   209 qed simp_all

   210

   211 lemma norm_prod_minus1_le_prod_minus1:

   212   fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,comm_ring_1}"

   213   shows "norm (prod (\<lambda>n. 1 + f n) A - 1) \<le> prod (\<lambda>n. 1 + norm (f n)) A - 1"

   214 proof (induction A rule: infinite_finite_induct)

   215   case (insert x A)

   216   from insert.hyps have

   217     "norm ((\<Prod>n\<in>insert x A. 1 + f n) - 1) =

   218        norm ((\<Prod>n\<in>A. 1 + f n) - 1 + f x * (\<Prod>n\<in>A. 1 + f n))"

   219     by (simp add: algebra_simps)

   220   also have "\<dots> \<le> norm ((\<Prod>n\<in>A. 1 + f n) - 1) + norm (f x * (\<Prod>n\<in>A. 1 + f n))"

   221     by (rule norm_triangle_ineq)

   222   also have "norm (f x * (\<Prod>n\<in>A. 1 + f n)) = norm (f x) * (\<Prod>x\<in>A. norm (1 + f x))"

   223     by (simp add: prod_norm norm_mult)

   224   also have "(\<Prod>x\<in>A. norm (1 + f x)) \<le> (\<Prod>x\<in>A. norm (1::'a) + norm (f x))"

   225     by (intro prod_mono norm_triangle_ineq ballI conjI) auto

   226   also have "norm (1::'a) = 1" by simp

   227   also note insert.IH

   228   also have "(\<Prod>n\<in>A. 1 + norm (f n)) - 1 + norm (f x) * (\<Prod>x\<in>A. 1 + norm (f x)) =

   229              (\<Prod>n\<in>insert x A. 1 + norm (f n)) - 1"

   230     using insert.hyps by (simp add: algebra_simps)

   231   finally show ?case by - (simp_all add: mult_left_mono)

   232 qed simp_all

   233

   234 lemma convergent_prod_imp_ev_nonzero:

   235   fixes f :: "nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}"

   236   assumes "convergent_prod f"

   237   shows   "eventually (\<lambda>n. f n \<noteq> 0) sequentially"

   238   using assms by (auto simp: eventually_at_top_linorder convergent_prod_altdef)

   239

   240 lemma convergent_prod_imp_LIMSEQ:

   241   fixes f :: "nat \<Rightarrow> 'a :: {real_normed_field}"

   242   assumes "convergent_prod f"

   243   shows   "f \<longlonglongrightarrow> 1"

   244 proof -

   245   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"

   246     by (auto simp: convergent_prod_altdef)

   247   hence L': "(\<lambda>n. \<Prod>i\<le>Suc n. f (i+M)) \<longlonglongrightarrow> L" by (subst filterlim_sequentially_Suc)

   248   have "(\<lambda>n. (\<Prod>i\<le>Suc n. f (i+M)) / (\<Prod>i\<le>n. f (i+M))) \<longlonglongrightarrow> L / L"

   249     using L L' by (intro tendsto_divide) simp_all

   250   also from L have "L / L = 1" by simp

   251   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))"

   252     using assms L by (auto simp: fun_eq_iff atMost_Suc)

   253   finally show ?thesis by (rule LIMSEQ_offset)

   254 qed

   255

   256 lemma abs_convergent_prod_imp_summable:

   257   fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"

   258   assumes "abs_convergent_prod f"

   259   shows "summable (\<lambda>i. norm (f i - 1))"

   260 proof -

   261   from assms have "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"

   262     unfolding abs_convergent_prod_def by (rule convergent_prod_imp_convergent)

   263   then obtain L where L: "(\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1)) \<longlonglongrightarrow> L"

   264     unfolding convergent_def by blast

   265   have "convergent (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))"

   266   proof (rule Bseq_monoseq_convergent)

   267     have "eventually (\<lambda>n. (\<Prod>i\<le>n. 1 + norm (f i - 1)) < L + 1) sequentially"

   268       using L(1) by (rule order_tendstoD) simp_all

   269     hence "\<forall>\<^sub>F x in sequentially. norm (\<Sum>i\<le>x. norm (f i - 1)) \<le> L + 1"

   270     proof eventually_elim

   271       case (elim n)

   272       have "norm (\<Sum>i\<le>n. norm (f i - 1)) = (\<Sum>i\<le>n. norm (f i - 1))"

   273         unfolding real_norm_def by (intro abs_of_nonneg sum_nonneg) simp_all

   274       also have "\<dots> \<le> (\<Prod>i\<le>n. 1 + norm (f i - 1))" by (rule sum_le_prod) auto

   275       also have "\<dots> < L + 1" by (rule elim)

   276       finally show ?case by simp

   277     qed

   278     thus "Bseq (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))" by (rule BfunI)

   279   next

   280     show "monoseq (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))"

   281       by (rule mono_SucI1) auto

   282   qed

   283   thus "summable (\<lambda>i. norm (f i - 1))" by (simp add: summable_iff_convergent')

   284 qed

   285

   286 lemma summable_imp_abs_convergent_prod:

   287   fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"

   288   assumes "summable (\<lambda>i. norm (f i - 1))"

   289   shows   "abs_convergent_prod f"

   290 proof (intro abs_convergent_prodI Bseq_monoseq_convergent)

   291   show "monoseq (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"

   292     by (intro mono_SucI1)

   293        (auto simp: atMost_Suc algebra_simps intro!: mult_nonneg_nonneg prod_nonneg)

   294 next

   295   show "Bseq (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"

   296   proof (rule Bseq_eventually_mono)

   297     show "eventually (\<lambda>n. norm (\<Prod>i\<le>n. 1 + norm (f i - 1)) \<le>

   298             norm (exp (\<Sum>i\<le>n. norm (f i - 1)))) sequentially"

   299       by (intro always_eventually allI) (auto simp: abs_prod exp_sum intro!: prod_mono)

   300   next

   301     from assms have "(\<lambda>n. \<Sum>i\<le>n. norm (f i - 1)) \<longlonglongrightarrow> (\<Sum>i. norm (f i - 1))"

   302       using sums_def_le by blast

   303     hence "(\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1))) \<longlonglongrightarrow> exp (\<Sum>i. norm (f i - 1))"

   304       by (rule tendsto_exp)

   305     hence "convergent (\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1)))"

   306       by (rule convergentI)

   307     thus "Bseq (\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1)))"

   308       by (rule convergent_imp_Bseq)

   309   qed

   310 qed

   311

   312 lemma abs_convergent_prod_conv_summable:

   313   fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"

   314   shows "abs_convergent_prod f \<longleftrightarrow> summable (\<lambda>i. norm (f i - 1))"

   315   by (blast intro: abs_convergent_prod_imp_summable summable_imp_abs_convergent_prod)

   316

   317 lemma abs_convergent_prod_imp_LIMSEQ:

   318   fixes f :: "nat \<Rightarrow> 'a :: {comm_ring_1,real_normed_div_algebra}"

   319   assumes "abs_convergent_prod f"

   320   shows   "f \<longlonglongrightarrow> 1"

   321 proof -

   322   from assms have "summable (\<lambda>n. norm (f n - 1))"

   323     by (rule abs_convergent_prod_imp_summable)

   324   from summable_LIMSEQ_zero[OF this] have "(\<lambda>n. f n - 1) \<longlonglongrightarrow> 0"

   325     by (simp add: tendsto_norm_zero_iff)

   326   from tendsto_add[OF this tendsto_const[of 1]] show ?thesis by simp

   327 qed

   328

   329 lemma abs_convergent_prod_imp_ev_nonzero:

   330   fixes f :: "nat \<Rightarrow> 'a :: {comm_ring_1,real_normed_div_algebra}"

   331   assumes "abs_convergent_prod f"

   332   shows   "eventually (\<lambda>n. f n \<noteq> 0) sequentially"

   333 proof -

   334   from assms have "f \<longlonglongrightarrow> 1"

   335     by (rule abs_convergent_prod_imp_LIMSEQ)

   336   hence "eventually (\<lambda>n. dist (f n) 1 < 1) at_top"

   337     by (auto simp: tendsto_iff)

   338   thus ?thesis by eventually_elim auto

   339 qed

   340

   341 lemma convergent_prod_offset:

   342   assumes "convergent_prod (\<lambda>n. f (n + m))"

   343   shows   "convergent_prod f"

   344 proof -

   345   from assms obtain M L where "(\<lambda>n. \<Prod>k\<le>n. f (k + (M + m))) \<longlonglongrightarrow> L" "L \<noteq> 0"

   346     by (auto simp: prod_defs add.assoc)

   347   thus "convergent_prod f"

   348     unfolding prod_defs by blast

   349 qed

   350

   351 lemma abs_convergent_prod_offset:

   352   assumes "abs_convergent_prod (\<lambda>n. f (n + m))"

   353   shows   "abs_convergent_prod f"

   354   using assms unfolding abs_convergent_prod_def by (rule convergent_prod_offset)

   355

   356 lemma convergent_prod_ignore_initial_segment:

   357   fixes f :: "nat \<Rightarrow> 'a :: {real_normed_field}"

   358   assumes "convergent_prod f"

   359   shows   "convergent_prod (\<lambda>n. f (n + m))"

   360 proof -

   361   from assms obtain M L

   362     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"

   363     by (auto simp: convergent_prod_altdef)

   364   define C where "C = (\<Prod>k<m. f (k + M))"

   365   from nz have [simp]: "C \<noteq> 0"

   366     by (auto simp: C_def)

   367

   368   from L(1) have "(\<lambda>n. \<Prod>k\<le>n+m. f (k + M)) \<longlonglongrightarrow> L"

   369     by (rule LIMSEQ_ignore_initial_segment)

   370   also have "(\<lambda>n. \<Prod>k\<le>n+m. f (k + M)) = (\<lambda>n. C * (\<Prod>k\<le>n. f (k + M + m)))"

   371   proof (rule ext, goal_cases)

   372     case (1 n)

   373     have "{..n+m} = {..<m} \<union> {m..n+m}" by auto

   374     also have "(\<Prod>k\<in>\<dots>. f (k + M)) = C * (\<Prod>k=m..n+m. f (k + M))"

   375       unfolding C_def by (rule prod.union_disjoint) auto

   376     also have "(\<Prod>k=m..n+m. f (k + M)) = (\<Prod>k\<le>n. f (k + m + M))"

   377       by (intro ext prod.reindex_bij_witness[of _ "\<lambda>k. k + m" "\<lambda>k. k - m"]) auto

   378     finally show ?case by (simp add: add_ac)

   379   qed

   380   finally have "(\<lambda>n. C * (\<Prod>k\<le>n. f (k + M + m)) / C) \<longlonglongrightarrow> L / C"

   381     by (intro tendsto_divide tendsto_const) auto

   382   hence "(\<lambda>n. \<Prod>k\<le>n. f (k + M + m)) \<longlonglongrightarrow> L / C" by simp

   383   moreover from \<open>L \<noteq> 0\<close> have "L / C \<noteq> 0" by simp

   384   ultimately show ?thesis

   385     unfolding prod_defs by blast

   386 qed

   387

   388 lemma abs_convergent_prod_ignore_initial_segment:

   389   assumes "abs_convergent_prod f"

   390   shows   "abs_convergent_prod (\<lambda>n. f (n + m))"

   391   using assms unfolding abs_convergent_prod_def

   392   by (rule convergent_prod_ignore_initial_segment)

   393

   394 lemma abs_convergent_prod_imp_convergent_prod:

   395   fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,complete_space,comm_ring_1}"

   396   assumes "abs_convergent_prod f"

   397   shows   "convergent_prod f"

   398 proof -

   399   from assms have "eventually (\<lambda>n. f n \<noteq> 0) sequentially"

   400     by (rule abs_convergent_prod_imp_ev_nonzero)

   401   then obtain N where N: "f n \<noteq> 0" if "n \<ge> N" for n

   402     by (auto simp: eventually_at_top_linorder)

   403   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)"

   404

   405   have "Cauchy ?P"

   406   proof (rule CauchyI', goal_cases)

   407     case (1 \<epsilon>)

   408     from assms have "abs_convergent_prod (\<lambda>n. f (n + N))"

   409       by (rule abs_convergent_prod_ignore_initial_segment)

   410     hence "Cauchy ?Q"

   411       unfolding abs_convergent_prod_def

   412       by (intro convergent_Cauchy convergent_prod_imp_convergent)

   413     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

   414       by blast

   415     show ?case

   416     proof (rule exI[of _ M], safe, goal_cases)

   417       case (1 m n)

   418       have "dist (?P m) (?P n) = norm (?P n - ?P m)"

   419         by (simp add: dist_norm norm_minus_commute)

   420       also from 1 have "{..n} = {..m} \<union> {m<..n}" by auto

   421       hence "norm (?P n - ?P m) = norm (?P m * (\<Prod>k\<in>{m<..n}. f (k + N)) - ?P m)"

   422         by (subst prod.union_disjoint [symmetric]) (auto simp: algebra_simps)

   423       also have "\<dots> = norm (?P m * ((\<Prod>k\<in>{m<..n}. f (k + N)) - 1))"

   424         by (simp add: algebra_simps)

   425       also have "\<dots> = (\<Prod>k\<le>m. norm (f (k + N))) * norm ((\<Prod>k\<in>{m<..n}. f (k + N)) - 1)"

   426         by (simp add: norm_mult prod_norm)

   427       also have "\<dots> \<le> ?Q m * ((\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) - 1)"

   428         using norm_prod_minus1_le_prod_minus1[of "\<lambda>k. f (k + N) - 1" "{m<..n}"]

   429               norm_triangle_ineq[of 1 "f k - 1" for k]

   430         by (intro mult_mono prod_mono ballI conjI norm_prod_minus1_le_prod_minus1 prod_nonneg) auto

   431       also have "\<dots> = ?Q m * (\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) - ?Q m"

   432         by (simp add: algebra_simps)

   433       also have "?Q m * (\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) =

   434                    (\<Prod>k\<in>{..m}\<union>{m<..n}. 1 + norm (f (k + N) - 1))"

   435         by (rule prod.union_disjoint [symmetric]) auto

   436       also from 1 have "{..m}\<union>{m<..n} = {..n}" by auto

   437       also have "?Q n - ?Q m \<le> norm (?Q n - ?Q m)" by simp

   438       also from 1 have "\<dots> < \<epsilon>" by (intro M) auto

   439       finally show ?case .

   440     qed

   441   qed

   442   hence conv: "convergent ?P" by (rule Cauchy_convergent)

   443   then obtain L where L: "?P \<longlonglongrightarrow> L"

   444     by (auto simp: convergent_def)

   445

   446   have "L \<noteq> 0"

   447   proof

   448     assume [simp]: "L = 0"

   449     from tendsto_norm[OF L] have limit: "(\<lambda>n. \<Prod>k\<le>n. norm (f (k + N))) \<longlonglongrightarrow> 0"

   450       by (simp add: prod_norm)

   451

   452     from assms have "(\<lambda>n. f (n + N)) \<longlonglongrightarrow> 1"

   453       by (intro abs_convergent_prod_imp_LIMSEQ abs_convergent_prod_ignore_initial_segment)

   454     hence "eventually (\<lambda>n. norm (f (n + N) - 1) < 1) sequentially"

   455       by (auto simp: tendsto_iff dist_norm)

   456     then obtain M0 where M0: "norm (f (n + N) - 1) < 1" if "n \<ge> M0" for n

   457       by (auto simp: eventually_at_top_linorder)

   458

   459     {

   460       fix M assume M: "M \<ge> M0"

   461       with M0 have M: "norm (f (n + N) - 1) < 1" if "n \<ge> M" for n using that by simp

   462

   463       have "(\<lambda>n. \<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<longlonglongrightarrow> 0"

   464       proof (rule tendsto_sandwich)

   465         show "eventually (\<lambda>n. (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<ge> 0) sequentially"

   466           using M by (intro always_eventually prod_nonneg allI ballI) (auto intro: less_imp_le)

   467         have "norm (1::'a) - norm (f (i + M + N) - 1) \<le> norm (f (i + M + N))" for i

   468           using norm_triangle_ineq3[of "f (i + M + N)" 1] by simp

   469         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"

   470           using M by (intro always_eventually allI prod_mono ballI conjI) (auto intro: less_imp_le)

   471

   472         define C where "C = (\<Prod>k<M. norm (f (k + N)))"

   473         from N have [simp]: "C \<noteq> 0" by (auto simp: C_def)

   474         from L have "(\<lambda>n. norm (\<Prod>k\<le>n+M. f (k + N))) \<longlonglongrightarrow> 0"

   475           by (intro LIMSEQ_ignore_initial_segment) (simp add: tendsto_norm_zero_iff)

   476         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))))"

   477         proof (rule ext, goal_cases)

   478           case (1 n)

   479           have "{..n+M} = {..<M} \<union> {M..n+M}" by auto

   480           also have "norm (\<Prod>k\<in>\<dots>. f (k + N)) = C * norm (\<Prod>k=M..n+M. f (k + N))"

   481             unfolding C_def by (subst prod.union_disjoint) (auto simp: norm_mult prod_norm)

   482           also have "(\<Prod>k=M..n+M. f (k + N)) = (\<Prod>k\<le>n. f (k + N + M))"

   483             by (intro prod.reindex_bij_witness[of _ "\<lambda>i. i + M" "\<lambda>i. i - M"]) auto

   484           finally show ?case by (simp add: add_ac prod_norm)

   485         qed

   486         finally have "(\<lambda>n. C * (\<Prod>k\<le>n. norm (f (k + M + N))) / C) \<longlonglongrightarrow> 0 / C"

   487           by (intro tendsto_divide tendsto_const) auto

   488         thus "(\<lambda>n. \<Prod>k\<le>n. norm (f (k + M + N))) \<longlonglongrightarrow> 0" by simp

   489       qed simp_all

   490

   491       have "1 - (\<Sum>i. norm (f (i + M + N) - 1)) \<le> 0"

   492       proof (rule tendsto_le)

   493         show "eventually (\<lambda>n. 1 - (\<Sum>k\<le>n. norm (f (k+M+N) - 1)) \<le>

   494                                 (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1))) at_top"

   495           using M by (intro always_eventually allI weierstrass_prod_ineq) (auto intro: less_imp_le)

   496         show "(\<lambda>n. \<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<longlonglongrightarrow> 0" by fact

   497         show "(\<lambda>n. 1 - (\<Sum>k\<le>n. norm (f (k + M + N) - 1)))

   498                   \<longlonglongrightarrow> 1 - (\<Sum>i. norm (f (i + M + N) - 1))"

   499           by (intro tendsto_intros summable_LIMSEQ' summable_ignore_initial_segment

   500                 abs_convergent_prod_imp_summable assms)

   501       qed simp_all

   502       hence "(\<Sum>i. norm (f (i + M + N) - 1)) \<ge> 1" by simp

   503       also have "\<dots> + (\<Sum>i<M. norm (f (i + N) - 1)) = (\<Sum>i. norm (f (i + N) - 1))"

   504         by (intro suminf_split_initial_segment [symmetric] summable_ignore_initial_segment

   505               abs_convergent_prod_imp_summable assms)

   506       finally have "1 + (\<Sum>i<M. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))" by simp

   507     } note * = this

   508

   509     have "1 + (\<Sum>i. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))"

   510     proof (rule tendsto_le)

   511       show "(\<lambda>M. 1 + (\<Sum>i<M. norm (f (i + N) - 1))) \<longlonglongrightarrow> 1 + (\<Sum>i. norm (f (i + N) - 1))"

   512         by (intro tendsto_intros summable_LIMSEQ summable_ignore_initial_segment

   513                 abs_convergent_prod_imp_summable assms)

   514       show "eventually (\<lambda>M. 1 + (\<Sum>i<M. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))) at_top"

   515         using eventually_ge_at_top[of M0] by eventually_elim (use * in auto)

   516     qed simp_all

   517     thus False by simp

   518   qed

   519   with L show ?thesis by (auto simp: prod_defs)

   520 qed

   521

   522 lemma convergent_prod_offset_0:

   523   fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"

   524   assumes "convergent_prod f" "\<And>i. f i \<noteq> 0"

   525   shows "\<exists>p. gen_has_prod f 0 p"

   526   using assms

   527   unfolding convergent_prod_def

   528 proof (clarsimp simp: prod_defs)

   529   fix M p

   530   assume "(\<lambda>n. \<Prod>i\<le>n. f (i + M)) \<longlonglongrightarrow> p" "p \<noteq> 0"

   531   then have "(\<lambda>n. prod f {..<M} * (\<Prod>i\<le>n. f (i + M))) \<longlonglongrightarrow> prod f {..<M} * p"

   532     by (metis tendsto_mult_left)

   533   moreover have "prod f {..<M} * (\<Prod>i\<le>n. f (i + M)) = prod f {..n+M}" for n

   534   proof -

   535     have "{..n+M} = {..<M} \<union> {M..n+M}"

   536       by auto

   537     then have "prod f {..n+M} = prod f {..<M} * prod f {M..n+M}"

   538       by simp (subst prod.union_disjoint; force)

   539     also have "... = prod f {..<M} * (\<Prod>i\<le>n. f (i + M))"

   540       by (metis (mono_tags, lifting) add.left_neutral atMost_atLeast0 prod_shift_bounds_cl_nat_ivl)

   541     finally show ?thesis by metis

   542   qed

   543   ultimately have "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f {..<M} * p"

   544     by (auto intro: LIMSEQ_offset [where k=M])

   545   then show "\<exists>p. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> p \<and> p \<noteq> 0"

   546     using \<open>p \<noteq> 0\<close> assms

   547     by (rule_tac x="prod f {..<M} * p" in exI) auto

   548 qed

   549

   550 lemma prodinf_eq_lim:

   551   fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"

   552   assumes "convergent_prod f" "\<And>i. f i \<noteq> 0"

   553   shows "prodinf f = lim (\<lambda>n. \<Prod>i\<le>n. f i)"

   554   using assms convergent_prod_offset_0 [OF assms]

   555   by (simp add: prod_defs lim_def) (metis (no_types) assms(1) convergent_prod_to_zero_iff)

   556

   557 lemma has_prod_one[simp, intro]: "(\<lambda>n. 1) has_prod 1"

   558   unfolding prod_defs by auto

   559

   560 lemma convergent_prod_one[simp, intro]: "convergent_prod (\<lambda>n. 1)"

   561   unfolding prod_defs by auto

   562

   563 lemma prodinf_cong: "(\<And>n. f n = g n) \<Longrightarrow> prodinf f = prodinf g"

   564   by presburger

   565

   566 lemma convergent_prod_cong:

   567   fixes f g :: "nat \<Rightarrow> 'a::{field,topological_semigroup_mult,t2_space}"

   568   assumes ev: "eventually (\<lambda>x. f x = g x) sequentially" and f: "\<And>i. f i \<noteq> 0" and g: "\<And>i. g i \<noteq> 0"

   569   shows "convergent_prod f = convergent_prod g"

   570 proof -

   571   from assms obtain N where N: "\<forall>n\<ge>N. f n = g n"

   572     by (auto simp: eventually_at_top_linorder)

   573   define C where "C = (\<Prod>k<N. f k / g k)"

   574   with g have "C \<noteq> 0"

   575     by (simp add: f)

   576   have *: "eventually (\<lambda>n. prod f {..n} = C * prod g {..n}) sequentially"

   577     using eventually_ge_at_top[of N]

   578   proof eventually_elim

   579     case (elim n)

   580     then have "{..n} = {..<N} \<union> {N..n}"

   581       by auto

   582     also have "prod f ... = prod f {..<N} * prod f {N..n}"

   583       by (intro prod.union_disjoint) auto

   584     also from N have "prod f {N..n} = prod g {N..n}"

   585       by (intro prod.cong) simp_all

   586     also have "prod f {..<N} * prod g {N..n} = C * (prod g {..<N} * prod g {N..n})"

   587       unfolding C_def by (simp add: g prod_dividef)

   588     also have "prod g {..<N} * prod g {N..n} = prod g ({..<N} \<union> {N..n})"

   589       by (intro prod.union_disjoint [symmetric]) auto

   590     also from elim have "{..<N} \<union> {N..n} = {..n}"

   591       by auto

   592     finally show "prod f {..n} = C * prod g {..n}" .

   593   qed

   594   then have cong: "convergent (\<lambda>n. prod f {..n}) = convergent (\<lambda>n. C * prod g {..n})"

   595     by (rule convergent_cong)

   596   show ?thesis

   597   proof

   598     assume cf: "convergent_prod f"

   599     then have "\<not> (\<lambda>n. prod g {..n}) \<longlonglongrightarrow> 0"

   600       using tendsto_mult_left * convergent_prod_to_zero_iff f filterlim_cong by fastforce

   601     then show "convergent_prod g"

   602       by (metis convergent_mult_const_iff \<open>C \<noteq> 0\<close> cong cf convergent_LIMSEQ_iff convergent_prod_iff_convergent convergent_prod_imp_convergent g)

   603   next

   604     assume cg: "convergent_prod g"

   605     have "\<exists>a. C * a \<noteq> 0 \<and> (\<lambda>n. prod g {..n}) \<longlonglongrightarrow> a"

   606       by (metis (no_types) \<open>C \<noteq> 0\<close> cg convergent_prod_iff_nz_lim divide_eq_0_iff g nonzero_mult_div_cancel_right)

   607     then show "convergent_prod f"

   608       using "*" tendsto_mult_left filterlim_cong

   609       by (fastforce simp add: convergent_prod_iff_nz_lim f)

   610   qed

   611 qed

   612

   613 lemma has_prod_finite:

   614   fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"

   615   assumes [simp]: "finite N"

   616     and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 1"

   617   shows "f has_prod (\<Prod>n\<in>N. f n)"

   618 proof -

   619   have eq: "prod f {..n + Suc (Max N)} = prod f N" for n

   620   proof (rule prod.mono_neutral_right)

   621     show "N \<subseteq> {..n + Suc (Max N)}"

   622       by (auto simp add: le_Suc_eq trans_le_add2)

   623     show "\<forall>i\<in>{..n + Suc (Max N)} - N. f i = 1"

   624       using f by blast

   625   qed auto

   626   show ?thesis

   627   proof (cases "\<forall>n\<in>N. f n \<noteq> 0")

   628     case True

   629     then have "prod f N \<noteq> 0"

   630       by simp

   631     moreover have "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f N"

   632       by (rule LIMSEQ_offset[of _ "Suc (Max N)"]) (simp add: eq atLeast0LessThan del: add_Suc_right)

   633     ultimately show ?thesis

   634       by (simp add: gen_has_prod_def has_prod_def)

   635   next

   636     case False

   637     then obtain k where "k \<in> N" "f k = 0"

   638       by auto

   639     let ?Z = "{n \<in> N. f n = 0}"

   640     have maxge: "Max ?Z \<ge> n" if "f n = 0" for n

   641       using Max_ge [of ?Z] \<open>finite N\<close> \<open>f n = 0\<close>

   642       by (metis (mono_tags) Collect_mem_eq f finite_Collect_conjI mem_Collect_eq zero_neq_one)

   643     let ?q = "prod f {Suc (Max ?Z)..Max N}"

   644     have [simp]: "?q \<noteq> 0"

   645       using maxge Suc_n_not_le_n le_trans by force

   646     have eq: "(\<Prod>i\<le>n + Max N. f (Suc (i + Max ?Z))) = ?q" for n

   647     proof -

   648       have "(\<Prod>i\<le>n + Max N. f (Suc (i + Max ?Z))) = prod f {Suc (Max ?Z)..n + Max N + Suc (Max ?Z)}"

   649       proof (rule prod.reindex_cong [where l = "\<lambda>i. i + Suc (Max ?Z)", THEN sym])

   650         show "{Suc (Max ?Z)..n + Max N + Suc (Max ?Z)} = (\<lambda>i. i + Suc (Max ?Z))  {..n + Max N}"

   651           using le_Suc_ex by fastforce

   652       qed (auto simp: inj_on_def)

   653       also have "... = ?q"

   654         by (rule prod.mono_neutral_right)

   655            (use Max.coboundedI [OF \<open>finite N\<close>] f in \<open>force+\<close>)

   656       finally show ?thesis .

   657     qed

   658     have q: "gen_has_prod f (Suc (Max ?Z)) ?q"

   659     proof (simp add: gen_has_prod_def)

   660       show "(\<lambda>n. \<Prod>i\<le>n. f (Suc (i + Max ?Z))) \<longlonglongrightarrow> ?q"

   661         by (rule LIMSEQ_offset[of _ "(Max N)"]) (simp add: eq)

   662     qed

   663     show ?thesis

   664       unfolding has_prod_def

   665     proof (intro disjI2 exI conjI)

   666       show "prod f N = 0"

   667         using \<open>f k = 0\<close> \<open>k \<in> N\<close> \<open>finite N\<close> prod_zero by blast

   668       show "f (Max ?Z) = 0"

   669         using Max_in [of ?Z] \<open>finite N\<close> \<open>f k = 0\<close> \<open>k \<in> N\<close> by auto

   670     qed (use q in auto)

   671   qed

   672 qed

   673

   674 corollary has_prod_0:

   675   fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"

   676   assumes "\<And>n. f n = 1"

   677   shows "f has_prod 1"

   678   by (simp add: assms has_prod_cong)

   679

   680 lemma convergent_prod_finite:

   681   fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"

   682   assumes "finite N" "\<And>n. n \<notin> N \<Longrightarrow> f n = 1"

   683   shows "convergent_prod f"

   684 proof -

   685   have "\<exists>n p. gen_has_prod f n p"

   686     using assms has_prod_def has_prod_finite by blast

   687   then show ?thesis

   688     by (simp add: convergent_prod_def)

   689 qed

   690

   691 end
`