src/HOL/Analysis/Infinite_Products.thy
author wenzelm
Mon Mar 25 17:21:26 2019 +0100 (4 weeks ago)
changeset 69981 3dced198b9ec
parent 69565 1daf07b65385
child 70113 c8deb8ba6d05
permissions -rw-r--r--
more strict AFP properties;
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
lp15@68585
     9
  imports Topology_Euclidean_Space Complex_Transcendental
eberlm@66277
    10
begin
lp15@68424
    11
eberlm@68651
    12
subsection%unimportant \<open>Preliminaries\<close>
lp15@68424
    13
eberlm@66277
    14
lemma sum_le_prod:
eberlm@66277
    15
  fixes f :: "'a \<Rightarrow> 'b :: linordered_semidom"
eberlm@66277
    16
  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 0"
eberlm@66277
    17
  shows   "sum f A \<le> (\<Prod>x\<in>A. 1 + f x)"
eberlm@66277
    18
  using assms
eberlm@66277
    19
proof (induction A rule: infinite_finite_induct)
eberlm@66277
    20
  case (insert x A)
eberlm@66277
    21
  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
    22
    by (intro add_mono insert mult_left_mono prod_mono) (auto intro: insert.prems)
eberlm@66277
    23
  with insert.hyps show ?case by (simp add: algebra_simps)
eberlm@66277
    24
qed simp_all
eberlm@66277
    25
eberlm@66277
    26
lemma prod_le_exp_sum:
eberlm@66277
    27
  fixes f :: "'a \<Rightarrow> real"
eberlm@66277
    28
  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<ge> 0"
eberlm@66277
    29
  shows   "prod (\<lambda>x. 1 + f x) A \<le> exp (sum f A)"
eberlm@66277
    30
  using assms
eberlm@66277
    31
proof (induction A rule: infinite_finite_induct)
eberlm@66277
    32
  case (insert x A)
eberlm@66277
    33
  have "(1 + f x) * (\<Prod>x\<in>A. 1 + f x) \<le> exp (f x) * exp (sum f A)"
eberlm@66277
    34
    using insert.prems by (intro mult_mono insert prod_nonneg exp_ge_add_one_self) auto
eberlm@66277
    35
  with insert.hyps show ?case by (simp add: algebra_simps exp_add)
eberlm@66277
    36
qed simp_all
eberlm@66277
    37
eberlm@66277
    38
lemma lim_ln_1_plus_x_over_x_at_0: "(\<lambda>x::real. ln (1 + x) / x) \<midarrow>0\<rightarrow> 1"
eberlm@66277
    39
proof (rule lhopital)
eberlm@66277
    40
  show "(\<lambda>x::real. ln (1 + x)) \<midarrow>0\<rightarrow> 0"
eberlm@66277
    41
    by (rule tendsto_eq_intros refl | simp)+
eberlm@66277
    42
  have "eventually (\<lambda>x::real. x \<in> {-1/2<..<1/2}) (nhds 0)"
eberlm@66277
    43
    by (rule eventually_nhds_in_open) auto
eberlm@66277
    44
  hence *: "eventually (\<lambda>x::real. x \<in> {-1/2<..<1/2}) (at 0)"
eberlm@66277
    45
    by (rule filter_leD [rotated]) (simp_all add: at_within_def)   
eberlm@66277
    46
  show "eventually (\<lambda>x::real. ((\<lambda>x. ln (1 + x)) has_field_derivative inverse (1 + x)) (at x)) (at 0)"
eberlm@66277
    47
    using * by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)
eberlm@66277
    48
  show "eventually (\<lambda>x::real. ((\<lambda>x. x) has_field_derivative 1) (at x)) (at 0)"
eberlm@66277
    49
    using * by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)
eberlm@66277
    50
  show "\<forall>\<^sub>F x in at 0. x \<noteq> 0" by (auto simp: at_within_def eventually_inf_principal)
eberlm@66277
    51
  show "(\<lambda>x::real. inverse (1 + x) / 1) \<midarrow>0\<rightarrow> 1"
eberlm@66277
    52
    by (rule tendsto_eq_intros refl | simp)+
eberlm@66277
    53
qed auto
eberlm@66277
    54
lp15@68424
    55
subsection\<open>Definitions and basic properties\<close>
lp15@68424
    56
eberlm@68651
    57
definition%important raw_has_prod :: "[nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}, nat, 'a] \<Rightarrow> bool" 
lp15@68361
    58
  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
    59
lp15@68064
    60
text\<open>The nonzero and zero cases, as in \emph{Complex Analysis} by Joseph Bak and Donald J.Newman, page 241\<close>
wenzelm@69565
    61
text%important \<open>%whitespace\<close>
eberlm@68651
    62
definition%important
eberlm@68651
    63
  has_prod :: "(nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}) \<Rightarrow> 'a \<Rightarrow> bool" (infixr "has'_prod" 80)
lp15@68361
    64
  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
    65
eberlm@68651
    66
definition%important convergent_prod :: "(nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}) \<Rightarrow> bool" where
lp15@68361
    67
  "convergent_prod f \<equiv> \<exists>M p. raw_has_prod f M p"
lp15@68064
    68
eberlm@68651
    69
definition%important prodinf :: "(nat \<Rightarrow> 'a::{t2_space, comm_semiring_1}) \<Rightarrow> 'a"
lp15@68064
    70
    (binder "\<Prod>" 10)
lp15@68064
    71
  where "prodinf f = (THE p. f has_prod p)"
lp15@68064
    72
lp15@68361
    73
lemmas prod_defs = raw_has_prod_def has_prod_def convergent_prod_def prodinf_def
lp15@68064
    74
lp15@68064
    75
lemma has_prod_subst[trans]: "f = g \<Longrightarrow> g has_prod z \<Longrightarrow> f has_prod z"
lp15@68064
    76
  by simp
lp15@68064
    77
lp15@68064
    78
lemma has_prod_cong: "(\<And>n. f n = g n) \<Longrightarrow> f has_prod c \<longleftrightarrow> g has_prod c"
lp15@68064
    79
  by presburger
eberlm@66277
    80
lp15@68361
    81
lemma raw_has_prod_nonzero [simp]: "\<not> raw_has_prod f M 0"
lp15@68361
    82
  by (simp add: raw_has_prod_def)
lp15@68071
    83
lp15@68361
    84
lemma raw_has_prod_eq_0:
lp15@68361
    85
  fixes f :: "nat \<Rightarrow> 'a::{semidom,t2_space}"
lp15@68361
    86
  assumes p: "raw_has_prod f m p" and i: "f i = 0" "i \<ge> m"
lp15@68136
    87
  shows "p = 0"
lp15@68136
    88
proof -
lp15@68136
    89
  have eq0: "(\<Prod>k\<le>n. f (k+m)) = 0" if "i - m \<le> n" for n
lp15@68361
    90
  proof -
lp15@68361
    91
    have "\<exists>k\<le>n. f (k + m) = 0"
lp15@68361
    92
      using i that by auto
lp15@68361
    93
    then show ?thesis
lp15@68361
    94
      by auto
lp15@68361
    95
  qed
lp15@68136
    96
  have "(\<lambda>n. \<Prod>i\<le>n. f (i + m)) \<longlonglongrightarrow> 0"
lp15@68136
    97
    by (rule LIMSEQ_offset [where k = "i-m"]) (simp add: eq0)
lp15@68136
    98
    with p show ?thesis
lp15@68361
    99
      unfolding raw_has_prod_def
lp15@68136
   100
    using LIMSEQ_unique by blast
lp15@68136
   101
qed
lp15@68136
   102
lp15@68452
   103
lemma raw_has_prod_Suc: 
lp15@68452
   104
  "raw_has_prod f (Suc M) a \<longleftrightarrow> raw_has_prod (\<lambda>n. f (Suc n)) M a"
lp15@68452
   105
  unfolding raw_has_prod_def by auto
lp15@68452
   106
lp15@68361
   107
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
   108
  by (simp add: has_prod_def)
lp15@68136
   109
      
lp15@68136
   110
lemma has_prod_unique2: 
lp15@68361
   111
  fixes f :: "nat \<Rightarrow> 'a::{semidom,t2_space}"
lp15@68136
   112
  assumes "f has_prod a" "f has_prod b" shows "a = b"
lp15@68136
   113
  using assms
lp15@68361
   114
  by (auto simp: has_prod_def raw_has_prod_eq_0) (meson raw_has_prod_def sequentially_bot tendsto_unique)
lp15@68136
   115
lp15@68136
   116
lemma has_prod_unique:
lp15@68361
   117
  fixes f :: "nat \<Rightarrow> 'a :: {semidom,t2_space}"
lp15@68136
   118
  shows "f has_prod s \<Longrightarrow> s = prodinf f"
lp15@68136
   119
  by (simp add: has_prod_unique2 prodinf_def the_equality)
lp15@68071
   120
eberlm@66277
   121
lemma convergent_prod_altdef:
eberlm@66277
   122
  fixes f :: "nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}"
eberlm@66277
   123
  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
   124
proof
eberlm@66277
   125
  assume "convergent_prod f"
eberlm@66277
   126
  then obtain M L where *: "(\<lambda>n. \<Prod>i\<le>n. f (i+M)) \<longlonglongrightarrow> L" "L \<noteq> 0"
lp15@68064
   127
    by (auto simp: prod_defs)
eberlm@66277
   128
  have "f i \<noteq> 0" if "i \<ge> M" for i
eberlm@66277
   129
  proof
eberlm@66277
   130
    assume "f i = 0"
eberlm@66277
   131
    have **: "eventually (\<lambda>n. (\<Prod>i\<le>n. f (i+M)) = 0) sequentially"
eberlm@66277
   132
      using eventually_ge_at_top[of "i - M"]
eberlm@66277
   133
    proof eventually_elim
eberlm@66277
   134
      case (elim n)
eberlm@66277
   135
      with \<open>f i = 0\<close> and \<open>i \<ge> M\<close> show ?case
eberlm@66277
   136
        by (auto intro!: bexI[of _ "i - M"] prod_zero)
eberlm@66277
   137
    qed
eberlm@66277
   138
    have "(\<lambda>n. (\<Prod>i\<le>n. f (i+M))) \<longlonglongrightarrow> 0"
eberlm@66277
   139
      unfolding filterlim_iff
eberlm@66277
   140
      by (auto dest!: eventually_nhds_x_imp_x intro!: eventually_mono[OF **])
eberlm@66277
   141
    from tendsto_unique[OF _ this *(1)] and *(2)
eberlm@66277
   142
      show False by simp
eberlm@66277
   143
  qed
eberlm@66277
   144
  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
   145
    by blast
lp15@68064
   146
qed (auto simp: prod_defs)
eberlm@66277
   147
lp15@68424
   148
lp15@68424
   149
subsection\<open>Absolutely convergent products\<close>
lp15@68424
   150
eberlm@68651
   151
definition%important abs_convergent_prod :: "(nat \<Rightarrow> _) \<Rightarrow> bool" where
eberlm@66277
   152
  "abs_convergent_prod f \<longleftrightarrow> convergent_prod (\<lambda>i. 1 + norm (f i - 1))"
eberlm@66277
   153
eberlm@66277
   154
lemma abs_convergent_prodI:
eberlm@66277
   155
  assumes "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   156
  shows   "abs_convergent_prod f"
eberlm@66277
   157
proof -
eberlm@66277
   158
  from assms obtain L where L: "(\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1)) \<longlonglongrightarrow> L"
eberlm@66277
   159
    by (auto simp: convergent_def)
eberlm@66277
   160
  have "L \<ge> 1"
eberlm@66277
   161
  proof (rule tendsto_le)
eberlm@66277
   162
    show "eventually (\<lambda>n. (\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> 1) sequentially"
eberlm@66277
   163
    proof (intro always_eventually allI)
eberlm@66277
   164
      fix n
eberlm@66277
   165
      have "(\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> (\<Prod>i\<le>n. 1)"
eberlm@66277
   166
        by (intro prod_mono) auto
eberlm@66277
   167
      thus "(\<Prod>i\<le>n. 1 + norm (f i - 1)) \<ge> 1" by simp
eberlm@66277
   168
    qed
eberlm@66277
   169
  qed (use L in simp_all)
eberlm@66277
   170
  hence "L \<noteq> 0" by auto
lp15@68064
   171
  with L show ?thesis unfolding abs_convergent_prod_def prod_defs
eberlm@66277
   172
    by (intro exI[of _ "0::nat"] exI[of _ L]) auto
eberlm@66277
   173
qed
eberlm@66277
   174
eberlm@66277
   175
lemma
lp15@68064
   176
  fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"
eberlm@66277
   177
  assumes "convergent_prod f"
eberlm@66277
   178
  shows   convergent_prod_imp_convergent: "convergent (\<lambda>n. \<Prod>i\<le>n. f i)"
eberlm@66277
   179
    and   convergent_prod_to_zero_iff:    "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<exists>i. f i = 0)"
eberlm@66277
   180
proof -
eberlm@66277
   181
  from assms obtain M L 
eberlm@66277
   182
    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
   183
    by (auto simp: convergent_prod_altdef)
eberlm@66277
   184
  note this(2)
eberlm@66277
   185
  also have "(\<lambda>n. \<Prod>i\<le>n. f (i + M)) = (\<lambda>n. \<Prod>i=M..M+n. f i)"
eberlm@66277
   186
    by (intro ext prod.reindex_bij_witness[of _ "\<lambda>n. n - M" "\<lambda>n. n + M"]) auto
eberlm@66277
   187
  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
   188
    by (intro tendsto_mult tendsto_const)
eberlm@66277
   189
  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
   190
    by (subst prod.union_disjoint) auto
eberlm@66277
   191
  also have "(\<lambda>n. {..<M} \<union> {M..M+n}) = (\<lambda>n. {..n+M})" by auto
eberlm@66277
   192
  finally have lim: "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f {..<M} * L" 
eberlm@66277
   193
    by (rule LIMSEQ_offset)
eberlm@66277
   194
  thus "convergent (\<lambda>n. \<Prod>i\<le>n. f i)"
eberlm@66277
   195
    by (auto simp: convergent_def)
eberlm@66277
   196
eberlm@66277
   197
  show "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0 \<longleftrightarrow> (\<exists>i. f i = 0)"
eberlm@66277
   198
  proof
eberlm@66277
   199
    assume "\<exists>i. f i = 0"
eberlm@66277
   200
    then obtain i where "f i = 0" by auto
eberlm@66277
   201
    moreover with M have "i < M" by (cases "i < M") auto
eberlm@66277
   202
    ultimately have "(\<Prod>i<M. f i) = 0" by auto
eberlm@66277
   203
    with lim show "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0" by simp
eberlm@66277
   204
  next
eberlm@66277
   205
    assume "(\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> 0"
eberlm@66277
   206
    from tendsto_unique[OF _ this lim] and \<open>L \<noteq> 0\<close>
eberlm@66277
   207
    show "\<exists>i. f i = 0" by auto
eberlm@66277
   208
  qed
eberlm@66277
   209
qed
eberlm@66277
   210
lp15@68064
   211
lemma convergent_prod_iff_nz_lim:
lp15@68064
   212
  fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"
lp15@68064
   213
  assumes "\<And>i. f i \<noteq> 0"
lp15@68064
   214
  shows "convergent_prod f \<longleftrightarrow> (\<exists>L. (\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> L \<and> L \<noteq> 0)"
lp15@68064
   215
    (is "?lhs \<longleftrightarrow> ?rhs")
lp15@68064
   216
proof
lp15@68064
   217
  assume ?lhs then show ?rhs
lp15@68064
   218
    using assms convergentD convergent_prod_imp_convergent convergent_prod_to_zero_iff by blast
lp15@68064
   219
next
lp15@68064
   220
  assume ?rhs then show ?lhs
lp15@68064
   221
    unfolding prod_defs
lp15@68138
   222
    by (rule_tac x=0 in exI) auto
lp15@68064
   223
qed
lp15@68064
   224
eberlm@68651
   225
lemma%important convergent_prod_iff_convergent: 
lp15@68064
   226
  fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"
lp15@68064
   227
  assumes "\<And>i. f i \<noteq> 0"
lp15@68064
   228
  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
   229
  by (force simp: convergent_prod_iff_nz_lim assms convergent_def limI)
lp15@68064
   230
lp15@68527
   231
lemma bounded_imp_convergent_prod:
lp15@68527
   232
  fixes a :: "nat \<Rightarrow> real"
lp15@68527
   233
  assumes 1: "\<And>n. a n \<ge> 1" and bounded: "\<And>n. (\<Prod>i\<le>n. a i) \<le> B"
lp15@68527
   234
  shows "convergent_prod a"
lp15@68527
   235
proof -
lp15@68527
   236
  have "bdd_above (range(\<lambda>n. \<Prod>i\<le>n. a i))"
lp15@68527
   237
    by (meson bdd_aboveI2 bounded)
lp15@68527
   238
  moreover have "incseq (\<lambda>n. \<Prod>i\<le>n. a i)"
lp15@68527
   239
    unfolding mono_def by (metis 1 prod_mono2 atMost_subset_iff dual_order.trans finite_atMost zero_le_one)
lp15@68527
   240
  ultimately obtain p where p: "(\<lambda>n. \<Prod>i\<le>n. a i) \<longlonglongrightarrow> p"
lp15@68527
   241
    using LIMSEQ_incseq_SUP by blast
