src/HOL/Multivariate_Analysis/Complex_Analysis_Basics.thy
author paulson <lp15@cam.ac.uk>
Wed Mar 19 14:54:45 2014 +0000 (2014-03-19)
changeset 56215 fcf90317383d
child 56217 dc429a5b13c4
permissions -rw-r--r--
New complex analysis material
lp15@56215
     1
(*  Author: John Harrison, Marco Maggesi, Graziano Gentili, Gianni Ciolli, Valentina Bruno
lp15@56215
     2
    Ported from "hol_light/Multivariate/canal.ml" by L C Paulson (2014)
lp15@56215
     3
*)
lp15@56215
     4
lp15@56215
     5
header {* Complex Analysis Basics *}
lp15@56215
     6
lp15@56215
     7
theory Complex_Analysis_Basics
lp15@56215
     8
imports  "~~/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space"
lp15@56215
     9
lp15@56215
    10
begin
lp15@56215
    11
lp15@56215
    12
subsection {*Complex number lemmas *}
lp15@56215
    13
lp15@56215
    14
lemma abs_sqrt_wlog:
lp15@56215
    15
  fixes x::"'a::linordered_idom"
lp15@56215
    16
  assumes "!!x::'a. x\<ge>0 \<Longrightarrow> P x (x\<^sup>2)" shows "P \<bar>x\<bar> (x\<^sup>2)"
lp15@56215
    17
by (metis abs_ge_zero assms power2_abs)
lp15@56215
    18
lp15@56215
    19
lemma complex_abs_le_norm: "abs(Re z) + abs(Im z) \<le> sqrt(2) * norm z"
lp15@56215
    20
proof (cases z)
lp15@56215
    21
  case (Complex x y)
lp15@56215
    22
  show ?thesis
lp15@56215
    23
    apply (rule power2_le_imp_le)
lp15@56215
    24
    apply (auto simp: real_sqrt_mult [symmetric] Complex)
lp15@56215
    25
    apply (rule abs_sqrt_wlog [where x=x])
lp15@56215
    26
    apply (rule abs_sqrt_wlog [where x=y])
lp15@56215
    27
    apply (simp add: power2_sum add_commute sum_squares_bound)
lp15@56215
    28
    done
lp15@56215
    29
qed
lp15@56215
    30
lp15@56215
    31
lemma continuous_Re: "continuous_on UNIV Re"
lp15@56215
    32
  by (metis (poly_guards_query) bounded_linear.continuous_on bounded_linear_Re 
lp15@56215
    33
            continuous_on_cong continuous_on_id)
lp15@56215
    34
lp15@56215
    35
lemma continuous_Im: "continuous_on UNIV Im"
lp15@56215
    36
  by (metis (poly_guards_query) bounded_linear.continuous_on bounded_linear_Im 
lp15@56215
    37
            continuous_on_cong continuous_on_id)
lp15@56215
    38
lp15@56215
    39
lemma open_halfspace_Re_lt: "open {z. Re(z) < b}"
lp15@56215
    40
proof -
lp15@56215
    41
  have "{z. Re(z) < b} = Re -`{..<b}"
lp15@56215
    42
    by blast
lp15@56215
    43
  then show ?thesis
lp15@56215
    44
    by (auto simp: continuous_Re continuous_imp_open_vimage [of UNIV])
lp15@56215
    45
qed
lp15@56215
    46
lp15@56215
    47
lemma open_halfspace_Re_gt: "open {z. Re(z) > b}"
lp15@56215
    48
proof -
lp15@56215
    49
  have "{z. Re(z) > b} = Re -`{b<..}"
lp15@56215
    50
    by blast
lp15@56215
    51
  then show ?thesis
lp15@56215
    52
    by (auto simp: continuous_Re continuous_imp_open_vimage [of UNIV])
lp15@56215
    53
qed
lp15@56215
    54
lp15@56215
    55
lemma closed_halfspace_Re_ge: "closed {z. Re(z) \<ge> b}"
lp15@56215
    56
proof -
lp15@56215
    57
  have "{z. Re(z) \<ge> b} = - {z. Re(z) < b}"
lp15@56215
    58
    by auto
lp15@56215
    59
  then show ?thesis
lp15@56215
    60
    by (simp add: closed_def open_halfspace_Re_lt)
lp15@56215
    61
qed
lp15@56215
    62
lp15@56215
    63
lemma closed_halfspace_Re_le: "closed {z. Re(z) \<le> b}"
lp15@56215
    64
proof -
lp15@56215
    65
  have "{z. Re(z) \<le> b} = - {z. Re(z) > b}"
lp15@56215
    66
    by auto
lp15@56215
    67
  then show ?thesis
lp15@56215
    68
    by (simp add: closed_def open_halfspace_Re_gt)
lp15@56215
    69
qed
lp15@56215
    70
lp15@56215
    71
lemma closed_halfspace_Re_eq: "closed {z. Re(z) = b}"
lp15@56215
    72
proof -
lp15@56215
    73
  have "{z. Re(z) = b} = {z. Re(z) \<le> b} \<inter> {z. Re(z) \<ge> b}"
lp15@56215
    74
    by auto
lp15@56215
    75
  then show ?thesis
lp15@56215
    76
    by (auto simp: closed_Int closed_halfspace_Re_le closed_halfspace_Re_ge)
lp15@56215
    77
qed
lp15@56215
    78
lp15@56215
    79
lemma open_halfspace_Im_lt: "open {z. Im(z) < b}"
lp15@56215
    80
proof -
lp15@56215
    81
  have "{z. Im(z) < b} = Im -`{..<b}"
lp15@56215
    82
    by blast
lp15@56215
    83
  then show ?thesis
lp15@56215
    84
    by (auto simp: continuous_Im continuous_imp_open_vimage [of UNIV])
lp15@56215
    85
qed
lp15@56215
    86
lp15@56215
    87
lemma open_halfspace_Im_gt: "open {z. Im(z) > b}"
lp15@56215
    88
proof -
lp15@56215
    89
  have "{z. Im(z) > b} = Im -`{b<..}"
lp15@56215
    90
    by blast
lp15@56215
    91
  then show ?thesis
lp15@56215
    92
    by (auto simp: continuous_Im continuous_imp_open_vimage [of UNIV])
lp15@56215
    93
qed
lp15@56215
    94
lp15@56215
    95
lemma closed_halfspace_Im_ge: "closed {z. Im(z) \<ge> b}"
lp15@56215
    96
proof -
lp15@56215
    97
  have "{z. Im(z) \<ge> b} = - {z. Im(z) < b}"
lp15@56215
    98
    by auto
lp15@56215
    99
  then show ?thesis
lp15@56215
   100
    by (simp add: closed_def open_halfspace_Im_lt)
lp15@56215
   101
qed
lp15@56215
   102
lp15@56215
   103
lemma closed_halfspace_Im_le: "closed {z. Im(z) \<le> b}"
lp15@56215
   104
proof -
lp15@56215
   105
  have "{z. Im(z) \<le> b} = - {z. Im(z) > b}"
lp15@56215
   106
    by auto
lp15@56215
   107
  then show ?thesis
lp15@56215
   108
    by (simp add: closed_def open_halfspace_Im_gt)
lp15@56215
   109
qed
lp15@56215
   110
lp15@56215
   111
lemma closed_halfspace_Im_eq: "closed {z. Im(z) = b}"
lp15@56215
   112
proof -
lp15@56215
   113
  have "{z. Im(z) = b} = {z. Im(z) \<le> b} \<inter> {z. Im(z) \<ge> b}"
lp15@56215
   114
    by auto
lp15@56215
   115
  then show ?thesis
lp15@56215
   116
    by (auto simp: closed_Int closed_halfspace_Im_le closed_halfspace_Im_ge)
lp15@56215
   117
qed
lp15@56215
   118
lp15@56215
   119
lemma complex_is_Real_iff: "z \<in> \<real> \<longleftrightarrow> Im z = 0"
lp15@56215
   120
  by (metis Complex_in_Reals Im_complex_of_real Reals_cases complex_surj)
lp15@56215
   121
lp15@56215
   122
lemma closed_complex_Reals: "closed (Reals :: complex set)"
lp15@56215
   123
proof -
lp15@56215
   124
  have "-(Reals :: complex set) = {z. Im(z) < 0} \<union> {z. 0 < Im(z)}"
lp15@56215
   125
    by (auto simp: complex_is_Real_iff)
lp15@56215
   126
  then show ?thesis
lp15@56215
   127
    by (metis closed_def open_Un open_halfspace_Im_gt open_halfspace_Im_lt)
lp15@56215
   128
qed
lp15@56215
   129
lp15@56215
   130
lp15@56215
   131
lemma linear_times:
lp15@56215
   132
  fixes c::"'a::{real_algebra,real_vector}" shows "linear (\<lambda>x. c * x)"
lp15@56215
   133
  by (auto simp: linearI distrib_left)
lp15@56215
   134
lp15@56215
   135
lemma bilinear_times:
lp15@56215
   136
  fixes c::"'a::{real_algebra,real_vector}" shows "bilinear (\<lambda>x y::'a. x*y)"
lp15@56215
   137
  unfolding bilinear_def
lp15@56215
   138
  by (auto simp: distrib_left distrib_right intro!: linearI)
lp15@56215
   139
lp15@56215
   140
lemma linear_cnj: "linear cnj"
lp15@56215
   141
  by (auto simp: linearI cnj_def)
lp15@56215
   142
lp15@56215
   143
lemma tendsto_mult_left:
lp15@56215
   144
  fixes c::"'a::real_normed_algebra" 
lp15@56215
   145
  shows "(f ---> l) F \<Longrightarrow> ((\<lambda>x. c * (f x)) ---> c * l) F"
lp15@56215
   146
by (rule tendsto_mult [OF tendsto_const])
lp15@56215
   147
lp15@56215
   148
lemma tendsto_mult_right:
lp15@56215
   149
  fixes c::"'a::real_normed_algebra" 
lp15@56215
   150
  shows "(f ---> l) F \<Longrightarrow> ((\<lambda>x. (f x) * c) ---> l * c) F"
lp15@56215
   151
by (rule tendsto_mult [OF _ tendsto_const])
lp15@56215
   152
lp15@56215
   153
lemma tendsto_Re_upper:
lp15@56215
   154
  assumes "~ (trivial_limit F)" 
lp15@56215
   155
          "(f ---> l) F" 
lp15@56215
   156
          "eventually (\<lambda>x. Re(f x) \<le> b) F"
lp15@56215
   157
    shows  "Re(l) \<le> b"
lp15@56215
   158
  by (metis assms tendsto_le [OF _ tendsto_const]  tendsto_Re)
lp15@56215
   159
lp15@56215
   160
lemma tendsto_Re_lower:
lp15@56215
   161
  assumes "~ (trivial_limit F)" 
lp15@56215
   162
          "(f ---> l) F" 
lp15@56215
   163
          "eventually (\<lambda>x. b \<le> Re(f x)) F"
lp15@56215
   164
    shows  "b \<le> Re(l)"
lp15@56215
   165
  by (metis assms tendsto_le [OF _ _ tendsto_const]  tendsto_Re)
lp15@56215
   166
lp15@56215
   167
lemma tendsto_Im_upper:
lp15@56215
   168
  assumes "~ (trivial_limit F)" 
lp15@56215
   169
          "(f ---> l) F" 
lp15@56215
   170
          "eventually (\<lambda>x. Im(f x) \<le> b) F"
lp15@56215
   171
    shows  "Im(l) \<le> b"
lp15@56215
   172
  by (metis assms tendsto_le [OF _ tendsto_const]  tendsto_Im)
lp15@56215
   173
lp15@56215
   174
lemma tendsto_Im_lower:
lp15@56215
   175
  assumes "~ (trivial_limit F)" 
lp15@56215
   176
          "(f ---> l) F" 
lp15@56215
   177
          "eventually (\<lambda>x. b \<le> Im(f x)) F"
lp15@56215
   178
    shows  "b \<le> Im(l)"
lp15@56215
   179
  by (metis assms tendsto_le [OF _ _ tendsto_const]  tendsto_Im)
lp15@56215
   180
lp15@56215
   181
subsection{*General lemmas*}
lp15@56215
   182
lp15@56215
   183
lemma continuous_mult_left:
lp15@56215
   184
  fixes c::"'a::real_normed_algebra" 
lp15@56215
   185
  shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. c * f x)"
lp15@56215
   186
by (rule continuous_mult [OF continuous_const])
lp15@56215
   187
lp15@56215
   188
lemma continuous_mult_right:
lp15@56215
   189
  fixes c::"'a::real_normed_algebra" 
lp15@56215
   190
  shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. f x * c)"
lp15@56215
   191
by (rule continuous_mult [OF _ continuous_const])
lp15@56215
   192
lp15@56215
   193
lemma continuous_on_mult_left:
lp15@56215
   194
  fixes c::"'a::real_normed_algebra" 
lp15@56215
   195
  shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. c * f x)"
lp15@56215
   196
by (rule continuous_on_mult [OF continuous_on_const])
lp15@56215
   197
lp15@56215
   198
lemma continuous_on_mult_right:
lp15@56215
   199
  fixes c::"'a::real_normed_algebra" 
lp15@56215
   200
  shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. f x * c)"
lp15@56215
   201
by (rule continuous_on_mult [OF _ continuous_on_const])
lp15@56215
   202
