src/HOL/Analysis/Infinite_Products.thy
author paulson <lp15@cam.ac.uk>
Sun Jun 03 15:22:30 2018 +0100 (13 months ago)
changeset 68361 20375f232f3b
parent 68138 c738f40e88d4
child 68424 02e5a44ffe7d
permissions -rw-r--r--
infinite product material
lp15@68064
     1
(*File:      HOL/Analysis/Infinite_Product.thy
lp15@68064
     2
  Author:    Manuel Eberl & LC Paulson
eberlm@66277
     3
eberlm@66277
     4
  Basic results about convergence and absolute convergence of infinite products
eberlm@66277
     5
  and their connection to summability.
eberlm@66277
     6
*)
eberlm@66277
     7
section \<open>Infinite Products\<close>
eberlm@66277
     8
theory Infinite_Products
eberlm@66277
     9
  imports Complex_Main
eberlm@66277
    10
begin
lp15@68064
    11
    
eberlm@66277
    12
lemma sum_le_prod:
eberlm@66277
    13
  fixes f :: "'a \<Rightarrow> 'b :: linordered_semidom"
eberlm@66277
    14
  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 0"
eberlm@66277
    15
  shows   "sum f A \<le> (\<Prod>x\<in>A. 1 + f x)"
eberlm@66277
    16
  using assms
eberlm@66277
    17
proof (induction A rule: infinite_finite_induct)
eberlm@66277
    18
  case (insert x A)
eberlm@66277
    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)"
eberlm@66277
    20
    by (intro add_mono insert mult_left_mono prod_mono) (auto intro: insert.prems)
eberlm@66277
    21
  with insert.hyps show ?case by (simp add: algebra_simps)
eberlm@66277
    22
qed simp_all
eberlm@66277
    23
eberlm@66277
    24
lemma prod_le_exp_sum:
eberlm@66277
    25
  fixes f :: "'a \<Rightarrow> real"
eberlm@66277
    26
  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 0"
eberlm@66277
    27
  shows   "prod (\<lambda>x. 1 + f x) A \<le> exp (sum f A)"
eberlm@66277
    28
  using assms
eberlm@66277
    29
proof (induction A rule: infinite_finite_induct)
eberlm@66277
    30
  case (insert x A)
eberlm@66277
    31
  have "(1 + f x) * (\<Prod>x\<in>A. 1 + f x) \<le> exp (f x) * exp (sum f A)"
eberlm@66277
    32
    using insert.prems by (intro mult_mono insert prod_nonneg exp_ge_add_one_self) auto
eberlm@66277
    33
  with insert.hyps show ?case by (simp add: algebra_simps exp_add)
eberlm@66277
    34
qed simp_all
eberlm@66277
    35
eberlm@66277
    36
lemma lim_ln_1_plus_x_over_x_at_0: "(\<lambda>x::real. ln (1 + x) / x) \<midarrow>0\<rightarrow> 1"
eberlm@66277
    37
proof (rule lhopital)
eberlm@66277
    38
  show "(\<lambda>x::real. ln (1 + x)) \<midarrow>0\<rightarrow> 0"
eberlm@66277
    39
    by (rule tendsto_eq_intros refl | simp)+
eberlm@66277
    40
  have "eventually (\<lambda>x::real. x \<in> {-1/2<..<1/2}) (nhds 0)"
eberlm@66277
    41
    by (rule eventually_nhds_in_open) auto
eberlm@66277
    42
  hence *: "eventually (\<lambda>x::real. x \<in> {-1/2<..<1/2}) (at 0)"
eberlm@66277
    43
    by (rule filter_leD [rotated]) (simp_all add: at_within_def)   
eberlm@66277
    44
  show "eventually (\<lambda>x::real. ((\<lambda>x. ln (1 + x)) has_field_derivative inverse (1 + x)) (at x)) (at 0)"
eberlm@66277
    45
    using * by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)
eberlm@66277
    46
  show "eventually (\<lambda>x::real. ((\<lambda>x. x) has_field_derivative 1) (at x)) (at 0)"
eberlm@66277
    47
    using * by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)
eberlm@66277
    48
  show "\<forall>\<^sub>F x in at 0. x \<noteq> 0" by (auto simp: at_within_def eventually_inf_principal)
eberlm@66277
    49
  show "(\<lambda>x::real. inverse (1 + x) / 1) \<midarrow>0\<rightarrow> 1"
eberlm@66277
    50
    by (rule tendsto_eq_intros refl | simp)+
eberlm@66277
    51
qed auto
eberlm@66277
    52
lp15@68361
    53
definition raw_has_prod :: "[nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}, nat, 'a] \<Rightarrow> bool" 
lp15@68361
    54
  where "raw_has_prod f M p \<equiv> (\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> p \<and> p \<noteq> 0"
lp15@68064
    55
lp15@68064
    56
text\<open>The nonzero and zero cases, as in \emph{Complex Analysis} by Joseph Bak and Donald J.Newman, page 241\<close>
lp15@68064
    57
definition has_prod :: "(nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}) \<Rightarrow> 'a \<Rightarrow> bool" (infixr "has'_prod" 80)
lp15@68361
    58
  where "f has_prod p \<equiv> raw_has_prod f 0 p \<or> (\<exists>i q. p = 0 \<and> f i = 0 \<and> raw_has_prod f (Suc i) q)"
lp15@68064
    59
eberlm@66277
    60
definition convergent_prod :: "(nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}) \<Rightarrow> bool" where
lp15@68361
    61
  "convergent_prod f \<equiv> \<exists>M p. raw_has_prod f M p"
lp15@68064
    62
lp15@68064
    63
definition prodinf :: "(nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}) \<Rightarrow> 'a"
lp15@68064
    64
    (binder "\<Prod>" 10)
lp15@68064
    65
  where "prodinf f = (THE p. f has_prod p)"
lp15@68064
    66
lp15@68361
    67
lemmas prod_defs = raw_has_prod_def has_prod_def convergent_prod_def prodinf_def
lp15@68064
    68
lp15@68064
    69
lemma has_prod_subst[trans]: "f = g \<Longrightarrow> g has_prod z \<Longrightarrow> f has_prod z"
lp15@68064
    70
  by simp
lp15@68064
    71
lp15@68064
    72
lemma has_prod_cong: "(\<And>n. f n = g n) \<Longrightarrow> f has_prod c \<longleftrightarrow> g has_prod c"
lp15@68064
    73
  by presburger
eberlm@66277
    74
lp15@68361
    75
lemma raw_has_prod_nonzero [simp]: "\<not> raw_has_prod f M 0"
lp15@68361
    76
  by (simp add: raw_has_prod_def)
lp15@68071
    77
lp15@68361
    78
lemma raw_has_prod_eq_0:
lp15@68361
    79
  fixes f :: "nat \<Rightarrow> 'a::{semidom,t2_space}"
lp15@68361
    80
  assumes p: "raw_has_prod f m p" and i: "f i = 0" "i \<ge> m"
lp15@68136
    81
  shows "p = 0"
lp15@68136
    82
proof -
lp15@68136
    83
  have eq0: "(\<Prod>k\<le>n. f (k+m)) = 0" if "i - m \<le> n" for n
lp15@68361
    84
  proof -
lp15@68361
    85
    have "\<exists>k\<le>n. f (k + m) = 0"
lp15@68361
    86
      using i that by auto
lp15@68361
    87
    then show ?thesis
lp15@68361
    88
      by auto
lp15@68361
    89
  qed
lp15@68136
    90
  have "(\<lambda>n. \<Prod>i\<le>n. f (i + m)) \<longlonglongrightarrow> 0"
lp15@68136
    91
    by (rule LIMSEQ_offset [where k = "i-m"]) (simp add: eq0)
lp15@68136
    92
    with p show ?thesis
lp15@68361
    93
      unfolding raw_has_prod_def
lp15@68136
    94
    using LIMSEQ_unique by blast
lp15@68136
    95
qed
lp15@68136
    96
lp15@68361
    97
lemma has_prod_0_iff: "f has_prod 0 \<longleftrightarrow> (\<exists>i. f i = 0 \<and> (\<exists>p. raw_has_prod f (Suc i) p))"
lp15@68071
    98
  by (simp add: has_prod_def)
lp15@68136
    99
      
lp15@68136
   100
lemma has_prod_unique2: 
lp15@68361
   101
  fixes f :: "nat \<Rightarrow> 'a::{semidom,t2_space}"
lp15@68136
   102
  assumes "f has_prod a" "f has_prod b" shows "a = b"
lp15@68136
   103
  using assms
lp15@68361
   104
  by (auto simp: has_prod_def raw_has_prod_eq_0) (meson raw_has_prod_def sequentially_bot tendsto_unique)
lp15@68136
   105
lp15@68136
   106
lemma has_prod_unique:
lp15@68361
   107
  fixes f :: "nat \<Rightarrow> 'a :: {semidom,t2_space}"
lp15@68136
   108
  shows "f has_prod s \<Longrightarrow> s = prodinf f"
lp15@68136
   109
  by (simp add: has_prod_unique2 prodinf_def the_equality)
lp15@68071
   110
eberlm@66277
   111
lemma convergent_prod_altdef:
eberlm@66277
   112
  fixes f :: "nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}"
eberlm@66277
   113
  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)"
eberlm@66277
   114
proof
eberlm@66277
   115
  assume "convergent_prod f"
eberlm@66277
   116
  then obtain M L where *: "(\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> L" "L \<noteq> 0"
lp15@68064
   117
    by (auto simp: prod_defs)
eberlm@66277
   118
  have "f i \<noteq> 0" if "i \<ge> M" for i
eberlm@66277
   119
  proof
eberlm@66277
   120
    assume "f i = 0"
eberlm@66277
   121
    have **: "eventually (\<lambda>n. (\<Prod>i\<le>n. f (i+M)) = 0) sequentially"
eberlm@66277
   122
      using eventually_ge_at_top[of "i - M"]
eberlm@66277
   123
    proof eventually_elim
eberlm@66277
   124
      case (elim n)
eberlm@66277
   125
      with \<open>f i = 0\<close> and \<open>i \<ge> M\<close> show ?case
eberlm@66277
   126
        by (auto intro!: bexI[of _ "i - M"] prod_zero)
eberlm@66277
   127
    qed
eberlm@66277
   128
    have "(\<lambda>n. (\<Prod>i\<le>n. f (i+M))) \<longlonglongrightarrow> 0"
eberlm@66277
   129
      unfolding filterlim_iff
eberlm@66277
   130
      by (auto dest!: eventually_nhds_x_imp_x intro!: eventually_mono[OF **])
eberlm@66277
   131
    from tendsto_unique[OF _ this *(1)] and *(2)
eberlm@66277
   132
      show False by simp
eberlm@66277
   133
  qed
eberlm@66277
   134
  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)" 
eberlm@66277
   135
    by blast
lp15@68064
   136
qed (auto simp: prod_defs)
eberlm@66277
   137
eberlm@66277
   138
definition abs_convergent_prod :: "(nat \<Rightarrow> _) \<Rightarrow> bool" where
eberlm@66277
   139
  "abs_convergent_prod f \<longleftrightarrow> convergent_prod (\<lambda>i. 1 + norm (f i - 1))"
eberlm@66277
   140
eberlm@66277
   141
lemma abs_convergent_prodI:
eberlm@66277
   142
  assumes "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   143
  shows   "abs_convergent_prod f"
eberlm@66277
   144
proof -
eberlm@66277
   145
  from assms obtain L where L: "(\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1)) \<longlonglongrightarrow> L"
eberlm@66277
   146
    by (auto simp: convergent_def)
eberlm@66277
   147
  have "L \<ge> 1"
eberlm@66277
   148
  proof (rule tendsto_le)
eberlm@66277
   149
    show "eventually (\<lambda>n. (\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> 1) sequentially"
eberlm@66277
   150
    proof (intro always_eventually allI)
eberlm@66277
   151
      fix n
eberlm@66277
   152
      have "(\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> (\<Prod>i\<le>n. 1)"
eberlm@66277
   153
        by (intro prod_mono) auto
eberlm@66277
   154
      thus "(\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> 1" by simp
eberlm@66277
   155
    qed
eberlm@66277
   156
  qed (use L in simp_all)
eberlm@66277
   157
  hence "L \<noteq> 0" by auto
lp15@68064
   158
  with L show ?thesis unfolding abs_convergent_prod_def prod_defs
eberlm@66277
   159
    by (intro exI[of _ "0::nat"] exI[of _ L]) auto
eberlm@66277
   160
qed
eberlm@66277
   161
eberlm@66277
   162
lemma
lp15@68064
   163
  fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"
eberlm@66277
   164
  assumes "convergent_prod f"
eberlm@66277
   165
  shows   convergent_prod_imp_convergent: "convergent (\<lambda>n. \<Prod>i\<le>n. f i)"
eberlm@66277
   166
    and   convergent_prod_to_zero_iff:    "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<exists>i. f i = 0)"
eberlm@66277
   167