lp15@68527
   242
  then have "p \<noteq> 0"
lp15@68527
   243
    by (metis "1" not_one_le_zero prod_ge_1 LIMSEQ_le_const)
lp15@68527
   244
  with 1 p show ?thesis
lp15@68527
   245
    by (metis convergent_prod_iff_nz_lim not_one_le_zero)
lp15@68527
   246
qed
lp15@68527
   247
lp15@68064
   248
eberlm@66277
   249
lemma abs_convergent_prod_altdef:
lp15@68064
   250
  fixes f :: "nat \<Rightarrow> 'a :: {one,real_normed_vector}"
lp15@68064
   251
  shows  "abs_convergent_prod f \<longleftrightarrow> convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   252
proof
eberlm@66277
   253
  assume "abs_convergent_prod f"
eberlm@66277
   254
  thus "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   255
    by (auto simp: abs_convergent_prod_def intro!: convergent_prod_imp_convergent)
eberlm@66277
   256
qed (auto intro: abs_convergent_prodI)
eberlm@66277
   257
nipkow@69529
   258
lemma Weierstrass_prod_ineq:
eberlm@66277
   259
  fixes f :: "'a \<Rightarrow> real" 
eberlm@66277
   260
  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<in> {0..1}"
eberlm@66277
   261
  shows   "1 - sum f A \<le> (\<Prod>x\<in>A. 1 - f x)"
eberlm@66277
   262
  using assms
eberlm@66277
   263
proof (induction A rule: infinite_finite_induct)
eberlm@66277
   264
  case (insert x A)
eberlm@66277
   265
  from insert.hyps and insert.prems 
eberlm@66277
   266
    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
   267
    by (intro insert.IH add_mono mult_left_mono prod_mono) auto
eberlm@66277
   268
  with insert.hyps show ?case by (simp add: algebra_simps)
eberlm@66277
   269
qed simp_all
eberlm@66277
   270
eberlm@66277
   271
lemma norm_prod_minus1_le_prod_minus1:
eberlm@66277
   272
  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,comm_ring_1}"  
eberlm@66277
   273
  shows "norm (prod (\<lambda>n. 1 + f n) A - 1) \<le> prod (\<lambda>n. 1 + norm (f n)) A - 1"
eberlm@66277
   274
proof (induction A rule: infinite_finite_induct)
eberlm@66277
   275
  case (insert x A)
eberlm@66277
   276
  from insert.hyps have 
eberlm@66277
   277
    "norm ((\<Prod>n\<in>insert x A. 1 + f n) - 1) = 
eberlm@66277
   278
       norm ((\<Prod>n\<in>A. 1 + f n) - 1 + f x * (\<Prod>n\<in>A. 1 + f n))"
eberlm@66277
   279
    by (simp add: algebra_simps)
eberlm@66277
   280
  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
   281
    by (rule norm_triangle_ineq)
eberlm@66277
   282
  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
   283
    by (simp add: prod_norm norm_mult)
eberlm@66277
   284
  also have "(\<Prod>x\<in>A. norm (1 + f x)) \<le> (\<Prod>x\<in>A. norm (1::'a) + norm (f x))"
eberlm@66277
   285
    by (intro prod_mono norm_triangle_ineq ballI conjI) auto
eberlm@66277
   286
  also have "norm (1::'a) = 1" by simp
eberlm@66277
   287
  also note insert.IH
eberlm@66277
   288
  also have "(\<Prod>n\<in>A. 1 + norm (f n)) - 1 + norm (f x) * (\<Prod>x\<in>A. 1 + norm (f x)) =
lp15@68064
   289
             (\<Prod>n\<in>insert x A. 1 + norm (f n)) - 1"
eberlm@66277
   290
    using insert.hyps by (simp add: algebra_simps)
eberlm@66277
   291
  finally show ?case by - (simp_all add: mult_left_mono)
eberlm@66277
   292
qed simp_all
eberlm@66277
   293
eberlm@66277
   294
lemma convergent_prod_imp_ev_nonzero:
eberlm@66277
   295
  fixes f :: "nat \<Rightarrow> 'a :: {t2_space,comm_semiring_1}"
eberlm@66277
   296
  assumes "convergent_prod f"
eberlm@66277
   297
  shows   "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
eberlm@66277
   298
  using assms by (auto simp: eventually_at_top_linorder convergent_prod_altdef)
eberlm@66277
   299
eberlm@66277
   300
lemma convergent_prod_imp_LIMSEQ:
eberlm@66277
   301
  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_field}"
eberlm@66277
   302
  assumes "convergent_prod f"
eberlm@66277
   303
  shows   "f \<longlonglongrightarrow> 1"
eberlm@66277
   304
proof -
eberlm@66277
   305
  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
   306
    by (auto simp: convergent_prod_altdef)
eberlm@66277
   307
  hence L': "(\<lambda>n. \<Prod>i\<le>Suc n. f (i+M)) \<longlonglongrightarrow> L" by (subst filterlim_sequentially_Suc)
eberlm@66277
   308
  have "(\<lambda>n. (\<Prod>i\<le>Suc n. f (i+M)) / (\<Prod>i\<le>n. f (i+M))) \<longlonglongrightarrow> L / L"
eberlm@66277
   309
    using L L' by (intro tendsto_divide) simp_all
eberlm@66277
   310
  also from L have "L / L = 1" by simp
eberlm@66277
   311
  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
   312
    using assms L by (auto simp: fun_eq_iff atMost_Suc)
eberlm@66277
   313
  finally show ?thesis by (rule LIMSEQ_offset)
eberlm@66277
   314
qed
eberlm@66277
   315
eberlm@66277
   316
lemma abs_convergent_prod_imp_summable:
eberlm@66277
   317
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
eberlm@66277
   318
  assumes "abs_convergent_prod f"
eberlm@66277
   319
  shows "summable (\<lambda>i. norm (f i - 1))"
eberlm@66277
   320
proof -
eberlm@66277
   321
  from assms have "convergent (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))" 
eberlm@66277
   322
    unfolding abs_convergent_prod_def by (rule convergent_prod_imp_convergent)
eberlm@66277
   323
  then obtain L where L: "(\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1)) \<longlonglongrightarrow> L"
eberlm@66277
   324
    unfolding convergent_def by blast
eberlm@66277
   325
  have "convergent (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))"
eberlm@66277
   326
  proof (rule Bseq_monoseq_convergent)
eberlm@66277
   327
    have "eventually (\<lambda>n. (\<Prod>i\<le>n. 1 + norm (f i - 1)) < L + 1) sequentially"
eberlm@66277
   328
      using L(1) by (rule order_tendstoD) simp_all
eberlm@66277
   329
    hence "\<forall>\<^sub>F x in sequentially. norm (\<Sum>i\<le>x. norm (f i - 1)) \<le> L + 1"
eberlm@66277
   330
    proof eventually_elim
eberlm@66277
   331
      case (elim n)
eberlm@66277
   332
      have "norm (\<Sum>i\<le>n. norm (f i - 1)) = (\<Sum>i\<le>n. norm (f i - 1))"
eberlm@66277
   333
        unfolding real_norm_def by (intro abs_of_nonneg sum_nonneg) simp_all
eberlm@66277
   334
      also have "\<dots> \<le> (\<Prod>i\<le>n. 1 + norm (f i - 1))" by (rule sum_le_prod) auto
eberlm@66277
   335
      also have "\<dots> < L + 1" by (rule elim)
eberlm@66277
   336
      finally show ?case by simp
eberlm@66277
   337
    qed
eberlm@66277
   338
    thus "Bseq (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))" by (rule BfunI)
eberlm@66277
   339
  next
eberlm@66277
   340
    show "monoseq (\<lambda>n. \<Sum>i\<le>n. norm (f i - 1))"
eberlm@66277
   341
      by (rule mono_SucI1) auto
eberlm@66277
   342
  qed
eberlm@66277
   343
  thus "summable (\<lambda>i. norm (f i - 1))" by (simp add: summable_iff_convergent')
eberlm@66277
   344
qed
eberlm@66277
   345
eberlm@66277
   346
lemma summable_imp_abs_convergent_prod:
eberlm@66277
   347
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
eberlm@66277
   348
  assumes "summable (\<lambda>i. norm (f i - 1))"
eberlm@66277
   349
  shows   "abs_convergent_prod f"
eberlm@66277
   350
proof (intro abs_convergent_prodI Bseq_monoseq_convergent)
eberlm@66277
   351
  show "monoseq (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   352
    by (intro mono_SucI1) 
eberlm@66277
   353
       (auto simp: atMost_Suc algebra_simps intro!: mult_nonneg_nonneg prod_nonneg)
eberlm@66277
   354
next
eberlm@66277
   355
  show "Bseq (\<lambda>n. \<Prod>i\<le>n. 1 + norm (f i - 1))"
eberlm@66277
   356
  proof (rule Bseq_eventually_mono)
eberlm@66277
   357
    show "eventually (\<lambda>n. norm (\<Prod>i\<le>n. 1 + norm (f i - 1)) \<le> 
eberlm@66277
   358
            norm (exp (\<Sum>i\<le>n. norm (f i - 1)))) sequentially"
eberlm@66277
   359
      by (intro always_eventually allI) (auto simp: abs_prod exp_sum intro!: prod_mono)
eberlm@66277
   360
  next
eberlm@66277
   361
    from assms have "(\<lambda>n. \<Sum>i\<le>n. norm (f i - 1)) \<longlonglongrightarrow> (\<Sum>i. norm (f i - 1))"
eberlm@66277
   362
      using sums_def_le by blast
eberlm@66277
   363
    hence "(\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1))) \<longlonglongrightarrow> exp (\<Sum>i. norm (f i - 1))"
eberlm@66277
   364
      by (rule tendsto_exp)
eberlm@66277
   365
    hence "convergent (\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1)))"
eberlm@66277
   366
      by (rule convergentI)
eberlm@66277
   367
    thus "Bseq (\<lambda>n. exp (\<Sum>i\<le>n. norm (f i - 1)))"
eberlm@66277
   368
      by (rule convergent_imp_Bseq)
eberlm@66277
   369
  qed
eberlm@66277
   370
qed
eberlm@66277
   371
eberlm@68651
   372
theorem abs_convergent_prod_conv_summable:
eberlm@66277
   373
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra"
eberlm@66277
   374
  shows "abs_convergent_prod f \<longleftrightarrow> summable (\<lambda>i. norm (f i - 1))"
eberlm@66277
   375
  by (blast intro: abs_convergent_prod_imp_summable summable_imp_abs_convergent_prod)
eberlm@66277
   376
eberlm@66277
   377
lemma abs_convergent_prod_imp_LIMSEQ:
eberlm@66277
   378
  fixes f :: "nat \<Rightarrow> 'a :: {comm_ring_1,real_normed_div_algebra}"
eberlm@66277
   379
  assumes "abs_convergent_prod f"
eberlm@66277
   380
  shows   "f \<longlonglongrightarrow> 1"
eberlm@66277
   381
proof -
eberlm@66277
   382
  from assms have "summable (\<lambda>n. norm (f n - 1))"
eberlm@66277
   383
    by (rule abs_convergent_prod_imp_summable)
eberlm@66277
   384
  from summable_LIMSEQ_zero[OF this] have "(\<lambda>n. f n - 1) \<longlonglongrightarrow> 0"
eberlm@66277
   385
    by (simp add: tendsto_norm_zero_iff)
eberlm@66277
   386
  from tendsto_add[OF this tendsto_const[of 1]] show ?thesis by simp
eberlm@66277
   387
qed
eberlm@66277
   388
eberlm@66277
   389
lemma abs_convergent_prod_imp_ev_nonzero:
eberlm@66277
   390
  fixes f :: "nat \<Rightarrow> 'a :: {comm_ring_1,real_normed_div_algebra}"
eberlm@66277
   391
  assumes "abs_convergent_prod f"
eberlm@66277
   392
  shows   "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
eberlm@66277
   393
proof -
eberlm@66277
   394
  from assms have "f \<longlonglongrightarrow> 1" 
eberlm@66277
   395
    by (rule abs_convergent_prod_imp_LIMSEQ)
eberlm@66277
   396
  hence "eventually (\<lambda>n. dist (f n) 1 < 1) at_top"
eberlm@66277
   397
    by (auto simp: tendsto_iff)
eberlm@66277
   398
  thus ?thesis by eventually_elim auto
eberlm@66277
   399
qed
eberlm@66277
   400
eberlm@68651
   401
subsection%unimportant \<open>Ignoring initial segments\<close>
eberlm@68651
   402
eberlm@66277
   403
lemma convergent_prod_offset:
eberlm@66277
   404
  assumes "convergent_prod (\<lambda>n. f (n + m))"  
eberlm@66277
   405
  shows   "convergent_prod f"
eberlm@66277
   406
proof -
eberlm@66277
   407
  from assms obtain M L where "(\<lambda>n. \<Prod>k\<le>n. f (k + (M + m))) \<longlonglongrightarrow> L" "L \<noteq> 0"
lp15@68064
   408
    by (auto simp: prod_defs add.assoc)
lp15@68064
   409
  thus "convergent_prod f" 
lp15@68064
   410
    unfolding prod_defs by blast
eberlm@66277
   411
qed
eberlm@66277
   412
eberlm@66277
   413
lemma abs_convergent_prod_offset:
eberlm@66277
   414
  assumes "abs_convergent_prod (\<lambda>n. f (n + m))"  
eberlm@66277
   415
  shows   "abs_convergent_prod f"
eberlm@66277
   416
  using assms unfolding abs_convergent_prod_def by (rule convergent_prod_offset)
eberlm@66277
   417
lp15@68424
   418
lp15@68361
   419
lemma raw_has_prod_ignore_initial_segment:
lp15@68361
   420
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_field"
lp15@68361
   421
  assumes "raw_has_prod f M p" "N \<ge> M"
lp15@68361
   422
  obtains q where  "raw_has_prod f N q"
eberlm@66277
   423
proof -
lp15@68361
   424
  have p: "(\<lambda>n. \<Prod>k\<le>n. f (k + M)) \<longlonglongrightarrow> p" and "p \<noteq> 0" 
lp15@68361
   425
    using assms by (auto simp: raw_has_prod_def)
lp15@68361
   426
  then have nz: "\<And>n. n \<ge> M \<Longrightarrow> f n \<noteq> 0"
lp15@68361
   427
    using assms by (auto simp: raw_has_prod_eq_0)
lp15@68361
   428
  define C where "C = (\<Prod>k<N-M. f (k + M))"
eberlm@66277
   429
  from nz have [simp]: "C \<noteq> 0" 
eberlm@66277
   430
    by (auto simp: C_def)
eberlm@66277
   431
lp15@68361
   432
  from p have "(\<lambda>i. \<Prod>k\<le>i + (N-M). f (k + M)) \<longlonglongrightarrow> p" 
eberlm@66277
   433
    by (rule LIMSEQ_ignore_initial_segment)
lp15@68361
   434
  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
   435
  proof (rule ext, goal_cases)
eberlm@66277
   436
    case (1 n)
lp15@68361
   437
    have "{..n+(N-M)} = {..<(N-M)} \<union> {(N-M)..n+(N-M)}" by auto
lp15@68361
   438
    also have "(\<Prod>k\<in>\<dots>. f (k + M)) = C * (\<Prod>k=(N-M)..n+(N-M). f (k + M))"
eberlm@66277
   439
      unfolding C_def by (rule prod.union_disjoint) auto
lp15@68361
   440
    also have "(\<Prod>k=(N-M)..n+(N-M). f (k + M)) = (\<Prod>k\<le>n. f (k + (N-M) + M))"
lp15@68361
   441
      by (intro ext prod.reindex_bij_witness[of _ "\<lambda>k. k + (N-M)" "\<lambda>k. k - (N-M)"]) auto
lp15@68361
   442
    finally show ?case
lp15@68361
   443
      using \<open>N \<ge> M\<close> by (simp add: add_ac)
eberlm@66277
   444
  qed
lp15@68361
   445
  finally have "(\<lambda>n. C * (\<Prod>k\<le>n. f (k + N)) / C) \<longlonglongrightarrow> p / C"
eberlm@66277
   446
    by (intro tendsto_divide tendsto_const) auto
lp15@68361
   447
  hence "(\<lambda>n. \<Prod>k\<le>n. f (k + N)) \<longlonglongrightarrow> p / C" by simp
lp15@68361
   448
  moreover from \<open>p \<noteq> 0\<close> have "p / C \<noteq> 0" by simp
lp15@68361
   449
  ultimately show ?thesis
lp15@68361
   450
    using raw_has_prod_def that by blast 
eberlm@66277
   451
qed
eberlm@66277
   452
eberlm@68651
   453
corollary%unimportant convergent_prod_ignore_initial_segment:
lp15@68361
   454
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_field"
lp15@68361
   455
  assumes "convergent_prod f"
lp15@68361
   456
  shows   "convergent_prod (\<lambda>n. f (n + m))"
lp15@68361
   457
  using assms
lp15@68361
   458
  unfolding convergent_prod_def 
lp15@68361
   459
  apply clarify
lp15@68361
   460
  apply (erule_tac N="M+m" in raw_has_prod_ignore_initial_segment)
lp15@68361
   461
  apply (auto simp add: raw_has_prod_def add_ac)
lp15@68361
   462
  done
lp15@68361
   463
eberlm@68651
   464