lp15@56215
   203
lemma uniformly_continuous_on_cmul_right [continuous_on_intros]:
lp15@56215
   204
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
lp15@56215
   205
  assumes "uniformly_continuous_on s f"
lp15@56215
   206
  shows "uniformly_continuous_on s (\<lambda>x. f x * c)"
lp15@56215
   207
proof (cases "c=0")
lp15@56215
   208
  case True then show ?thesis
lp15@56215
   209
    by (simp add: uniformly_continuous_on_const)
lp15@56215
   210
next
lp15@56215
   211
  case False show ?thesis
lp15@56215
   212
    apply (rule bounded_linear.uniformly_continuous_on)
lp15@56215
   213
    apply (metis bounded_linear_ident)
lp15@56215
   214
    using assms
lp15@56215
   215
    apply (auto simp: uniformly_continuous_on_def dist_norm)
lp15@56215
   216
    apply (drule_tac x = "e / norm c" in spec, auto)
lp15@56215
   217
    apply (metis divide_pos_pos zero_less_norm_iff False)
lp15@56215
   218
    apply (rule_tac x=d in exI, auto)
lp15@56215
   219
    apply (drule_tac x = x in bspec, assumption)
lp15@56215
   220
    apply (drule_tac x = "x'" in bspec)
lp15@56215
   221
    apply (auto simp: False less_divide_eq)
lp15@56215
   222
    by (metis dual_order.strict_trans2 left_diff_distrib norm_mult_ineq)
lp15@56215
   223
qed
lp15@56215
   224
lp15@56215
   225
lemma uniformly_continuous_on_cmul_left[continuous_on_intros]:
lp15@56215
   226
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
lp15@56215
   227
  assumes "uniformly_continuous_on s f"
lp15@56215
   228
    shows "uniformly_continuous_on s (\<lambda>x. c * f x)"
lp15@56215
   229
by (metis assms bounded_linear.uniformly_continuous_on bounded_linear_mult_right)
lp15@56215
   230
lp15@56215
   231
lemma continuous_within_norm_id [continuous_intros]: "continuous (at x within S) norm"
lp15@56215
   232
  by (rule continuous_norm [OF continuous_ident])
lp15@56215
   233
lp15@56215
   234
lemma continuous_on_norm_id [continuous_intros]: "continuous_on S norm"
lp15@56215
   235
  by (metis continuous_on_eq continuous_on_id continuous_on_norm)
lp15@56215
   236
lp15@56215
   237
lp15@56215
   238
subsection{*DERIV stuff*}
lp15@56215
   239
lp15@56215
   240
(*move some premises to a sensible order. Use more \<And> symbols.*)
lp15@56215
   241
lp15@56215
   242
lemma DERIV_continuous_on: "\<lbrakk>\<And>x. x \<in> s \<Longrightarrow> DERIV f x :> D\<rbrakk> \<Longrightarrow> continuous_on s f"
lp15@56215
   243
  by (metis DERIV_continuous continuous_at_imp_continuous_on)
lp15@56215
   244
lp15@56215
   245
lemma DERIV_subset: 
lp15@56215
   246
  "(f has_field_derivative f') (at x within s) \<Longrightarrow> t \<subseteq> s 