proof -
eberlm@66277
   168
  from assms obtain M L 
eberlm@66277
   169
    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"
eberlm@66277
   170
    by (auto simp: convergent_prod_altdef)
eberlm@66277
   171
  note this(2)
eberlm@66277
   172
  also have "(\<lambda>n. \<Prod>i\<le>n. f (i + M)) = (\<lambda>n. \<Prod>i=M..M+n. f i)"
eberlm@66277
   173
    by (intro ext prod.reindex_bij_witness[of _ "\<lambda>n. n - M" "\<lambda>n. n + M"]) auto
eberlm@66277
   174
  finally have "(\<lambda>n. (\<Prod>i<M. f i) * (\<Prod>i=M..M+n. f i)) \<longlonglongrightarrow> (\<Prod>i<M. f i) * L"
eberlm@66277
   175
    by (intro tendsto_mult tendsto_const)
eberlm@66277
   176
  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))"
eberlm@66277
   177
    by (subst prod.union_disjoint) auto
eberlm@66277
   178
  also have "(\<lambda>n. {..<M} \<union> {M..M+n}) = (\<lambda>n. {..n+M})" by auto
eberlm@66277
   179
  finally have lim: "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f {..<M} * L" 
eberlm@66277
   180
    by (rule LIMSEQ_offset)
eberlm@66277
   181
  thus "convergent (\<lambda>n. \<Prod>i\<le>n. f i)"
eberlm@66277
   182
    by (auto simp: convergent_def)
eberlm@66277
   183
eberlm@66277
   184
  show "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<exists>i. f i = 0)"
eberlm@66277
   185
  proof
eberlm@66277
   186
    assume "\<exists>i. f i = 0"
eberlm@66277
   187
    then obtain i where "f i = 0" by auto
eberlm@66277
   188
    moreover with M have "i < M" by (cases "i < M") auto
eberlm@66277
   189
    ultimately have "(\<Prod>i<M. f i) = 0" by auto
eberlm@66277
   190
    with lim show "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0" by simp
eberlm@66277
   191
  next
eberlm@66277
   192
    assume "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0"
eberlm@66277
   193
    from tendsto_unique[OF _ this lim] and \<open>L \<noteq> 0\<close>
eberlm@66277
   194
    show "\<exists>i. f i = 0" by auto
eberlm@66277
   195
  qed
eberlm@66277
   196
qed
eberlm@66277
   197
lp15@68064
   198
lemma convergent_prod_iff_nz_lim:
lp15@68064
   199
  fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"
lp15@68064
   200
  assumes "\<And>i. f i \<noteq> 0"
lp15@68064
   201
  shows "convergent_prod f \<longleftrightarrow> (\<exists>L. (\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> L \<and> L \<noteq> 0)"
lp15@68064
   202
    (is "?lhs \<longleftrightarrow> ?rhs")
lp15@68064
   203
proof
lp15@68064
   204
  assume ?lhs then show ?rhs
lp15@68064
   205
    using assms convergentD convergent_prod_imp_convergent convergent_prod_to_zero_iff by blast
lp15@68064
   206
next
lp15@68064
   207
  assume ?rhs then show ?lhs
lp15@68064
   208
    unfolding prod_defs
lp15@68138
   209
    by (rule_tac x=0 in exI) auto
lp15@68064
   210
qed
lp15@68064
   211
lp15@68064
   212
lemma convergent_prod_iff_convergent: 
lp15@68064
   213
  fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"
lp15@68064
   214
  assumes "\<And>i. f i \<noteq> 0"
lp15@68064
   215
  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"
lp15@68138
   216
  by (force simp: convergent_prod_iff_nz_lim assms convergent_def limI)
lp15@68064
   217
lp15@68064
   218
eberlm@66277
   219
lemma abs_convergent_prod_altdef:
lp15@68064
   220
  fixes f :: "nat \<Rightarrow> 'a :: {one,real_normed_vector}"
lp15@68064
   221
  shows  "abs_convergent_prod f \<longleftrightarrow> convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   222
proof
eberlm@66277
   223
  assume "abs_convergent_prod f"
eberlm@66277
   224
  thus "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   225
    by (auto simp: abs_convergent_prod_def intro!: convergent_prod_imp_convergent)
eberlm@66277
   226
qed (auto intro: abs_convergent_prodI)
eberlm@66277
   227
eberlm@66277
   228
lemma weierstrass_prod_ineq:
eberlm@66277
   229
  fixes f :: "'a \<Rightarrow> real" 
eberlm@66277
   230
  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<in> {0..1}"
eberlm@66277
   231
  shows   "1 - sum f A \<le> (\<Prod>x\<in>A. 1 - f x)"
eberlm@66277
   232
  using assms
eberlm@66277
   233
proof (induction A rule: infinite_finite_induct)
eberlm@66277
   234
  case (insert x A)
eberlm@66277
   235
  from insert.hyps and insert.prems 
eberlm@66277
   236
    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)"
eberlm@66277
   237
    by (intro insert.IH add_mono mult_left_mono prod_mono) auto
eberlm@66277
   238
  with insert.hyps show ?case by (simp add: algebra_simps)
eberlm@66277
   239
qed simp_all
eberlm@66277
   240
eberlm@66277
   241
lemma norm_prod_minus1_le_prod_minus1:
eberlm@66277
   242
  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,comm_ring_1}"  
eberlm@66277
   243
  shows "norm (prod (\<lambda>n. 1 + f n) A - 1) \<le> prod (\<lambda>n. 1 + norm (f n)) A - 1"
eberlm@66277
   244
proof (induction A rule: infinite_finite_induct)
eberlm@66277
   245
  case (insert x A)
eberlm@66277
   246
  from insert.hyps have 
eberlm@66277
   247
    "norm ((\<Prod>n\<in>insert x A. 1 + f n) - 1) = 
eberlm@66277
   248
       norm ((\<Prod>n\<in>A. 1 + f n) - 1 + f x * (\<Prod>n\<in>A. 1 + f n))"
eberlm@66277
   249
    by (simp add: algebra_simps)
eberlm@66277
   250
  also have "\<dots> \<le> norm ((\<Prod>n\<in>A. 1 + f n) - 1) + norm (f x * (\<Prod>n\<in>A. 1 + f n))"
eberlm@66277
   251
    by (rule norm_triangle_ineq)
eberlm@66277
   252
  also have "norm (f x * (\<Prod>n\<in>A. 1 + f n)) = norm (f x) * (\<Prod>x\<in>A. norm (1 + f x))"
eberlm@66277
   253
    by (simp add: prod_norm norm_mult)
eberlm@66277
   254
  also have "(\<Prod>x\<in>A. norm (1 + f x)) \<le> (\<Prod>x\<in>A. norm (1::'a) + norm (f x))"
eberlm@66277
   255
    by (intro prod_mono norm_triangle_ineq ballI conjI) auto
eberlm@66277
   256
  also have "norm (1::'a) = 1" by simp
eberlm@66277
   257
  also note insert.IH
eberlm@66277
   258
  also have "(\<Prod>n\<in>A. 1 + norm (f n)) - 1 + norm (f x) * (\<Prod>x\<in>A. 1 + norm (f x)) =
lp15@68064
   259
             (\<Prod>n\<in>insert x A. 1 + norm (f n)) - 1"
eberlm@66277
   260
    using insert.hyps by (simp add: algebra_simps)
eberlm@66277
   261
  finally show ?case by - (simp_all add: mult_left_mono)
eberlm@66277
   262
qed simp_all
eberlm@66277
   263
eberlm@66277
   264
lemma convergent_prod_imp_ev_nonzero:
eberlm@66277
   265
  fixes f :: "nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}"
eberlm@66277
   266
  assumes "convergent_prod f"
eberlm@66277
   267
  shows   "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
eberlm@66277
   268
  using assms by (auto simp: eventually_at_top_linorder convergent_prod_altdef)
eberlm@66277
   269
eberlm@66277
   270
lemma convergent_prod_imp_LIMSEQ:
eberlm@66277
   271
  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_field}"
eberlm@66277
   272
  assumes "convergent_prod f"
eberlm@66277
   273
  shows   "f \<longlonglongrightarrow> 1"
eberlm@66277
   274
proof -
eberlm@66277
   275
  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"
eberlm@66277
   276
    by (auto simp: convergent_prod_altdef)
eberlm@66277
   277
  hence L': "(\<lambda>n. \<Prod>i\<le>Suc n. f (i+M)) \<longlonglongrightarrow> L" by (subst filterlim_sequentially_Suc)
eberlm@66277
   278
  have "(\<lambda>n. (\<Prod>i\<le>Suc n. f (i+M)) / (\<Prod>i\<le>n. f (i+M))) \<longlonglongrightarrow> L / L"
eberlm@66277
   279
    using L L' by (intro tendsto_divide) simp_all
eberlm@66277
   280
  also from L have "L / L = 1" by simp
eberlm@66277
   281
  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))"
eberlm@66277
   282
    using assms L by (auto simp: fun_eq_iff atMost_Suc)
eberlm@66277
   283
  finally show ?thesis by (rule LIMSEQ_offset)
eberlm@66277
   284
qed
eberlm@66277
   285
eberlm@66277
   286
lemma abs_convergent_prod_imp_summable:
eberlm@66277
   287
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
eberlm@66277
   288
  assumes "abs_convergent_prod f"
eberlm@66277
   289
  shows "summable (\<lambda>i. norm (f i - 1))"
eberlm@66277
   290
proof -
eberlm@66277
   291
  from assms have "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))" 
eberlm@66277
   292
    unfolding abs_convergent_prod_def by (rule convergent_prod_imp_convergent)
eberlm@66277
   293
  then obtain L where L: "(\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1)) \<longlonglongrightarrow> L"
eberlm@66277
   294
    unfolding convergent_def by blast
eberlm@66277
   295
  have "convergent (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))"
eberlm@66277
   296
  proof (rule Bseq_monoseq_convergent)
eberlm@66277
   297
    have "eventually (\<lambda>n. (\<Prod>i\<le>n. 1 + norm (f i - 1)) < L + 1) sequentially"
eberlm@66277
   298
      using L(1) by (rule order_tendstoD) simp_all
eberlm@66277
   299
    hence "\<forall>\<^sub>F x in sequentially. norm (\<Sum>i\<le>x. norm (f i - 1)) \<le> L + 1"
eberlm@66277
   300
    proof eventually_elim
eberlm@66277
   301
      case (elim n)
eberlm@66277
   302
      have "norm (\<Sum>i\<le>n. norm (f i - 1)) = (\<Sum>i\<le>n. norm (f i - 1))"
eberlm@66277
   303
        unfolding real_norm_def by (intro abs_of_nonneg sum_nonneg) simp_all
eberlm@66277
   304
      also have "\<dots> \<le> (\<Prod>i\<le>n. 1 + norm (f i - 1))" by (rule sum_le_prod) auto
eberlm@66277
   305
      also have "\<dots> < L + 1" by (rule elim)
eberlm@66277
   306
      finally show ?case by simp
eberlm@66277
   307
    qed
eberlm@66277
   308
    thus "Bseq (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))" by (rule BfunI)
eberlm@66277
   309
  next
eberlm@66277
   310
    show "monoseq (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))"
eberlm@66277
   311
      by (rule mono_SucI1) auto
eberlm@66277
   312
  qed
eberlm@66277
   313
  thus "summable (\<lambda>i. norm (f i - 1))" by (simp add: summable_iff_convergent')
eberlm@66277
   314
qed
eberlm@66277
   315
eberlm@66277
   316
lemma summable_imp_abs_convergent_prod:
eberlm@66277
   317
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
eberlm@66277
   318
  assumes "summable (\<lambda>i. norm (f i - 1))"
eberlm@66277
   319
  shows   "abs_convergent_prod f"
eberlm@66277
   320
proof (intro abs_convergent_prodI Bseq_monoseq_convergent)
eberlm@66277
   321
  show "monoseq (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   322
    by (intro mono_SucI1) 
eberlm@66277
   323
       (auto simp: atMost_Suc algebra_simps intro!: mult_nonneg_nonneg prod_nonneg)
eberlm@66277
   324
next
eberlm@66277
   325
  show "Bseq (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   326
  proof (rule Bseq_eventually_mono)
eberlm@66277
   327
    show "eventually (\<lambda>n. norm (\<Prod>i\<le>n. 1 + norm (f i - 1)) \<le> 
eberlm@66277
   328
            norm (exp (\<Sum>i\<le>n. norm (f i - 1)))) sequentially"
eberlm@66277
   329
      by (intro always_eventually allI) (auto simp: abs_prod exp_sum intro!: prod_mono)
eberlm@66277
   330
  next
eberlm@66277
   331
    from assms have "(\<lambda>n. \<Sum>i\<le>n. norm (f i - 1)) \<longlonglongrightarrow> (\<Sum>i. norm (f i - 1))"
eberlm@66277
   332
      using sums_def_le by blast