corollary%unimportant convergent_prod_ignore_nonzero_segment:
lp15@68136
   465
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_field"
lp15@68136
   466
  assumes f: "convergent_prod f" and nz: "\<And>i. i \<ge> M \<Longrightarrow> f i \<noteq> 0"
lp15@68361
   467
  shows "\<exists>p. raw_has_prod f M p"
lp15@68136
   468
  using convergent_prod_ignore_initial_segment [OF f]
lp15@68136
   469
  by (metis convergent_LIMSEQ_iff convergent_prod_iff_convergent le_add_same_cancel2 nz prod_defs(1) zero_order(1))
lp15@68136
   470
eberlm@68651
   471
corollary%unimportant abs_convergent_prod_ignore_initial_segment:
eberlm@66277
   472
  assumes "abs_convergent_prod f"
eberlm@66277
   473
  shows   "abs_convergent_prod (\<lambda>n. f (n + m))"
eberlm@66277
   474
  using assms unfolding abs_convergent_prod_def 
eberlm@66277
   475
  by (rule convergent_prod_ignore_initial_segment)
eberlm@66277
   476
eberlm@68651
   477
subsection\<open>More elementary properties\<close>
eberlm@68651
   478
eberlm@68651
   479
theorem abs_convergent_prod_imp_convergent_prod:
eberlm@66277
   480
  fixes f :: "nat \<Rightarrow> 'a :: {real_normed_div_algebra,complete_space,comm_ring_1}"
eberlm@66277
   481
  assumes "abs_convergent_prod f"
eberlm@66277
   482
  shows   "convergent_prod f"
eberlm@66277
   483
proof -
eberlm@66277
   484
  from assms have "eventually (\<lambda>n. f n \<noteq> 0) sequentially"
eberlm@66277
   485
    by (rule abs_convergent_prod_imp_ev_nonzero)
eberlm@66277
   486
  then obtain N where N: "f n \<noteq> 0" if "n \<ge> N" for n 
eberlm@66277
   487
    by (auto simp: eventually_at_top_linorder)
eberlm@66277
   488
  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
   489
eberlm@66277
   490
  have "Cauchy ?P"
eberlm@66277
   491
  proof (rule CauchyI', goal_cases)
eberlm@66277
   492
    case (1 \<epsilon>)
eberlm@66277
   493
    from assms have "abs_convergent_prod (\<lambda>n. f (n + N))"
eberlm@66277
   494
      by (rule abs_convergent_prod_ignore_initial_segment)
eberlm@66277
   495
    hence "Cauchy ?Q"
eberlm@66277
   496
      unfolding abs_convergent_prod_def
eberlm@66277
   497
      by (intro convergent_Cauchy convergent_prod_imp_convergent)
eberlm@66277
   498
    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
   499
      by blast
eberlm@66277
   500
    show ?case
eberlm@66277
   501
    proof (rule exI[of _ M], safe, goal_cases)
eberlm@66277
   502
      case (1 m n)
eberlm@66277
   503
      have "dist (?P m) (?P n) = norm (?P n - ?P m)"
eberlm@66277
   504
        by (simp add: dist_norm norm_minus_commute)
eberlm@66277
   505
      also from 1 have "{..n} = {..m} \<union> {m<..n}" by auto
eberlm@66277
   506
      hence "norm (?P n - ?P m) = norm (?P m * (\<Prod>k\<in>{m<..n}. f (k + N)) - ?P m)"
eberlm@66277
   507
        by (subst prod.union_disjoint [symmetric]) (auto simp: algebra_simps)
eberlm@66277
   508
      also have "\<dots> = norm (?P m * ((\<Prod>k\<in>{m<..n}. f (k + N)) - 1))"
eberlm@66277
   509
        by (simp add: algebra_simps)
eberlm@66277
   510
      also have "\<dots> = (\<Prod>k\<le>m. norm (f (k + N))) * norm ((\<Prod>k\<in>{m<..n}. f (k + N)) - 1)"
eberlm@66277
   511
        by (simp add: norm_mult prod_norm)
eberlm@66277
   512
      also have "\<dots> \<le> ?Q m * ((\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) - 1)"
eberlm@66277
   513
        using norm_prod_minus1_le_prod_minus1[of "\<lambda>k. f (k + N) - 1" "{m<..n}"]
eberlm@66277
   514
              norm_triangle_ineq[of 1 "f k - 1" for k]
eberlm@66277
   515
        by (intro mult_mono prod_mono ballI conjI norm_prod_minus1_le_prod_minus1 prod_nonneg) auto
eberlm@66277
   516
      also have "\<dots> = ?Q m * (\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) - ?Q m"
eberlm@66277
   517
        by (simp add: algebra_simps)
eberlm@66277
   518
      also have "?Q m * (\<Prod>k\<in>{m<..n}. 1 + norm (f (k + N) - 1)) = 
eberlm@66277
   519
                   (\<Prod>k\<in>{..m}\<union>{m<..n}. 1 + norm (f (k + N) - 1))"
eberlm@66277
   520
        by (rule prod.union_disjoint [symmetric]) auto
eberlm@66277
   521
      also from 1 have "{..m}\<union>{m<..n} = {..n}" by auto
eberlm@66277
   522
      also have "?Q n - ?Q m \<le> norm (?Q n - ?Q m)" by simp
eberlm@66277
   523
      also from 1 have "\<dots> < \<epsilon>" by (intro M) auto
eberlm@66277
   524
      finally show ?case .
eberlm@66277
   525
    qed
eberlm@66277
   526
  qed
eberlm@66277
   527
  hence conv: "convergent ?P" by (rule Cauchy_convergent)
eberlm@66277
   528
  then obtain L where L: "?P \<longlonglongrightarrow> L"
eberlm@66277
   529
    by (auto simp: convergent_def)
eberlm@66277
   530
eberlm@66277
   531
  have "L \<noteq> 0"
eberlm@66277
   532
  proof
eberlm@66277
   533
    assume [simp]: "L = 0"
eberlm@66277
   534
    from tendsto_norm[OF L] have limit: "(\<lambda>n. \<Prod>k\<le>n. norm (f (k + N))) \<longlonglongrightarrow> 0" 
eberlm@66277
   535
      by (simp add: prod_norm)
eberlm@66277
   536
eberlm@66277
   537
    from assms have "(\<lambda>n. f (n + N)) \<longlonglongrightarrow> 1"
eberlm@66277
   538
      by (intro abs_convergent_prod_imp_LIMSEQ abs_convergent_prod_ignore_initial_segment)
eberlm@66277
   539
    hence "eventually (\<lambda>n. norm (f (n + N) - 1) < 1) sequentially"
eberlm@66277
   540
      by (auto simp: tendsto_iff dist_norm)
eberlm@66277
   541
    then obtain M0 where M0: "norm (f (n + N) - 1) < 1" if "n \<ge> M0" for n
eberlm@66277
   542
      by (auto simp: eventually_at_top_linorder)
eberlm@66277
   543
eberlm@66277
   544
    {
eberlm@66277
   545
      fix M assume M: "M \<ge> M0"
eberlm@66277
   546
      with M0 have M: "norm (f (n + N) - 1) < 1" if "n \<ge> M" for n using that by simp
eberlm@66277
   547
eberlm@66277
   548
      have "(\<lambda>n. \<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<longlonglongrightarrow> 0"
eberlm@66277
   549
      proof (rule tendsto_sandwich)
eberlm@66277
   550
        show "eventually (\<lambda>n. (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<ge> 0) sequentially"
eberlm@66277
   551
          using M by (intro always_eventually prod_nonneg allI ballI) (auto intro: less_imp_le)
eberlm@66277
   552
        have "norm (1::'a) - norm (f (i + M + N) - 1) \<le> norm (f (i + M + N))" for i
eberlm@66277
   553
          using norm_triangle_ineq3[of "f (i + M + N)" 1] by simp
eberlm@66277
   554
        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
   555
          using M by (intro always_eventually allI prod_mono ballI conjI) (auto intro: less_imp_le)
eberlm@66277
   556
        
eberlm@66277
   557
        define C where "C = (\<Prod>k<M. norm (f (k + N)))"
eberlm@66277
   558
        from N have [simp]: "C \<noteq> 0" by (auto simp: C_def)
eberlm@66277
   559
        from L have "(\<lambda>n. norm (\<Prod>k\<le>n+M. f (k + N))) \<longlonglongrightarrow> 0"
eberlm@66277
   560
          by (intro LIMSEQ_ignore_initial_segment) (simp add: tendsto_norm_zero_iff)
eberlm@66277
   561
        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
   562
        proof (rule ext, goal_cases)
eberlm@66277
   563
          case (1 n)
eberlm@66277
   564
          have "{..n+M} = {..<M} \<union> {M..n+M}" by auto
eberlm@66277
   565
          also have "norm (\<Prod>k\<in>\<dots>. f (k + N)) = C * norm (\<Prod>k=M..n+M. f (k + N))"
eberlm@66277
   566
            unfolding C_def by (subst prod.union_disjoint) (auto simp: norm_mult prod_norm)
eberlm@66277
   567
          also have "(\<Prod>k=M..n+M. f (k + N)) = (\<Prod>k\<le>n. f (k + N + M))"
eberlm@66277
   568
            by (intro prod.reindex_bij_witness[of _ "\<lambda>i. i + M" "\<lambda>i. i - M"]) auto
eberlm@66277
   569
          finally show ?case by (simp add: add_ac prod_norm)
eberlm@66277
   570
        qed
eberlm@66277
   571
        finally have "(\<lambda>n. C * (\<Prod>k\<le>n. norm (f (k + M + N))) / C) \<longlonglongrightarrow> 0 / C"
eberlm@66277
   572
          by (intro tendsto_divide tendsto_const) auto
eberlm@66277
   573
        thus "(\<lambda>n. \<Prod>k\<le>n. norm (f (k + M + N))) \<longlonglongrightarrow> 0" by simp
eberlm@66277
   574
      qed simp_all
eberlm@66277
   575
eberlm@66277
   576
      have "1 - (\<Sum>i. norm (f (i + M + N) - 1)) \<le> 0"
eberlm@66277
   577
      proof (rule tendsto_le)
eberlm@66277
   578
        show "eventually (\<lambda>n. 1 - (\<Sum>k\<le>n. norm (f (k+M+N) - 1)) \<le> 
eberlm@66277
   579
                                (\<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1))) at_top"
nipkow@69529
   580
          using M by (intro always_eventually allI Weierstrass_prod_ineq) (auto intro: less_imp_le)
eberlm@66277
   581
        show "(\<lambda>n. \<Prod>k\<le>n. 1 - norm (f (k+M+N) - 1)) \<longlonglongrightarrow> 0" by fact
eberlm@66277
   582
        show "(\<lambda>n. 1 - (\<Sum>k\<le>n. norm (f (k + M + N) - 1)))
eberlm@66277
   583
                  \<longlonglongrightarrow> 1 - (\<Sum>i. norm (f (i + M + N) - 1))"
eberlm@66277
   584
          by (intro tendsto_intros summable_LIMSEQ' summable_ignore_initial_segment 
eberlm@66277
   585
                abs_convergent_prod_imp_summable assms)
eberlm@66277
   586
      qed simp_all
eberlm@66277
   587
      hence "(\<Sum>i. norm (f (i + M + N) - 1)) \<ge> 1" by simp
eberlm@66277
   588
      also have "\<dots> + (\<Sum>i<M. norm (f (i + N) - 1)) = (\<Sum>i. norm (f (i + N) - 1))"
eberlm@66277
   589
        by (intro suminf_split_initial_segment [symmetric] summable_ignore_initial_segment
eberlm@66277
   590
              abs_convergent_prod_imp_summable assms)
eberlm@66277
   591
      finally have "1 + (\<Sum>i<M. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))" by simp
eberlm@66277
   592
    } note * = this
eberlm@66277
   593
eberlm@66277
   594
    have "1 + (\<Sum>i. norm (f (i + N) - 1)) \<le> (\<Sum>i. norm (f (i + N) - 1))"
eberlm@66277
   595
    proof (rule tendsto_le)
eberlm@66277
   596
      show "(\<lambda>M. 1 + (\<Sum>i<M. norm (f (i + N) - 1))) \<longlonglongrightarrow> 1 + (\<Sum>i. norm (f (i + N) - 1))"
eberlm@66277
   597
        by (intro tendsto_intros summable_LIMSEQ summable_ignore_initial_segment 
eberlm@66277
   598
                abs_convergent_prod_imp_summable assms)
eberlm@66277
   599
      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
   600
        using eventually_ge_at_top[of M0] by eventually_elim (use * in auto)
eberlm@66277
   601
    qed simp_all
eberlm@66277
   602
    thus False by simp
eberlm@66277
   603
  qed
lp15@68064
   604
  with L show ?thesis by (auto simp: prod_defs)
lp15@68064
   605
qed
lp15@68064
   606
lp15@68361
   607
lemma raw_has_prod_cases:
lp15@68064
   608
  fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"
lp15@68361
   609
  assumes "raw_has_prod f M p"
lp15@68361
   610
  obtains i where "i<M" "f i = 0" | p where "raw_has_prod f 0 p"
lp15@68136
   611
proof -
lp15@68136
   612
  have "(\<lambda>n. \<Prod>i\<le>n. f (i + M)) \<longlonglongrightarrow> p" "p \<noteq> 0"
lp15@68361
   613
    using assms unfolding raw_has_prod_def by blast+
lp15@68064
   614
  then have "(\<lambda>n. prod f {..<M} * (\<Prod>i\<le>n. f (i + M))) \<longlonglongrightarrow> prod f {..<M} * p"
lp15@68064
   615
    by (metis tendsto_mult_left)
lp15@68064
   616
  moreover have "prod f {..<M} * (\<Prod>i\<le>n. f (i + M)) = prod f {..n+M}" for n
lp15@68064
   617
  proof -
lp15@68064
   618
    have "{..n+M} = {..<M} \<union> {M..n+M}"
lp15@68064
   619
      by auto
lp15@68064
   620
    then have "prod f {..n+M} = prod f {..<M} * prod f {M..n+M}"
lp15@68064
   621
      by simp (subst prod.union_disjoint; force)
lp15@68138
   622
    also have "\<dots> = prod f {..<M} * (\<Prod>i\<le>n. f (i + M))"
lp15@68064
   623
      by (metis (mono_tags, lifting) add.left_neutral atMost_atLeast0 prod_shift_bounds_cl_nat_ivl)
lp15@68064
   624
    finally show ?thesis by metis
lp15@68064
   625
  qed
lp15@68064
   626
  ultimately have "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f {..<M} * p"
lp15@68064
   627
    by (auto intro: LIMSEQ_offset [where k=M])
lp15@68361
   628
  then have "raw_has_prod f 0 (prod f {..<M} * p)" if "\<forall>i<M. f i \<noteq> 0"
lp15@68361
   629
    using \<open>p \<noteq> 0\<close> assms that by (auto simp: raw_has_prod_def)
lp15@68136
   630
  then show thesis
lp15@68136
   631
    using that by blast
lp15@68064
   632
qed
lp15@68064
   633
lp15@68136
   634
corollary convergent_prod_offset_0:
lp15@68136
   635
  fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"
lp15@68136
   636
  assumes "convergent_prod f" "\<And>i. f i \<noteq> 0"
lp15@68361
   637
  shows "\<exists>p. raw_has_prod f 0 p"
lp15@68361
   638
  using assms convergent_prod_def raw_has_prod_cases by blast
lp15@68136
   639
lp15@68064
   640
lemma prodinf_eq_lim:
lp15@68064
   641
  fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"
lp15@68064
   642
  assumes "convergent_prod f" "\<And>i. f i \<noteq> 0"
lp15@68064
   643
  shows "prodinf f = lim (\<lambda>n. \<Prod>i\<le>n. f i)"
lp15@68064
   644
  using assms convergent_prod_offset_0 [OF assms]
lp15@68064
   645
  by (simp add: prod_defs lim_def) (metis (no_types) assms(1) convergent_prod_to_zero_iff)
lp15@68064
   646
lp15@68064
   647
lemma has_prod_one[simp, intro]: "(\<lambda>n. 1) has_prod 1"
lp15@68064
   648
  unfolding prod_defs by auto
lp15@68064
   649
lp15@68064
   650
lemma convergent_prod_one[simp, intro]: "convergent_prod (\<lambda>n. 1)"
lp15@68064
   651
  unfolding prod_defs by auto
lp15@68064
   652
lp15@68064
   653
lemma prodinf_cong: "(\<And>n. f n = g n) \<Longrightarrow> prodinf f = prodinf g"
lp15@68064
   654
  by presburger
lp15@68064
   655
lp15@68064
   656
lemma convergent_prod_cong:
lp15@68064
   657
  fixes f g :: "nat \<Rightarrow> 'a::{field,topological_semigroup_mult,t2_space}"
lp15@68064
   658
  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
   659
  shows "convergent_prod f = convergent_prod g"
lp15@68064
   660
proof -
lp15@68064
   661
  from assms obtain N where N: "\<forall>n\<ge>N. f n = g n"
lp15@68064
   662
    by (auto simp: eventually_at_top_linorder)
lp15@68064
   663
  define C where "C = (\<Prod>k<N. f k / g k)"
lp15@68064
   664
  with g have "C \<noteq> 0"
lp15@68064
   665
    by (simp add: f)