lp15@56215
   247
   \<Longrightarrow> (f has_field_derivative f') (at x within t)"
lp15@56215
   248
  by (simp add: has_field_derivative_def has_derivative_within_subset)
lp15@56215
   249
lp15@56215
   250
lemma lambda_zero: "(\<lambda>h::'a::mult_zero. 0) = op * 0"
lp15@56215
   251
  by auto
lp15@56215
   252
lp15@56215
   253
lemma lambda_one: "(\<lambda>x::'a::monoid_mult. x) = op * 1"
lp15@56215
   254
  by auto
lp15@56215
   255
lp15@56215
   256
lemma has_derivative_zero_constant:
lp15@56215
   257
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
lp15@56215
   258
  assumes "convex s"
lp15@56215
   259
      and d0: "\<And>x. x\<in>s \<Longrightarrow> (f has_derivative (\<lambda>h. 0)) (at x within s)"
lp15@56215
   260
    shows "\<exists>c. \<forall>x\<in>s. f x = c"
lp15@56215
   261
proof (cases "s={}")
lp15@56215
   262
  case False
lp15@56215
   263
  then obtain x where "x \<in> s"
lp15@56215
   264
    by auto
lp15@56215
   265
  have d0': "\<forall>x\<in>s. (f has_derivative (\<lambda>h. 0)) (at x within s)"
lp15@56215
   266
    by (metis d0)
lp15@56215
   267
  have "\<And>y. y \<in> s \<Longrightarrow> f x = f y"
lp15@56215
   268
  proof -
lp15@56215
   269
    case goal1
lp15@56215
   270
    then show ?case
lp15@56215
   271
      using differentiable_bound[OF assms(1) d0', of 0 x y] and `x \<in> s`
lp15@56215
   272
      unfolding onorm_const
lp15@56215
   273
      by auto
lp15@56215
   274
  qed
lp15@56215
   275
  then show ?thesis 
lp15@56215
   276
    by metis
lp15@56215
   277
next
lp15@56215
   278
  case True
lp15@56215
   279
  then show ?thesis by auto
lp15@56215
   280
qed
lp15@56215
   281
lp15@56215
   282
lemma has_derivative_zero_unique:
lp15@56215
   283
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
lp15@56215
   284
  assumes "convex s"
lp15@56215
   285
      and "\<And>x. x\<in>s \<Longrightarrow> (f has_derivative (\<lambda>h. 0)) (at x within s)"
lp15@56215
   286
      and "a \<in> s"
lp15@56215
   287
      and "x \<in> s"
lp15@56215
   288
    shows "f x = f a"
lp15@56215
   289
  using assms
lp15@56215
   290
  by (metis has_derivative_zero_constant)
lp15@56215
   291
lp15@56215
   292
lemma has_derivative_zero_connected_constant:
lp15@56215
   293
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
lp15@56215
   294
  assumes "connected s"
lp15@56215
   295
      and "open s"
lp15@56215
   296
      and "finite k"
lp15@56215
   297
      and "continuous_on s f"
lp15@56215
   298
      and "\<forall>x\<in>(s - k). (f has_derivative (\<lambda>h. 0)) (at x within s)"
lp15@56215
   299
    obtains c where "\<And>x. x \<in> s \<Longrightarrow> f(x) = c"
lp15@56215
   300
proof (cases "s = {}")
lp15@56215
   301
  case True
lp15@56215
   302
  then show ?thesis
lp15@56215
   303
by (metis empty_iff that)
lp15@56215
   304
next
lp15@56215
   305
  case False
lp15@56215
   306
  then obtain c where "c \<in> s"
lp15@56215
   307
    by (metis equals0I)
lp15@56215
   308
  then show ?thesis
lp15@56215
   309
    by (metis has_derivative_zero_unique_strong_connected assms that)
lp15@56215
   310
qed
lp15@56215
   311
lp15@56215
   312
lemma DERIV_zero_connected_constant:
lp15@56215
   313
  fixes f :: "'a::{real_normed_field,euclidean_space} \<Rightarrow> 'a"
lp15@56215
   314
  assumes "connected s"
lp15@56215
   315
      and "open s"
lp15@56215
   316
      and "finite k"
lp15@56215
   317
      and "continuous_on s f"
lp15@56215
   318
      and "\<forall>x\<in>(s - k). DERIV f x :> 0"
lp15@56215
   319
    obtains c where "\<And>x. x \<in> s \<Longrightarrow> f(x) = c"
lp15@56215
   320
using has_derivative_zero_connected_constant [OF assms(1-4)] assms
lp15@56215
   321
by (metis DERIV_const Derivative.has_derivative_const Diff_iff at_within_open 
lp15@56215
   322
          frechet_derivative_at has_field_derivative_def)
lp15@56215
   323
lp15@56215
   324
lemma DERIV_zero_constant:
lp15@56215
   325
  fixes f :: "'a::{real_normed_field,euclidean_space} \<Rightarrow> 'a"
lp15@56215
   326
  shows    "\<lbrakk>convex s;
lp15@56215
   327
             \<And>x. x\<in>s \<Longrightarrow> (f has_field_derivative 0) (at x within s)\<rbrakk> 
lp15@56215
   328
             \<Longrightarrow> \<exists>c. \<forall>x \<in> s. f(x) = c"
lp15@56215
   329
  unfolding has_field_derivative_def
lp15@56215
   330
  by (auto simp: lambda_zero intro: has_derivative_zero_constant)
lp15@56215
   331
lp15@56215
   332
lemma DERIV_zero_unique:
lp15@56215
   333
  fixes f :: "'a::{real_normed_field,euclidean_space} \<Rightarrow> 'a"
lp15@56215
   334
  assumes "convex s"
lp15@56215
   335
      and d0: "\<And>x. x\<in>s \<Longrightarrow> (f has_field_derivative 0) (at x within s)"
lp15@56215
   336
      and "a \<in> s"
lp15@56215
   337
      and "x \<in> s"
lp15@56215
   338
    shows "f x = f a"
lp15@56215
   339
apply (rule has_derivative_zero_unique [where f=f, OF assms(1) _ assms(3,4)])
lp15@56215
   340
by (metis d0 has_field_derivative_imp_has_derivative lambda_zero)
lp15@56215
   341
lp15@56215
   342
lemma DERIV_zero_connected_unique:
lp15@56215
   343
  fixes f :: "'a::{real_normed_field,euclidean_space} \<Rightarrow> 'a"
lp15@56215
   344
  assumes "connected s"
lp15@56215
   345
      and "open s"
lp15@56215
   346
      and d0: "\<And>x. x\<in>s \<Longrightarrow> DERIV f x :> 0"
lp15@56215
   347
      and "a \<in> s"
lp15@56215
   348
      and "x \<in> s"
lp15@56215
   349
    shows "f x = f a" 
lp15@56215
   350
    apply (rule Integration.has_derivative_zero_unique_strong_connected [of s "{}" f])
lp15@56215
   351
    using assms
lp15@56215
   352
    apply auto
lp15@56215
   353
    apply (metis DERIV_continuous_on)
lp15@56215
   354
  by (metis at_within_open has_field_derivative_def lambda_zero)
lp15@56215
   355
lp15@56215
   356
lemma DERIV_transform_within:
lp15@56215
   357
  assumes "(f has_field_derivative f') (at a within s)"
lp15@56215
   358
      and "0 < d" "a \<in> s"
lp15@56215
   359
      and "\<And>x. x\<in>s \<Longrightarrow> dist x a < d \<Longrightarrow> f x = g x"
lp15@56215
   360
    shows "(g has_field_derivative f') (at a within s)"
lp15@56215
   361
  using assms unfolding has_field_derivative_def
lp15@56215
   362
  by (blast intro: Derivative.has_derivative_transform_within)
lp15@56215
   363
lp15@56215
   364
lemma DERIV_transform_within_open:
lp15@56215
   365
  assumes "DERIV f a :> f'"
lp15@56215
   366
      and "open s" "a \<in> s"
lp15@56215
   367
      and "\<And>x. x\<in>s \<Longrightarrow> f x = g x"
lp15@56215
   368
    shows "DERIV g a :> f'"
lp15@56215
   369
  using assms unfolding has_field_derivative_def
lp15@56215
   370
by (metis has_derivative_transform_within_open)
lp15@56215
   371
lp15@56215
   372
lemma DERIV_transform_at:
lp15@56215
   373
  assumes "DERIV f a :> f'"
lp15@56215
   374
      and "0 < d"
lp15@56215
   375
      and "\<And>x. dist x a < d \<Longrightarrow> f x = g x"
lp15@56215
   376
    shows "DERIV g a :> f'"
lp15@56215
   377
  by (blast intro: assms DERIV_transform_within)
lp15@56215
   378
lp15@56215
   379
lp15@56215
   380
subsection{*Holomorphic functions*}
lp15@56215
   381
lp15@56215
   382
lemma has_derivative_ident[has_derivative_intros, simp]: 
lp15@56215
   383
     "FDERIV complex_of_real x :> complex_of_real"
lp15@56215
   384
  by (simp add: has_derivative_def tendsto_const bounded_linear_of_real)
lp15@56215
   385
lp15@56215
   386
lemma has_real_derivative:
lp15@56215
   387
  fixes f :: "real\<Rightarrow>real" 
lp15@56215
   388
  assumes "(f has_derivative f') F"
lp15@56215
   389
    obtains c where "(f has_derivative (\<lambda>x. x * c)) F"
lp15@56215
   390
proof -
lp15@56215
   391
  obtain c where "f' = (\<lambda>x. x * c)"
lp15@56215
   392
    by (metis assms derivative_linear real_bounded_linear)
lp15@56215
   393
  then show ?thesis
lp15@56215
   394
    by (metis assms that)
lp15@56215
   395
qed
lp15@56215
   396
lp15@56215
   397
lemma has_real_derivative_iff:
lp15@56215
   398
  fixes f :: "real\<Rightarrow>real" 
lp15@56215
   399
  shows "(\<exists>f'. (f has_derivative (\<lambda>x. x * f')) F) = (\<exists>D. (f has_derivative D) F)"
lp15@56215
   400
by (auto elim: has_real_derivative)
lp15@56215
   401
lp15@56215
   402
definition complex_differentiable :: "[complex \<Rightarrow> complex, complex filter] \<Rightarrow> bool"
lp15@56215
   403
           (infixr "(complex'_differentiable)" 50)  
lp15@56215
   404
  where "f complex_differentiable F \<equiv> \<exists>f'. (f has_field_derivative f') F"
lp15@56215
   405
lp15@56215
   406
definition DD :: "['a \<Rightarrow> 'a::real_normed_field, 'a] \<Rightarrow> 'a" --{*for real, complex?*}
lp15@56215
   407
  where "DD f x \<equiv> THE f'. (f has_derivative (\<lambda>x. x * f')) (at x)"
lp15@56215
   408
lp15@56215
   409
definition holomorphic_on :: "[complex \<Rightarrow> complex, complex set] \<Rightarrow> bool"
lp15@56215
   410
           (infixl "(holomorphic'_on)" 50)
lp15@56215
   411
  where "f holomorphic_on s \<equiv> \<forall>x \<in> s. \<exists>f'. (f has_field_derivative f') (at x within s)"
lp15@56215
   412
  
lp15@56215
   413
lemma holomorphic_on_empty: "f holomorphic_on {}"
lp15@56215
   414
  by (simp add: holomorphic_on_def)
lp15@56215
   415
lp15@56215
   416
lemma holomorphic_on_differentiable:
lp15@56215
   417
     "f holomorphic_on s \<longleftrightarrow> (\<forall>x \<in> s. f complex_differentiable (at x within s))"
lp15@56215
   418
unfolding holomorphic_on_def complex_differentiable_def has_field_derivative_def
lp15@56215
   419
by (metis mult_commute_abs)
lp15@56215
   420
lp15@56215
   421
lemma holomorphic_on_open:
lp15@56215
   422
    "open s \<Longrightarrow> f holomorphic_on s \<longleftrightarrow> (\<forall>x \<in> s. \<exists>f'. DERIV f x :> f')"
lp15@56215
   423
  by (auto simp: holomorphic_on_def has_field_derivative_def at_within_open [of _ s])
lp15@56215
   424
lp15@56215
   425
lemma complex_differentiable_imp_continuous_at: 
lp15@56215
   426
    "f complex_differentiable (at x) \<Longrightarrow> continuous (at x) f"
lp15@56215
   427
  by (metis DERIV_continuous complex_differentiable_def)
lp15@56215
   428
lp15@56215
   429
lemma holomorphic_on_imp_continuous_on: 
lp15@56215
   430
    "f holomorphic_on s \<Longrightarrow> continuous_on s f"
lp15@56215
   431
  by (metis DERIV_continuous continuous_on_eq_continuous_within holomorphic_on_def) 
lp15@56215
   432
lp15@56215
   433
lemma has_derivative_within_open:
lp15@56215
   434
  "a \<in> s \<Longrightarrow> open s \<Longrightarrow> (f has_field_derivative f') (at a within s) \<longleftrightarrow> DERIV f a :> f'"
lp15@56215
   435
  by (simp add: has_field_derivative_def) (metis has_derivative_within_open)
lp15@56215
   436
lp15@56215
   437
lemma holomorphic_on_subset:
lp15@56215
   438
    "f holomorphic_on s \<Longrightarrow> t \<subseteq> s \<Longrightarrow> f holomorphic_on t"
lp15@56215
   439
  unfolding holomorphic_on_def
lp15@56215
   440
  by (metis DERIV_subset subsetD)
lp15@56215
   441
lp15@56215
   442
lemma complex_differentiable_within_subset:
lp15@56215
   443
    "\<lbrakk>f complex_differentiable (at x within s); t \<subseteq> s\<rbrakk>
lp15@56215
   444
     \<Longrightarrow> f complex_differentiable (at x within t)"
lp15@56215
   445
  unfolding complex_differentiable_def
lp15@56215
   446
  by (metis DERIV_subset)
lp15@56215
   447
lp15@56215
   448
lemma complex_differentiable_at_within:
lp15@56215
   449
    "\<lbrakk>f complex_differentiable (at x)\<rbrakk>
lp15@56215
   450
     \<Longrightarrow> f complex_differentiable (at x within s)"
lp15@56215
   451
  unfolding complex_differentiable_def
lp15@56215
   452
  by (metis DERIV_subset top_greatest)
lp15@56215
   453
lp15@56215
   454
lp15@56215
   455
lemma has_derivative_mult_right:
lp15@56215
   456
  fixes c:: "'a :: real_normed_algebra"
lp15@56215
   457
  shows "((op * c) has_derivative (op * c)) F"
lp15@56215
   458
by (rule has_derivative_mult_right [OF has_derivative_id])
lp15@56215
   459
lp15@56215
   460
lemma complex_differentiable_linear:
lp15@56215
   461
     "(op * c) complex_differentiable F"
lp15@56215
   462
proof -
lp15@56215
   463
  have "\<And>u::complex. (\<lambda>x. x * u) = op * u"
lp15@56215
   464
    by (rule ext) (simp add: mult_ac)
lp15@56215
   465
  then show ?thesis
lp15@56215
   466
    unfolding complex_differentiable_def has_field_derivative_def
lp15@56215
   467
    by (force intro: has_derivative_mult_right)
lp15@56215
   468
qed
lp15@56215
   469
lp15@56215
   470
lemma complex_differentiable_const:
lp15@56215
   471
  "(\<lambda>z. c) complex_differentiable F"
lp15@56215
   472
  unfolding complex_differentiable_def has_field_derivative_def
lp15@56215
   473
  apply (rule exI [where x=0])
lp15@56215
   474
  by (metis Derivative.has_derivative_const lambda_zero) 
lp15@56215
   475
lp15@56215
   476
lemma complex_differentiable_id:
lp15@56215
   477
  "(\<lambda>z. z) complex_differentiable F"
lp15@56215
   478
  unfolding complex_differentiable_def has_field_derivative_def
lp15@56215
   479
  apply (rule exI [where x=1])
lp15@56215
   480
  apply (simp add: lambda_one [symmetric])
lp15@56215
   481
  done
lp15@56215
   482
lp15@56215
   483
(*DERIV_minus*)
lp15@56215
   484
lemma field_differentiable_minus:
lp15@56215
   485
  assumes "(f has_field_derivative f') F" 
lp15@56215
   486
    shows "((\<lambda>z. - (f z)) has_field_derivative -f') F"
lp15@56215
   487
  apply (rule has_derivative_imp_has_field_derivative[OF has_derivative_minus])
lp15@56215
   488
  using assms 
lp15@56215
   489
  by (auto simp: has_field_derivative_def field_simps mult_commute_abs)
lp15@56215
   490
lp15@56215
   491
(*DERIV_add*)
lp15@56215
   492
lemma field_differentiable_add:
lp15@56215
   493
  assumes "(f has_field_derivative f') F" "(g has_field_derivative g') F"
lp15@56215
   494
    shows "((\<lambda>z. f z + g z) has_field_derivative f' + g') F"
lp15@56215
   495
  apply (rule has_derivative_imp_has_field_derivative[OF has_derivative_add])
lp15@56215
   496
  using assms 
lp15@56215
   497
  by (auto simp: has_field_derivative_def field_simps mult_commute_abs)
lp15@56215
   498
lp15@56215
   499
(*DERIV_diff*)
lp15@56215
   500
lemma field_differentiable_diff:
lp15@56215
   501
  assumes "(f has_field_derivative f') F" "(g has_field_derivative g') F"
lp15@56215
   502
    shows "((\<lambda>z. f z - g z) has_field_derivative f' - g') F"
lp15@56215
   503
by (simp only: assms diff_conv_add_uminus field_differentiable_add field_differentiable_minus)
lp15@56215
   504
lp15@56215
   505
lemma complex_differentiable_minus:
lp15@56215
   506
    "f complex_differentiable F \<Longrightarrow> (\<lambda>z. -(f z)) complex_differentiable F"
lp15@56215
   507
  using assms unfolding complex_differentiable_def
lp15@56215
   508
  by (metis field_differentiable_minus)
lp15@56215
   509
lp15@56215
   510
lemma complex_differentiable_add:
lp15@56215
   511
  assumes "f complex_differentiable F" "g complex_differentiable F"
lp15@56215
   512
    shows "(\<lambda>z. f z + g z) complex_differentiable F"
lp15@56215
   513
  using assms unfolding complex_differentiable_def
lp15@56215
   514
  by (metis field_differentiable_add)
lp15@56215
   515
lp15@56215
   516
lemma complex_differentiable_diff:
lp15@56215
   517
  assumes "f complex_differentiable F" "g complex_differentiable F"
lp15@56215
   518
    shows "(\<lambda>z. f z - g z) complex_differentiable F"
lp15@56215
   519
  using assms unfolding complex_differentiable_def
lp15@56215
   520
  by (metis field_differentiable_diff)
lp15@56215
   521
lp15@56215
   522
lemma complex_differentiable_inverse:
lp15@56215
   523
  assumes "f complex_differentiable (at a within s)" "f a \<noteq> 0"
lp15@56215
   524
  shows "(\<lambda>z. inverse (f z)) complex_differentiable (at a within s)"
lp15@56215
   525
  using assms unfolding complex_differentiable_def
lp15@56215
   526
  by (metis DERIV_inverse_fun)
lp15@56215
   527
lp15@56215
   528
lemma complex_differentiable_mult:
lp15@56215
   529
  assumes "f complex_differentiable (at a within s)" 
lp15@56215
   530
          "g complex_differentiable (at a within s)"
lp15@56215
   531
    shows "(\<lambda>z. f z * g z) complex_differentiable (at a within s)"
lp15@56215
   532
  using assms unfolding complex_differentiable_def
lp15@56215
   533
  by (metis DERIV_mult [of f _ a s g])
lp15@56215
   534
  
lp15@56215
   535
lemma complex_differentiable_divide:
lp15@56215
   536
  assumes "f complex_differentiable (at a within s)" 
lp15@56215
   537
          "g complex_differentiable (at a within s)"
lp15@56215
   538
          "g a \<noteq> 0"
lp15@56215
   539
    shows "(\<lambda>z. f z / g z) complex_differentiable (at a within s)"
lp15@56215
   540
  using assms unfolding complex_differentiable_def
lp15@56215
   541
  by (metis DERIV_divide [of f _ a s g])
lp15@56215
   542
lp15@56215
   543
lemma complex_differentiable_power:
lp15@56215
   544
  assumes "f complex_differentiable (at a within s)" 
lp15@56215
   545
    shows "(\<lambda>z. f z ^ n) complex_differentiable (at a within s)"
lp15@56215
   546
  using assms unfolding complex_differentiable_def
lp15@56215
   547
  by (metis DERIV_power)
lp15@56215
   548
lp15@56215
   549
lemma complex_differentiable_transform_within:
lp15@56215
   550
  "0 < d \<Longrightarrow>
lp15@56215
   551
        x \<in> s \<Longrightarrow>
lp15@56215
   552
        (\<And>x'. x' \<in> s \<Longrightarrow> dist x' x < d \<Longrightarrow> f x' = g x') \<Longrightarrow>
lp15@56215
   553
        f complex_differentiable (at x within s)
lp15@56215
   554
        \<Longrightarrow> g complex_differentiable (at x within s)"
lp15@56215
   555
  unfolding complex_differentiable_def has_field_derivative_def
lp15@56215
   556
  by (blast intro: has_derivative_transform_within)
lp15@56215
   557
lp15@56215
   558
lemma complex_differentiable_compose_within:
lp15@56215
   559
  assumes "f complex_differentiable (at a within s)" 
lp15@56215
   560
          "g complex_differentiable (at (f a) within f`s)"
lp15@56215
   561
    shows "(g o f) complex_differentiable (at a within s)"
lp15@56215
   562
  using assms unfolding complex_differentiable_def
lp15@56215
   563
  by (metis DERIV_image_chain)
lp15@56215
   564
lp15@56215
   565
lemma complex_differentiable_within_open:
lp15@56215
   566
     "\<lbrakk>a \<in> s; open s\<rbrakk> \<Longrightarrow> f complex_differentiable at a within s \<longleftrightarrow> 
lp15@56215
   567
                          f complex_differentiable at a"
lp15@56215
   568
  unfolding complex_differentiable_def
lp15@56215
   569
  by (metis at_within_open)
lp15@56215
   570
lp15@56215
   571
lemma holomorphic_transform:
lp15@56215
   572
     "\<lbrakk>f holomorphic_on s; \<And>x. x \<in> s \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> g holomorphic_on s"
lp15@56215
   573
  apply (auto simp: holomorphic_on_def has_field_derivative_def)
lp15@56215
   574
  by (metis complex_differentiable_def complex_differentiable_transform_within has_field_derivative_def linordered_field_no_ub)
lp15@56215
   575
lp15@56215
   576
lemma holomorphic_eq:
lp15@56215
   577
     "(\<And>x. x \<in> s \<Longrightarrow> f x = g x) \<Longrightarrow> f holomorphic_on s \<longleftrightarrow> g holomorphic_on s"
lp15@56215
   578
  by (metis holomorphic_transform)
lp15@56215
   579
lp15@56215
   580
subsection{*Holomorphic*}
lp15@56215
   581
lp15@56215
   582
lemma holomorphic_on_linear:
lp15@56215
   583
     "(op * c) holomorphic_on s"
lp15@56215
   584
  unfolding holomorphic_on_def  by (metis DERIV_cmult_Id)
lp15@56215
   585
lp15@56215
   586
lemma holomorphic_on_const:
lp15@56215
   587
     "(\<lambda>z. c) holomorphic_on s"
lp15@56215
   588
  unfolding holomorphic_on_def  
lp15@56215
   589
  by (metis DERIV_const)
lp15@56215
   590
lp15@56215
   591
lemma holomorphic_on_id:
lp15@56215
   592
     "id holomorphic_on s"
lp15@56215
   593
  unfolding holomorphic_on_def id_def  
lp15@56215
   594
  by (metis DERIV_ident)
lp15@56215
   595
lp15@56215
   596
lemma holomorphic_on_compose:
lp15@56215
   597
  "f holomorphic_on s \<Longrightarrow> g holomorphic_on (f ` s)
lp15@56215
   598
           \<Longrightarrow> (g o f) holomorphic_on s"
lp15@56215
   599
  unfolding holomorphic_on_def
lp15@56215
   600
  by (metis DERIV_image_chain imageI)
lp15@56215
   601
lp15@56215
   602
lemma holomorphic_on_compose_gen:
lp15@56215
   603
  "\<lbrakk>f holomorphic_on s; g holomorphic_on t; f ` s \<subseteq> t\<rbrakk> \<Longrightarrow> (g o f) holomorphic_on s"
lp15@56215
   604
  unfolding holomorphic_on_def
lp15@56215
   605
  by (metis DERIV_image_chain DERIV_subset image_subset_iff)
lp15@56215
   606
lp15@56215
   607
lemma holomorphic_on_minus:
lp15@56215
   608
  "f holomorphic_on s \<Longrightarrow> (\<lambda>z. -(f z)) holomorphic_on s"
lp15@56215
   609
  unfolding holomorphic_on_def
lp15@56215
   610
by (metis DERIV_minus)
lp15@56215
   611
lp15@56215
   612
lemma holomorphic_on_add:
lp15@56215
   613
  "\<lbrakk>f holomorphic_on s; g holomorphic_on s\<rbrakk> \<Longrightarrow> (\<lambda>z. f z + g z) holomorphic_on s"
lp15@56215
   614
  unfolding holomorphic_on_def
lp15@56215
   615
  by (metis DERIV_add)
lp15@56215
   616
lp15@56215
   617
lemma holomorphic_on_diff:
lp15@56215
   618
  "\<lbrakk>f holomorphic_on s; g holomorphic_on s\<rbrakk> \<Longrightarrow> (\<lambda>z. f z - g z) holomorphic_on s"
lp15@56215
   619
  unfolding holomorphic_on_def
lp15@56215
   620
  by (metis DERIV_diff)
lp15@56215
   621
lp15@56215
   622
lemma holomorphic_on_mult:
lp15@56215
   623
  "\<lbrakk>f holomorphic_on s; g holomorphic_on s\<rbrakk> \<Longrightarrow> (\<lambda>z. f z * g z) holomorphic_on s"
lp15@56215
   624
  unfolding holomorphic_on_def
lp15@56215
   625
  by auto (metis DERIV_mult)
lp15@56215
   626
lp15@56215
   627
lemma holomorphic_on_inverse:
lp15@56215
   628
  "\<lbrakk>f holomorphic_on s; \<And>z. z \<in> s \<Longrightarrow> f z \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>z. inverse (f z)) holomorphic_on s"
lp15@56215
   629
  unfolding holomorphic_on_def
lp15@56215
   630
  by (metis DERIV_inverse')
lp15@56215
   631
lp15@56215
   632
lemma holomorphic_on_divide:
lp15@56215
   633
  "\<lbrakk>f holomorphic_on s; g holomorphic_on s; \<And>z. z \<in> s \<Longrightarrow> g z \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>z. f z / g z) holomorphic_on s"
lp15@56215
   634
  unfolding holomorphic_on_def
lp15@56215
   635
  by (metis (full_types) DERIV_divide)
lp15@56215
   636
lp15@56215
   637
lemma holomorphic_on_power:
lp15@56215
   638
  "f holomorphic_on s \<Longrightarrow> (\<lambda>z. (f z)^n) holomorphic_on s"
lp15@56215
   639
  unfolding holomorphic_on_def
lp15@56215
   640
  by (metis DERIV_power)
lp15@56215
   641
lp15@56215
   642
lemma holomorphic_on_setsum:
lp15@56215
   643
  "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> (f i) holomorphic_on s)
lp15@56215
   644
           \<Longrightarrow> (\<lambda>x. setsum (\<lambda>i. f i x) I) holomorphic_on s"
lp15@56215
   645
  unfolding holomorphic_on_def
lp15@56215
   646
  apply (induct I rule: finite_induct) 
lp15@56215
   647
  apply (force intro: DERIV_const DERIV_add)+
lp15@56215
   648
  done
lp15@56215
   649
lp15@56215
   650
lemma DERIV_imp_DD: "DERIV f x :> f' \<Longrightarrow> DD f x = f'"
lp15@56215
   651
    apply (simp add: DD_def has_field_derivative_def mult_commute_abs)
lp15@56215
   652
    apply (rule the_equality, assumption)
lp15@56215
   653
    apply (metis DERIV_unique has_field_derivative_def)
lp15@56215
   654
    done
lp15@56215
   655
lp15@56215
   656
lemma DD_iff_derivative_differentiable:
lp15@56215
   657
  fixes f :: "real\<Rightarrow>real" 
lp15@56215
   658
  shows   "DERIV f x :> DD f x \<longleftrightarrow> f differentiable at x"
lp15@56215
   659
unfolding DD_def differentiable_def 
lp15@56215
   660
by (metis (full_types) DD_def DERIV_imp_DD has_field_derivative_def has_real_derivative_iff 
lp15@56215
   661
          mult_commute_abs)
lp15@56215
   662
lp15@56215
   663
lemma DD_iff_derivative_complex_differentiable:
lp15@56215
   664
  fixes f :: "complex\<Rightarrow>complex" 
lp15@56215
   665
  shows "DERIV f x :> DD f x \<longleftrightarrow> f complex_differentiable at x"
lp15@56215
   666
unfolding DD_def complex_differentiable_def
lp15@56215
   667
by (metis DD_def DERIV_imp_DD)
lp15@56215
   668
lp15@56215
   669
lemma complex_differentiable_compose:
lp15@56215
   670
  "f complex_differentiable at z \<Longrightarrow> g complex_differentiable at (f z)
lp15@56215
   671
          \<Longrightarrow> (g o f) complex_differentiable at z"
lp15@56215
   672
by (metis complex_differentiable_at_within complex_differentiable_compose_within)
lp15@56215
   673
lp15@56215
   674
lemma complex_derivative_chain:
lp15@56215
   675
  fixes z::complex
lp15@56215
   676
  shows
lp15@56215
   677
  "f complex_differentiable at z \<Longrightarrow> g complex_differentiable at (f z)
lp15@56215
   678
          \<Longrightarrow> DD (g o f) z = DD g (f z) * DD f z"
lp15@56215
   679
by (metis DD_iff_derivative_complex_differentiable DERIV_chain DERIV_imp_DD)
lp15@56215
   680
lp15@56215
   681
lemma comp_derivative_chain:
lp15@56215
   682
  fixes z::real
lp15@56215
   683
  shows "\<lbrakk>f differentiable at z; g differentiable at (f z)\<rbrakk> 
lp15@56215
   684
         \<Longrightarrow> DD (g o f) z = DD g (f z) * DD f z"
lp15@56215
   685
by (metis DD_iff_derivative_differentiable DERIV_chain DERIV_imp_DD)
lp15@56215
   686
lp15@56215
   687
lemma complex_derivative_linear: "DD (\<lambda>w. c * w) = (\<lambda>z. c)"
lp15@56215
   688
by (metis DERIV_imp_DD DERIV_cmult_Id)
lp15@56215
   689
lp15@56215
   690
lemma complex_derivative_ident: "DD (\<lambda>w. w) = (\<lambda>z. 1)"
lp15@56215
   691
by (metis DERIV_imp_DD DERIV_ident)
lp15@56215
   692
lp15@56215
   693
lemma complex_derivative_const: "DD (\<lambda>w. c) = (\<lambda>z. 0)"
lp15@56215
   694
by (metis DERIV_imp_DD DERIV_const)
lp15@56215
   695
lp15@56215
   696
lemma complex_derivative_add:
lp15@56215
   697
  "\<lbrakk>f complex_differentiable at z; g complex_differentiable at z\<rbrakk>  
lp15@56215
   698
   \<Longrightarrow> DD (\<lambda>w. f w + g w) z = DD f z + DD g z"
lp15@56215
   699
  unfolding complex_differentiable_def
lp15@56215
   700
  by (rule DERIV_imp_DD) (metis (poly_guards_query) DERIV_add DERIV_imp_DD)  
lp15@56215
   701
lp15@56215
   702
lemma complex_derivative_diff:
lp15@56215
   703
  "\<lbrakk>f complex_differentiable at z; g complex_differentiable at z\<rbrakk>  
lp15@56215
   704
   \<Longrightarrow> DD (\<lambda>w. f w - g w) z = DD f z - DD g z"
lp15@56215
   705
  unfolding complex_differentiable_def
lp15@56215
   706
  by (rule DERIV_imp_DD) (metis (poly_guards_query) DERIV_diff DERIV_imp_DD)
lp15@56215
   707
lp15@56215
   708
lemma complex_derivative_mult:
lp15@56215
   709
  "\<lbrakk>f complex_differentiable at z; g complex_differentiable at z\<rbrakk>  
lp15@56215
   710
   \<Longrightarrow> DD (\<lambda>w. f w * g w) z = f z * DD g z + DD f z * g z"
lp15@56215
   711
  unfolding complex_differentiable_def
lp15@56215
   712
  by (rule DERIV_imp_DD) (metis DERIV_imp_DD DERIV_mult')
lp15@56215
   713
lp15@56215
   714
lemma complex_derivative_cmult:
lp15@56215
   715
  "f complex_differentiable at z \<Longrightarrow> DD (\<lambda>w. c * f w) z = c * DD f z"
lp15@56215
   716
  unfolding complex_differentiable_def
lp15@56215
   717
  by (metis DERIV_cmult DERIV_imp_DD)
lp15@56215
   718
lp15@56215
   719
lemma complex_derivative_cmult_right:
lp15@56215
   720
  "f complex_differentiable at z \<Longrightarrow> DD (\<lambda>w. f w * c) z = DD f z * c"
lp15@56215
   721
  unfolding complex_differentiable_def
lp15@56215
   722
  by (metis DERIV_cmult_right DERIV_imp_DD)
lp15@56215
   723
lp15@56215
   724
lemma complex_derivative_transform_within_open:
lp15@56215
   725
  "\<lbrakk>f holomorphic_on s; g holomorphic_on s; open s; z \<in> s; \<And>w. w \<in> s \<Longrightarrow> f w = g w\<rbrakk> 
lp15@56215
   726
   \<Longrightarrow> DD f z = DD g z"
lp15@56215
   727
  unfolding holomorphic_on_def
lp15@56215
   728
  by (rule DERIV_imp_DD) (metis has_derivative_within_open DERIV_imp_DD DERIV_transform_within_open)
lp15@56215
   729
lp15@56215
   730
lemma complex_derivative_compose_linear:
lp15@56215
   731
    "f complex_differentiable at (c * z) \<Longrightarrow> DD (\<lambda>w. f (c * w)) z = c * DD f (c * z)"
lp15@56215
   732
apply (rule DERIV_imp_DD)
lp15@56215
   733
apply (simp add: DD_iff_derivative_complex_differentiable [symmetric])
lp15@56215
   734
apply (metis DERIV_chain' DERIV_cmult_Id comm_semiring_1_class.normalizing_semiring_rules(7))  
lp15@56215
   735
done
lp15@56215
   736
lp15@56215
   737
subsection{*Caratheodory characterization.*}
lp15@56215
   738
lp15@56215
   739
(*REPLACE the original version. BUT IN WHICH FILE??*)
lp15@56215
   740
thm Deriv.CARAT_DERIV
lp15@56215
   741
lp15@56215
   742
lemma complex_differentiable_caratheodory_at:
lp15@56215
   743
  "f complex_differentiable (at z) \<longleftrightarrow>
lp15@56215
   744
         (\<exists>g. (\<forall>w. f(w) - f(z) = g(w) * (w - z)) \<and> continuous (at z) g)"
lp15@56215
   745
  using CARAT_DERIV [of f]
lp15@56215
   746
  by (simp add: complex_differentiable_def has_field_derivative_def)
lp15@56215
   747
lp15@56215
   748
lemma complex_differentiable_caratheodory_within:
lp15@56215
   749
  "f complex_differentiable (at z within s) \<longleftrightarrow>
lp15@56215
   750
         (\<exists>g. (\<forall>w. f(w) - f(z) = g(w) * (w - z)) \<and> continuous (at z within s) g)"
lp15@56215
   751
  using DERIV_caratheodory_within [of f]
lp15@56215
   752
  by (simp add: complex_differentiable_def has_field_derivative_def)
lp15@56215
   753
lp15@56215
   754
subsection{*analyticity on a set*}
lp15@56215
   755
lp15@56215
   756
definition analytic_on (infixl "(analytic'_on)" 50)  
lp15@56215
   757
  where
lp15@56215
   758
   "f analytic_on s \<equiv> \<forall>x \<in> s. \<exists>e. 0 < e \<and> f holomorphic_on (ball x e)"
lp15@56215
   759
lp15@56215
   760
lemma analytic_imp_holomorphic:
lp15@56215
   761
     "f analytic_on s \<Longrightarrow> f holomorphic_on s"
lp15@56215
   762
  unfolding analytic_on_def holomorphic_on_def
lp15@56215
   763
  apply (simp add: has_derivative_within_open [OF _ open_ball])
lp15@56215
   764
  apply (metis DERIV_subset dist_self mem_ball top_greatest)
lp15@56215
   765
  done
lp15@56215
   766
lp15@56215
   767
lemma analytic_on_open:
lp15@56215
   768
     "open s \<Longrightarrow> f analytic_on s \<longleftrightarrow> f holomorphic_on s"
lp15@56215
   769
apply (auto simp: analytic_imp_holomorphic)
lp15@56215
   770
apply (auto simp: analytic_on_def holomorphic_on_def)
lp15@56215
   771
by (metis holomorphic_on_def holomorphic_on_subset open_contains_ball)
lp15@56215
   772
lp15@56215
   773
lemma analytic_on_imp_differentiable_at:
lp15@56215
   774
  "f analytic_on s \<Longrightarrow> x \<in> s \<Longrightarrow> f complex_differentiable (at x)"
lp15@56215
   775
 apply (auto simp: analytic_on_def holomorphic_on_differentiable)
lp15@56215
   776
by (metis Topology_Euclidean_Space.open_ball centre_in_ball complex_differentiable_within_open)
lp15@56215
   777
lp15@56215
   778
lemma analytic_on_subset:
lp15@56215
   779
     "f analytic_on s \<Longrightarrow> t \<subseteq> s \<Longrightarrow> f analytic_on t"
lp15@56215
   780
  by (auto simp: analytic_on_def)
lp15@56215
   781
lp15@56215
   782
lemma analytic_on_Un:
lp15@56215
   783
    "f analytic_on (s \<union> t) \<longleftrightarrow> f analytic_on s \<and> f analytic_on t"
lp15@56215
   784
  by (auto simp: analytic_on_def)
lp15@56215
   785
lp15@56215
   786
lemma analytic_on_Union:
lp15@56215
   787
  "f analytic_on (\<Union> s) \<longleftrightarrow> (\<forall>t \<in> s. f analytic_on t)"
lp15@56215
   788
  by (auto simp: analytic_on_def)
lp15@56215
   789
  
lp15@56215
   790
lemma analytic_on_holomorphic:
lp15@56215
   791
  "f analytic_on s \<longleftrightarrow> (\<exists>t. open t \<and> s \<subseteq> t \<and> f holomorphic_on t)"
lp15@56215
   792
  (is "?lhs = ?rhs")
lp15@56215
   793
proof -
lp15@56215
   794
  have "?lhs \<longleftrightarrow> (\<exists>t. open t \<and> s \<subseteq> t \<and> f analytic_on t)"
lp15@56215
   795
  proof safe
lp15@56215
   796
    assume "f analytic_on s"
lp15@56215
   797
    then show "\<exists>t. open t \<and> s \<subseteq> t \<and> f analytic_on t"
lp15@56215
   798
      apply (simp add: analytic_on_def)
lp15@56215
   799
      apply (rule exI [where x="\<Union>{u. open u \<and> f analytic_on u}"], auto)
lp15@56215
   800
      apply (metis Topology_Euclidean_Space.open_ball analytic_on_open centre_in_ball)
lp15@56215
   801
      by (metis analytic_on_def)
lp15@56215
   802
  next
lp15@56215
   803
    fix t
lp15@56215
   804
    assume "open t" "s \<subseteq> t" "f analytic_on t" 
lp15@56215
   805
    then show "f analytic_on s"
lp15@56215
   806
        by (metis analytic_on_subset)
lp15@56215
   807
  qed
lp15@56215
   808
  also have "... \<longleftrightarrow> ?rhs"
lp15@56215
   809
    by (auto simp: analytic_on_open)
lp15@56215
   810
  finally show ?thesis .
lp15@56215
   811
qed
lp15@56215
   812
lp15@56215
   813
lemma analytic_on_linear: "(op * c) analytic_on s"
lp15@56215
   814
  apply (simp add: analytic_on_holomorphic holomorphic_on_linear)
lp15@56215
   815
  by (metis open_UNIV top_greatest)
lp15@56215
   816
lp15@56215
   817
lemma analytic_on_const: "(\<lambda>z. c) analytic_on s"
lp15@56215
   818
  unfolding analytic_on_def
lp15@56215
   819
  by (metis holomorphic_on_const zero_less_one)
lp15@56215
   820
lp15@56215
   821
lemma analytic_on_id: "id analytic_on s"
lp15@56215
   822
  unfolding analytic_on_def
lp15@56215
   823
  apply (simp add: holomorphic_on_id)
lp15@56215
   824
  by (metis gt_ex)
lp15@56215
   825
lp15@56215
   826
lemma analytic_on_compose:
lp15@56215
   827
  assumes f: "f analytic_on s"
lp15@56215
   828
      and g: "g analytic_on (f ` s)"
lp15@56215
   829
    shows "(g o f) analytic_on s"
lp15@56215
   830
unfolding analytic_on_def
lp15@56215
   831
proof (intro ballI)
lp15@56215
   832
  fix x
lp15@56215
   833
  assume x: "x \<in> s"
lp15@56215
   834
  then obtain e where e: "0 < e" and fh: "f holomorphic_on ball x e" using f
lp15@56215
   835
    by (metis analytic_on_def)
lp15@56215
   836
  obtain e' where e': "0 < e'" and gh: "g holomorphic_on ball (f x) e'" using g
lp15@56215
   837
    by (metis analytic_on_def g image_eqI x) 
lp15@56215
   838
  have "isCont f x"
lp15@56215
   839
    by (metis analytic_on_imp_differentiable_at complex_differentiable_imp_continuous_at f x)
lp15@56215
   840
  with e' obtain d where d: "0 < d" and fd: "f ` ball x d \<subseteq> ball (f x) e'"
lp15@56215
   841
     by (auto simp: continuous_at_ball)
lp15@56215
   842
  have "g \<circ> f holomorphic_on ball x (min d e)" 
lp15@56215
   843
    apply (rule holomorphic_on_compose)
lp15@56215
   844
    apply (metis fh holomorphic_on_subset min.bounded_iff order_refl subset_ball)
lp15@56215
   845
    by (metis fd gh holomorphic_on_subset image_mono min.cobounded1 subset_ball)
lp15@56215
   846
  then show "\<exists>e>0. g \<circ> f holomorphic_on ball x e"
lp15@56215
   847
    by (metis d e min_less_iff_conj) 
lp15@56215
   848
qed
lp15@56215
   849
lp15@56215
   850
lemma analytic_on_compose_gen:
lp15@56215
   851
  "f analytic_on s \<Longrightarrow> g analytic_on t \<Longrightarrow> (\<And>z. z \<in> s \<Longrightarrow> f z \<in> t)
lp15@56215
   852
             \<Longrightarrow> g o f analytic_on s"
lp15@56215
   853
by (metis analytic_on_compose analytic_on_subset image_subset_iff)
lp15@56215
   854
lp15@56215
   855
lemma analytic_on_neg:
lp15@56215
   856
  "f analytic_on s \<Longrightarrow> (\<lambda>z. -(f z)) analytic_on s"
lp15@56215
   857
by (metis analytic_on_holomorphic holomorphic_on_minus)
lp15@56215
   858
lp15@56215
   859
lemma analytic_on_add:
lp15@56215
   860
  assumes f: "f analytic_on s"
lp15@56215
   861
      and g: "g analytic_on s"
lp15@56215
   862
    shows "(\<lambda>z. f z + g z) analytic_on s"
lp15@56215
   863
unfolding analytic_on_def
lp15@56215
   864
proof (intro ballI)
lp15@56215
   865
  fix z
lp15@56215
   866
  assume z: "z \<in> s"
lp15@56215
   867
  then obtain e where e: "0 < e" and fh: "f holomorphic_on ball z e" using f
lp15@56215
   868
    by (metis analytic_on_def)
lp15@56215
   869
  obtain e' where e': "0 < e'" and gh: "g holomorphic_on ball z e'" using g
lp15@56215
   870
    by (metis analytic_on_def g z) 
lp15@56215
   871
  have "(\<lambda>z. f z + g z) holomorphic_on ball z (min e e')" 
lp15@56215
   872
    apply (rule holomorphic_on_add) 
lp15@56215
   873
    apply (metis fh holomorphic_on_subset min.bounded_iff order_refl subset_ball)
lp15@56215
   874
    by (metis gh holomorphic_on_subset min.bounded_iff order_refl subset_ball)
lp15@56215
   875
  then show "\<exists>e>0. (\<lambda>z. f z + g z) holomorphic_on ball z e"
lp15@56215
   876
    by (metis e e' min_less_iff_conj)
lp15@56215
   877
qed
lp15@56215
   878
lp15@56215
   879
lemma analytic_on_diff:
lp15@56215
   880
  assumes f: "f analytic_on s"
lp15@56215
   881
      and g: "g analytic_on s"
lp15@56215
   882
    shows "(\<lambda>z. f z - g z) analytic_on s"
lp15@56215
   883
unfolding analytic_on_def
lp15@56215
   884
proof (intro ballI)
lp15@56215
   885
  fix z
lp15@56215
   886
  assume z: "z \<in> s"
lp15@56215
   887
  then obtain e where e: "0 < e" and fh: "f holomorphic_on ball z e" using f
lp15@56215
   888
    by (metis analytic_on_def)
lp15@56215
   889
  obtain e' where e': "0 < e'" and gh: "g holomorphic_on ball z e'" using g
lp15@56215
   890
    by (metis analytic_on_def g z) 
lp15@56215
   891
  have "(\<lambda>z. f z - g z) holomorphic_on ball z (min e e')" 
lp15@56215
   892
    apply (rule holomorphic_on_diff) 
lp15@56215
   893
    apply (metis fh holomorphic_on_subset min.bounded_iff order_refl subset_ball)
lp15@56215
   894
    by (metis gh holomorphic_on_subset min.bounded_iff order_refl subset_ball)
lp15@56215
   895
  then show "\<exists>e>0. (\<lambda>z. f z - g z) holomorphic_on ball z e"
lp15@56215
   896
    by (metis e e' min_less_iff_conj)
lp15@56215
   897
qed
lp15@56215
   898
lp15@56215
   899
lemma analytic_on_mult:
lp15@56215
   900
  assumes f: "f analytic_on s"
lp15@56215
   901
      and g: "g analytic_on s"
lp15@56215
   902
    shows "(\<lambda>z. f z * g z) analytic_on s"
lp15@56215
   903
unfolding analytic_on_def
lp15@56215
   904
proof (intro ballI)
lp15@56215
   905
  fix z
lp15@56215
   906
  assume z: "z \<in> s"
lp15@56215
   907
  then obtain e where e: "0 < e" and fh: "f holomorphic_on ball z e" using f
lp15@56215
   908
    by (metis analytic_on_def)
lp15@56215
   909
  obtain e' where e': "0 < e'" and gh: "g holomorphic_on ball z e'" using g
lp15@56215
   910
    by (metis analytic_on_def g z) 
lp15@56215
   911
  have "(\<lambda>z. f z * g z) holomorphic_on ball z (min e e')" 
lp15@56215
   912
    apply (rule holomorphic_on_mult) 
lp15@56215
   913
    apply (metis fh holomorphic_on_subset min.bounded_iff order_refl subset_ball)
lp15@56215
   914
    by (metis gh holomorphic_on_subset min.bounded_iff order_refl subset_ball)
lp15@56215
   915
  then show "\<exists>e>0. (\<lambda>z. f z * g z) holomorphic_on ball z e"
lp15@56215
   916
    by (metis e e' min_less_iff_conj)
lp15@56215
   917
qed
lp15@56215
   918
lp15@56215
   919
lemma analytic_on_inverse:
lp15@56215
   920
  assumes f: "f analytic_on s"
lp15@56215
   921
      and nz: "(\<And>z. z \<in> s \<Longrightarrow> f z \<noteq> 0)"
lp15@56215
   922
    shows "(\<lambda>z. inverse (f z)) analytic_on s"
lp15@56215
   923
unfolding analytic_on_def
lp15@56215
   924
proof (intro ballI)
lp15@56215
   925
  fix z
lp15@56215
   926
  assume z: "z \<in> s"
lp15@56215
   927
  then obtain e where e: "0 < e" and fh: "f holomorphic_on ball z e" using f
lp15@56215
   928
    by (metis analytic_on_def)
lp15@56215
   929
  have "continuous_on (ball z e) f"
lp15@56215
   930
    by (metis fh holomorphic_on_imp_continuous_on)
lp15@56215
   931
  then obtain e' where e': "0 < e'" and nz': "\<And>y. dist z y < e' \<Longrightarrow> f y \<noteq> 0" 
lp15@56215
   932
    by (metis Topology_Euclidean_Space.open_ball centre_in_ball continuous_on_open_avoid e z nz)  
lp15@56215
   933
  have "(\<lambda>z. inverse (f z)) holomorphic_on ball z (min e e')" 
lp15@56215
   934
    apply (rule holomorphic_on_inverse)
lp15@56215
   935
    apply (metis fh holomorphic_on_subset min.cobounded2 min.commute subset_ball)
lp15@56215
   936
    by (metis nz' mem_ball min_less_iff_conj) 
lp15@56215
   937
  then show "\<exists>e>0. (\<lambda>z. inverse (f z)) holomorphic_on ball z e"
lp15@56215
   938
    by (metis e e' min_less_iff_conj)
lp15@56215
   939
qed
lp15@56215
   940
lp15@56215
   941
lp15@56215
   942
lemma analytic_on_divide:
lp15@56215
   943
  assumes f: "f analytic_on s"
lp15@56215
   944
      and g: "g analytic_on s"
lp15@56215
   945
      and nz: "(\<And>z. z \<in> s \<Longrightarrow> g z \<noteq> 0)"
lp15@56215
   946
    shows "(\<lambda>z. f z / g z) analytic_on s"
lp15@56215
   947
unfolding divide_inverse
lp15@56215
   948
by (metis analytic_on_inverse analytic_on_mult f g nz)
lp15@56215
   949
lp15@56215
   950
lemma analytic_on_power:
lp15@56215
   951
  "f analytic_on s \<Longrightarrow> (\<lambda>z. (f z) ^ n) analytic_on s"
lp15@56215
   952
by (induct n) (auto simp: analytic_on_const analytic_on_mult)
lp15@56215
   953
lp15@56215
   954
lemma analytic_on_setsum:
lp15@56215
   955
  "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> (f i) analytic_on s)
lp15@56215
   956
           \<Longrightarrow> (\<lambda>x. setsum (\<lambda>i. f i x) I) analytic_on s"
lp15@56215
   957
  by (induct I rule: finite_induct) (auto simp: analytic_on_const analytic_on_add)
lp15@56215
   958
lp15@56215
   959
subsection{*analyticity at a point.*}
lp15@56215
   960
lp15@56215
   961
lemma analytic_at_ball:
lp15@56215
   962
  "f analytic_on {z} \<longleftrightarrow> (\<exists>e. 0<e \<and> f holomorphic_on ball z e)"
lp15@56215
   963
by (metis analytic_on_def singleton_iff)
lp15@56215
   964
lp15@56215
   965
lemma analytic_at:
lp15@56215
   966
    "f analytic_on {z} \<longleftrightarrow> (\<exists>s. open s \<and> z \<in> s \<and> f holomorphic_on s)"
lp15@56215
   967
by (metis analytic_on_holomorphic empty_subsetI insert_subset)
lp15@56215
   968
lp15@56215
   969
lemma analytic_on_analytic_at:
lp15@56215
   970
    "f analytic_on s \<longleftrightarrow> (\<forall>z \<in> s. f analytic_on {z})"
lp15@56215
   971
by (metis analytic_at_ball analytic_on_def)
lp15@56215
   972
lp15@56215
   973
lemma analytic_at_two:
lp15@56215
   974
  "f analytic_on {z} \<and> g analytic_on {z} \<longleftrightarrow>
lp15@56215
   975
   (\<exists>s. open s \<and> z \<in> s \<and> f holomorphic_on s \<and> g holomorphic_on s)"
lp15@56215
   976
  (is "?lhs = ?rhs")
lp15@56215
   977
proof 
lp15@56215
   978
  assume ?lhs
lp15@56215
   979
  then obtain s t 
lp15@56215
   980
    where st: "open s" "z \<in> s" "f holomorphic_on s"
lp15@56215
   981
              "open t" "z \<in> t" "g holomorphic_on t"
lp15@56215
   982
    by (auto simp: analytic_at)
lp15@56215
   983
  show ?rhs
lp15@56215
   984
    apply (rule_tac x="s \<inter> t" in exI)
lp15@56215
   985
    using st
lp15@56215
   986
    apply (auto simp: Diff_subset holomorphic_on_subset)
lp15@56215
   987
    done
lp15@56215
   988
next
lp15@56215
   989
  assume ?rhs 
lp15@56215
   990
  then show ?lhs
lp15@56215
   991
    by (force simp add: analytic_at)
lp15@56215
   992
qed
lp15@56215
   993
lp15@56215
   994
subsection{*Combining theorems for derivative with ``analytic at'' hypotheses*}
lp15@56215
   995
lp15@56215
   996
lemma 
lp15@56215
   997
  assumes "f analytic_on {z}" "g analytic_on {z}"
lp15@56215
   998
  shows complex_derivative_add_at: "DD (\<lambda>w. f w + g w) z = DD f z + DD g z"
lp15@56215
   999
    and complex_derivative_diff_at: "DD (\<lambda>w. f w - g w) z = DD f z - DD g z"
lp15@56215
  1000
    and complex_derivative_mult_at: "DD (\<lambda>w. f w * g w) z =
lp15@56215
  1001
           f z * DD g z + DD f z * g z"
lp15@56215
  1002
proof -
lp15@56215
  1003
  obtain s where s: "open s" "z \<in> s" "f holomorphic_on s" "g holomorphic_on s"
lp15@56215
  1004
    using assms by (metis analytic_at_two)
lp15@56215
  1005
  show "DD (\<lambda>w. f w + g w) z = DD f z + DD g z"
lp15@56215
  1006
    apply (rule DERIV_imp_DD [OF DERIV_add])
lp15@56215
  1007
    using s
lp15@56215
  1008
    apply (auto simp: holomorphic_on_open complex_differentiable_def DD_iff_derivative_complex_differentiable)
lp15@56215
  1009
    done
lp15@56215
  1010
  show "DD (\<lambda>w. f w - g w) z = DD f z - DD g z"
lp15@56215
  1011
    apply (rule DERIV_imp_DD [OF DERIV_diff])
lp15@56215
  1012
    using s
lp15@56215
  1013
    apply (auto simp: holomorphic_on_open complex_differentiable_def DD_iff_derivative_complex_differentiable)
lp15@56215
  1014
    done
lp15@56215
  1015
  show "DD (\<lambda>w. f w * g w) z = f z * DD g z + DD f z * g z"
lp15@56215
  1016
    apply (rule DERIV_imp_DD [OF DERIV_mult'])
lp15@56215
  1017
    using s
lp15@56215
  1018
    apply (auto simp: holomorphic_on_open complex_differentiable_def DD_iff_derivative_complex_differentiable)
lp15@56215
  1019
    done
lp15@56215
  1020
qed
lp15@56215
  1021
lp15@56215
  1022
lemma complex_derivative_cmult_at:
lp15@56215
  1023
  "f analytic_on {z} \<Longrightarrow>  DD (\<lambda>w. c * f w) z = c * DD f z"
lp15@56215
  1024
by (auto simp: complex_derivative_mult_at complex_derivative_const analytic_on_const)
lp15@56215
  1025
lp15@56215
  1026
lemma complex_derivative_cmult_right_at:
lp15@56215
  1027
  "f analytic_on {z} \<Longrightarrow>  DD (\<lambda>w. f w * c) z = DD f z * c"
lp15@56215
  1028
by (auto simp: complex_derivative_mult_at complex_derivative_const analytic_on_const)
lp15@56215
  1029
lp15@56215
  1030
text{*A composition lemma for functions of mixed type*}
lp15@56215
  1031
lemma has_vector_derivative_real_complex:
lp15@56215
  1032
  fixes f :: "complex \<Rightarrow> complex"
lp15@56215
  1033
  assumes "DERIV f (of_real a) :> f'"
lp15@56215
  1034
  shows "((\<lambda>x. f (of_real x)) has_vector_derivative f') (at a)"
lp15@56215
  1035
  using diff_chain_at [OF has_derivative_ident, of f "op * f'" a] assms
lp15@56215
  1036
  unfolding has_field_derivative_def has_vector_derivative_def o_def
lp15@56215
  1037
  by (auto simp: mult_ac scaleR_conv_of_real)
lp15@56215
  1038
lp15@56215
  1039
subsection{*Complex differentiation of sequences and series*}
lp15@56215
  1040
lp15@56215
  1041
lemma has_complex_derivative_sequence:
lp15@56215
  1042
  fixes s :: "complex set"
lp15@56215
  1043
  assumes cvs: "convex s"
lp15@56215
  1044
      and df:  "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x within s)"
lp15@56215
  1045
      and conv: "\<And>e. 0 < e \<Longrightarrow> \<exists>N. \<forall>n x. n \<ge> N \<longrightarrow> x \<in> s \<longrightarrow> norm (f' n x - g' x) \<le> e"
lp15@56215
  1046
      and "\<exists>x l. x \<in> s \<and> ((\<lambda>n. f n x) ---> l) sequentially"
lp15@56215
  1047
    shows "\<exists>g. \<forall>x \<in> s. ((\<lambda>n. f n x) ---> g x) sequentially \<and> 
lp15@56215
  1048
                       (g has_field_derivative (g' x)) (at x within s)"
lp15@56215
  1049
proof -
lp15@56215
  1050
  from assms obtain x l where x: "x \<in> s" and tf: "((\<lambda>n. f n x) ---> l) sequentially"
lp15@56215
  1051
    by blast
lp15@56215
  1052
  { fix e::real assume e: "e > 0"
lp15@56215
  1053
    then obtain N where N: "\<forall>n\<ge>N. \<forall>x. x \<in> s \<longrightarrow> cmod (f' n x - g' x) \<le> e"
lp15@56215
  1054
      by (metis conv)    
lp15@56215
  1055
    have "\<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. cmod (f' n x * h - g' x * h) \<le> e * cmod h"
lp15@56215
  1056
    proof (rule exI [of _ N], clarify)
lp15@56215
  1057
      fix n y h
lp15@56215
  1058
      assume "N \<le> n" "y \<in> s"
lp15@56215
  1059
      then have "cmod (f' n y - g' y) \<le> e"
lp15@56215
  1060
        by (metis N)
lp15@56215
  1061
      then have "cmod h * cmod (f' n y - g' y) \<le> cmod h * e"
lp15@56215
  1062
        by (auto simp: antisym_conv2 mult_le_cancel_left norm_triangle_ineq2)
lp15@56215
  1063
      then show "cmod (f' n y * h - g' y * h) \<le> e * cmod h"
lp15@56215
  1064
        by (simp add: norm_mult [symmetric] field_simps)
lp15@56215
  1065
    qed
lp15@56215
  1066
  } note ** = this
lp15@56215
  1067
  show ?thesis
lp15@56215
  1068
  unfolding has_field_derivative_def
lp15@56215
  1069
  proof (rule has_derivative_sequence [OF cvs _ _ x])
lp15@56215
  1070
    show "\<forall>n. \<forall>x\<in>s. (f n has_derivative (op * (f' n x))) (at x within s)"
lp15@56215
  1071
      by (metis has_field_derivative_def df)
lp15@56215
  1072
  next show "(\<lambda>n. f n x) ----> l"
lp15@56215
  1073
    by (rule tf)
lp15@56215
  1074
  next show "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. cmod (f' n x * h - g' x * h) \<le> e * cmod h"
lp15@56215
  1075
    by (blast intro: **)
lp15@56215
  1076
  qed
lp15@56215
  1077
qed
lp15@56215
  1078
lp15@56215
  1079
lp15@56215
  1080
lemma has_complex_derivative_series:
lp15@56215
  1081
  fixes s :: "complex set"
lp15@56215
  1082
  assumes cvs: "convex s"
lp15@56215
  1083
      and df:  "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x within s)"
lp15@56215
  1084
      and conv: "\<And>e. 0 < e \<Longrightarrow> \<exists>N. \<forall>n x. n \<ge> N \<longrightarrow> x \<in> s 
lp15@56215
  1085
                \<longrightarrow> cmod ((\<Sum>i<n. f' i x) - g' x) \<le> e"
lp15@56215
  1086
      and "\<exists>x l. x \<in> s \<and> ((\<lambda>n. f n x) sums l)"
lp15@56215
  1087
    shows "\<exists>g. \<forall>x \<in> s. ((\<lambda>n. f n x) sums g x) \<and> ((g has_field_derivative g' x) (at x within s))"
lp15@56215
  1088
proof -
lp15@56215
  1089
  from assms obtain x l where x: "x \<in> s" and sf: "((\<lambda>n. f n x) sums l)"
lp15@56215
  1090
    by blast
lp15@56215
  1091
  { fix e::real assume e: "e > 0"
lp15@56215
  1092
    then obtain N where N: "\<forall>n x. n \<ge> N \<longrightarrow> x \<in> s 
lp15@56215
  1093
            \<longrightarrow> cmod ((\<Sum>i<n. f' i x) - g' x) \<le> e"
lp15@56215
  1094
      by (metis conv)    
lp15@56215
  1095
    have "\<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. cmod ((\<Sum>i<n. h * f' i x) - g' x * h) \<le> e * cmod h"
lp15@56215
  1096
    proof (rule exI [of _ N], clarify)
lp15@56215
  1097
      fix n y h
lp15@56215
  1098
      assume "N \<le> n" "y \<in> s"
lp15@56215
  1099
      then have "cmod ((\<Sum>i<n. f' i y) - g' y) \<le> e"
lp15@56215
  1100
        by (metis N)
lp15@56215
  1101
      then have "cmod h * cmod ((\<Sum>i<n. f' i y) - g' y) \<le> cmod h * e"
lp15@56215
  1102
        by (auto simp: antisym_conv2 mult_le_cancel_left norm_triangle_ineq2)
lp15@56215
  1103
      then show "cmod ((\<Sum>i<n. h * f' i y) - g' y * h) \<le> e * cmod h"
lp15@56215
  1104
        by (simp add: norm_mult [symmetric] field_simps setsum_right_distrib)
lp15@56215
  1105
    qed
lp15@56215
  1106
  } note ** = this
lp15@56215
  1107
  show ?thesis
lp15@56215
  1108
  unfolding has_field_derivative_def
lp15@56215
  1109
  proof (rule has_derivative_series [OF cvs _ _ x])
lp15@56215
  1110
    fix n x
lp15@56215
  1111
    assume "x \<in> s"
lp15@56215
  1112
    then show "((f n) has_derivative (\<lambda>z. z * f' n x)) (at x within s)"
lp15@56215
  1113
      by (metis df has_field_derivative_def mult_commute_abs)
lp15@56215
  1114
  next show " ((\<lambda>n. f n x) sums l)"
lp15@56215
  1115
    by (rule sf)
lp15@56215
  1116
  next show "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. cmod ((\<Sum>i<n. h * f' i x) - g' x * h) \<le> e * cmod h"
lp15@56215
  1117
    by (blast intro: **)
lp15@56215
  1118
  qed
lp15@56215
  1119
qed
lp15@56215
  1120
lp15@56215
  1121
subsection{*Bound theorem*}
lp15@56215
  1122
lp15@56215
  1123
lemma complex_differentiable_bound:
lp15@56215
  1124
  fixes s :: "complex set"
lp15@56215
  1125
  assumes cvs: "convex s"
lp15@56215
  1126
      and df:  "\<And>z. z \<in> s \<Longrightarrow> (f has_field_derivative f' z) (at z within s)"
lp15@56215
  1127
      and dn:  "\<And>z. z \<in> s \<Longrightarrow> norm (f' z) \<le> B"
lp15@56215
  1128
      and "x \<in> s"  "y \<in> s"
lp15@56215
  1129
    shows "norm(f x - f y) \<le> B * norm(x - y)"
lp15@56215
  1130
  apply (rule differentiable_bound [OF cvs])
lp15@56215
  1131
  using assms
lp15@56215
  1132
  apply (auto simp: has_field_derivative_def Ball_def onorm_def)
lp15@56215
  1133
  apply (rule cSUP_least)
lp15@56215
  1134
  apply (auto simp: norm_mult)
lp15@56215
  1135
  apply (metis norm_one)
lp15@56215
  1136
  done
lp15@56215
  1137
lp15@56215
  1138
subsection{*Inverse function theorem for complex derivatives.*}
lp15@56215
  1139
lp15@56215
  1140
lemma has_complex_derivative_inverse_basic:
lp15@56215
  1141
  fixes f :: "complex \<Rightarrow> complex"
lp15@56215
  1142
  shows "DERIV f (g y) :> f' \<Longrightarrow>
lp15@56215
  1143
        f' \<noteq> 0 \<Longrightarrow>
lp15@56215
  1144
        continuous (at y) g \<Longrightarrow>
lp15@56215
  1145
        open t \<Longrightarrow>
lp15@56215
  1146
        y \<in> t \<Longrightarrow>
lp15@56215
  1147
        (\<And>z. z \<in> t \<Longrightarrow> f (g z) = z)
lp15@56215
  1148
        \<Longrightarrow> DERIV g y :> inverse (f')"
lp15@56215
  1149
  unfolding has_field_derivative_def
lp15@56215
  1150
  apply (rule has_derivative_inverse_basic)
lp15@56215
  1151
  apply (auto simp:  bounded_linear_mult_right)
lp15@56215
  1152
  done
lp15@56215
  1153
lp15@56215
  1154
(*Used only once, in Multivariate/cauchy.ml. *)
lp15@56215
  1155
lemma has_complex_derivative_inverse_strong:
lp15@56215
  1156
  fixes f :: "complex \<Rightarrow> complex"
lp15@56215
  1157
  shows "DERIV f x :> f' \<Longrightarrow>
lp15@56215
  1158
         f' \<noteq> 0 \<Longrightarrow>
lp15@56215
  1159
         open s \<Longrightarrow>
lp15@56215
  1160
         x \<in> s \<Longrightarrow>
lp15@56215
  1161
         continuous_on s f \<Longrightarrow>
lp15@56215
  1162
         (\<And>z. z \<in> s \<Longrightarrow> g (f z) = z)
lp15@56215
  1163
         \<Longrightarrow> DERIV g (f x) :> inverse (f')"
lp15@56215
  1164
  unfolding has_field_derivative_def
lp15@56215
  1165
  apply (rule has_derivative_inverse_strong [of s x f g ])
lp15@56215
  1166
  using assms 
lp15@56215
  1167
  by auto
lp15@56215
  1168
lp15@56215
  1169
lemma has_complex_derivative_inverse_strong_x:
lp15@56215
  1170
  fixes f :: "complex \<Rightarrow> complex"
lp15@56215
  1171
  shows  "DERIV f (g y) :> f' \<Longrightarrow>
lp15@56215
  1172
          f' \<noteq> 0 \<Longrightarrow>
lp15@56215
  1173
          open s \<Longrightarrow>
lp15@56215
  1174
          continuous_on s f \<Longrightarrow>
lp15@56215
  1175
          g y \<in> s \<Longrightarrow> f(g y) = y \<Longrightarrow>
lp15@56215
  1176
          (\<And>z. z \<in> s \<Longrightarrow> g (f z) = z)
lp15@56215
  1177
          \<Longrightarrow> DERIV g y :> inverse (f')"
lp15@56215
  1178
  unfolding has_field_derivative_def
lp15@56215
  1179
  apply (rule has_derivative_inverse_strong_x [of s g y f])
lp15@56215
  1180
  using assms 
lp15@56215
  1181
  by auto
lp15@56215
  1182
lp15@56215
  1183
subsection{*Further useful properties of complex conjugation*}
lp15@56215
  1184
lp15@56215
  1185
lemma lim_cnj: "((\<lambda>x. cnj(f x)) ---> cnj l) F \<longleftrightarrow> (f ---> l) F"
lp15@56215
  1186
  by (simp add: tendsto_iff dist_complex_def Complex.complex_cnj_diff [symmetric])
lp15@56215
  1187
lp15@56215
  1188
lemma sums_cnj: "((\<lambda>x. cnj(f x)) sums cnj l) \<longleftrightarrow> (f sums l)"
lp15@56215
  1189
  by (simp add: sums_def lim_cnj cnj_setsum [symmetric])
lp15@56215
  1190
lp15@56215
  1191
lemma continuous_within_cnj: "continuous (at z within s) cnj"
lp15@56215
  1192
by (metis bounded_linear_cnj linear_continuous_within)
lp15@56215
  1193
lp15@56215
  1194
lemma continuous_on_cnj: "continuous_on s cnj"
lp15@56215
  1195
by (metis bounded_linear_cnj linear_continuous_on)
lp15@56215
  1196
lp15@56215
  1197
subsection{*Some limit theorems about real part of real series etc.*}
lp15@56215
  1198
lp15@56215
  1199
lemma real_lim:
lp15@56215
  1200
  fixes l::complex
lp15@56215
  1201
  assumes "(f ---> l) F" and " ~(trivial_limit F)" and "eventually P F" and "\<And>a. P a \<Longrightarrow> f a \<in> \<real>"
lp15@56215
  1202
  shows  "l \<in> \<real>"
lp15@56215
  1203
proof -
lp15@56215
  1204
  have 1: "((\<lambda>i. Im (f i)) ---> Im l) F"
lp15@56215
  1205
    by (metis assms(1) tendsto_Im) 
lp15@56215
  1206
  then have  "((\<lambda>i. Im (f i)) ---> 0) F"
lp15@56215
  1207
    by (smt2 Lim_eventually assms(3) assms(4) complex_is_Real_iff eventually_elim2)
lp15@56215
  1208
  then show ?thesis using 1
lp15@56215
  1209
    by (metis 1 assms(2) complex_is_Real_iff tendsto_unique) 
lp15@56215
  1210
qed
lp15@56215
  1211
lp15@56215
  1212
lemma real_lim_sequentially:
lp15@56215
  1213
  fixes l::complex
lp15@56215
  1214
  shows "(f ---> l) sequentially \<Longrightarrow> (\<exists>N. \<forall>n\<ge>N. f n \<in> \<real>) \<Longrightarrow> l \<in> \<real>"
lp15@56215
  1215
by (rule real_lim [where F=sequentially]) (auto simp: eventually_sequentially)
lp15@56215
  1216
lp15@56215
  1217
lemma real_series: 
lp15@56215
  1218
  fixes l::complex
lp15@56215
  1219
  shows "f sums l \<Longrightarrow> (\<And>n. f n \<in> \<real>) \<Longrightarrow> l \<in> \<real>"
lp15@56215
  1220
unfolding sums_def
lp15@56215
  1221
by (metis real_lim_sequentially setsum_in_Reals)
lp15@56215
  1222
lp15@56215
  1223
lp15@56215
  1224
lemma Lim_null_comparison_Re:
lp15@56215
  1225
   "eventually (\<lambda>x. norm(f x) \<le> Re(g x)) F \<Longrightarrow>  (g ---> 0) F \<Longrightarrow> (f ---> 0) F"
lp15@56215
  1226
  by (metis Lim_null_comparison complex_Re_zero tendsto_Re)
lp15@56215
  1227
lp15@56215
  1228
lp15@56215
  1229
lemma norm_setsum_bound:
lp15@56215
  1230
  fixes n::nat
lp15@56215
  1231
  shows" \<lbrakk>\<And>n. N \<le> n \<Longrightarrow> norm (f n) \<le> g n; N \<le> m\<rbrakk>
lp15@56215
  1232
       \<Longrightarrow> norm (setsum f {m..<n}) \<le> setsum g {m..<n}"
lp15@56215
  1233
apply (induct n, auto)
lp15@56215
  1234
by (metis dual_order.trans le_cases le_neq_implies_less norm_triangle_mono)
lp15@56215
  1235
lp15@56215
  1236
(*Replaces the one in Series*)
lp15@56215
  1237
lemma summable_comparison_test:
lp15@56215
  1238
  fixes f:: "nat \<Rightarrow> 'a::banach" 
lp15@56215
  1239
  shows "summable g \<Longrightarrow> (\<And>n. n \<ge> N \<Longrightarrow> norm(f n) \<le> g n) \<Longrightarrow> summable f"
lp15@56215
  1240
apply (auto simp: Series.summable_Cauchy)  
lp15@56215
  1241
apply (drule_tac x = e in spec, auto)
lp15@56215
  1242
apply (rule_tac x="max N Na" in exI, auto)
lp15@56215
  1243
by (smt2 norm_setsum_bound)
lp15@56215
  1244
lp15@56215
  1245
(*MOVE TO Finite_Cartesian_Product*)
lp15@56215
  1246
lemma sums_vec_nth :
lp15@56215
  1247
  assumes "f sums a"
lp15@56215
  1248
  shows "(\<lambda>x. f x $ i) sums a $ i"
lp15@56215
  1249
using assms unfolding sums_def
lp15@56215
  1250
by (auto dest: tendsto_vec_nth [where i=i])
lp15@56215
  1251
lp15@56215
  1252
lemma summable_vec_nth :
lp15@56215
  1253
  assumes "summable f"
lp15@56215
  1254
  shows "summable (\<lambda>x. f x $ i)"
lp15@56215
  1255
using assms unfolding summable_def
lp15@56215
  1256
by (blast intro: sums_vec_nth)
lp15@56215
  1257
lp15@56215
  1258
(*REPLACE THE ONES IN COMPLEX.THY*)
lp15@56215
  1259
lemma Re_setsum: "Re(setsum f s) = setsum (%x. Re(f x)) s"
lp15@56215
  1260
apply (cases "finite s")
lp15@56215
  1261
  by (induct s rule: finite_induct) auto
lp15@56215
  1262
lp15@56215
  1263
lemma Im_setsum: "Im(setsum f s) = setsum (%x. Im(f x)) s"
lp15@56215
  1264
apply (cases "finite s")
lp15@56215
  1265
  by (induct s rule: finite_induct) auto
lp15@56215
  1266
lp15@56215
  1267
lemma of_real_setsum: "of_real (setsum f s) = setsum (%x. of_real(f x)) s"
lp15@56215
  1268
apply (cases "finite s")
lp15@56215
  1269
  by (induct s rule: finite_induct) auto
lp15@56215
  1270
lp15@56215
  1271
lemma of_real_setprod: "of_real (setprod f s) = setprod (%x. of_real(f x)) s"
lp15@56215
  1272
apply (cases "finite s")
lp15@56215
  1273
  by (induct s rule: finite_induct) auto
lp15@56215
  1274
lp15@56215
  1275
lemma sums_Re:
lp15@56215
  1276
  assumes "f sums a"
lp15@56215
  1277
  shows "(\<lambda>x. Re (f x)) sums Re a"
lp15@56215
  1278
using assms 
lp15@56215
  1279
by (auto simp: sums_def Re_setsum [symmetric] isCont_tendsto_compose [of a Re])
lp15@56215
  1280
lp15@56215
  1281
lemma sums_Im:
lp15@56215
  1282
  assumes "f sums a"
lp15@56215
  1283
  shows "(\<lambda>x. Im (f x)) sums Im a"
lp15@56215
  1284
using assms 
lp15@56215
  1285
by (auto simp: sums_def Im_setsum [symmetric] isCont_tendsto_compose [of a Im])
lp15@56215
  1286
lp15@56215
  1287
lemma summable_Re:
lp15@56215
  1288
  assumes "summable f"
lp15@56215
  1289
  shows "summable (\<lambda>x. Re (f x))"
lp15@56215
  1290
using assms unfolding summable_def
lp15@56215
  1291
by (blast intro: sums_Re)
lp15@56215
  1292
lp15@56215
  1293
lemma summable_Im:
lp15@56215
  1294
  assumes "summable f"
lp15@56215
  1295
  shows "summable (\<lambda>x. Im (f x))"
lp15@56215
  1296
using assms unfolding summable_def
lp15@56215
  1297
by (blast intro: sums_Im)
lp15@56215
  1298
lp15@56215
  1299
lemma series_comparison_complex:
lp15@56215
  1300
  fixes f:: "nat \<Rightarrow> 'a::banach"
lp15@56215
  1301
  assumes sg: "summable g"
lp15@56215
  1302
     and "\<And>n. g n \<in> \<real>" "\<And>n. Re (g n) \<ge> 0"
lp15@56215
  1303
     and fg: "\<And>n. n \<ge> N \<Longrightarrow> norm(f n) \<le> norm(g n)"
lp15@56215
  1304
  shows "summable f"
lp15@56215
  1305
proof -
lp15@56215
  1306
  have g: "\<And>n. cmod (g n) = Re (g n)" using assms
lp15@56215
  1307
    by (metis abs_of_nonneg in_Reals_norm)
lp15@56215
  1308
  show ?thesis
lp15@56215
  1309
    apply (rule summable_comparison_test [where g = "\<lambda>n. norm (g n)" and N=N])
lp15@56215
  1310
    using sg
lp15@56215
  1311
    apply (auto simp: summable_def)
lp15@56215
  1312
    apply (rule_tac x="Re s" in exI)
lp15@56215
  1313
    apply (auto simp: g sums_Re)
lp15@56215
  1314
    apply (metis fg g)
lp15@56215
  1315
    done
lp15@56215
  1316
qed
lp15@56215
  1317
lp15@56215
  1318
lemma summable_complex_of_real [simp]:
lp15@56215
  1319
  "summable (\<lambda>n. complex_of_real (f n)) = summable f"
lp15@56215
  1320
apply (auto simp: Series.summable_Cauchy)  
lp15@56215
  1321
apply (drule_tac x = e in spec, auto)
lp15@56215
  1322
apply (rule_tac x=N in exI)
lp15@56215
  1323
apply (auto simp: of_real_setsum [symmetric])
lp15@56215
  1324
done
lp15@56215
  1325
lp15@56215
  1326
lp15@56215
  1327
(* ------------------------------------------------------------------------- *)
lp15@56215
  1328
(* A kind of complex Taylor theorem.                                         *)
lp15@56215
  1329
(* ------------------------------------------------------------------------- *)
lp15@56215
  1330
lp15@56215
  1331
lp15@56215
  1332
lemma setsum_Suc_reindex:
lp15@56215
  1333
  fixes f :: "nat \<Rightarrow> 'a::ab_group_add"
lp15@56215
  1334
    shows  "setsum f {0..n} = f 0 - f (Suc n) + setsum (\<lambda>i. f (Suc i)) {0..n}"
lp15@56215
  1335
by (induct n) auto
lp15@56215
  1336
lp15@56215
  1337
(*REPLACE THE REAL VERSIONS*)
lp15@56215
  1338
lemma mult_left_cancel:
lp15@56215
  1339
  fixes c:: "'a::ring_no_zero_divisors"
lp15@56215
  1340
  shows "c \<noteq> 0 \<Longrightarrow> (c*a=c*b) = (a=b)"
lp15@56215
  1341
by simp 
lp15@56215
  1342
lp15@56215
  1343
lemma mult_right_cancel:
lp15@56215
  1344
  fixes c:: "'a::ring_no_zero_divisors"
lp15@56215
  1345
  shows "c \<noteq> 0 \<Longrightarrow> (a*c=b*c) = (a=b)"
lp15@56215
  1346
by simp 
lp15@56215
  1347
lp15@56215
  1348
lemma complex_taylor:
lp15@56215
  1349
  assumes s: "convex s" 
lp15@56215
  1350
      and f: "\<And>i x. x \<in> s \<Longrightarrow> i \<le> n \<Longrightarrow> (f i has_field_derivative f (Suc i) x) (at x within s)"
lp15@56215
  1351
      and B: "\<And>x. x \<in> s \<Longrightarrow> cmod (f (Suc n) x) \<le> B"
lp15@56215
  1352
      and w: "w \<in> s"
lp15@56215
  1353
      and z: "z \<in> s"
lp15@56215
  1354
    shows "cmod(f 0 z - (\<Sum>i\<le>n. f i w * (z-w) ^ i / of_nat (fact i)))
lp15@56215
  1355
          \<le> B * cmod(z - w)^(Suc n) / fact n"
lp15@56215
  1356
proof -
lp15@56215
  1357
  have wzs: "closed_segment w z \<subseteq> s" using assms
lp15@56215
  1358
    by (metis convex_contains_segment)
lp15@56215
  1359
  { fix u
lp15@56215
  1360
    assume "u \<in> closed_segment w z"
lp15@56215
  1361
    then have "u \<in> s"
lp15@56215
  1362
      by (metis wzs subsetD)
lp15@56215
  1363
    have "(\<Sum>i\<le>n. f i u * (- of_nat i * (z-u)^(i - 1)) / of_nat (fact i) +
lp15@56215
  1364
                      f (Suc i) u * (z-u)^i / of_nat (fact i)) = 
lp15@56215
  1365
              f (Suc n) u * (z-u) ^ n / of_nat (fact n)"
lp15@56215
  1366
    proof (induction n)
lp15@56215
  1367
      case 0 show ?case by simp
lp15@56215
  1368
    next
lp15@56215
  1369
      case (Suc n)
lp15@56215
  1370
      have "(\<Sum>i\<le>Suc n. f i u * (- of_nat i * (z-u) ^ (i - 1)) / of_nat (fact i) +
lp15@56215
  1371
                             f (Suc i) u * (z-u) ^ i / of_nat (fact i)) =  
lp15@56215
  1372
           f (Suc n) u * (z-u) ^ n / of_nat (fact n) +
lp15@56215
  1373
           f (Suc (Suc n)) u * ((z-u) * (z-u) ^ n) / of_nat (fact (Suc n)) -
lp15@56215
  1374
           f (Suc n) u * ((1 + of_nat n) * (z-u) ^ n) / of_nat (fact (Suc n))"
lp15@56215
  1375
        using Suc by simp
lp15@56215
  1376
      also have "... = f (Suc (Suc n)) u * (z-u) ^ Suc n / of_nat (fact (Suc n))"
lp15@56215
  1377
      proof -
lp15@56215
  1378
        have "of_nat(fact(Suc n)) *
lp15@56215
  1379
             (f(Suc n) u *(z-u) ^ n / of_nat(fact n) +
lp15@56215
  1380
               f(Suc(Suc n)) u *((z-u) *(z-u) ^ n) / of_nat(fact(Suc n)) -
lp15@56215
  1381
               f(Suc n) u *((1 + of_nat n) *(z-u) ^ n) / of_nat(fact(Suc n))) =
lp15@56215
  1382
            (of_nat(fact(Suc n)) *(f(Suc n) u *(z-u) ^ n)) / of_nat(fact n) +
lp15@56215
  1383
            (of_nat(fact(Suc n)) *(f(Suc(Suc n)) u *((z-u) *(z-u) ^ n)) / of_nat(fact(Suc n))) -
lp15@56215
  1384
            (of_nat(fact(Suc n)) *(f(Suc n) u *(of_nat(Suc n) *(z-u) ^ n))) / of_nat(fact(Suc n))"
lp15@56215
  1385
          by (simp add: algebra_simps del: fact_Suc)
lp15@56215
  1386
        also have "... =
lp15@56215
  1387
                   (of_nat (fact (Suc n)) * (f (Suc n) u * (z-u) ^ n)) / of_nat (fact n) +
lp15@56215
  1388
                   (f (Suc (Suc n)) u * ((z-u) * (z-u) ^ n)) -
lp15@56215
  1389
                   (f (Suc n) u * ((1 + of_nat n) * (z-u) ^ n))"
lp15@56215
  1390
          by (simp del: fact_Suc)
lp15@56215
  1391
        also have "... = 
lp15@56215
  1392
                   (of_nat (Suc n) * (f (Suc n) u * (z-u) ^ n)) +
lp15@56215
  1393
                   (f (Suc (Suc n)) u * ((z-u) * (z-u) ^ n)) -
lp15@56215
  1394
                   (f (Suc n) u * ((1 + of_nat n) * (z-u) ^ n))"
lp15@56215
  1395
          by (simp only: fact_Suc of_nat_mult mult_ac) simp
lp15@56215
  1396
        also have "... = f (Suc (Suc n)) u * ((z-u) * (z-u) ^ n)"
lp15@56215
  1397
          by (simp add: algebra_simps)
lp15@56215
  1398
        finally show ?thesis
lp15@56215
  1399
        by (simp add: mult_left_cancel [where c = "of_nat (fact (Suc n))", THEN iffD1] del: fact_Suc)
lp15@56215
  1400
      qed
lp15@56215
  1401
      finally show ?case .
lp15@56215
  1402
    qed
lp15@56215
  1403
    then have "((\<lambda>v. (\<Sum>i\<le>n. f i v * (z - v)^i / of_nat (fact i))) 
lp15@56215
  1404
                has_field_derivative f (Suc n) u * (z-u) ^ n / of_nat (fact n))
lp15@56215
  1405
               (at u within s)"
lp15@56215
  1406
      apply (intro DERIV_intros DERIV_power[THEN DERIV_cong])
lp15@56215
  1407
      apply (blast intro: assms `u \<in> s`)
lp15@56215
  1408
      apply (rule refl)+
lp15@56215
  1409
      apply (auto simp: field_simps)
lp15@56215
  1410
      done
lp15@56215
  1411
  } note sum_deriv = this
lp15@56215
  1412
  { fix u
lp15@56215
  1413
    assume u: "u \<in> closed_segment w z"
lp15@56215
  1414
    then have us: "u \<in> s"
lp15@56215
  1415
      by (metis wzs subsetD)
lp15@56215
  1416
    have "cmod (f (Suc n) u) * cmod (z - u) ^ n \<le> cmod (f (Suc n) u) * cmod (u - z) ^ n"
lp15@56215
  1417
      by (metis norm_minus_commute order_refl)
lp15@56215
  1418
    also have "... \<le> cmod (f (Suc n) u) * cmod (z - w) ^ n"
lp15@56215
  1419
      by (metis mult_left_mono norm_ge_zero power_mono segment_bound [OF u])
lp15@56215
  1420
    also have "... \<le> B * cmod (z - w) ^ n"
lp15@56215
  1421
      by (metis norm_ge_zero zero_le_power mult_right_mono  B [OF us])
lp15@56215
  1422
    finally have "cmod (f (Suc n) u) * cmod (z - u) ^ n \<le> B * cmod (z - w) ^ n" .
lp15@56215
  1423
  } note cmod_bound = this
lp15@56215
  1424
  have "(\<Sum>i\<le>n. f i z * (z - z) ^ i / of_nat (fact i)) = (\<Sum>i\<le>n. (f i z / of_nat (fact i)) * 0 ^ i)"
lp15@56215
  1425
    by simp
lp15@56215
  1426
  also have "\<dots> = f 0 z / of_nat (fact 0)"
lp15@56215
  1427
    by (subst setsum_zero_power) simp
lp15@56215
  1428
  finally have "cmod (f 0 z - (\<Sum>i\<le>n. f i w * (z - w) ^ i / of_nat (fact i))) 
lp15@56215
  1429
            \<le> cmod ((\<Sum>i\<le>n. f i w * (z - w) ^ i / of_nat (fact i)) -
lp15@56215
  1430
                    (\<Sum>i\<le>n. f i z * (z - z) ^ i / of_nat (fact i)))"
lp15@56215
  1431
    by (simp add: norm_minus_commute)
lp15@56215
  1432
  also have "... \<le> B * cmod (z - w) ^ n / real_of_nat (fact n) * cmod (w - z)"
lp15@56215
  1433
    apply (rule complex_differentiable_bound 
lp15@56215
  1434
      [where f' = "\<lambda>w. f (Suc n) w * (z - w)^n / of_nat(fact n)"
lp15@56215
  1435
         and s = "closed_segment w z", OF convex_segment])
lp15@56215
  1436
    apply (auto simp: ends_in_segment real_of_nat_def DERIV_subset [OF sum_deriv wzs]
lp15@56215
  1437
                  norm_divide norm_mult norm_power divide_le_cancel cmod_bound)
lp15@56215
  1438
    done
lp15@56215
  1439
  also have "...  \<le> B * cmod (z - w) ^ Suc n / real (fact n)"
lp15@56215
  1440
    by (simp add: algebra_simps norm_minus_commute real_of_nat_def)
lp15@56215
  1441
  finally show ?thesis .
lp15@56215
  1442
qed
lp15@56215
  1443
lp15@56215
  1444
end
lp15@56215
  1445