eberlm@66277
   333
    hence "(\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1))) \<longlonglongrightarrow> exp (\<Sum>i. norm (f i - 1))"
eberlm@66277
   334
      by (rule tendsto_exp)
eberlm@66277
   335
    hence "convergent (\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1)))"
eberlm@66277
   336
      by (rule convergentI)
eberlm@66277
   337
    thus "Bseq (\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1)))"
eberlm@66277
   338
      by (rule convergent_imp_Bseq)
eberlm@66277
   339
  qed
eberlm@66277
   340
qed
eberlm@66277
   341
eberlm@66277
   342
lemma abs_convergent_prod_conv_summable:
eberlm@66277
   343
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
eberlm@66277
   344
  shows "abs_convergent_prod f \<longleftrightarrow> summable (\<lambda>i. norm (f i - 1))"
eberlm@66277
   345
  by (blast intro: abs_convergent_prod_imp_summable summable_imp_abs_convergent_prod)
eberlm@66277
   346
eberlm@66277
   347
lemma abs_convergent_prod_imp_LIMSEQ:
eberlm@66277
   348
  fixes f :: "nat \<Rightarrow> 'a :: {comm_ring_1,real_normed_div_algebra}"
eberlm@66277
   349
  assumes "abs_convergent_prod f"
eberlm@66277
   350
  shows   "f \<longlonglongrightarrow> 1"
eberlm@66277
   351
proof -
eberlm@66277
   352
  from assms have "summable (\<lambda>n. norm (f n - 1))"
eberlm@66277
   353
    by (rule abs_convergent_prod_imp_summable)
eberlm@66277
   354
  from summable_LIMSEQ_zero[OF this] have "(\<lambda>n. f n - 1) \<longlonglongrightarrow> 0"
eberlm@66277
   355
    by (simp add: tendsto_norm_zero_iff)
eberlm@66277
   356
  from tendsto_add[OF this tendsto_const[of 1]] show ?thesis by simp
eberlm@66277
   357
qed
eberlm@66277
   358
eberlm@66277
   359
lemma abs_convergent_prod_imp_ev_nonzero:
eberlm@66277
   360
  fixes f :: "nat \<Rightarrow> 'a :: {comm_ring_1,real_normed_div_algebra}"
eberlm@66277
   361
  assumes "abs_convergent_prod f"
eberlm@66277
   362
  shows   "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
eberlm@66277
   363
proof -
eberlm@66277
   364
  from assms have "f \<longlonglongrightarrow> 1" 
eberlm@66277
   365
    by (rule abs_convergent_prod_imp_LIMSEQ)
eberlm@66277
   366
  hence "eventually (\<lambda>n. dist (f n) 1 < 1) at_top"
eberlm@66277
   367
    by (auto simp: tendsto_iff)
eberlm@66277
   368
  thus ?thesis by eventually_elim auto
eberlm@66277
   369
qed
eberlm@66277
   370
eberlm@66277
   371
lemma convergent_prod_offset:
eberlm@66277
   372
  assumes "convergent_prod (\<lambda>n. f (n + m))"  
eberlm@66277
   373
  shows   "convergent_prod f"
eberlm@66277
   374
proof -
eberlm@66277
   375
  from assms obtain M L where "(\<lambda>n. \<Prod>k\<le>n. f (k + (M + m))) \<longlonglongrightarrow> L" "L \<noteq> 0"
lp15@68064
   376
    by (auto simp: prod_defs add.assoc)
lp15@68064
   377
  thus "convergent_prod f" 
lp15@68064
   378
    unfolding prod_defs by blast
eberlm@66277
   379
qed
eberlm@66277
   380
eberlm@66277
   381
lemma abs_convergent_prod_offset:
eberlm@66277
   382
  assumes "abs_convergent_prod (\<lambda>n. f (n + m))"  
eberlm@66277
   383
  shows   "abs_convergent_prod f"
eberlm@66277
   384
  using assms unfolding abs_convergent_prod_def by (rule convergent_prod_offset)
eberlm@66277
   385
lp15@68361
   386
lemma raw_has_prod_ignore_initial_segment:
lp15@68361
   387
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_field"
lp15@68361
   388
  assumes "raw_has_prod f M p" "N \<ge> M"
lp15@68361
   389
  obtains q where  "raw_has_prod f N q"
eberlm@66277
   390
proof -
lp15@68361
   391
  have p: "(\<lambda>n. \<Prod>k\<le>n. f (k + M)) \<longlonglongrightarrow> p" and "p \<noteq> 0" 
lp15@68361
   392
    using assms by (auto simp: raw_has_prod_def)
lp15@68361
   393
  then have nz: "\<And>n. n \<ge> M \<Longrightarrow> f n \<noteq> 0"
lp15@68361
   394
    using assms by (auto simp: raw_has_prod_eq_0)
lp15@68361
   395
  define C where "C = (\<Prod>k<N-M. f (k + M))"
eberlm@66277
   396
  from nz have [simp]: "C \<noteq> 0" 
eberlm@66277
   397
    by (auto simp: C_def)
eberlm@66277
   398
lp15@68361
   399
  from p have "(\<lambda>i. \<Prod>k\<le>i + (N-M). f (k + M)) \<longlonglongrightarrow> p" 
eberlm@66277
   400
    by (rule LIMSEQ_ignore_initial_segment)
lp15@68361
   401
  also have "(\<lambda>i. \<Prod>k\<le>i + (N-M). f (k + M)) = (\<lambda>n. C * (\<Prod>k\<le>n. f (k + N)))"
eberlm@66277
   402
  proof (rule ext, goal_cases)
eberlm@66277
   403
    case (1 n)
lp15@68361
   404
    have "{..n+(N-M)} = {..<(N-M)} \<union> {(N-M)..n+(N-M)}" by auto
lp15@68361
   405
    also have "(\<Prod>k\<in>\<dots>. f (k + M)) = C * (\<Prod>k=(N-M)..n+(N-M). f (k + M))"
eberlm@66277
   406
      unfolding C_def by (rule prod.union_disjoint) auto
lp15@68361
   407
    also have "(\<Prod>k=(N-M)..n+(N-M). f (k + M)) = (\<Prod>k\<le>n. f (k + (N-M) + M))"
lp15@68361
   408
      by (intro ext prod.reindex_bij_witness[of _ "\<lambda>k. k + (N-M)" "\<lambda>k. k - (N-M)"]) auto
lp15@68361
   409
    finally show ?case
lp15@68361
   410
      using \<open>N \<ge> M\<close> by (simp add: add_ac)
eberlm@66277
   411
  qed
lp15@68361
   412
  finally have "(\<lambda>n. C * (\<Prod>k\<le>n. f (k + N)) / C) \<longlonglongrightarrow> p / C"
eberlm@66277
   413
    by (intro tendsto_divide tendsto_const) auto
lp15@68361
   414
  hence "(\<lambda>n. \<Prod>k\<le>n. f (k + N)) \<longlonglongrightarrow> p / C" by simp
lp15@68361
   415
  moreover from \<open>p \<noteq> 0\<close> have "p / C \<noteq> 0" by simp
lp15@68361
   416
  ultimately show ?thesis
lp15@68361
   417
    using raw_has_prod_def that by blast 
eberlm@66277
   418
qed
eberlm@66277
   419
lp15@68361
   420
corollary convergent_prod_ignore_initial_segment:
lp15@68361
   421
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_field"
lp15@68361
   422
  assumes "convergent_prod f"
lp15@68361
   423
  shows   "convergent_prod (\<lambda>n. f (n + m))"
lp15@68361
   424
  using assms
lp15@68361
   425
  unfolding convergent_prod_def 
lp15@68361
   426
  apply clarify
lp15@68361
   427
  apply (erule_tac N="M+m" in raw_has_prod_ignore_initial_segment)
lp15@68361
   428
  apply (auto simp add: raw_has_prod_def add_ac)
lp15@68361
   429
  done
lp15@68361
   430
lp15@68136
   431
corollary convergent_prod_ignore_nonzero_segment:
lp15@68136
   432
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_field"
lp15@68136
   433
  assumes f: "convergent_prod f" and nz: "\<And>i. i \<ge> M \<Longrightarrow> f i \<noteq> 0"
lp15@68361
   434
  shows "\<exists>p. raw_has_prod f M p"
lp15@68136
   435
  using convergent_prod_ignore_initial_segment [OF f]
lp15@68136
   436
  by (metis convergent_LIMSEQ_iff convergent_prod_iff_convergent le_add_same_cancel2 nz prod_defs(1) zero_order(1))
lp15@68136
   437
lp15@68136
   438
corollary abs_convergent_prod_ignore_initial_segment:
eberlm@66277
   439
  assumes "abs_convergent_prod f"
eberlm@66277
   440
  shows   "abs_convergent_prod (\<lambda>n. f (n + m))"
eberlm@66277
   441
  using assms unfolding abs_convergent_prod_def 
eberlm@66277
   442
  by (rule convergent_prod_ignore_initial_segment)
eberlm@66277
   443
eberlm@66277
   444
lemma abs_convergent_prod_imp_convergent_prod:
eberlm@66277
   445
  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,complete_space,comm_ring_1}"
eberlm@66277
   446
  assumes "abs_convergent_prod f"
eberlm@66277
   447
  shows   "convergent_prod f"
eberlm@66277
   448
proof -
eberlm@66277
   449
  from assms have "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
eberlm@66277
   450
    by (rule abs_convergent_prod_imp_ev_nonzero)
eberlm@66277
   451
  then obtain N where N: "f n \<noteq> 0" if "n \<ge> N" for n 
eberlm@66277
   452
    by (auto simp: eventually_at_top_linorder)
eberlm@66277
   453
  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)"
eberlm@66277
   454
eberlm@66277
   455
  have "Cauchy ?P"
eberlm@66277
   456
  proof (rule CauchyI', goal_cases)
eberlm@66277
   457
    case (1 \<epsilon>)
eberlm@66277
   458
    from assms have "abs_convergent_prod (\<lambda>n. f (n + N))"
eberlm@66277
   459
      by (rule abs_convergent_prod_ignore_initial_segment)
eberlm@66277
   460
    hence "Cauchy ?Q"
eberlm@66277
   461
      unfolding abs_convergent_prod_def
eberlm@66277
   462
      by (intro convergent_Cauchy convergent_prod_imp_convergent)
eberlm@66277
   463
    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
eberlm@66277
   464
      by blast
eberlm@66277
   465
    show ?case
eberlm@66277
   466
    proof (rule exI[of _ M], safe, goal_cases)
eberlm@66277
   467
      case (1 m n)
eberlm@66277
   468
      have "dist (?P m) (?P n) = norm (?P n - ?P m)"
eberlm@66277
   469
        by (simp add: dist_norm norm_minus_commute)
eberlm@66277
   470
      also from 1 have "{..n} = {..m} \<union> {m<..n}" by auto
eberlm@66277
   471
      hence "norm (?P n - ?P m) = norm (?P m * (\<Prod>k\<in>{m<..n}. f (k + N)) - ?P m)"
eberlm@66277
   472
        by (subst prod.union_disjoint [symmetric]) (auto simp: algebra_simps)
eberlm@66277
   473
      also have "\<dots> = norm (?P m * ((\<Prod>k\<in>{m<..n}. f (k + N)) - 1))"
eberlm@66277
   474
        by (simp add: algebra_simps)
eberlm@66277
   475
      also have "\<dots> = (\<Prod>k\<le>m. norm (f (k + N))) * norm ((\<Prod>k\<in>{m<..n}. f (k + N)) - 1)"
eberlm@66277
   476
        by (simp add: norm_mult prod_norm)
eberlm@66277
   477
      also have "\<dots> \<le> ?Q m * ((\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) - 1)"
eberlm@66277
   478
        using norm_prod_minus1_le_prod_minus1[of "\<lambda>k. f (k + N) - 1" "{m<..n}"]
eberlm@66277
   479
              norm_triangle_ineq[of 1 "f k - 1" for k]
eberlm@66277
   480
        by (intro mult_mono prod_mono ballI conjI norm_prod_minus1_le_prod_minus1 prod_nonneg) auto
eberlm@66277
   481
      also have "\<dots> = ?Q m * (\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) - ?Q m"
eberlm@66277
   482
        by (simp add: algebra_simps)
eberlm@66277
   483
      also have "?Q m * (\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) = 
eberlm@66277
   484
                   (\<Prod>k\<in>{..m}\<union>{m<..n}. 1 + norm (f (k + N) - 1))"
eberlm@66277
   485
        by (rule prod.union_disjoint [symmetric]) auto
eberlm@66277
   486
      also from 1 have "{..m}\<union>{m<..n} = {..n}" by auto
eberlm@66277
   487
      also have "?Q n - ?Q m \<le> norm (?Q n - ?Q m)" by simp
eberlm@66277
   488
      also from 1 have "\<dots> < \<epsilon>" by (intro M) auto
eberlm@66277
   489
      finally show ?case .
eberlm@66277
   490
    qed
eberlm@66277
   491
  qed
eberlm@66277
   492
  hence conv: "convergent ?P" by (rule Cauchy_convergent)
eberlm@66277
   493
  then obtain L where L: "?P \<longlonglongrightarrow> L"
eberlm@66277
   494
    by (auto simp: convergent_def)
eberlm@66277
   495
eberlm@66277
   496
  have "L \<noteq> 0"
eberlm@66277
   497
  proof
eberlm@66277
   498
    assume [simp]: "L = 0"
eberlm@66277
   499
    from tendsto_norm[OF L] have limit: "(\<lambda>n. \<Prod>k\<le>n. norm (f (k + N))) \<longlonglongrightarrow> 0" 
eberlm@66277
   500
      by (simp add: prod_norm)
eberlm@66277
   501
eberlm@66277
   502
    from assms have "(\<lambda>n. f (n + N)) \<longlonglongrightarrow> 1"
eberlm@66277
   503
      by (intro abs_convergent_prod_imp_LIMSEQ abs_convergent_prod_ignore_initial_segment)
eberlm@66277
   504
    hence "eventually (\<lambda>n. norm (f (n + N) - 1) < 1) sequentially"
eberlm@66277
   505
      by (auto simp: tendsto_iff dist_norm)
eberlm@66277
   506
    then obtain M0 where M0: "norm (f (n + N) - 1) < 1" if "n \<ge> M0" for n
eberlm@66277
   507
      by (auto simp: eventually_at_top_linorder)
eberlm@66277
   508
eberlm@66277
   509
    {
eberlm@66277
   510
      fix M assume M: "M \<ge> M0"
eberlm@66277
   511
      with M0 have M: "norm (f (n + N) - 1) < 1" if "n \<ge> M" for n using that by simp
eberlm@66277
   512
eberlm@66277
   513
      have "(\<lambda>n. \<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<longlonglongrightarrow> 0"
eberlm@66277
   514
      proof (rule tendsto_sandwich)
eberlm@66277
   515
        show "eventually (\<lambda>n. (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<ge> 0) sequentially"
eberlm@66277
   516
          using M by (intro always_eventually prod_nonneg allI ballI) (auto intro: less_imp_le)
eberlm@66277
   517
        have "norm (1::'a) - norm (f (i + M + N) - 1) \<le> norm (f (i + M + N))" for i
eberlm@66277
   518
          using norm_triangle_ineq3[of "f (i + M + N)" 1] by simp
eberlm@66277
   519
        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"
eberlm@66277
   520
          using M by (intro always_eventually allI prod_mono ballI conjI) (auto intro: less_imp_le)
eberlm@66277
   521
        
eberlm@66277
   522
        define C where "C = (\<Prod>k<M. norm (f (k + N)))"
eberlm@66277
   523
        from N have [simp]: "C \<noteq> 0" by (auto simp: C_def)
eberlm@66277
   524
        from L have "(\<lambda>n. norm (\<Prod>k\<le>n+M. f (k + N))) \<longlonglongrightarrow> 0"
eberlm@66277
   525
          by (intro LIMSEQ_ignore_initial_segment) (simp add: tendsto_norm_zero_iff)
eberlm@66277
   526
        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))))"