lp15@68064
   666
  have *: "eventually (\<lambda>n. prod f {..n} = C * prod g {..n}) sequentially"
lp15@68064
   667
    using eventually_ge_at_top[of N]
lp15@68064
   668
  proof eventually_elim
lp15@68064
   669
    case (elim n)
lp15@68064
   670
    then have "{..n} = {..<N} \<union> {N..n}"
lp15@68064
   671
      by auto
lp15@68138
   672
    also have "prod f \<dots> = prod f {..<N} * prod f {N..n}"
lp15@68064
   673
      by (intro prod.union_disjoint) auto
lp15@68064
   674
    also from N have "prod f {N..n} = prod g {N..n}"
lp15@68064
   675
      by (intro prod.cong) simp_all
lp15@68064
   676
    also have "prod f {..<N} * prod g {N..n} = C * (prod g {..<N} * prod g {N..n})"
lp15@68064
   677
      unfolding C_def by (simp add: g prod_dividef)
lp15@68064
   678
    also have "prod g {..<N} * prod g {N..n} = prod g ({..<N} \<union> {N..n})"
lp15@68064
   679
      by (intro prod.union_disjoint [symmetric]) auto
lp15@68064
   680
    also from elim have "{..<N} \<union> {N..n} = {..n}"
lp15@68064
   681
      by auto                                                                    
lp15@68064
   682
    finally show "prod f {..n} = C * prod g {..n}" .
lp15@68064
   683
  qed
lp15@68064
   684
  then have cong: "convergent (\<lambda>n. prod f {..n}) = convergent (\<lambda>n. C * prod g {..n})"
lp15@68064
   685
    by (rule convergent_cong)
lp15@68064
   686
  show ?thesis
lp15@68064
   687
  proof
lp15@68064
   688
    assume cf: "convergent_prod f"
lp15@68064
   689
    then have "\<not> (\<lambda>n. prod g {..n}) \<longlonglongrightarrow> 0"
lp15@68064
   690
      using tendsto_mult_left * convergent_prod_to_zero_iff f filterlim_cong by fastforce
lp15@68064
   691
    then show "convergent_prod g"
lp15@68064
   692
      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
   693
  next
lp15@68064
   694
    assume cg: "convergent_prod g"
lp15@68064
   695
    have "\<exists>a. C * a \<noteq> 0 \<and> (\<lambda>n. prod g {..n}) \<longlonglongrightarrow> a"
lp15@68064
   696
      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
   697
    then show "convergent_prod f"
lp15@68064
   698
      using "*" tendsto_mult_left filterlim_cong
lp15@68064
   699
      by (fastforce simp add: convergent_prod_iff_nz_lim f)
lp15@68064
   700
  qed
eberlm@66277
   701
qed
eberlm@66277
   702
lp15@68071
   703
lemma has_prod_finite:
lp15@68361
   704
  fixes f :: "nat \<Rightarrow> 'a::{semidom,t2_space}"
lp15@68071
   705
  assumes [simp]: "finite N"
lp15@68071
   706
    and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 1"
lp15@68071
   707
  shows "f has_prod (\<Prod>n\<in>N. f n)"
lp15@68071
   708
proof -
lp15@68071
   709
  have eq: "prod f {..n + Suc (Max N)} = prod f N" for n
lp15@68071
   710
  proof (rule prod.mono_neutral_right)
lp15@68071
   711
    show "N \<subseteq> {..n + Suc (Max N)}"
lp15@68138
   712
      by (auto simp: le_Suc_eq trans_le_add2)
lp15@68071
   713
    show "\<forall>i\<in>{..n + Suc (Max N)} - N. f i = 1"
lp15@68071
   714
      using f by blast
lp15@68071
   715
  qed auto
lp15@68071
   716
  show ?thesis
lp15@68071
   717
  proof (cases "\<forall>n\<in>N. f n \<noteq> 0")
lp15@68071
   718
    case True
lp15@68071
   719
    then have "prod f N \<noteq> 0"
lp15@68071
   720
      by simp
lp15@68071
   721
    moreover have "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> prod f N"
lp15@68071
   722
      by (rule LIMSEQ_offset[of _ "Suc (Max N)"]) (simp add: eq atLeast0LessThan del: add_Suc_right)
lp15@68071
   723
    ultimately show ?thesis
lp15@68361
   724
      by (simp add: raw_has_prod_def has_prod_def)
lp15@68071
   725
  next
lp15@68071
   726
    case False
lp15@68071
   727
    then obtain k where "k \<in> N" "f k = 0"
lp15@68071
   728
      by auto
lp15@68071
   729
    let ?Z = "{n \<in> N. f n = 0}"
lp15@68071
   730
    have maxge: "Max ?Z \<ge> n" if "f n = 0" for n
lp15@68071
   731
      using Max_ge [of ?Z] \<open>finite N\<close> \<open>f n = 0\<close>
lp15@68071
   732
      by (metis (mono_tags) Collect_mem_eq f finite_Collect_conjI mem_Collect_eq zero_neq_one)
lp15@68071
   733
    let ?q = "prod f {Suc (Max ?Z)..Max N}"
lp15@68071
   734
    have [simp]: "?q \<noteq> 0"
lp15@68071
   735
      using maxge Suc_n_not_le_n le_trans by force
lp15@68076
   736
    have eq: "(\<Prod>i\<le>n + Max N. f (Suc (i + Max ?Z))) = ?q" for n
lp15@68076
   737
    proof -
lp15@68076
   738
      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
   739
      proof (rule prod.reindex_cong [where l = "\<lambda>i. i + Suc (Max ?Z)", THEN sym])
lp15@68076
   740
        show "{Suc (Max ?Z)..n + Max N + Suc (Max ?Z)} = (\<lambda>i. i + Suc (Max ?Z)) ` {..n + Max N}"
lp15@68076
   741
          using le_Suc_ex by fastforce
lp15@68076
   742
      qed (auto simp: inj_on_def)
lp15@68138
   743
      also have "\<dots> = ?q"
lp15@68076
   744
        by (rule prod.mono_neutral_right)
lp15@68076
   745
           (use Max.coboundedI [OF \<open>finite N\<close>] f in \<open>force+\<close>)
lp15@68076
   746
      finally show ?thesis .
lp15@68076
   747
    qed
lp15@68361
   748
    have q: "raw_has_prod f (Suc (Max ?Z)) ?q"
lp15@68361
   749
    proof (simp add: raw_has_prod_def)
lp15@68076
   750
      show "(\<lambda>n. \<Prod>i\<le>n. f (Suc (i + Max ?Z))) \<longlonglongrightarrow> ?q"
lp15@68076
   751
        by (rule LIMSEQ_offset[of _ "(Max N)"]) (simp add: eq)
lp15@68076
   752
    qed
lp15@68071
   753
    show ?thesis
lp15@68071
   754
      unfolding has_prod_def
lp15@68071
   755
    proof (intro disjI2 exI conjI)      
lp15@68071
   756
      show "prod f N = 0"
lp15@68071
   757
        using \<open>f k = 0\<close> \<open>k \<in> N\<close> \<open>finite N\<close> prod_zero by blast
lp15@68071
   758
      show "f (Max ?Z) = 0"
lp15@68071
   759
        using Max_in [of ?Z] \<open>finite N\<close> \<open>f k = 0\<close> \<open>k \<in> N\<close> by auto
lp15@68071
   760
    qed (use q in auto)
lp15@68071
   761
  qed
lp15@68071
   762
qed
lp15@68071
   763
eberlm@68651
   764
corollary%unimportant has_prod_0:
lp15@68361
   765
  fixes f :: "nat \<Rightarrow> 'a::{semidom,t2_space}"
lp15@68071
   766
  assumes "\<And>n. f n = 1"
lp15@68071
   767
  shows "f has_prod 1"
lp15@68071
   768
  by (simp add: assms has_prod_cong)
lp15@68071
   769
lp15@68361
   770
lemma prodinf_zero[simp]: "prodinf (\<lambda>n. 1::'a::real_normed_field) = 1"
lp15@68361
   771
  using has_prod_unique by force
lp15@68361
   772
lp15@68071
   773
lemma convergent_prod_finite:
lp15@68071
   774
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68071
   775
  assumes "finite N" "\<And>n. n \<notin> N \<Longrightarrow> f n = 1"
lp15@68071
   776
  shows "convergent_prod f"
lp15@68071
   777
proof -
lp15@68361
   778
  have "\<exists>n p. raw_has_prod f n p"
lp15@68071
   779
    using assms has_prod_def has_prod_finite by blast
lp15@68071
   780
  then show ?thesis
lp15@68071
   781
    by (simp add: convergent_prod_def)
lp15@68071
   782
qed
lp15@68071
   783
lp15@68127
   784
lemma has_prod_If_finite_set:
lp15@68127
   785
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   786
  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
   787
  using has_prod_finite[of A "(\<lambda>r. if r \<in> A then f r else 1)"]
lp15@68127
   788
  by simp
lp15@68127
   789
lp15@68127
   790
lemma has_prod_If_finite:
lp15@68127
   791
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   792
  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
   793
  using has_prod_If_finite_set[of "{r. P r}"] by simp
lp15@68127
   794
lp15@68127
   795
lemma convergent_prod_If_finite_set[simp, intro]:
lp15@68127
   796
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   797
  shows "finite A \<Longrightarrow> convergent_prod (\<lambda>r. if r \<in> A then f r else 1)"
lp15@68127
   798
  by (simp add: convergent_prod_finite)
lp15@68127
   799
lp15@68127
   800
lemma convergent_prod_If_finite[simp, intro]:
lp15@68127
   801
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   802
  shows "finite {r. P r} \<Longrightarrow> convergent_prod (\<lambda>r. if P r then f r else 1)"
lp15@68127
   803
  using convergent_prod_def has_prod_If_finite has_prod_def by fastforce
lp15@68127
   804
lp15@68127
   805
lemma has_prod_single:
lp15@68127
   806
  fixes f :: "nat \<Rightarrow> 'a::{idom,t2_space}"
lp15@68127
   807
  shows "(\<lambda>r. if r = i then f r else 1) has_prod f i"
lp15@68127
   808
  using has_prod_If_finite[of "\<lambda>r. r = i"] by simp
lp15@68127
   809
lp15@68136
   810
context
lp15@68136
   811
  fixes f :: "nat \<Rightarrow> 'a :: real_normed_field"
lp15@68136
   812
begin
lp15@68136
   813
lp15@68136
   814
lemma convergent_prod_imp_has_prod: 
lp15@68136
   815
  assumes "convergent_prod f"
lp15@68136
   816
  shows "\<exists>p. f has_prod p"
lp15@68136
   817
proof -
lp15@68361
   818
  obtain M p where p: "raw_has_prod f M p"
lp15@68136
   819
    using assms convergent_prod_def by blast
lp15@68136
   820
  then have "p \<noteq> 0"
lp15@68361
   821
    using raw_has_prod_nonzero by blast
lp15@68136
   822
  with p have fnz: "f i \<noteq> 0" if "i \<ge> M" for i
lp15@68361
   823
    using raw_has_prod_eq_0 that by blast
lp15@68136
   824
  define C where "C = (\<Prod>n<M. f n)"
lp15@68136
   825
  show ?thesis
lp15@68136
   826
  proof (cases "\<forall>n\<le>M. f n \<noteq> 0")
lp15@68136
   827
    case True
lp15@68136
   828
    then have "C \<noteq> 0"
lp15@68136
   829
      by (simp add: C_def)
lp15@68136
   830
    then show ?thesis
lp15@68136
   831
      by (meson True assms convergent_prod_offset_0 fnz has_prod_def nat_le_linear)
lp15@68136
   832
  next
lp15@68136
   833
    case False
lp15@68136
   834
    let ?N = "GREATEST n. f n = 0"
lp15@68136
   835
    have 0: "f ?N = 0"
lp15@68136
   836
      using fnz False
lp15@68136
   837
      by (metis (mono_tags, lifting) GreatestI_ex_nat nat_le_linear)
lp15@68136
   838
    have "f i \<noteq> 0" if "i > ?N" for i
lp15@68136
   839
      by (metis (mono_tags, lifting) Greatest_le_nat fnz leD linear that)
lp15@68361
   840
    then have "\<exists>p. raw_has_prod f (Suc ?N) p"
lp15@68136
   841
      using assms by (auto simp: intro!: convergent_prod_ignore_nonzero_segment)
lp15@68136
   842
    then show ?thesis
lp15@68136
   843
      unfolding has_prod_def using 0 by blast
lp15@68136
   844
  qed
lp15@68136
   845
qed
lp15@68136
   846
lp15@68136
   847
lemma convergent_prod_has_prod [intro]:
lp15@68136
   848
  shows "convergent_prod f \<Longrightarrow> f has_prod (prodinf f)"
lp15@68136
   849
  unfolding prodinf_def
