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