eberlm@66277
   527
        proof (rule ext, goal_cases)
eberlm@66277
   528
          case (1 n)
eberlm@66277
   529
          have "{..n+M} = {..<M} \<union> {M..n+M}" by auto
eberlm@66277
   530
          also have "norm (\<Prod>k\<in>\<dots>. f (k + N)) = C * norm (\<Prod>k=M..n+M. f (k + N))"
eberlm@66277
   531
            unfolding C_def by (subst prod.union_disjoint) (auto simp: norm_mult prod_norm)
eberlm@66277
   532
          also have "(\<Prod>k=M..n+M. f (k + N)) = (\<Prod>k\<le>n. f (k + N + M))"
eberlm@66277
   533
            by (intro prod.reindex_bij_witness[of _ "\<lambda>i. i + M" "\<lambda>i. i - M"]) auto
eberlm@66277
   534
          finally show ?case by (simp add: add_ac prod_norm)
eberlm@66277
   535
        qed
eberlm@66277
   536
        finally have "(\<lambda>n. C * (\<Prod>k\<le>n. norm (f (k + M + N))) / C) \<longlonglongrightarrow> 0 / C"
eberlm@66277
   537
          by (intro tendsto_divide tendsto_const) auto
eberlm@66277
   538
        thus "(\<lambda>n. \<Prod>k\<le>n. norm (f (k + M + N))) \<longlonglongrightarrow> 0" by simp
eberlm@66277
   539
      qed simp_all
eberlm@66277
   540
eberlm@66277
   541
      have "1 - (\<Sum>i. norm (f (i + M + N) - 1)) \<le> 0"
eberlm@66277
   542
      proof (rule tendsto_le)
eberlm@66277
   543
        show "eventually (\<lambda>n. 1 - (\<Sum>k\<le>n. norm (f (k+M+N) - 1)) \<le> 
eberlm@66277
   544
                                (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1))) at_top"
eberlm@66277
   545
          using M by (intro always_eventually allI weierstrass_prod_ineq) (auto intro: less_imp_le)
eberlm@66277
   546
        show "(\<lambda>n. \<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<longlonglongrightarrow> 0" by fact
eberlm@66277
   547
        show "(\<lambda>n. 1 - (\<Sum>k\<le>n. norm (f (k + M + N) - 1)))
eberlm@66277
   548
                  \<longlonglongrightarrow> 1 - (\<Sum>i. norm (f (i + M + N) - 1))"
eberlm@66277
   549
          by (intro tendsto_intros summable_LIMSEQ' summable_ignore_initial_segment 
eberlm@66277
   550
                abs_convergent_prod_imp_summable assms)
eberlm@66277
   551
      qed simp_all
eberlm@66277
   552
      hence "(\<Sum>i. norm (f (i + M + N) - 1)) \<ge> 1" by simp
eberlm@66277
   553
      also have "\<dots> + (\<Sum>i<M. norm (f (i + N) - 1)) = (\<Sum>i. norm (f (i + N) - 1))"
eberlm@66277
   554
        by (intro suminf_split_initial_segment [symmetric] summable_ignore_initial_segment
eberlm@66277
   555
              abs_convergent_prod_imp_summable assms)
eberlm@66277
   556
      finally have "1 + (\<Sum>i<M. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))" by simp
eberlm@66277
   557
    } note * = this
eberlm@66277
   558
eberlm@66277
   559
    have "1 + (\<Sum>i. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))"
eberlm@66277
   560
    proof (rule tendsto_le)
eberlm@66277
   561
      show "(\<lambda>M. 1 + (\<Sum>i<M. norm (f (i + N) - 1))) \<longlonglongrightarrow> 1 + (\<Sum>i. norm (f (i + N) - 1))"
eberlm@66277
   562
        by (intro tendsto_intros summable_LIMSEQ summable_ignore_initial_segment 
eberlm@66277
   563
                abs_convergent_prod_imp_summable assms)
eberlm@66277
   564
      show "eventually (\<lambda>M. 1 + (\<Sum>i<M. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))) at_top"
eberlm@66277
   565
        using eventually_ge_at_top[of M0] by eventually_elim (use * in auto)
eberlm@66277
   566
    qed simp_all
eberlm@66277
   567
    thus False by simp
eberlm@66277
   568
  qed
lp15@68064
   569
  with L show ?thesis by (auto simp: prod_defs)
lp15@68064
   570
qed
lp15@68064
   571
lp15@68361
   572
lemma raw_has_prod_cases:
lp15@68064
   573
  fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"
lp15@68361
   574
  assumes "raw_has_prod f M p"
lp15@68361
   575
  obtains i where "i<M" "f i = 0" | p where "raw_has_prod f 0 p"
lp15@68136
   576
proof -
lp15@68136
   577
  have "(\<lambda>n. \<Prod>i\<le>n. f (i + M)) \<longlonglongrightarrow> p" "p \<noteq> 0"
lp15@68361
   578
    using assms unfolding raw_has_prod_def by blast+
lp15@68064
   579
  then have "(\<lambda>n. prod f {..<M} * (\<Prod>i\<le>n. f (i + M))) \<longlonglongrightarrow> prod f {..<M} * p"
lp15@68064
   580
    by (metis tendsto_mult_left)
lp15@68064
   581
  moreover have "prod f {..<M} * (\<Prod>i\<le>n. f (i + M)) = prod f {..n+M}" for n
lp15@68064
   582
  proof -
lp15@68064
   583
    have "{..n+M} = {..<M} \<union> {M..n+M}"
lp15@68064
   584
      by auto
lp15@68064
   585
    then have "prod f {..n+M} = prod f {..<M} * prod f {M..n+M}"
lp15@68064
   586
      by simp (subst prod.union_disjoint; force)
lp15@68138
   587
    also have "\<dots> = prod f {..<M} * (\<Prod>i\<le>n. f (i + M))"
lp15@68064
   588
      by (metis (mono_tags, lifting) add.left_neutral atMost_atLeast0 prod_shift_bounds_cl_nat_ivl)
lp15@68064
   589
    finally show ?thesis by metis
lp15@68064
   590
  qed
lp15@68064
   591
  ultimately have "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f {..<M} * p"
lp15@68064
   592
    by (auto intro: LIMSEQ_offset [where k=M])
lp15@68361
   593
  then have "raw_has_prod f 0 (prod f {..<M} * p)" if "\<forall>i<M. f i \<noteq> 0"
lp15@68361
   594
    using \<open>p \<noteq> 0\<close> assms that by (auto simp: raw_has_prod_def)
lp15@68136
   595
  then show thesis
lp15@68136
   596
    using that by blast
lp15@68064
   597
qed
lp15@68064
   598
lp15@68136
   599
corollary convergent_prod_offset_0:
lp15@68136
   600
  fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"
lp15@68136
   601
  assumes "convergent_prod f" "\<And>i. f i \<noteq> 0"
lp15@68361
   602
  shows "\<exists>p. raw_has_prod f 0 p"
lp15@68361
   603
  using assms convergent_prod_def raw_has_prod_cases by blast
lp15@68136
   604
lp15@68064
   605
lemma prodinf_eq_lim:
lp15@68064
   606
  fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"
lp15@68064
   607
  assumes "convergent_prod f" "\<And>i. f i \<noteq> 0"
lp15@68064
   608
  shows "prodinf f = lim (\<lambda>n. \<Prod>i\<le>n. f i)"
lp15@68064
   609
  using assms convergent_prod_offset_0 [OF assms]
lp15@68064
   610
  by (simp add: prod_defs lim_def) (metis (no_types) assms(1) convergent_prod_to_zero_iff)
lp15@68064
   611
lp15@68064
   612
lemma has_prod_one[simp, intro]: "(\<lambda>n. 1) has_prod 1"
lp15@68064
   613
  unfolding prod_defs by auto
lp15@68064
   614
lp15@68064
   615
lemma convergent_prod_one[simp, intro]: "convergent_prod (\<lambda>n. 1)"
lp15@68064
   616
  unfolding prod_defs by auto
lp15@68064
   617
lp15@68064
   618
lemma prodinf_cong: "(\<And>n. f n = g n) \<Longrightarrow> prodinf f = prodinf g"
lp15@68064
   619
  by presburger
lp15@68064
   620
lp15@68064
   621
lemma convergent_prod_cong:
lp15@68064
   622
  fixes f g :: "nat \<Rightarrow> 'a::{field,topological_semigroup_mult,t2_space}"
lp15@68064
   623
  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"
lp15@68064
   624
  shows "convergent_prod f = convergent_prod g"
lp15@68064
   625
proof -
lp15@68064
   626
  from assms obtain N where N: "\<forall>n\<ge>N. f n = g n"
lp15@68064
   627
    by (auto simp: eventually_at_top_linorder)
lp15@68064
   628
  define C where "C = (\<Prod>k<N. f k / g k)"
lp15@68064
   629
  with g have "C \<noteq> 0"
lp15@68064
   630
    by (simp add: f)
lp15@68064
   631
  have *: "eventually (\<lambda>n. prod f {..n} = C * prod g {..n}) sequentially"
lp15@68064
   632
    using eventually_ge_at_top[of N]
lp15@68064
   633
  proof eventually_elim
lp15@68064
   634
    case (elim n)
lp15@68064
   635
    then have "{..n} = {..<N} \<union> {N..n}"
lp15@68064
   636
      by auto
lp15@68138
   637
    also have "prod f \<dots> = prod f {..<N} * prod f {N..n}"
lp15@68064
   638
      by (intro prod.union_disjoint) auto
lp15@68064
   639
    also from N have "prod f {N..n} = prod g {N..n}"
lp15@68064
   640
      by (intro prod.cong) simp_all
lp15@68064
   641
    also have "prod f {..<N} * prod g {N..n} = C * (prod g {..<N} * prod g {N..n})"
lp15@68064
   642
      unfolding C_def by (simp add: g prod_dividef)
