src/HOL/Multivariate_Analysis/Generalised_Binomial_Theorem.thy
 author hoelzl Fri Feb 19 13:40:50 2016 +0100 (2016-02-19) changeset 62378 85ed00c1fe7c parent 62131 1baed43f453e child 62390 842917225d56 permissions -rw-r--r--
generalize more theorems to support enat and ennreal
```     1 (*  Title:    HOL/Multivariate_Analysis/Generalised_Binomial_Theorem.thy
```
```     2     Author:   Manuel Eberl, TU München
```
```     3 *)
```
```     4
```
```     5 section \<open>Generalised Binomial Theorem\<close>
```
```     6
```
```     7 text \<open>
```
```     8   The proof of the Generalised Binomial Theorem and related results.
```
```     9   We prove the generalised binomial theorem for complex numbers, following the proof at:
```
```    10   \url{https://proofwiki.org/wiki/Binomial_Theorem/General_Binomial_Theorem}
```
```    11 \<close>
```
```    12
```
```    13 theory Generalised_Binomial_Theorem
```
```    14 imports
```
```    15   Complex_Main
```
```    16   Complex_Transcendental
```
```    17   Summation
```
```    18 begin
```
```    19
```
```    20 lemma gbinomial_ratio_limit:
```
```    21   fixes a :: "'a :: real_normed_field"
```
```    22   assumes "a \<notin> \<nat>"
```
```    23   shows "(\<lambda>n. (a gchoose n) / (a gchoose Suc n)) \<longlonglongrightarrow> -1"
```
```    24 proof (rule Lim_transform_eventually)
```
```    25   let ?f = "\<lambda>n. inverse (a / of_nat (Suc n) - of_nat n / of_nat (Suc n))"
```
```    26   from eventually_gt_at_top[of "0::nat"]
```
```    27     show "eventually (\<lambda>n. ?f n = (a gchoose n) /(a gchoose Suc n)) sequentially"
```
```    28   proof eventually_elim
```
```    29     fix n :: nat assume n: "n > 0"
```
```    30     let ?P = "\<Prod>i = 0..n - 1. a - of_nat i"
```
```    31     from n have "(a gchoose n) / (a gchoose Suc n) = (of_nat (Suc n) :: 'a) *
```
```    32                    (?P / (\<Prod>i = 0..n. a - of_nat i))" by (simp add: gbinomial_def)
```
```    33     also from n have "(\<Prod>i = 0..n. a - of_nat i) = ?P * (a - of_nat n)"
```
```    34       by (cases n) (simp_all add: setprod_nat_ivl_Suc)
```
```    35     also have "?P / \<dots> = (?P / ?P) / (a - of_nat n)" by (rule divide_divide_eq_left[symmetric])
```
```    36     also from assms have "?P / ?P = 1" by auto
```
```    37     also have "of_nat (Suc n) * (1 / (a - of_nat n)) =
```
```    38                    inverse (inverse (of_nat (Suc n)) * (a - of_nat n))" by (simp add: field_simps)
```
```    39     also have "inverse (of_nat (Suc n)) * (a - of_nat n) = a / of_nat (Suc n) - of_nat n / of_nat (Suc n)"
```
```    40       by (simp add: field_simps del: of_nat_Suc)
```
```    41     finally show "?f n = (a gchoose n) / (a gchoose Suc n)" by simp
```
```    42   qed
```
```    43
```
```    44   have "(\<lambda>n. norm a / (of_nat (Suc n))) \<longlonglongrightarrow> 0"
```
```    45     unfolding divide_inverse
```
```    46     by (intro tendsto_mult_right_zero LIMSEQ_inverse_real_of_nat)
```
```    47   hence "(\<lambda>n. a / of_nat (Suc n)) \<longlonglongrightarrow> 0"
```
```    48     by (subst tendsto_norm_zero_iff[symmetric]) (simp add: norm_divide del: of_nat_Suc)
```
```    49   hence "?f \<longlonglongrightarrow> inverse (0 - 1)"
```
```    50     by (intro tendsto_inverse tendsto_diff LIMSEQ_n_over_Suc_n) simp_all
```
```    51   thus "?f \<longlonglongrightarrow> -1" by simp
```
```    52 qed
```
```    53
```
```    54 lemma conv_radius_gchoose:
```
```    55   fixes a :: "'a :: {real_normed_field,banach}"
```
```    56   shows "conv_radius (\<lambda>n. a gchoose n) = (if a \<in> \<nat> then \<infinity> else 1)"
```
```    57 proof (cases "a \<in> \<nat>")
```
```    58   assume a: "a \<in> \<nat>"
```
```    59   have "eventually (\<lambda>n. (a gchoose n) = 0) sequentially"
```
```    60     using eventually_gt_at_top[of "nat \<lfloor>norm a\<rfloor>"]
```
```    61     by eventually_elim (insert a, auto elim!: Nats_cases simp: binomial_gbinomial[symmetric])
```
```    62   from conv_radius_cong[OF this] a show ?thesis by simp
```
```    63 next
```
```    64   assume a: "a \<notin> \<nat>"
```
```    65   from tendsto_norm[OF gbinomial_ratio_limit[OF this]]
```
```    66     have "conv_radius (\<lambda>n. a gchoose n) = 1"
```
```    67     by (intro conv_radius_ratio_limit_nonzero[of _ 1]) (simp_all add: norm_divide)
```
```    68   with a show ?thesis by simp
```
```    69 qed
```
```    70
```
```    71 lemma gen_binomial_complex:
```
```    72   fixes z :: complex
```
```    73   assumes "norm z < 1"
```
```    74   shows   "(\<lambda>n. (a gchoose n) * z^n) sums (1 + z) powr a"
```
```    75 proof -
```
```    76   def K \<equiv> "1 - (1 - norm z) / 2"
```
```    77   from assms have K: "K > 0" "K < 1" "norm z < K"
```
```    78      unfolding K_def by (auto simp: field_simps intro!: add_pos_nonneg)
```
```    79   let ?f = "\<lambda>n. a gchoose n" and ?f' = "diffs (\<lambda>n. a gchoose n)"
```
```    80   have summable_strong: "summable (\<lambda>n. ?f n * z ^ n)" if "norm z < 1" for z using that
```
```    81     by (intro summable_in_conv_radius) (simp_all add: conv_radius_gchoose)
```
```    82   with K have summable: "summable (\<lambda>n. ?f n * z ^ n)" if "norm z < K" for z using that by auto
```
```    83   hence summable': "summable (\<lambda>n. ?f' n * z ^ n)" if "norm z < K" for z using that
```
```    84     by (intro termdiff_converges[of _ K]) simp_all
```
```    85
```
```    86   def f \<equiv> "\<lambda>z. \<Sum>n. ?f n * z ^ n" and f' \<equiv> "\<lambda>z. \<Sum>n. ?f' n * z ^ n"
```
```    87   {
```
```    88     fix z :: complex assume z: "norm z < K"
```
```    89     from summable_mult2[OF summable'[OF z], of z]
```
```    90       have summable1: "summable (\<lambda>n. ?f' n * z ^ Suc n)" by (simp add: mult_ac)
```
```    91     hence summable2: "summable (\<lambda>n. of_nat n * ?f n * z^n)"
```
```    92       unfolding diffs_def by (subst (asm) summable_Suc_iff)
```
```    93
```
```    94     have "(1 + z) * f' z = (\<Sum>n. ?f' n * z^n) + (\<Sum>n. ?f' n * z^Suc n)"
```
```    95       unfolding f'_def using summable' z by (simp add: algebra_simps suminf_mult)
```
```    96     also have "(\<Sum>n. ?f' n * z^n) = (\<Sum>n. of_nat (Suc n) * ?f (Suc n) * z^n)"
```
```    97       by (intro suminf_cong) (simp add: diffs_def)
```
```    98     also have "(\<Sum>n. ?f' n * z^Suc n) = (\<Sum>n. of_nat n * ?f n * z ^ n)"
```
```    99       using summable1 suminf_split_initial_segment[OF summable1] unfolding diffs_def
```
```   100       by (subst suminf_split_head, subst (asm) summable_Suc_iff) simp_all
```
```   101     also have "(\<Sum>n. of_nat (Suc n) * ?f (Suc n) * z^n) + (\<Sum>n. of_nat n * ?f n * z^n) =
```
```   102                  (\<Sum>n. a * ?f n * z^n)"
```
```   103       by (subst gbinomial_mult_1, subst suminf_add)
```
```   104          (insert summable'[OF z] summable2,
```
```   105           simp_all add: summable_powser_split_head algebra_simps diffs_def)
```
```   106     also have "\<dots> = a * f z" unfolding f_def
```
```   107       by (subst suminf_mult[symmetric]) (simp_all add: summable[OF z] mult_ac)
```
```   108     finally have "a * f z = (1 + z) * f' z" by simp
```
```   109   } note deriv = this
```
```   110
```
```   111   have [derivative_intros]: "(f has_field_derivative f' z) (at z)" if "norm z < of_real K" for z
```
```   112     unfolding f_def f'_def using K that
```
```   113     by (intro termdiffs_strong[of "?f" K z] summable_strong) simp_all
```
```   114   have "f 0 = (\<Sum>n. if n = 0 then 1 else 0)" unfolding f_def by (intro suminf_cong) simp
```
```   115   also have "\<dots> = 1" using sums_single[of 0 "\<lambda>_. 1::complex"] unfolding sums_iff by simp
```
```   116   finally have [simp]: "f 0 = 1" .
```
```   117
```
```   118   have "\<exists>c. \<forall>z\<in>ball 0 K. f z * (1 + z) powr (-a) = c"
```
```   119   proof (rule has_field_derivative_zero_constant)
```
```   120     fix z :: complex assume z': "z \<in> ball 0 K"
```
```   121     hence z: "norm z < K" by (simp add: dist_0_norm)
```
```   122     with K have nz: "1 + z \<noteq> 0" by (auto dest!: minus_unique)
```
```   123     from z K have "norm z < 1" by simp
```
```   124     hence "(1 + z) \<notin> \<real>\<^sub>\<le>\<^sub>0" by (cases z) (auto simp: complex_nonpos_Reals_iff)
```
```   125     hence "((\<lambda>z. f z * (1 + z) powr (-a)) has_field_derivative
```
```   126               f' z * (1 + z) powr (-a) - a * f z * (1 + z) powr (-a-1)) (at z)" using z
```
```   127       by (auto intro!: derivative_eq_intros)
```
```   128     also from z have "a * f z = (1 + z) * f' z" by (rule deriv)
```
```   129     finally show "((\<lambda>z. f z * (1 + z) powr (-a)) has_field_derivative 0) (at z within ball 0 K)"
```
```   130       using nz by (simp add: field_simps powr_diff_complex at_within_open[OF z'])
```
```   131   qed simp_all
```
```   132   then obtain c where c: "\<And>z. z \<in> ball 0 K \<Longrightarrow> f z * (1 + z) powr (-a) = c" by blast
```
```   133   from c[of 0] and K have "c = 1" by simp
```
```   134   with c[of z] have "f z = (1 + z) powr a" using K
```
```   135     by (simp add: powr_minus_complex field_simps dist_complex_def)
```
```   136   with summable K show ?thesis unfolding f_def by (simp add: sums_iff)
```
```   137 qed
```
```   138
```
```   139 lemma gen_binomial_complex':
```
```   140   fixes x y :: real and a :: complex
```
```   141   assumes "\<bar>x\<bar> < \<bar>y\<bar>"
```
```   142   shows   "(\<lambda>n. (a gchoose n) * of_real x^n * of_real y powr (a - of_nat n)) sums
```
```   143                of_real (x + y) powr a" (is "?P x y")
```
```   144 proof -
```
```   145   {
```
```   146     fix x y :: real assume xy: "\<bar>x\<bar> < \<bar>y\<bar>" "y \<ge> 0"
```
```   147     hence "y > 0" by simp
```
```   148     note xy = xy this
```
```   149     from xy have "(\<lambda>n. (a gchoose n) * of_real (x / y) ^ n) sums (1 + of_real (x / y)) powr a"
```
```   150         by (intro gen_binomial_complex) (simp add: norm_divide)
```
```   151     hence "(\<lambda>n. (a gchoose n) * of_real (x / y) ^ n * y powr a) sums
```
```   152                ((1 + of_real (x / y)) powr a * y powr a)"
```
```   153       by (rule sums_mult2)
```
```   154     also have "(1 + complex_of_real (x / y)) = complex_of_real (1 + x/y)" by simp
```
```   155     also from xy have "\<dots> powr a * of_real y powr a = (\<dots> * y) powr a"
```
```   156       by (subst powr_times_real[symmetric]) (simp_all add: field_simps)
```
```   157     also from xy have "complex_of_real (1 + x / y) * complex_of_real y = of_real (x + y)"
```
```   158       by (simp add: field_simps)
```
```   159     finally have "?P x y" using xy by (simp add: field_simps powr_diff_complex powr_nat)
```
```   160   } note A = this
```
```   161
```
```   162   show ?thesis
```
```   163   proof (cases "y < 0")
```
```   164     assume y: "y < 0"
```
```   165     with assms have xy: "x + y < 0" by simp
```
```   166     with assms have "\<bar>-x\<bar> < \<bar>-y\<bar>" "-y \<ge> 0" by simp_all
```
```   167     note A[OF this]
```
```   168     also have "complex_of_real (-x + -y) = - complex_of_real (x + y)" by simp
```
```   169     also from xy assms have "... powr a = (-1) powr -a * of_real (x + y) powr a"
```
```   170       by (subst powr_neg_real_complex) (simp add: abs_real_def split: split_if_asm)
```
```   171     also {
```
```   172       fix n :: nat
```
```   173       from y have "(a gchoose n) * of_real (-x) ^ n * of_real (-y) powr (a - of_nat n) =
```
```   174                        (a gchoose n) * (-of_real x / -of_real y) ^ n * (- of_real y) powr a"
```
```   175         by (subst power_divide) (simp add: powr_diff_complex powr_nat)
```
```   176       also from y have "(- of_real y) powr a = (-1) powr -a * of_real y powr a"
```
```   177         by (subst powr_neg_real_complex) simp
```
```   178       also have "-complex_of_real x / -complex_of_real y = complex_of_real x / complex_of_real y"
```
```   179         by simp
```
```   180       also have "... ^ n = of_real x ^ n / of_real y ^ n" by (simp add: power_divide)
```
```   181       also have "(a gchoose n) * ... * ((-1) powr -a * of_real y powr a) =
```
```   182                    (-1) powr -a * ((a gchoose n) * of_real x ^ n * of_real y powr (a - n))"
```
```   183         by (simp add: algebra_simps powr_diff_complex powr_nat)
```
```   184       finally have "(a gchoose n) * of_real (- x) ^ n * of_real (- y) powr (a - of_nat n) =
```
```   185                       (-1) powr -a * ((a gchoose n) * of_real x ^ n * of_real y powr (a - of_nat n))" .
```
```   186     }
```
```   187     note sums_cong[OF this]
```
```   188     finally show ?thesis by (simp add: sums_mult_iff)
```
```   189   qed (insert A[of x y] assms, simp_all add: not_less)
```
```   190 qed
```
```   191
```
```   192 lemma gen_binomial_complex'':
```
```   193   fixes x y :: real and a :: complex
```
```   194   assumes "\<bar>y\<bar> < \<bar>x\<bar>"
```
```   195   shows   "(\<lambda>n. (a gchoose n) * of_real x powr (a - of_nat n) * of_real y ^ n) sums
```
```   196                of_real (x + y) powr a"
```
```   197   using gen_binomial_complex'[OF assms] by (simp add: mult_ac add.commute)
```
```   198
```
```   199 lemma gen_binomial_real:
```
```   200   fixes z :: real
```
```   201   assumes "\<bar>z\<bar> < 1"
```
```   202   shows   "(\<lambda>n. (a gchoose n) * z^n) sums (1 + z) powr a"
```
```   203 proof -
```
```   204   from assms have "norm (of_real z :: complex) < 1" by simp
```
```   205   from gen_binomial_complex[OF this]
```
```   206     have "(\<lambda>n. (of_real a gchoose n :: complex) * of_real z ^ n) sums
```
```   207               (of_real (1 + z)) powr (of_real a)" by simp
```
```   208   also have "(of_real (1 + z) :: complex) powr (of_real a) = of_real ((1 + z) powr a)"
```
```   209     using assms by (subst powr_of_real) simp_all
```
```   210   also have "(of_real a gchoose n :: complex) = of_real (a gchoose n)" for n
```
```   211     by (simp add: gbinomial_def)
```
```   212   hence "(\<lambda>n. (of_real a gchoose n :: complex) * of_real z ^ n) =
```
```   213            (\<lambda>n. of_real ((a gchoose n) * z ^ n))" by (intro ext) simp
```
```   214   finally show ?thesis by (simp only: sums_of_real_iff)
```
```   215 qed
```
```   216
```
```   217 lemma gen_binomial_real':
```
```   218   fixes x y a :: real
```
```   219   assumes "\<bar>x\<bar> < y"
```
```   220   shows   "(\<lambda>n. (a gchoose n) * x^n * y powr (a - of_nat n)) sums (x + y) powr a"
```
```   221 proof -
```
```   222   from assms have "y > 0" by simp
```
```   223   note xy = this assms
```
```   224   from assms have "\<bar>x / y\<bar> < 1" by simp
```
```   225   hence "(\<lambda>n. (a gchoose n) * (x / y) ^ n) sums (1 + x / y) powr a"
```
```   226     by (rule gen_binomial_real)
```
```   227   hence "(\<lambda>n. (a gchoose n) * (x / y) ^ n * y powr a) sums ((1 + x / y) powr a * y powr a)"
```
```   228     by (rule sums_mult2)
```
```   229   with xy show ?thesis
```
```   230     by (simp add: field_simps powr_divide powr_divide2[symmetric] powr_realpow)
```
```   231 qed
```
```   232
```
```   233 lemma one_plus_neg_powr_powser:
```
```   234   fixes z s :: complex
```
```   235   assumes "norm (z :: complex) < 1"
```
```   236   shows "(\<lambda>n. (-1)^n * ((s + n - 1) gchoose n) * z^n) sums (1 + z) powr (-s)"
```
```   237     using gen_binomial_complex[OF assms, of "-s"] by (simp add: gbinomial_minus)
```
```   238
```
```   239 lemma gen_binomial_real'':
```
```   240   fixes x y a :: real
```
```   241   assumes "\<bar>y\<bar> < x"
```
```   242   shows   "(\<lambda>n. (a gchoose n) * x powr (a - of_nat n) * y^n) sums (x + y) powr a"
```
```   243   using gen_binomial_real'[OF assms] by (simp add: mult_ac add.commute)
```
```   244
```
```   245 lemma sqrt_series':
```
```   246   "\<bar>z\<bar> < a \<Longrightarrow> (\<lambda>n. ((1/2) gchoose n) * a powr (1/2 - real_of_nat n) * z ^ n) sums
```
```   247                   sqrt (a + z :: real)"
```
```   248   using gen_binomial_real''[of z a "1/2"] by (simp add: powr_half_sqrt)
```
```   249
```
```   250 lemma sqrt_series:
```
```   251   "\<bar>z\<bar> < 1 \<Longrightarrow> (\<lambda>n. ((1/2) gchoose n) * z ^ n) sums sqrt (1 + z)"
```
```   252   using gen_binomial_real[of z "1/2"] by (simp add: powr_half_sqrt)
```
```   253
```
`   254 end`