lp15@68136
   850
  by (metis convergent_prod_imp_has_prod has_prod_unique theI')
lp15@68136
   851
lp15@68136
   852
lemma convergent_prod_LIMSEQ:
lp15@68136
   853
  shows "convergent_prod f \<Longrightarrow> (\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> prodinf f"
lp15@68136
   854
  by (metis convergent_LIMSEQ_iff convergent_prod_has_prod convergent_prod_imp_convergent 
lp15@68361
   855
      convergent_prod_to_zero_iff raw_has_prod_eq_0 has_prod_def prodinf_eq_lim zero_le)
lp15@68136
   856
eberlm@68651
   857
theorem has_prod_iff: "f has_prod x \<longleftrightarrow> convergent_prod f \<and> prodinf f = x"
lp15@68136
   858
proof
lp15@68136
   859
  assume "f has_prod x"
lp15@68136
   860
  then show "convergent_prod f \<and> prodinf f = x"
lp15@68136
   861
    apply safe
lp15@68136
   862
    using convergent_prod_def has_prod_def apply blast
lp15@68136
   863
    using has_prod_unique by blast
lp15@68136
   864
qed auto
lp15@68136
   865
lp15@68136
   866
lemma convergent_prod_has_prod_iff: "convergent_prod f \<longleftrightarrow> f has_prod prodinf f"
lp15@68136
   867
  by (auto simp: has_prod_iff convergent_prod_has_prod)
lp15@68136
   868
lp15@68136
   869
lemma prodinf_finite:
lp15@68136
   870
  assumes N: "finite N"
lp15@68136
   871
    and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 1"
lp15@68136
   872
  shows "prodinf f = (\<Prod>n\<in>N. f n)"
lp15@68136
   873
  using has_prod_finite[OF assms, THEN has_prod_unique] by simp
lp15@68127
   874
eberlm@66277
   875
end
lp15@68136
   876
eberlm@68651
   877
subsection%unimportant \<open>Infinite products on ordered topological monoids\<close>
lp15@68361
   878
lp15@68361
   879
lemma LIMSEQ_prod_0: 
lp15@68361
   880
  fixes f :: "nat \<Rightarrow> 'a::{semidom,topological_space}"
lp15@68361
   881
  assumes "f i = 0"
lp15@68361
   882
  shows "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> 0"
lp15@68361
   883
proof (subst tendsto_cong)
lp15@68361
   884
  show "\<forall>\<^sub>F n in sequentially. prod f {..n} = 0"
lp15@68361
   885
  proof
lp15@68361
   886
    show "prod f {..n} = 0" if "n \<ge> i" for n
lp15@68361
   887
      using that assms by auto
lp15@68361
   888
  qed
lp15@68361
   889
qed auto
lp15@68361
   890
lp15@68361
   891
lemma LIMSEQ_prod_nonneg: 
lp15@68361
   892
  fixes f :: "nat \<Rightarrow> 'a::{linordered_semidom,linorder_topology}"
lp15@68361
   893
  assumes 0: "\<And>n. 0 \<le> f n" and a: "(\<lambda>n. prod f {..n}) \<longlonglongrightarrow> a"
lp15@68361
   894
  shows "a \<ge> 0"
lp15@68361
   895
  by (simp add: "0" prod_nonneg LIMSEQ_le_const [OF a])
lp15@68361
   896
lp15@68361
   897
lp15@68361
   898
context
lp15@68361
   899
  fixes f :: "nat \<Rightarrow> 'a::{linordered_semidom,linorder_topology}"
lp15@68361
   900
begin
lp15@68361
   901
lp15@68361
   902
lemma has_prod_le:
lp15@68361
   903
  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
   904
  shows "a \<le> b"
lp15@68361
   905
proof (cases "a=0 \<or> b=0")
lp15@68361
   906
  case True
lp15@68361
   907
  then show ?thesis
lp15@68361
   908
  proof
lp15@68361
   909
    assume [simp]: "a=0"
lp15@68361
   910
    have "b \<ge> 0"
lp15@68361
   911
    proof (rule LIMSEQ_prod_nonneg)
lp15@68361
   912
      show "(\<lambda>n. prod g {..n}) \<longlonglongrightarrow> b"
lp15@68361
   913
        using g by (auto simp: has_prod_def raw_has_prod_def LIMSEQ_prod_0)
lp15@68361
   914
    qed (use le order_trans in auto)
lp15@68361
   915
    then show ?thesis
lp15@68361
   916
      by auto
lp15@68361
   917
  next
lp15@68361
   918
    assume [simp]: "b=0"
lp15@68361
   919
    then obtain i where "g i = 0"    
lp15@68361
   920
      using g by (auto simp: prod_defs)
lp15@68361
   921
    then have "f i = 0"
lp15@68361
   922
      using antisym le by force
lp15@68361
   923
    then have "a=0"
lp15@68361
   924
      using f by (auto simp: prod_defs LIMSEQ_prod_0 LIMSEQ_unique)
lp15@68361
   925
    then show ?thesis
lp15@68361
   926
      by auto
lp15@68361
   927
  qed
lp15@68361
   928
next
lp15@68361
   929
  case False
lp15@68361
   930
  then show ?thesis
lp15@68361
   931
    using assms
lp15@68361
   932
    unfolding has_prod_def raw_has_prod_def
lp15@68361
   933
    by (force simp: LIMSEQ_prod_0 intro!: LIMSEQ_le prod_mono)
lp15@68361
   934
qed
lp15@68361
   935
lp15@68361
   936
lemma prodinf_le: 
lp15@68361
   937
  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
   938
  shows "prodinf f \<le> prodinf g"
lp15@68361
   939
  using has_prod_le [OF assms] has_prod_unique f g  by blast
lp15@68361
   940
lp15@68136
   941
end
lp15@68361
   942
lp15@68361
   943
lp15@68361
   944
lemma prod_le_prodinf: 
lp15@68361
   945
  fixes f :: "nat \<Rightarrow> 'a::{linordered_idom,linorder_topology}"
lp15@68361
   946
  assumes "f has_prod a" "\<And>i. 0 \<le> f i" "\<And>i. i\<ge>n \<Longrightarrow> 1 \<le> f i"
lp15@68361
   947
  shows "prod f {..<n} \<le> prodinf f"
lp15@68361
   948
  by(rule has_prod_le[OF has_prod_If_finite_set]) (use assms has_prod_unique in auto)
lp15@68361
   949
lp15@68361
   950
lemma prodinf_nonneg:
lp15@68361
   951
  fixes f :: "nat \<Rightarrow> 'a::{linordered_idom,linorder_topology}"
lp15@68361
   952
  assumes "f has_prod a" "\<And>i. 1 \<le> f i" 
lp15@68361
   953
  shows "1 \<le> prodinf f"
lp15@68361
   954
  using prod_le_prodinf[of f a 0] assms
lp15@68361
   955
  by (metis order_trans prod_ge_1 zero_le_one)
lp15@68361
   956
lp15@68361
   957
lemma prodinf_le_const:
lp15@68361
   958
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   959
  assumes "convergent_prod f" "\<And>n. prod f {..<n} \<le> x" 
lp15@68361
   960
  shows "prodinf f \<le> x"
lp15@68361
   961
  by (metis lessThan_Suc_atMost assms convergent_prod_LIMSEQ LIMSEQ_le_const2)
lp15@68361
   962
lp15@68361
   963
lemma prodinf_eq_one_iff: 
lp15@68361
   964
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   965
  assumes f: "convergent_prod f" and ge1: "\<And>n. 1 \<le> f n"
lp15@68361
   966
  shows "prodinf f = 1 \<longleftrightarrow> (\<forall>n. f n = 1)"
lp15@68361
   967
proof
lp15@68361
   968
  assume "prodinf f = 1" 
lp15@68361
   969
  then have "(\<lambda>n. \<Prod>i<n. f i) \<longlonglongrightarrow> 1"
lp15@68361
   970
    using convergent_prod_LIMSEQ[of f] assms by (simp add: LIMSEQ_lessThan_iff_atMost)
lp15@68361
   971
  then have "\<And>i. (\<Prod>n\<in>{i}. f n) \<le> 1"
lp15@68361
   972
  proof (rule LIMSEQ_le_const)
lp15@68361
   973
    have "1 \<le> prod f n" for n
lp15@68361
   974
      by (simp add: ge1 prod_ge_1)
lp15@68361
   975
    have "prod f {..<n} = 1" for n
lp15@68361
   976
      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
   977
    then have "(\<Prod>n\<in>{i}. f n) \<le> prod f {..<n}" if "n \<ge> Suc i" for i n
lp15@68361
   978
      by (metis mult.left_neutral order_refl prod.cong prod.neutral_const prod_lessThan_Suc)
lp15@68361
   979
    then show "\<exists>N. \<forall>n\<ge>N. (\<Prod>n\<in>{i}. f n) \<le> prod f {..<n}" for i
lp15@68361
   980
      by blast      
lp15@68361
   981
  qed
lp15@68361
   982
  with ge1 show "\<forall>n. f n = 1"
lp15@68361
   983
    by (auto intro!: antisym)
lp15@68361
   984
qed (metis prodinf_zero fun_eq_iff)
lp15@68361
   985
lp15@68361
   986
lemma prodinf_pos_iff:
lp15@68361
   987
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   988
  assumes "convergent_prod f" "\<And>n. 1 \<le> f n"
lp15@68361
   989
  shows "1 < prodinf f \<longleftrightarrow> (\<exists>i. 1 < f i)"
lp15@68361
   990
  using prod_le_prodinf[of f 1] prodinf_eq_one_iff
lp15@68361
   991
  by (metis convergent_prod_has_prod assms less_le prodinf_nonneg)
lp15@68361
   992
lp15@68361
   993
lemma less_1_prodinf2:
lp15@68361
   994
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
   995
  assumes "convergent_prod f" "\<And>n. 1 \<le> f n" "1 < f i"
lp15@68361
   996
  shows "1 < prodinf f"
lp15@68361
   997
proof -
lp15@68361
   998
  have "1 < (\<Prod>n<Suc i. f n)"
lp15@68361
   999
    using assms  by (intro less_1_prod2[where i=i]) auto
lp15@68361
  1000
  also have "\<dots> \<le> prodinf f"
lp15@68361
  1001
    by (intro prod_le_prodinf) (use assms order_trans zero_le_one in \<open>blast+\<close>)
lp15@68361
  1002
  finally show ?thesis .
lp15@68361
  1003
qed
lp15@68361
  1004
lp15@68361
  1005
lemma less_1_prodinf:
lp15@68361
  1006
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1007
  shows "\<lbrakk>convergent_prod f; \<And>n. 1 < f n\<rbrakk> \<Longrightarrow> 1 < prodinf f"
lp15@68361
  1008
  by (intro less_1_prodinf2[where i=1]) (auto intro: less_imp_le)
lp15@68361
  1009
lp15@68361
  1010
lemma prodinf_nonzero:
lp15@68361
  1011
  fixes f :: "nat \<Rightarrow> 'a :: {idom,topological_semigroup_mult,t2_space}"
lp15@68361
  1012
  assumes "convergent_prod f" "\<And>i. f i \<noteq> 0"
lp15@68361
  1013
  shows "prodinf f \<noteq> 0"
lp15@68361
  1014
  by (metis assms convergent_prod_offset_0 has_prod_unique raw_has_prod_def has_prod_def)
lp15@68361
  1015
lp15@68361
  1016
lemma less_0_prodinf:
lp15@68361
  1017
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1018
  assumes f: "convergent_prod f" and 0: "\<And>i. f i > 0"
lp15@68361
  1019
  shows "0 < prodinf f"
lp15@68361
  1020
proof -
lp15@68361
  1021
  have "prodinf f \<noteq> 0"
lp15@68361
  1022
    by (metis assms less_irrefl prodinf_nonzero)
lp15@68361
  1023
  moreover have "0 < (\<Prod>n<i. f n)" for i
lp15@68361
  1024
    by (simp add: 0 prod_pos)
lp15@68361
  1025
  then have "prodinf f \<ge> 0"
lp15@68361
  1026
    using convergent_prod_LIMSEQ [OF f] LIMSEQ_prod_nonneg 0 less_le by blast
lp15@68361
  1027
  ultimately show ?thesis
lp15@68361
  1028
    by auto
lp15@68361
  1029
qed
lp15@68361
  1030
lp15@68361
  1031
lemma prod_less_prodinf2:
lp15@68361
  1032
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1033
  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
  1034
  shows "prod f {..<n} < prodinf f"
lp15@68361
  1035
proof -
lp15@68361
  1036
  have "prod f {..<n} \<le> prod f {..<i}"
lp15@68361
  1037
    by (rule prod_mono2) (use assms less_le in auto)
lp15@68361
  1038
  then have "prod f {..<n} < f i * prod f {..<i}"
lp15@68361
  1039
    using mult_less_le_imp_less[of 1 "f i" "prod f {..<n}" "prod f {..<i}"] assms
lp15@68361
  1040
    by (simp add: prod_pos)
lp15@68361
  1041
  moreover have "prod f {..<Suc i} \<le> prodinf f"
lp15@68361
  1042
    using prod_le_prodinf[of f _ "Suc i"]
lp15@68361
  1043
    by (meson "0" "1" Suc_leD convergent_prod_has_prod f \<open>n \<le> i\<close> le_trans less_eq_real_def)
lp15@68361
  1044
  ultimately show ?thesis
lp15@68361
  1045
    by (metis le_less_trans mult.commute not_le prod_lessThan_Suc)
lp15@68361
  1046
qed
lp15@68361
  1047
lp15@68361
  1048
lemma prod_less_prodinf:
lp15@68361
  1049
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1050
  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
  1051
  shows "prod f {..<n} < prodinf f"
lp15@68361
  1052
  by (meson "0" "1" f le_less prod_less_prodinf2)
lp15@68361
  1053
lp15@68361
  1054
lemma raw_has_prodI_bounded:
lp15@68361
  1055
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1056
  assumes pos: "\<And>n. 1 \<le> f n"
lp15@68361
  1057
    and le: "\<And>n. (\<Prod>i<n. f i) \<le> x"
lp15@68361
  1058
  shows "\<exists>p. raw_has_prod f 0 p"
lp15@68361
  1059
  unfolding raw_has_prod_def add_0_right
lp15@68361
  1060
proof (rule exI LIMSEQ_incseq_SUP conjI)+
lp15@68361
  1061
  show "bdd_above (range (\<lambda>n. prod f {..n}))"
lp15@68361
  1062
    by (metis bdd_aboveI2 le lessThan_Suc_atMost)
lp15@68361
  1063
  then have "(SUP i. prod f {..i}) > 0"
lp15@68361
  1064
    by (metis UNIV_I cSUP_upper less_le_trans pos prod_pos zero_less_one)
lp15@68361
  1065
  then show "(SUP i. prod f {..i}) \<noteq> 0"
lp15@68361
  1066
    by auto
lp15@68361
  1067
  show "incseq (\<lambda>n. prod f {..n})"
lp15@68361
  1068
    using pos order_trans [OF zero_le_one] by (auto simp: mono_def intro!: prod_mono2)
lp15@68361
  1069
qed
lp15@68361
  1070
lp15@68361
  1071
lemma convergent_prodI_nonneg_bounded:
lp15@68361
  1072
  fixes f :: "nat \<Rightarrow> real"
lp15@68361
  1073
  assumes "\<And>n. 1 \<le> f n" "\<And>n. (\<Prod>i<n. f i) \<le> x"
lp15@68361
  1074
  shows "convergent_prod f"
lp15@68361
  1075
  using convergent_prod_def raw_has_prodI_bounded [OF assms] by blast
lp15@68361
  1076
lp15@68361
  1077
eberlm@68651
  1078
subsection%unimportant \<open>Infinite products on topological spaces\<close>
lp15@68361
  1079
lp15@68361
  1080
context
lp15@68361
  1081
  fixes f g :: "nat \<Rightarrow> 'a::{t2_space,topological_semigroup_mult,idom}"
lp15@68361
  1082
begin
lp15@68361
  1083
lp15@68361
  1084
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
  1085
  by (force simp add: prod.distrib tendsto_mult raw_has_prod_def)
lp15@68361
  1086
lp15@68361
  1087
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
  1088
  by (simp add: raw_has_prod_mult has_prod_def)
lp15@68361
  1089
lp15@68361
  1090
end
lp15@68361
  1091
lp15@68361
  1092
lp15@68361
  1093
context
lp15@68361
  1094
  fixes f g :: "nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1095
begin
lp15@68361
  1096
lp15@68361
  1097
lemma has_prod_mult:
lp15@68361
  1098
  assumes f: "f has_prod a" and g: "g has_prod b"
lp15@68361
  1099
  shows "(\<lambda>n. f n * g n) has_prod (a * b)"
lp15@68361
  1100
  using f [unfolded has_prod_def]
lp15@68361
  1101
proof (elim disjE exE conjE)
lp15@68361
  1102
  assume f0: "raw_has_prod f 0 a"
lp15@68361
  1103
  show ?thesis
lp15@68361
  1104
    using g [unfolded has_prod_def]
lp15@68361
  1105
  proof (elim disjE exE conjE)
lp15@68361
  1106
    assume g0: "raw_has_prod g 0 b"
lp15@68361
  1107
    with f0 show ?thesis
lp15@68361
  1108
      by (force simp add: has_prod_def prod.distrib tendsto_mult raw_has_prod_def)
lp15@68361
  1109
  next
lp15@68361
  1110
    fix j q
lp15@68361
  1111
    assume "b = 0" and "g j = 0" and q: "raw_has_prod g (Suc j) q"
lp15@68361
  1112
    obtain p where p: "raw_has_prod f (Suc j) p"
lp15@68361
  1113
      using f0 raw_has_prod_ignore_initial_segment by blast
lp15@68361
  1114
    then have "Ex (raw_has_prod (\<lambda>n. f n * g n) (Suc j))"
lp15@68361
  1115
      using q raw_has_prod_mult by blast
lp15@68361
  1116
    then show ?thesis
lp15@68361
  1117
      using \<open>b = 0\<close> \<open>g j = 0\<close> has_prod_0_iff by fastforce
lp15@68361
  1118
  qed
lp15@68361
  1119
next
lp15@68361
  1120
  fix i p
lp15@68361
  1121
  assume "a = 0" and "f i = 0" and p: "raw_has_prod f (Suc i) p"
lp15@68361
  1122
  show ?thesis
lp15@68361
  1123
    using g [unfolded has_prod_def]
lp15@68361
  1124
  proof (elim disjE exE conjE)
lp15@68361
  1125
    assume g0: "raw_has_prod g 0 b"
lp15@68361
  1126
    obtain q where q: "raw_has_prod g (Suc i) q"
lp15@68361
  1127
      using g0 raw_has_prod_ignore_initial_segment by blast
lp15@68361
  1128
    then have "Ex (raw_has_prod (\<lambda>n. f n * g n) (Suc i))"
lp15@68361
  1129
      using raw_has_prod_mult p by blast
lp15@68361
  1130
    then show ?thesis
lp15@68361
  1131
      using \<open>a = 0\<close> \<open>f i = 0\<close> has_prod_0_iff by fastforce
lp15@68361
  1132
  next
lp15@68361
  1133
    fix j q
lp15@68361
  1134
    assume "b = 0" and "g j = 0" and q: "raw_has_prod g (Suc j) q"
lp15@68361
  1135
    obtain p' where p': "raw_has_prod f (Suc (max i j)) p'"
lp15@68361
  1136
      by (metis raw_has_prod_ignore_initial_segment max_Suc_Suc max_def p)
lp15@68361
  1137
    moreover
lp15@68361
  1138
    obtain q' where q': "raw_has_prod g (Suc (max i j)) q'"
lp15@68361
  1139
      by (metis raw_has_prod_ignore_initial_segment max.cobounded2 max_Suc_Suc q)
lp15@68361
  1140
    ultimately show ?thesis
lp15@68361
  1141
      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
  1142
  qed
lp15@68361
  1143
qed
lp15@68361
  1144
lp15@68361
  1145
lemma convergent_prod_mult:
lp15@68361
  1146
  assumes f: "convergent_prod f" and g: "convergent_prod g"
lp15@68361
  1147
  shows "convergent_prod (\<lambda>n. f n * g n)"
lp15@68361
  1148
  unfolding convergent_prod_def
lp15@68361
  1149
proof -
lp15@68361
  1150
  obtain M p N q where p: "raw_has_prod f M p" and q: "raw_has_prod g N q"
lp15@68361
  1151
    using convergent_prod_def f g by blast+
lp15@68361
  1152
  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
  1153
    by (meson raw_has_prod_ignore_initial_segment max.cobounded1 max.cobounded2)
lp15@68361
  1154
  then show "\<exists>M p. raw_has_prod (\<lambda>n. f n * g n) M p"
lp15@68361
  1155
    using raw_has_prod_mult by blast
lp15@68361
  1156
qed
lp15@68361
  1157
lp15@68361
  1158
lemma prodinf_mult: "convergent_prod f \<Longrightarrow> convergent_prod g \<Longrightarrow> prodinf f * prodinf g = (\<Prod>n. f n * g n)"
lp15@68361
  1159
  by (intro has_prod_unique has_prod_mult convergent_prod_has_prod)
lp15@68361
  1160
lp15@68361
  1161
end
lp15@68361
  1162
lp15@68361
  1163
context
lp15@68361
  1164
  fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1165
    and I :: "'i set"
lp15@68361
  1166
begin
lp15@68361
  1167
lp15@68361
  1168
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
  1169
  by (induct I rule: infinite_finite_induct) (auto intro!: has_prod_mult)
lp15@68361
  1170
lp15@68361
  1171
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
  1172
  using has_prod_unique[OF has_prod_prod, OF convergent_prod_has_prod] by simp
lp15@68361
  1173
lp15@68361
  1174
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
  1175
  using convergent_prod_has_prod_iff has_prod_prod prodinf_prod by force
lp15@68361
  1176
lp15@68361
  1177
end
lp15@68361
  1178
eberlm@68651
  1179
subsection%unimportant \<open>Infinite summability on real normed fields\<close>
lp15@68361
  1180
lp15@68361
  1181
context
lp15@68361
  1182
  fixes f :: "nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1183
begin
lp15@68361
  1184
lp15@68361
  1185
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
  1186
proof -
lp15@68361
  1187
  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
  1188
    by (subst LIMSEQ_Suc_iff) (simp add: raw_has_prod_def)
lp15@68361
  1189
  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
  1190
    by (simp add: ac_simps atMost_Suc_eq_insert_0 image_Suc_atMost prod_atLeast1_atMost_eq lessThan_Suc_atMost)
lp15@68361
  1191
  also have "\<dots> \<longleftrightarrow> raw_has_prod (\<lambda>n. f (Suc n)) M a \<and> f M \<noteq> 0"
lp15@68361
  1192
  proof safe
lp15@68361
  1193
    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
  1194
    with tendsto_divide[OF tends tendsto_const, of "f M"]    
lp15@68361
  1195
    show "raw_has_prod (\<lambda>n. f (Suc n)) M a"
lp15@68361
  1196
      by (simp add: raw_has_prod_def)
lp15@68361
  1197
  qed (auto intro: tendsto_mult_right simp:  raw_has_prod_def)
lp15@68361
  1198
  finally show ?thesis .
lp15@68361
  1199
qed
lp15@68361
  1200
lp15@68361
  1201
lemma has_prod_Suc_iff:
lp15@68361
  1202
  assumes "f 0 \<noteq> 0" shows "(\<lambda>n. f (Suc n)) has_prod a \<longleftrightarrow> f has_prod (a * f 0)"
lp15@68361
  1203
proof (cases "a = 0")
lp15@68361
  1204
  case True
lp15@68361
  1205
  then show ?thesis
lp15@68361
  1206
  proof (simp add: has_prod_def, safe)
lp15@68361
  1207
    fix i x
lp15@68361
  1208
    assume "f (Suc i) = 0" and "raw_has_prod (\<lambda>n. f (Suc n)) (Suc i) x"
lp15@68361
  1209
    then obtain y where "raw_has_prod f (Suc (Suc i)) y"
lp15@68361
  1210
      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
  1211
    then show "\<exists>i. f i = 0 \<and> Ex (raw_has_prod f (Suc i))"
lp15@68361
  1212
      using \<open>f (Suc i) = 0\<close> by blast
lp15@68361
  1213
  next
lp15@68361
  1214
    fix i x
lp15@68361
  1215
    assume "f i = 0" and x: "raw_has_prod f (Suc i) x"
lp15@68361
  1216
    then obtain j where j: "i = Suc j"
lp15@68361
  1217
      by (metis assms not0_implies_Suc)
lp15@68361
  1218
    moreover have "\<exists> y. raw_has_prod (\<lambda>n. f (Suc n)) i y"
lp15@68361
  1219
      using x by (auto simp: raw_has_prod_def)
lp15@68361
  1220
    then show "\<exists>i. f (Suc i) = 0 \<and> Ex (raw_has_prod (\<lambda>n. f (Suc n)) (Suc i))"
lp15@68361
  1221
      using \<open>f i = 0\<close> j by blast
lp15@68361
  1222
  qed
lp15@68361
  1223
next
lp15@68361
  1224
  case False
lp15@68361
  1225
  then show ?thesis
lp15@68361
  1226
    by (auto simp: has_prod_def raw_has_prod_Suc_iff assms)
lp15@68361
  1227
qed
lp15@68361
  1228
lp15@68361
  1229
lemma convergent_prod_Suc_iff:
lp15@68452
  1230
  shows "convergent_prod (\<lambda>n. f (Suc n)) = convergent_prod f"
lp15@68361
  1231
proof
lp15@68361
  1232
  assume "convergent_prod f"
lp15@68452
  1233
  then obtain M L where M_nz:"\<forall>n\<ge>M. f n \<noteq> 0" and 
lp15@68452
  1234
        M_L:"(\<lambda>n. \<Prod>i\<le>n. f (i + M)) \<longlonglongrightarrow> L" and "L \<noteq> 0" 
lp15@68452
  1235
    unfolding convergent_prod_altdef by auto
lp15@68452
  1236
  have "(\<lambda>n. \<Prod>i\<le>n. f (Suc (i + M))) \<longlonglongrightarrow> L / f M"
lp15@68452
  1237
  proof -
lp15@68452
  1238
    have "(\<lambda>n. \<Prod>i\<in>{0..Suc n}. f (i + M)) \<longlonglongrightarrow> L"
lp15@68452
  1239
      using M_L 
lp15@68452
  1240
      apply (subst (asm) LIMSEQ_Suc_iff[symmetric]) 
lp15@68452
  1241
      using atLeast0AtMost by auto
lp15@68452
  1242
    then have "(\<lambda>n. f M * (\<Prod>i\<in>{0..n}. f (Suc (i + M)))) \<longlonglongrightarrow> L"
lp15@68452
  1243
      apply (subst (asm) prod.atLeast0_atMost_Suc_shift)
lp15@68452
  1244
      by simp
lp15@68452
  1245
    then have "(\<lambda>n. (\<Prod>i\<in>{0..n}. f (Suc (i + M)))) \<longlonglongrightarrow> L/f M"
lp15@68452
  1246
      apply (drule_tac tendsto_divide)
lp15@68452
  1247
      using M_nz[rule_format,of M,simplified] by auto
lp15@68452
  1248
    then show ?thesis unfolding atLeast0AtMost .
lp15@68452
  1249
  qed
lp15@68452
  1250
  then show "convergent_prod (\<lambda>n. f (Suc n))" unfolding convergent_prod_altdef
lp15@68452
  1251
    apply (rule_tac exI[where x=M])
lp15@68452
  1252
    apply (rule_tac exI[where x="L/f M"])
lp15@68452
  1253
    using M_nz \<open>L\<noteq>0\<close> by auto
lp15@68361
  1254
next
lp15@68361
  1255
  assume "convergent_prod (\<lambda>n. f (Suc n))"
lp15@68452
  1256
  then obtain M where "\<exists>L. (\<forall>n\<ge>M. f (Suc n) \<noteq> 0) \<and> (\<lambda>n. \<Prod>i\<le>n. f (Suc (i + M))) \<longlonglongrightarrow> L \<and> L \<noteq> 0"
lp15@68452
  1257
    unfolding convergent_prod_altdef by auto
lp15@68452
  1258
  then show "convergent_prod f" unfolding convergent_prod_altdef
lp15@68452
  1259
    apply (rule_tac exI[where x="Suc M"])
lp15@68452
  1260
    using Suc_le_D by auto
lp15@68361
  1261
qed
lp15@68361
  1262
lp15@68361
  1263
lemma raw_has_prod_inverse: 
lp15@68361
  1264
  assumes "raw_has_prod f M a" shows "raw_has_prod (\<lambda>n. inverse (f n)) M (inverse a)"
lp15@68361
  1265
  using assms unfolding raw_has_prod_def by (auto dest: tendsto_inverse simp: prod_inversef [symmetric])
lp15@68361
  1266
lp15@68361
  1267
lemma has_prod_inverse: 
lp15@68361
  1268
  assumes "f has_prod a" shows "(\<lambda>n. inverse (f n)) has_prod (inverse a)"
lp15@68361
  1269
using assms raw_has_prod_inverse unfolding has_prod_def by auto 
lp15@68361
  1270
lp15@68361
  1271
lemma convergent_prod_inverse:
lp15@68361
  1272
  assumes "convergent_prod f" 
lp15@68361
  1273
  shows "convergent_prod (\<lambda>n. inverse (f n))"
lp15@68361
  1274
  using assms unfolding convergent_prod_def  by (blast intro: raw_has_prod_inverse elim: )
lp15@68361
  1275
lp15@68361
  1276
end
lp15@68361
  1277
lp15@68424
  1278
context 
lp15@68361
  1279
  fixes f :: "nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1280
begin
lp15@68361
  1281
lp15@68361
  1282
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
  1283
  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
  1284
lp15@68361
  1285
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
  1286
  unfolding divide_inverse by (intro has_prod_inverse has_prod_mult)
lp15@68361
  1287
lp15@68361
  1288
lemma convergent_prod_divide:
lp15@68361
  1289
  assumes f: "convergent_prod f" and g: "convergent_prod g"
lp15@68361
  1290
  shows "convergent_prod (\<lambda>n. f n / g n)"
lp15@68361
  1291
  using f g has_prod_divide has_prod_iff by blast
lp15@68361
  1292
lp15@68361
  1293
lemma prodinf_divide: "convergent_prod f \<Longrightarrow> convergent_prod g \<Longrightarrow> prodinf f / prodinf g = (\<Prod>n. f n / g n)"
lp15@68361
  1294
  by (intro has_prod_unique has_prod_divide convergent_prod_has_prod)
lp15@68361
  1295
lp15@68361
  1296
lemma prodinf_inverse: "convergent_prod f \<Longrightarrow> (\<Prod>n. inverse (f n)) = inverse (\<Prod>n. f n)"
lp15@68361
  1297
  by (intro has_prod_unique [symmetric] has_prod_inverse convergent_prod_has_prod)
lp15@68361
  1298
lp15@68452
  1299
lemma has_prod_Suc_imp: 
lp15@68452
  1300
  assumes "(\<lambda>n. f (Suc n)) has_prod a"
lp15@68452
  1301
  shows "f has_prod (a * f 0)"
lp15@68452
  1302
proof -
lp15@68452
  1303
  have "f has_prod (a * f 0)" when "raw_has_prod (\<lambda>n. f (Suc n)) 0 a" 
lp15@68452
  1304
    apply (cases "f 0=0")
lp15@68452
  1305
    using that unfolding has_prod_def raw_has_prod_Suc 
lp15@68452
  1306
    by (auto simp add: raw_has_prod_Suc_iff)
lp15@68452
  1307
  moreover have "f has_prod (a * f 0)" when 
lp15@68452
  1308
    "(\<exists>i q. a = 0 \<and> f (Suc i) = 0 \<and> raw_has_prod (\<lambda>n. f (Suc n)) (Suc i) q)" 
lp15@68452
  1309
  proof -
lp15@68452
  1310
    from that 
lp15@68452
  1311
    obtain i q where "a = 0" "f (Suc i) = 0" "raw_has_prod (\<lambda>n. f (Suc n)) (Suc i) q"
lp15@68452
  1312
      by auto
lp15@68452
  1313
    then show ?thesis unfolding has_prod_def 
lp15@68452
  1314
      by (auto intro!:exI[where x="Suc i"] simp:raw_has_prod_Suc)
lp15@68452
  1315
  qed
lp15@68452
  1316
  ultimately show "f has_prod (a * f 0)" using assms unfolding has_prod_def by auto
lp15@68452
  1317
qed
lp15@68452
  1318
lp15@68361
  1319
lemma has_prod_iff_shift: 
lp15@68361
  1320
  assumes "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1321
  shows "(\<lambda>i. f (i + n)) has_prod a \<longleftrightarrow> f has_prod (a * (\<Prod>i<n. f i))"
lp15@68361
  1322
  using assms
lp15@68361
  1323
proof (induct n arbitrary: a)
lp15@68361
  1324
  case 0
lp15@68361
  1325
  then show ?case by simp
lp15@68361
  1326
next
lp15@68361
  1327
  case (Suc n)
lp15@68361
  1328
  then have "(\<lambda>i. f (Suc i + n)) has_prod a \<longleftrightarrow> (\<lambda>i. f (i + n)) has_prod (a * f n)"
lp15@68361
  1329
    by (subst has_prod_Suc_iff) auto
lp15@68361
  1330
  with Suc show ?case
lp15@68361
  1331
    by (simp add: ac_simps)
lp15@68361
  1332
qed
lp15@68361
  1333
eberlm@68651
  1334
corollary%unimportant has_prod_iff_shift':
lp15@68361
  1335
  assumes "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1336
  shows "(\<lambda>i. f (i + n)) has_prod (a / (\<Prod>i<n. f i)) \<longleftrightarrow> f has_prod a"
lp15@68361
  1337
  by (simp add: assms has_prod_iff_shift)
lp15@68361
  1338
lp15@68361
  1339
lemma has_prod_one_iff_shift:
lp15@68361
  1340
  assumes "\<And>i. i < n \<Longrightarrow> f i = 1"
lp15@68361
  1341
  shows "(\<lambda>i. f (i+n)) has_prod a \<longleftrightarrow> (\<lambda>i. f i) has_prod a"
lp15@68361
  1342
  by (simp add: assms has_prod_iff_shift)
lp15@68361
  1343
lp15@68361
  1344
lemma convergent_prod_iff_shift:
lp15@68361
  1345
  shows "convergent_prod (\<lambda>i. f (i + n)) \<longleftrightarrow> convergent_prod f"
lp15@68361
  1346
  apply safe
lp15@68361
  1347
  using convergent_prod_offset apply blast
lp15@68361
  1348
  using convergent_prod_ignore_initial_segment convergent_prod_def by blast
lp15@68361
  1349
lp15@68361
  1350
lemma has_prod_split_initial_segment:
lp15@68361
  1351
  assumes "f has_prod a" "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1352
  shows "(\<lambda>i. f (i + n)) has_prod (a / (\<Prod>i<n. f i))"
lp15@68361
  1353
  using assms has_prod_iff_shift' by blast
lp15@68361
  1354
lp15@68361
  1355
lemma prodinf_divide_initial_segment:
lp15@68361
  1356
  assumes "convergent_prod f" "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1357
  shows "(\<Prod>i. f (i + n)) = (\<Prod>i. f i) / (\<Prod>i<n. f i)"
lp15@68361
  1358
  by (rule has_prod_unique[symmetric]) (auto simp: assms has_prod_iff_shift)
lp15@68361
  1359
lp15@68361
  1360
lemma prodinf_split_initial_segment:
lp15@68361
  1361
  assumes "convergent_prod f" "\<And>i. i < n \<Longrightarrow> f i \<noteq> 0"
lp15@68361
  1362
  shows "prodinf f = (\<Prod>i. f (i + n)) * (\<Prod>i<n. f i)"
lp15@68361
  1363
  by (auto simp add: assms prodinf_divide_initial_segment)
lp15@68361
  1364
lp15@68361
  1365
lemma prodinf_split_head:
lp15@68361
  1366
  assumes "convergent_prod f" "f 0 \<noteq> 0"
lp15@68361
  1367
  shows "(\<Prod>n. f (Suc n)) = prodinf f / f 0"
lp15@68361
  1368
  using prodinf_split_initial_segment[of 1] assms by simp
lp15@68361
  1369
lp15@68361
  1370
end
lp15@68361
  1371
lp15@68424
  1372
context 
lp15@68361
  1373
  fixes f :: "nat \<Rightarrow> 'a::real_normed_field"
lp15@68361
  1374
begin
lp15@68361
  1375
lp15@68361
  1376
lemma convergent_prod_inverse_iff: "convergent_prod (\<lambda>n. inverse (f n)) \<longleftrightarrow> convergent_prod f"
lp15@68361
  1377
  by (auto dest: convergent_prod_inverse)
lp15@68361
  1378
lp15@68361
  1379
lemma convergent_prod_const_iff:
lp15@68361
  1380
  fixes c :: "'a :: {real_normed_field}"
lp15@68361
  1381
  shows "convergent_prod (\<lambda>_. c) \<longleftrightarrow> c = 1"
lp15@68361
  1382
proof
lp15@68361
  1383
  assume "convergent_prod (\<lambda>_. c)"
lp15@68361
  1384
  then show "c = 1"
lp15@68361
  1385
    using convergent_prod_imp_LIMSEQ LIMSEQ_unique by blast 
lp15@68361
  1386
next
lp15@68361
  1387
  assume "c = 1"
lp15@68361
  1388
  then show "convergent_prod (\<lambda>_. c)"
lp15@68361
  1389
    by auto
lp15@68361
  1390
qed
lp15@68361
  1391
lp15@68361
  1392
lemma has_prod_power: "f has_prod a \<Longrightarrow> (\<lambda>i. f i ^ n) has_prod (a ^ n)"
lp15@68361
  1393
  by (induction n) (auto simp: has_prod_mult)
lp15@68361
  1394
lp15@68361
  1395
lemma convergent_prod_power: "convergent_prod f \<Longrightarrow> convergent_prod (\<lambda>i. f i ^ n)"
lp15@68361
  1396
  by (induction n) (auto simp: convergent_prod_mult)
lp15@68361
  1397
lp15@68361
  1398
lemma prodinf_power: "convergent_prod f \<Longrightarrow> prodinf (\<lambda>i. f i ^ n) = prodinf f ^ n"
lp15@68361
  1399
  by (metis has_prod_unique convergent_prod_imp_has_prod has_prod_power)
lp15@68361
  1400
lp15@68361
  1401
end
lp15@68361
  1402
lp15@68424
  1403
lp15@68424
  1404
subsection\<open>Exponentials and logarithms\<close>
lp15@68424
  1405
lp15@68424
  1406
context 
lp15@68424
  1407
  fixes f :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
lp15@68424
  1408
begin
lp15@68424
  1409
lp15@68424
  1410
lemma sums_imp_has_prod_exp: 
lp15@68424
  1411
  assumes "f sums s"
lp15@68424
  1412
  shows "raw_has_prod (\<lambda>i. exp (f i)) 0 (exp s)"
lp15@68424
  1413
  using assms continuous_on_exp [of UNIV "\<lambda>x::'a. x"]
lp15@68424
  1414
  using continuous_on_tendsto_compose [of UNIV exp "(\<lambda>n. sum f {..n})" s]
lp15@68424
  1415
  by (simp add: prod_defs sums_def_le exp_sum)
lp15@68424
  1416
lp15@68424
  1417
lemma convergent_prod_exp: 
lp15@68424
  1418
  assumes "summable f"
lp15@68424
  1419
  shows "convergent_prod (\<lambda>i. exp (f i))"
lp15@68424
  1420
  using sums_imp_has_prod_exp assms unfolding summable_def convergent_prod_def  by blast
lp15@68424
  1421
lp15@68424
  1422
lemma prodinf_exp: 
lp15@68424
  1423
  assumes "summable f"
lp15@68424
  1424
  shows "prodinf (\<lambda>i. exp (f i)) = exp (suminf f)"
lp15@68424
  1425
proof -
lp15@68424
  1426
  have "f sums suminf f"
lp15@68424
  1427
    using assms by blast
lp15@68424
  1428
  then have "(\<lambda>i. exp (f i)) has_prod exp (suminf f)"
lp15@68424
  1429
    by (simp add: has_prod_def sums_imp_has_prod_exp)
lp15@68424
  1430
  then show ?thesis
lp15@68424
  1431
    by (rule has_prod_unique [symmetric])
lp15@68424
  1432
qed
lp15@68424
  1433
lp15@68361
  1434
end
lp15@68424
  1435
eberlm@68651
  1436
theorem convergent_prod_iff_summable_real:
lp15@68585
  1437
  fixes a :: "nat \<Rightarrow> real"
lp15@68585
  1438
  assumes "\<And>n. a n > 0"
lp15@68585
  1439
  shows "convergent_prod (\<lambda>k. 1 + a k) \<longleftrightarrow> summable a" (is "?lhs = ?rhs")
lp15@68585
  1440
proof
lp15@68585
  1441
  assume ?lhs
lp15@68585
  1442
  then obtain p where "raw_has_prod (\<lambda>k. 1 + a k) 0 p"
lp15@68585
  1443
    by (metis assms add_less_same_cancel2 convergent_prod_offset_0 not_one_less_zero)
lp15@68585
  1444
  then have to_p: "(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> p"
lp15@68585
  1445
    by (auto simp: raw_has_prod_def)
lp15@68585
  1446
  moreover have le: "(\<Sum>k\<le>n. a k) \<le> (\<Prod>k\<le>n. 1 + a k)" for n
lp15@68585
  1447
    by (rule sum_le_prod) (use assms less_le in force)
lp15@68585
  1448
  have "(\<Prod>k\<le>n. 1 + a k) \<le> p" for n
lp15@68585
  1449
  proof (rule incseq_le [OF _ to_p])
lp15@68585
  1450
    show "incseq (\<lambda>n. \<Prod>k\<le>n. 1 + a k)"
lp15@68585
  1451
      using assms by (auto simp: mono_def order.strict_implies_order intro!: prod_mono2)
lp15@68585
  1452
  qed
lp15@68585
  1453
  with le have "(\<Sum>k\<le>n. a k) \<le> p" for n
lp15@68585
  1454
    by (metis order_trans)
lp15@68585
  1455
  with assms bounded_imp_summable show ?rhs
lp15@68585
  1456
    by (metis not_less order.asym)
lp15@68585
  1457
next
lp15@68585
  1458
  assume R: ?rhs
lp15@68585
  1459
  have "(\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)" for n
lp15@68585
  1460
  proof -
lp15@68585
  1461
    have "(\<Prod>k\<le>n. 1 + a k) \<le> exp (\<Sum>k\<le>n. a k)" for n
lp15@68585
  1462
      by (rule prod_le_exp_sum) (use assms less_le in force)
lp15@68585
  1463
    moreover have "exp (\<Sum>k\<le>n. a k) \<le> exp (suminf a)" for n
lp15@68585
  1464
      unfolding exp_le_cancel_iff
lp15@68585
  1465
      by (meson sum_le_suminf R assms finite_atMost less_eq_real_def)
lp15@68585
  1466
    ultimately show ?thesis
lp15@68585
  1467
      by (meson order_trans)
lp15@68585
  1468
  qed
lp15@68585
  1469
  then obtain L where L: "(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L"
lp15@68585
  1470
    by (metis assms bounded_imp_convergent_prod convergent_prod_iff_nz_lim le_add_same_cancel1 le_add_same_cancel2 less_le not_le zero_le_one)
lp15@68585
  1471
  moreover have "L \<noteq> 0"
lp15@68585
  1472
  proof
lp15@68585
  1473
    assume "L = 0"
lp15@68585
  1474
    with L have "(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> 0"
lp15@68585
  1475
      by simp
lp15@68585
  1476
    moreover have "(\<Prod>k\<le>n. 1 + a k) > 1" for n
lp15@68585
  1477
      by (simp add: assms less_1_prod)
lp15@68585
  1478
    ultimately show False
lp15@68585
  1479
      by (meson Lim_bounded2 not_one_le_zero less_imp_le)
lp15@68585
  1480
  qed
lp15@68585
  1481
  ultimately show ?lhs
lp15@68585
  1482
    using assms convergent_prod_iff_nz_lim
lp15@68585
  1483
    by (metis add_less_same_cancel1 less_le not_le zero_less_one)
lp15@68585
  1484
qed
lp15@68585
  1485
lp15@68452
  1486
lemma exp_suminf_prodinf_real:
lp15@68452
  1487
  fixes f :: "nat \<Rightarrow> real"
lp15@68452
  1488
  assumes ge0:"\<And>n. f n \<ge> 0" and ac: "abs_convergent_prod (\<lambda>n. exp (f n))"
lp15@68452
  1489
  shows "prodinf (\<lambda>i. exp (f i)) = exp (suminf f)"
lp15@68452
  1490
proof -
lp15@68517
  1491
  have "summable f"
lp15@68452
  1492
    using ac unfolding abs_convergent_prod_conv_summable
lp15@68452
  1493
  proof (elim summable_comparison_test')
lp15@68452
  1494
    fix n
lp15@68517
  1495
    have "\<bar>f n\<bar> = f n"
lp15@68517
  1496
      by (simp add: ge0)
lp15@68517
  1497
    also have "\<dots> \<le> exp (f n) - 1"
lp15@68517
  1498
      by (metis diff_diff_add exp_ge_add_one_self ge_iff_diff_ge_0)
lp15@68517
  1499
    finally show "norm (f n) \<le> norm (exp (f n) - 1)"
lp15@68517
  1500
      by simp
lp15@68452
  1501
  qed
lp15@68452
  1502
  then show ?thesis
lp15@68452
  1503
    by (simp add: prodinf_exp)
lp15@68452
  1504
qed
lp15@68452
  1505
lp15@68424
  1506
lemma has_prod_imp_sums_ln_real: 
lp15@68424
  1507
  fixes f :: "nat \<Rightarrow> real"
lp15@68424
  1508
  assumes "raw_has_prod f 0 p" and 0: "\<And>x. f x > 0"
lp15@68424
  1509
  shows "(\<lambda>i. ln (f i)) sums (ln p)"
lp15@68424
  1510
proof -
lp15@68424
  1511
  have "p > 0"
lp15@68424
  1512
    using assms unfolding prod_defs by (metis LIMSEQ_prod_nonneg less_eq_real_def)
lp15@68424
  1513
  then show ?thesis
lp15@68424
  1514
  using assms continuous_on_ln [of "{0<..}" "\<lambda>x. x"]
lp15@68424
  1515
  using continuous_on_tendsto_compose [of "{0<..}" ln "(\<lambda>n. prod f {..n})" p]
lp15@68424
  1516
  by (auto simp: prod_defs sums_def_le ln_prod order_tendstoD)
lp15@68424
  1517
qed
lp15@68424
  1518
lp15@68424
  1519
lemma summable_ln_real: 
lp15@68424
  1520
  fixes f :: "nat \<Rightarrow> real"
lp15@68424
  1521
  assumes f: "convergent_prod f" and 0: "\<And>x. f x > 0"
lp15@68424
  1522
  shows "summable (\<lambda>i. ln (f i))"
lp15@68424
  1523
proof -
lp15@68424
  1524
  obtain M p where "raw_has_prod f M p"
lp15@68424
  1525
    using f convergent_prod_def by blast
lp15@68424
  1526
  then consider i where "i<M" "f i = 0" | p where "raw_has_prod f 0 p"
lp15@68424
  1527
    using raw_has_prod_cases by blast
lp15@68424
  1528
  then show ?thesis
lp15@68424
  1529
  proof cases
lp15@68424
  1530
    case 1
lp15@68424
  1531
    with 0 show ?thesis
lp15@68424
  1532
      by (metis less_irrefl)
lp15@68424
  1533
  next
lp15@68424
  1534
    case 2
lp15@68424
  1535
    then show ?thesis
lp15@68424
  1536
      using "0" has_prod_imp_sums_ln_real summable_def by blast
lp15@68424
  1537
  qed
lp15@68424
  1538
qed
lp15@68424
  1539
lp15@68424
  1540
lemma suminf_ln_real: 
lp15@68424
  1541
  fixes f :: "nat \<Rightarrow> real"
lp15@68424
  1542
  assumes f: "convergent_prod f" and 0: "\<And>x. f x > 0"
lp15@68424
  1543
  shows "suminf (\<lambda>i. ln (f i)) = ln (prodinf f)"
lp15@68424
  1544
proof -
lp15@68424
  1545
  have "f has_prod prodinf f"
lp15@68424
  1546
    by (simp add: f has_prod_iff)
lp15@68424
  1547
  then have "raw_has_prod f 0 (prodinf f)"
lp15@68424
  1548
    by (metis "0" has_prod_def less_irrefl)
lp15@68424
  1549
  then have "(\<lambda>i. ln (f i)) sums ln (prodinf f)"
lp15@68424
  1550
    using "0" has_prod_imp_sums_ln_real by blast
lp15@68424
  1551
  then show ?thesis
lp15@68424
  1552
    by (rule sums_unique [symmetric])
lp15@68424
  1553
qed
lp15@68424
  1554
lp15@68424
  1555
lemma prodinf_exp_real: 
lp15@68424
  1556
  fixes f :: "nat \<Rightarrow> real"
lp15@68424
  1557
  assumes f: "convergent_prod f" and 0: "\<And>x. f x > 0"
lp15@68424
  1558
  shows "prodinf f = exp (suminf (\<lambda>i. ln (f i)))"
lp15@68424
  1559
  by (simp add: "0" f less_0_prodinf suminf_ln_real)
lp15@68424
  1560
lp15@68424
  1561
eberlm@68651
  1562
theorem Ln_prodinf_complex:
lp15@68585
  1563
  fixes z :: "nat \<Rightarrow> complex"
lp15@68585
  1564
  assumes z: "\<And>j. z j \<noteq> 0" and \<xi>: "\<xi> \<noteq> 0"
lp15@68585
  1565
  shows "((\<lambda>n. \<Prod>j\<le>n. z j) \<longlonglongrightarrow> \<xi>) \<longleftrightarrow> (\<exists>k. (\<lambda>n. (\<Sum>j\<le>n. Ln (z j))) \<longlonglongrightarrow> Ln \<xi> + of_int k * (of_real(2*pi) * \<i>))" (is "?lhs = ?rhs")
lp15@68585
  1566
proof
lp15@68585
  1567
  assume L: ?lhs
lp15@68585
  1568
  have pnz: "(\<Prod>j\<le>n. z j) \<noteq> 0" for n
lp15@68585
  1569
    using z by auto
lp15@68585
  1570
  define \<Theta> where "\<Theta> \<equiv> Arg \<xi> + 2*pi"
lp15@68585
  1571
  then have "\<Theta> > pi"
lp15@68585
  1572
    using Arg_def mpi_less_Im_Ln by fastforce
lp15@68585
  1573
  have \<xi>_eq: "\<xi> = cmod \<xi> * exp (\<i> * \<Theta>)"
lp15@68585
  1574
    using Arg_def Arg_eq \<xi> unfolding \<Theta>_def by (simp add: algebra_simps exp_add)
lp15@68585
  1575
  define \<theta> where "\<theta> \<equiv> \<lambda>n. THE t. is_Arg (\<Prod>j\<le>n. z j) t \<and> t \<in> {\<Theta>-pi<..\<Theta>+pi}"
lp15@68585
  1576
  have uniq: "\<exists>!s. is_Arg (\<Prod>j\<le>n. z j) s \<and> s \<in> {\<Theta>-pi<..\<Theta>+pi}" for n
lp15@68585
  1577
    using Argument_exists_unique [OF pnz] by metis
lp15@68585
  1578
  have \<theta>: "is_Arg (\<Prod>j\<le>n. z j) (\<theta> n)" and \<theta>_interval: "\<theta> n \<in> {\<Theta>-pi<..\<Theta>+pi}" for n
lp15@68585
  1579
    unfolding \<theta>_def
lp15@68585
  1580
    using theI' [OF uniq] by metis+
lp15@68585
  1581
  have \<theta>_pos: "\<And>j. \<theta> j > 0"
lp15@68585
  1582
    using \<theta>_interval \<open>\<Theta> > pi\<close> by simp (meson diff_gt_0_iff_gt less_trans)
lp15@68585
  1583
  have "(\<Prod>j\<le>n. z j) = cmod (\<Prod>j\<le>n. z j) * exp (\<i> * \<theta> n)" for n
lp15@68585
  1584
    using \<theta> by (auto simp: is_Arg_def)
lp15@68585
  1585
  then have eq: "(\<lambda>n. \<Prod>j\<le>n. z j) = (\<lambda>n. cmod (\<Prod>j\<le>n. z j) * exp (\<i> * \<theta> n))"
lp15@68585
  1586
    by simp
lp15@68585
  1587
  then have "(\<lambda>n. (cmod (\<Prod>j\<le>n. z j)) * exp (\<i> * (\<theta> n))) \<longlonglongrightarrow> \<xi>"
lp15@68585
  1588
    using L by force
lp15@68585
  1589
  then obtain k where k: "(\<lambda>j. \<theta> j - of_int (k j) * (2 * pi)) \<longlonglongrightarrow> \<Theta>"
lp15@68585
  1590
    using L by (subst (asm) \<xi>_eq) (auto simp add: eq z \<xi> polar_convergence)
lp15@68585
  1591
  moreover have "\<forall>\<^sub>F n in sequentially. k n = 0"
lp15@68585
  1592
  proof -
lp15@68585
  1593
    have *: "kj = 0" if "dist (vj - real_of_int kj * 2) V < 1" "vj \<in> {V - 1<..V + 1}" for kj vj V
lp15@68585
  1594
      using that  by (auto simp: dist_norm)
lp15@68585
  1595
    have "\<forall>\<^sub>F j in sequentially. dist (\<theta> j - of_int (k j) * (2 * pi)) \<Theta> < pi"
lp15@68585
  1596
      using tendstoD [OF k] pi_gt_zero by blast
lp15@68585
  1597
    then show ?thesis
lp15@68585
  1598
    proof (rule eventually_mono)
lp15@68585
  1599
      fix j
lp15@68585
  1600
      assume d: "dist (\<theta> j - real_of_int (k j) * (2 * pi)) \<Theta> < pi"
lp15@68585
  1601
      show "k j = 0"
lp15@68585
  1602
        by (rule * [of "\<theta> j/pi" _ "\<Theta>/pi"])
lp15@68585
  1603
           (use \<theta>_interval [of j] d in \<open>simp_all add: divide_simps dist_norm\<close>)
lp15@68585
  1604
    qed
lp15@68585
  1605
  qed
lp15@68585
  1606
  ultimately have \<theta>to\<Theta>: "\<theta> \<longlonglongrightarrow> \<Theta>"
lp15@68585
  1607
    apply (simp only: tendsto_def)
lp15@68585
  1608
    apply (erule all_forward imp_forward asm_rl)+
lp15@68585
  1609
    apply (drule (1) eventually_conj)
lp15@68585
  1610
    apply (auto elim: eventually_mono)
lp15@68585
  1611
    done
lp15@68585
  1612
  then have to0: "(\<lambda>n. \<bar>\<theta> (Suc n) - \<theta> n\<bar>) \<longlonglongrightarrow> 0"
lp15@68585
  1613
    by (metis (full_types) diff_self filterlim_sequentially_Suc tendsto_diff tendsto_rabs_zero)
lp15@68585
  1614
  have "\<exists>k. Im (\<Sum>j\<le>n. Ln (z j)) - of_int k * (2*pi) = \<theta> n" for n
lp15@68585
  1615
  proof (rule is_Arg_exp_diff_2pi)
lp15@68585
  1616
    show "is_Arg (exp (\<Sum>j\<le>n. Ln (z j))) (\<theta> n)"
lp15@68585
  1617
      using pnz \<theta> by (simp add: is_Arg_def exp_sum prod_norm)
lp15@68585
  1618
  qed
lp15@68585
  1619
  then have "\<exists>k. (\<Sum>j\<le>n. Im (Ln (z j))) = \<theta> n + of_int k * (2*pi)" for n
lp15@68585
  1620
    by (simp add: algebra_simps)
lp15@68585
  1621
  then obtain k where k: "\<And>n. (\<Sum>j\<le>n. Im (Ln (z j))) = \<theta> n + of_int (k n) * (2*pi)"
lp15@68585
  1622
    by metis
lp15@68585
  1623
  obtain K where "\<forall>\<^sub>F n in sequentially. k n = K"
lp15@68585
  1624
  proof -
lp15@68585
  1625
    have k_le: "(2*pi) * \<bar>k (Suc n) - k n\<bar> \<le> \<bar>\<theta> (Suc n) - \<theta> n\<bar> + \<bar>Im (Ln (z (Suc n)))\<bar>" for n
lp15@68585
  1626
    proof -
lp15@68585
  1627
      have "(\<Sum>j\<le>Suc n. Im (Ln (z j))) - (\<Sum>j\<le>n. Im (Ln (z j))) = Im (Ln (z (Suc n)))"
lp15@68585
  1628
        by simp
lp15@68585
  1629
      then show ?thesis
lp15@68585
  1630
        using k [of "Suc n"] k [of n] by (auto simp: abs_if algebra_simps)
lp15@68585
  1631
    qed
lp15@68585
  1632
    have "z \<longlonglongrightarrow> 1"
lp15@68585
  1633
      using L \<xi> convergent_prod_iff_nz_lim z by (blast intro: convergent_prod_imp_LIMSEQ)
lp15@68585
  1634
    with z have "(\<lambda>n. Ln (z n)) \<longlonglongrightarrow> Ln 1"
lp15@68585
  1635
      using isCont_tendsto_compose [OF continuous_at_Ln] nonpos_Reals_one_I by blast
lp15@68585
  1636
    then have "(\<lambda>n. Ln (z n)) \<longlonglongrightarrow> 0"
lp15@68585
  1637
      by simp
lp15@68585
  1638
    then have "(\<lambda>n. \<bar>Im (Ln (z (Suc n)))\<bar>) \<longlonglongrightarrow> 0"
lp15@68585
  1639
      by (metis LIMSEQ_unique \<open>z \<longlonglongrightarrow> 1\<close> continuous_at_Ln filterlim_sequentially_Suc isCont_tendsto_compose nonpos_Reals_one_I tendsto_Im tendsto_rabs_zero_iff zero_complex.simps(2))
lp15@68585
  1640
    then have "\<forall>\<^sub>F n in sequentially. \<bar>Im (Ln (z (Suc n)))\<bar> < 1"
lp15@68585
  1641
      by (simp add: order_tendsto_iff)
lp15@68585
  1642
    moreover have "\<forall>\<^sub>F n in sequentially. \<bar>\<theta> (Suc n) - \<theta> n\<bar> < 1"
lp15@68585
  1643
      using to0 by (simp add: order_tendsto_iff)
lp15@68585
  1644
    ultimately have "\<forall>\<^sub>F n in sequentially. (2*pi) * \<bar>k (Suc n) - k n\<bar> < 1 + 1" 
lp15@68585
  1645
    proof (rule eventually_elim2) 
lp15@68585
  1646
      fix n 
lp15@68585
  1647
      assume "\<bar>Im (Ln (z (Suc n)))\<bar> < 1" and "\<bar>\<theta> (Suc n) - \<theta> n\<bar> < 1"
lp15@68585
  1648
      with k_le [of n] show "2 * pi * real_of_int \<bar>k (Suc n) - k n\<bar> < 1 + 1"
lp15@68585
  1649
        by linarith
lp15@68585
  1650
    qed
lp15@68585
  1651
    then have "\<forall>\<^sub>F n in sequentially. real_of_int\<bar>k (Suc n) - k n\<bar> < 1" 
lp15@68585
  1652
    proof (rule eventually_mono)
lp15@68585
  1653
      fix n :: "nat"
lp15@68585
  1654
      assume "2 * pi * \<bar>k (Suc n) - k n\<bar> < 1 + 1"
lp15@68585
  1655
      then have "\<bar>k (Suc n) - k n\<bar> < 2 / (2*pi)"
lp15@68585
  1656
        by (simp add: field_simps)
lp15@68585
  1657
      also have "... < 1"
lp15@68585
  1658
        using pi_ge_two by auto
lp15@68585
  1659
      finally show "real_of_int \<bar>k (Suc n) - k n\<bar> < 1" .
lp15@68585
  1660
    qed
lp15@68585
  1661
  then obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> \<bar>k (Suc n) - k n\<bar> = 0"
lp15@68585
  1662
    using eventually_sequentially less_irrefl of_int_abs by fastforce
lp15@68585
  1663
  have "k (N+i) = k N" for i
lp15@68585
  1664
  proof (induction i)
lp15@68585
  1665
    case (Suc i)
lp15@68585
  1666
    with N [of "N+i"] show ?case
lp15@68585
  1667
      by auto
lp15@68585
  1668
  qed simp
lp15@68585
  1669
  then have "\<And>n. n\<ge>N \<Longrightarrow> k n = k N"
lp15@68585
  1670
    using le_Suc_ex by auto
lp15@68585
  1671
  then show ?thesis
lp15@68585
  1672
    by (force simp add: eventually_sequentially intro: that)
lp15@68585
  1673
  qed
lp15@68585
  1674
  with \<theta>to\<Theta> have "(\<lambda>n. (\<Sum>j\<le>n. Im (Ln (z j)))) \<longlonglongrightarrow> \<Theta> + of_int K * (2*pi)"
lp15@68585
  1675
    by (simp add: k tendsto_add tendsto_mult Lim_eventually)
lp15@68585
  1676
  moreover have "(\<lambda>n. (\<Sum>k\<le>n. Re (Ln (z k)))) \<longlonglongrightarrow> Re (Ln \<xi>)"
lp15@68585
  1677
    using assms continuous_imp_tendsto [OF isCont_ln tendsto_norm [OF L]]
lp15@68585
  1678
    by (simp add: o_def flip: prod_norm ln_prod)
lp15@68585
  1679
  ultimately show ?rhs
lp15@68585
  1680
    by (rule_tac x="K+1" in exI) (auto simp: tendsto_complex_iff \<Theta>_def Arg_def assms algebra_simps)
lp15@68585
  1681
next
lp15@68585
  1682
  assume ?rhs
lp15@68585
  1683
  then obtain r where r: "(\<lambda>n. (\<Sum>k\<le>n. Ln (z k))) \<longlonglongrightarrow> Ln \<xi> + of_int r * (of_real(2*pi) * \<i>)" ..
lp15@68585
  1684
  have "(\<lambda>n. exp (\<Sum>k\<le>n. Ln (z k))) \<longlonglongrightarrow> \<xi>"
lp15@68585
  1685
    using assms continuous_imp_tendsto [OF isCont_exp r] exp_integer_2pi [of r]
lp15@68585
  1686
    by (simp add: o_def exp_add algebra_simps)
lp15@68585
  1687
  moreover have "exp (\<Sum>k\<le>n. Ln (z k)) = (\<Prod>k\<le>n. z k)" for n
lp15@68585
  1688
    by (simp add: exp_sum add_eq_0_iff assms)
lp15@68585
  1689
  ultimately show ?lhs
lp15@68585
  1690
    by auto
lp15@68585
  1691
qed
lp15@68585
  1692
lp15@68585
  1693
text\<open>Prop 17.2 of Bak and Newman, Complex Analysis, p.242\<close>
lp15@68585
  1694
proposition convergent_prod_iff_summable_complex:
lp15@68585
  1695
  fixes z :: "nat \<Rightarrow> complex"
lp15@68585
  1696
  assumes "\<And>k. z k \<noteq> 0"
lp15@68585
  1697
  shows "convergent_prod (\<lambda>k. z k) \<longleftrightarrow> summable (\<lambda>k. Ln (z k))" (is "?lhs = ?rhs")
lp15@68585
  1698
proof
lp15@68585
  1699
  assume ?lhs
lp15@68585
  1700
  then obtain p where p: "(\<lambda>n. \<Prod>k\<le>n. z k) \<longlonglongrightarrow> p" and "p \<noteq> 0"
lp15@68585
  1701
    using convergent_prod_LIMSEQ prodinf_nonzero add_eq_0_iff assms by fastforce
lp15@68585
  1702
  then show ?rhs
lp15@68585
  1703
    using Ln_prodinf_complex assms
lp15@68585
  1704
    by (auto simp: prodinf_nonzero summable_def sums_def_le)
lp15@68585
  1705
next
lp15@68585
  1706
  assume R: ?rhs
lp15@68585
  1707
  have "(\<Prod>k\<le>n. z k) = exp (\<Sum>k\<le>n. Ln (z k))" for n
lp15@68585
  1708
    by (simp add: exp_sum add_eq_0_iff assms)
lp15@68585
  1709
  then have "(\<lambda>n. \<Prod>k\<le>n. z k) \<longlonglongrightarrow> exp (suminf (\<lambda>k. Ln (z k)))"
lp15@68585
  1710
    using continuous_imp_tendsto [OF isCont_exp summable_LIMSEQ' [OF R]] by (simp add: o_def)
lp15@68585
  1711
  then show ?lhs
lp15@68585
  1712
    by (subst convergent_prod_iff_convergent) (auto simp: convergent_def tendsto_Lim assms add_eq_0_iff)
lp15@68585
  1713
qed
lp15@68585
  1714
lp15@68586
  1715
text\<open>Prop 17.3 of Bak and Newman, Complex Analysis\<close>
lp15@68586
  1716
proposition summable_imp_convergent_prod_complex:
lp15@68586
  1717
  fixes z :: "nat \<Rightarrow> complex"
lp15@68586
  1718
  assumes z: "summable (\<lambda>k. norm (z k))" and non0: "\<And>k. z k \<noteq> -1"
lp15@68586
  1719
  shows "convergent_prod (\<lambda>k. 1 + z k)" 
lp15@68586
  1720
proof -
lp15@68586
  1721
  note if_cong [cong] power_Suc [simp del]
lp15@68586
  1722
  obtain N where N: "\<And>k. k\<ge>N \<Longrightarrow> norm (z k) < 1/2"
lp15@68586
  1723
    using summable_LIMSEQ_zero [OF z]
lp15@68586
  1724
    by (metis diff_zero dist_norm half_gt_zero_iff less_numeral_extra(1) lim_sequentially tendsto_norm_zero_iff)
lp15@68586
  1725
  have "norm (Ln (1 + z k)) \<le> 2 * norm (z k)" if "k \<ge> N" for k
lp15@68586
  1726
  proof (cases "z k = 0")
lp15@68586
  1727
    case False
lp15@68586
  1728
    let ?f = "\<lambda>i. cmod ((- 1) ^ i * z k ^ i / of_nat (Suc i))"
lp15@68586
  1729
    have normf: "norm (?f n) \<le> (1 / 2) ^ n" for n
lp15@68586
  1730
    proof -
lp15@68586
  1731
      have "norm (?f n) = cmod (z k) ^ n / cmod (1 + of_nat n)"
lp15@68586
  1732
        by (auto simp: norm_divide norm_mult norm_power)
lp15@68586
  1733
      also have "\<dots> \<le> cmod (z k) ^ n"
lp15@68586
  1734
        by (auto simp: divide_simps mult_le_cancel_left1 in_Reals_norm)
lp15@68586
  1735
      also have "\<dots> \<le> (1 / 2) ^ n"
lp15@68586
  1736
        using N [OF that] by (simp add: power_mono)
lp15@68586
  1737
      finally show "norm (?f n) \<le> (1 / 2) ^ n" .
lp15@68586
  1738
    qed
lp15@68586
  1739
    have summablef: "summable ?f"
lp15@68586
  1740
      by (intro normf summable_comparison_test' [OF summable_geometric [of "1/2"]]) auto
lp15@68586
  1741
    have "(\<lambda>n. (- 1) ^ Suc n / of_nat n * z k ^ n) sums Ln (1 + z k)"
lp15@68586
  1742
      using Ln_series [of "z k"] N that by fastforce
lp15@68586
  1743
    then have *: "(\<lambda>i. z k * (((- 1) ^ i * z k ^ i) / (Suc i))) sums Ln (1 + z k)"
lp15@68586
  1744
      using sums_split_initial_segment [where n= 1]  by (force simp: power_Suc mult_ac)
lp15@68586
  1745
    then have "norm (Ln (1 + z k)) = norm (suminf (\<lambda>i. z k * (((- 1) ^ i * z k ^ i) / (Suc i))))"
lp15@68586
  1746
      using sums_unique by force
lp15@68586
  1747
    also have "\<dots> = norm (z k * suminf (\<lambda>i. ((- 1) ^ i * z k ^ i) / (Suc i)))"
lp15@68586
  1748
      apply (subst suminf_mult)
lp15@68586
  1749
      using * False
lp15@68586
  1750
      by (auto simp: sums_summable intro: summable_mult_D [of "z k"])
lp15@68586
  1751
    also have "\<dots> = norm (z k) * norm (suminf (\<lambda>i. ((- 1) ^ i * z k ^ i) / (Suc i)))"
lp15@68586
  1752
      by (simp add: norm_mult)
lp15@68586
  1753
    also have "\<dots> \<le> norm (z k) * suminf (\<lambda>i. norm (((- 1) ^ i * z k ^ i) / (Suc i)))"
lp15@68586
  1754
      by (intro mult_left_mono summable_norm summablef) auto
lp15@68586
  1755
    also have "\<dots> \<le> norm (z k) * suminf (\<lambda>i. (1/2) ^ i)"
lp15@68586
  1756
      by (intro mult_left_mono suminf_le) (use summable_geometric [of "1/2"] summablef normf in auto)
lp15@68586
  1757
    also have "\<dots> \<le> norm (z k) * 2"
lp15@68586
  1758
      using suminf_geometric [of "1/2::real"] by simp
lp15@68586
  1759
    finally show ?thesis
lp15@68586
  1760
      by (simp add: mult_ac)
lp15@68586
  1761
  qed simp
lp15@68586
  1762
  then have "summable (\<lambda>k. Ln (1 + z k))"
lp15@68586
  1763
    by (metis summable_comparison_test summable_mult z)
lp15@68586
  1764
  with non0 show ?thesis
lp15@68586
  1765
    by (simp add: add_eq_0_iff convergent_prod_iff_summable_complex)
lp15@68586
  1766
qed
lp15@68586
  1767
lp15@68616
  1768
lemma summable_Ln_complex:
lp15@68616
  1769
  fixes z :: "nat \<Rightarrow> complex"
lp15@68616
  1770
  assumes "convergent_prod z" "\<And>k. z k \<noteq> 0"
lp15@68616
  1771
  shows "summable (\<lambda>k. Ln (z k))"
lp15@68616
  1772
  using convergent_prod_def assms convergent_prod_iff_summable_complex by blast
lp15@68616
  1773
lp15@68586
  1774
eberlm@68651
  1775
subsection%unimportant \<open>Embeddings from the reals into some complete real normed field\<close>
lp15@68424
  1776
lp15@68426
  1777
lemma tendsto_eq_of_real_lim:
lp15@68424
  1778
  assumes "(\<lambda>n. of_real (f n) :: 'a::{complete_space,real_normed_field}) \<longlonglongrightarrow> q"
lp15@68424
  1779
  shows "q = of_real (lim f)"
lp15@68424
  1780
proof -
lp15@68424
  1781
  have "convergent (\<lambda>n. of_real (f n) :: 'a)"
lp15@68424
  1782
    using assms convergent_def by blast 
lp15@68424
  1783
  then have "convergent f"
lp15@68424
  1784
    unfolding convergent_def
lp15@68424
  1785
    by (simp add: convergent_eq_Cauchy Cauchy_def)
lp15@68424
  1786
  then show ?thesis
lp15@68424
  1787
    by (metis LIMSEQ_unique assms convergentD sequentially_bot tendsto_Lim tendsto_of_real)
lp15@68424
  1788
qed
lp15@68424
  1789
lp15@68426
  1790
lemma tendsto_eq_of_real:
lp15@68424
  1791
  assumes "(\<lambda>n. of_real (f n) :: 'a::{complete_space,real_normed_field}) \<longlonglongrightarrow> q"
lp15@68424
  1792
  obtains r where "q = of_real r"
lp15@68426
  1793
  using tendsto_eq_of_real_lim assms by blast
lp15@68424
  1794
lp15@68424
  1795
lemma has_prod_of_real_iff:
lp15@68424
  1796
  "(\<lambda>n. of_real (f n) :: 'a::{complete_space,real_normed_field}) has_prod of_real c \<longleftrightarrow> f has_prod c"
lp15@68424
  1797
  (is "?lhs = ?rhs")
lp15@68424
  1798
proof
lp15@68424
  1799
  assume ?lhs
lp15@68424
  1800
  then show ?rhs
lp15@68424
  1801
    apply (auto simp: prod_defs LIMSEQ_prod_0 tendsto_of_real_iff simp flip: of_real_prod)
lp15@68426
  1802
    using tendsto_eq_of_real
lp15@68424
  1803
    by (metis of_real_0 tendsto_of_real_iff)
lp15@68424
  1804
next
lp15@68424
  1805
  assume ?rhs
lp15@68424
  1806
  with tendsto_of_real_iff show ?lhs
lp15@68424
  1807
    by (fastforce simp: prod_defs simp flip: of_real_prod)
lp15@68424
  1808
qed
lp15@68424
  1809
lp15@68424
  1810
end