lp15@68064
   643
    also have "prod g {..<N} * prod g {N..n} = prod g ({..<N} \<union> {N..n})"
lp15@68064
   644
      by (intro prod.union_disjoint [symmetric]) auto
lp15@68064
   645
    also from elim have "{..<N} \<union> {N..n} = {..n}"
lp15@68064
   646
      by auto                                                                    
lp15@68064
   647
    finally show "prod f {..n} = C * prod g {..n}" .
lp15@68064
   648
  qed
lp15@68064
   649
  then have cong: "convergent (\<lambda>n. prod f {..n}) = convergent (\<lambda>n. C * prod g {..n})"
lp15@68064
   650
    by (rule convergent_cong)
lp15@68064
   651
  show ?thesis
lp15@68064
   652
  proof
lp15@68064
   653
    assume cf: "convergent_prod f"
lp15@68064
   654
    then have "\<not> (\<lambda>n. prod g {..n}) \<longlonglongrightarrow> 0"
lp15@68064
   655
      using tendsto_mult_left * convergent_prod_to_zero_iff f filterlim_cong by fastforce
lp15@68064
   656
    then show "convergent_prod g"
lp15@68064
   657
      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)
lp15@68064
   658
  next
lp15@68064
   659
    assume cg: "convergent_prod g"
lp15@68064
   660
    have "\<exists>a. C * a \<noteq> 0 \<and> (\<lambda>n. prod g {..n}) \<longlonglongrightarrow> a"
lp15@68064
   661
      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)
lp15@68064
   662
    then show "convergent_prod f"
lp15@68064
   663
      using "*" tendsto_mult_left filterlim_cong
lp15@68064
   664
      by (fastforce simp add: convergent_prod_iff_nz_lim f)
lp15@68064
   665
  qed
eberlm@66277
   666
qed
eberlm@66277
   667
lp15@68071
   668
lemma has_prod_finite:
lp15@68361
   669
  fixes f :: "nat \<Rightarrow> 'a::{semidom,t2_space}"
lp15@68071
   670
  assumes [simp]: "finite N"
lp15@68071
   671
    and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 1"
lp15@68071
   672
  shows "f has_prod (\<Prod>n\<in>N. f n)"
lp15@68071
   673
proof -
lp15@68071
   674
  have eq: "prod f {..n + Suc (Max N)} = prod f N" for n
lp15@68071
   675
  proof (rule prod.mono_neutral_right)
lp15@68071
   676
    show "N \<subseteq> {..n + Suc (Max N)}"
lp15@68138
   677
      by (auto simp: le_Suc_eq trans_le_add2)
lp15@68071
   678
    show "\<forall>i\<in>{..n + Suc (Max N)} - N. f i = 1"
lp15@68071
   679
      using f by blast
lp15@68071
   680
  qed auto
lp15@68071
   681
  show ?thesis
lp15@68071
   682
  proof (cases "\<forall>n\<in>N. f n \<noteq> 0")
lp15@68071
   683
    case True
lp15@68071
   684
    then have "prod f N \<noteq> 0"
lp15@68071
   685
      by simp
lp15@68071
   686
    moreover have "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f N"
lp15@68071
   687
      by (rule LIMSEQ_offset[of _ "Suc (Max N)"]) (simp add: eq atLeast0LessThan del: add_Suc_right)
lp15@68071
   688
    ultimately show ?thesis
lp15@68361
   689
      by (simp add: raw_has_prod_def has_prod_def)
lp15@68071
   690
  next
lp15@68071
   691
    case False
lp15@68071
   692
    then obtain k where "k \<in> N" "f k = 0"
lp15@68071
   693
      by auto
lp15@68071
   694
    let ?Z = "{n \<in> N. f n = 0}"
lp15@68071
   695
    have maxge: "Max ?Z \<ge> n" if "f n = 0" for n
lp15@68071
   696
      using Max_ge [of ?Z] \<open>finite N\<close> \<open>f n = 0\<close>
lp15@68071
   697
      by (metis (mono_tags) Collect_mem_eq f finite_Collect_conjI mem_Collect_eq zero_neq_one)
lp15@68071
   698
    let ?q = "prod f {Suc (Max ?Z)..Max N}"
lp15@68071
   699
    have [simp]: "?q \<noteq> 0"
lp15@68071
   700
      using maxge Suc_n_not_le_n le_trans by force
lp15@68076
   701
    have eq: "(\<Prod>i\<le>n + Max N. f (Suc (i + Max ?Z))) = ?q" for n
lp15@68076
   702
    proof -
lp15@68076
   703
      have "(\<Prod>i\<le>n + Max N. f (Suc (i + Max ?Z))) = prod f {Suc (Max ?Z)..n + Max N + Suc (Max ?Z)}" 
lp15@68076
   704
      proof (rule prod.reindex_cong [where l = "\<lambda>i. i + Suc (Max ?Z)", THEN sym])
lp15@68076
   705
        show "{Suc (Max ?Z)..n + Max N + Suc (Max ?Z)} = (\<lambda>i. i + Suc (Max ?Z)) ` {..n + Max N}"
lp15@68076
   706
          using le_Suc_ex by fastforce
lp15@68076
   707
      qed (auto simp: inj_on_def)
lp15@68138
   708
      also have "\<dots> = ?q"
lp15@68076
   709
        by (rule prod.mono_neutral_right)
lp15@68076
   710
           (use Max.coboundedI [OF \<open>finite N\<close>] f in \<open>force+\<close>)
lp15@68076
   711
      finally show ?thesis .
lp15@68076
   712
    qed
lp15@68361
   713
    have q: "raw_has_prod f (Suc (Max ?Z)) ?q"
lp15@68361
   714
    proof (simp add: raw_has_prod_def)
lp15@68076
   715
      show "(\<lambda>n. \<Prod>i\<le>n. f (Suc (i + Max ?Z))) \<longlonglongrightarrow> ?q"
lp15@68076
   716
        by (rule LIMSEQ_offset[of _ "(Max N)"]) (simp add: eq)
lp15@68076
   717
    qed
lp15@68071
   718
    show ?thesis
lp15@68071
   719
      unfolding has_prod_def
lp15@68071
   720
    proof (intro disjI2 exI conjI)      
lp15@68071
   721
      show "prod f N = 0"
lp15@68071
   722
        using \<open>f k = 0\<close> \<open>k \<in> N\<close> \<open>finite N\<close> prod_zero by blast
lp15@68071
   723
      show "f (Max ?Z) = 0"
lp15@68071
   724
        using Max_in [of ?Z] \<open>finite N\<close> \<open>f k = 0\<close> \<open>k \<in> N\<close> by auto
lp15@68071
   725
    qed (use q in auto)
lp15@68071
   726
  qed
lp15@68071
   727
qed
lp15@68071
   728
lp15@68071
   729
corollary has_prod_0:
lp15@68361
   730
  fixes f :: "nat \<Rightarrow> 'a::{semidom,t2_space}"
lp15@68071
   731
  assumes "\<And>n. f n = 1"
lp15@68071
   732
  shows "f has_prod 1"
lp15@68071
   733
  by (simp add: assms has_prod_cong)
lp15@68071
   734
lp15@68361
   735
lemma prodinf_zero[simp]: "prodinf (\<lambda>n. 1::'a::real_normed_field) = 1"
lp15@68361
   736
  using has_prod_unique by force
lp15@68361
   737
lp15@68071
   738
lemma convergent_prod_finite:
lp15@68071
   739
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68071
   740
  assumes "finite N" "\<And>n. n \<notin> N \<Longrightarrow> f n = 1"
lp15@68071
   741
  shows "convergent_prod f"
lp15@68071
   742
proof -
lp15@68361
   743
  have "\<exists>n p. raw_has_prod f n p"
lp15@68071
   744
    using assms has_prod_def has_prod_finite by blast
lp15@68071
   745
  then show ?thesis
lp15@68071
   746
    by (simp add: convergent_prod_def)
lp15@68071
   747
qed
lp15@68071
   748
lp15@68127
   749
lemma has_prod_If_finite_set:
lp15@68127
   750
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   751
  shows "finite A \<Longrightarrow> (\<lambda>r. if r \<in> A then f r else 1) has_prod (\<Prod>r\<in>A. f r)"
lp15@68127
   752
  using has_prod_finite[of A "(\<lambda>r. if r \<in> A then f r else 1)"]
lp15@68127
   753
  by simp
lp15@68127
   754
lp15@68127
   755
lemma has_prod_If_finite:
lp15@68127
   756
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   757
  shows "finite {r. P r} \<Longrightarrow> (\<lambda>r. if P r then f r else 1) has_prod (\<Prod>r | P r. f r)"
lp15@68127
   758
  using has_prod_If_finite_set[of "{r. P r}"] by simp
lp15@68127
   759
lp15@68127
   760
lemma convergent_prod_If_finite_set[simp, intro]:
lp15@68127
   761
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   762
  shows "finite A \<Longrightarrow> convergent_prod (\<lambda>r. if r \<in> A then f r else 1)"
lp15@68127
   763
  by (simp add: convergent_prod_finite)
lp15@68127
   764
lp15@68127
   765
lemma convergent_prod_If_finite[simp, intro]:
lp15@68127
   766
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   767
  shows "finite {r. P r} \<Longrightarrow> convergent_prod (\<lambda>r. if P r then f r else 1)"
lp15@68127
   768
  using convergent_prod_def has_prod_If_finite has_prod_def by fastforce
lp15@68127
   769
lp15@68127
   770
lemma has_prod_single:
lp15@68127
   771
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   772
  shows "(\<lambda>r. if r = i then f r else 1) has_prod f i"
lp15@68127
   773
  using has_prod_If_finite[of "\<lambda>r. r = i"] by simp
lp15@68127
   774
lp15@68136
   775
context
lp15@68136
   776
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_field"
lp15@68136
   777
begin
lp15@68136
   778
lp15@68136
   779
lemma convergent_prod_imp_has_prod: 
lp15@68136
   780
  assumes "convergent_prod f"
lp15@68136
   781
  shows "\<exists>p. f has_prod p"
lp15@68136
   782
proof -
lp15@68361
   783
  obtain M p where p: "raw_has_prod f M p"
lp15@68136
   784
    using assms convergent_prod_def by blast
lp15@68136
   785
  then have "p \<noteq> 0"
lp15@68361
   786
    using raw_has_prod_nonzero by blast
lp15@68136
   787
  with p have fnz: "f i \<noteq> 0" if "i \<ge> M" for i
lp15@68361
   788
    using raw_has_prod_eq_0 that by blast
lp15@68136
   789
  define C where "C = (\<Prod>n<M. f n)"
lp15@68136
   790
  show ?thesis
lp15@68136
   791
  proof (cases "\<forall>n\<le>M. f n \<noteq> 0")
lp15@68136
   792
    case True
lp15@68136
   793
    then have "C \<noteq> 0"
lp15@68136
   794
      by (simp add: C_def)
lp15@68136
   795
    then show ?thesis
lp15@68136
   796
      by (meson True assms convergent_prod_offset_0 fnz has_prod_def nat_le_linear)
lp15@68136
   797
  next
lp15@68136
   798
    case False
lp15@68136
   799
    let ?N = "GREATEST n. f n = 0"
lp15@68136
   800
    have 0: "f ?N = 0"
lp15@68136
   801
      using fnz False
lp15@68136
   802
      by (metis (mono_tags, lifting) GreatestI_ex_nat nat_le_linear)
lp15@68136
   803
    have "f i \<noteq> 0" if "i > ?N" for i
lp15@68136
   804
      by (metis (mono_tags, lifting) Greatest_le_nat fnz leD linear that)
lp15@68361
   805
    then have "\<exists>p. raw_has_prod f (Suc ?N) p"
lp15@68136
   806
      using assms by (auto simp: intro!: convergent_prod_ignore_nonzero_segment)
lp15@68136
   807
    then show ?thesis
lp15@68136
   808
      unfolding has_prod_def using 0 by blast
lp15@68136
   809
  qed
lp15@68136
   810
qed
lp15@68136
   811
lp15@68136
   812
lemma convergent_prod_has_prod [intro]:
lp15@68136
   813
  shows "convergent_prod f \<Longrightarrow> f has_prod (prodinf f)"
lp15@68136
   814
  unfolding prodinf_def
lp15@68136
   815
  by (metis convergent_prod_imp_has_prod has_prod_unique theI')
lp15@68136
   816
lp15@68136
   817
lemma convergent_prod_LIMSEQ:
lp15@68136
   818
  shows "convergent_prod f \<Longrightarrow> (\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> prodinf f"
lp15@68136
   819
  by (metis convergent_LIMSEQ_iff convergent_prod_has_prod convergent_prod_imp_convergent 
lp15@68361
   820
      convergent_prod_to_zero_iff raw_has_prod_eq_0 has_prod_def prodinf_eq_lim zero_le)
lp15@68136
   821
lp15@68136
   822
lemma has_prod_iff: "f has_prod x \<longleftrightarrow> convergent_prod f \<and> prodinf f = x"
lp15@68136
   823
proof
lp15@68136
   824
  assume "f has_prod x"
lp15@68136
   825
  then show "convergent_prod f \<and> prodinf f = x"
lp15@68136
   826
    apply safe
lp15@68136
   827
    using convergent_prod_def has_prod_def apply blast
lp15@68136
   828
    using has_prod_unique by blast
lp15@68136
   829
qed auto
lp15@68136
   830
lp15@68136
   831
lemma convergent_prod_has_prod_iff: "convergent_prod f \<longleftrightarrow> f has_prod prodinf f"
lp15@68136
   832
  by (auto simp: has_prod_iff convergent_prod_has_prod)
lp15@68136
   833
lp15@68136
   834
lemma prodinf_finite:
lp15@68136
   835
  assumes N: "finite N"
lp15@68136
   836
    and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 1"
lp15@68136
   837
  shows "prodinf f = (\<Prod>n\<in>N. f n)"
lp15@68136
   838
  using has_prod_finite[OF assms, THEN has_prod_unique] by simp
lp15@68127
   839
eberlm@66277
   840
end
lp15@68136
   841
lp15@68361
   842
subsection \<open>Infinite products on ordered, topological monoids\<close>
lp15@68361
   843
lp15@68361
   844
lemma LIMSEQ_prod_0: 
lp15@68361
   845
  fixes f :: "nat \<Rightarrow> 'a::{semidom,topological_space}"
lp15@68361
   846
  assumes "f i = 0"
lp15@68361
   847
  shows "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> 0"
lp15@68361
   848
proof (subst tendsto_cong)
lp15@68361
   849
  show "\<forall>\<^sub>F n in sequentially. prod f {..n} = 0"
lp15@68361
   850
  proof
lp15@68361
   851
    show "prod f {..n} = 0" if "n \<ge> i" for n
lp15@68361
   852
      using that assms by auto
lp15@68361
   853
  qed
lp15@68361
   854
qed auto
lp15@68361
   855
lp15@68361
   856
lemma LIMSEQ_prod_nonneg: 
lp15@68361
   857
  fixes f :: "nat \<Rightarrow> 'a::{linordered_semidom,linorder_topology}"
lp15@68361
   858
  assumes 0: "\<And>n. 0 \<le> f n" and a: "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> a"
lp15@68361
   859
  shows "a \<ge> 0"
lp15@68361
   860
  by (simp add: "0" prod_nonneg LIMSEQ_le_const [OF a])
lp15@68361
   861
lp15@68361
   862
lp15@68361
   863
context
lp15@68361
   864
  fixes f :: "nat \<Rightarrow> 'a::{linordered_semidom,linorder_topology}"
lp15@68361
   865
begin
lp15@68361
   866
lp15@68361
   867
lemma has_prod_le:
lp15@68361
   868
  assumes f: "f has_prod a" and g: "g has_prod b" and le: "\<And>n. 0 \<le> f n \<and> f n \<le> g n"
lp15@68361
   869
  shows "a \<le> b"
lp15@68361
   870
proof (cases "a=0 \<or> b=0")
lp15@68361
   871
  case True
lp15@68361
   872
  then show ?thesis
lp15@68361
   873
  proof
lp15@68361
   874
    assume [simp]: "a=0"
lp15@68361
   875
    have "b \<ge> 0"
lp15@68361
   876
    proof (rule LIMSEQ_prod_nonneg)
lp15@68361
   877
      show "(\<lambda>n. prod g {..n}) \<longlonglongrightarrow> b"
lp15@68361
   878
        using g by (auto simp: has_prod_def raw_has_prod_def LIMSEQ_prod_0)
lp15@68361
   879
    qed (use le order_trans in auto)
lp15@68361
   880
    then show ?thesis
lp15@68361
   881
      by auto
lp15@68361
   882
  next
lp15@68361
   883
    assume [simp]: "b=0"
lp15@68361
   884
    then obtain i where "g i = 0"    
lp15@68361
   885
      using g by (auto simp: prod_defs)
lp15@68361
   886
    then have "f i = 0"
lp15@68361
   887
      using antisym le by force
lp15@68361
   888
    then have "a=0"
lp15@68361
   889
      using f by (auto simp: prod_defs LIMSEQ_prod_0 LIMSEQ_unique)
lp15@68361
   890
    then show ?thesis
lp15@68361
   891
      by auto
lp15@68361
   892
  qed
lp15@68361
   893
next
lp15@68361
   894
  case False
lp15@68361
   895
  then show ?thesis
lp15@68361
   896
    using assms
lp15@68361
   897
    unfolding has_prod_def raw_has_prod_def
lp15@68361
   898
    by (force simp: LIMSEQ_prod_0 intro!: LIMSEQ_le prod_mono)
lp15@68361
   899
qed
lp15@68361
   900
lp15@68361
   901
lemma prodinf_le: 
lp15@68361
   902
  assumes f: "f has_prod a" and g: "g has_prod b" and le: "\<And>n. 0 \<le> f n \<and> f n \<le> g n"
lp15@68361
   903
  shows "prodinf f \<le> prodinf g"
lp15@68361
   904
  using has_prod_le [OF assms] has_prod_unique f g  by blast
lp15@68361
   905
lp15@68136
   906
end
lp15@68361
   907
lp15@68361
   908
lp15@68361
   909
lemma prod_le_prodinf: 
lp15@68361
   910
  fixes f :: "nat \<Rightarrow> 'a::{linordered_idom,linorder_topology}"
lp15@68361
   911
  assumes "f has_prod a" "\<And>i. 0 \<le> f i" "\<And>i. i\<ge>n \<Longrightarrow> 1 \<le> f i"
lp15@68361
   912
  shows "prod f {..<n} \<le> prodinf f"
lp15@68361
   913
  by(rule has_prod_le[OF has_prod_If_finite_set]) (use assms has_prod_unique in auto)
lp15@68361
   914
lp15@68361
   915
lemma prodinf_nonneg:
lp15@68361
   916
  fixes f :: "nat \<Rightarrow> 'a::{linordered_idom,linorder_topology}"
lp15@68361
   917
  assumes "f has_prod a" "\<And>i. 1 \<le> f i" 
lp15@68361
   918
  shows "1 \<le> prodinf f"
lp15@68361
   919
  using prod_le_prodinf[of f a 0] assms
lp15@68361
   920
  by (metis order_trans prod_ge_1 zero_le_one)
lp15@68361
   921
lp15@68361
   922
lemma prodinf_le_const:
lp15@68361
   923
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   924
  assumes "convergent_prod f" "\<And>n. prod f {..<n} \<le> x" 
lp15@68361
   925
  shows "prodinf f \<le> x"
lp15@68361
   926
  by (metis lessThan_Suc_atMost assms convergent_prod_LIMSEQ LIMSEQ_le_const2)
lp15@68361
   927
lp15@68361
   928
lemma prodinf_eq_one_iff: 
lp15@68361
   929
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   930
  assumes f: "convergent_prod f" and ge1: "\<And>n. 1 \<le> f n"
lp15@68361
   931
  shows "prodinf f = 1 \<longleftrightarrow> (\<forall>n. f n = 1)"
lp15@68361
   932
proof
lp15@68361
   933
  assume "prodinf f = 1" 
lp15@68361
   934
  then have "(\<lambda>n. \<Prod>i<n. f i) \<longlonglongrightarrow> 1"
lp15@68361
   935
    using convergent_prod_LIMSEQ[of f] assms by (simp add: LIMSEQ_lessThan_iff_atMost)
lp15@68361
   936
  then have "\<And>i. (\<Prod>n\<in>{i}. f n) \<le> 1"
lp15@68361
   937
  proof (rule LIMSEQ_le_const)
lp15@68361
   938
    have "1 \<le> prod f n" for n
lp15@68361
   939
      by (simp add: ge1 prod_ge_1)
lp15@68361
   940
    have "prod f {..<n} = 1" for n
lp15@68361
   941
      by (metis \<open>\<And>n. 1 \<le> prod f n\<close> \<open>prodinf f = 1\<close> antisym f convergent_prod_has_prod ge1 order_trans prod_le_prodinf zero_le_one)
lp15@68361
   942
    then have "(\<Prod>n\<in>{i}. f n) \<le> prod f {..<n}" if "n \<ge> Suc i" for i n
lp15@68361
   943
      by (metis mult.left_neutral order_refl prod.cong prod.neutral_const prod_lessThan_Suc)
lp15@68361
   944
    then show "\<exists>N. \<forall>n\<ge>N. (\<Prod>n\<in>{i}. f n) \<le> prod f {..<n}" for i
lp15@68361
   945
      by blast      
lp15@68361
   946
  qed
lp15@68361
   947
  with ge1 show "\<forall>n. f n = 1"
lp15@68361
   948
    by (auto intro!: antisym)
lp15@68361
   949
qed (metis prodinf_zero fun_eq_iff)
lp15@68361
   950
lp15@68361
   951
lemma prodinf_pos_iff:
lp15@68361
   952
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   953
  assumes "convergent_prod f" "\<And>n. 1 \<le> f n"
lp15@68361
   954
  shows "1 < prodinf f \<longleftrightarrow> (\<exists>i. 1 < f i)"
lp15@68361
   955
  using prod_le_prodinf[of f 1] prodinf_eq_one_iff
lp15@68361
   956
  by (metis convergent_prod_has_prod assms less_le prodinf_nonneg)
lp15@68361
   957
lp15@68361
   958
lemma less_1_prodinf2:
lp15@68361
   959
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   960
  assumes "convergent_prod f" "\<And>n. 1 \<le> f n" "1 < f i"
lp15@68361
   961
  shows "1 < prodinf f"
lp15@68361
   962
proof -
lp15@68361
   963
  have "1 < (\<Prod>n<Suc i. f n)"
lp15@68361
   964
    using assms  by (intro less_1_prod2[where i=i]) auto
lp15@68361
   965
  also have "\<dots> \<le> prodinf f"
lp15@68361
   966
    by (intro prod_le_prodinf) (use assms order_trans zero_le_one in \<open>blast+\<close>)
lp15@68361
   967
  finally show ?thesis .
lp15@68361
   968
qed
lp15@68361
   969
lp15@68361
   970
lemma less_1_prodinf:
lp15@68361
   971
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   972
  shows "\<lbrakk>convergent_prod f; \<And>n. 1 < f n\<rbrakk> \<Longrightarrow> 1 < prodinf f"
lp15@68361
   973
  by (intro less_1_prodinf2[where i=1]) (auto intro: less_imp_le)
lp15@68361
   974
lp15@68361
   975
lemma prodinf_nonzero:
lp15@68361
   976
  fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"
lp15@68361
   977
  assumes "convergent_prod f" "\<And>i. f i \<noteq> 0"
lp15@68361
   978
  shows "prodinf f \<noteq> 0"
lp15@68361
   979
  by (metis assms convergent_prod_offset_0 has_prod_unique raw_has_prod_def has_prod_def)
lp15@68361
   980
lp15@68361
   981
lemma less_0_prodinf:
lp15@68361
   982
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   983
  assumes f: "convergent_prod f" and 0: "\<And>i. f i > 0"
lp15@68361
   984
  shows "0 < prodinf f"
lp15@68361
   985
proof -
lp15@68361
   986
  have "prodinf f \<noteq> 0"
lp15@68361
   987
    by (metis assms less_irrefl prodinf_nonzero)
lp15@68361
   988
  moreover have "0 < (\<Prod>n<i. f n)" for i
lp15@68361
   989
    by (simp add: 0 prod_pos)
lp15@68361
   990
  then have "prodinf f \<ge> 0"
lp15@68361
   991
    using convergent_prod_LIMSEQ [OF f] LIMSEQ_prod_nonneg 0 less_le by blast
lp15@68361
   992
  ultimately show ?thesis
lp15@68361
   993
    by auto
lp15@68361
   994
qed
lp15@68361
   995
lp15@68361
   996
lemma prod_less_prodinf2:
lp15@68361
   997
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   998
  assumes f: "convergent_prod f" and 1: "\<And>m. m\<ge>n \<Longrightarrow> 1 \<le> f m" and 0: "\<And>m. 0 < f m" and i: "n \<le> i" "1 < f i"
lp15@68361
   999
  shows "prod f {..<n} < prodinf f"
lp15@68361
  1000
proof -
lp15@68361
  1001
  have "prod f {..<n} \<le> prod f {..<i}"
lp15@68361
  1002
    by (rule prod_mono2) (use assms less_le in auto)
lp15@68361
  1003
  then have "prod f {..<n} < f i * prod f {..<i}"
lp15@68361
  1004
    using mult_less_le_imp_less[of 1 "f i" "prod f {..<n}" "prod f {..<i}"] assms
lp15@68361
  1005
    by (simp add: prod_pos)
lp15@68361
  1006
  moreover have "prod f {..<Suc i} \<le> prodinf f"
lp15@68361
  1007
    using prod_le_prodinf[of f _ "Suc i"]
lp15@68361
  1008
    by (meson "0" "1" Suc_leD convergent_prod_has_prod f \<open>n \<le> i\<close> le_trans less_eq_real_def)
lp15@68361
  1009
  ultimately show ?thesis
lp15@68361
  1010
    by (metis le_less_trans mult.commute not_le prod_lessThan_Suc)
lp15@68361
  1011
qed
lp15@68361
  1012
lp15@68361
  1013
lemma prod_less_prodinf:
lp15@68361
  1014
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1015
  assumes f: "convergent_prod f" and 1: "\<And>m. m\<ge>n \<Longrightarrow> 1 < f m" and 0: "\<And>m. 0 < f m" 
lp15@68361
  1016
  shows "prod f {..<n} < prodinf f"
lp15@68361
  1017
  by (meson "0" "1" f le_less prod_less_prodinf2)
lp15@68361
  1018
lp15@68361
  1019
lemma raw_has_prodI_bounded:
lp15@68361
  1020
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1021
  assumes pos: "\<And>n. 1 \<le> f n"
lp15@68361
  1022
    and le: "\<And>n. (\<Prod>i<n. f i) \<le> x"
lp15@68361
  1023
  shows "\<exists>p. raw_has_prod f 0 p"
lp15@68361
  1024
  unfolding raw_has_prod_def add_0_right
lp15@68361
  1025
proof (rule exI LIMSEQ_incseq_SUP conjI)+
lp15@68361
  1026
  show "bdd_above (range (\<lambda>n. prod f {..n}))"
lp15@68361
  1027
    by (metis bdd_aboveI2 le lessThan_Suc_atMost)
lp15@68361
  1028
  then have "(SUP i. prod f {..i}) > 0"
lp15@68361
  1029
    by (metis UNIV_I cSUP_upper less_le_trans pos prod_pos zero_less_one)
lp15@68361
  1030
  then show "(SUP i. prod f {..i}) \<noteq> 0"
lp15@68361
  1031
    by auto
lp15@68361
  1032
  show "incseq (\<lambda>n. prod f {..n})"
lp15@68361
  1033
    using pos order_trans [OF zero_le_one] by (auto simp: mono_def intro!: prod_mono2)
lp15@68361
  1034
qed
lp15@68361
  1035
lp15@68361
  1036
lemma convergent_prodI_nonneg_bounded:
lp15@68361
  1037
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1038
  assumes "\<And>n. 1 \<le> f n" "\<And>n. (\<Prod>i<n. f i) \<le> x"
lp15@68361
  1039
  shows "convergent_prod f"
lp15@68361
  1040
  using convergent_prod_def raw_has_prodI_bounded [OF assms] by blast
lp15@68361
  1041
lp15@68361
  1042
lp15@68361
  1043
subsection \<open>Infinite products on topological monoids\<close>
lp15@68361
  1044
lp15@68361
  1045
context
lp15@68361
  1046
  fixes f g :: "nat \<Rightarrow> 'a::{t2_space,topological_semigroup_mult,idom}"
lp15@68361
  1047
begin
lp15@68361
  1048
lp15@68361
  1049
lemma raw_has_prod_mult: "\<lbrakk>raw_has_prod f M a; raw_has_prod g M b\<rbrakk> \<Longrightarrow> raw_has_prod (\<lambda>n. f n * g n) M (a * b)"
lp15@68361
  1050
  by (force simp add: prod.distrib tendsto_mult raw_has_prod_def)
lp15@68361
  1051
lp15@68361
  1052
lemma has_prod_mult_nz: "\<lbrakk>f has_prod a; g has_prod b; a \<noteq> 0; b \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>n. f n * g n) has_prod (a * b)"
lp15@68361
  1053
  by (simp add: raw_has_prod_mult has_prod_def)
lp15@68361
  1054
lp15@68361
  1055
end
lp15@68361
  1056
lp15@68361
  1057
lp15@68361
  1058
context
lp15@68361
  1059
  fixes f g :: "nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1060
begin
lp15@68361
  1061
lp15@68361
  1062
lemma has_prod_mult:
lp15@68361
  1063
  assumes f: "f has_prod a" and g: "g has_prod b"
lp15@68361
  1064
  shows "(\<lambda>n. f n * g n) has_prod (a * b)"
lp15@68361
  1065
  using f [unfolded has_prod_def]
lp15@68361
  1066
proof (elim disjE exE conjE)
lp15@68361
  1067
  assume f0: "raw_has_prod f 0 a"
lp15@68361
  1068
  show ?thesis
lp15@68361
  1069
    using g [unfolded has_prod_def]
lp15@68361
  1070
  proof (elim disjE exE conjE)
lp15@68361
  1071
    assume g0: "raw_has_prod g 0 b"
lp15@68361
  1072
    with f0 show ?thesis
lp15@68361
  1073
      by (force simp add: has_prod_def prod.distrib tendsto_mult raw_has_prod_def)
lp15@68361
  1074
  next
lp15@68361
  1075
    fix j q
lp15@68361
  1076
    assume "b = 0" and "g j = 0" and q: "raw_has_prod g (Suc j) q"
lp15@68361
  1077
    obtain p where p: "raw_has_prod f (Suc j) p"
lp15@68361
  1078
      using f0 raw_has_prod_ignore_initial_segment by blast
lp15@68361
  1079
    then have "Ex (raw_has_prod (\<lambda>n. f n * g n) (Suc j))"
lp15@68361
  1080
      using q raw_has_prod_mult by blast
lp15@68361
  1081
    then show ?thesis
lp15@68361
  1082
      using \<open>b = 0\<close> \<open>g j = 0\<close> has_prod_0_iff by fastforce
lp15@68361
  1083
  qed
lp15@68361
  1084
next
lp15@68361
  1085
  fix i p
lp15@68361
  1086
  assume "a = 0" and "f i = 0" and p: "raw_has_prod f (Suc i) p"
lp15@68361
  1087
  show ?thesis
lp15@68361
  1088
    using g [unfolded has_prod_def]
lp15@68361
  1089
  proof (elim disjE exE conjE)
lp15@68361
  1090
    assume g0: "raw_has_prod g 0 b"
lp15@68361
  1091
    obtain q where q: "raw_has_prod g (Suc i) q"
lp15@68361
  1092
      using g0 raw_has_prod_ignore_initial_segment by blast
lp15@68361
  1093
    then have "Ex (raw_has_prod (\<lambda>n. f n * g n) (Suc i))"
lp15@68361
  1094
      using raw_has_prod_mult p by blast
lp15@68361
  1095
    then show ?thesis
lp15@68361
  1096
      using \<open>a = 0\<close> \<open>f i = 0\<close> has_prod_0_iff by fastforce
lp15@68361
  1097
  next
lp15@68361
  1098
    fix j q
lp15@68361
  1099
    assume "b = 0" and "g j = 0" and q: "raw_has_prod g (Suc j) q"
lp15@68361
  1100
    obtain p' where p': "raw_has_prod f (Suc (max i j)) p'"
lp15@68361
  1101
      by (metis raw_has_prod_ignore_initial_segment max_Suc_Suc max_def p)
lp15@68361
  1102
    moreover
lp15@68361
  1103
    obtain q' where q': "raw_has_prod g (Suc (max i j)) q'"
lp15@68361
  1104
      by (metis raw_has_prod_ignore_initial_segment max.cobounded2 max_Suc_Suc q)
lp15@68361
  1105
    ultimately show ?thesis
lp15@68361
  1106
      using \<open>b = 0\<close> by (simp add: has_prod_def) (metis \<open>f i = 0\<close> \<open>g j = 0\<close> raw_has_prod_mult max_def)
lp15@68361
  1107
  qed
lp15@68361
  1108
qed
lp15@68361
  1109
lp15@68361
  1110
lemma convergent_prod_mult:
lp15@68361
  1111
  assumes f: "convergent_prod f" and g: "convergent_prod g"
lp15@68361
  1112
  shows "convergent_prod (\<lambda>n. f n * g n)"
lp15@68361
  1113
  unfolding convergent_prod_def
lp15@68361
  1114
proof -
lp15@68361
  1115
  obtain M p N q where p: "raw_has_prod f M p" and q: "raw_has_prod g N q"
lp15@68361
  1116
    using convergent_prod_def f g by blast+
lp15@68361
  1117
  then obtain p' q' where p': "raw_has_prod f (max M N) p'" and q': "raw_has_prod g (max M N) q'"
lp15@68361
  1118
    by (meson raw_has_prod_ignore_initial_segment max.cobounded1 max.cobounded2)
lp15@68361
  1119
  then show "\<exists>M p. raw_has_prod (\<lambda>n. f n * g n) M p"
lp15@68361
  1120
    using raw_has_prod_mult by blast
lp15@68361
  1121
qed
lp15@68361
  1122
lp15@68361
  1123
lemma prodinf_mult: "convergent_prod f \<Longrightarrow> convergent_prod g \<Longrightarrow> prodinf f * prodinf g = (\<Prod>n. f n * g n)"
lp15@68361
  1124
  by (intro has_prod_unique has_prod_mult convergent_prod_has_prod)
lp15@68361
  1125
lp15@68361
  1126
end
lp15@68361
  1127
lp15@68361
  1128
context
lp15@68361
  1129
  fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1130
    and I :: "'i set"
lp15@68361
  1131
begin
lp15@68361
  1132
lp15@68361
  1133
lemma has_prod_prod: "(\<And>i. i \<in> I \<Longrightarrow> (f i) has_prod (x i)) \<Longrightarrow> (\<lambda>n. \<Prod>i\<in>I. f i n) has_prod (\<Prod>i\<in>I. x i)"
lp15@68361
  1134
  by (induct I rule: infinite_finite_induct) (auto intro!: has_prod_mult)
lp15@68361
  1135
lp15@68361
  1136
lemma prodinf_prod: "(\<And>i. i \<in> I \<Longrightarrow> convergent_prod (f i)) \<Longrightarrow> (\<Prod>n. \<Prod>i\<in>I. f i n) = (\<Prod>i\<in>I. \<Prod>n. f i n)"
lp15@68361
  1137
  using has_prod_unique[OF has_prod_prod, OF convergent_prod_has_prod] by simp
lp15@68361
  1138
lp15@68361
  1139
lemma convergent_prod_prod: "(\<And>i. i \<in> I \<Longrightarrow> convergent_prod (f i)) \<Longrightarrow> convergent_prod (\<lambda>n. \<Prod>i\<in>I. f i n)"
lp15@68361
  1140
  using convergent_prod_has_prod_iff has_prod_prod prodinf_prod by force
lp15@68361
  1141
lp15@68361
  1142
end
lp15@68361
  1143
lp15@68361
  1144
subsection \<open>Infinite summability on real normed vector spaces\<close>
lp15@68361
  1145
lp15@68361
  1146
context
lp15@68361
  1147
  fixes f :: "nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1148
begin
lp15@68361
  1149
lp15@68361
  1150
lemma raw_has_prod_Suc_iff: "raw_has_prod f M (a * f M) \<longleftrightarrow> raw_has_prod (\<lambda>n. f (Suc n)) M a \<and> f M \<noteq> 0"
lp15@68361
  1151
proof -
lp15@68361
  1152
  have "raw_has_prod f M (a * f M) \<longleftrightarrow> (\<lambda>i. \<Prod>j\<le>Suc i. f (j+M)) \<longlonglongrightarrow> a * f M \<and> a * f M \<noteq> 0"
lp15@68361
  1153
    by (subst LIMSEQ_Suc_iff) (simp add: raw_has_prod_def)
lp15@68361
  1154
  also have "\<dots> \<longleftrightarrow> (\<lambda>i. (\<Prod>j\<le>i. f (Suc j + M)) * f M) \<longlonglongrightarrow> a * f M \<and> a * f M \<noteq> 0"
lp15@68361
  1155
    by (simp add: ac_simps atMost_Suc_eq_insert_0 image_Suc_atMost prod_atLeast1_atMost_eq lessThan_Suc_atMost)
lp15@68361
  1156
  also have "\<dots> \<longleftrightarrow> raw_has_prod (\<lambda>n. f (Suc n)) M a \<and> f M \<noteq> 0"
lp15@68361
  1157
  proof safe
lp15@68361
  1158
    assume tends: "(\<lambda>i. (\<Prod>j\<le>i. f (Suc j + M)) * f M) \<longlonglongrightarrow> a * f M" and 0: "a * f M \<noteq> 0"
lp15@68361
  1159
    with tendsto_divide[OF tends tendsto_const, of "f M"]    
lp15@68361
  1160
    show "raw_has_prod (\<lambda>n. f (Suc n)) M a"
lp15@68361
  1161
      by (simp add: raw_has_prod_def)
lp15@68361
  1162
  qed (auto intro: tendsto_mult_right simp:  raw_has_prod_def)
lp15@68361
  1163
  finally show ?thesis .
lp15@68361
  1164
qed
lp15@68361
  1165
lp15@68361
  1166
lemma has_prod_Suc_iff:
lp15@68361
  1167
  assumes "f 0 \<noteq> 0" shows "(\<lambda>n. f (Suc n)) has_prod a \<longleftrightarrow> f has_prod (a * f 0)"
lp15@68361
  1168
proof (cases "a = 0")
lp15@68361
  1169
  case True
lp15@68361
  1170
  then show ?thesis
lp15@68361
  1171
  proof (simp add: has_prod_def, safe)
lp15@68361
  1172
    fix i x
lp15@68361
  1173
    assume "f (Suc i) = 0" and "raw_has_prod (\<lambda>n. f (Suc n)) (Suc i) x"
lp15@68361
  1174
    then obtain y where "raw_has_prod f (Suc (Suc i)) y"
lp15@68361
  1175
      by (metis (no_types) raw_has_prod_eq_0 Suc_n_not_le_n raw_has_prod_Suc_iff raw_has_prod_ignore_initial_segment raw_has_prod_nonzero linear)
lp15@68361
  1176
    then show "\<exists>i. f i = 0 \<and> Ex (raw_has_prod f (Suc i))"
lp15@68361
  1177
      using \<open>f (Suc i) = 0\<close> by blast
lp15@68361
  1178
  next
lp15@68361
  1179
    fix i x
lp15@68361
  1180
    assume "f i = 0" and x: "raw_has_prod f (Suc i) x"
lp15@68361
  1181
    then obtain j where j: "i = Suc j"
lp15@68361
  1182
      by (metis assms not0_implies_Suc)
lp15@68361
  1183
    moreover have "\<exists> y. raw_has_prod (\<lambda>n. f (Suc n)) i y"
lp15@68361
  1184
      using x by (auto simp: raw_has_prod_def)
lp15@68361
  1185
    then show "\<exists>i. f (Suc i) = 0 \<and> Ex (raw_has_prod (\<lambda>n. f (Suc n)) (Suc i))"
lp15@68361
  1186
      using \<open>f i = 0\<close> j by blast
lp15@68361
  1187
  qed
lp15@68361
  1188
next
lp15@68361
  1189
  case False
lp15@68361
  1190
  then show ?thesis
lp15@68361
  1191
    by (auto simp: has_prod_def raw_has_prod_Suc_iff assms)
lp15@68361
  1192
qed
lp15@68361
  1193
lp15@68361
  1194
lemma convergent_prod_Suc_iff:
lp15@68361
  1195
  assumes "\<And>k. f k \<noteq> 0" shows "convergent_prod (\<lambda>n. f (Suc n)) = convergent_prod f"
lp15@68361
  1196
proof
lp15@68361
  1197
  assume "convergent_prod f"
lp15@68361
  1198
  then have "f has_prod prodinf f"
lp15@68361
  1199
    by (rule convergent_prod_has_prod)
lp15@68361
  1200
  moreover have "prodinf f \<noteq> 0"
lp15@68361
  1201
    by (simp add: \<open>convergent_prod f\<close> assms prodinf_nonzero)
lp15@68361
  1202
  ultimately have "(\<lambda>n. f (Suc n)) has_prod (prodinf f * inverse (f 0))"
lp15@68361
  1203
    by (simp add: has_prod_Suc_iff inverse_eq_divide assms)
lp15@68361
  1204
  then show "convergent_prod (\<lambda>n. f (Suc n))"
lp15@68361
  1205
    using has_prod_iff by blast
lp15@68361
  1206
next
lp15@68361
  1207
  assume "convergent_prod (\<lambda>n. f (Suc n))"
lp15@68361
  1208
  then show "convergent_prod f"
lp15@68361
  1209
    using assms convergent_prod_def raw_has_prod_Suc_iff by blast
lp15@68361
  1210
qed
lp15@68361
  1211
lp15@68361
  1212
lemma raw_has_prod_inverse: 
lp15@68361
  1213
  assumes "raw_has_prod f M a" shows "raw_has_prod (\<lambda>n. inverse (f n)) M (inverse a)"
lp15@68361
  1214
  using assms unfolding raw_has_prod_def by (auto dest: tendsto_inverse simp: prod_inversef [symmetric])
lp15@68361
  1215
lp15@68361
  1216
lemma has_prod_inverse: 
lp15@68361
  1217
  assumes "f has_prod a" shows "(\<lambda>n. inverse (f n)) has_prod (inverse a)"
lp15@68361
  1218
using assms raw_has_prod_inverse unfolding has_prod_def by auto 
lp15@68361
  1219
lp15@68361
  1220
lemma convergent_prod_inverse:
lp15@68361
  1221
  assumes "convergent_prod f" 
lp15@68361
  1222
  shows "convergent_prod (\<lambda>n. inverse (f n))"
lp15@68361
  1223
  using assms unfolding convergent_prod_def  by (blast intro: raw_has_prod_inverse elim: )
lp15@68361
  1224
lp15@68361
  1225
end
lp15@68361
  1226
lp15@68361
  1227
context (* Separate contexts are necessary to allow general use of the results above, here. *)
lp15@68361
  1228
  fixes f :: "nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1229
begin
lp15@68361
  1230
lp15@68361
  1231
lemma raw_has_prod_Suc_iff': "raw_has_prod f M a \<longleftrightarrow> raw_has_prod (\<lambda>n. f (Suc n)) M (a / f M) \<and> f M \<noteq> 0"
lp15@68361
  1232
  by (metis raw_has_prod_eq_0 add.commute add.left_neutral raw_has_prod_Suc_iff raw_has_prod_nonzero le_add1 nonzero_mult_div_cancel_right times_divide_eq_left)
lp15@68361
  1233
lp15@68361
  1234
lemma has_prod_divide: "f has_prod a \<Longrightarrow> g has_prod b \<Longrightarrow> (\<lambda>n. f n / g n) has_prod (a / b)"
lp15@68361
  1235
  unfolding divide_inverse by (intro has_prod_inverse has_prod_mult)
lp15@68361
  1236
lp15@68361
  1237
lemma convergent_prod_divide:
lp15@68361
  1238
  assumes f: "convergent_prod f" and g: "convergent_prod g"
lp15@68361
  1239
  shows "convergent_prod (\<lambda>n. f n / g n)"
lp15@68361
  1240
  using f g has_prod_divide has_prod_iff by blast
lp15@68361
  1241
lp15@68361
  1242
lemma prodinf_divide: "convergent_prod f \<Longrightarrow> convergent_prod g \<Longrightarrow> prodinf f / prodinf g = (\<Prod>n. f n / g n)"
lp15@68361
  1243
  by (intro has_prod_unique has_prod_divide convergent_prod_has_prod)
lp15@68361
  1244
lp15@68361
  1245
lemma prodinf_inverse: "convergent_prod f \<Longrightarrow> (\<Prod>n. inverse (f n)) = inverse (\<Prod>n. f n)"
lp15@68361
  1246
  by (intro has_prod_unique [symmetric] has_prod_inverse convergent_prod_has_prod)
lp15@68361
  1247
lp15@68361
  1248
lemma has_prod_iff_shift: 
lp15@68361
  1249
  assumes "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1250
  shows "(\<lambda>i. f (i + n)) has_prod a \<longleftrightarrow> f has_prod (a * (\<Prod>i<n. f i))"
lp15@68361
  1251
  using assms
lp15@68361
  1252
proof (induct n arbitrary: a)
lp15@68361
  1253
  case 0
lp15@68361
  1254
  then show ?case by simp
lp15@68361
  1255
next
lp15@68361
  1256
  case (Suc n)
lp15@68361
  1257
  then have "(\<lambda>i. f (Suc i + n)) has_prod a \<longleftrightarrow> (\<lambda>i. f (i + n)) has_prod (a * f n)"
lp15@68361
  1258
    by (subst has_prod_Suc_iff) auto
lp15@68361
  1259
  with Suc show ?case
lp15@68361
  1260
    by (simp add: ac_simps)
lp15@68361
  1261
qed
lp15@68361
  1262
lp15@68361
  1263
corollary has_prod_iff_shift':
lp15@68361
  1264
  assumes "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1265
  shows "(\<lambda>i. f (i + n)) has_prod (a / (\<Prod>i<n. f i)) \<longleftrightarrow> f has_prod a"
lp15@68361
  1266
  by (simp add: assms has_prod_iff_shift)
lp15@68361
  1267
lp15@68361
  1268
lemma has_prod_one_iff_shift:
lp15@68361
  1269
  assumes "\<And>i. i < n \<Longrightarrow> f i = 1"
lp15@68361
  1270
  shows "(\<lambda>i. f (i+n)) has_prod a \<longleftrightarrow> (\<lambda>i. f i) has_prod a"
lp15@68361
  1271
  by (simp add: assms has_prod_iff_shift)
lp15@68361
  1272
lp15@68361
  1273
lemma convergent_prod_iff_shift:
lp15@68361
  1274
  shows "convergent_prod (\<lambda>i. f (i + n)) \<longleftrightarrow> convergent_prod f"
lp15@68361
  1275
  apply safe
lp15@68361
  1276
  using convergent_prod_offset apply blast
lp15@68361
  1277
  using convergent_prod_ignore_initial_segment convergent_prod_def by blast
lp15@68361
  1278
lp15@68361
  1279
lemma has_prod_split_initial_segment:
lp15@68361
  1280
  assumes "f has_prod a" "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1281
  shows "(\<lambda>i. f (i + n)) has_prod (a / (\<Prod>i<n. f i))"
lp15@68361
  1282
  using assms has_prod_iff_shift' by blast
lp15@68361
  1283
lp15@68361
  1284
lemma prodinf_divide_initial_segment:
lp15@68361
  1285
  assumes "convergent_prod f" "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1286
  shows "(\<Prod>i. f (i + n)) = (\<Prod>i. f i) / (\<Prod>i<n. f i)"
lp15@68361
  1287
  by (rule has_prod_unique[symmetric]) (auto simp: assms has_prod_iff_shift)
lp15@68361
  1288
lp15@68361
  1289
lemma prodinf_split_initial_segment:
lp15@68361
  1290
  assumes "convergent_prod f" "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1291
  shows "prodinf f = (\<Prod>i. f (i + n)) * (\<Prod>i<n. f i)"
lp15@68361
  1292
  by (auto simp add: assms prodinf_divide_initial_segment)
lp15@68361
  1293
lp15@68361
  1294
lemma prodinf_split_head:
lp15@68361
  1295
  assumes "convergent_prod f" "f 0 \<noteq> 0"
lp15@68361
  1296
  shows "(\<Prod>n. f (Suc n)) = prodinf f / f 0"
lp15@68361
  1297
  using prodinf_split_initial_segment[of 1] assms by simp
lp15@68361
  1298
lp15@68361
  1299
end
lp15@68361
  1300
lp15@68361
  1301
context (* Separate contexts are necessary to allow general use of the results above, here. *)
lp15@68361
  1302
  fixes f :: "nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1303
begin
lp15@68361
  1304
lp15@68361
  1305
lemma convergent_prod_inverse_iff: "convergent_prod (\<lambda>n. inverse (f n)) \<longleftrightarrow> convergent_prod f"
lp15@68361
  1306
  by (auto dest: convergent_prod_inverse)
lp15@68361
  1307
lp15@68361
  1308
lemma convergent_prod_const_iff:
lp15@68361
  1309
  fixes c :: "'a :: {real_normed_field}"
lp15@68361
  1310
  shows "convergent_prod (\<lambda>_. c) \<longleftrightarrow> c = 1"
lp15@68361
  1311
proof
lp15@68361
  1312
  assume "convergent_prod (\<lambda>_. c)"
lp15@68361
  1313
  then show "c = 1"
lp15@68361
  1314
    using convergent_prod_imp_LIMSEQ LIMSEQ_unique by blast 
lp15@68361
  1315
next
lp15@68361
  1316
  assume "c = 1"
lp15@68361
  1317
  then show "convergent_prod (\<lambda>_. c)"
lp15@68361
  1318
    by auto
lp15@68361
  1319
qed
lp15@68361
  1320
lp15@68361
  1321
lemma has_prod_power: "f has_prod a \<Longrightarrow> (\<lambda>i. f i ^ n) has_prod (a ^ n)"
lp15@68361
  1322
  by (induction n) (auto simp: has_prod_mult)
lp15@68361
  1323
lp15@68361
  1324
lemma convergent_prod_power: "convergent_prod f \<Longrightarrow> convergent_prod (\<lambda>i. f i ^ n)"
lp15@68361
  1325
  by (induction n) (auto simp: convergent_prod_mult)
lp15@68361
  1326
lp15@68361
  1327
lemma prodinf_power: "convergent_prod f \<Longrightarrow> prodinf (\<lambda>i. f i ^ n) = prodinf f ^ n"
lp15@68361
  1328
  by (metis has_prod_unique convergent_prod_imp_has_prod has_prod_power)
lp15@68361
  1329
lp15@68361
  1330
end
lp15@68361
  1331
lp15@68361
  1332
end